Passed
Branch master (b77c0f)
by John
04:56
created
core/modules/modSubtotal.class.php 2 patches
Indentation   +404 added lines, -404 removed lines patch added patch discarded remove patch
@@ -31,196 +31,196 @@  discard block
 block discarded – undo
31 31
 class modSubtotal extends DolibarrModules
32 32
 {
33 33
 
34
-    /**
35
-     * 	Constructor. Define names, constants, directories, boxes, permissions
36
-     *
37
-     * 	@param	DoliDB		$db	Database handler
38
-     */
34
+	/**
35
+	 * 	Constructor. Define names, constants, directories, boxes, permissions
36
+	 *
37
+	 * 	@param	DoliDB		$db	Database handler
38
+	 */
39 39
 
40
-    public function __construct($db)
41
-    {
42
-        global $langs, $conf;
40
+	public function __construct($db)
41
+	{
42
+		global $langs, $conf;
43 43
 
44
-        $this->db = $db;
44
+		$this->db = $db;
45 45
 
46 46
 		$this->editor_name = 'ATM-Consulting';
47
-        // Id for module (must be unique).
48
-        // Use a free id here
49
-        // (See in Home -> System information -> Dolibarr for list of used modules id).
50
-        $this->numero = 104777; // 104000 to 104999 for ATM CONSULTING
51
-        // Key text used to identify module (for permissions, menus, etc...)
52
-        $this->rights_class = 'subtotal';
47
+		// Id for module (must be unique).
48
+		// Use a free id here
49
+		// (See in Home -> System information -> Dolibarr for list of used modules id).
50
+		$this->numero = 104777; // 104000 to 104999 for ATM CONSULTING
51
+		// Key text used to identify module (for permissions, menus, etc...)
52
+		$this->rights_class = 'subtotal';
53 53
 
54
-        // Family can be 'crm','financial','hr','projects','products','ecm','technic','other'
55
-        // It is used to group modules in module setup page
56
-        $this->family = "technic";
57
-        // Module label (no space allowed)
58
-        // used if translation string 'ModuleXXXName' not found
59
-        // (where XXX is value of numeric property 'numero' of module)
60
-        $this->name = preg_replace('/^mod/i', '', get_class($this));
61
-        // Module description
62
-        // used if translation string 'ModuleXXXDesc' not found
63
-        // (where XXX is value of numeric property 'numero' of module)
64
-        $this->description = "Module permettant l'ajout de sous-totaux et sous-totaux intermédiaires et le déplacement d'une ligne aisée de l'un dans l'autre";
65
-        // Possible values for version are: 'development', 'experimental' or version
66
-        $this->version = '3.6.4';
54
+		// Family can be 'crm','financial','hr','projects','products','ecm','technic','other'
55
+		// It is used to group modules in module setup page
56
+		$this->family = "technic";
57
+		// Module label (no space allowed)
58
+		// used if translation string 'ModuleXXXName' not found
59
+		// (where XXX is value of numeric property 'numero' of module)
60
+		$this->name = preg_replace('/^mod/i', '', get_class($this));
61
+		// Module description
62
+		// used if translation string 'ModuleXXXDesc' not found
63
+		// (where XXX is value of numeric property 'numero' of module)
64
+		$this->description = "Module permettant l'ajout de sous-totaux et sous-totaux intermédiaires et le déplacement d'une ligne aisée de l'un dans l'autre";
65
+		// Possible values for version are: 'development', 'experimental' or version
66
+		$this->version = '3.6.4';
67 67
 
68
-        // Key used in llx_const table to save module status enabled/disabled
69
-        // (where MYMODULE is value of property name of module in uppercase)
70
-        $this->const_name = 'MAIN_MODULE_' . strtoupper($this->name);
71
-        // Where to store the module in setup page
72
-        // (0=common,1=interface,2=others,3=very specific)
73
-        $this->special = 2;
74
-        // Name of image file used for this module.
75
-        // If file is in theme/yourtheme/img directory under name object_pictovalue.png
76
-        // use this->picto='pictovalue'
77
-        // If file is in module/img directory under name object_pictovalue.png
78
-        // use this->picto='pictovalue@module'
79
-        $this->picto = 'subtotal@subtotal'; // mypicto@titre
80
-        // Defined all module parts (triggers, login, substitutions, menus, css, etc...)
81
-        // for default path (eg: /titre/core/xxxxx) (0=disable, 1=enable)
82
-        // for specific path of parts (eg: /titre/core/modules/barcode)
83
-        // for specific css file (eg: /titre/css/titre.css.php)
84
-        $this->module_parts = array(
85
-            // Set this to 1 if module has its own trigger directory
86
-            'triggers' => 1,
87
-            // Set this to 1 if module has its own login method directory
88
-            //'login' => 0,
89
-            // Set this to 1 if module has its own substitution function file
90
-            //'substitutions' => 0,
91
-            // Set this to 1 if module has its own menus handler directory
92
-            //'menus' => 0,
93
-            // Set this to 1 if module has its own barcode directory
94
-            //'barcode' => 0,
95
-            // Set this to 1 if module has its own models directory
96
-            'models' => 1,
97
-            // Set this to relative path of css if module has its own css file
98
-            //'css' => '/titre/css/mycss.css.php',
99
-            // Set here all hooks context managed by module
100
-            'hooks' => array(
101
-                'invoicecard'
102
-                ,'invoicesuppliercard'
103
-                ,'propalcard'
104
-                ,'supplier_proposalcard'
105
-                ,'ordercard'
106
-                ,'ordersuppliercard'
107
-                ,'odtgeneration'
108
-                ,'orderstoinvoice'
109
-                ,'orderstoinvoicesupplier'
110
-                ,'admin'
111
-                ,'invoicereccard'
112
-                ,'consumptionthirdparty'
113
-            	,'ordershipmentcard'
114
-            	,'expeditioncard'
68
+		// Key used in llx_const table to save module status enabled/disabled
69
+		// (where MYMODULE is value of property name of module in uppercase)
70
+		$this->const_name = 'MAIN_MODULE_' . strtoupper($this->name);
71
+		// Where to store the module in setup page
72
+		// (0=common,1=interface,2=others,3=very specific)
73
+		$this->special = 2;
74
+		// Name of image file used for this module.
75
+		// If file is in theme/yourtheme/img directory under name object_pictovalue.png
76
+		// use this->picto='pictovalue'
77
+		// If file is in module/img directory under name object_pictovalue.png
78
+		// use this->picto='pictovalue@module'
79
+		$this->picto = 'subtotal@subtotal'; // mypicto@titre
80
+		// Defined all module parts (triggers, login, substitutions, menus, css, etc...)
81
+		// for default path (eg: /titre/core/xxxxx) (0=disable, 1=enable)
82
+		// for specific path of parts (eg: /titre/core/modules/barcode)
83
+		// for specific css file (eg: /titre/css/titre.css.php)
84
+		$this->module_parts = array(
85
+			// Set this to 1 if module has its own trigger directory
86
+			'triggers' => 1,
87
+			// Set this to 1 if module has its own login method directory
88
+			//'login' => 0,
89
+			// Set this to 1 if module has its own substitution function file
90
+			//'substitutions' => 0,
91
+			// Set this to 1 if module has its own menus handler directory
92
+			//'menus' => 0,
93
+			// Set this to 1 if module has its own barcode directory
94
+			//'barcode' => 0,
95
+			// Set this to 1 if module has its own models directory
96
+			'models' => 1,
97
+			// Set this to relative path of css if module has its own css file
98
+			//'css' => '/titre/css/mycss.css.php',
99
+			// Set here all hooks context managed by module
100
+			'hooks' => array(
101
+				'invoicecard'
102
+				,'invoicesuppliercard'
103
+				,'propalcard'
104
+				,'supplier_proposalcard'
105
+				,'ordercard'
106
+				,'ordersuppliercard'
107
+				,'odtgeneration'
108
+				,'orderstoinvoice'
109
+				,'orderstoinvoicesupplier'
110
+				,'admin'
111
+				,'invoicereccard'
112
+				,'consumptionthirdparty'
113
+				,'ordershipmentcard'
114
+				,'expeditioncard'
115 115
 				,'deliverycard'
116 116
 				,'paiementcard'
117 117
 				,'referencelettersinstacecard'
118
-                ,'shippableorderlist'
118
+				,'shippableorderlist'
119 119
 				,'propallist'
120 120
 				,'orderlist'
121 121
 				,'invoicelist'
122 122
 				,'supplierorderlist'
123 123
 				,'supplierinvoicelist'
124
-            ),
125
-            // Set here all workflow context managed by module
126
-            //'workflow' => array('order' => array('WORKFLOW_ORDER_AUTOCREATE_INVOICE')),
127
-            'tpl' => 1
128
-        );
124
+			),
125
+			// Set here all workflow context managed by module
126
+			//'workflow' => array('order' => array('WORKFLOW_ORDER_AUTOCREATE_INVOICE')),
127
+			'tpl' => 1
128
+		);
129 129
 
130
-        // Data directories to create when module is enabled.
131
-        // Example: this->dirs = array("/titre/temp");
132
-        $this->dirs = array();
130
+		// Data directories to create when module is enabled.
131
+		// Example: this->dirs = array("/titre/temp");
132
+		$this->dirs = array();
133 133
 
134
-        // Config pages. Put here list of php pages
135
-        // stored into titre/admin directory, used to setup module.
136
-        $this->config_page_url = array("subtotal_setup.php@subtotal");
134
+		// Config pages. Put here list of php pages
135
+		// stored into titre/admin directory, used to setup module.
136
+		$this->config_page_url = array("subtotal_setup.php@subtotal");
137 137
 
138
-        // Dependencies
139
-        // List of modules id that must be enabled if this module is enabled
140
-        $this->depends = array();
138
+		// Dependencies
139
+		// List of modules id that must be enabled if this module is enabled
140
+		$this->depends = array();
141 141
 
142 142
 		$this->conflictwith=array('modMilestone');
143
-        // List of modules id to disable if this one is disabled
144
-        $this->requiredby = array();
145
-        // Minimum version of PHP required by module
146
-        $this->phpmin = array(5, 3);
147
-        // Minimum version of Dolibarr required by module
148
-        $this->need_dolibarr_version = array(3, 2);
149
-        $this->langfiles = array("subtotal@subtotal"); // langfiles@titre
150
-        // Constants
151
-        // List of particular constants to add when module is enabled
152
-        // (key, 'chaine', value, desc, visible, 'current' or 'allentities', deleteonunactive)
153
-        // Example:
154
-        $this->const = array(
155
-            	0=>array(
156
-            		'SUBTOTAL_STYLE_TITRES_SI_LIGNES_CACHEES',
157
-            		'chaine',
158
-            		'I',
159
-            		'Définit le style (B : gras, I : Italique, U : Souligné) des sous titres lorsque le détail des lignes et des ensembles est caché',
160
-            		1
161
-            	)
143
+		// List of modules id to disable if this one is disabled
144
+		$this->requiredby = array();
145
+		// Minimum version of PHP required by module
146
+		$this->phpmin = array(5, 3);
147
+		// Minimum version of Dolibarr required by module
148
+		$this->need_dolibarr_version = array(3, 2);
149
+		$this->langfiles = array("subtotal@subtotal"); // langfiles@titre
150
+		// Constants
151
+		// List of particular constants to add when module is enabled
152
+		// (key, 'chaine', value, desc, visible, 'current' or 'allentities', deleteonunactive)
153
+		// Example:
154
+		$this->const = array(
155
+				0=>array(
156
+					'SUBTOTAL_STYLE_TITRES_SI_LIGNES_CACHEES',
157
+					'chaine',
158
+					'I',
159
+					'Définit le style (B : gras, I : Italique, U : Souligné) des sous titres lorsque le détail des lignes et des ensembles est caché',
160
+					1
161
+				)
162 162
 				,1=>array('SUBTOTAL_ALLOW_ADD_BLOCK', 'chaine', '1', 'Permet l\'ajout de titres et sous-totaux')
163 163
 				,2=>array('SUBTOTAL_ALLOW_EDIT_BLOCK', 'chaine', '1', 'Permet de modifier titres et sous-totaux')
164 164
 				,3=>array('SUBTOTAL_ALLOW_REMOVE_BLOCK', 'chaine', '1', 'Permet de supprimer les titres et sous-totaux')
165 165
 				,4=>array('SUBTOTAL_TITLE_STYLE', 'chaine', 'BU')
166 166
 				,5=>array('SUBTOTAL_SUBTOTAL_STYLE', 'chaine', 'B')
167
-            //	1=>array(
168
-            //		'MYMODULE_MYNEWCONST2',
169
-            //		'chaine',
170
-            //		'myvalue',
171
-            //		'This is another constant to add',
172
-            //		0
173
-            //	)
174
-        );
167
+			//	1=>array(
168
+			//		'MYMODULE_MYNEWCONST2',
169
+			//		'chaine',
170
+			//		'myvalue',
171
+			//		'This is another constant to add',
172
+			//		0
173
+			//	)
174
+		);
175 175
 
176 176
 
177 177
 
178 178
 
179
-        // Array to add new pages in new tabs
180
-        // Example:
181
-        $this->tabs = array(
182
-            //	// To add a new tab identified by code tabname1
183
-            //	'objecttype:+tabname1:Title1:langfile@titre:$user->rights->titre->read:/titre/mynewtab1.php?id=__ID__',
184
-            //	// To add another new tab identified by code tabname2
185
-            //	'objecttype:+tabname2:Title2:langfile@titre:$user->rights->othermodule->read:/titre/mynewtab2.php?id=__ID__',
186
-            //	// To remove an existing tab identified by code tabname
187
-            //	'objecttype:-tabname'
188
-        );
189
-        // where objecttype can be
190
-        // 'thirdparty'			to add a tab in third party view
191
-        // 'intervention'		to add a tab in intervention view
192
-        // 'order_supplier'		to add a tab in supplier order view
193
-        // 'invoice_supplier'	to add a tab in supplier invoice view
194
-        // 'invoice'			to add a tab in customer invoice view
195
-        // 'order'				to add a tab in customer order view
196
-        // 'product'			to add a tab in product view
197
-        // 'stock'				to add a tab in stock view
198
-        // 'propal'				to add a tab in propal view
199
-        // 'member'				to add a tab in fundation member view
200
-        // 'contract'			to add a tab in contract view
201
-        // 'user'				to add a tab in user view
202
-        // 'group'				to add a tab in group view
203
-        // 'contact'			to add a tab in contact view
204
-        // 'categories_x'		to add a tab in category view
205
-        // (replace 'x' by type of category (0=product, 1=supplier, 2=customer, 3=member)
206
-        // Dictionnaries
207
-        if (! isset($conf->subtotal->enabled)) {
208
-            $conf->subtotal=new stdClass();
209
-            $conf->subtotal->enabled = 0;
210
-        }
211
-        $this->dictionaries = array(
179
+		// Array to add new pages in new tabs
180
+		// Example:
181
+		$this->tabs = array(
182
+			//	// To add a new tab identified by code tabname1
183
+			//	'objecttype:+tabname1:Title1:langfile@titre:$user->rights->titre->read:/titre/mynewtab1.php?id=__ID__',
184
+			//	// To add another new tab identified by code tabname2
185
+			//	'objecttype:+tabname2:Title2:langfile@titre:$user->rights->othermodule->read:/titre/mynewtab2.php?id=__ID__',
186
+			//	// To remove an existing tab identified by code tabname
187
+			//	'objecttype:-tabname'
188
+		);
189
+		// where objecttype can be
190
+		// 'thirdparty'			to add a tab in third party view
191
+		// 'intervention'		to add a tab in intervention view
192
+		// 'order_supplier'		to add a tab in supplier order view
193
+		// 'invoice_supplier'	to add a tab in supplier invoice view
194
+		// 'invoice'			to add a tab in customer invoice view
195
+		// 'order'				to add a tab in customer order view
196
+		// 'product'			to add a tab in product view
197
+		// 'stock'				to add a tab in stock view
198
+		// 'propal'				to add a tab in propal view
199
+		// 'member'				to add a tab in fundation member view
200
+		// 'contract'			to add a tab in contract view
201
+		// 'user'				to add a tab in user view
202
+		// 'group'				to add a tab in group view
203
+		// 'contact'			to add a tab in contact view
204
+		// 'categories_x'		to add a tab in category view
205
+		// (replace 'x' by type of category (0=product, 1=supplier, 2=customer, 3=member)
206
+		// Dictionnaries
207
+		if (! isset($conf->subtotal->enabled)) {
208
+			$conf->subtotal=new stdClass();
209
+			$conf->subtotal->enabled = 0;
210
+		}
211
+		$this->dictionaries = array(
212 212
 			'langs'=>'subtotal@subtotal',
213
-            'tabname'=>array(MAIN_DB_PREFIX.'c_subtotal_free_text'),		// List of tables we want to see into dictonnary editor
214
-            'tablib'=>array($langs->trans('subtotalFreeLineDictionary')),													// Label of tables
215
-            'tabsql'=>array('SELECT f.rowid as rowid, f.label, f.content, f.entity, f.active FROM '.MAIN_DB_PREFIX.'c_subtotal_free_text as f WHERE f.entity='.$conf->entity),	// Request to select fields
216
-            'tabsqlsort'=>array('label ASC'),																					// Sort order
217
-            'tabfield'=>array('label,content'),							// List of fields (result of select to show dictionary)
218
-            'tabfieldvalue'=>array('label,content'),						// List of fields (list of fields to edit a record)
219
-            'tabfieldinsert'=>array('label,content,entity'),					// List of fields (list of fields for insert)
220
-            'tabrowid'=>array('rowid'),											// Name of columns with primary key (try to always name it 'rowid')
221
-            'tabcond'=>array($conf->subtotal->enabled)
213
+			'tabname'=>array(MAIN_DB_PREFIX.'c_subtotal_free_text'),		// List of tables we want to see into dictonnary editor
214
+			'tablib'=>array($langs->trans('subtotalFreeLineDictionary')),													// Label of tables
215
+			'tabsql'=>array('SELECT f.rowid as rowid, f.label, f.content, f.entity, f.active FROM '.MAIN_DB_PREFIX.'c_subtotal_free_text as f WHERE f.entity='.$conf->entity),	// Request to select fields
216
+			'tabsqlsort'=>array('label ASC'),																					// Sort order
217
+			'tabfield'=>array('label,content'),							// List of fields (result of select to show dictionary)
218
+			'tabfieldvalue'=>array('label,content'),						// List of fields (list of fields to edit a record)
219
+			'tabfieldinsert'=>array('label,content,entity'),					// List of fields (list of fields for insert)
220
+			'tabrowid'=>array('rowid'),											// Name of columns with primary key (try to always name it 'rowid')
221
+			'tabcond'=>array($conf->subtotal->enabled)
222 222
 		);
223
-        /* Example:
223
+		/* Example:
224 224
           // This is to avoid warnings
225 225
           if (! isset($conf->titre->enabled)) $conf->titre->enabled=0;
226 226
           $this->dictionnaries=array(
@@ -261,223 +261,223 @@  discard block
 block discarded – undo
261 261
           );
262 262
          */
263 263
 
264
-        // Boxes
265
-        // Add here list of php file(s) stored in core/boxes that contains class to show a box.
266
-        $this->boxes = array(); // Boxes list
264
+		// Boxes
265
+		// Add here list of php file(s) stored in core/boxes that contains class to show a box.
266
+		$this->boxes = array(); // Boxes list
267 267
 
268
-        /*
268
+		/*
269 269
           $this->boxes[$r][1] = "myboxb.php";
270 270
           $r++;
271 271
          */
272 272
 
273
-        // Permissions
274
-        $this->rights = array(); // Permission array used by this module
275
-        $r = 0;
273
+		// Permissions
274
+		$this->rights = array(); // Permission array used by this module
275
+		$r = 0;
276 276
 
277
-        // Add here list of permission defined by
278
-        // an id, a label, a boolean and two constant strings.
279
-        // Example:
280
-        //// Permission id (must not be already used)
281
-        //$this->rights[$r][0] = 2000;
282
-        //// Permission label
283
-        //$this->rights[$r][1] = 'Permision label';
284
-        //// Permission by default for new user (0/1)
285
-        //$this->rights[$r][3] = 1;
286
-        //// In php code, permission will be checked by test
287
-        //// if ($user->rights->permkey->level1->level2)
288
-        //$this->rights[$r][4] = 'level1';
289
-        //// In php code, permission will be checked by test
290
-        //// if ($user->rights->permkey->level1->level2)
291
-        //$this->rights[$r][5] = 'level2';
292
-        //$r++;
293
-        // Main menu entries
294
-        $this->menus = array(); // List of menus to add
295
-        $r = 0;
277
+		// Add here list of permission defined by
278
+		// an id, a label, a boolean and two constant strings.
279
+		// Example:
280
+		//// Permission id (must not be already used)
281
+		//$this->rights[$r][0] = 2000;
282
+		//// Permission label
283
+		//$this->rights[$r][1] = 'Permision label';
284
+		//// Permission by default for new user (0/1)
285
+		//$this->rights[$r][3] = 1;
286
+		//// In php code, permission will be checked by test
287
+		//// if ($user->rights->permkey->level1->level2)
288
+		//$this->rights[$r][4] = 'level1';
289
+		//// In php code, permission will be checked by test
290
+		//// if ($user->rights->permkey->level1->level2)
291
+		//$this->rights[$r][5] = 'level2';
292
+		//$r++;
293
+		// Main menu entries
294
+		$this->menus = array(); // List of menus to add
295
+		$r = 0;
296 296
 
297
-        // Add here entries to declare new menus
298
-        //
299
-        // Example to declare a new Top Menu entry and its Left menu entry:
300
-        //$this->menu[$r]=array(
301
-        //	// Put 0 if this is a top menu
302
-        //	'fk_menu'=>0,
303
-        //	// This is a Top menu entry
304
-        //	'type'=>'top',
305
-        //	'titre'=>'titre top menu',
306
-        //	'mainmenu'=>'titre',
307
-        //	'leftmenu'=>'titre',
308
-        //	'url'=>'/titre/pagetop.php',
309
-        //	// Lang file to use (without .lang) by module.
310
-        //	// File must be in langs/code_CODE/ directory.
311
-        //	'langs'=>'mylangfile',
312
-        //	'position'=>100,
313
-        //	// Define condition to show or hide menu entry.
314
-        //	// Use '$conf->titre->enabled' if entry must be visible if module is enabled.
315
-        //	'enabled'=>'$conf->titre->enabled',
316
-        //	// Use 'perms'=>'$user->rights->titre->level1->level2'
317
-        //	// if you want your menu with a permission rules
318
-        //	'perms'=>'1',
319
-        //	'target'=>'',
320
-        //	// 0=Menu for internal users, 1=external users, 2=both
321
-        //	'user'=>2
322
-        //);
323
-        //$r++;
324
-        //$this->menu[$r]=array(
325
-        //	// Use r=value where r is index key used for the parent menu entry
326
-        //	// (higher parent must be a top menu entry)
327
-        //	'fk_menu'=>'r=0',
328
-        //	// This is a Left menu entry
329
-        //	'type'=>'left',
330
-        //	'titre'=>'titre left menu',
331
-        //	'mainmenu'=>'titre',
332
-        //	'leftmenu'=>'titre',
333
-        //	'url'=>'/titre/pagelevel1.php',
334
-        //	// Lang file to use (without .lang) by module.
335
-        //	// File must be in langs/code_CODE/ directory.
336
-        //	'langs'=>'mylangfile',
337
-        //	'position'=>100,
338
-        //	// Define condition to show or hide menu entry.
339
-        //	// Use '$conf->titre->enabled' if entry must be visible if module is enabled.
340
-        //	'enabled'=>'$conf->titre->enabled',
341
-        //	// Use 'perms'=>'$user->rights->titre->level1->level2'
342
-        //	// if you want your menu with a permission rules
343
-        //	'perms'=>'1',
344
-        //	'target'=>'',
345
-        //	// 0=Menu for internal users, 1=external users, 2=both
346
-        //	'user'=>2
347
-        //);
348
-        //$r++;
349
-        //
350
-        // Example to declare a Left Menu entry into an existing Top menu entry:
351
-        //$this->menu[$r]=array(
352
-        //	// Use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy'
353
-        //	'fk_menu'=>'fk_mainmenu=mainmenucode',
354
-        //	// This is a Left menu entry
355
-        //	'type'=>'left',
356
-        //	'titre'=>'titre left menu',
357
-        //	'mainmenu'=>'mainmenucode',
358
-        //	'leftmenu'=>'titre',
359
-        //	'url'=>'/titre/pagelevel2.php',
360
-        //	// Lang file to use (without .lang) by module.
361
-        //	// File must be in langs/code_CODE/ directory.
362
-        //	'langs'=>'mylangfile',
363
-        //	'position'=>100,
364
-        //	// Define condition to show or hide menu entry.
365
-        //	// Use '$conf->titre->enabled' if entry must be visible if module is enabled.
366
-        //	// Use '$leftmenu==\'system\'' to show if leftmenu system is selected.
367
-        //	'enabled'=>'$conf->titre->enabled',
368
-        //	// Use 'perms'=>'$user->rights->titre->level1->level2'
369
-        //	// if you want your menu with a permission rules
370
-        //	'perms'=>'1',
371
-        //	'target'=>'',
372
-        //	// 0=Menu for internal users, 1=external users, 2=both
373
-        //	'user'=>2
374
-        //);
375
-        //$r++;
376
-        // Exports
377
-        $r = 1;
297
+		// Add here entries to declare new menus
298
+		//
299
+		// Example to declare a new Top Menu entry and its Left menu entry:
300
+		//$this->menu[$r]=array(
301
+		//	// Put 0 if this is a top menu
302
+		//	'fk_menu'=>0,
303
+		//	// This is a Top menu entry
304
+		//	'type'=>'top',
305
+		//	'titre'=>'titre top menu',
306
+		//	'mainmenu'=>'titre',
307
+		//	'leftmenu'=>'titre',
308
+		//	'url'=>'/titre/pagetop.php',
309
+		//	// Lang file to use (without .lang) by module.
310
+		//	// File must be in langs/code_CODE/ directory.
311
+		//	'langs'=>'mylangfile',
312
+		//	'position'=>100,
313
+		//	// Define condition to show or hide menu entry.
314
+		//	// Use '$conf->titre->enabled' if entry must be visible if module is enabled.
315
+		//	'enabled'=>'$conf->titre->enabled',
316
+		//	// Use 'perms'=>'$user->rights->titre->level1->level2'
317
+		//	// if you want your menu with a permission rules
318
+		//	'perms'=>'1',
319
+		//	'target'=>'',
320
+		//	// 0=Menu for internal users, 1=external users, 2=both
321
+		//	'user'=>2
322
+		//);
323
+		//$r++;
324
+		//$this->menu[$r]=array(
325
+		//	// Use r=value where r is index key used for the parent menu entry
326
+		//	// (higher parent must be a top menu entry)
327
+		//	'fk_menu'=>'r=0',
328
+		//	// This is a Left menu entry
329
+		//	'type'=>'left',
330
+		//	'titre'=>'titre left menu',
331
+		//	'mainmenu'=>'titre',
332
+		//	'leftmenu'=>'titre',
333
+		//	'url'=>'/titre/pagelevel1.php',
334
+		//	// Lang file to use (without .lang) by module.
335
+		//	// File must be in langs/code_CODE/ directory.
336
+		//	'langs'=>'mylangfile',
337
+		//	'position'=>100,
338
+		//	// Define condition to show or hide menu entry.
339
+		//	// Use '$conf->titre->enabled' if entry must be visible if module is enabled.
340
+		//	'enabled'=>'$conf->titre->enabled',
341
+		//	// Use 'perms'=>'$user->rights->titre->level1->level2'
342
+		//	// if you want your menu with a permission rules
343
+		//	'perms'=>'1',
344
+		//	'target'=>'',
345
+		//	// 0=Menu for internal users, 1=external users, 2=both
346
+		//	'user'=>2
347
+		//);
348
+		//$r++;
349
+		//
350
+		// Example to declare a Left Menu entry into an existing Top menu entry:
351
+		//$this->menu[$r]=array(
352
+		//	// Use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy'
353
+		//	'fk_menu'=>'fk_mainmenu=mainmenucode',
354
+		//	// This is a Left menu entry
355
+		//	'type'=>'left',
356
+		//	'titre'=>'titre left menu',
357
+		//	'mainmenu'=>'mainmenucode',
358
+		//	'leftmenu'=>'titre',
359
+		//	'url'=>'/titre/pagelevel2.php',
360
+		//	// Lang file to use (without .lang) by module.
361
+		//	// File must be in langs/code_CODE/ directory.
362
+		//	'langs'=>'mylangfile',
363
+		//	'position'=>100,
364
+		//	// Define condition to show or hide menu entry.
365
+		//	// Use '$conf->titre->enabled' if entry must be visible if module is enabled.
366
+		//	// Use '$leftmenu==\'system\'' to show if leftmenu system is selected.
367
+		//	'enabled'=>'$conf->titre->enabled',
368
+		//	// Use 'perms'=>'$user->rights->titre->level1->level2'
369
+		//	// if you want your menu with a permission rules
370
+		//	'perms'=>'1',
371
+		//	'target'=>'',
372
+		//	// 0=Menu for internal users, 1=external users, 2=both
373
+		//	'user'=>2
374
+		//);
375
+		//$r++;
376
+		// Exports
377
+		$r = 1;
378 378
 
379
-        // Example:
380
-        //$this->export_code[$r]=$this->rights_class.'_'.$r;
381
-        //// Translation key (used only if key ExportDataset_xxx_z not found)
382
-        //$this->export_label[$r]='CustomersInvoicesAndInvoiceLines';
383
-        //// Condition to show export in list (ie: '$user->id==3').
384
-        //// Set to 1 to always show when module is enabled.
385
-        //$this->export_enabled[$r]='1';
386
-        //$this->export_permission[$r]=array(array("facture","facture","export"));
387
-        //$this->export_fields_array[$r]=array(
388
-        //	's.rowid'=>"IdCompany",
389
-        //	's.nom'=>'CompanyName',
390
-        //	's.address'=>'Address',
391
-        //	's.cp'=>'Zip',
392
-        //	's.ville'=>'Town',
393
-        //	's.fk_pays'=>'Country',
394
-        //	's.tel'=>'Phone',
395
-        //	's.siren'=>'ProfId1',
396
-        //	's.siret'=>'ProfId2',
397
-        //	's.ape'=>'ProfId3',
398
-        //	's.idprof4'=>'ProfId4',
399
-        //	's.code_compta'=>'CustomerAccountancyCode',
400
-        //	's.code_compta_fournisseur'=>'SupplierAccountancyCode',
401
-        //	'f.rowid'=>"InvoiceId",
402
-        //	'f.facnumber'=>"InvoiceRef",
403
-        //	'f.datec'=>"InvoiceDateCreation",
404
-        //	'f.datef'=>"DateInvoice",
405
-        //	'f.total'=>"TotalHT",
406
-        //	'f.total_ttc'=>"TotalTTC",
407
-        //	'f.tva'=>"TotalVAT",
408
-        //	'f.paye'=>"InvoicePaid",
409
-        //	'f.fk_statut'=>'InvoiceStatus',
410
-        //	'f.note'=>"InvoiceNote",
411
-        //	'fd.rowid'=>'LineId',
412
-        //	'fd.description'=>"LineDescription",
413
-        //	'fd.price'=>"LineUnitPrice",
414
-        //	'fd.tva_tx'=>"LineVATRate",
415
-        //	'fd.qty'=>"LineQty",
416
-        //	'fd.total_ht'=>"LineTotalHT",
417
-        //	'fd.total_tva'=>"LineTotalTVA",
418
-        //	'fd.total_ttc'=>"LineTotalTTC",
419
-        //	'fd.date_start'=>"DateStart",
420
-        //	'fd.date_end'=>"DateEnd",
421
-        //	'fd.fk_product'=>'ProductId',
422
-        //	'p.ref'=>'ProductRef'
423
-        //);
424
-        //$this->export_entities_array[$r]=array('s.rowid'=>"company",
425
-        //	's.nom'=>'company',
426
-        //	's.address'=>'company',
427
-        //	's.cp'=>'company',
428
-        //	's.ville'=>'company',
429
-        //	's.fk_pays'=>'company',
430
-        //	's.tel'=>'company',
431
-        //	's.siren'=>'company',
432
-        //	's.siret'=>'company',
433
-        //	's.ape'=>'company',
434
-        //	's.idprof4'=>'company',
435
-        //	's.code_compta'=>'company',
436
-        //	's.code_compta_fournisseur'=>'company',
437
-        //	'f.rowid'=>"invoice",
438
-        //	'f.facnumber'=>"invoice",
439
-        //	'f.datec'=>"invoice",
440
-        //	'f.datef'=>"invoice",
441
-        //	'f.total'=>"invoice",
442
-        //	'f.total_ttc'=>"invoice",
443
-        //	'f.tva'=>"invoice",
444
-        //	'f.paye'=>"invoice",
445
-        //	'f.fk_statut'=>'invoice',
446
-        //	'f.note'=>"invoice",
447
-        //	'fd.rowid'=>'invoice_line',
448
-        //	'fd.description'=>"invoice_line",
449
-        //	'fd.price'=>"invoice_line",
450
-        //	'fd.total_ht'=>"invoice_line",
451
-        //	'fd.total_tva'=>"invoice_line",
452
-        //	'fd.total_ttc'=>"invoice_line",
453
-        //	'fd.tva_tx'=>"invoice_line",
454
-        //	'fd.qty'=>"invoice_line",
455
-        //	'fd.date_start'=>"invoice_line",
456
-        //	'fd.date_end'=>"invoice_line",
457
-        //	'fd.fk_product'=>'product',
458
-        //	'p.ref'=>'product'
459
-        //);
460
-        //$this->export_sql_start[$r] = 'SELECT DISTINCT ';
461
-        //$this->export_sql_end[$r] = ' FROM (' . MAIN_DB_PREFIX . 'facture as f, '
462
-        //	. MAIN_DB_PREFIX . 'facturedet as fd, ' . MAIN_DB_PREFIX . 'societe as s)';
463
-        //$this->export_sql_end[$r] .= ' LEFT JOIN ' . MAIN_DB_PREFIX
464
-        //	. 'product as p on (fd.fk_product = p.rowid)';
465
-        //$this->export_sql_end[$r] .= ' WHERE f.fk_soc = s.rowid '
466
-        //	. 'AND f.rowid = fd.fk_facture';
467
-        //$r++;
468
-    }
379
+		// Example:
380
+		//$this->export_code[$r]=$this->rights_class.'_'.$r;
381
+		//// Translation key (used only if key ExportDataset_xxx_z not found)
382
+		//$this->export_label[$r]='CustomersInvoicesAndInvoiceLines';
383
+		//// Condition to show export in list (ie: '$user->id==3').
384
+		//// Set to 1 to always show when module is enabled.
385
+		//$this->export_enabled[$r]='1';
386
+		//$this->export_permission[$r]=array(array("facture","facture","export"));
387
+		//$this->export_fields_array[$r]=array(
388
+		//	's.rowid'=>"IdCompany",
389
+		//	's.nom'=>'CompanyName',
390
+		//	's.address'=>'Address',
391
+		//	's.cp'=>'Zip',
392
+		//	's.ville'=>'Town',
393
+		//	's.fk_pays'=>'Country',
394
+		//	's.tel'=>'Phone',
395
+		//	's.siren'=>'ProfId1',
396
+		//	's.siret'=>'ProfId2',
397
+		//	's.ape'=>'ProfId3',
398
+		//	's.idprof4'=>'ProfId4',
399
+		//	's.code_compta'=>'CustomerAccountancyCode',
400
+		//	's.code_compta_fournisseur'=>'SupplierAccountancyCode',
401
+		//	'f.rowid'=>"InvoiceId",
402
+		//	'f.facnumber'=>"InvoiceRef",
403
+		//	'f.datec'=>"InvoiceDateCreation",
404
+		//	'f.datef'=>"DateInvoice",
405
+		//	'f.total'=>"TotalHT",
406
+		//	'f.total_ttc'=>"TotalTTC",
407
+		//	'f.tva'=>"TotalVAT",
408
+		//	'f.paye'=>"InvoicePaid",
409
+		//	'f.fk_statut'=>'InvoiceStatus',
410
+		//	'f.note'=>"InvoiceNote",
411
+		//	'fd.rowid'=>'LineId',
412
+		//	'fd.description'=>"LineDescription",
413
+		//	'fd.price'=>"LineUnitPrice",
414
+		//	'fd.tva_tx'=>"LineVATRate",
415
+		//	'fd.qty'=>"LineQty",
416
+		//	'fd.total_ht'=>"LineTotalHT",
417
+		//	'fd.total_tva'=>"LineTotalTVA",
418
+		//	'fd.total_ttc'=>"LineTotalTTC",
419
+		//	'fd.date_start'=>"DateStart",
420
+		//	'fd.date_end'=>"DateEnd",
421
+		//	'fd.fk_product'=>'ProductId',
422
+		//	'p.ref'=>'ProductRef'
423
+		//);
424
+		//$this->export_entities_array[$r]=array('s.rowid'=>"company",
425
+		//	's.nom'=>'company',
426
+		//	's.address'=>'company',
427
+		//	's.cp'=>'company',
428
+		//	's.ville'=>'company',
429
+		//	's.fk_pays'=>'company',
430
+		//	's.tel'=>'company',
431
+		//	's.siren'=>'company',
432
+		//	's.siret'=>'company',
433
+		//	's.ape'=>'company',
434
+		//	's.idprof4'=>'company',
435
+		//	's.code_compta'=>'company',
436
+		//	's.code_compta_fournisseur'=>'company',
437
+		//	'f.rowid'=>"invoice",
438
+		//	'f.facnumber'=>"invoice",
439
+		//	'f.datec'=>"invoice",
440
+		//	'f.datef'=>"invoice",
441
+		//	'f.total'=>"invoice",
442
+		//	'f.total_ttc'=>"invoice",
443
+		//	'f.tva'=>"invoice",
444
+		//	'f.paye'=>"invoice",
445
+		//	'f.fk_statut'=>'invoice',
446
+		//	'f.note'=>"invoice",
447
+		//	'fd.rowid'=>'invoice_line',
448
+		//	'fd.description'=>"invoice_line",
449
+		//	'fd.price'=>"invoice_line",
450
+		//	'fd.total_ht'=>"invoice_line",
451
+		//	'fd.total_tva'=>"invoice_line",
452
+		//	'fd.total_ttc'=>"invoice_line",
453
+		//	'fd.tva_tx'=>"invoice_line",
454
+		//	'fd.qty'=>"invoice_line",
455
+		//	'fd.date_start'=>"invoice_line",
456
+		//	'fd.date_end'=>"invoice_line",
457
+		//	'fd.fk_product'=>'product',
458
+		//	'p.ref'=>'product'
459
+		//);
460
+		//$this->export_sql_start[$r] = 'SELECT DISTINCT ';
461
+		//$this->export_sql_end[$r] = ' FROM (' . MAIN_DB_PREFIX . 'facture as f, '
462
+		//	. MAIN_DB_PREFIX . 'facturedet as fd, ' . MAIN_DB_PREFIX . 'societe as s)';
463
+		//$this->export_sql_end[$r] .= ' LEFT JOIN ' . MAIN_DB_PREFIX
464
+		//	. 'product as p on (fd.fk_product = p.rowid)';
465
+		//$this->export_sql_end[$r] .= ' WHERE f.fk_soc = s.rowid '
466
+		//	. 'AND f.rowid = fd.fk_facture';
467
+		//$r++;
468
+	}
469 469
 
470
-    /**
471
-     * Function called when module is enabled.
472
-     * The init function add constants, boxes, permissions and menus
473
-     * (defined in constructor) into Dolibarr database.
474
-     * It also creates data directories
475
-     *
476
-     * 	@param		string	$options	Options when enabling module ('', 'noboxes')
477
-     * 	@return		int					1 if OK, 0 if KO
478
-     */
479
-    public function init($options = '')
480
-    {
470
+	/**
471
+	 * Function called when module is enabled.
472
+	 * The init function add constants, boxes, permissions and menus
473
+	 * (defined in constructor) into Dolibarr database.
474
+	 * It also creates data directories
475
+	 *
476
+	 * 	@param		string	$options	Options when enabling module ('', 'noboxes')
477
+	 * 	@return		int					1 if OK, 0 if KO
478
+	 */
479
+	public function init($options = '')
480
+	{
481 481
 	  	global $conf, $db;
482 482
 
483 483
 
@@ -485,46 +485,46 @@  discard block
 block discarded – undo
485 485
 			exit("Attention, ce module rentre ne conflit avec le module Jalon/Milestones. Merci de le désactiver auparavant.");
486 486
 		}
487 487
       */
488
-	    $sql = array();
488
+		$sql = array();
489 489
 
490
-        $result = $this->loadTables();
491
-        dol_include_once('/core/class/extrafields.class.php');
490
+		$result = $this->loadTables();
491
+		dol_include_once('/core/class/extrafields.class.php');
492 492
 
493
-        $extra = new ExtraFields($db); // propaldet, commandedet, facturedet
494
-        $TElementType = array('propaldet', 'commandedet', 'facturedet', 'supplier_proposaldet', 'commande_fournisseurdet', 'facture_fourn_det');
495
-        foreach($TElementType as $element_type) {
496
-            $extra->addExtraField('show_total_ht', 'Afficher le Total HT sur le sous-total', 'int', 0, 10, $element_type, 0, 0, '', unserialize('a:1:{s:7:"options";a:1:{s:0:"";N;}}'), 0, '', 0, 1);
497
-            $extra->addExtraField('show_reduc', 'Afficher la réduction sur le sous-total', 'int', 0, 10, $element_type, 0, 0, '', unserialize('a:1:{s:7:"options";a:1:{s:0:"";N;}}'), 0, '', 0, 1);
498
-        }
493
+		$extra = new ExtraFields($db); // propaldet, commandedet, facturedet
494
+		$TElementType = array('propaldet', 'commandedet', 'facturedet', 'supplier_proposaldet', 'commande_fournisseurdet', 'facture_fourn_det');
495
+		foreach($TElementType as $element_type) {
496
+			$extra->addExtraField('show_total_ht', 'Afficher le Total HT sur le sous-total', 'int', 0, 10, $element_type, 0, 0, '', unserialize('a:1:{s:7:"options";a:1:{s:0:"";N;}}'), 0, '', 0, 1);
497
+			$extra->addExtraField('show_reduc', 'Afficher la réduction sur le sous-total', 'int', 0, 10, $element_type, 0, 0, '', unserialize('a:1:{s:7:"options";a:1:{s:0:"";N;}}'), 0, '', 0, 1);
498
+		}
499 499
 
500
-        return $this->_init($sql, $options);
501
-    }
500
+		return $this->_init($sql, $options);
501
+	}
502 502
 
503
-    /**
504
-     * Function called when module is disabled.
505
-     * Remove from database constants, boxes and permissions from Dolibarr database.
506
-     * Data directories are not deleted
507
-     *
508
-     * 	@param		string	$options	Options when enabling module ('', 'noboxes')
509
-     * 	@return		int					1 if OK, 0 if KO
510
-     */
511
-    public function remove($options = '')
512
-    {
513
-        $sql = array();
503
+	/**
504
+	 * Function called when module is disabled.
505
+	 * Remove from database constants, boxes and permissions from Dolibarr database.
506
+	 * Data directories are not deleted
507
+	 *
508
+	 * 	@param		string	$options	Options when enabling module ('', 'noboxes')
509
+	 * 	@return		int					1 if OK, 0 if KO
510
+	 */
511
+	public function remove($options = '')
512
+	{
513
+		$sql = array();
514 514
 
515
-        return $this->_remove($sql, $options);
516
-    }
515
+		return $this->_remove($sql, $options);
516
+	}
517 517
 
518
-    /**
519
-     * Create tables, keys and data required by module
520
-     * Files llx_table1.sql, llx_table1.key.sql llx_data.sql with create table, create keys
521
-     * and create data commands must be stored in directory /titre/sql/
522
-     * This function is called by this->init
523
-     *
524
-     * 	@return		int		<=0 if KO, >0 if OK
525
-     */
526
-    private function loadTables()
527
-    {
528
-        return $this->_load_tables('/subtotal/sql/');
529
-    }
518
+	/**
519
+	 * Create tables, keys and data required by module
520
+	 * Files llx_table1.sql, llx_table1.key.sql llx_data.sql with create table, create keys
521
+	 * and create data commands must be stored in directory /titre/sql/
522
+	 * This function is called by this->init
523
+	 *
524
+	 * 	@return		int		<=0 if KO, >0 if OK
525
+	 */
526
+	private function loadTables()
527
+	{
528
+		return $this->_load_tables('/subtotal/sql/');
529
+	}
530 530
 }
Please login to merge, or discard this patch.
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
  * 	\ingroup	titre
24 24
  * 	\brief		Description and activation file for module titre
25 25
  */
26
-include_once DOL_DOCUMENT_ROOT . "/core/modules/DolibarrModules.class.php";
26
+include_once DOL_DOCUMENT_ROOT."/core/modules/DolibarrModules.class.php";
27 27
 
28 28
 /**
29 29
  * Description and activation class for module titre
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
 
68 68
         // Key used in llx_const table to save module status enabled/disabled
69 69
         // (where MYMODULE is value of property name of module in uppercase)
70
-        $this->const_name = 'MAIN_MODULE_' . strtoupper($this->name);
70
+        $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);
71 71
         // Where to store the module in setup page
72 72
         // (0=common,1=interface,2=others,3=very specific)
73 73
         $this->special = 2;
@@ -139,7 +139,7 @@  discard block
 block discarded – undo
139 139
         // List of modules id that must be enabled if this module is enabled
140 140
         $this->depends = array();
141 141
 
142
-		$this->conflictwith=array('modMilestone');
142
+		$this->conflictwith = array('modMilestone');
143 143
         // List of modules id to disable if this one is disabled
144 144
         $this->requiredby = array();
145 145
         // Minimum version of PHP required by module
@@ -204,20 +204,20 @@  discard block
 block discarded – undo
204 204
         // 'categories_x'		to add a tab in category view
205 205
         // (replace 'x' by type of category (0=product, 1=supplier, 2=customer, 3=member)
206 206
         // Dictionnaries
207
-        if (! isset($conf->subtotal->enabled)) {
208
-            $conf->subtotal=new stdClass();
207
+        if (!isset($conf->subtotal->enabled)) {
208
+            $conf->subtotal = new stdClass();
209 209
             $conf->subtotal->enabled = 0;
210 210
         }
211 211
         $this->dictionaries = array(
212 212
 			'langs'=>'subtotal@subtotal',
213
-            'tabname'=>array(MAIN_DB_PREFIX.'c_subtotal_free_text'),		// List of tables we want to see into dictonnary editor
214
-            'tablib'=>array($langs->trans('subtotalFreeLineDictionary')),													// Label of tables
215
-            'tabsql'=>array('SELECT f.rowid as rowid, f.label, f.content, f.entity, f.active FROM '.MAIN_DB_PREFIX.'c_subtotal_free_text as f WHERE f.entity='.$conf->entity),	// Request to select fields
216
-            'tabsqlsort'=>array('label ASC'),																					// Sort order
217
-            'tabfield'=>array('label,content'),							// List of fields (result of select to show dictionary)
218
-            'tabfieldvalue'=>array('label,content'),						// List of fields (list of fields to edit a record)
219
-            'tabfieldinsert'=>array('label,content,entity'),					// List of fields (list of fields for insert)
220
-            'tabrowid'=>array('rowid'),											// Name of columns with primary key (try to always name it 'rowid')
213
+            'tabname'=>array(MAIN_DB_PREFIX.'c_subtotal_free_text'), // List of tables we want to see into dictonnary editor
214
+            'tablib'=>array($langs->trans('subtotalFreeLineDictionary')), // Label of tables
215
+            'tabsql'=>array('SELECT f.rowid as rowid, f.label, f.content, f.entity, f.active FROM '.MAIN_DB_PREFIX.'c_subtotal_free_text as f WHERE f.entity='.$conf->entity), // Request to select fields
216
+            'tabsqlsort'=>array('label ASC'), // Sort order
217
+            'tabfield'=>array('label,content'), // List of fields (result of select to show dictionary)
218
+            'tabfieldvalue'=>array('label,content'), // List of fields (list of fields to edit a record)
219
+            'tabfieldinsert'=>array('label,content,entity'), // List of fields (list of fields for insert)
220
+            'tabrowid'=>array('rowid'), // Name of columns with primary key (try to always name it 'rowid')
221 221
             'tabcond'=>array($conf->subtotal->enabled)
222 222
 		);
223 223
         /* Example:
@@ -492,7 +492,7 @@  discard block
 block discarded – undo
492 492
 
493 493
         $extra = new ExtraFields($db); // propaldet, commandedet, facturedet
494 494
         $TElementType = array('propaldet', 'commandedet', 'facturedet', 'supplier_proposaldet', 'commande_fournisseurdet', 'facture_fourn_det');
495
-        foreach($TElementType as $element_type) {
495
+        foreach ($TElementType as $element_type) {
496 496
             $extra->addExtraField('show_total_ht', 'Afficher le Total HT sur le sous-total', 'int', 0, 10, $element_type, 0, 0, '', unserialize('a:1:{s:7:"options";a:1:{s:0:"";N;}}'), 0, '', 0, 1);
497 497
             $extra->addExtraField('show_reduc', 'Afficher la réduction sur le sous-total', 'int', 0, 10, $element_type, 0, 0, '', unserialize('a:1:{s:7:"options";a:1:{s:0:"";N;}}'), 0, '', 0, 1);
498 498
         }
Please login to merge, or discard this patch.
core/tpl/originproductline.tpl.php 2 patches
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -17,7 +17,7 @@  discard block
 block discarded – undo
17 17
  */
18 18
 
19 19
 // Protection to avoid direct call of template
20
-if (empty($conf) || ! is_object($conf))
20
+if (empty($conf) || !is_object($conf))
21 21
 {
22 22
 	print "Error, template page can't be called as URL";
23 23
 	exit;
@@ -28,11 +28,11 @@  discard block
 block discarded – undo
28 28
 <!-- BEGIN PHP TEMPLATE originproductline.tpl.php -->
29 29
 <?php
30 30
 
31
-$selected=1;
31
+$selected = 1;
32 32
 
33 33
 if ($this->tpl['subtotal'] != $this->tpl['id'] || !in_array($this->tpl['sub-type'], array('title', 'total')))
34 34
 {
35
-	print '<tr class="oddeven'.(empty($this->tpl['strike'])?'':' strikefordisabled').'">';
35
+	print '<tr class="oddeven'.(empty($this->tpl['strike']) ? '' : ' strikefordisabled').'">';
36 36
 	print '<td>'.$this->tpl['label'].'</td>';
37 37
 	print '<td>'.$this->tpl['description'].'</td>';
38 38
 	print '<td class="right">'.$this->tpl['vat_rate'].'</td>';
@@ -41,27 +41,27 @@  discard block
 block discarded – undo
41 41
 		print '<td class="right">'.$this->tpl['multicurrency_price'].'</td>';
42 42
 
43 43
 	print '<td class="right">'.$this->tpl['qty'].'</td>';
44
-	if($conf->global->PRODUCT_USE_UNITS)
44
+	if ($conf->global->PRODUCT_USE_UNITS)
45 45
 		print '<td class="left">'.$langs->trans($this->tpl['unit']).'</td>';
46 46
 
47 47
 	print '<td class="right">'.$this->tpl['remise_percent'].'</td>';
48 48
 
49 49
 
50
-	if (!empty($selectedLines) && !in_array($this->tpl['id'], $selectedLines)) $selected=0;
50
+	if (!empty($selectedLines) && !in_array($this->tpl['id'], $selectedLines)) $selected = 0;
51 51
 	print '<td class="center">';
52
-	print '<input id="cb'.$this->tpl['id'].'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$this->tpl['id'].'"'.($selected?' checked="checked"':'').'>';
52
+	print '<input id="cb'.$this->tpl['id'].'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$this->tpl['id'].'"'.($selected ? ' checked="checked"' : '').'>';
53 53
 	print '</td>';
54 54
 	print '</tr>'."\n";
55 55
 }
56 56
 else
57 57
 {
58 58
 
59
-	print '<tr class="oddeven'.(empty($this->tpl['strike'])?'':' strikefordisabled').'" '.(!empty($this->tpl['sub-tr-style']) ? 'style="'.$this->tpl['sub-tr-style'].'"' : '').'>';
59
+	print '<tr class="oddeven'.(empty($this->tpl['strike']) ? '' : ' strikefordisabled').'" '.(!empty($this->tpl['sub-tr-style']) ? 'style="'.$this->tpl['sub-tr-style'].'"' : '').'>';
60 60
 	print '<td colspan="6" '.$this->tpl['sub-td-style'].'>'.$this->tpl["sublabel"].'</td>';
61 61
 
62
-	if (!empty($selectedLines) && !in_array($this->tpl['id'], $selectedLines)) $selected=0;
62
+	if (!empty($selectedLines) && !in_array($this->tpl['id'], $selectedLines)) $selected = 0;
63 63
 	print '<td class="center">';
64
-	print '<input id="cb'.$this->tpl['id'].'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$this->tpl['id'].'"'.($selected?' checked="checked"':'').'>';
64
+	print '<input id="cb'.$this->tpl['id'].'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$this->tpl['id'].'"'.($selected ? ' checked="checked"' : '').'>';
65 65
 	print '</td>';
66 66
 	print '</tr>'."\n";
67 67
 }
Please login to merge, or discard this patch.
Braces   +13 added lines, -8 removed lines patch added patch discarded remove patch
@@ -37,29 +37,34 @@
 block discarded – undo
37 37
 	print '<td>'.$this->tpl['description'].'</td>';
38 38
 	print '<td class="right">'.$this->tpl['vat_rate'].'</td>';
39 39
 	print '<td class="right">'.$this->tpl['price'].'</td>';
40
-	if (!empty($conf->multicurrency->enabled))
41
-		print '<td class="right">'.$this->tpl['multicurrency_price'].'</td>';
40
+	if (!empty($conf->multicurrency->enabled)) {
41
+			print '<td class="right">'.$this->tpl['multicurrency_price'].'</td>';
42
+	}
42 43
 
43 44
 	print '<td class="right">'.$this->tpl['qty'].'</td>';
44
-	if($conf->global->PRODUCT_USE_UNITS)
45
-		print '<td class="left">'.$langs->trans($this->tpl['unit']).'</td>';
45
+	if($conf->global->PRODUCT_USE_UNITS) {
46
+			print '<td class="left">'.$langs->trans($this->tpl['unit']).'</td>';
47
+	}
46 48
 
47 49
 	print '<td class="right">'.$this->tpl['remise_percent'].'</td>';
48 50
 
49 51
 
50
-	if (!empty($selectedLines) && !in_array($this->tpl['id'], $selectedLines)) $selected=0;
52
+	if (!empty($selectedLines) && !in_array($this->tpl['id'], $selectedLines)) {
53
+		$selected=0;
54
+	}
51 55
 	print '<td class="center">';
52 56
 	print '<input id="cb'.$this->tpl['id'].'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$this->tpl['id'].'"'.($selected?' checked="checked"':'').'>';
53 57
 	print '</td>';
54 58
 	print '</tr>'."\n";
55
-}
56
-else
59
+} else
57 60
 {
58 61
 
59 62
 	print '<tr class="oddeven'.(empty($this->tpl['strike'])?'':' strikefordisabled').'" '.(!empty($this->tpl['sub-tr-style']) ? 'style="'.$this->tpl['sub-tr-style'].'"' : '').'>';
60 63
 	print '<td colspan="6" '.$this->tpl['sub-td-style'].'>'.$this->tpl["sublabel"].'</td>';
61 64
 
62
-	if (!empty($selectedLines) && !in_array($this->tpl['id'], $selectedLines)) $selected=0;
65
+	if (!empty($selectedLines) && !in_array($this->tpl['id'], $selectedLines)) {
66
+		$selected=0;
67
+	}
63 68
 	print '<td class="center">';
64 69
 	print '<input id="cb'.$this->tpl['id'].'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$this->tpl['id'].'"'.($selected?' checked="checked"':'').'>';
65 70
 	print '</td>';
Please login to merge, or discard this patch.
script/interface.php 2 patches
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-	if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', 1);
3
+	if (!defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', 1);
4 4
 
5 5
 	require '../config.php';
6 6
 
@@ -13,8 +13,8 @@  discard block
 block discarded – undo
13 13
 	dol_include_once('/supplier_proposal/class/supplier_proposal.class.php');
14 14
 	dol_include_once('/fourn/class/fournisseur.facture.class.php');
15 15
 
16
-	$get=GETPOST('get', 'none');
17
-	$set=GETPOST('set', 'none');
16
+	$get = GETPOST('get', 'none');
17
+	$set = GETPOST('set', 'none');
18 18
 
19 19
 	switch ($get) {
20 20
 		default:
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
 
24 24
 	switch ($set) {
25 25
 		case 'updateLineNC': // Gestion du Compris/Non Compris via les titres et/ou lignes
26
-			echo json_encode( _updateLineNC(GETPOST('element', 'none'), GETPOST('elementid', 'none'), GETPOST('lineid', 'none'), GETPOST('subtotal_nc', 'none')) );
26
+			echo json_encode(_updateLineNC(GETPOST('element', 'none'), GETPOST('elementid', 'none'), GETPOST('lineid', 'none'), GETPOST('subtotal_nc', 'none')));
27 27
 
28 28
 			break;
29 29
 		default:
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,6 +1,8 @@
 block discarded – undo
1 1
 <?php
2 2
 
3
-	if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', 1);
3
+	if (! defined('NOTOKENRENEWAL')) {
4
+		define('NOTOKENRENEWAL', 1);
5
+	}
4 6
 
5 7
 	require '../config.php';
6 8
 
Please login to merge, or discard this patch.
class/staticPdf.model.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -6,7 +6,7 @@
 block discarded – undo
6 6
  * This class is used by subtotal to access CommonDocGenerator method without real model
7 7
  *
8 8
  */
9
-class ModelePDFStatic extends CommonDocGenerator{
9
+class ModelePDFStatic extends CommonDocGenerator {
10 10
 
11 11
 
12 12
 	/**
Please login to merge, or discard this patch.
class/subtotal.class.php 3 patches
Indentation   +67 added lines, -67 removed lines patch added patch discarded remove patch
@@ -41,15 +41,15 @@  discard block
 block discarded – undo
41 41
 			}
42 42
 
43 43
 			if($object->element=='facture')
44
-            {
45
-                /** @var Facture $object */
46
-                $res =  $object->addline($desc, 0,$qty,0,0,0,0,0,'','',0,0,'','HT',0,9,$rang, TSubtotal::$module_number, '', 0, 0, null, 0, $label);
47
-            }
44
+			{
45
+				/** @var Facture $object */
46
+				$res =  $object->addline($desc, 0,$qty,0,0,0,0,0,'','',0,0,'','HT',0,9,$rang, TSubtotal::$module_number, '', 0, 0, null, 0, $label);
47
+			}
48 48
 			elseif($object->element=='invoice_supplier') {
49
-                /** @var FactureFournisseur $object */
50
-			    $object->special_code = TSubtotal::$module_number;
51
-                if( (float)DOL_VERSION < 6 ) $rang = $object->line_max() + 1;
52
-			    $res = $object->addline($label,0,0,0,0,$qty,0,0,'','',0,0,'HT',9,$rang);
49
+				/** @var FactureFournisseur $object */
50
+				$object->special_code = TSubtotal::$module_number;
51
+				if( (float)DOL_VERSION < 6 ) $rang = $object->line_max() + 1;
52
+				$res = $object->addline($label,0,0,0,0,$qty,0,0,'','',0,0,'HT',9,$rang);
53 53
 			}
54 54
 			/**
55 55
 			 * @var $object Propal
@@ -68,8 +68,8 @@  discard block
 block discarded – undo
68 68
 			 * @var $object Commande fournisseur
69 69
 			 */
70 70
 			else if($object->element=='order_supplier') {
71
-			    $object->special_code = TSubtotal::$module_number;
72
-			    $res = $object->addline($label, 0,$qty,0,0,0,0,0,'',0,'HT', 0, 9);
71
+				$object->special_code = TSubtotal::$module_number;
72
+				$res = $object->addline($label, 0,$qty,0,0,0,0,0,'',0,'HT', 0, 9);
73 73
 			}
74 74
 			/**
75 75
 			 * @var $object Facturerec
@@ -375,8 +375,8 @@  discard block
 block discarded – undo
375 375
 	{
376 376
 		if (empty($fk_commande)) return false;
377 377
 
378
-        $table = 'commandedet';
379
-        if ($supplier) $table = 'commande_fournisseurdet';
378
+		$table = 'commandedet';
379
+		if ($supplier) $table = 'commande_fournisseurdet';
380 380
 
381 381
 		$sql = 'SELECT rowid FROM '.MAIN_DB_PREFIX.$table.' WHERE fk_commande = '.$fk_commande.' ORDER BY rang DESC LIMIT 1';
382 382
 		$resql = $db->query($sql);
@@ -402,7 +402,7 @@  discard block
 block discarded – undo
402 402
 		{
403 403
 			if ($line->rang >= $rang || ($lvl > 0 && self::getNiveau($line) > $lvl)) continue; // Tout ce qui ce trouve en dessous j'ignore, nous voulons uniquement ce qui ce trouve au dessus
404 404
 
405
-            if (self::isTitle($line))
405
+			if (self::isTitle($line))
406 406
 			{
407 407
 				if ($skip_title)
408 408
 				{
@@ -445,10 +445,10 @@  discard block
 block discarded – undo
445 445
 	 */
446 446
 	public static function isSubtotal(&$line, $level=-1)
447 447
 	{
448
-	    $res = $line->special_code == self::$module_number && $line->product_type == 9 && $line->qty >= 90;
449
-	    if($res && $level > -1) {
450
-	        return self::getNiveau($line) == $level;
451
-	    } else return $res;
448
+		$res = $line->special_code == self::$module_number && $line->product_type == 9 && $line->qty >= 90;
449
+		if($res && $level > -1) {
450
+			return self::getNiveau($line) == $level;
451
+		} else return $res;
452 452
 	}
453 453
 
454 454
 	/**
@@ -504,35 +504,35 @@  discard block
 block discarded – undo
504 504
 		$createRight = $user->rights->{$object->element}->creer;
505 505
 		if($object->element == 'facturerec' )
506 506
 		{
507
-		    $object->statut = 0; // hack for facture rec
508
-		    $createRight = $user->rights->facture->creer;
507
+			$object->statut = 0; // hack for facture rec
508
+			$createRight = $user->rights->facture->creer;
509 509
 		}
510 510
 		elseif($object->element == 'order_supplier' )
511 511
 		{
512
-		    $createRight = $user->rights->fournisseur->commande->creer;
512
+			$createRight = $user->rights->fournisseur->commande->creer;
513 513
 		}
514 514
 		elseif($object->element == 'invoice_supplier' )
515 515
 		{
516
-		    $createRight = $user->rights->fournisseur->facture->creer;
516
+			$createRight = $user->rights->fournisseur->facture->creer;
517 517
 		}
518 518
 
519 519
 		if ($object->statut == 0  && $createRight && (!empty($conf->global->SUBTOTAL_ALLOW_DUPLICATE_BLOCK) || !empty($conf->global->SUBTOTAL_ALLOW_DUPLICATE_LINE)))
520 520
 		{
521 521
 			dol_include_once('/subtotal/lib/subtotal.lib.php');
522 522
 
523
-            if(!empty($object->lines)) {
524
-                foreach($object->lines as $line) {
525
-                    if($line->id == $lineid) $duplicateLine = $line;
526
-                }
527
-            }
528
-            if(!empty($duplicateLine) && !self::isModSubtotalLine($duplicateLine)) $TLine = array($duplicateLine);
529
-            else $TLine = self::getLinesFromTitleId($object, $lineid, $withBlockLine);
523
+			if(!empty($object->lines)) {
524
+				foreach($object->lines as $line) {
525
+					if($line->id == $lineid) $duplicateLine = $line;
526
+				}
527
+			}
528
+			if(!empty($duplicateLine) && !self::isModSubtotalLine($duplicateLine)) $TLine = array($duplicateLine);
529
+			else $TLine = self::getLinesFromTitleId($object, $lineid, $withBlockLine);
530 530
 
531 531
 			if (!empty($TLine))
532 532
 			{
533 533
 				$object->db->begin();
534 534
 				$res = 1;
535
-                $object->context['subtotalDuplicateLines'] = true;
535
+				$object->context['subtotalDuplicateLines'] = true;
536 536
 
537 537
 				$TLineAdded = array();
538 538
 				foreach ($TLine as $line)
@@ -545,8 +545,8 @@  discard block
 block discarded – undo
545 545
 							break;
546 546
 
547 547
 						case 'supplier_proposal':
548
-						    $res = $object->addline($line->desc, $line->subprice, $line->qty, $line->tva_tx, $line->localtax1_tx, $line->localtax2_tx, $line->fk_product, $line->remise_percent, 'HT', 0, $line->info_bits, $line->product_type, -1, $line->special_code, 0, 0, $line->pa_ht, $line->label, $line->date_start, $line->date_end, $line->array_options, $line->fk_unit, $object->element, $line->id);
549
-						    break;
548
+							$res = $object->addline($line->desc, $line->subprice, $line->qty, $line->tva_tx, $line->localtax1_tx, $line->localtax2_tx, $line->fk_product, $line->remise_percent, 'HT', 0, $line->info_bits, $line->product_type, -1, $line->special_code, 0, 0, $line->pa_ht, $line->label, $line->date_start, $line->date_end, $line->array_options, $line->fk_unit, $object->element, $line->id);
549
+							break;
550 550
 
551 551
 						case 'commande':
552 552
 							//$desc, $pu_ht, $qty, $txtva, $txlocaltax1=0, $txlocaltax2=0, $fk_product=0, $remise_percent=0, $info_bits=0, $fk_remise_except=0, $price_base_type='HT', $pu_ttc=0, $date_start='', $date_end='', $type=0, $rang=-1, $special_code=0, $fk_parent_line=0, $fk_fournprice=null, $pa_ht=0, $label='',$array_options=0, $fk_unit=null, $origin='', $origin_id=0)
@@ -554,12 +554,12 @@  discard block
 block discarded – undo
554 554
 							break;
555 555
 
556 556
 						case 'order_supplier':
557
-						    $object->line = $line;
558
-						    $object->line->origin = $object->element;
559
-						    $object->line->origin_id = $line->id;
560
-						    $object->line->fk_commande = $object->id;
561
-						    $object->line->rang = $object->line_max() +1;
562
-						    $res = $object->line->insert(1);
557
+							$object->line = $line;
558
+							$object->line->origin = $object->element;
559
+							$object->line->origin_id = $line->id;
560
+							$object->line->fk_commande = $object->id;
561
+							$object->line->rang = $object->line_max() +1;
562
+							$res = $object->line->insert(1);
563 563
 							break;
564 564
 
565 565
 						case 'facture':
@@ -601,8 +601,8 @@  discard block
 block discarded – undo
601 601
 					$object->db->commit();
602 602
 					foreach ($TLineAdded as &$line)
603 603
 					{
604
-					    // ça peut paraitre non optimisé de déclancher la fonction sur toutes les lignes mais ceci est nécessaire pour réappliquer l'état exact de chaque ligne
605
-                        //En gros ça met à jour le sous total
604
+						// ça peut paraitre non optimisé de déclancher la fonction sur toutes les lignes mais ceci est nécessaire pour réappliquer l'état exact de chaque ligne
605
+						//En gros ça met à jour le sous total
606 606
 					   if(!empty($line->array_options['options_subtotal_nc'])) _updateLineNC($object->element, $object->id, $line->id, $line->array_options['options_subtotal_nc']);
607 607
 					}
608 608
 					return count($TLineAdded);
@@ -722,33 +722,33 @@  discard block
 block discarded – undo
722 722
 
723 723
 		switch ($object->element)
724 724
 		{
725
-		    case 'propal':
726
-		        $res = $object->updateline($rowid, $pu, $qty, $remise_percent, $txtva, $txlocaltax1, $txlocaltax2, $desc, $price_base_type, $info_bits, $special_code, $fk_parent_line, $skip_update_total, $fk_fournprice, $pa_ht, $label, $type, $date_start, $date_end, $array_options, $fk_unit, 0, $notrigger);
727
-		        break;
725
+			case 'propal':
726
+				$res = $object->updateline($rowid, $pu, $qty, $remise_percent, $txtva, $txlocaltax1, $txlocaltax2, $desc, $price_base_type, $info_bits, $special_code, $fk_parent_line, $skip_update_total, $fk_fournprice, $pa_ht, $label, $type, $date_start, $date_end, $array_options, $fk_unit, 0, $notrigger);
727
+				break;
728 728
 
729
-		    case 'supplier_proposal':
730
-		        $res = $object->updateline($rowid, $pu, $qty, $remise_percent, $txtva, $txlocaltax1, $txlocaltax2, $desc, $price_base_type, $info_bits, $special_code, $fk_parent_line, $skip_update_total, $fk_fournprice, $pa_ht, $label, $type, $array_options,'', $fk_unit);
731
-		        break;
729
+			case 'supplier_proposal':
730
+				$res = $object->updateline($rowid, $pu, $qty, $remise_percent, $txtva, $txlocaltax1, $txlocaltax2, $desc, $price_base_type, $info_bits, $special_code, $fk_parent_line, $skip_update_total, $fk_fournprice, $pa_ht, $label, $type, $array_options,'', $fk_unit);
731
+				break;
732 732
 
733 733
 			case 'commande':
734 734
 				$res = $object->updateline($rowid, $desc, $pu, $qty, $remise_percent, $txtva, $txlocaltax1, $txlocaltax2, $price_base_type, $info_bits, $date_start, $date_end, $type, $fk_parent_line, $skip_update_total, $fk_fournprice, $pa_ht, $label, $special_code, $array_options, $fk_unit, 0, $notrigger);
735 735
 				break;
736 736
 
737 737
 			case 'order_supplier':
738
-			    $object->special_code = SELF::$module_number;
739
-			    if (empty($desc)) $desc = $label;
740
-			    $res = $object->updateline($rowid, $desc, $pu, $qty, $remise_percent, $txtva, $txlocaltax1, $txlocaltax2, $price_base_type, $info_bits, $type, 0, $date_start, $date_end, $array_options, $fk_unit);
741
-			    break;
738
+				$object->special_code = SELF::$module_number;
739
+				if (empty($desc)) $desc = $label;
740
+				$res = $object->updateline($rowid, $desc, $pu, $qty, $remise_percent, $txtva, $txlocaltax1, $txlocaltax2, $price_base_type, $info_bits, $type, 0, $date_start, $date_end, $array_options, $fk_unit);
741
+				break;
742 742
 
743 743
 			case 'facture':
744 744
 				$res = $object->updateline($rowid, $desc, $pu, $qty, $remise_percent, $date_start, $date_end, $txtva, $txlocaltax1, $txlocaltax2, $price_base_type, $info_bits, $type, $fk_parent_line, $skip_update_total, $fk_fournprice, $pa_ht, $label, $special_code, $array_options, $situation_percent, $fk_unit, 0, $notrigger);
745 745
 				break;
746 746
 
747 747
 			case 'invoice_supplier':
748
-			    $object->special_code = SELF::$module_number;
749
-			    if (empty($desc)) $desc = $label;
750
-			    $res = $object->updateline($rowid, $desc, $pu, $txtva, $txlocaltax1, $txlocaltax2, $qty, 0, $price_base_type, $info_bits, $type, $remise_percent, 0, $date_start, $date_end, $array_options, $fk_unit);
751
-			    break;
748
+				$object->special_code = SELF::$module_number;
749
+				if (empty($desc)) $desc = $label;
750
+				$res = $object->updateline($rowid, $desc, $pu, $txtva, $txlocaltax1, $txlocaltax2, $qty, 0, $price_base_type, $info_bits, $type, $remise_percent, 0, $date_start, $date_end, $array_options, $fk_unit);
751
+				break;
752 752
 
753 753
 			case 'facturerec':
754 754
 				// Add extrafields and get rang
@@ -1158,8 +1158,8 @@  discard block
 block discarded – undo
1158 1158
 		{
1159 1159
 			if (is_readable($logo))
1160 1160
 			{
1161
-			    $height=pdf_getHeightForLogo($logo);
1162
-			    $pdf->Image($logo, $objmarge->marge_gauche, $posy, 0, $height);	// width=0 (auto)
1161
+				$height=pdf_getHeightForLogo($logo);
1162
+				$pdf->Image($logo, $objmarge->marge_gauche, $posy, 0, $height);	// width=0 (auto)
1163 1163
 			}
1164 1164
 			else
1165 1165
 			{
@@ -1361,10 +1361,10 @@  discard block
 block discarded – undo
1361 1361
 	 */
1362 1362
 	private static function printRect($pdf, $x, $y, $l, $h, $hidetop=0, $hidebottom=0)
1363 1363
 	{
1364
-	    if (empty($hidetop) || $hidetop==-1) $pdf->line($x, $y, $x+$l, $y);
1365
-	    $pdf->line($x+$l, $y, $x+$l, $y+$h);
1366
-	    if (empty($hidebottom)) $pdf->line($x+$l, $y+$h, $x, $y+$h);
1367
-	    $pdf->line($x, $y+$h, $x, $y);
1364
+		if (empty($hidetop) || $hidetop==-1) $pdf->line($x, $y, $x+$l, $y);
1365
+		$pdf->line($x+$l, $y, $x+$l, $y+$h);
1366
+		if (empty($hidebottom)) $pdf->line($x+$l, $y+$h, $x, $y+$h);
1367
+		$pdf->line($x, $y+$h, $x, $y);
1368 1368
 	}
1369 1369
 
1370 1370
 	/**
@@ -1380,14 +1380,14 @@  discard block
 block discarded – undo
1380 1380
 		if (empty($fileoutput)) $fileoutput = $file[0];
1381 1381
 
1382 1382
 		$pdf=pdf_getInstance();
1383
-        if (class_exists('TCPDF'))
1384
-        {
1385
-            $pdf->setPrintHeader(false);
1386
-            $pdf->setPrintFooter(false);
1387
-        }
1388
-        $pdf->SetFont(pdf_getPDFFont($outputlangs));
1389
-
1390
-        if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
1383
+		if (class_exists('TCPDF'))
1384
+		{
1385
+			$pdf->setPrintHeader(false);
1386
+			$pdf->setPrintFooter(false);
1387
+		}
1388
+		$pdf->SetFont(pdf_getPDFFont($outputlangs));
1389
+
1390
+		if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
1391 1391
 
1392 1392
 
1393 1393
 		foreach($files as $file)
Please login to merge, or discard this patch.
Spacing   +200 added lines, -200 removed lines patch added patch discarded remove patch
@@ -12,69 +12,69 @@  discard block
 block discarded – undo
12 12
 	 * @param int          $rang
13 13
 	 * @return int
14 14
 	 */
15
-	static function addSubTotalLine(&$object, $label, $qty, $rang=-1) {
15
+	static function addSubTotalLine(&$object, $label, $qty, $rang = -1) {
16 16
 
17 17
 		$res = 0;
18 18
 
19
-		if( (float)DOL_VERSION <= 3.4 ) {
19
+		if ((float) DOL_VERSION <= 3.4) {
20 20
 			/**
21 21
 			 * @var $object Facture
22 22
 			 */
23
-			if($object->element=='facture') $res =  $object->addline($object->id, $label, 0,$qty,0,0,0,0,0,'','',0,0,'','HT',0,9,-1, TSubtotal::$module_number);
23
+			if ($object->element == 'facture') $res = $object->addline($object->id, $label, 0, $qty, 0, 0, 0, 0, 0, '', '', 0, 0, '', 'HT', 0, 9, -1, TSubtotal::$module_number);
24 24
 			/**
25 25
 			 * @var $object Propal
26 26
 			 */
27
-			else if($object->element=='propal') $res =  $object->addline($object->id,$label, 0,$qty,0,0,0,0,0,'HT',0,0,9,-1, TSubtotal::$module_number);
27
+			else if ($object->element == 'propal') $res = $object->addline($object->id, $label, 0, $qty, 0, 0, 0, 0, 0, 'HT', 0, 0, 9, -1, TSubtotal::$module_number);
28 28
 			/**
29 29
 			 * @var $object Commande
30 30
 			 */
31
-			else if($object->element=='commande') $res =  $object->addline($object->id,$label, 0,$qty,0,0,0,0,0,0,0,'HT',0,'','',9,-1, TSubtotal::$module_number);
31
+			else if ($object->element == 'commande') $res = $object->addline($object->id, $label, 0, $qty, 0, 0, 0, 0, 0, 0, 0, 'HT', 0, '', '', 9, -1, TSubtotal::$module_number);
32 32
 
33 33
 		}
34 34
 		else {
35 35
 			$desc = '';
36 36
 
37
-			$TNotElements = array ('invoice_supplier', 'order_supplier');
38
-			if ((float) DOL_VERSION < 6  || $qty==50 && !in_array($object->element, $TNotElements) ) {
37
+			$TNotElements = array('invoice_supplier', 'order_supplier');
38
+			if ((float) DOL_VERSION < 6 || $qty == 50 && !in_array($object->element, $TNotElements)) {
39 39
 				$desc = $label;
40 40
 				$label = '';
41 41
 			}
42 42
 
43
-			if($object->element=='facture')
43
+			if ($object->element == 'facture')
44 44
             {
45 45
                 /** @var Facture $object */
46
-                $res =  $object->addline($desc, 0,$qty,0,0,0,0,0,'','',0,0,'','HT',0,9,$rang, TSubtotal::$module_number, '', 0, 0, null, 0, $label);
46
+                $res = $object->addline($desc, 0, $qty, 0, 0, 0, 0, 0, '', '', 0, 0, '', 'HT', 0, 9, $rang, TSubtotal::$module_number, '', 0, 0, null, 0, $label);
47 47
             }
48
-			elseif($object->element=='invoice_supplier') {
48
+			elseif ($object->element == 'invoice_supplier') {
49 49
                 /** @var FactureFournisseur $object */
50 50
 			    $object->special_code = TSubtotal::$module_number;
51
-                if( (float)DOL_VERSION < 6 ) $rang = $object->line_max() + 1;
52
-			    $res = $object->addline($label,0,0,0,0,$qty,0,0,'','',0,0,'HT',9,$rang);
51
+                if ((float) DOL_VERSION < 6) $rang = $object->line_max() + 1;
52
+			    $res = $object->addline($label, 0, 0, 0, 0, $qty, 0, 0, '', '', 0, 0, 'HT', 9, $rang);
53 53
 			}
54 54
 			/**
55 55
 			 * @var $object Propal
56 56
 			 */
57
-			else if($object->element=='propal') $res = $object->addline($desc, 0,$qty,0,0,0,0,0,'HT',0,0,9,$rang, TSubtotal::$module_number, 0, 0, 0, $label);
57
+			else if ($object->element == 'propal') $res = $object->addline($desc, 0, $qty, 0, 0, 0, 0, 0, 'HT', 0, 0, 9, $rang, TSubtotal::$module_number, 0, 0, 0, $label);
58 58
 			/**
59 59
 			 * @var $object Propal Fournisseur
60 60
 			 */
61
-			else if($object->element=='supplier_proposal') $res = $object->addline($desc, 0,$qty,0,0,0,0,0,'HT',0,0,9,$rang, TSubtotal::$module_number, 0, 0, 0, $label);
61
+			else if ($object->element == 'supplier_proposal') $res = $object->addline($desc, 0, $qty, 0, 0, 0, 0, 0, 'HT', 0, 0, 9, $rang, TSubtotal::$module_number, 0, 0, 0, $label);
62 62
 
63 63
 			/**
64 64
 			 * @var $object Commande
65 65
 			 */
66
-			else if($object->element=='commande') $res =  $object->addline($desc, 0,$qty,0,0,0,0,0,0,0,'HT',0,'','',9,$rang, TSubtotal::$module_number, 0, null, 0, $label);
66
+			else if ($object->element == 'commande') $res = $object->addline($desc, 0, $qty, 0, 0, 0, 0, 0, 0, 0, 'HT', 0, '', '', 9, $rang, TSubtotal::$module_number, 0, null, 0, $label);
67 67
 			/**
68 68
 			 * @var $object Commande fournisseur
69 69
 			 */
70
-			else if($object->element=='order_supplier') {
70
+			else if ($object->element == 'order_supplier') {
71 71
 			    $object->special_code = TSubtotal::$module_number;
72
-			    $res = $object->addline($label, 0,$qty,0,0,0,0,0,'',0,'HT', 0, 9);
72
+			    $res = $object->addline($label, 0, $qty, 0, 0, 0, 0, 0, '', 0, 'HT', 0, 9);
73 73
 			}
74 74
 			/**
75 75
 			 * @var $object Facturerec
76 76
 			 */
77
-			else if($object->element=='facturerec') $res =  $object->addline($desc, 0,$qty, 0, 0, 0, 0, 0, 'HT', 0, '', 0, 9, $rang, TSubtotal::$module_number,$label);
77
+			else if ($object->element == 'facturerec') $res = $object->addline($desc, 0, $qty, 0, 0, 0, 0, 0, 'HT', 0, '', 0, 9, $rang, TSubtotal::$module_number, $label);
78 78
 
79 79
 		}
80 80
 
@@ -88,20 +88,20 @@  discard block
 block discarded – undo
88 88
 	 */
89 89
 	public static function generateDoc(&$object)
90 90
 	{
91
-		global $conf,$langs,$db;
91
+		global $conf, $langs, $db;
92 92
 
93 93
 		if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE))
94 94
 		{
95
-			$hidedetails = (GETPOST('hidedetails', 'int') ? GETPOST('hidedetails', 'int') : (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS) ? 1 : 0));
96
-			$hidedesc = (GETPOST('hidedesc', 'int') ? GETPOST('hidedesc', 'int') : (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DESC) ? 1 : 0));
97
-			$hideref = (GETPOST('hideref', 'int') ? GETPOST('hideref', 'int') : (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_REF) ? 1 : 0));
95
+			$hidedetails = (GETPOST('hidedetails', 'int') ? GETPOST('hidedetails', 'int') : (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS) ? 1 : 0));
96
+			$hidedesc = (GETPOST('hidedesc', 'int') ? GETPOST('hidedesc', 'int') : (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DESC) ? 1 : 0));
97
+			$hideref = (GETPOST('hideref', 'int') ? GETPOST('hideref', 'int') : (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_REF) ? 1 : 0));
98 98
 
99 99
 			// Define output language
100 100
 			$outputlangs = $langs;
101 101
 			$newlang = GETPOST('lang_id', 'alpha');
102
-			if (! empty($conf->global->MAIN_MULTILANGS) && empty($newlang))
102
+			if (!empty($conf->global->MAIN_MULTILANGS) && empty($newlang))
103 103
 				$newlang = !empty($object->client) ? $object->client->default_lang : $object->thirdparty->default_lang;
104
-			if (! empty($newlang)) {
104
+			if (!empty($newlang)) {
105 105
 				$outputlangs = new Translate("", $conf);
106 106
 				$outputlangs->setDefaultLang($newlang);
107 107
 			}
@@ -115,7 +115,7 @@  discard block
 block discarded – undo
115 115
 			}
116 116
 			else
117 117
 			{
118
-				if ($object->element!= 'facturerec') $object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
118
+				if ($object->element != 'facturerec') $object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
119 119
 			}
120 120
 		}
121 121
 	}
@@ -127,11 +127,11 @@  discard block
 block discarded – undo
127 127
 	 * @param type $rang_start
128 128
 	 * @param type $move_to
129 129
 	 */
130
-	public static function updateRang(&$object, $rang_start, $move_to=1)
130
+	public static function updateRang(&$object, $rang_start, $move_to = 1)
131 131
 	{
132 132
 		if (!class_exists('GenericObject')) require_once DOL_DOCUMENT_ROOT.'/core/class/genericobject.class.php';
133 133
 
134
-		$row=new GenericObject($object->db);
134
+		$row = new GenericObject($object->db);
135 135
 		$row->table_element_line = $object->table_element_line;
136 136
 		$row->fk_element = $object->fk_element;
137 137
 		$row->id = $object->id;
@@ -140,7 +140,7 @@  discard block
 block discarded – undo
140 140
 		{
141 141
 			if ($line->rang < $rang_start) continue;
142 142
 
143
-			$row->updateRangOfLine($line->id, $line->rang+$move_to);
143
+			$row->updateRangOfLine($line->id, $line->rang + $move_to);
144 144
 		}
145 145
 	}
146 146
 
@@ -169,7 +169,7 @@  discard block
 block discarded – undo
169 169
 			{
170 170
 				if ($rang_to_add != -1) self::updateRang($object, $rang_to_add);
171 171
 
172
-				self::addSubTotalLine($object, $langs->trans('SubTotal'), 100-$title_niveau, $rang_to_add);
172
+				self::addSubTotalLine($object, $langs->trans('SubTotal'), 100 - $title_niveau, $rang_to_add);
173 173
 
174 174
 				$object->lines[] = $object->line; // ajout de la ligne dans le tableau de ligne (Dolibarr ne le fait pas)
175 175
 				if ($rang_to_add != -1)
@@ -181,7 +181,7 @@  discard block
 block discarded – undo
181 181
 		}
182 182
 	}
183 183
 
184
-	public static function addTitle(&$object, $label, $level, $rang=-1)
184
+	public static function addTitle(&$object, $label, $level, $rang = -1)
185 185
 	/**
186 186
 	 * @param CommonObject $object
187 187
 	 * @param string       $label
@@ -193,7 +193,7 @@  discard block
 block discarded – undo
193 193
 		return self::addSubTotalLine($object, $label, $level, $rang);
194 194
 	}
195 195
 
196
-	public static function addTotal(&$object, $label, $level, $rang=-1)
196
+	public static function addTotal(&$object, $label, $level, $rang = -1)
197 197
 	/**
198 198
 	 * @param CommonObject $object
199 199
 	 * @param string       $label
@@ -202,7 +202,7 @@  discard block
 block discarded – undo
202 202
 	 * @return int
203 203
 	 */
204 204
 	{
205
-		return self::addSubTotalLine($object, $label, (100-$level), $rang);
205
+		return self::addSubTotalLine($object, $label, (100 - $level), $rang);
206 206
 	}
207 207
 
208 208
 	/**
@@ -213,7 +213,7 @@  discard block
 block discarded – undo
213 213
 	 *
214 214
 	 * @return array
215 215
 	 */
216
-	public static function getAllTitleWithoutTotalFromDocument(&$object, $get_block_total=false)
216
+	public static function getAllTitleWithoutTotalFromDocument(&$object, $get_block_total = false)
217 217
 	{
218 218
 		$TTitle = self::getAllTitleFromDocument($object, $get_block_total);
219 219
 
@@ -234,7 +234,7 @@  discard block
 block discarded – undo
234 234
 	 * @param boolean								$return_rang_on_false	si true alors renvoi le rang où devrait ce trouver le sous-total
235 235
 	 * @return boolean
236 236
 	 */
237
-	public static function titleHasTotalLine(&$object, &$title_line, $strict_mode=false, $return_rang_on_false=false)
237
+	public static function titleHasTotalLine(&$object, &$title_line, $strict_mode = false, $return_rang_on_false = false)
238 238
 	{
239 239
 		if (empty($object->lines) || !is_array($object->lines)) return false;
240 240
 
@@ -265,7 +265,7 @@  discard block
 block discarded – undo
265 265
 	 * @param boolean      $get_block_total
266 266
 	 * @return array
267 267
 	 */
268
-	public static function getAllTitleFromDocument(&$object, $get_block_total=false)
268
+	public static function getAllTitleFromDocument(&$object, $get_block_total = false)
269 269
 	{
270 270
 		$TRes = array();
271 271
 		if (!empty($object->lines))
@@ -324,7 +324,7 @@  discard block
 block discarded – undo
324 324
 			{
325 325
 				// Fix DA020000 : exlure les sous-totaux du calcul (calcul pété)
326 326
 				// sinon ça compte les ligne de produit puis les sous-totaux qui leurs correspondent...
327
-				if (! self::isSubtotal($l))
327
+				if (!self::isSubtotal($l))
328 328
 				{
329 329
 					$TTot['total_pa_ht'] += $l->pa_ht * $l->qty;
330 330
 					$TTot['total_subprice'] += $l->subprice * $l->qty;
@@ -398,7 +398,7 @@  discard block
 block discarded – undo
398 398
 		$skip_title = 0;
399 399
 		$TLineReverse = array_reverse($object->lines);
400 400
 
401
-		foreach($TLineReverse as $line)
401
+		foreach ($TLineReverse as $line)
402 402
 		{
403 403
 			if ($line->rang >= $rang || ($lvl > 0 && self::getNiveau($line) > $lvl)) continue; // Tout ce qui ce trouve en dessous j'ignore, nous voulons uniquement ce qui ce trouve au dessus
404 404
 
@@ -429,10 +429,10 @@  discard block
 block discarded – undo
429 429
 	 * @param int              $level
430 430
 	 * @return bool
431 431
 	 */
432
-	public static function isTitle(&$line, $level=-1)
432
+	public static function isTitle(&$line, $level = -1)
433 433
 	{
434 434
 		$res = $line->special_code == self::$module_number && $line->product_type == 9 && $line->qty <= 9;
435
-		if($res && $level > -1) {
435
+		if ($res && $level > -1) {
436 436
 			return $line->qty == $level;
437 437
 		} else return $res;
438 438
 
@@ -443,10 +443,10 @@  discard block
 block discarded – undo
443 443
 	 * @param int              $level
444 444
 	 * @return bool
445 445
 	 */
446
-	public static function isSubtotal(&$line, $level=-1)
446
+	public static function isSubtotal(&$line, $level = -1)
447 447
 	{
448 448
 	    $res = $line->special_code == self::$module_number && $line->product_type == 9 && $line->qty >= 90;
449
-	    if($res && $level > -1) {
449
+	    if ($res && $level > -1) {
450 450
 	        return self::getNiveau($line) == $level;
451 451
 	    } else return $res;
452 452
 	}
@@ -474,20 +474,20 @@  discard block
 block discarded – undo
474 474
 	 * @param int $readonly
475 475
 	 * @return string|void
476 476
 	 */
477
-	public static function getFreeTextHtml(&$line, $readonly=0)
477
+	public static function getFreeTextHtml(&$line, $readonly = 0)
478 478
 	{
479 479
 		global $conf;
480 480
 
481 481
 		// Copie du fichier "objectline_edit.tpl.php"
482 482
 		// editeur wysiwyg
483 483
 		require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
484
-		$nbrows=ROWS_2;
485
-		if (! empty($conf->global->MAIN_INPUT_DESC_HEIGHT)) $nbrows=$conf->global->MAIN_INPUT_DESC_HEIGHT;
486
-		$enable=(isset($conf->global->FCKEDITOR_ENABLE_DETAILS)?$conf->global->FCKEDITOR_ENABLE_DETAILS:0);
487
-		$toolbarname='dolibarr_details';
488
-		if (! empty($conf->global->FCKEDITOR_ENABLE_DETAILS_FULL)) $toolbarname='dolibarr_notes';
489
-		$text = !empty($line->description)?$line->description:$line->label;
490
-		$doleditor=new DolEditor('line-description',$text,'',164,$toolbarname,'',false,true,$enable,$nbrows,'98%', $readonly);
484
+		$nbrows = ROWS_2;
485
+		if (!empty($conf->global->MAIN_INPUT_DESC_HEIGHT)) $nbrows = $conf->global->MAIN_INPUT_DESC_HEIGHT;
486
+		$enable = (isset($conf->global->FCKEDITOR_ENABLE_DETAILS) ? $conf->global->FCKEDITOR_ENABLE_DETAILS : 0);
487
+		$toolbarname = 'dolibarr_details';
488
+		if (!empty($conf->global->FCKEDITOR_ENABLE_DETAILS_FULL)) $toolbarname = 'dolibarr_notes';
489
+		$text = !empty($line->description) ? $line->description : $line->label;
490
+		$doleditor = new DolEditor('line-description', $text, '', 164, $toolbarname, '', false, true, $enable, $nbrows, '98%', $readonly);
491 491
 		return $doleditor->Create(1);
492 492
 	}
493 493
 
@@ -497,35 +497,35 @@  discard block
 block discarded – undo
497 497
 	 * @param bool         $withBlockLine
498 498
 	 * @return int
499 499
 	 */
500
-	public static function duplicateLines(&$object, $lineid, $withBlockLine=false)
500
+	public static function duplicateLines(&$object, $lineid, $withBlockLine = false)
501 501
 	{
502
-		global $db,$user,$conf;
502
+		global $db, $user, $conf;
503 503
 
504 504
 		$createRight = $user->rights->{$object->element}->creer;
505
-		if($object->element == 'facturerec' )
505
+		if ($object->element == 'facturerec')
506 506
 		{
507 507
 		    $object->statut = 0; // hack for facture rec
508 508
 		    $createRight = $user->rights->facture->creer;
509 509
 		}
510
-		elseif($object->element == 'order_supplier' )
510
+		elseif ($object->element == 'order_supplier')
511 511
 		{
512 512
 		    $createRight = $user->rights->fournisseur->commande->creer;
513 513
 		}
514
-		elseif($object->element == 'invoice_supplier' )
514
+		elseif ($object->element == 'invoice_supplier')
515 515
 		{
516 516
 		    $createRight = $user->rights->fournisseur->facture->creer;
517 517
 		}
518 518
 
519
-		if ($object->statut == 0  && $createRight && (!empty($conf->global->SUBTOTAL_ALLOW_DUPLICATE_BLOCK) || !empty($conf->global->SUBTOTAL_ALLOW_DUPLICATE_LINE)))
519
+		if ($object->statut == 0 && $createRight && (!empty($conf->global->SUBTOTAL_ALLOW_DUPLICATE_BLOCK) || !empty($conf->global->SUBTOTAL_ALLOW_DUPLICATE_LINE)))
520 520
 		{
521 521
 			dol_include_once('/subtotal/lib/subtotal.lib.php');
522 522
 
523
-            if(!empty($object->lines)) {
524
-                foreach($object->lines as $line) {
525
-                    if($line->id == $lineid) $duplicateLine = $line;
523
+            if (!empty($object->lines)) {
524
+                foreach ($object->lines as $line) {
525
+                    if ($line->id == $lineid) $duplicateLine = $line;
526 526
                 }
527 527
             }
528
-            if(!empty($duplicateLine) && !self::isModSubtotalLine($duplicateLine)) $TLine = array($duplicateLine);
528
+            if (!empty($duplicateLine) && !self::isModSubtotalLine($duplicateLine)) $TLine = array($duplicateLine);
529 529
             else $TLine = self::getLinesFromTitleId($object, $lineid, $withBlockLine);
530 530
 
531 531
 			if (!empty($TLine))
@@ -558,7 +558,7 @@  discard block
 block discarded – undo
558 558
 						    $object->line->origin = $object->element;
559 559
 						    $object->line->origin_id = $line->id;
560 560
 						    $object->line->fk_commande = $object->id;
561
-						    $object->line->rang = $object->line_max() +1;
561
+						    $object->line->rang = $object->line_max() + 1;
562 562
 						    $res = $object->line->insert(1);
563 563
 							break;
564 564
 
@@ -603,7 +603,7 @@  discard block
 block discarded – undo
603 603
 					{
604 604
 					    // ça peut paraitre non optimisé de déclancher la fonction sur toutes les lignes mais ceci est nécessaire pour réappliquer l'état exact de chaque ligne
605 605
                         //En gros ça met à jour le sous total
606
-					   if(!empty($line->array_options['options_subtotal_nc'])) _updateLineNC($object->element, $object->id, $line->id, $line->array_options['options_subtotal_nc']);
606
+					   if (!empty($line->array_options['options_subtotal_nc'])) _updateLineNC($object->element, $object->id, $line->id, $line->array_options['options_subtotal_nc']);
607 607
 					}
608 608
 					return count($TLineAdded);
609 609
 				}
@@ -627,7 +627,7 @@  discard block
 block discarded – undo
627 627
 	 * @param bool         $key_is_id
628 628
 	 * @return array
629 629
 	 */
630
-	public static function getLinesFromTitle(&$object, $key_trad, $level=1, $under_title='', $withBlockLine=false, $key_is_id=false)
630
+	public static function getLinesFromTitle(&$object, $key_trad, $level = 1, $under_title = '', $withBlockLine = false, $key_is_id = false)
631 631
 	{
632 632
 		global $langs;
633 633
 
@@ -639,17 +639,17 @@  discard block
 block discarded – undo
639 639
 
640 640
 		$TLine = array();
641 641
 		$add_line = false;
642
-		$under_title_found=false;
642
+		$under_title_found = false;
643 643
 
644 644
 		foreach ($object->lines as $key => &$line)
645 645
 		{
646 646
 			if (!$under_title_found && !empty($TTitle_under_search))
647 647
 			{
648
-				if ($line->product_type == 9 && (in_array($line->desc, $TTitle_under_search) || in_array($line->label, $TTitle_under_search)) ) $under_title_found = true;
648
+				if ($line->product_type == 9 && (in_array($line->desc, $TTitle_under_search) || in_array($line->label, $TTitle_under_search))) $under_title_found = true;
649 649
 			}
650 650
 			else
651 651
 			{
652
-				if ( ($key_is_id && $line->id == $key_trad) || (!$key_is_id && $line->product_type == 9 && $line->qty == $level && (in_array($line->desc, $TTitle_search) || in_array($line->label, $TTitle_search) )))
652
+				if (($key_is_id && $line->id == $key_trad) || (!$key_is_id && $line->product_type == 9 && $line->qty == $level && (in_array($line->desc, $TTitle_search) || in_array($line->label, $TTitle_search))))
653 653
 				{
654 654
 					if ($key_is_id) $level = $line->qty;
655 655
 
@@ -665,7 +665,7 @@  discard block
 block discarded – undo
665 665
 
666 666
 				if ($add_line)
667 667
 				{
668
-					if (!$withBlockLine && (self::isTitle($line) || self::isSubtotal($line)) ) continue;
668
+					if (!$withBlockLine && (self::isTitle($line) || self::isSubtotal($line))) continue;
669 669
 					else $TLine[] = $line;
670 670
 				}
671 671
 			}
@@ -680,7 +680,7 @@  discard block
 block discarded – undo
680 680
 	 * @param bool         $withBlockLine
681 681
 	 * @return array
682 682
 	 */
683
-	public static function getLinesFromTitleId(&$object, $lineid, $withBlockLine=false)
683
+	public static function getLinesFromTitleId(&$object, $lineid, $withBlockLine = false)
684 684
 	{
685 685
 		return self::getLinesFromTitle($object, $lineid, '', '', $withBlockLine, true);
686 686
 	}
@@ -715,7 +715,7 @@  discard block
 block discarded – undo
715 715
 	 * @param int $notrigger
716 716
 	 * @return int
717 717
 	 */
718
-	public static function doUpdateLine(&$object, $rowid, $desc, $pu, $qty, $remise_percent, $date_start, $date_end, $txtva, $type, $txlocaltax1=0, $txlocaltax2=0, $price_base_type='HT', $info_bits=0, $fk_parent_line=0, $skip_update_total=0, $fk_fournprice=null, $pa_ht=0, $label='', $special_code=0, $array_options=0, $situation_percent=0, $fk_unit = null, $notrigger = 0)
718
+	public static function doUpdateLine(&$object, $rowid, $desc, $pu, $qty, $remise_percent, $date_start, $date_end, $txtva, $type, $txlocaltax1 = 0, $txlocaltax2 = 0, $price_base_type = 'HT', $info_bits = 0, $fk_parent_line = 0, $skip_update_total = 0, $fk_fournprice = null, $pa_ht = 0, $label = '', $special_code = 0, $array_options = 0, $situation_percent = 0, $fk_unit = null, $notrigger = 0)
719 719
 	{
720 720
 		$res = 0;
721 721
 		$object->db->begin();
@@ -727,7 +727,7 @@  discard block
 block discarded – undo
727 727
 		        break;
728 728
 
729 729
 		    case 'supplier_proposal':
730
-		        $res = $object->updateline($rowid, $pu, $qty, $remise_percent, $txtva, $txlocaltax1, $txlocaltax2, $desc, $price_base_type, $info_bits, $special_code, $fk_parent_line, $skip_update_total, $fk_fournprice, $pa_ht, $label, $type, $array_options,'', $fk_unit);
730
+		        $res = $object->updateline($rowid, $pu, $qty, $remise_percent, $txtva, $txlocaltax1, $txlocaltax2, $desc, $price_base_type, $info_bits, $special_code, $fk_parent_line, $skip_update_total, $fk_fournprice, $pa_ht, $label, $type, $array_options, '', $fk_unit);
731 731
 		        break;
732 732
 
733 733
 			case 'commande':
@@ -756,9 +756,9 @@  discard block
 block discarded – undo
756 756
 				$factureRecLine->fetch($rowid);
757 757
 				$factureRecLine->array_options = $array_options;
758 758
 				$factureRecLine->insertExtraFields();
759
-				$rang=$factureRecLine->rang;
759
+				$rang = $factureRecLine->rang;
760 760
 
761
-				$fk_product=0; $fk_remise_except=''; $pu_ttc=0;
761
+				$fk_product = 0; $fk_remise_except = ''; $pu_ttc = 0;
762 762
 				$res = $object->updateline($rowid, $desc, $pu, $qty, $txtva, $txlocaltax1, $txlocaltax2, $fk_product, $remise_percent, $price_base_type, $info_bits, $fk_remise_except, $pu_ttc, $type, $rang, $special_code, $label, $fk_unit);
763 763
 				break;
764 764
 		}
@@ -779,7 +779,7 @@  discard block
 block discarded – undo
779 779
 		global $db, $object;
780 780
 
781 781
 		$TTitle = array();
782
-		if(! empty($object->id) && in_array($object->element, array('propal', 'commande', 'facture'))) {}
782
+		if (!empty($object->id) && in_array($object->element, array('propal', 'commande', 'facture'))) {}
783 783
 		else {
784 784
 			if ($origin_line->element == 'propaldet')
785 785
 			{
@@ -866,7 +866,7 @@  discard block
 block discarded – undo
866 866
 	 */
867 867
 	public static function addRecapPage(&$parameters, &$origin_pdf)
868 868
 	{
869
-		global $user,$conf,$langs;
869
+		global $user, $conf, $langs;
870 870
 
871 871
 		$origin_file = $parameters['file'];
872 872
 		$outputlangs = $parameters['outputlangs'];
@@ -882,21 +882,21 @@  discard block
 block discarded – undo
882 882
 		$objmarge->marge_droite = 10;
883 883
 
884 884
 		$objectref = dol_sanitizeFileName($object->ref);
885
-		if ($object->element == 'propal') $dir = $conf->propal->dir_output . '/' . $objectref;
886
-		elseif ($object->element == 'commande') $dir = $conf->commande->dir_output . '/' . $objectref;
887
-		elseif ($object->element == 'facture') $dir = $conf->facture->dir_output . '/' . $objectref;
885
+		if ($object->element == 'propal') $dir = $conf->propal->dir_output.'/'.$objectref;
886
+		elseif ($object->element == 'commande') $dir = $conf->commande->dir_output.'/'.$objectref;
887
+		elseif ($object->element == 'facture') $dir = $conf->facture->dir_output.'/'.$objectref;
888 888
 		elseif ($object->element == 'facturerec') return; // no PDF for facturerec
889 889
 		else
890 890
 		{
891 891
 			setEventMessage($langs->trans('warning_subtotal_recap_object_element_unknown', $object->element), 'warnings');
892 892
 			return -1;
893 893
 		}
894
-		$file = $dir . '/' . $objectref . '_recap.pdf';
894
+		$file = $dir.'/'.$objectref.'_recap.pdf';
895 895
 
896 896
 //		$pdf=pdf_getInstance($origin_pdf->format);
897
-		$pdf=pdf_getInstance(array(210, 297)); // Format A4 Portrait
898
-		$default_font_size = pdf_getPDFFontSize($outputlangs);	// Must be after pdf_getInstance
899
-		$pdf->SetAutoPageBreak(1,0);
897
+		$pdf = pdf_getInstance(array(210, 297)); // Format A4 Portrait
898
+		$default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance
899
+		$pdf->SetAutoPageBreak(1, 0);
900 900
 
901 901
 		if (class_exists('TCPDF'))
902 902
 		{
@@ -905,49 +905,49 @@  discard block
 block discarded – undo
905 905
 		}
906 906
 		$pdf->SetFont(pdf_getPDFFont($outputlangs));
907 907
 		// Set path to the background PDF File
908
-		if (empty($conf->global->MAIN_DISABLE_FPDI) && ! empty($conf->global->MAIN_ADD_PDF_BACKGROUND))
908
+		if (empty($conf->global->MAIN_DISABLE_FPDI) && !empty($conf->global->MAIN_ADD_PDF_BACKGROUND))
909 909
 		{
910 910
 			$pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND);
911 911
 			$tplidx = $pdf->importPage(1);
912 912
 		}
913 913
 
914 914
 		$pdf->Open();
915
-		$pagenb=0;
916
-		$pdf->SetDrawColor(128,128,128);
915
+		$pagenb = 0;
916
+		$pdf->SetDrawColor(128, 128, 128);
917 917
 
918 918
 		$pdf->SetTitle($outputlangs->convToOutputCharset($object->ref));
919 919
 		$pdf->SetSubject($outputlangs->transnoentities("subtotalRecap"));
920 920
 		$pdf->SetCreator("Dolibarr ".DOL_VERSION);
921 921
 		$pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
922 922
 		$pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("subtotalRecap")." ".$outputlangs->convToOutputCharset($object->thirdparty->name));
923
-		if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
923
+		if (!empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
924 924
 
925
-		$pdf->SetMargins($objmarge->marge_gauche, $objmarge->marge_haute, $objmarge->marge_droite);   // Left, Top, Right
925
+		$pdf->SetMargins($objmarge->marge_gauche, $objmarge->marge_haute, $objmarge->marge_droite); // Left, Top, Right
926 926
 
927
-		$pagenb=0;
928
-		$pdf->SetDrawColor(128,128,128);
927
+		$pagenb = 0;
928
+		$pdf->SetDrawColor(128, 128, 128);
929 929
 
930 930
 
931 931
 		// New page
932 932
 		$pdf->AddPage();
933
-		if (! empty($tplidx)) $pdf->useTemplate($tplidx);
933
+		if (!empty($tplidx)) $pdf->useTemplate($tplidx);
934 934
 		$pagenb++;
935 935
 
936 936
 
937 937
 		self::pagehead($objmarge, $pdf, $object, 1, $outputlangs);
938
-		$pdf->SetFont('','', $default_font_size - 1);
939
-		$pdf->MultiCell(0, 3, '');		// Set interline to 3
940
-		$pdf->SetTextColor(0,0,0);
938
+		$pdf->SetFont('', '', $default_font_size - 1);
939
+		$pdf->MultiCell(0, 3, ''); // Set interline to 3
940
+		$pdf->SetTextColor(0, 0, 0);
941 941
 
942
-		$heightforinfotot = 25;	// Height reserved to output the info and total part
943
-		$heightforfooter = $objmarge->marge_basse + 8;	// Height reserved to output the footer (value include bottom margin)
942
+		$heightforinfotot = 25; // Height reserved to output the info and total part
943
+		$heightforfooter = $objmarge->marge_basse + 8; // Height reserved to output the footer (value include bottom margin)
944 944
 
945 945
 		$posx_designation = 25;
946 946
 		$posx_options = 150;
947 947
 		$posx_montant = 170;
948 948
 
949 949
 		$tab_top = 72;
950
-		$tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)?72:20); // TODO à vérifier
950
+		$tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD) ? 72 : 20); // TODO à vérifier
951 951
 
952 952
 		$TTot = array('total_ht' => 0, 'total_ttc' => 0, 'TTotal_tva' => array());
953 953
 
@@ -961,14 +961,14 @@  discard block
 block discarded – undo
961 961
 			$nexY = $tab_top + 10;
962 962
 
963 963
 			$nblignes = count($TLine);
964
-			foreach($TLine as $i => &$line)
964
+			foreach ($TLine as $i => &$line)
965 965
 			{
966 966
 				$curY = $nexY;
967 967
 
968 968
 				if (self::getNiveau($line) == 1)
969 969
 				{
970
-					$pdf->SetFont('','B', $default_font_size - 1);   // Into loop to work with multipage
971
-					$curY+=2;
970
+					$pdf->SetFont('', 'B', $default_font_size - 1); // Into loop to work with multipage
971
+					$curY += 2;
972 972
 
973 973
 					$TTot['total_ht'] += $line->total_ht;
974 974
 					$TTot['total_tva'] += $line->total_tva;
@@ -987,67 +987,67 @@  discard block
 block discarded – undo
987 987
 						$TTot['TTotal_tva_multicurrency'][$tx] += $amount;
988 988
 					}
989 989
 				}
990
-				else $pdf->SetFont('','', $default_font_size - 1);   // Into loop to work with multipage
990
+				else $pdf->SetFont('', '', $default_font_size - 1); // Into loop to work with multipage
991 991
 
992
-				$pdf->SetTextColor(0,0,0);
992
+				$pdf->SetTextColor(0, 0, 0);
993 993
 
994 994
 				$pdf->setTopMargin($tab_top_newpage + 10);
995
-				$pdf->setPageOrientation('', 1, $heightforfooter+$heightforinfotot);	// The only function to edit the bottom margin of current page to set it.
996
-				$pageposbefore=$pdf->getPage();
995
+				$pdf->setPageOrientation('', 1, $heightforfooter + $heightforinfotot); // The only function to edit the bottom margin of current page to set it.
996
+				$pageposbefore = $pdf->getPage();
997 997
 
998
-				$showpricebeforepagebreak=1;
998
+				$showpricebeforepagebreak = 1;
999 999
 
1000 1000
 				$decalage = (self::getNiveau($line) - 1) * 2;
1001 1001
 
1002 1002
 				// Print: Designation
1003 1003
 				$label = $line->label;
1004
-				if( (float)DOL_VERSION < 6 ) {
1004
+				if ((float) DOL_VERSION < 6) {
1005 1005
 					$label = !empty($line->label) ? $line->label : $line->desc;
1006 1006
 				}
1007 1007
 
1008 1008
 
1009 1009
 				$pdf->startTransaction();
1010
-				$pdf->writeHTMLCell($posx_options-$posx_designation-$decalage, 3, $posx_designation+$decalage, $curY, $outputlangs->convToOutputCharset($label), 0, 1, false, true, 'J',true);
1011
-				$pageposafter=$pdf->getPage();
1010
+				$pdf->writeHTMLCell($posx_options - $posx_designation - $decalage, 3, $posx_designation + $decalage, $curY, $outputlangs->convToOutputCharset($label), 0, 1, false, true, 'J', true);
1011
+				$pageposafter = $pdf->getPage();
1012 1012
 				if ($pageposafter > $pageposbefore)	// There is a pagebreak
1013 1013
 				{
1014 1014
 					$pdf->rollbackTransaction(true);
1015
-					$pageposafter=$pageposbefore;
1015
+					$pageposafter = $pageposbefore;
1016 1016
 					//print $pageposafter.'-'.$pageposbefore;exit;
1017
-					$pdf->setPageOrientation('', 1, $heightforfooter);	// The only function to edit the bottom margin of current page to set it.
1018
-					$pdf->writeHTMLCell($posx_options-$posx_designation-$decalage, 3, $posx_designation+$decalage, $curY, $outputlangs->convToOutputCharset($label), 0, 1, false, true, 'J',true);
1017
+					$pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it.
1018
+					$pdf->writeHTMLCell($posx_options - $posx_designation - $decalage, 3, $posx_designation + $decalage, $curY, $outputlangs->convToOutputCharset($label), 0, 1, false, true, 'J', true);
1019 1019
 
1020
-					$pageposafter=$pdf->getPage();
1021
-					$posyafter=$pdf->GetY();
1020
+					$pageposafter = $pdf->getPage();
1021
+					$posyafter = $pdf->GetY();
1022 1022
 					//var_dump($posyafter); var_dump(($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))); exit;
1023
-					if ($posyafter > ($objmarge->page_hauteur - ($heightforfooter+$heightforinfotot)))	// There is no space left for total+free text
1023
+					if ($posyafter > ($objmarge->page_hauteur - ($heightforfooter + $heightforinfotot)))	// There is no space left for total+free text
1024 1024
 					{
1025
-						if ($i == ($nblignes-1))	// No more lines, and no space left to show total, so we create a new page
1025
+						if ($i == ($nblignes - 1))	// No more lines, and no space left to show total, so we create a new page
1026 1026
 						{
1027
-							$pdf->AddPage('','',true);
1028
-							if (! empty($tplidx)) $pdf->useTemplate($tplidx);
1027
+							$pdf->AddPage('', '', true);
1028
+							if (!empty($tplidx)) $pdf->useTemplate($tplidx);
1029 1029
 							if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) self::pagehead($objmarge, $pdf, $object, 0, $outputlangs);
1030
-							$pdf->setPage($pageposafter+1);
1030
+							$pdf->setPage($pageposafter + 1);
1031 1031
 						}
1032 1032
 					}
1033 1033
 					else
1034 1034
 					{
1035 1035
 						// We found a page break
1036
-						$showpricebeforepagebreak=0;
1036
+						$showpricebeforepagebreak = 0;
1037 1037
 					}
1038 1038
 				}
1039 1039
 				else	// No pagebreak
1040 1040
 				{
1041 1041
 					$pdf->commitTransaction();
1042 1042
 				}
1043
-				$posYAfterDescription=$pdf->GetY();
1043
+				$posYAfterDescription = $pdf->GetY();
1044 1044
 
1045 1045
 				$nexY = $pdf->GetY();
1046
-				$pageposafter=$pdf->getPage();
1046
+				$pageposafter = $pdf->getPage();
1047 1047
 
1048 1048
 				$pdf->setPage($pageposbefore);
1049 1049
 				$pdf->setTopMargin($objmarge->marge_haute);
1050
-				$pdf->setPageOrientation('', 1, 0);	// The only function to edit the bottom margin of current page to set it.
1050
+				$pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
1051 1051
 
1052 1052
 				// We suppose that a too long description or photo were moved completely on next page
1053 1053
 				if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) {
@@ -1060,14 +1060,14 @@  discard block
 block discarded – undo
1060 1060
 				if (!empty($line->total_options))
1061 1061
 				{
1062 1062
 					$pdf->SetXY($posx_options, $curY);
1063
-					$pdf->MultiCell($posx_montant-$posx_options-0.8, 3, price($line->total_options, 0, $outputlangs), 0, 'R', 0);
1063
+					$pdf->MultiCell($posx_montant - $posx_options - 0.8, 3, price($line->total_options, 0, $outputlangs), 0, 'R', 0);
1064 1064
 				}
1065 1065
 
1066 1066
 				// Print: Montant
1067 1067
 				$pdf->SetXY($posx_montant, $curY);
1068
-				$pdf->MultiCell($objmarge->page_largeur-$objmarge->marge_droite-$posx_montant-0.8, 3, price($line->total_ht, 0, $outputlangs), 0, 'R', 0);
1068
+				$pdf->MultiCell($objmarge->page_largeur - $objmarge->marge_droite - $posx_montant - 0.8, 3, price($line->total_ht, 0, $outputlangs), 0, 'R', 0);
1069 1069
 
1070
-				$nexY+=2;    // Passe espace entre les lignes
1070
+				$nexY += 2; // Passe espace entre les lignes
1071 1071
 
1072 1072
 				// Detect if some page were added automatically and output _tableau for past pages
1073 1073
 				while ($pagenb < $pageposafter)
@@ -1084,7 +1084,7 @@  discard block
 block discarded – undo
1084 1084
 
1085 1085
 					$pagenb++;
1086 1086
 					$pdf->setPage($pagenb);
1087
-					$pdf->setPageOrientation('', 1, 0);	// The only function to edit the bottom margin of current page to set it.
1087
+					$pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
1088 1088
 					if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) self::pagehead($objmarge, $pdf, $object, 0, $outputlangs);
1089 1089
 				}
1090 1090
 			}
@@ -1094,19 +1094,19 @@  discard block
 block discarded – undo
1094 1094
 		if ($pagenb == 1)
1095 1095
 		{
1096 1096
 			self::tableau($objmarge, $pdf, $posx_designation, $posx_options, $posx_montant, $tab_top, $objmarge->page_hauteur - $tab_top - $heightforinfotot - $heightforfooter, 0, $outputlangs, 0, 0, $object->multicurrency_code);
1097
-			$bottomlasttab=$objmarge->page_hauteur - $heightforinfotot - $heightforfooter + 1;
1097
+			$bottomlasttab = $objmarge->page_hauteur - $heightforinfotot - $heightforfooter + 1;
1098 1098
 		}
1099 1099
 		else
1100 1100
 		{
1101 1101
 			self::tableau($objmarge, $pdf, $posx_designation, $posx_options, $posx_montant, $tab_top_newpage, $objmarge->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfooter, 0, $outputlangs, $hidetop, 0, $object->multicurrency_code);
1102
-			$bottomlasttab=$objmarge->page_hauteur - $heightforinfotot - $heightforfooter + 1;
1102
+			$bottomlasttab = $objmarge->page_hauteur - $heightforinfotot - $heightforfooter + 1;
1103 1103
 		}
1104 1104
 
1105 1105
 		// Affiche zone totaux
1106
-		$posy=self::tableau_tot($objmarge, $pdf, $object, $bottomlasttab, $outputlangs, $TTot);
1106
+		$posy = self::tableau_tot($objmarge, $pdf, $object, $bottomlasttab, $outputlangs, $TTot);
1107 1107
 
1108 1108
 		$pdf->Close();
1109
-		$pdf->Output($file,'F');
1109
+		$pdf->Output($file, 'F');
1110 1110
 
1111 1111
 		$pagecount = self::concat($outputlangs, array($origin_file, $file), $origin_file);
1112 1112
 
@@ -1125,7 +1125,7 @@  discard block
 block discarded – undo
1125 1125
 		$level = $line->qty; // TODO à améliorer
1126 1126
 
1127 1127
 		$pdf->SetXY($objmarge->marge_gauche, $curY);
1128
-		$pdf->MultiCell($posx_designation-$objmarge->marge_gauche-0.8, 5, $level, 0, 'L', 0);
1128
+		$pdf->MultiCell($posx_designation - $objmarge->marge_gauche - 0.8, 5, $level, 0, 'L', 0);
1129 1129
 	}
1130 1130
 
1131 1131
 	/**
@@ -1139,50 +1139,50 @@  discard block
 block discarded – undo
1139 1139
 	 */
1140 1140
 	private static function pagehead(&$objmarge, &$pdf, &$object, $showdetail, $outputlangs)
1141 1141
 	{
1142
-		global $conf,$mysoc;
1142
+		global $conf, $mysoc;
1143 1143
 
1144 1144
 		$default_font_size = pdf_getPDFFontSize($outputlangs);
1145 1145
 
1146
-		pdf_pagehead($pdf,$outputlangs,$objmarge->page_hauteur);
1146
+		pdf_pagehead($pdf, $outputlangs, $objmarge->page_hauteur);
1147 1147
 
1148
-		$pdf->SetTextColor(0,0,60);
1149
-		$pdf->SetFont('','B', $default_font_size + 3);
1148
+		$pdf->SetTextColor(0, 0, 60);
1149
+		$pdf->SetFont('', 'B', $default_font_size + 3);
1150 1150
 
1151
-		$posy=$objmarge->marge_haute;
1152
-		$posx=$objmarge->page_largeur-$objmarge->marge_droite-100;
1151
+		$posy = $objmarge->marge_haute;
1152
+		$posx = $objmarge->page_largeur - $objmarge->marge_droite - 100;
1153 1153
 
1154
-		$pdf->SetXY($objmarge->marge_gauche,$posy);
1154
+		$pdf->SetXY($objmarge->marge_gauche, $posy);
1155 1155
 
1156
-		$logo=$conf->mycompany->dir_output.'/logos/'.$mysoc->logo;
1156
+		$logo = $conf->mycompany->dir_output.'/logos/'.$mysoc->logo;
1157 1157
 		if ($mysoc->logo)
1158 1158
 		{
1159 1159
 			if (is_readable($logo))
1160 1160
 			{
1161
-			    $height=pdf_getHeightForLogo($logo);
1162
-			    $pdf->Image($logo, $objmarge->marge_gauche, $posy, 0, $height);	// width=0 (auto)
1161
+			    $height = pdf_getHeightForLogo($logo);
1162
+			    $pdf->Image($logo, $objmarge->marge_gauche, $posy, 0, $height); // width=0 (auto)
1163 1163
 			}
1164 1164
 			else
1165 1165
 			{
1166
-				$pdf->SetTextColor(200,0,0);
1167
-				$pdf->SetFont('','B',$default_font_size - 2);
1168
-				$pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound",$logo), 0, 'L');
1166
+				$pdf->SetTextColor(200, 0, 0);
1167
+				$pdf->SetFont('', 'B', $default_font_size - 2);
1168
+				$pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound", $logo), 0, 'L');
1169 1169
 				$pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L');
1170 1170
 			}
1171 1171
 
1172
-			$posy+=35;
1172
+			$posy += 35;
1173 1173
 		}
1174 1174
 		else
1175 1175
 		{
1176
-			$text=$mysoc->name;
1176
+			$text = $mysoc->name;
1177 1177
 			$pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0, 'L');
1178 1178
 
1179
-			$posy+=15;
1179
+			$posy += 15;
1180 1180
 		}
1181 1181
 
1182 1182
 
1183
-		$pdf->SetTextColor(0,0,0);
1184
-		$pdf->SetFont('','B', $default_font_size + 2);
1185
-		$pdf->SetXY($objmarge->marge_gauche,$posy);
1183
+		$pdf->SetTextColor(0, 0, 0);
1184
+		$pdf->SetFont('', 'B', $default_font_size + 2);
1185
+		$pdf->SetXY($objmarge->marge_gauche, $posy);
1186 1186
 
1187 1187
 		$key = 'subtotalPropalTitle';
1188 1188
 		if ($object->element == 'commande') $key = 'subtotalCommandeTitle';
@@ -1191,14 +1191,14 @@  discard block
 block discarded – undo
1191 1191
 
1192 1192
 		$pdf->MultiCell(150, 4, $outputlangs->transnoentities($key, $object->ref, $object->thirdparty->name), '', 'L');
1193 1193
 
1194
-		$pdf->SetFont('','', $default_font_size);
1195
-		$pdf->SetXY($objmarge->page_largeur-$objmarge->marge_droite-40,$posy);
1194
+		$pdf->SetFont('', '', $default_font_size);
1195
+		$pdf->SetXY($objmarge->page_largeur - $objmarge->marge_droite - 40, $posy);
1196 1196
 		$pdf->MultiCell(40, 4, dol_print_date($object->date, 'daytext'), '', 'R');
1197 1197
 
1198 1198
 		$posy += 8;
1199 1199
 
1200
-		$pdf->SetFont('','B', $default_font_size + 2);
1201
-		$pdf->SetXY($objmarge->marge_gauche,$posy);
1200
+		$pdf->SetFont('', 'B', $default_font_size + 2);
1201
+		$pdf->SetXY($objmarge->marge_gauche, $posy);
1202 1202
 		$pdf->MultiCell(70, 4, $outputlangs->transnoentities('subtotalRecapLot'), '', 'L');
1203 1203
 
1204 1204
 	}
@@ -1216,44 +1216,44 @@  discard block
 block discarded – undo
1216 1216
 	 *   @param		string		$currency		Currency code
1217 1217
 	 *   @return	void
1218 1218
 	 */
1219
-	private static function tableau(&$objmarge, &$pdf, $posx_designation, $posx_options, $posx_montant, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop=0, $hidebottom=0, $currency='')
1219
+	private static function tableau(&$objmarge, &$pdf, $posx_designation, $posx_options, $posx_montant, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0, $currency = '')
1220 1220
 	{
1221 1221
 		global $conf;
1222 1222
 
1223 1223
 		// Force to disable hidetop and hidebottom
1224
-		$hidebottom=0;
1225
-		if ($hidetop) $hidetop=-1;
1224
+		$hidebottom = 0;
1225
+		if ($hidetop) $hidetop = -1;
1226 1226
 
1227 1227
 		$currency = !empty($currency) ? $currency : $conf->currency;
1228 1228
 		$default_font_size = pdf_getPDFFontSize($outputlangs);
1229 1229
 
1230 1230
 		// Amount in (at tab_top - 1)
1231
-		$pdf->SetTextColor(0,0,0);
1232
-		$pdf->SetFont('','',$default_font_size);
1231
+		$pdf->SetTextColor(0, 0, 0);
1232
+		$pdf->SetFont('', '', $default_font_size);
1233 1233
 
1234 1234
 		if (empty($hidetop))
1235 1235
 		{
1236
-			$titre = $outputlangs->transnoentities("AmountInCurrency",$outputlangs->transnoentitiesnoconv("Currency".$currency));
1237
-			$pdf->SetXY($objmarge->page_largeur - $objmarge->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top-4.5);
1236
+			$titre = $outputlangs->transnoentities("AmountInCurrency", $outputlangs->transnoentitiesnoconv("Currency".$currency));
1237
+			$pdf->SetXY($objmarge->page_largeur - $objmarge->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top - 4.5);
1238 1238
 			$pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre);
1239 1239
 
1240
-			if (! empty($conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)) $pdf->Rect($objmarge->marge_gauche, $tab_top, $objmarge->page_largeur-$objmarge->marge_droite-$objmarge->marge_gauche, 8, 'F', null, explode(',',$conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR));
1240
+			if (!empty($conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)) $pdf->Rect($objmarge->marge_gauche, $tab_top, $objmarge->page_largeur - $objmarge->marge_droite - $objmarge->marge_gauche, 8, 'F', null, explode(',', $conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR));
1241 1241
 
1242 1242
 
1243
-			$pdf->line($objmarge->marge_gauche, $tab_top, $objmarge->page_largeur-$objmarge->marge_droite, $tab_top);	// line prend une position y en 2eme param et 4eme param
1243
+			$pdf->line($objmarge->marge_gauche, $tab_top, $objmarge->page_largeur - $objmarge->marge_droite, $tab_top); // line prend une position y en 2eme param et 4eme param
1244 1244
 
1245
-			$pdf->SetXY($posx_designation, $tab_top+2);
1246
-			$pdf->MultiCell($posx_options - $posx_designation,2, $outputlangs->transnoentities("Designation"),'','L');
1247
-			$pdf->SetXY($posx_options, $tab_top+2);
1248
-			$pdf->MultiCell($posx_montant - $posx_options,2, $outputlangs->transnoentities("Options"),'','R');
1249
-			$pdf->SetXY($posx_montant, $tab_top+2);
1250
-			$pdf->MultiCell($objmarge->page_largeur - $objmarge->marge_droite - $posx_montant,2, $outputlangs->transnoentities("Amount"),'','R');
1245
+			$pdf->SetXY($posx_designation, $tab_top + 2);
1246
+			$pdf->MultiCell($posx_options - $posx_designation, 2, $outputlangs->transnoentities("Designation"), '', 'L');
1247
+			$pdf->SetXY($posx_options, $tab_top + 2);
1248
+			$pdf->MultiCell($posx_montant - $posx_options, 2, $outputlangs->transnoentities("Options"), '', 'R');
1249
+			$pdf->SetXY($posx_montant, $tab_top + 2);
1250
+			$pdf->MultiCell($objmarge->page_largeur - $objmarge->marge_droite - $posx_montant, 2, $outputlangs->transnoentities("Amount"), '', 'R');
1251 1251
 
1252
-			$pdf->line($objmarge->marge_gauche, $tab_top+8, $objmarge->page_largeur-$objmarge->marge_droite, $tab_top+8);	// line prend une position y en 2eme param et 4eme param
1252
+			$pdf->line($objmarge->marge_gauche, $tab_top + 8, $objmarge->page_largeur - $objmarge->marge_droite, $tab_top + 8); // line prend une position y en 2eme param et 4eme param
1253 1253
 		}
1254 1254
 		else
1255 1255
 		{
1256
-			$pdf->line($objmarge->marge_gauche, $tab_top-2, $objmarge->page_largeur-$objmarge->marge_droite, $tab_top-2);	// line prend une position y en 2eme param et 4eme param
1256
+			$pdf->line($objmarge->marge_gauche, $tab_top - 2, $objmarge->page_largeur - $objmarge->marge_droite, $tab_top - 2); // line prend une position y en 2eme param et 4eme param
1257 1257
 		}
1258 1258
 
1259 1259
 	}
@@ -1271,29 +1271,29 @@  discard block
 block discarded – undo
1271 1271
 	{
1272 1272
 		global $conf;
1273 1273
 
1274
-		$pdf->line($objmarge->marge_gauche, $posy, $objmarge->page_largeur-$objmarge->marge_droite, $posy);	// line prend une position y en 2eme param et 4eme param
1274
+		$pdf->line($objmarge->marge_gauche, $posy, $objmarge->page_largeur - $objmarge->marge_droite, $posy); // line prend une position y en 2eme param et 4eme param
1275 1275
 
1276 1276
 		$default_font_size = pdf_getPDFFontSize($outputlangs);
1277 1277
 
1278
-		$tab2_top = $posy+2;
1278
+		$tab2_top = $posy + 2;
1279 1279
 		$tab2_hl = 4;
1280
-		$pdf->SetFont('','', $default_font_size - 1);
1280
+		$pdf->SetFont('', '', $default_font_size - 1);
1281 1281
 
1282 1282
 		// Tableau total
1283 1283
 		$col1x = 120; $col2x = 170;
1284 1284
 		if ($objmarge->page_largeur < 210) // To work with US executive format
1285 1285
 		{
1286
-			$col2x-=20;
1286
+			$col2x -= 20;
1287 1287
 		}
1288 1288
 		$largcol2 = ($objmarge->page_largeur - $objmarge->marge_droite - $col2x);
1289 1289
 
1290
-		$useborder=0;
1290
+		$useborder = 0;
1291 1291
 		$index = 0;
1292 1292
 
1293 1293
 		// Total HT
1294
-		$pdf->SetFillColor(255,255,255);
1294
+		$pdf->SetFillColor(255, 255, 255);
1295 1295
 		$pdf->SetXY($col1x, $tab2_top + 0);
1296
-		$pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalHT"), 0, 'L', 1);
1296
+		$pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("TotalHT"), 0, 'L', 1);
1297 1297
 
1298 1298
 		// $total_ht = ($conf->multicurrency->enabled && $object->mylticurrency_tx != 1) ? $TTot['multicurrency_total_ht'] : $TTot['total_ht'];
1299 1299
 		$total_ht = $TTot['total_ht'];
@@ -1301,10 +1301,10 @@  discard block
 block discarded – undo
1301 1301
 		$pdf->MultiCell($largcol2, $tab2_hl, price($total_ht, 0, $outputlangs), 0, 'R', 1);
1302 1302
 
1303 1303
 		// Show VAT by rates and total
1304
-		$pdf->SetFillColor(248,248,248);
1304
+		$pdf->SetFillColor(248, 248, 248);
1305 1305
 
1306
-		$atleastoneratenotnull=0;
1307
-		foreach($TTot['TTotal_tva'] as $tvakey => $tvaval)
1306
+		$atleastoneratenotnull = 0;
1307
+		foreach ($TTot['TTotal_tva'] as $tvakey => $tvaval)
1308 1308
 		{
1309 1309
 			if ($tvakey != 0)    // On affiche pas taux 0
1310 1310
 			{
@@ -1313,15 +1313,15 @@  discard block
 block discarded – undo
1313 1313
 				$index++;
1314 1314
 				$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1315 1315
 
1316
-				$tvacompl='';
1317
-				if (preg_match('/\*/',$tvakey))
1316
+				$tvacompl = '';
1317
+				if (preg_match('/\*/', $tvakey))
1318 1318
 				{
1319
-					$tvakey=str_replace('*','',$tvakey);
1319
+					$tvakey = str_replace('*', '', $tvakey);
1320 1320
 					$tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
1321 1321
 				}
1322
-				$totalvat =$outputlangs->transnoentities("TotalVAT").' ';
1323
-				$totalvat.=vatrate($tvakey,1).$tvacompl;
1324
-				$pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
1322
+				$totalvat = $outputlangs->transnoentities("TotalVAT").' ';
1323
+				$totalvat .= vatrate($tvakey, 1).$tvacompl;
1324
+				$pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1);
1325 1325
 
1326 1326
 				$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1327 1327
 				$pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
@@ -1331,16 +1331,16 @@  discard block
 block discarded – undo
1331 1331
 		// Total TTC
1332 1332
 		$index++;
1333 1333
 		$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1334
-		$pdf->SetTextColor(0,0,60);
1335
-		$pdf->SetFillColor(224,224,224);
1336
-		$pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalTTC"), $useborder, 'L', 1);
1334
+		$pdf->SetTextColor(0, 0, 60);
1335
+		$pdf->SetFillColor(224, 224, 224);
1336
+		$pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("TotalTTC"), $useborder, 'L', 1);
1337 1337
 
1338 1338
 		// $total_ttc = ($conf->multicurrency->enabled && $object->multiccurency_tx != 1) ? $TTot['multicurrency_total_ttc'] : $TTot['total_ttc'];
1339 1339
 		$total_ttc = $TTot['total_ttc'];
1340 1340
 		$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1341 1341
 		$pdf->MultiCell($largcol2, $tab2_hl, price($total_ttc, 0, $outputlangs), $useborder, 'R', 1);
1342 1342
 
1343
-		$pdf->SetTextColor(0,0,0);
1343
+		$pdf->SetTextColor(0, 0, 0);
1344 1344
 
1345 1345
 		$index++;
1346 1346
 		return ($tab2_top + ($tab2_hl * $index));
@@ -1359,12 +1359,12 @@  discard block
 block discarded – undo
1359 1359
 	 * @param	int		$hidebottom		Hide bottom
1360 1360
 	 * @return	void
1361 1361
 	 */
1362
-	private static function printRect($pdf, $x, $y, $l, $h, $hidetop=0, $hidebottom=0)
1362
+	private static function printRect($pdf, $x, $y, $l, $h, $hidetop = 0, $hidebottom = 0)
1363 1363
 	{
1364
-	    if (empty($hidetop) || $hidetop==-1) $pdf->line($x, $y, $x+$l, $y);
1365
-	    $pdf->line($x+$l, $y, $x+$l, $y+$h);
1366
-	    if (empty($hidebottom)) $pdf->line($x+$l, $y+$h, $x, $y+$h);
1367
-	    $pdf->line($x, $y+$h, $x, $y);
1364
+	    if (empty($hidetop) || $hidetop == -1) $pdf->line($x, $y, $x + $l, $y);
1365
+	    $pdf->line($x + $l, $y, $x + $l, $y + $h);
1366
+	    if (empty($hidebottom)) $pdf->line($x + $l, $y + $h, $x, $y + $h);
1367
+	    $pdf->line($x, $y + $h, $x, $y);
1368 1368
 	}
1369 1369
 
1370 1370
 	/**
@@ -1373,13 +1373,13 @@  discard block
 block discarded – undo
1373 1373
 	 * @param string    $fileoutput
1374 1374
 	 * @return int
1375 1375
 	 */
1376
-	public static function concat(&$outputlangs, $files, $fileoutput='')
1376
+	public static function concat(&$outputlangs, $files, $fileoutput = '')
1377 1377
 	{
1378 1378
 		global $conf;
1379 1379
 
1380 1380
 		if (empty($fileoutput)) $fileoutput = $file[0];
1381 1381
 
1382
-		$pdf=pdf_getInstance();
1382
+		$pdf = pdf_getInstance();
1383 1383
         if (class_exists('TCPDF'))
1384 1384
         {
1385 1385
             $pdf->setPrintHeader(false);
@@ -1387,10 +1387,10 @@  discard block
 block discarded – undo
1387 1387
         }
1388 1388
         $pdf->SetFont(pdf_getPDFFont($outputlangs));
1389 1389
 
1390
-        if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
1390
+        if (!empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
1391 1391
 
1392 1392
 
1393
-		foreach($files as $file)
1393
+		foreach ($files as $file)
1394 1394
 		{
1395 1395
 			$pagecount = $pdf->setSourceFile($file);
1396 1396
 			for ($i = 1; $i <= $pagecount; $i++)
@@ -1402,8 +1402,8 @@  discard block
 block discarded – undo
1402 1402
 			}
1403 1403
 		}
1404 1404
 
1405
-		$pdf->Output($fileoutput,'F');
1406
-		if (! empty($conf->global->MAIN_UMASK)) @chmod($file, octdec($conf->global->MAIN_UMASK));
1405
+		$pdf->Output($fileoutput, 'F');
1406
+		if (!empty($conf->global->MAIN_UMASK)) @chmod($file, octdec($conf->global->MAIN_UMASK));
1407 1407
 
1408 1408
 		return $pagecount;
1409 1409
 	}
@@ -1416,7 +1416,7 @@  discard block
 block discarded – undo
1416 1416
 	 */
1417 1417
 	public static function hasNcTitle(&$line)
1418 1418
 	{
1419
-		if(isset($line->has_nc_title)) return $line->has_nc_title;
1419
+		if (isset($line->has_nc_title)) return $line->has_nc_title;
1420 1420
 
1421 1421
 		$TTitle = self::getAllTitleFromLine($line);
1422 1422
 		foreach ($TTitle as &$line_title)
Please login to merge, or discard this patch.
Braces   +299 added lines, -143 removed lines patch added patch discarded remove patch
@@ -20,18 +20,23 @@  discard block
 block discarded – undo
20 20
 			/**
21 21
 			 * @var $object Facture
22 22
 			 */
23
-			if($object->element=='facture') $res =  $object->addline($object->id, $label, 0,$qty,0,0,0,0,0,'','',0,0,'','HT',0,9,-1, TSubtotal::$module_number);
23
+			if($object->element=='facture') {
24
+				$res =  $object->addline($object->id, $label, 0,$qty,0,0,0,0,0,'','',0,0,'','HT',0,9,-1, TSubtotal::$module_number);
25
+			}
24 26
 			/**
25 27
 			 * @var $object Propal
26 28
 			 */
27
-			else if($object->element=='propal') $res =  $object->addline($object->id,$label, 0,$qty,0,0,0,0,0,'HT',0,0,9,-1, TSubtotal::$module_number);
29
+			else if($object->element=='propal') {
30
+				$res =  $object->addline($object->id,$label, 0,$qty,0,0,0,0,0,'HT',0,0,9,-1, TSubtotal::$module_number);
31
+			}
28 32
 			/**
29 33
 			 * @var $object Commande
30 34
 			 */
31
-			else if($object->element=='commande') $res =  $object->addline($object->id,$label, 0,$qty,0,0,0,0,0,0,0,'HT',0,'','',9,-1, TSubtotal::$module_number);
35
+			else if($object->element=='commande') {
36
+				$res =  $object->addline($object->id,$label, 0,$qty,0,0,0,0,0,0,0,'HT',0,'','',9,-1, TSubtotal::$module_number);
37
+			}
32 38
 
33
-		}
34
-		else {
39
+		} else {
35 40
 			$desc = '';
36 41
 
37 42
 			$TNotElements = array ('invoice_supplier', 'order_supplier');
@@ -44,26 +49,33 @@  discard block
 block discarded – undo
44 49
             {
45 50
                 /** @var Facture $object */
46 51
                 $res =  $object->addline($desc, 0,$qty,0,0,0,0,0,'','',0,0,'','HT',0,9,$rang, TSubtotal::$module_number, '', 0, 0, null, 0, $label);
47
-            }
48
-			elseif($object->element=='invoice_supplier') {
52
+            } elseif($object->element=='invoice_supplier') {
49 53
                 /** @var FactureFournisseur $object */
50 54
 			    $object->special_code = TSubtotal::$module_number;
51
-                if( (float)DOL_VERSION < 6 ) $rang = $object->line_max() + 1;
55
+                if( (float)DOL_VERSION < 6 ) {
56
+                	$rang = $object->line_max() + 1;
57
+                }
52 58
 			    $res = $object->addline($label,0,0,0,0,$qty,0,0,'','',0,0,'HT',9,$rang);
53 59
 			}
54 60
 			/**
55 61
 			 * @var $object Propal
56 62
 			 */
57
-			else if($object->element=='propal') $res = $object->addline($desc, 0,$qty,0,0,0,0,0,'HT',0,0,9,$rang, TSubtotal::$module_number, 0, 0, 0, $label);
63
+			else if($object->element=='propal') {
64
+				$res = $object->addline($desc, 0,$qty,0,0,0,0,0,'HT',0,0,9,$rang, TSubtotal::$module_number, 0, 0, 0, $label);
65
+			}
58 66
 			/**
59 67
 			 * @var $object Propal Fournisseur
60 68
 			 */
61
-			else if($object->element=='supplier_proposal') $res = $object->addline($desc, 0,$qty,0,0,0,0,0,'HT',0,0,9,$rang, TSubtotal::$module_number, 0, 0, 0, $label);
69
+			else if($object->element=='supplier_proposal') {
70
+				$res = $object->addline($desc, 0,$qty,0,0,0,0,0,'HT',0,0,9,$rang, TSubtotal::$module_number, 0, 0, 0, $label);
71
+			}
62 72
 
63 73
 			/**
64 74
 			 * @var $object Commande
65 75
 			 */
66
-			else if($object->element=='commande') $res =  $object->addline($desc, 0,$qty,0,0,0,0,0,0,0,'HT',0,'','',9,$rang, TSubtotal::$module_number, 0, null, 0, $label);
76
+			else if($object->element=='commande') {
77
+				$res =  $object->addline($desc, 0,$qty,0,0,0,0,0,0,0,'HT',0,'','',9,$rang, TSubtotal::$module_number, 0, null, 0, $label);
78
+			}
67 79
 			/**
68 80
 			 * @var $object Commande fournisseur
69 81
 			 */
@@ -74,7 +86,9 @@  discard block
 block discarded – undo
74 86
 			/**
75 87
 			 * @var $object Facturerec
76 88
 			 */
77
-			else if($object->element=='facturerec') $res =  $object->addline($desc, 0,$qty, 0, 0, 0, 0, 0, 'HT', 0, '', 0, 9, $rang, TSubtotal::$module_number,$label);
89
+			else if($object->element=='facturerec') {
90
+				$res =  $object->addline($desc, 0,$qty, 0, 0, 0, 0, 0, 'HT', 0, '', 0, 9, $rang, TSubtotal::$module_number,$label);
91
+			}
78 92
 
79 93
 		}
80 94
 
@@ -99,8 +113,9 @@  discard block
 block discarded – undo
99 113
 			// Define output language
100 114
 			$outputlangs = $langs;
101 115
 			$newlang = GETPOST('lang_id', 'alpha');
102
-			if (! empty($conf->global->MAIN_MULTILANGS) && empty($newlang))
103
-				$newlang = !empty($object->client) ? $object->client->default_lang : $object->thirdparty->default_lang;
116
+			if (! empty($conf->global->MAIN_MULTILANGS) && empty($newlang)) {
117
+							$newlang = !empty($object->client) ? $object->client->default_lang : $object->thirdparty->default_lang;
118
+			}
104 119
 			if (! empty($newlang)) {
105 120
 				$outputlangs = new Translate("", $conf);
106 121
 				$outputlangs->setDefaultLang($newlang);
@@ -109,13 +124,18 @@  discard block
 block discarded – undo
109 124
 			$ret = $object->fetch($object->id); // Reload to get new records
110 125
 			if ((float) DOL_VERSION <= 3.6)
111 126
 			{
112
-				if ($object->element == 'propal') propale_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
113
-				elseif ($object->element == 'commande') commande_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
114
-				elseif ($object->element == 'facture') facture_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
115
-			}
116
-			else
127
+				if ($object->element == 'propal') {
128
+					propale_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
129
+				} elseif ($object->element == 'commande') {
130
+					commande_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
131
+				} elseif ($object->element == 'facture') {
132
+					facture_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
133
+				}
134
+			} else
117 135
 			{
118
-				if ($object->element!= 'facturerec') $object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
136
+				if ($object->element!= 'facturerec') {
137
+					$object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
138
+				}
119 139
 			}
120 140
 		}
121 141
 	}
@@ -129,7 +149,9 @@  discard block
 block discarded – undo
129 149
 	 */
130 150
 	public static function updateRang(&$object, $rang_start, $move_to=1)
131 151
 	{
132
-		if (!class_exists('GenericObject')) require_once DOL_DOCUMENT_ROOT.'/core/class/genericobject.class.php';
152
+		if (!class_exists('GenericObject')) {
153
+			require_once DOL_DOCUMENT_ROOT.'/core/class/genericobject.class.php';
154
+		}
133 155
 
134 156
 		$row=new GenericObject($object->db);
135 157
 		$row->table_element_line = $object->table_element_line;
@@ -138,7 +160,9 @@  discard block
 block discarded – undo
138 160
 
139 161
 		foreach ($object->lines as &$line)
140 162
 		{
141
-			if ($line->rang < $rang_start) continue;
163
+			if ($line->rang < $rang_start) {
164
+				continue;
165
+			}
142 166
 
143 167
 			$row->updateRangOfLine($line->id, $line->rang+$move_to);
144 168
 		}
@@ -161,21 +185,28 @@  discard block
 block discarded – undo
161 185
 		foreach ($TTitle_reverse as $k => $title_line)
162 186
 		{
163 187
 			$title_niveau = self::getNiveau($title_line);
164
-			if ($title_niveau < $level_new_title) break;
188
+			if ($title_niveau < $level_new_title) {
189
+				break;
190
+			}
165 191
 
166 192
 			$rang_to_add = self::titleHasTotalLine($object, $title_line, true, true);
167 193
 
168 194
 			if (is_numeric($rang_to_add))
169 195
 			{
170
-				if ($rang_to_add != -1) self::updateRang($object, $rang_to_add);
196
+				if ($rang_to_add != -1) {
197
+					self::updateRang($object, $rang_to_add);
198
+				}
171 199
 
172 200
 				self::addSubTotalLine($object, $langs->trans('SubTotal'), 100-$title_niveau, $rang_to_add);
173 201
 
174 202
 				$object->lines[] = $object->line; // ajout de la ligne dans le tableau de ligne (Dolibarr ne le fait pas)
175 203
 				if ($rang_to_add != -1)
176 204
 				{
177
-					if (method_exists($object, 'fetch_lines')) $object->fetch_lines();
178
-					else $object->fetch($object->id);
205
+					if (method_exists($object, 'fetch_lines')) {
206
+						$object->fetch_lines();
207
+					} else {
208
+						$object->fetch($object->id);
209
+					}
179 210
 				}
180 211
 			}
181 212
 		}
@@ -219,7 +250,9 @@  discard block
 block discarded – undo
219 250
 
220 251
 		foreach ($TTitle as $k => $title_line)
221 252
 		{
222
-			if (self::titleHasTotalLine($object, $title_line)) unset($TTitle[$k]);
253
+			if (self::titleHasTotalLine($object, $title_line)) {
254
+				unset($TTitle[$k]);
255
+			}
223 256
 		}
224 257
 
225 258
 		return $TTitle;
@@ -236,23 +269,41 @@  discard block
 block discarded – undo
236 269
 	 */
237 270
 	public static function titleHasTotalLine(&$object, &$title_line, $strict_mode=false, $return_rang_on_false=false)
238 271
 	{
239
-		if (empty($object->lines) || !is_array($object->lines)) return false;
272
+		if (empty($object->lines) || !is_array($object->lines)) {
273
+			return false;
274
+		}
240 275
 
241 276
 		$title_niveau = self::getNiveau($title_line);
242 277
 		foreach ($object->lines as &$line)
243 278
 		{
244
-			if ($line->rang <= $title_line->rang) continue;
245
-			if (self::isTitle($line) && self::getNiveau($line) <= $title_niveau) return false; // Oups on croise un titre d'un niveau inférieur ou égale (exemple : je croise un titre niveau 2 alors que je suis sur un titre de niveau 3) pas lieu de continuer car un nouveau bloc commence
246
-			if (!self::isSubtotal($line)) continue;
279
+			if ($line->rang <= $title_line->rang) {
280
+				continue;
281
+			}
282
+			if (self::isTitle($line) && self::getNiveau($line) <= $title_niveau) {
283
+				return false;
284
+			}
285
+			// Oups on croise un titre d'un niveau inférieur ou égale (exemple : je croise un titre niveau 2 alors que je suis sur un titre de niveau 3) pas lieu de continuer car un nouveau bloc commence
286
+			if (!self::isSubtotal($line)) {
287
+				continue;
288
+			}
247 289
 
248 290
 			$subtotal_niveau = self::getNiveau($line);
249 291
 
250 292
 			// Comparaison du niveau de la ligne de sous-total avec celui du titre
251
-			if ($subtotal_niveau == $title_niveau) return true; // niveau égale => Ok mon titre a un sous-total
252
-			elseif ($subtotal_niveau < $title_niveau) // niveau inférieur trouvé (exemple : sous-total de niveau 1 contre mon titre de niveau 3)
293
+			if ($subtotal_niveau == $title_niveau) {
294
+				return true;
295
+			}
296
+			// niveau égale => Ok mon titre a un sous-total
297
+			elseif ($subtotal_niveau < $title_niveau) {
298
+				// niveau inférieur trouvé (exemple : sous-total de niveau 1 contre mon titre de niveau 3)
253 299
 			{
254
-				if ($strict_mode) return ($return_rang_on_false) ? $line->rang : false; // mode strict niveau pas égale donc faux
255
-				else return true; // mode libre => OK je considère que mon titre à un sous-total
300
+				if ($strict_mode) return ($return_rang_on_false) ? $line->rang : false;
301
+			}
302
+			// mode strict niveau pas égale donc faux
303
+				else {
304
+					return true;
305
+				}
306
+				// mode libre => OK je considère que mon titre à un sous-total
256 307
 			}
257 308
 		}
258 309
 
@@ -311,16 +362,19 @@  discard block
 block discarded – undo
311 362
 
312 363
 		foreach ($object->lines as &$l)
313 364
 		{
314
-			if ($l->rang <= $line->rang) continue;
315
-			elseif (self::isSubtotal($l) && self::getNiveau($l) <= self::getNiveau($line)) break;
316
-			elseif ($breakOnTitle && self::isTitle($l) && self::getNiveau($l) <= self::getNiveau($line)) break;
365
+			if ($l->rang <= $line->rang) {
366
+				continue;
367
+			} elseif (self::isSubtotal($l) && self::getNiveau($l) <= self::getNiveau($line)) {
368
+				break;
369
+			} elseif ($breakOnTitle && self::isTitle($l) && self::getNiveau($l) <= self::getNiveau($line)) {
370
+				break;
371
+			}
317 372
 
318 373
 			if (!empty($l->array_options['options_subtotal_nc']))
319 374
 			{
320 375
 				$tabprice = calcul_price_total($l->qty, $l->subprice, $l->remise_percent, $l->tva_tx, $l->localtax1_tx, $l->localtax2_tx, 0, 'HT', $l->info_bits, $l->product_type);
321 376
 				$TTot['total_options'] += $tabprice[0]; // total ht
322
-			}
323
-			else
377
+			} else
324 378
 			{
325 379
 				// Fix DA020000 : exlure les sous-totaux du calcul (calcul pété)
326 380
 				// sinon ça compte les ligne de produit puis les sous-totaux qui leurs correspondent...
@@ -353,16 +407,23 @@  discard block
 block discarded – undo
353 407
 	 */
354 408
 	public static function getOrderIdFromLineId(&$db, $fk_commandedet, $supplier = false)
355 409
 	{
356
-		if (empty($fk_commandedet)) return false;
410
+		if (empty($fk_commandedet)) {
411
+			return false;
412
+		}
357 413
 
358 414
 		$table = 'commandedet';
359
-		if ($supplier) $table = 'commande_fournisseurdet';
415
+		if ($supplier) {
416
+			$table = 'commande_fournisseurdet';
417
+		}
360 418
 
361 419
 		$sql = 'SELECT fk_commande FROM '.MAIN_DB_PREFIX.$table.' WHERE rowid = '.$fk_commandedet;
362 420
 		$resql = $db->query($sql);
363 421
 
364
-		if ($resql && ($row = $db->fetch_object($resql))) return $row->fk_commande;
365
-		else return false;
422
+		if ($resql && ($row = $db->fetch_object($resql))) {
423
+			return $row->fk_commande;
424
+		} else {
425
+			return false;
426
+		}
366 427
 	}
367 428
 
368 429
 	/**
@@ -373,16 +434,23 @@  discard block
 block discarded – undo
373 434
 	 */
374 435
 	public static function getLastLineOrderId(&$db, $fk_commande, $supplier = false)
375 436
 	{
376
-		if (empty($fk_commande)) return false;
437
+		if (empty($fk_commande)) {
438
+			return false;
439
+		}
377 440
 
378 441
         $table = 'commandedet';
379
-        if ($supplier) $table = 'commande_fournisseurdet';
442
+        if ($supplier) {
443
+        	$table = 'commande_fournisseurdet';
444
+        }
380 445
 
381 446
 		$sql = 'SELECT rowid FROM '.MAIN_DB_PREFIX.$table.' WHERE fk_commande = '.$fk_commande.' ORDER BY rang DESC LIMIT 1';
382 447
 		$resql = $db->query($sql);
383 448
 
384
-		if ($resql && ($row = $db->fetch_object($resql))) return (int) $row->rowid;
385
-		else return false;
449
+		if ($resql && ($row = $db->fetch_object($resql))) {
450
+			return (int) $row->rowid;
451
+		} else {
452
+			return false;
453
+		}
386 454
 	}
387 455
 
388 456
 	/**
@@ -393,14 +461,19 @@  discard block
 block discarded – undo
393 461
 	 */
394 462
 	public static function getParentTitleOfLine(&$object, $rang, $lvl = 0)
395 463
 	{
396
-		if ($rang <= 0) return false;
464
+		if ($rang <= 0) {
465
+			return false;
466
+		}
397 467
 
398 468
 		$skip_title = 0;
399 469
 		$TLineReverse = array_reverse($object->lines);
400 470
 
401 471
 		foreach($TLineReverse as $line)
402 472
 		{
403
-			if ($line->rang >= $rang || ($lvl > 0 && self::getNiveau($line) > $lvl)) continue; // Tout ce qui ce trouve en dessous j'ignore, nous voulons uniquement ce qui ce trouve au dessus
473
+			if ($line->rang >= $rang || ($lvl > 0 && self::getNiveau($line) > $lvl)) {
474
+				continue;
475
+			}
476
+			// Tout ce qui ce trouve en dessous j'ignore, nous voulons uniquement ce qui ce trouve au dessus
404 477
 
405 478
             if (self::isTitle($line))
406 479
 			{
@@ -413,8 +486,7 @@  discard block
 block discarded – undo
413 486
 				//@INFO J'ai ma ligne titre qui contient ma ligne, par contre je check pas s'il y a un sous-total
414 487
 				return $line;
415 488
 				break;
416
-			}
417
-			elseif (self::isSubtotal($line))
489
+			} elseif (self::isSubtotal($line))
418 490
 			{
419 491
 				// Il s'agit d'un sous-total, ça veut dire que le prochain titre théoriquement doit être ignorer (je travail avec un incrément au cas ou je croise plusieurs sous-totaux)
420 492
 				$skip_title++;
@@ -434,7 +506,9 @@  discard block
 block discarded – undo
434 506
 		$res = $line->special_code == self::$module_number && $line->product_type == 9 && $line->qty <= 9;
435 507
 		if($res && $level > -1) {
436 508
 			return $line->qty == $level;
437
-		} else return $res;
509
+		} else {
510
+			return $res;
511
+		}
438 512
 
439 513
 	}
440 514
 
@@ -448,7 +522,9 @@  discard block
 block discarded – undo
448 522
 	    $res = $line->special_code == self::$module_number && $line->product_type == 9 && $line->qty >= 90;
449 523
 	    if($res && $level > -1) {
450 524
 	        return self::getNiveau($line) == $level;
451
-	    } else return $res;
525
+	    } else {
526
+	    	return $res;
527
+	    }
452 528
 	}
453 529
 
454 530
 	/**
@@ -482,10 +558,14 @@  discard block
 block discarded – undo
482 558
 		// editeur wysiwyg
483 559
 		require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
484 560
 		$nbrows=ROWS_2;
485
-		if (! empty($conf->global->MAIN_INPUT_DESC_HEIGHT)) $nbrows=$conf->global->MAIN_INPUT_DESC_HEIGHT;
561
+		if (! empty($conf->global->MAIN_INPUT_DESC_HEIGHT)) {
562
+			$nbrows=$conf->global->MAIN_INPUT_DESC_HEIGHT;
563
+		}
486 564
 		$enable=(isset($conf->global->FCKEDITOR_ENABLE_DETAILS)?$conf->global->FCKEDITOR_ENABLE_DETAILS:0);
487 565
 		$toolbarname='dolibarr_details';
488
-		if (! empty($conf->global->FCKEDITOR_ENABLE_DETAILS_FULL)) $toolbarname='dolibarr_notes';
566
+		if (! empty($conf->global->FCKEDITOR_ENABLE_DETAILS_FULL)) {
567
+			$toolbarname='dolibarr_notes';
568
+		}
489 569
 		$text = !empty($line->description)?$line->description:$line->label;
490 570
 		$doleditor=new DolEditor('line-description',$text,'',164,$toolbarname,'',false,true,$enable,$nbrows,'98%', $readonly);
491 571
 		return $doleditor->Create(1);
@@ -506,12 +586,10 @@  discard block
 block discarded – undo
506 586
 		{
507 587
 		    $object->statut = 0; // hack for facture rec
508 588
 		    $createRight = $user->rights->facture->creer;
509
-		}
510
-		elseif($object->element == 'order_supplier' )
589
+		} elseif($object->element == 'order_supplier' )
511 590
 		{
512 591
 		    $createRight = $user->rights->fournisseur->commande->creer;
513
-		}
514
-		elseif($object->element == 'invoice_supplier' )
592
+		} elseif($object->element == 'invoice_supplier' )
515 593
 		{
516 594
 		    $createRight = $user->rights->fournisseur->facture->creer;
517 595
 		}
@@ -522,11 +600,16 @@  discard block
 block discarded – undo
522 600
 
523 601
             if(!empty($object->lines)) {
524 602
                 foreach($object->lines as $line) {
525
-                    if($line->id == $lineid) $duplicateLine = $line;
603
+                    if($line->id == $lineid) {
604
+                    	$duplicateLine = $line;
605
+                    }
526 606
                 }
527 607
             }
528
-            if(!empty($duplicateLine) && !self::isModSubtotalLine($duplicateLine)) $TLine = array($duplicateLine);
529
-            else $TLine = self::getLinesFromTitleId($object, $lineid, $withBlockLine);
608
+            if(!empty($duplicateLine) && !self::isModSubtotalLine($duplicateLine)) {
609
+            	$TLine = array($duplicateLine);
610
+            } else {
611
+            	$TLine = self::getLinesFromTitleId($object, $lineid, $withBlockLine);
612
+            }
530 613
 
531 614
 			if (!empty($TLine))
532 615
 			{
@@ -593,7 +676,9 @@  discard block
 block discarded – undo
593 676
 
594 677
 					$TLineAdded[] = $object->line;
595 678
 					// Error from addline
596
-					if ($res <= 0) break;
679
+					if ($res <= 0) {
680
+						break;
681
+					}
597 682
 				}
598 683
 
599 684
 				if ($res > 0)
@@ -603,11 +688,12 @@  discard block
 block discarded – undo
603 688
 					{
604 689
 					    // ça peut paraitre non optimisé de déclancher la fonction sur toutes les lignes mais ceci est nécessaire pour réappliquer l'état exact de chaque ligne
605 690
                         //En gros ça met à jour le sous total
606
-					   if(!empty($line->array_options['options_subtotal_nc'])) _updateLineNC($object->element, $object->id, $line->id, $line->array_options['options_subtotal_nc']);
691
+					   if(!empty($line->array_options['options_subtotal_nc'])) {
692
+					   	_updateLineNC($object->element, $object->id, $line->id, $line->array_options['options_subtotal_nc']);
693
+					   }
607 694
 					}
608 695
 					return count($TLineAdded);
609
-				}
610
-				else
696
+				} else
611 697
 				{
612 698
 					$object->db->rollback();
613 699
 					return -1;
@@ -632,10 +718,14 @@  discard block
 block discarded – undo
632 718
 		global $langs;
633 719
 
634 720
 		// Besoin de comparer sur les 2 formes d'écriture
635
-		if (!$key_is_id) $TTitle_search = array($langs->trans($key_trad), $langs->transnoentitiesnoconv($key_trad));
721
+		if (!$key_is_id) {
722
+			$TTitle_search = array($langs->trans($key_trad), $langs->transnoentitiesnoconv($key_trad));
723
+		}
636 724
 
637 725
 		$TTitle_under_search = array();
638
-		if (!empty($under_title)) $TTitle_under_search = array($langs->trans($under_title), $langs->transnoentitiesnoconv($under_title));
726
+		if (!empty($under_title)) {
727
+			$TTitle_under_search = array($langs->trans($under_title), $langs->transnoentitiesnoconv($under_title));
728
+		}
639 729
 
640 730
 		$TLine = array();
641 731
 		$add_line = false;
@@ -645,28 +735,37 @@  discard block
 block discarded – undo
645 735
 		{
646 736
 			if (!$under_title_found && !empty($TTitle_under_search))
647 737
 			{
648
-				if ($line->product_type == 9 && (in_array($line->desc, $TTitle_under_search) || in_array($line->label, $TTitle_under_search)) ) $under_title_found = true;
649
-			}
650
-			else
738
+				if ($line->product_type == 9 && (in_array($line->desc, $TTitle_under_search) || in_array($line->label, $TTitle_under_search)) ) {
739
+					$under_title_found = true;
740
+				}
741
+			} else
651 742
 			{
652 743
 				if ( ($key_is_id && $line->id == $key_trad) || (!$key_is_id && $line->product_type == 9 && $line->qty == $level && (in_array($line->desc, $TTitle_search) || in_array($line->label, $TTitle_search) )))
653 744
 				{
654
-					if ($key_is_id) $level = $line->qty;
745
+					if ($key_is_id) {
746
+						$level = $line->qty;
747
+					}
655 748
 
656 749
 					$add_line = true;
657
-					if ($withBlockLine) $TLine[] = $line;
750
+					if ($withBlockLine) {
751
+						$TLine[] = $line;
752
+					}
658 753
 					continue;
659
-				}
660
-				elseif ($add_line && TSubtotal::isModSubtotalLine($line) && TSubtotal::getNiveau($line) == $level) // Si on tombe sur un sous-total, il faut que ce soit un du même niveau que le titre
754
+				} elseif ($add_line && TSubtotal::isModSubtotalLine($line) && TSubtotal::getNiveau($line) == $level) {
755
+					// Si on tombe sur un sous-total, il faut que ce soit un du même niveau que le titre
661 756
 				{
662 757
 					if ($withBlockLine) $TLine[] = $line;
758
+				}
663 759
 					break;
664 760
 				}
665 761
 
666 762
 				if ($add_line)
667 763
 				{
668
-					if (!$withBlockLine && (self::isTitle($line) || self::isSubtotal($line)) ) continue;
669
-					else $TLine[] = $line;
764
+					if (!$withBlockLine && (self::isTitle($line) || self::isSubtotal($line)) ) {
765
+						continue;
766
+					} else {
767
+						$TLine[] = $line;
768
+					}
670 769
 				}
671 770
 			}
672 771
 		}
@@ -736,7 +835,9 @@  discard block
 block discarded – undo
736 835
 
737 836
 			case 'order_supplier':
738 837
 			    $object->special_code = SELF::$module_number;
739
-			    if (empty($desc)) $desc = $label;
838
+			    if (empty($desc)) {
839
+			    	$desc = $label;
840
+			    }
740 841
 			    $res = $object->updateline($rowid, $desc, $pu, $qty, $remise_percent, $txtva, $txlocaltax1, $txlocaltax2, $price_base_type, $info_bits, $type, 0, $date_start, $date_end, $array_options, $fk_unit);
741 842
 			    break;
742 843
 
@@ -746,7 +847,9 @@  discard block
 block discarded – undo
746 847
 
747 848
 			case 'invoice_supplier':
748 849
 			    $object->special_code = SELF::$module_number;
749
-			    if (empty($desc)) $desc = $label;
850
+			    if (empty($desc)) {
851
+			    	$desc = $label;
852
+			    }
750 853
 			    $res = $object->updateline($rowid, $desc, $pu, $txtva, $txlocaltax1, $txlocaltax2, $qty, 0, $price_base_type, $info_bits, $type, $remise_percent, 0, $date_start, $date_end, $array_options, $fk_unit);
751 854
 			    break;
752 855
 
@@ -763,8 +866,11 @@  discard block
 block discarded – undo
763 866
 				break;
764 867
 		}
765 868
 
766
-		if ($res <= 0) $object->db->rollback();
767
-		else $object->db->commit();
869
+		if ($res <= 0) {
870
+			$object->db->rollback();
871
+		} else {
872
+			$object->db->commit();
873
+		}
768 874
 
769 875
 		return $res;
770 876
 	}
@@ -779,24 +885,20 @@  discard block
 block discarded – undo
779 885
 		global $db, $object;
780 886
 
781 887
 		$TTitle = array();
782
-		if(! empty($object->id) && in_array($object->element, array('propal', 'commande', 'facture'))) {}
783
-		else {
888
+		if(! empty($object->id) && in_array($object->element, array('propal', 'commande', 'facture'))) {} else {
784 889
 			if ($origin_line->element == 'propaldet')
785 890
 			{
786 891
 				$object = new Propal($db);
787 892
 				$object->fetch($origin_line->fk_propal);
788
-			}
789
-			else if ($origin_line->element == 'commandedet')
893
+			} else if ($origin_line->element == 'commandedet')
790 894
 			{
791 895
 				$object = new Commande($db);
792 896
 				$object->fetch($origin_line->fk_commande);
793
-			}
794
-			else if ($origin_line->element == 'facturedet')
897
+			} else if ($origin_line->element == 'facturedet')
795 898
 			{
796 899
 				$object = new Facture($db);
797 900
 				$object->fetch($origin_line->fk_facture);
798
-			}
799
-			else
901
+			} else
800 902
 			{
801 903
 				return $TTitle;
802 904
 			}
@@ -806,8 +908,11 @@  discard block
 block discarded – undo
806 908
 		$i = 0;
807 909
 		foreach ($object->lines as &$line)
808 910
 		{
809
-			if ($origin_line->id == $line->id) break;
810
-			else $i++;
911
+			if ($origin_line->id == $line->id) {
912
+				break;
913
+			} else {
914
+				$i++;
915
+			}
811 916
 		}
812 917
 
813 918
 		$i--; // Skip la ligne d'origine
@@ -822,26 +927,30 @@  discard block
 block discarded – undo
822 927
 				if (self::isSubtotal($object->lines[$y]))
823 928
 				{
824 929
 					$next_title_lvl_to_skip = self::getNiveau($object->lines[$y]);
825
-				}
826
-				elseif (self::isTitle($object->lines[$y]))
930
+				} elseif (self::isTitle($object->lines[$y]))
827 931
 				{
828 932
 					if ($object->lines[$y]->qty == $next_title_lvl_to_skip)
829 933
 					{
830 934
 						$next_title_lvl_to_skip = 0;
831 935
 						continue;
832
-					}
833
-					else
936
+					} else
834 937
 					{
835
-						if (empty($object->lines[$y]->array_options) && !empty($object->lines[$y]->id)) $object->lines[$y]->fetch_optionals();
938
+						if (empty($object->lines[$y]->array_options) && !empty($object->lines[$y]->id)) {
939
+							$object->lines[$y]->fetch_optionals();
940
+						}
836 941
 						$TTitle[$object->lines[$y]->id] = $object->lines[$y];
837 942
 
838
-						if ($object->lines[$y]->qty == 1) break;
943
+						if ($object->lines[$y]->qty == 1) {
944
+							break;
945
+						}
839 946
 					}
840 947
 				}
841 948
 			}
842 949
 		}
843 950
 
844
-		if ($reverse) $TTitle = array_reverse($TTitle, true);
951
+		if ($reverse) {
952
+			$TTitle = array_reverse($TTitle, true);
953
+		}
845 954
 
846 955
 		return $TTitle;
847 956
 	}
@@ -852,9 +961,13 @@  discard block
 block discarded – undo
852 961
 	 */
853 962
 	public static function getNiveau(&$line)
854 963
 	{
855
-		if (self::isTitle($line)) return $line->qty;
856
-		elseif (self::isSubtotal($line)) return 100 - $line->qty;
857
-		else return 0;
964
+		if (self::isTitle($line)) {
965
+			return $line->qty;
966
+		} elseif (self::isSubtotal($line)) {
967
+			return 100 - $line->qty;
968
+		} else {
969
+			return 0;
970
+		}
858 971
 	}
859 972
 
860 973
 	/**
@@ -882,10 +995,16 @@  discard block
 block discarded – undo
882 995
 		$objmarge->marge_droite = 10;
883 996
 
884 997
 		$objectref = dol_sanitizeFileName($object->ref);
885
-		if ($object->element == 'propal') $dir = $conf->propal->dir_output . '/' . $objectref;
886
-		elseif ($object->element == 'commande') $dir = $conf->commande->dir_output . '/' . $objectref;
887
-		elseif ($object->element == 'facture') $dir = $conf->facture->dir_output . '/' . $objectref;
888
-		elseif ($object->element == 'facturerec') return; // no PDF for facturerec
998
+		if ($object->element == 'propal') {
999
+			$dir = $conf->propal->dir_output . '/' . $objectref;
1000
+		} elseif ($object->element == 'commande') {
1001
+			$dir = $conf->commande->dir_output . '/' . $objectref;
1002
+		} elseif ($object->element == 'facture') {
1003
+			$dir = $conf->facture->dir_output . '/' . $objectref;
1004
+		} elseif ($object->element == 'facturerec') {
1005
+			return;
1006
+		}
1007
+		// no PDF for facturerec
889 1008
 		else
890 1009
 		{
891 1010
 			setEventMessage($langs->trans('warning_subtotal_recap_object_element_unknown', $object->element), 'warnings');
@@ -920,7 +1039,9 @@  discard block
 block discarded – undo
920 1039
 		$pdf->SetCreator("Dolibarr ".DOL_VERSION);
921 1040
 		$pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
922 1041
 		$pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("subtotalRecap")." ".$outputlangs->convToOutputCharset($object->thirdparty->name));
923
-		if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
1042
+		if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) {
1043
+			$pdf->SetCompression(false);
1044
+		}
924 1045
 
925 1046
 		$pdf->SetMargins($objmarge->marge_gauche, $objmarge->marge_haute, $objmarge->marge_droite);   // Left, Top, Right
926 1047
 
@@ -930,7 +1051,9 @@  discard block
 block discarded – undo
930 1051
 
931 1052
 		// New page
932 1053
 		$pdf->AddPage();
933
-		if (! empty($tplidx)) $pdf->useTemplate($tplidx);
1054
+		if (! empty($tplidx)) {
1055
+			$pdf->useTemplate($tplidx);
1056
+		}
934 1057
 		$pagenb++;
935 1058
 
936 1059
 
@@ -986,8 +1109,10 @@  discard block
 block discarded – undo
986 1109
 					{
987 1110
 						$TTot['TTotal_tva_multicurrency'][$tx] += $amount;
988 1111
 					}
1112
+				} else {
1113
+					$pdf->SetFont('','', $default_font_size - 1);
989 1114
 				}
990
-				else $pdf->SetFont('','', $default_font_size - 1);   // Into loop to work with multipage
1115
+				// Into loop to work with multipage
991 1116
 
992 1117
 				$pdf->SetTextColor(0,0,0);
993 1118
 
@@ -1009,9 +1134,11 @@  discard block
 block discarded – undo
1009 1134
 				$pdf->startTransaction();
1010 1135
 				$pdf->writeHTMLCell($posx_options-$posx_designation-$decalage, 3, $posx_designation+$decalage, $curY, $outputlangs->convToOutputCharset($label), 0, 1, false, true, 'J',true);
1011 1136
 				$pageposafter=$pdf->getPage();
1012
-				if ($pageposafter > $pageposbefore)	// There is a pagebreak
1137
+				if ($pageposafter > $pageposbefore) {
1138
+					// There is a pagebreak
1013 1139
 				{
1014 1140
 					$pdf->rollbackTransaction(true);
1141
+				}
1015 1142
 					$pageposafter=$pageposbefore;
1016 1143
 					//print $pageposafter.'-'.$pageposbefore;exit;
1017 1144
 					$pdf->setPageOrientation('', 1, $heightforfooter);	// The only function to edit the bottom margin of current page to set it.
@@ -1020,23 +1147,27 @@  discard block
 block discarded – undo
1020 1147
 					$pageposafter=$pdf->getPage();
1021 1148
 					$posyafter=$pdf->GetY();
1022 1149
 					//var_dump($posyafter); var_dump(($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))); exit;
1023
-					if ($posyafter > ($objmarge->page_hauteur - ($heightforfooter+$heightforinfotot)))	// There is no space left for total+free text
1150
+					if ($posyafter > ($objmarge->page_hauteur - ($heightforfooter+$heightforinfotot))) {
1151
+						// There is no space left for total+free text
1024 1152
 					{
1025 1153
 						if ($i == ($nblignes-1))	// No more lines, and no space left to show total, so we create a new page
1026 1154
 						{
1027 1155
 							$pdf->AddPage('','',true);
1028
-							if (! empty($tplidx)) $pdf->useTemplate($tplidx);
1029
-							if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) self::pagehead($objmarge, $pdf, $object, 0, $outputlangs);
1156
+					}
1157
+							if (! empty($tplidx)) {
1158
+								$pdf->useTemplate($tplidx);
1159
+							}
1160
+							if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) {
1161
+								self::pagehead($objmarge, $pdf, $object, 0, $outputlangs);
1162
+							}
1030 1163
 							$pdf->setPage($pageposafter+1);
1031 1164
 						}
1032
-					}
1033
-					else
1165
+					} else
1034 1166
 					{
1035 1167
 						// We found a page break
1036 1168
 						$showpricebeforepagebreak=0;
1037 1169
 					}
1038
-				}
1039
-				else	// No pagebreak
1170
+				} else	// No pagebreak
1040 1171
 				{
1041 1172
 					$pdf->commitTransaction();
1042 1173
 				}
@@ -1076,8 +1207,7 @@  discard block
 block discarded – undo
1076 1207
 					if ($pagenb == 1)
1077 1208
 					{
1078 1209
 						self::tableau($objmarge, $pdf, $posx_designation, $posx_options, $posx_montant, $tab_top, $objmarge->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1, $object->multicurrency_code);
1079
-					}
1080
-					else
1210
+					} else
1081 1211
 					{
1082 1212
 						self::tableau($objmarge, $pdf, $posx_designation, $posx_options, $posx_montant, $tab_top_newpage, $objmarge->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, $hidetop, 1, $object->multicurrency_code);
1083 1213
 					}
@@ -1085,7 +1215,9 @@  discard block
 block discarded – undo
1085 1215
 					$pagenb++;
1086 1216
 					$pdf->setPage($pagenb);
1087 1217
 					$pdf->setPageOrientation('', 1, 0);	// The only function to edit the bottom margin of current page to set it.
1088
-					if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) self::pagehead($objmarge, $pdf, $object, 0, $outputlangs);
1218
+					if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) {
1219
+						self::pagehead($objmarge, $pdf, $object, 0, $outputlangs);
1220
+					}
1089 1221
 				}
1090 1222
 			}
1091 1223
 		}
@@ -1095,8 +1227,7 @@  discard block
 block discarded – undo
1095 1227
 		{
1096 1228
 			self::tableau($objmarge, $pdf, $posx_designation, $posx_options, $posx_montant, $tab_top, $objmarge->page_hauteur - $tab_top - $heightforinfotot - $heightforfooter, 0, $outputlangs, 0, 0, $object->multicurrency_code);
1097 1229
 			$bottomlasttab=$objmarge->page_hauteur - $heightforinfotot - $heightforfooter + 1;
1098
-		}
1099
-		else
1230
+		} else
1100 1231
 		{
1101 1232
 			self::tableau($objmarge, $pdf, $posx_designation, $posx_options, $posx_montant, $tab_top_newpage, $objmarge->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfooter, 0, $outputlangs, $hidetop, 0, $object->multicurrency_code);
1102 1233
 			$bottomlasttab=$objmarge->page_hauteur - $heightforinfotot - $heightforfooter + 1;
@@ -1110,7 +1241,9 @@  discard block
 block discarded – undo
1110 1241
 
1111 1242
 		$pagecount = self::concat($outputlangs, array($origin_file, $file), $origin_file);
1112 1243
 
1113
-		if (empty($conf->global->SUBTOTAL_KEEP_RECAP_FILE)) unlink($file);
1244
+		if (empty($conf->global->SUBTOTAL_KEEP_RECAP_FILE)) {
1245
+			unlink($file);
1246
+		}
1114 1247
 	}
1115 1248
 
1116 1249
 	/**
@@ -1160,8 +1293,7 @@  discard block
 block discarded – undo
1160 1293
 			{
1161 1294
 			    $height=pdf_getHeightForLogo($logo);
1162 1295
 			    $pdf->Image($logo, $objmarge->marge_gauche, $posy, 0, $height);	// width=0 (auto)
1163
-			}
1164
-			else
1296
+			} else
1165 1297
 			{
1166 1298
 				$pdf->SetTextColor(200,0,0);
1167 1299
 				$pdf->SetFont('','B',$default_font_size - 2);
@@ -1170,8 +1302,7 @@  discard block
 block discarded – undo
1170 1302
 			}
1171 1303
 
1172 1304
 			$posy+=35;
1173
-		}
1174
-		else
1305
+		} else
1175 1306
 		{
1176 1307
 			$text=$mysoc->name;
1177 1308
 			$pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0, 'L');
@@ -1185,9 +1316,13 @@  discard block
 block discarded – undo
1185 1316
 		$pdf->SetXY($objmarge->marge_gauche,$posy);
1186 1317
 
1187 1318
 		$key = 'subtotalPropalTitle';
1188
-		if ($object->element == 'commande') $key = 'subtotalCommandeTitle';
1189
-		elseif ($object->element == 'facture') $key = 'subtotalInvoiceTitle';
1190
-		elseif ($object->element == 'facturerec') $key = 'subtotalInvoiceTitle';
1319
+		if ($object->element == 'commande') {
1320
+			$key = 'subtotalCommandeTitle';
1321
+		} elseif ($object->element == 'facture') {
1322
+			$key = 'subtotalInvoiceTitle';
1323
+		} elseif ($object->element == 'facturerec') {
1324
+			$key = 'subtotalInvoiceTitle';
1325
+		}
1191 1326
 
1192 1327
 		$pdf->MultiCell(150, 4, $outputlangs->transnoentities($key, $object->ref, $object->thirdparty->name), '', 'L');
1193 1328
 
@@ -1222,7 +1357,9 @@  discard block
 block discarded – undo
1222 1357
 
1223 1358
 		// Force to disable hidetop and hidebottom
1224 1359
 		$hidebottom=0;
1225
-		if ($hidetop) $hidetop=-1;
1360
+		if ($hidetop) {
1361
+			$hidetop=-1;
1362
+		}
1226 1363
 
1227 1364
 		$currency = !empty($currency) ? $currency : $conf->currency;
1228 1365
 		$default_font_size = pdf_getPDFFontSize($outputlangs);
@@ -1237,7 +1374,9 @@  discard block
 block discarded – undo
1237 1374
 			$pdf->SetXY($objmarge->page_largeur - $objmarge->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top-4.5);
1238 1375
 			$pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre);
1239 1376
 
1240
-			if (! empty($conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)) $pdf->Rect($objmarge->marge_gauche, $tab_top, $objmarge->page_largeur-$objmarge->marge_droite-$objmarge->marge_gauche, 8, 'F', null, explode(',',$conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR));
1377
+			if (! empty($conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)) {
1378
+				$pdf->Rect($objmarge->marge_gauche, $tab_top, $objmarge->page_largeur-$objmarge->marge_droite-$objmarge->marge_gauche, 8, 'F', null, explode(',',$conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR));
1379
+			}
1241 1380
 
1242 1381
 
1243 1382
 			$pdf->line($objmarge->marge_gauche, $tab_top, $objmarge->page_largeur-$objmarge->marge_droite, $tab_top);	// line prend une position y en 2eme param et 4eme param
@@ -1250,8 +1389,7 @@  discard block
 block discarded – undo
1250 1389
 			$pdf->MultiCell($objmarge->page_largeur - $objmarge->marge_droite - $posx_montant,2, $outputlangs->transnoentities("Amount"),'','R');
1251 1390
 
1252 1391
 			$pdf->line($objmarge->marge_gauche, $tab_top+8, $objmarge->page_largeur-$objmarge->marge_droite, $tab_top+8);	// line prend une position y en 2eme param et 4eme param
1253
-		}
1254
-		else
1392
+		} else
1255 1393
 		{
1256 1394
 			$pdf->line($objmarge->marge_gauche, $tab_top-2, $objmarge->page_largeur-$objmarge->marge_droite, $tab_top-2);	// line prend une position y en 2eme param et 4eme param
1257 1395
 		}
@@ -1281,10 +1419,12 @@  discard block
 block discarded – undo
1281 1419
 
1282 1420
 		// Tableau total
1283 1421
 		$col1x = 120; $col2x = 170;
1284
-		if ($objmarge->page_largeur < 210) // To work with US executive format
1422
+		if ($objmarge->page_largeur < 210) {
1423
+			// To work with US executive format
1285 1424
 		{
1286 1425
 			$col2x-=20;
1287 1426
 		}
1427
+		}
1288 1428
 		$largcol2 = ($objmarge->page_largeur - $objmarge->marge_droite - $col2x);
1289 1429
 
1290 1430
 		$useborder=0;
@@ -1306,9 +1446,11 @@  discard block
 block discarded – undo
1306 1446
 		$atleastoneratenotnull=0;
1307 1447
 		foreach($TTot['TTotal_tva'] as $tvakey => $tvaval)
1308 1448
 		{
1309
-			if ($tvakey != 0)    // On affiche pas taux 0
1449
+			if ($tvakey != 0) {
1450
+				// On affiche pas taux 0
1310 1451
 			{
1311 1452
 				$atleastoneratenotnull++;
1453
+			}
1312 1454
 
1313 1455
 				$index++;
1314 1456
 				$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
@@ -1361,9 +1503,13 @@  discard block
 block discarded – undo
1361 1503
 	 */
1362 1504
 	private static function printRect($pdf, $x, $y, $l, $h, $hidetop=0, $hidebottom=0)
1363 1505
 	{
1364
-	    if (empty($hidetop) || $hidetop==-1) $pdf->line($x, $y, $x+$l, $y);
1506
+	    if (empty($hidetop) || $hidetop==-1) {
1507
+	    	$pdf->line($x, $y, $x+$l, $y);
1508
+	    }
1365 1509
 	    $pdf->line($x+$l, $y, $x+$l, $y+$h);
1366
-	    if (empty($hidebottom)) $pdf->line($x+$l, $y+$h, $x, $y+$h);
1510
+	    if (empty($hidebottom)) {
1511
+	    	$pdf->line($x+$l, $y+$h, $x, $y+$h);
1512
+	    }
1367 1513
 	    $pdf->line($x, $y+$h, $x, $y);
1368 1514
 	}
1369 1515
 
@@ -1377,7 +1523,9 @@  discard block
 block discarded – undo
1377 1523
 	{
1378 1524
 		global $conf;
1379 1525
 
1380
-		if (empty($fileoutput)) $fileoutput = $file[0];
1526
+		if (empty($fileoutput)) {
1527
+			$fileoutput = $file[0];
1528
+		}
1381 1529
 
1382 1530
 		$pdf=pdf_getInstance();
1383 1531
         if (class_exists('TCPDF'))
@@ -1387,7 +1535,9 @@  discard block
 block discarded – undo
1387 1535
         }
1388 1536
         $pdf->SetFont(pdf_getPDFFont($outputlangs));
1389 1537
 
1390
-        if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
1538
+        if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) {
1539
+        	$pdf->SetCompression(false);
1540
+        }
1391 1541
 
1392 1542
 
1393 1543
 		foreach($files as $file)
@@ -1403,7 +1553,9 @@  discard block
 block discarded – undo
1403 1553
 		}
1404 1554
 
1405 1555
 		$pdf->Output($fileoutput,'F');
1406
-		if (! empty($conf->global->MAIN_UMASK)) @chmod($file, octdec($conf->global->MAIN_UMASK));
1556
+		if (! empty($conf->global->MAIN_UMASK)) {
1557
+			@chmod($file, octdec($conf->global->MAIN_UMASK));
1558
+		}
1407 1559
 
1408 1560
 		return $pagecount;
1409 1561
 	}
@@ -1416,7 +1568,9 @@  discard block
 block discarded – undo
1416 1568
 	 */
1417 1569
 	public static function hasNcTitle(&$line)
1418 1570
 	{
1419
-		if(isset($line->has_nc_title)) return $line->has_nc_title;
1571
+		if(isset($line->has_nc_title)) {
1572
+			return $line->has_nc_title;
1573
+		}
1420 1574
 
1421 1575
 		$TTitle = self::getAllTitleFromLine($line);
1422 1576
 		foreach ($TTitle as &$line_title)
@@ -1441,7 +1595,9 @@  discard block
 block discarded – undo
1441 1595
 	public static function getTitleLabel($line)
1442 1596
 	{
1443 1597
 		$title = $line->label;
1444
-		if (empty($title)) $title = !empty($line->description) ? $line->description : $line->desc;
1598
+		if (empty($title)) {
1599
+			$title = !empty($line->description) ? $line->description : $line->desc;
1600
+		}
1445 1601
 		return $title;
1446 1602
 	}
1447 1603
 }
Please login to merge, or discard this patch.
class/actions_subtotal.class.php 3 patches
Indentation   +382 added lines, -382 removed lines patch added patch discarded remove patch
@@ -107,11 +107,11 @@  discard block
 block discarded – undo
107 107
 	 * @return     void
108 108
 	 */
109 109
 
110
-    var $module_number = 104777;
110
+	var $module_number = 104777;
111 111
 
112
-    function formObjectOptions($parameters, &$object, &$action, $hookmanager)
113
-    {
114
-      	global $langs,$db,$user, $conf;
112
+	function formObjectOptions($parameters, &$object, &$action, $hookmanager)
113
+	{
114
+	  	global $langs,$db,$user, $conf;
115 115
 
116 116
 		$langs->load('subtotal@subtotal');
117 117
 
@@ -126,10 +126,10 @@  discard block
 block discarded – undo
126 126
 				$createRight = $user->rights->facture->creer;
127 127
 			} elseif($object->element == 'order_supplier' )
128 128
 			{
129
-			    $createRight = $user->rights->fournisseur->commande->creer;
129
+				$createRight = $user->rights->fournisseur->commande->creer;
130 130
 			} elseif($object->element == 'invoice_supplier' )
131 131
 			{
132
-			    $createRight = $user->rights->fournisseur->facture->creer;
132
+				$createRight = $user->rights->fournisseur->facture->creer;
133 133
 			}
134 134
 			elseif($object->element == 'shipping')
135 135
 			{
@@ -183,7 +183,7 @@  discard block
 block discarded – undo
183 183
 
184 184
 					if (!empty($conf->global->SUBTOTAL_AUTO_ADD_SUBTOTAL_ON_ADDING_NEW_TITLE) && $qty < 10) TSubtotal::addSubtotalMissing($object, $qty);
185 185
 
186
-	    			TSubtotal::addSubTotalLine($object, $title, $qty);
186
+					TSubtotal::addSubTotalLine($object, $title, $qty);
187 187
 				}
188 188
 				else if($action==='ask_deleteallline') {
189 189
 						$form=new Form($db);
@@ -407,37 +407,37 @@  discard block
 block discarded – undo
407 407
 		$TContext = explode(':',$parameters['context']);
408 408
 		if (
409 409
 				in_array('invoicecard',$TContext)
410
-		        || in_array('invoicesuppliercard',$TContext)
410
+				|| in_array('invoicesuppliercard',$TContext)
411 411
 				|| in_array('propalcard',$TContext)
412 412
 				|| in_array('ordercard',$TContext)
413
-		        || in_array('ordersuppliercard',$TContext)
413
+				|| in_array('ordersuppliercard',$TContext)
414 414
 				|| in_array('invoicereccard',$TContext)
415 415
 			)
416
-	        {
417
-	            $hideInnerLines	= isset( $_SESSION['subtotal_hideInnerLines_'.$parameters['modulepart']][$object->id] ) ?  $_SESSION['subtotal_hideInnerLines_'.$parameters['modulepart']][$object->id] : 0;
418
-	            $hidedetails	= isset( $_SESSION['subtotal_hidedetails_'.$parameters['modulepart']][$object->id] ) ?  $_SESSION['subtotal_hidedetails_'.$parameters['modulepart']][$object->id] : 0;
416
+			{
417
+				$hideInnerLines	= isset( $_SESSION['subtotal_hideInnerLines_'.$parameters['modulepart']][$object->id] ) ?  $_SESSION['subtotal_hideInnerLines_'.$parameters['modulepart']][$object->id] : 0;
418
+				$hidedetails	= isset( $_SESSION['subtotal_hidedetails_'.$parameters['modulepart']][$object->id] ) ?  $_SESSION['subtotal_hidedetails_'.$parameters['modulepart']][$object->id] : 0;
419 419
 				$hidepricesDefaultConf = !empty($conf->global->SUBTOTAL_HIDE_PRICE_DEFAULT_CHECKED)?$conf->global->SUBTOTAL_HIDE_PRICE_DEFAULT_CHECKED:0;
420 420
 				$hideprices= isset( $_SESSION['subtotal_hideprices_'.$parameters['modulepart']][$object->id] ) ?  $_SESSION['subtotal_hideprices_'.$parameters['modulepart']][$object->id] : $hidepricesDefaultConf;
421 421
 
422 422
 				$var=false;
423 423
 				$out = '';
424
-		     	$out.= '<tr '.$bc[$var].'>
424
+			 	$out.= '<tr '.$bc[$var].'>
425 425
 		     			<td colspan="4" align="right">
426 426
 		     				<label for="hideInnerLines">'.$langs->trans('HideInnerLines').'</label>
427 427
 		     				<input type="checkbox" onclick="if($(this).is(\':checked\')) { $(\'#hidedetails\').prop(\'checked\', \'checked\')  }" id="hideInnerLines" name="hideInnerLines" value="1" '.(( $hideInnerLines ) ? 'checked="checked"' : '' ).' />
428 428
 		     			</td>
429 429
 		     			</tr>';
430 430
 
431
-		     	$var=!$var;
432
-		     	$out.= '<tr '.$bc[$var].'>
431
+			 	$var=!$var;
432
+			 	$out.= '<tr '.$bc[$var].'>
433 433
 		     			<td colspan="4" align="right">
434 434
 		     				<label for="hidedetails">'.$langs->trans('SubTotalhidedetails').'</label>
435 435
 		     				<input type="checkbox" id="hidedetails" name="hidedetails" value="1" '.(( $hidedetails ) ? 'checked="checked"' : '' ).' />
436 436
 		     			</td>
437 437
 		     			</tr>';
438 438
 
439
-		     	$var=!$var;
440
-		     	$out.= '<tr '.$bc[$var].'>
439
+			 	$var=!$var;
440
+			 	$out.= '<tr '.$bc[$var].'>
441 441
 		     			<td colspan="4" align="right">
442 442
 		     				<label for="hideprices">'.$langs->trans('SubTotalhidePrice').'</label>
443 443
 		     				<input type="checkbox" id="hideprices" name="hideprices" value="1" '.(( $hideprices ) ? 'checked="checked"' : '' ).' />
@@ -449,9 +449,9 @@  discard block
 block discarded – undo
449 449
 				if (
450 450
 					(in_array('propalcard',$TContext) && !empty($conf->global->SUBTOTAL_PROPAL_ADD_RECAP))
451 451
 					|| (in_array('ordercard',$TContext) && !empty($conf->global->SUBTOTAL_COMMANDE_ADD_RECAP))
452
-				    || (in_array('ordersuppliercard',$TContext) && !empty($conf->global->SUBTOTAL_COMMANDE_ADD_RECAP))
452
+					|| (in_array('ordersuppliercard',$TContext) && !empty($conf->global->SUBTOTAL_COMMANDE_ADD_RECAP))
453 453
 					|| (in_array('invoicecard',$TContext) && !empty($conf->global->SUBTOTAL_INVOICE_ADD_RECAP))
454
-				    || (in_array('invoicesuppliercard',$TContext) && !empty($conf->global->SUBTOTAL_INVOICE_ADD_RECAP))
454
+					|| (in_array('invoicesuppliercard',$TContext) && !empty($conf->global->SUBTOTAL_INVOICE_ADD_RECAP))
455 455
 					|| (in_array('invoicereccard',$TContext)  && !empty($conf->global->SUBTOTAL_INVOICE_ADD_RECAP ))
456 456
 				)
457 457
 				{
@@ -470,19 +470,19 @@  discard block
 block discarded – undo
470 470
 			}
471 471
 
472 472
 
473
-        return 1;
473
+		return 1;
474 474
 	}
475 475
 
476
-    function formEditProductOptions($parameters, &$object, &$action, $hookmanager)
477
-    {
476
+	function formEditProductOptions($parameters, &$object, &$action, $hookmanager)
477
+	{
478 478
 
479
-    	if (in_array('invoicecard',explode(':',$parameters['context'])))
480
-        {
479
+		if (in_array('invoicecard',explode(':',$parameters['context'])))
480
+		{
481 481
 
482
-        }
482
+		}
483 483
 
484
-        return 0;
485
-    }
484
+		return 0;
485
+	}
486 486
 
487 487
 	function ODTSubstitutionLine(&$parameters, &$object, $action, $hookmanager) {
488 488
 		global $conf;
@@ -493,14 +493,14 @@  discard block
 block discarded – undo
493 493
 			$object = &$parameters['object'];
494 494
 			$substitutionarray = &$parameters['substitutionarray'];
495 495
 
496
-            $substitutionarray['line_not_modsubtotal'] = true;
497
-            $substitutionarray['line_modsubtotal'] = false;
498
-            $substitutionarray['line_modsubtotal_total'] = false;
499
-            $substitutionarray['line_modsubtotal_title'] = false;
496
+			$substitutionarray['line_not_modsubtotal'] = true;
497
+			$substitutionarray['line_modsubtotal'] = false;
498
+			$substitutionarray['line_modsubtotal_total'] = false;
499
+			$substitutionarray['line_modsubtotal_title'] = false;
500 500
 
501 501
 			if($line->product_type == 9 && $line->special_code == $this->module_number) {
502 502
 				$substitutionarray['line_modsubtotal'] = 1;
503
-                $substitutionarray['line_not_modsubtotal'] = false;
503
+				$substitutionarray['line_not_modsubtotal'] = false;
504 504
 
505 505
 				$substitutionarray['line_price_ht']
506 506
 					 = $substitutionarray['line_price_vat']
@@ -514,7 +514,7 @@  discard block
 block discarded – undo
514 514
 					$substitutionarray['line_modsubtotal_total'] = true;
515 515
 
516 516
 					//list($total, $total_tva, $total_ttc, $TTotal_tva) = $this->getTotalLineFromObject($object, $line, '', 1);
517
-                    $TInfo = $this->getTotalLineFromObject($object, $line, '', 1);
517
+					$TInfo = $this->getTotalLineFromObject($object, $line, '', 1);
518 518
 
519 519
 					$substitutionarray['line_price_ht'] = price($TInfo[0]);
520 520
 					$substitutionarray['line_price_vat'] = price($TInfo[1]);
@@ -539,11 +539,11 @@  discard block
 block discarded – undo
539 539
 
540 540
 		if (
541 541
 				in_array('invoicecard',explode(':',$parameters['context']))
542
-		        || in_array('invoicesuppliercard',explode(':',$parameters['context']))
542
+				|| in_array('invoicesuppliercard',explode(':',$parameters['context']))
543 543
 				|| in_array('propalcard',explode(':',$parameters['context']))
544
-		        || in_array('supplier_proposalcard',explode(':',$parameters['context']))
544
+				|| in_array('supplier_proposalcard',explode(':',$parameters['context']))
545 545
 				|| in_array('ordercard',explode(':',$parameters['context']))
546
-		        || in_array('ordersuppliercard',explode(':',$parameters['context']))
546
+				|| in_array('ordersuppliercard',explode(':',$parameters['context']))
547 547
 				|| in_array('invoicereccard',explode(':',$parameters['context']))
548 548
 		) {
549 549
 
@@ -627,20 +627,20 @@  discard block
 block discarded – undo
627 627
 				in_array('invoicecard',explode(':',$parameters['context']))
628 628
 				|| in_array('propalcard',explode(':',$parameters['context']))
629 629
 				|| in_array('ordercard',explode(':',$parameters['context']))
630
-			    || in_array('ordersuppliercard',explode(':',$parameters['context']))
631
-			    || in_array('invoicesuppliercard',explode(':',$parameters['context']))
632
-			    || in_array('supplier_proposalcard',explode(':',$parameters['context']))
630
+				|| in_array('ordersuppliercard',explode(':',$parameters['context']))
631
+				|| in_array('invoicesuppliercard',explode(':',$parameters['context']))
632
+				|| in_array('supplier_proposalcard',explode(':',$parameters['context']))
633 633
 			)
634
-	        {
634
+			{
635 635
 				if(in_array('invoicecard',explode(':',$parameters['context']))) {
636 636
 					$sessname = 'subtotal_hideInnerLines_facture';
637 637
 					$sessname2 = 'subtotal_hidedetails_facture';
638 638
 					$sessname3 = 'subtotal_hideprices_facture';
639 639
 				}
640 640
 				elseif(in_array('invoicesuppliercard',explode(':',$parameters['context']))) {
641
-				    $sessname = 'subtotal_hideInnerLines_facture_fournisseur';
642
-				    $sessname2 = 'subtotal_hidedetails_facture_fournisseur';
643
-				    $sessname3 = 'subtotal_hideprices_facture_fournisseur';
641
+					$sessname = 'subtotal_hideInnerLines_facture_fournisseur';
642
+					$sessname2 = 'subtotal_hidedetails_facture_fournisseur';
643
+					$sessname3 = 'subtotal_hideprices_facture_fournisseur';
644 644
 				}
645 645
 				elseif(in_array('propalcard',explode(':',$parameters['context']))) {
646 646
 					$sessname = 'subtotal_hideInnerLines_propal';
@@ -648,9 +648,9 @@  discard block
 block discarded – undo
648 648
 					$sessname3 = 'subtotal_hideprices_propal';
649 649
 				}
650 650
 				elseif(in_array('supplier_proposalcard',explode(':',$parameters['context']))) {
651
-				    $sessname = 'subtotal_hideInnerLines_supplier_proposal';
652
-				    $sessname2 = 'subtotal_hidedetails_supplier_proposal';
653
-				    $sessname3 = 'subtotal_hideprices_supplier_proposal';
651
+					$sessname = 'subtotal_hideInnerLines_supplier_proposal';
652
+					$sessname2 = 'subtotal_hidedetails_supplier_proposal';
653
+					$sessname3 = 'subtotal_hideprices_supplier_proposal';
654 654
 				}
655 655
 				elseif(in_array('ordercard',explode(':',$parameters['context']))) {
656 656
 					$sessname = 'subtotal_hideInnerLines_commande';
@@ -658,9 +658,9 @@  discard block
 block discarded – undo
658 658
 					$sessname3 = 'subtotal_hideprices_commande';
659 659
 				}
660 660
 				elseif(in_array('ordersuppliercard',explode(':',$parameters['context']))) {
661
-				    $sessname = 'subtotal_hideInnerLines_commande_fournisseur';
662
-				    $sessname2 = 'subtotal_hidedetails_commande_fournisseur';
663
-				    $sessname3 = 'subtotal_hideprices_commande_fournisseur';
661
+					$sessname = 'subtotal_hideInnerLines_commande_fournisseur';
662
+					$sessname2 = 'subtotal_hidedetails_commande_fournisseur';
663
+					$sessname3 = 'subtotal_hideprices_commande_fournisseur';
664 664
 				}
665 665
 				else {
666 666
 					$sessname = 'subtotal_hideInnerLines_unknown';
@@ -685,24 +685,24 @@  discard block
 block discarded – undo
685 685
 				foreach($object->lines as &$line) {
686 686
 					if ($line->product_type == 9 && $line->special_code == $this->module_number) {
687 687
 
688
-                        if($line->qty>=90) {
689
-                            $line->modsubtotal_total = 1;
690
-                        }
691
-                        else{
692
-                            $line->modsubtotal_title = 1;
693
-                        }
688
+						if($line->qty>=90) {
689
+							$line->modsubtotal_total = 1;
690
+						}
691
+						else{
692
+							$line->modsubtotal_title = 1;
693
+						}
694 694
 
695 695
 						$line->total_ht = $this->getTotalLineFromObject($object, $line, '');
696 696
 					}
697
-	        	}
698
-	        }
697
+				}
698
+			}
699 699
 
700 700
 		}
701 701
 		else if($action === 'confirm_delete_all_lines' && GETPOST('confirm', 'none')=='yes') {
702 702
 
703 703
 			$Tab = TSubtotal::getLinesFromTitleId($object, GETPOST('lineid', 'int'), true);
704 704
 			foreach($Tab as $line) {
705
-                $result = 0;
705
+				$result = 0;
706 706
 
707 707
 				$idLine = $line->id;
708 708
 				/**
@@ -737,7 +737,7 @@  discard block
 block discarded – undo
737 737
 				 */
738 738
 				else if($object->element=='order_supplier')
739 739
 				{
740
-                    			$result = $object->deleteline($idLine);
740
+								$result = $object->deleteline($idLine);
741 741
 				}
742 742
 				/**
743 743
 				 * @var $object Facturerec
@@ -748,15 +748,15 @@  discard block
 block discarded – undo
748 748
 				 */
749 749
 				else if($object->element=='shipping') $result = $object->deleteline($user, $idLine);
750 750
 
751
-                if ($result < 0) $error++;
751
+				if ($result < 0) $error++;
752 752
 			}
753 753
 
754
-            if ($error) {
755
-                setEventMessages($object->error, $object->errors, 'errors');
756
-                $db->rollback();
757
-            } else {
758
-                $db->commit();
759
-            }
754
+			if ($error) {
755
+				setEventMessages($object->error, $object->errors, 'errors');
756
+				$db->rollback();
757
+			} else {
758
+				$db->commit();
759
+			}
760 760
 
761 761
 			header('location:?id='.$object->id);
762 762
 			exit;
@@ -811,25 +811,25 @@  discard block
 block discarded – undo
811 811
 
812 812
 	function getArrayOfLineForAGroup(&$object, $lineid) {
813 813
 		$qty_line = 0;
814
-        $qty_end_line = 0;
814
+		$qty_end_line = 0;
815 815
 		$found = false;
816 816
 		$Tab= array();
817 817
 
818 818
 		foreach($object->lines as $l) {
819
-		    $lid = (!empty($l->rowid) ? $l->rowid : $l->id);
819
+			$lid = (!empty($l->rowid) ? $l->rowid : $l->id);
820 820
 
821 821
 			if($lid == $lineid && $l->qty > 0 && $l->qty < 10) {
822 822
 				$found = true;
823 823
 				$qty_line = $l->qty;
824
-                $qty_end_line = 100 - $qty_line;
824
+				$qty_end_line = 100 - $qty_line;
825 825
 			}
826 826
 
827 827
 			if($found) {
828
-                if ($l->special_code == $this->module_number && $lid != $lineid && ($l->qty <= $qty_line || $l->qty >= $qty_end_line)) {
829
-                    if ($l->qty == $qty_end_line) $Tab[] = $lid;
830
-                    break;
831
-                }
832
-                else $Tab[] = $lid;
828
+				if ($l->special_code == $this->module_number && $lid != $lineid && ($l->qty <= $qty_line || $l->qty >= $qty_end_line)) {
829
+					if ($l->qty == $qty_end_line) $Tab[] = $lid;
830
+					break;
831
+				}
832
+				else $Tab[] = $lid;
833 833
 			}
834 834
 		}
835 835
 
@@ -842,7 +842,7 @@  discard block
 block discarded – undo
842 842
 		$rang = $line->rang;
843 843
 		$qty_line = $line->qty;
844 844
 		$lvl = 0;
845
-        if (TSubtotal::isSubtotal($line)) $lvl = TSubtotal::getNiveau($line);
845
+		if (TSubtotal::isSubtotal($line)) $lvl = TSubtotal::getNiveau($line);
846 846
 
847 847
 		$title_break = TSubtotal::getParentTitleOfLine($object, $rang, $lvl);
848 848
 
@@ -868,40 +868,40 @@  discard block
 block discarded – undo
868 868
 			$l->total_ht = doubleval($l->total_ht);
869 869
 
870 870
 			//print $l->rang.'>='.$rang.' '.$total.'<br/>';
871
-            if ($l->rang>=$rang) continue;
872
-            if (!empty($title_break) && $title_break->id == $l->id) break;
873
-            elseif (!TSubtotal::isModSubtotalLine($l))
874
-            {
875
-                // TODO retirer le test avec $builddoc quand Dolibarr affichera le total progression sur la card et pas seulement dans le PDF
876
-                if ($builddoc && $object->element == 'facture' && $object->type==Facture::TYPE_SITUATION)
877
-                {
878
-                    if ($l->situation_percent > 0 && !empty($l->total_ht))
879
-                    {
880
-                        $prev_progress = 0;
881
-                        $progress = 1;
882
-                        if (method_exists($l, 'get_prev_progress'))
883
-                        {
884
-                            $prev_progress = $l->get_prev_progress($object->id);
885
-                            $progress = ($l->situation_percent - $prev_progress) / 100;
886
-                        }
887
-
888
-                        $result = $sign * ($l->total_ht / ($l->situation_percent / 100)) * $progress;
889
-                        $total+= $result;
890
-                        // TODO check si les 3 lignes du dessous sont corrects
891
-                        $total_tva += $sign * ($l->total_tva / ($l->situation_percent / 100)) * $progress;
892
-                        $TTotal_tva[$l->tva_tx] += $sign * ($l->total_tva / ($l->situation_percent / 100)) * $progress;
893
-                        $total_ttc += $sign * ($l->total_tva / ($l->total_ttc / 100)) * $progress;
894
-
895
-                    }
896
-                }
897
-                else
898
-                {
899
-                    $total += $l->total_ht;
900
-                    $total_tva += $l->total_tva;
901
-                    $TTotal_tva[$l->tva_tx] += $l->total_tva;
902
-                    $total_ttc += $l->total_ttc;
903
-                }
904
-            }
871
+			if ($l->rang>=$rang) continue;
872
+			if (!empty($title_break) && $title_break->id == $l->id) break;
873
+			elseif (!TSubtotal::isModSubtotalLine($l))
874
+			{
875
+				// TODO retirer le test avec $builddoc quand Dolibarr affichera le total progression sur la card et pas seulement dans le PDF
876
+				if ($builddoc && $object->element == 'facture' && $object->type==Facture::TYPE_SITUATION)
877
+				{
878
+					if ($l->situation_percent > 0 && !empty($l->total_ht))
879
+					{
880
+						$prev_progress = 0;
881
+						$progress = 1;
882
+						if (method_exists($l, 'get_prev_progress'))
883
+						{
884
+							$prev_progress = $l->get_prev_progress($object->id);
885
+							$progress = ($l->situation_percent - $prev_progress) / 100;
886
+						}
887
+
888
+						$result = $sign * ($l->total_ht / ($l->situation_percent / 100)) * $progress;
889
+						$total+= $result;
890
+						// TODO check si les 3 lignes du dessous sont corrects
891
+						$total_tva += $sign * ($l->total_tva / ($l->situation_percent / 100)) * $progress;
892
+						$TTotal_tva[$l->tva_tx] += $sign * ($l->total_tva / ($l->situation_percent / 100)) * $progress;
893
+						$total_ttc += $sign * ($l->total_tva / ($l->total_ttc / 100)) * $progress;
894
+
895
+					}
896
+				}
897
+				else
898
+				{
899
+					$total += $l->total_ht;
900
+					$total_tva += $l->total_tva;
901
+					$TTotal_tva[$l->tva_tx] += $l->total_tva;
902
+					$total_ttc += $l->total_ttc;
903
+				}
904
+			}
905 905
 		}
906 906
 		if (!$return_all) return $total;
907 907
 		else return array($total, $total_tva, $total_ttc, $TTotal_tva);
@@ -939,7 +939,7 @@  discard block
 block discarded – undo
939 939
 		if(method_exists('Closure','bind')) {
940 940
 			$pageBreakOriginalValue = $pdf->AcceptPageBreak();
941 941
 			$sweetsThief = function ($pdf) {
942
-		    		return $pdf->bMargin ;
942
+					return $pdf->bMargin ;
943 943
 			};
944 944
 			$sweetsThief = Closure::bind($sweetsThief, null, $pdf);
945 945
 
@@ -1025,7 +1025,7 @@  discard block
 block discarded – undo
1025 1025
 					$TTotal_tva = $TInfo[3];
1026 1026
 					$total_to_print = price($TInfo[0]);
1027 1027
 
1028
-                    $line->total_ht = $TInfo[0];
1028
+					$line->total_ht = $TInfo[0];
1029 1029
 					$line->total = $TInfo[0];
1030 1030
 					if (!TSubtotal::isModSubtotalLine($line)) $line->total_tva = $TInfo[1];
1031 1031
 					$line->total_ttc = $TInfo[2];
@@ -1189,7 +1189,7 @@  discard block
 block discarded – undo
1189 1189
 	}
1190 1190
 
1191 1191
 	function pdf_getlinetotalexcltax($parameters=array(), &$object, &$action='') {
1192
-	    global $conf, $hideprices, $hookmanager;
1192
+		global $conf, $hideprices, $hookmanager;
1193 1193
 
1194 1194
 		if(is_array($parameters)) $i = & $parameters['i'];
1195 1195
 		else $i = (int)$parameters;
@@ -1228,7 +1228,7 @@  discard block
 block discarded – undo
1228 1228
 			}
1229 1229
 		}
1230 1230
 		if (GETPOST('hideInnerLines', 'int') && !empty($conf->global->SUBTOTAL_REPLACE_WITH_VAT_IF_HIDE_INNERLINES)){
1231
-		    $this->resprints = price($object->lines[$i]->total_ht);
1231
+			$this->resprints = price($object->lines[$i]->total_ht);
1232 1232
 		}
1233 1233
 
1234 1234
 		// Si la gestion C/NC est active et que je suis sur un ligne dont l'extrafield est coché
@@ -1357,7 +1357,7 @@  discard block
 block discarded – undo
1357 1357
 	}
1358 1358
 
1359 1359
 	function pdf_getlineupexcltax($parameters=array(), &$object, &$action='') {
1360
-	    global $conf,$hideprices,$hookmanager;
1360
+		global $conf,$hideprices,$hookmanager;
1361 1361
 
1362 1362
 		if(is_array($parameters)) $i = & $parameters['i'];
1363 1363
 		else $i = (int)$parameters;
@@ -1365,18 +1365,18 @@  discard block
 block discarded – undo
1365 1365
 		if($this->isModSubtotalLine($parameters,$object) ) {
1366 1366
 			$this->resprints = ' ';
1367 1367
 
1368
-            $line = $object->lines[$i];
1368
+			$line = $object->lines[$i];
1369 1369
 
1370
-            // On récupère les montants du bloc pour les afficher dans la ligne de sous-total
1371
-            if(TSubtotal::isSubtotal($line)) {
1372
-                $parentTitle = TSubtotal::getParentTitleOfLine($object, $line->rang);
1370
+			// On récupère les montants du bloc pour les afficher dans la ligne de sous-total
1371
+			if(TSubtotal::isSubtotal($line)) {
1372
+				$parentTitle = TSubtotal::getParentTitleOfLine($object, $line->rang);
1373 1373
 
1374
-                if(is_object($parentTitle) && empty($parentTitle->array_options)) $parentTitle->fetch_optionals();
1375
-                if(! empty($parentTitle->array_options['options_show_total_ht'])) {
1376
-                    $TTotal = TSubtotal::getTotalBlockFromTitle($object, $parentTitle);
1377
-                    $this->resprints = price($TTotal['total_unit_subprice']);
1378
-                }
1379
-            }
1374
+				if(is_object($parentTitle) && empty($parentTitle->array_options)) $parentTitle->fetch_optionals();
1375
+				if(! empty($parentTitle->array_options['options_show_total_ht'])) {
1376
+					$TTotal = TSubtotal::getTotalBlockFromTitle($object, $parentTitle);
1377
+					$this->resprints = price($TTotal['total_unit_subprice']);
1378
+				}
1379
+			}
1380 1380
 
1381 1381
 			if((float)DOL_VERSION<=3.6) {
1382 1382
 				return '';
@@ -1392,58 +1392,58 @@  discard block
 block discarded – undo
1392 1392
 		(!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i]))
1393 1393
 		)
1394 1394
 		{
1395
-		    // alors je dois vérifier si la méthode fait partie de la conf qui l'exclue
1396
-		    if (!in_array(__FUNCTION__, explode(',', $conf->global->SUBTOTAL_TFIELD_TO_KEEP_WITH_NC)))
1397
-		    {
1398
-		        $this->resprints = ' ';
1395
+			// alors je dois vérifier si la méthode fait partie de la conf qui l'exclue
1396
+			if (!in_array(__FUNCTION__, explode(',', $conf->global->SUBTOTAL_TFIELD_TO_KEEP_WITH_NC)))
1397
+			{
1398
+				$this->resprints = ' ';
1399 1399
 
1400
-		        // currentcontext à modifier celon l'appel
1401
-		        $params = array('parameters' => $parameters, 'currentmethod' => 'pdf_getlineupexcltax', 'currentcontext'=>'subtotal_hide_nc', 'i' => $i);
1402
-		        return $this->callHook($object, $hookmanager, $action, $params); // return 1 (qui est la valeur par défaut) OU -1 si erreur OU overrideReturn (contient -1 ou 0 ou 1)
1400
+				// currentcontext à modifier celon l'appel
1401
+				$params = array('parameters' => $parameters, 'currentmethod' => 'pdf_getlineupexcltax', 'currentcontext'=>'subtotal_hide_nc', 'i' => $i);
1402
+				return $this->callHook($object, $hookmanager, $action, $params); // return 1 (qui est la valeur par défaut) OU -1 si erreur OU overrideReturn (contient -1 ou 0 ou 1)
1403 1403
 
1404
-		    }
1404
+			}
1405 1405
 		}
1406 1406
 		// Cache le prix pour les lignes standards dolibarr qui sont dans un ensemble
1407 1407
 		else if (!empty($hideprices))
1408 1408
 		{
1409 1409
 
1410
-		    // Check if a title exist for this line && if the title have subtotal
1411
-		    $lineTitle = TSubtotal::getParentTitleOfLine($object, $object->lines[$i]->rang);
1412
-		    if ($lineTitle && TSubtotal::titleHasTotalLine($object, $lineTitle, true))
1413
-		    {
1410
+			// Check if a title exist for this line && if the title have subtotal
1411
+			$lineTitle = TSubtotal::getParentTitleOfLine($object, $object->lines[$i]->rang);
1412
+			if ($lineTitle && TSubtotal::titleHasTotalLine($object, $lineTitle, true))
1413
+			{
1414 1414
 
1415
-		        $this->resprints = ' ';
1415
+				$this->resprints = ' ';
1416 1416
 
1417
-		        // currentcontext à modifier celon l'appel
1418
-		        $params = array('parameters' => $parameters, 'currentmethod' => 'pdf_getlineupexcltax', 'currentcontext'=>'subtotal_hideprices', 'i' => $i);
1419
-		        return $this->callHook($object, $hookmanager, $action, $params); // return 1 (qui est la valeur par défaut) OU -1 si erreur OU overrideReturn (contient -1 ou 0 ou 1)
1420
-		    }
1417
+				// currentcontext à modifier celon l'appel
1418
+				$params = array('parameters' => $parameters, 'currentmethod' => 'pdf_getlineupexcltax', 'currentcontext'=>'subtotal_hideprices', 'i' => $i);
1419
+				return $this->callHook($object, $hookmanager, $action, $params); // return 1 (qui est la valeur par défaut) OU -1 si erreur OU overrideReturn (contient -1 ou 0 ou 1)
1420
+			}
1421 1421
 		}
1422 1422
 
1423 1423
 		return 0;
1424 1424
 	}
1425 1425
 
1426 1426
 	function pdf_getlineremisepercent($parameters=array(), &$object, &$action='') {
1427
-	    global $conf,$hideprices,$hookmanager;
1427
+		global $conf,$hideprices,$hookmanager;
1428 1428
 
1429
-        if(is_array($parameters)) $i = & $parameters['i'];
1430
-        else $i = (int) $parameters;
1429
+		if(is_array($parameters)) $i = & $parameters['i'];
1430
+		else $i = (int) $parameters;
1431 1431
 
1432 1432
 		if($this->isModSubtotalLine($parameters,$object) ) {
1433 1433
 			$this->resprints = ' ';
1434 1434
 
1435
-            $line = $object->lines[$i];
1435
+			$line = $object->lines[$i];
1436 1436
 
1437
-            // Affichage de la remise
1438
-            if(TSubtotal::isSubtotal($line)) {
1439
-                $parentTitle = TSubtotal::getParentTitleOfLine($object, $line->rang);
1437
+			// Affichage de la remise
1438
+			if(TSubtotal::isSubtotal($line)) {
1439
+				$parentTitle = TSubtotal::getParentTitleOfLine($object, $line->rang);
1440 1440
 
1441
-                if(empty($parentTitle->array_options)) $parentTitle->fetch_optionals();
1442
-                if(! empty($parentTitle->array_options['options_show_reduc'])) {
1443
-                    $TTotal = TSubtotal::getTotalBlockFromTitle($object, $parentTitle);
1444
-                    $this->resprints = price((1-$TTotal['total_ht'] / $TTotal['total_subprice'])*100, 0, '', 1, 2, 2).'%';
1445
-                }
1446
-            }
1441
+				if(empty($parentTitle->array_options)) $parentTitle->fetch_optionals();
1442
+				if(! empty($parentTitle->array_options['options_show_reduc'])) {
1443
+					$TTotal = TSubtotal::getTotalBlockFromTitle($object, $parentTitle);
1444
+					$this->resprints = price((1-$TTotal['total_ht'] / $TTotal['total_subprice'])*100, 0, '', 1, 2, 2).'%';
1445
+				}
1446
+			}
1447 1447
 
1448 1448
 			if((float)DOL_VERSION<=3.6) {
1449 1449
 				return '';
@@ -1453,15 +1453,15 @@  discard block
 block discarded – undo
1453 1453
 			}
1454 1454
 		}
1455 1455
 		elseif (!empty($hideprices)
1456
-		        || (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])) )
1457
-		        )
1458
-		    {
1459
-		        if (!empty($hideprices) || !in_array(__FUNCTION__, explode(',', $conf->global->SUBTOTAL_TFIELD_TO_KEEP_WITH_NC)))
1460
-		        {
1461
-		            $this->resprints = ' ';
1462
-		            return 1;
1463
-		        }
1464
-		    }
1456
+				|| (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])) )
1457
+				)
1458
+			{
1459
+				if (!empty($hideprices) || !in_array(__FUNCTION__, explode(',', $conf->global->SUBTOTAL_TFIELD_TO_KEEP_WITH_NC)))
1460
+				{
1461
+					$this->resprints = ' ';
1462
+					return 1;
1463
+				}
1464
+			}
1465 1465
 
1466 1466
 		return 0;
1467 1467
 	}
@@ -1497,7 +1497,7 @@  discard block
 block discarded – undo
1497 1497
 	}
1498 1498
 
1499 1499
 	function pdf_getlinevatrate($parameters=array(), &$object, &$action='') {
1500
-	    global $conf,$hideprices,$hookmanager;
1500
+		global $conf,$hideprices,$hookmanager;
1501 1501
 
1502 1502
 		if($this->isModSubtotalLine($parameters,$object) ){
1503 1503
 			$this->resprints = ' ';
@@ -1522,31 +1522,31 @@  discard block
 block discarded – undo
1522 1522
 		(!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i]))
1523 1523
 		)
1524 1524
 		{
1525
-		    // alors je dois vérifier si la méthode fait partie de la conf qui l'exclue
1526
-		    if (!in_array(__FUNCTION__, explode(',', $conf->global->SUBTOTAL_TFIELD_TO_KEEP_WITH_NC)))
1527
-		    {
1528
-		        $this->resprints = ' ';
1525
+			// alors je dois vérifier si la méthode fait partie de la conf qui l'exclue
1526
+			if (!in_array(__FUNCTION__, explode(',', $conf->global->SUBTOTAL_TFIELD_TO_KEEP_WITH_NC)))
1527
+			{
1528
+				$this->resprints = ' ';
1529 1529
 
1530
-		        // currentcontext à modifier celon l'appel
1531
-		        $params = array('parameters' => $parameters, 'currentmethod' => 'pdf_getlinevatrate', 'currentcontext'=>'subtotal_hide_nc', 'i' => $i);
1532
-		        return $this->callHook($object, $hookmanager, $action, $params); // return 1 (qui est la valeur par défaut) OU -1 si erreur OU overrideReturn (contient -1 ou 0 ou 1)
1533
-		    }
1530
+				// currentcontext à modifier celon l'appel
1531
+				$params = array('parameters' => $parameters, 'currentmethod' => 'pdf_getlinevatrate', 'currentcontext'=>'subtotal_hide_nc', 'i' => $i);
1532
+				return $this->callHook($object, $hookmanager, $action, $params); // return 1 (qui est la valeur par défaut) OU -1 si erreur OU overrideReturn (contient -1 ou 0 ou 1)
1533
+			}
1534 1534
 		}
1535 1535
 		// Cache le prix pour les lignes standards dolibarr qui sont dans un ensemble
1536 1536
 		else if (!empty($hideprices))
1537 1537
 		{
1538 1538
 
1539
-		    // Check if a title exist for this line && if the title have subtotal
1540
-		    $lineTitle = TSubtotal::getParentTitleOfLine($object, $object->lines[$i]->rang);
1541
-		    if ($lineTitle && TSubtotal::titleHasTotalLine($object, $lineTitle, true))
1542
-		    {
1539
+			// Check if a title exist for this line && if the title have subtotal
1540
+			$lineTitle = TSubtotal::getParentTitleOfLine($object, $object->lines[$i]->rang);
1541
+			if ($lineTitle && TSubtotal::titleHasTotalLine($object, $lineTitle, true))
1542
+			{
1543 1543
 
1544
-		        $this->resprints = ' ';
1544
+				$this->resprints = ' ';
1545 1545
 
1546
-		        // currentcontext à modifier celon l'appel
1547
-		        $params = array('parameters' => $parameters, 'currentmethod' => 'pdf_getlinevatrate', 'currentcontext'=>'subtotal_hideprices', 'i' => $i);
1548
-		        return $this->callHook($object, $hookmanager, $action, $params); // return 1 (qui est la valeur par défaut) OU -1 si erreur OU overrideReturn (contient -1 ou 0 ou 1)
1549
-		    }
1546
+				// currentcontext à modifier celon l'appel
1547
+				$params = array('parameters' => $parameters, 'currentmethod' => 'pdf_getlinevatrate', 'currentcontext'=>'subtotal_hideprices', 'i' => $i);
1548
+				return $this->callHook($object, $hookmanager, $action, $params); // return 1 (qui est la valeur par défaut) OU -1 si erreur OU overrideReturn (contient -1 ou 0 ou 1)
1549
+			}
1550 1550
 		}
1551 1551
 
1552 1552
 		return 0;
@@ -1715,33 +1715,33 @@  discard block
 block discarded – undo
1715 1715
 
1716 1716
 		$this->add_numerotation($object);
1717 1717
 
1718
-        foreach($object->lines as $k => &$l) {
1719
-            if(TSubtotal::isSubtotal($l)) {
1720
-                $parentTitle = TSubtotal::getParentTitleOfLine($object, $l->rang);
1721
-                if(is_object($parentTitle) && empty($parentTitle->array_options)) $parentTitle->fetch_optionals();
1722
-                if(! empty($parentTitle->id) && ! empty($parentTitle->array_options['options_show_reduc'])) {
1723
-                    $l->remise_percent = 100;    // Affichage de la réduction sur la ligne de sous-total
1724
-                }
1725
-            }
1718
+		foreach($object->lines as $k => &$l) {
1719
+			if(TSubtotal::isSubtotal($l)) {
1720
+				$parentTitle = TSubtotal::getParentTitleOfLine($object, $l->rang);
1721
+				if(is_object($parentTitle) && empty($parentTitle->array_options)) $parentTitle->fetch_optionals();
1722
+				if(! empty($parentTitle->id) && ! empty($parentTitle->array_options['options_show_reduc'])) {
1723
+					$l->remise_percent = 100;    // Affichage de la réduction sur la ligne de sous-total
1724
+				}
1725
+			}
1726 1726
 
1727 1727
 
1728
-            // Pas de hook sur les colonnes du PDF expédition, on unset les bonnes variables
1729
-            if(($object->element == 'shipping' || $object->element == 'delivery') && $this->isModSubtotalLine($k, $object))
1728
+			// Pas de hook sur les colonnes du PDF expédition, on unset les bonnes variables
1729
+			if(($object->element == 'shipping' || $object->element == 'delivery') && $this->isModSubtotalLine($k, $object))
1730 1730
 			{
1731 1731
 				$l->qty = $l->qty_asked;
1732 1732
 				unset($l->qty_asked, $l->qty_shipped, $l->volume, $l->weight);
1733 1733
 			}
1734
-        }
1734
+		}
1735 1735
 
1736 1736
 		$hideInnerLines = GETPOST('hideInnerLines', 'int');
1737 1737
 		$hidedetails = GETPOST('hidedetails', 'int');
1738 1738
 
1739 1739
 		if ($hideInnerLines) { // si c une ligne de titre
1740
-	    	$fk_parent_line=0;
1740
+			$fk_parent_line=0;
1741 1741
 			$TLines =array();
1742 1742
 
1743 1743
 			$original_count=count($object->lines);
1744
-		    $TTvas = array(); // tableau de tva
1744
+			$TTvas = array(); // tableau de tva
1745 1745
 
1746 1746
 			foreach($object->lines as $k=>&$line)
1747 1747
 			{
@@ -1782,48 +1782,48 @@  discard block
 block discarded – undo
1782 1782
 
1783 1783
 				if ($hideInnerLines)
1784 1784
 				{
1785
-				    if(!empty($conf->global->SUBTOTAL_REPLACE_WITH_VAT_IF_HIDE_INNERLINES))
1786
-				    {
1787
-				        if($line->tva_tx != '0.000' && $line->product_type!=9){
1788
-
1789
-    				        // on remplit le tableau de tva pour substituer les lignes cachées
1790
-    				        $TTvas[$line->tva_tx]['total_tva'] += $line->total_tva;
1791
-    				        $TTvas[$line->tva_tx]['total_ht'] += $line->total_ht;
1792
-    				        $TTvas[$line->tva_tx]['total_ttc'] += $line->total_ttc;
1793
-    				    }
1794
-    					if($line->product_type==9 && $line->rowid>0)
1795
-    					{
1796
-    					    //Cas où je doit cacher les produits et afficher uniquement les sous-totaux avec les titres
1797
-    					    // génère des lignes d'affichage des montants HT soumis à tva
1798
-    					    $nbtva = count($TTvas);
1799
-    					    if(!empty($nbtva)){
1800
-    					        foreach ($TTvas as $tx =>$val){
1801
-    					            $l = clone $line;
1802
-    					            $l->product_type = 1;
1803
-    					            $l->special_code = '';
1804
-    					            $l->qty = 1;
1805
-    					            $l->desc = $langs->trans('AmountBeforeTaxesSubjectToVATX%', $langs->transnoentitiesnoconv('VAT'), price($tx));
1806
-    					            $l->tva_tx = $tx;
1807
-    					            $l->total_ht = $val['total_ht'];
1808
-    					            $l->total_tva = $val['total_tva'];
1809
-    					            $l->total = $line->total_ht;
1810
-    					            $l->total_ttc = $val['total_ttc'];
1811
-    					            $TLines[] = $l;
1812
-    					            array_shift($TTvas);
1813
-    					       }
1814
-    					    }
1815
-
1816
-    					    // ajoute la ligne de sous-total
1817
-    					    $TLines[] = $line;
1818
-    					}
1819
-				    } else {
1820
-
1821
-				        if($line->product_type==9 && $line->rowid>0)
1822
-				        {
1823
-				            // ajoute la ligne de sous-total
1824
-				            $TLines[] = $line;
1825
-				        }
1826
-				    }
1785
+					if(!empty($conf->global->SUBTOTAL_REPLACE_WITH_VAT_IF_HIDE_INNERLINES))
1786
+					{
1787
+						if($line->tva_tx != '0.000' && $line->product_type!=9){
1788
+
1789
+							// on remplit le tableau de tva pour substituer les lignes cachées
1790
+							$TTvas[$line->tva_tx]['total_tva'] += $line->total_tva;
1791
+							$TTvas[$line->tva_tx]['total_ht'] += $line->total_ht;
1792
+							$TTvas[$line->tva_tx]['total_ttc'] += $line->total_ttc;
1793
+						}
1794
+						if($line->product_type==9 && $line->rowid>0)
1795
+						{
1796
+							//Cas où je doit cacher les produits et afficher uniquement les sous-totaux avec les titres
1797
+							// génère des lignes d'affichage des montants HT soumis à tva
1798
+							$nbtva = count($TTvas);
1799
+							if(!empty($nbtva)){
1800
+								foreach ($TTvas as $tx =>$val){
1801
+									$l = clone $line;
1802
+									$l->product_type = 1;
1803
+									$l->special_code = '';
1804
+									$l->qty = 1;
1805
+									$l->desc = $langs->trans('AmountBeforeTaxesSubjectToVATX%', $langs->transnoentitiesnoconv('VAT'), price($tx));
1806
+									$l->tva_tx = $tx;
1807
+									$l->total_ht = $val['total_ht'];
1808
+									$l->total_tva = $val['total_tva'];
1809
+									$l->total = $line->total_ht;
1810
+									$l->total_ttc = $val['total_ttc'];
1811
+									$TLines[] = $l;
1812
+									array_shift($TTvas);
1813
+							   }
1814
+							}
1815
+
1816
+							// ajoute la ligne de sous-total
1817
+							$TLines[] = $line;
1818
+						}
1819
+					} else {
1820
+
1821
+						if($line->product_type==9 && $line->rowid>0)
1822
+						{
1823
+							// ajoute la ligne de sous-total
1824
+							$TLines[] = $line;
1825
+						}
1826
+					}
1827 1827
 
1828 1828
 
1829 1829
 				}
@@ -1848,20 +1848,20 @@  discard block
 block discarded – undo
1848 1848
 			$nbtva = count($TTvas);
1849 1849
 			if(!empty($nbtva) && $hideInnerLines && !empty($conf->global->SUBTOTAL_REPLACE_WITH_VAT_IF_HIDE_INNERLINES))
1850 1850
 			{
1851
-			    foreach ($TTvas as $tx =>$val){
1852
-			        $l = clone $line;
1853
-			        $l->product_type = 1;
1854
-			        $l->special_code = '';
1855
-			        $l->qty = 1;
1856
-			        $l->desc = $langs->trans('AmountBeforeTaxesSubjectToVATX%', $langs->transnoentitiesnoconv('VAT'), price($tx));
1857
-			        $l->tva_tx = $tx;
1858
-			        $l->total_ht = $val['total_ht'];
1859
-			        $l->total_tva = $val['total_tva'];
1860
-			        $l->total = $line->total_ht;
1861
-			        $l->total_ttc = $val['total_ttc'];
1862
-			        $TLines[] = $l;
1863
-			        array_shift($TTvas);
1864
-			    }
1851
+				foreach ($TTvas as $tx =>$val){
1852
+					$l = clone $line;
1853
+					$l->product_type = 1;
1854
+					$l->special_code = '';
1855
+					$l->qty = 1;
1856
+					$l->desc = $langs->trans('AmountBeforeTaxesSubjectToVATX%', $langs->transnoentitiesnoconv('VAT'), price($tx));
1857
+					$l->tva_tx = $tx;
1858
+					$l->total_ht = $val['total_ht'];
1859
+					$l->total_tva = $val['total_tva'];
1860
+					$l->total = $line->total_ht;
1861
+					$l->total_ttc = $val['total_ttc'];
1862
+					$TLines[] = $l;
1863
+					array_shift($TTvas);
1864
+				}
1865 1865
 			}
1866 1866
 
1867 1867
 			global $nblignes;
@@ -1873,7 +1873,7 @@  discard block
 block discarded – undo
1873 1873
 				$this->resprints = '';
1874 1874
 				return 0;
1875 1875
 			}
1876
-	    }
1876
+		}
1877 1877
 
1878 1878
 		return 0;
1879 1879
 	}
@@ -1998,7 +1998,7 @@  discard block
 block discarded – undo
1998 1998
 			$this->resprints = -1;
1999 1999
 		}
2000 2000
 
2001
-        return 0;
2001
+		return 0;
2002 2002
 	}
2003 2003
 
2004 2004
 	/**
@@ -2054,11 +2054,11 @@  discard block
 block discarded – undo
2054 2054
 		}
2055 2055
 		elseif($object->element == 'order_supplier' )
2056 2056
 		{
2057
-		    $createRight = $user->rights->fournisseur->commande->creer;
2057
+			$createRight = $user->rights->fournisseur->commande->creer;
2058 2058
 		}
2059 2059
 		elseif($object->element == 'invoice_supplier' )
2060 2060
 		{
2061
-		    $createRight = $user->rights->fournisseur->facture->creer;
2061
+			$createRight = $user->rights->fournisseur->facture->creer;
2062 2062
 		}
2063 2063
 		elseif($object->element == 'commande' && in_array('ordershipmentcard', $contexts))
2064 2064
 		{
@@ -2087,27 +2087,27 @@  discard block
 block discarded – undo
2087 2087
 			$line = $originline;
2088 2088
 		}
2089 2089
  		if($object->element=='facture')$idvar = 'facid';
2090
-        else $idvar='id';
2090
+		else $idvar='id';
2091 2091
 		if($line->special_code!=$this->module_number || $line->product_type!=9) {
2092 2092
 			if ($object->statut == 0  && $createRight && !empty($conf->global->SUBTOTAL_ALLOW_DUPLICATE_LINE) && $object->element !== 'invoice_supplier')
2093
-            {
2094
-                if(!(TSubtotal::isModSubtotalLine($line)) && ( $line->fk_prev_id === null ) && !($action == "editline" && GETPOST('lineid', 'int') == $line->id)) {
2095
-                    echo '<a name="duplicate-'.$line->id.'" href="' . $_SERVER['PHP_SELF'] . '?' . $idvar . '=' . $object->id . '&action=duplicate&lineid=' . $line->id . '"><i class="fa fa-clone" aria-hidden="true"></i></a>';
2093
+			{
2094
+				if(!(TSubtotal::isModSubtotalLine($line)) && ( $line->fk_prev_id === null ) && !($action == "editline" && GETPOST('lineid', 'int') == $line->id)) {
2095
+					echo '<a name="duplicate-'.$line->id.'" href="' . $_SERVER['PHP_SELF'] . '?' . $idvar . '=' . $object->id . '&action=duplicate&lineid=' . $line->id . '"><i class="fa fa-clone" aria-hidden="true"></i></a>';
2096 2096
 
2097
-                    ?>
2097
+					?>
2098 2098
                         <script type="text/javascript">
2099 2099
                             $(document).ready(function() {
2100 2100
                                 $("a[name='duplicate-<?php echo $line->id; ?>']").prependTo($('#row-<?php echo $line->id; ?>').find('.linecoledit'));
2101 2101
                             });
2102 2102
                         </script>
2103 2103
                     <?php
2104
-                }
2104
+				}
2105 2105
 
2106
-            }
2106
+			}
2107 2107
 			return 0;
2108 2108
 		}
2109 2109
 		else if (in_array('invoicecard',$contexts) || in_array('invoicesuppliercard',$contexts) || in_array('propalcard',$contexts) || in_array('supplier_proposalcard',$contexts) || in_array('ordercard',$contexts) || in_array('ordersuppliercard',$contexts) || in_array('invoicereccard',$contexts))
2110
-        {
2110
+		{
2111 2111
 
2112 2112
 
2113 2113
 			if((float)DOL_VERSION <= 3.4)
@@ -2156,7 +2156,7 @@  discard block
 block discarded – undo
2156 2156
 			//var_dump($line);
2157 2157
 
2158 2158
 			// HTML 5 data for js
2159
-            $data = $this->_getHtmlData($parameters, $object, $action, $hookmanager);
2159
+			$data = $this->_getHtmlData($parameters, $object, $action, $hookmanager);
2160 2160
 
2161 2161
 
2162 2162
 			?>
@@ -2218,8 +2218,8 @@  discard block
 block discarded – undo
2218 2218
 						}
2219 2219
 
2220 2220
 						if ($object->element == 'order_supplier' || $object->element == 'invoice_supplier') {
2221
-						    $line->label = !empty($line->description) ? $line->description : $line->desc;
2222
-						    $line->description = '';
2221
+							$line->label = !empty($line->description) ? $line->description : $line->desc;
2222
+							$line->description = '';
2223 2223
 						}
2224 2224
 						$newlabel = $line->label;
2225 2225
 						if($line->label=='' && !$isFreeText) {
@@ -2253,38 +2253,38 @@  discard block
 block discarded – undo
2253 2253
 
2254 2254
 
2255 2255
 						echo '<div class="subtotal_underline" style="margin-left:24px; line-height: 25px;">';
2256
-                        echo '<div>';
2257
-                        echo '<input style="vertical-align:sub;"  type="checkbox" name="line-pagebreak" id="subtotal-pagebreak" value="8" '.(($line->info_bits > 0) ? 'checked="checked"' : '') .' />&nbsp;';
2258
-                        echo '<label for="subtotal-pagebreak">'.$langs->trans('AddBreakPageBefore').'</label>';
2259
-                        echo '</div>';
2260
-
2261
-                        if (TSubtotal::isTitle($line))
2262
-                        {
2263
-                            $form = new Form($db);
2264
-                            echo '<div>';
2265
-                            echo '<label for="subtotal_tva_tx">'.$form->textwithpicto($langs->trans('subtotal_apply_default_tva'), $langs->trans('subtotal_apply_default_tva_help')).'</label>';
2266
-                            echo '<select id="subtotal_tva_tx" name="subtotal_tva_tx" class="flat"><option selected="selected" value="">-</option>';
2267
-                            if (empty($readonlyForSituation)) echo str_replace('selected', '', $form->load_tva('subtotal_tva_tx', '', $parameters['seller'], $parameters['buyer'], 0, 0, '', true));
2268
-                            echo '</select>';
2269
-                            echo '</div>';
2270
-
2271
-                            if (!empty($conf->global->INVOICE_USE_SITUATION) && $object->element == 'facture' && $object->type == Facture::TYPE_SITUATION)
2272
-                            {
2273
-                                echo '<div>';
2274
-                                echo '<label for="subtotal_progress">'.$langs->trans('subtotal_apply_progress').'</label> <input id="subtotal_progress" name="subtotal_progress" value="" size="1" />%';
2275
-                                echo '</div>';
2276
-                            }
2277
-                            echo '<div>';
2278
-                            echo '<input style="vertical-align:sub;"  type="checkbox" name="line-showTotalHT" id="subtotal-showTotalHT" value="9" '.(($line->array_options['options_show_total_ht'] > 0) ? 'checked="checked"' : '') .' />&nbsp;';
2279
-                            echo '<label for="subtotal-showTotalHT">'.$langs->trans('ShowTotalHTOnSubtotalBlock').'</label>';
2280
-                            echo '</div>';
2281
-
2282
-                            echo '<div>';
2283
-                            echo '<input style="vertical-align:sub;"  type="checkbox" name="line-showReduc" id="subtotal-showReduc" value="1" '.(($line->array_options['options_show_reduc'] > 0) ? 'checked="checked"' : '') .' />&nbsp;';
2284
-                            echo '<label for="subtotal-showReduc">'.$langs->trans('ShowReducOnSubtotalBlock').'</label>';
2285
-                            echo '</div>';
2286
-                        }
2287
-                        else if ($isFreeText) echo TSubtotal::getFreeTextHtml($line, (bool) $readonlyForSituation);
2256
+						echo '<div>';
2257
+						echo '<input style="vertical-align:sub;"  type="checkbox" name="line-pagebreak" id="subtotal-pagebreak" value="8" '.(($line->info_bits > 0) ? 'checked="checked"' : '') .' />&nbsp;';
2258
+						echo '<label for="subtotal-pagebreak">'.$langs->trans('AddBreakPageBefore').'</label>';
2259
+						echo '</div>';
2260
+
2261
+						if (TSubtotal::isTitle($line))
2262
+						{
2263
+							$form = new Form($db);
2264
+							echo '<div>';
2265
+							echo '<label for="subtotal_tva_tx">'.$form->textwithpicto($langs->trans('subtotal_apply_default_tva'), $langs->trans('subtotal_apply_default_tva_help')).'</label>';
2266
+							echo '<select id="subtotal_tva_tx" name="subtotal_tva_tx" class="flat"><option selected="selected" value="">-</option>';
2267
+							if (empty($readonlyForSituation)) echo str_replace('selected', '', $form->load_tva('subtotal_tva_tx', '', $parameters['seller'], $parameters['buyer'], 0, 0, '', true));
2268
+							echo '</select>';
2269
+							echo '</div>';
2270
+
2271
+							if (!empty($conf->global->INVOICE_USE_SITUATION) && $object->element == 'facture' && $object->type == Facture::TYPE_SITUATION)
2272
+							{
2273
+								echo '<div>';
2274
+								echo '<label for="subtotal_progress">'.$langs->trans('subtotal_apply_progress').'</label> <input id="subtotal_progress" name="subtotal_progress" value="" size="1" />%';
2275
+								echo '</div>';
2276
+							}
2277
+							echo '<div>';
2278
+							echo '<input style="vertical-align:sub;"  type="checkbox" name="line-showTotalHT" id="subtotal-showTotalHT" value="9" '.(($line->array_options['options_show_total_ht'] > 0) ? 'checked="checked"' : '') .' />&nbsp;';
2279
+							echo '<label for="subtotal-showTotalHT">'.$langs->trans('ShowTotalHTOnSubtotalBlock').'</label>';
2280
+							echo '</div>';
2281
+
2282
+							echo '<div>';
2283
+							echo '<input style="vertical-align:sub;"  type="checkbox" name="line-showReduc" id="subtotal-showReduc" value="1" '.(($line->array_options['options_show_reduc'] > 0) ? 'checked="checked"' : '') .' />&nbsp;';
2284
+							echo '<label for="subtotal-showReduc">'.$langs->trans('ShowReducOnSubtotalBlock').'</label>';
2285
+							echo '</div>';
2286
+						}
2287
+						else if ($isFreeText) echo TSubtotal::getFreeTextHtml($line, (bool) $readonlyForSituation);
2288 2288
 						echo '</div>';
2289 2289
 
2290 2290
 						if (TSubtotal::isTitle($line))
@@ -2911,17 +2911,17 @@  discard block
 block discarded – undo
2911 2911
 		if ($object->statut == 0 && !empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && $action != 'editline')
2912 2912
 		{
2913 2913
 
2914
-		    if($object->element == 'invoice_supplier' || $object->element == 'order_supplier')
2915
-		    {
2916
-		        foreach ($object->lines as $line)
2917
-		        {
2918
-		            // fetch optionals attributes and labels
2919
-		            require_once(DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php');
2920
-		            $extrafields=new ExtraFields($this->db);
2921
-		            $extralabels=$extrafields->fetch_name_optionals_label($object->table_element_line,true);
2922
-		            $line->fetch_optionals($line->id,$extralabels);
2923
-		        }
2924
-		    }
2914
+			if($object->element == 'invoice_supplier' || $object->element == 'order_supplier')
2915
+			{
2916
+				foreach ($object->lines as $line)
2917
+				{
2918
+					// fetch optionals attributes and labels
2919
+					require_once(DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php');
2920
+					$extrafields=new ExtraFields($this->db);
2921
+					$extralabels=$extrafields->fetch_name_optionals_label($object->table_element_line,true);
2922
+					$line->fetch_optionals($line->id,$extralabels);
2923
+				}
2924
+			}
2925 2925
 
2926 2926
 			$TSubNc = array();
2927 2927
 			foreach ($object->lines as &$l)
@@ -3020,12 +3020,12 @@  discard block
 block discarded – undo
3020 3020
 	 */
3021 3021
 	function getlinetotalremise($parameters, &$object, &$action, $hookmanager)
3022 3022
 	{
3023
-	    // Les lignes NC ne sont pas censées afficher de montant total de remise, nouveau hook en v11 dans pdf_sponge
3024
-	    if (! empty($object->lines[$parameters['i']]->array_options['options_subtotal_nc']))
3025
-	    {
3026
-            $this->resprints = '';
3027
-            return 1;
3028
-	    }
3023
+		// Les lignes NC ne sont pas censées afficher de montant total de remise, nouveau hook en v11 dans pdf_sponge
3024
+		if (! empty($object->lines[$parameters['i']]->array_options['options_subtotal_nc']))
3025
+		{
3026
+			$this->resprints = '';
3027
+			return 1;
3028
+		}
3029 3029
 
3030 3030
 		return 0;
3031 3031
 	}
@@ -3035,80 +3035,80 @@  discard block
 block discarded – undo
3035 3035
 	{
3036 3036
 		dol_include_once('/subtotal/class/subtotal.class.php');
3037 3037
 
3038
-	    $line = &$parameters['line'];
3038
+		$line = &$parameters['line'];
3039 3039
 
3040
-	    $ThtmlData['data-id']           = $line->id;
3041
-	    $ThtmlData['data-product_type'] = $line->product_type;
3042
-	    $ThtmlData['data-qty']          = 0; //$line->qty;
3043
-	    $ThtmlData['data-level']        = TSubtotal::getNiveau($line);
3040
+		$ThtmlData['data-id']           = $line->id;
3041
+		$ThtmlData['data-product_type'] = $line->product_type;
3042
+		$ThtmlData['data-qty']          = 0; //$line->qty;
3043
+		$ThtmlData['data-level']        = TSubtotal::getNiveau($line);
3044 3044
 
3045
-	    if(TSubtotal::isTitle($line)){
3046
-	        $ThtmlData['data-issubtotal'] = 'title';
3047
-	    }elseif(TSubtotal::isSubtotal($line)){
3048
-	        $ThtmlData['data-issubtotal'] = 'subtotal';
3049
-	    }
3050
-	    else{
3051
-	        $ThtmlData['data-issubtotal'] = 'freetext';
3052
-	    }
3045
+		if(TSubtotal::isTitle($line)){
3046
+			$ThtmlData['data-issubtotal'] = 'title';
3047
+		}elseif(TSubtotal::isSubtotal($line)){
3048
+			$ThtmlData['data-issubtotal'] = 'subtotal';
3049
+		}
3050
+		else{
3051
+			$ThtmlData['data-issubtotal'] = 'freetext';
3052
+		}
3053 3053
 
3054 3054
 
3055
-	    // Change or add data  from hooks
3056
-	    $parameters = array_replace($parameters , array(  'ThtmlData' => $ThtmlData )  );
3055
+		// Change or add data  from hooks
3056
+		$parameters = array_replace($parameters , array(  'ThtmlData' => $ThtmlData )  );
3057 3057
 
3058
-	    // hook
3059
-	    $reshook = $hookmanager->executeHooks('subtotalLineHtmlData',$parameters,$object,$action); // Note that $action and $object may have been modified by hook
3060
-	    if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
3061
-	    if ($reshook>0)
3062
-	    {
3063
-	        $ThtmlData = $hookmanager->resArray;
3064
-	    }
3058
+		// hook
3059
+		$reshook = $hookmanager->executeHooks('subtotalLineHtmlData',$parameters,$object,$action); // Note that $action and $object may have been modified by hook
3060
+		if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
3061
+		if ($reshook>0)
3062
+		{
3063
+			$ThtmlData = $hookmanager->resArray;
3064
+		}
3065 3065
 
3066
-	    return $this->implodeHtmlData($ThtmlData);
3066
+		return $this->implodeHtmlData($ThtmlData);
3067 3067
 
3068 3068
 	}
3069 3069
 
3070 3070
 
3071 3071
 	function implodeHtmlData($ThtmlData = array())
3072 3072
 	{
3073
-	    $data = '';
3074
-	    foreach($ThtmlData as $k => $h )
3075
-	    {
3076
-	        if(is_array($h))
3077
-	        {
3078
-	            $h = json_encode($h);
3079
-	        }
3080
-
3081
-	        $data .= $k . '="'.dol_htmlentities($h, ENT_QUOTES).'" ';
3082
-	    }
3083
-
3084
-	    return $data;
3073
+		$data = '';
3074
+		foreach($ThtmlData as $k => $h )
3075
+		{
3076
+			if(is_array($h))
3077
+			{
3078
+				$h = json_encode($h);
3079
+			}
3080
+
3081
+			$data .= $k . '="'.dol_htmlentities($h, ENT_QUOTES).'" ';
3082
+		}
3083
+
3084
+		return $data;
3085 3085
 	}
3086 3086
 
3087 3087
 	function _ajax_block_order_js($object)
3088 3088
 	{
3089
-	    global $conf,$tagidfortablednd,$filepath,$langs;
3089
+		global $conf,$tagidfortablednd,$filepath,$langs;
3090 3090
 
3091
-	    /*
3091
+		/*
3092 3092
 	     * this part of js is base on dolibarr htdocs/core/tpl/ajaxrow.tpl.php
3093 3093
 	     * for compatibility reasons we don't use tableDnD but jquery sortable
3094 3094
 	     */
3095 3095
 
3096
-	    $id=$object->id;
3097
-	    $nboflines=(isset($object->lines)?count($object->lines):0);
3098
-	    $forcereloadpage=empty($conf->global->MAIN_FORCE_RELOAD_PAGE)?0:1;
3096
+		$id=$object->id;
3097
+		$nboflines=(isset($object->lines)?count($object->lines):0);
3098
+		$forcereloadpage=empty($conf->global->MAIN_FORCE_RELOAD_PAGE)?0:1;
3099 3099
 
3100
-	    $id=$object->id;
3101
-	    $fk_element=$object->fk_element;
3102
-	    $table_element_line=$object->table_element_line;
3103
-	    $nboflines=(isset($object->lines)?count($object->lines):(empty($nboflines)?0:$nboflines));
3104
-	    $tagidfortablednd=(empty($tagidfortablednd)?'tablelines':$tagidfortablednd);
3105
-	    $filepath=(empty($filepath)?'':$filepath);
3100
+		$id=$object->id;
3101
+		$fk_element=$object->fk_element;
3102
+		$table_element_line=$object->table_element_line;
3103
+		$nboflines=(isset($object->lines)?count($object->lines):(empty($nboflines)?0:$nboflines));
3104
+		$tagidfortablednd=(empty($tagidfortablednd)?'tablelines':$tagidfortablednd);
3105
+		$filepath=(empty($filepath)?'':$filepath);
3106 3106
 
3107 3107
 
3108
-	    if (GETPOST('action','aZ09') != 'editline' && $nboflines > 1)
3109
-	    {
3108
+		if (GETPOST('action','aZ09') != 'editline' && $nboflines > 1)
3109
+		{
3110 3110
 
3111
-	        ?>
3111
+			?>
3112 3112
 
3113 3113
 
3114 3114
 			<script type="text/javascript">
@@ -3265,31 +3265,31 @@  discard block
 block discarded – undo
3265 3265
 	}
3266 3266
 
3267 3267
 /**
3268
-     * @param $parameters
3269
-     * @param $object
3270
-     * @param $action
3271
-     * @param $hookmanager
3272
-     */
3268
+ * @param $parameters
3269
+ * @param $object
3270
+ * @param $action
3271
+ * @param $hookmanager
3272
+ */
3273 3273
 	function handleExpeditionTitleAndTotal($parameters, &$object, &$action, $hookmanager){
3274
-        global $conf;
3275
-        //var_dump($parameters['line']);
3276
-	    dol_include_once('subtotal/class/subtotal.class.php');
3277
-        $currentcontext = explode(':', $parameters['context']);
3274
+		global $conf;
3275
+		//var_dump($parameters['line']);
3276
+		dol_include_once('subtotal/class/subtotal.class.php');
3277
+		$currentcontext = explode(':', $parameters['context']);
3278 3278
 
3279
-	    if ( in_array('shippableorderlist',$currentcontext)) {
3279
+		if ( in_array('shippableorderlist',$currentcontext)) {
3280 3280
 
3281
-            //var_dump($parameters['line']);
3282
-            if(TSubtotal::isModSubtotalLine($parameters['line'])) {
3281
+			//var_dump($parameters['line']);
3282
+			if(TSubtotal::isModSubtotalLine($parameters['line'])) {
3283 3283
 
3284
-                $confOld = $conf->global->STOCK_MUST_BE_ENOUGH_FOR_SHIPMENT;
3285
-                $conf->global->STOCK_MUST_BE_ENOUGH_FOR_SHIPMENT = 0;
3286
-                $res =  $parameters['shipping']->addline($parameters['TEnt_comm'][$object->order->id], $parameters['line']->id, $parameters['line']->qty);
3287
-                $conf->global->STOCK_MUST_BE_ENOUGH_FOR_SHIPMENT = $confOld;
3288
-            }
3284
+				$confOld = $conf->global->STOCK_MUST_BE_ENOUGH_FOR_SHIPMENT;
3285
+				$conf->global->STOCK_MUST_BE_ENOUGH_FOR_SHIPMENT = 0;
3286
+				$res =  $parameters['shipping']->addline($parameters['TEnt_comm'][$object->order->id], $parameters['line']->id, $parameters['line']->qty);
3287
+				$conf->global->STOCK_MUST_BE_ENOUGH_FOR_SHIPMENT = $confOld;
3288
+			}
3289 3289
 
3290
-        }
3290
+		}
3291 3291
 
3292
-    }
3292
+	}
3293 3293
 
3294 3294
 	/**
3295 3295
 	 * Overloading the defineColumnField function
Please login to merge, or discard this patch.
Spacing   +529 added lines, -529 removed lines patch added patch discarded remove patch
@@ -19,17 +19,17 @@  discard block
 block discarded – undo
19 19
 
20 20
 		global $type_element, $where;
21 21
 
22
-		$contexts = explode(':',$parameters['context']);
22
+		$contexts = explode(':', $parameters['context']);
23 23
 
24
-		if(in_array('consumptionthirdparty',$contexts) && in_array($type_element, array('propal', 'order', 'invoice', 'supplier_order', 'supplier_invoice', 'supplier_proposal'))) {
24
+		if (in_array('consumptionthirdparty', $contexts) && in_array($type_element, array('propal', 'order', 'invoice', 'supplier_order', 'supplier_invoice', 'supplier_proposal'))) {
25 25
 			$mod_num = TSubtotal::$module_number;
26 26
 
27 27
 			// Not a title (can't use TSubtotal class methods in sql)
28
-			$where.= ' AND (d.special_code != '.$mod_num.' OR d.product_type != 9 OR d.qty > 9)';
28
+			$where .= ' AND (d.special_code != '.$mod_num.' OR d.product_type != 9 OR d.qty > 9)';
29 29
 			// Not a subtotal (can't use TSubtotal class methods in sql)
30
-			$where.= ' AND (d.special_code != '.$mod_num.' OR d.product_type != 9 OR d.qty < 90)';
30
+			$where .= ' AND (d.special_code != '.$mod_num.' OR d.product_type != 9 OR d.qty < 90)';
31 31
 			// Not a free line text (can't use TSubtotal class methods in sql)
32
-			$where.= ' AND (d.special_code != '.$mod_num.' OR d.product_type != 9 OR d.qty != 50)';
32
+			$where .= ' AND (d.special_code != '.$mod_num.' OR d.product_type != 9 OR d.qty != 50)';
33 33
 
34 34
 		}
35 35
 
@@ -111,47 +111,47 @@  discard block
 block discarded – undo
111 111
 
112 112
     function formObjectOptions($parameters, &$object, &$action, $hookmanager)
113 113
     {
114
-      	global $langs,$db,$user, $conf;
114
+      	global $langs, $db, $user, $conf;
115 115
 
116 116
 		$langs->load('subtotal@subtotal');
117 117
 
118
-		$contexts = explode(':',$parameters['context']);
118
+		$contexts = explode(':', $parameters['context']);
119 119
 
120
-		if(in_array('ordercard',$contexts) || in_array('ordersuppliercard',$contexts) || in_array('propalcard',$contexts) || in_array('supplier_proposalcard',$contexts) || in_array('invoicecard',$contexts) || in_array('invoicesuppliercard',$contexts) || in_array('invoicereccard',$contexts) || in_array('expeditioncard',$contexts)) {
120
+		if (in_array('ordercard', $contexts) || in_array('ordersuppliercard', $contexts) || in_array('propalcard', $contexts) || in_array('supplier_proposalcard', $contexts) || in_array('invoicecard', $contexts) || in_array('invoicesuppliercard', $contexts) || in_array('invoicereccard', $contexts) || in_array('expeditioncard', $contexts)) {
121 121
 
122 122
 			$createRight = $user->rights->{$object->element}->creer;
123
-			if($object->element == 'facturerec' )
123
+			if ($object->element == 'facturerec')
124 124
 			{
125 125
 				$object->statut = 0; // hack for facture rec
126 126
 				$createRight = $user->rights->facture->creer;
127
-			} elseif($object->element == 'order_supplier' )
127
+			} elseif ($object->element == 'order_supplier')
128 128
 			{
129 129
 			    $createRight = $user->rights->fournisseur->commande->creer;
130
-			} elseif($object->element == 'invoice_supplier' )
130
+			} elseif ($object->element == 'invoice_supplier')
131 131
 			{
132 132
 			    $createRight = $user->rights->fournisseur->facture->creer;
133 133
 			}
134
-			elseif($object->element == 'shipping')
134
+			elseif ($object->element == 'shipping')
135 135
 			{
136 136
 				$createRight = true; // No rights management for shipments
137 137
 			}
138 138
 
139
-			if ($object->statut == 0  && $createRight) {
139
+			if ($object->statut == 0 && $createRight) {
140 140
 
141 141
 
142
-				if($object->element=='facture')$idvar = 'facid';
143
-				else $idvar='id';
142
+				if ($object->element == 'facture')$idvar = 'facid';
143
+				else $idvar = 'id';
144 144
 
145
-				if(in_array($action, array('add_title_line', 'add_total_line', 'add_subtitle_line', 'add_subtotal_line', 'add_free_text')) )
145
+				if (in_array($action, array('add_title_line', 'add_total_line', 'add_subtitle_line', 'add_subtotal_line', 'add_free_text')))
146 146
 				{
147 147
 					$level = GETPOST('level', 'int'); //New avec SUBTOTAL_USE_NEW_FORMAT
148 148
 
149
-					if($action=='add_title_line') {
149
+					if ($action == 'add_title_line') {
150 150
 						$title = GETPOST('title', 'none');
151
-						if(empty($title)) $title = $langs->trans('title');
152
-						$qty = $level<1 ? 1 : $level ;
151
+						if (empty($title)) $title = $langs->trans('title');
152
+						$qty = $level < 1 ? 1 : $level;
153 153
 					}
154
-					else if($action=='add_free_text') {
154
+					else if ($action == 'add_free_text') {
155 155
 						$title = GETPOST('title', 'restricthtml');
156 156
 
157 157
 						if (empty($title)) {
@@ -163,21 +163,21 @@  discard block
 block discarded – undo
163 163
 								}
164 164
 							}
165 165
 						}
166
-						if(empty($title)) $title = $langs->trans('subtotalAddLineDescription');
166
+						if (empty($title)) $title = $langs->trans('subtotalAddLineDescription');
167 167
 						$qty = 50;
168 168
 					}
169
-					else if($action=='add_subtitle_line') {
169
+					else if ($action == 'add_subtitle_line') {
170 170
 						$title = GETPOST('title', 'none');
171
-						if(empty($title)) $title = $langs->trans('subtitle');
171
+						if (empty($title)) $title = $langs->trans('subtitle');
172 172
 						$qty = 2;
173 173
 					}
174
-					else if($action=='add_subtotal_line') {
174
+					else if ($action == 'add_subtotal_line') {
175 175
 						$title = $langs->trans('SubSubTotal');
176 176
 						$qty = 98;
177 177
 					}
178 178
 					else {
179 179
 						$title = GETPOST('title', 'none') ? GETPOST('title', 'none') : $langs->trans('SubTotal');
180
-						$qty = $level ? 100-$level : 99;
180
+						$qty = $level ? 100 - $level : 99;
181 181
 					}
182 182
 					dol_include_once('/subtotal/class/subtotal.class.php');
183 183
 
@@ -185,15 +185,15 @@  discard block
 block discarded – undo
185 185
 
186 186
 	    			TSubtotal::addSubTotalLine($object, $title, $qty);
187 187
 				}
188
-				else if($action==='ask_deleteallline') {
189
-						$form=new Form($db);
188
+				else if ($action === 'ask_deleteallline') {
189
+						$form = new Form($db);
190 190
 
191
-						$lineid = GETPOST('lineid','integer');
191
+						$lineid = GETPOST('lineid', 'integer');
192 192
 						$TIdForGroup = TSubtotal::getLinesFromTitleId($object, $lineid, true);
193 193
 
194 194
 						$nbLines = count($TIdForGroup);
195 195
 
196
-						$formconfirm=$form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&lineid='.$lineid, $langs->trans('deleteWithAllLines'), $langs->trans('ConfirmDeleteAllThisLines',$nbLines), 'confirm_delete_all_lines','',0,1);
196
+						$formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&lineid='.$lineid, $langs->trans('deleteWithAllLines'), $langs->trans('ConfirmDeleteAllThisLines', $nbLines), 'confirm_delete_all_lines', '', 0, 1);
197 197
 						print $formconfirm;
198 198
 				}
199 199
 
@@ -203,13 +203,13 @@  discard block
 block discarded – undo
203 203
 				}
204 204
 
205 205
 
206
-				if($object->element != 'shipping' && $action!='editline') {
206
+				if ($object->element != 'shipping' && $action != 'editline') {
207 207
 					// New format is for 3.8
208 208
 					$this->printNewFormat($object, $conf, $langs, $idvar);
209 209
 				}
210 210
 			}
211 211
 		}
212
-		elseif ((!empty($parameters['currentcontext']) && $parameters['currentcontext'] == 'orderstoinvoice') || in_array('orderstoinvoice',$contexts) || in_array('orderstoinvoicesupplier',$contexts))
212
+		elseif ((!empty($parameters['currentcontext']) && $parameters['currentcontext'] == 'orderstoinvoice') || in_array('orderstoinvoice', $contexts) || in_array('orderstoinvoicesupplier', $contexts))
213 213
 		{
214 214
 			?>
215 215
 			<script type="text/javascript">
@@ -234,7 +234,7 @@  discard block
 block discarded – undo
234 234
 				$(document).ready(function() {
235 235
 					$('div.fiche div.tabsAction').append('<br />');
236 236
 
237
-					$('div.fiche div.tabsAction').append('<div class="inline-block divButAction"><a id="add_title_line" rel="add_title_line" href="javascript:;" class="butAction"><?php echo  $langs->trans('AddTitle' )?></a></div>');
237
+					$('div.fiche div.tabsAction').append('<div class="inline-block divButAction"><a id="add_title_line" rel="add_title_line" href="javascript:;" class="butAction"><?php echo  $langs->trans('AddTitle')?></a></div>');
238 238
 					$('div.fiche div.tabsAction').append('<div class="inline-block divButAction"><a id="add_total_line" rel="add_total_line" href="javascript:;" class="butAction"><?php echo  $langs->trans('AddSubTotal')?></a></div>');
239 239
 					$('div.fiche div.tabsAction').append('<div class="inline-block divButAction"><a id="add_free_text" rel="add_free_text" href="javascript:;" class="butAction"><?php echo  $langs->trans('AddFreeText')?></a></div>');
240 240
 
@@ -249,7 +249,7 @@  discard block
 block discarded – undo
249 249
 					     $( "#dialog-prompt-subtotal" ).remove();
250 250
 
251 251
 						 var dialog_html = '<div id="dialog-prompt-subtotal" '+(action == 'addSubtotal' ? 'class="center"' : '')+' >';
252
-						 dialog_html += '<input id="token" name="token" type="hidden" value="<?php echo ((float) DOL_VERSION < 11.0) ?  $_SESSION['newtoken'] : newToken(); ?>" />';
252
+						 dialog_html += '<input id="token" name="token" type="hidden" value="<?php echo ((float) DOL_VERSION < 11.0) ? $_SESSION['newtoken'] : newToken(); ?>" />';
253 253
 
254 254
 						 if (typeof show_under_title != 'undefined' && show_under_title)
255 255
 						 {
@@ -286,9 +286,9 @@  discard block
 block discarded – undo
286 286
 						$('body').append(dialog_html);
287 287
 
288 288
 						<?php
289
-						$editorTool = empty($conf->global->FCKEDITOR_EDITORNAME)?'ckeditor':$conf->global->FCKEDITOR_EDITORNAME;
290
-						$editorConf = empty($conf->global->FCKEDITOR_ENABLE_DETAILS)?false:$conf->global->FCKEDITOR_ENABLE_DETAILS;
291
-						if($editorConf && in_array($editorTool,array('textarea','ckeditor'))){
289
+						$editorTool = empty($conf->global->FCKEDITOR_EDITORNAME) ? 'ckeditor' : $conf->global->FCKEDITOR_EDITORNAME;
290
+						$editorConf = empty($conf->global->FCKEDITOR_ENABLE_DETAILS) ?false:$conf->global->FCKEDITOR_ENABLE_DETAILS;
291
+						if ($editorConf && in_array($editorTool, array('textarea', 'ckeditor'))) {
292 292
 						?>
293 293
 						if (action == 'addTitle' || action == 'addFreeTxt')
294 294
 						{
@@ -404,63 +404,63 @@  discard block
 block discarded – undo
404 404
 		global $conf, $langs, $bc;
405 405
 
406 406
 		$action = GETPOST('action', 'none');
407
-		$TContext = explode(':',$parameters['context']);
407
+		$TContext = explode(':', $parameters['context']);
408 408
 		if (
409
-				in_array('invoicecard',$TContext)
410
-		        || in_array('invoicesuppliercard',$TContext)
411
-				|| in_array('propalcard',$TContext)
412
-				|| in_array('ordercard',$TContext)
413
-		        || in_array('ordersuppliercard',$TContext)
414
-				|| in_array('invoicereccard',$TContext)
409
+				in_array('invoicecard', $TContext)
410
+		        || in_array('invoicesuppliercard', $TContext)
411
+				|| in_array('propalcard', $TContext)
412
+				|| in_array('ordercard', $TContext)
413
+		        || in_array('ordersuppliercard', $TContext)
414
+				|| in_array('invoicereccard', $TContext)
415 415
 			)
416 416
 	        {
417
-	            $hideInnerLines	= isset( $_SESSION['subtotal_hideInnerLines_'.$parameters['modulepart']][$object->id] ) ?  $_SESSION['subtotal_hideInnerLines_'.$parameters['modulepart']][$object->id] : 0;
418
-	            $hidedetails	= isset( $_SESSION['subtotal_hidedetails_'.$parameters['modulepart']][$object->id] ) ?  $_SESSION['subtotal_hidedetails_'.$parameters['modulepart']][$object->id] : 0;
419
-				$hidepricesDefaultConf = !empty($conf->global->SUBTOTAL_HIDE_PRICE_DEFAULT_CHECKED)?$conf->global->SUBTOTAL_HIDE_PRICE_DEFAULT_CHECKED:0;
420
-				$hideprices= isset( $_SESSION['subtotal_hideprices_'.$parameters['modulepart']][$object->id] ) ?  $_SESSION['subtotal_hideprices_'.$parameters['modulepart']][$object->id] : $hidepricesDefaultConf;
417
+	            $hideInnerLines = isset($_SESSION['subtotal_hideInnerLines_'.$parameters['modulepart']][$object->id]) ? $_SESSION['subtotal_hideInnerLines_'.$parameters['modulepart']][$object->id] : 0;
418
+	            $hidedetails = isset($_SESSION['subtotal_hidedetails_'.$parameters['modulepart']][$object->id]) ? $_SESSION['subtotal_hidedetails_'.$parameters['modulepart']][$object->id] : 0;
419
+				$hidepricesDefaultConf = !empty($conf->global->SUBTOTAL_HIDE_PRICE_DEFAULT_CHECKED) ? $conf->global->SUBTOTAL_HIDE_PRICE_DEFAULT_CHECKED : 0;
420
+				$hideprices = isset($_SESSION['subtotal_hideprices_'.$parameters['modulepart']][$object->id]) ? $_SESSION['subtotal_hideprices_'.$parameters['modulepart']][$object->id] : $hidepricesDefaultConf;
421 421
 
422
-				$var=false;
422
+				$var = false;
423 423
 				$out = '';
424
-		     	$out.= '<tr '.$bc[$var].'>
424
+		     	$out .= '<tr '.$bc[$var].'>
425 425
 		     			<td colspan="4" align="right">
426 426
 		     				<label for="hideInnerLines">'.$langs->trans('HideInnerLines').'</label>
427
-		     				<input type="checkbox" onclick="if($(this).is(\':checked\')) { $(\'#hidedetails\').prop(\'checked\', \'checked\')  }" id="hideInnerLines" name="hideInnerLines" value="1" '.(( $hideInnerLines ) ? 'checked="checked"' : '' ).' />
427
+		     				<input type="checkbox" onclick="if($(this).is(\':checked\')) { $(\'#hidedetails\').prop(\'checked\', \'checked\')  }" id="hideInnerLines" name="hideInnerLines" value="1" '.(($hideInnerLines) ? 'checked="checked"' : '').' />
428 428
 		     			</td>
429 429
 		     			</tr>';
430 430
 
431
-		     	$var=!$var;
432
-		     	$out.= '<tr '.$bc[$var].'>
431
+		     	$var = !$var;
432
+		     	$out .= '<tr '.$bc[$var].'>
433 433
 		     			<td colspan="4" align="right">
434 434
 		     				<label for="hidedetails">'.$langs->trans('SubTotalhidedetails').'</label>
435
-		     				<input type="checkbox" id="hidedetails" name="hidedetails" value="1" '.(( $hidedetails ) ? 'checked="checked"' : '' ).' />
435
+		     				<input type="checkbox" id="hidedetails" name="hidedetails" value="1" '.(($hidedetails) ? 'checked="checked"' : '').' />
436 436
 		     			</td>
437 437
 		     			</tr>';
438 438
 
439
-		     	$var=!$var;
440
-		     	$out.= '<tr '.$bc[$var].'>
439
+		     	$var = !$var;
440
+		     	$out .= '<tr '.$bc[$var].'>
441 441
 		     			<td colspan="4" align="right">
442 442
 		     				<label for="hideprices">'.$langs->trans('SubTotalhidePrice').'</label>
443
-		     				<input type="checkbox" id="hideprices" name="hideprices" value="1" '.(( $hideprices ) ? 'checked="checked"' : '' ).' />
443
+		     				<input type="checkbox" id="hideprices" name="hideprices" value="1" '.(($hideprices) ? 'checked="checked"' : '').' />
444 444
 		     			</td>
445 445
 		     			</tr>';
446 446
 
447 447
 
448 448
 
449 449
 				if (
450
-					(in_array('propalcard',$TContext) && !empty($conf->global->SUBTOTAL_PROPAL_ADD_RECAP))
451
-					|| (in_array('ordercard',$TContext) && !empty($conf->global->SUBTOTAL_COMMANDE_ADD_RECAP))
452
-				    || (in_array('ordersuppliercard',$TContext) && !empty($conf->global->SUBTOTAL_COMMANDE_ADD_RECAP))
453
-					|| (in_array('invoicecard',$TContext) && !empty($conf->global->SUBTOTAL_INVOICE_ADD_RECAP))
454
-				    || (in_array('invoicesuppliercard',$TContext) && !empty($conf->global->SUBTOTAL_INVOICE_ADD_RECAP))
455
-					|| (in_array('invoicereccard',$TContext)  && !empty($conf->global->SUBTOTAL_INVOICE_ADD_RECAP ))
450
+					(in_array('propalcard', $TContext) && !empty($conf->global->SUBTOTAL_PROPAL_ADD_RECAP))
451
+					|| (in_array('ordercard', $TContext) && !empty($conf->global->SUBTOTAL_COMMANDE_ADD_RECAP))
452
+				    || (in_array('ordersuppliercard', $TContext) && !empty($conf->global->SUBTOTAL_COMMANDE_ADD_RECAP))
453
+					|| (in_array('invoicecard', $TContext) && !empty($conf->global->SUBTOTAL_INVOICE_ADD_RECAP))
454
+				    || (in_array('invoicesuppliercard', $TContext) && !empty($conf->global->SUBTOTAL_INVOICE_ADD_RECAP))
455
+					|| (in_array('invoicereccard', $TContext) && !empty($conf->global->SUBTOTAL_INVOICE_ADD_RECAP))
456 456
 				)
457 457
 				{
458
-					$var=!$var;
459
-					$out.= '
458
+					$var = !$var;
459
+					$out .= '
460 460
 						<tr '.$bc[$var].'>
461 461
 							<td colspan="4" align="right">
462 462
 								<label for="subtotal_add_recap">'.$langs->trans('subtotal_add_recap').'</label>
463
-								<input type="checkbox" id="subtotal_add_recap" name="subtotal_add_recap" value="1" '.( GETPOST('subtotal_add_recap', 'none') ? 'checked="checked"' : '' ).' />
463
+								<input type="checkbox" id="subtotal_add_recap" name="subtotal_add_recap" value="1" '.(GETPOST('subtotal_add_recap', 'none') ? 'checked="checked"' : '').' />
464 464
 							</td>
465 465
 						</tr>';
466 466
 				}
@@ -476,7 +476,7 @@  discard block
 block discarded – undo
476 476
     function formEditProductOptions($parameters, &$object, &$action, $hookmanager)
477 477
     {
478 478
 
479
-    	if (in_array('invoicecard',explode(':',$parameters['context'])))
479
+    	if (in_array('invoicecard', explode(':', $parameters['context'])))
480 480
         {
481 481
 
482 482
         }
@@ -487,7 +487,7 @@  discard block
 block discarded – undo
487 487
 	function ODTSubstitutionLine(&$parameters, &$object, $action, $hookmanager) {
488 488
 		global $conf;
489 489
 
490
-		if($action === 'builddoc') {
490
+		if ($action === 'builddoc') {
491 491
 
492 492
 			$line = &$parameters['line'];
493 493
 			$object = &$parameters['object'];
@@ -498,7 +498,7 @@  discard block
 block discarded – undo
498 498
             $substitutionarray['line_modsubtotal_total'] = false;
499 499
             $substitutionarray['line_modsubtotal_title'] = false;
500 500
 
501
-			if($line->product_type == 9 && $line->special_code == $this->module_number) {
501
+			if ($line->product_type == 9 && $line->special_code == $this->module_number) {
502 502
 				$substitutionarray['line_modsubtotal'] = 1;
503 503
                 $substitutionarray['line_not_modsubtotal'] = false;
504 504
 
@@ -510,7 +510,7 @@  discard block
 block discarded – undo
510 510
 					 = $substitutionarray['line_up']
511 511
 					 = '';
512 512
 
513
-				if($line->qty>90) {
513
+				if ($line->qty > 90) {
514 514
 					$substitutionarray['line_modsubtotal_total'] = true;
515 515
 
516 516
 					//list($total, $total_tva, $total_ttc, $TTotal_tva) = $this->getTotalLineFromObject($object, $line, '', 1);
@@ -525,7 +525,7 @@  discard block
 block discarded – undo
525 525
 
526 526
 
527 527
 			}
528
-			else{
528
+			else {
529 529
 				$substitutionarray['line_not_modsubtotal'] = true;
530 530
 				$substitutionarray['line_modsubtotal'] = 0;
531 531
 			}
@@ -538,32 +538,32 @@  discard block
 block discarded – undo
538 538
 	function createFrom($parameters, &$object, $action, $hookmanager) {
539 539
 
540 540
 		if (
541
-				in_array('invoicecard',explode(':',$parameters['context']))
542
-		        || in_array('invoicesuppliercard',explode(':',$parameters['context']))
543
-				|| in_array('propalcard',explode(':',$parameters['context']))
544
-		        || in_array('supplier_proposalcard',explode(':',$parameters['context']))
545
-				|| in_array('ordercard',explode(':',$parameters['context']))
546
-		        || in_array('ordersuppliercard',explode(':',$parameters['context']))
547
-				|| in_array('invoicereccard',explode(':',$parameters['context']))
541
+				in_array('invoicecard', explode(':', $parameters['context']))
542
+		        || in_array('invoicesuppliercard', explode(':', $parameters['context']))
543
+				|| in_array('propalcard', explode(':', $parameters['context']))
544
+		        || in_array('supplier_proposalcard', explode(':', $parameters['context']))
545
+				|| in_array('ordercard', explode(':', $parameters['context']))
546
+		        || in_array('ordersuppliercard', explode(':', $parameters['context']))
547
+				|| in_array('invoicereccard', explode(':', $parameters['context']))
548 548
 		) {
549 549
 
550 550
 			global $db;
551 551
 
552 552
 			$objFrom = $parameters['objFrom'];
553 553
 
554
-			if(empty($object->lines) && method_exists($object, 'fetch_lines')) $object->fetch_lines();
554
+			if (empty($object->lines) && method_exists($object, 'fetch_lines')) $object->fetch_lines();
555 555
 
556
-			foreach($objFrom->lines as $k=> &$lineOld) {
556
+			foreach ($objFrom->lines as $k=> &$lineOld) {
557 557
 
558
-					if($lineOld->product_type == 9 && $lineOld->info_bits > 0 ) {
558
+					if ($lineOld->product_type == 9 && $lineOld->info_bits > 0) {
559 559
 
560 560
 							$line = & $object->lines[$k];
561 561
 
562 562
 							$idLine = (int) ($line->id ? $line->id : $line->rowid);
563 563
 
564
-							if($line->info_bits != $lineOld->info_bits) {
564
+							if ($line->info_bits != $lineOld->info_bits) {
565 565
 								$db->query("UPDATE ".MAIN_DB_PREFIX.$line->table_element."
566
-								SET info_bits=".(int)$lineOld->info_bits."
566
+								SET info_bits=".(int) $lineOld->info_bits."
567 567
 								WHERE rowid = ".$idLine."
568 568
 								");
569 569
 							}
@@ -581,15 +581,15 @@  discard block
 block discarded – undo
581 581
 
582 582
 	function doActions($parameters, &$object, $action, $hookmanager)
583 583
 	{
584
-		global $db, $conf, $langs,$user;
584
+		global $db, $conf, $langs, $user;
585 585
 
586 586
 		dol_include_once('/subtotal/class/subtotal.class.php');
587 587
 		dol_include_once('/subtotal/lib/subtotal.lib.php');
588
-		require_once DOL_DOCUMENT_ROOT . '/core/class/extrafields.class.php';
588
+		require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
589 589
 
590 590
 		$showBlockExtrafields = GETPOST('showBlockExtrafields', 'none');
591 591
 
592
-		if($object->element=='facture') $idvar = 'facid';
592
+		if ($object->element == 'facture') $idvar = 'facid';
593 593
 		else $idvar = 'id';
594 594
 
595 595
 		if ($action == 'updateligne' || $action == 'updateline')
@@ -602,7 +602,7 @@  discard block
 block discarded – undo
602 602
 				if ($line->id == $lineid && TSubtotal::isModSubtotalLine($line))
603 603
 				{
604 604
 					$found = true;
605
-					if(TSubtotal::isTitle($line) && !empty($showBlockExtrafields)) {
605
+					if (TSubtotal::isTitle($line) && !empty($showBlockExtrafields)) {
606 606
 						$extrafieldsline = new ExtraFields($db);
607 607
 						$extralabelsline = $extrafieldsline->fetch_name_optionals_label($object->table_element_line);
608 608
 						$extrafieldsline->setOptionalsFromPost($extralabelsline, $line);
@@ -621,43 +621,43 @@  discard block
 block discarded – undo
621 621
 				exit; // Surtout ne pas laisser Dolibarr faire du traitement sur le updateligne sinon ça plante les données de la ligne
622 622
 			}
623 623
 		}
624
-		else if($action === 'builddoc') {
624
+		else if ($action === 'builddoc') {
625 625
 
626 626
 			if (
627
-				in_array('invoicecard',explode(':',$parameters['context']))
628
-				|| in_array('propalcard',explode(':',$parameters['context']))
629
-				|| in_array('ordercard',explode(':',$parameters['context']))
630
-			    || in_array('ordersuppliercard',explode(':',$parameters['context']))
631
-			    || in_array('invoicesuppliercard',explode(':',$parameters['context']))
632
-			    || in_array('supplier_proposalcard',explode(':',$parameters['context']))
627
+				in_array('invoicecard', explode(':', $parameters['context']))
628
+				|| in_array('propalcard', explode(':', $parameters['context']))
629
+				|| in_array('ordercard', explode(':', $parameters['context']))
630
+			    || in_array('ordersuppliercard', explode(':', $parameters['context']))
631
+			    || in_array('invoicesuppliercard', explode(':', $parameters['context']))
632
+			    || in_array('supplier_proposalcard', explode(':', $parameters['context']))
633 633
 			)
634 634
 	        {
635
-				if(in_array('invoicecard',explode(':',$parameters['context']))) {
635
+				if (in_array('invoicecard', explode(':', $parameters['context']))) {
636 636
 					$sessname = 'subtotal_hideInnerLines_facture';
637 637
 					$sessname2 = 'subtotal_hidedetails_facture';
638 638
 					$sessname3 = 'subtotal_hideprices_facture';
639 639
 				}
640
-				elseif(in_array('invoicesuppliercard',explode(':',$parameters['context']))) {
640
+				elseif (in_array('invoicesuppliercard', explode(':', $parameters['context']))) {
641 641
 				    $sessname = 'subtotal_hideInnerLines_facture_fournisseur';
642 642
 				    $sessname2 = 'subtotal_hidedetails_facture_fournisseur';
643 643
 				    $sessname3 = 'subtotal_hideprices_facture_fournisseur';
644 644
 				}
645
-				elseif(in_array('propalcard',explode(':',$parameters['context']))) {
645
+				elseif (in_array('propalcard', explode(':', $parameters['context']))) {
646 646
 					$sessname = 'subtotal_hideInnerLines_propal';
647 647
 					$sessname2 = 'subtotal_hidedetails_propal';
648 648
 					$sessname3 = 'subtotal_hideprices_propal';
649 649
 				}
650
-				elseif(in_array('supplier_proposalcard',explode(':',$parameters['context']))) {
650
+				elseif (in_array('supplier_proposalcard', explode(':', $parameters['context']))) {
651 651
 				    $sessname = 'subtotal_hideInnerLines_supplier_proposal';
652 652
 				    $sessname2 = 'subtotal_hidedetails_supplier_proposal';
653 653
 				    $sessname3 = 'subtotal_hideprices_supplier_proposal';
654 654
 				}
655
-				elseif(in_array('ordercard',explode(':',$parameters['context']))) {
655
+				elseif (in_array('ordercard', explode(':', $parameters['context']))) {
656 656
 					$sessname = 'subtotal_hideInnerLines_commande';
657 657
 					$sessname2 = 'subtotal_hidedetails_commande';
658 658
 					$sessname3 = 'subtotal_hideprices_commande';
659 659
 				}
660
-				elseif(in_array('ordersuppliercard',explode(':',$parameters['context']))) {
660
+				elseif (in_array('ordersuppliercard', explode(':', $parameters['context']))) {
661 661
 				    $sessname = 'subtotal_hideInnerLines_commande_fournisseur';
662 662
 				    $sessname2 = 'subtotal_hidedetails_commande_fournisseur';
663 663
 				    $sessname3 = 'subtotal_hideprices_commande_fournisseur';
@@ -671,24 +671,24 @@  discard block
 block discarded – undo
671 671
 				global $hideprices;
672 672
 
673 673
 				$hideInnerLines = GETPOST('hideInnerLines', 'int');
674
-				if(empty($_SESSION[$sessname]) || !is_array($_SESSION[$sessname][$object->id]) ) $_SESSION[$sessname] = array(); // prevent old system
674
+				if (empty($_SESSION[$sessname]) || !is_array($_SESSION[$sessname][$object->id])) $_SESSION[$sessname] = array(); // prevent old system
675 675
 				$_SESSION[$sessname][$object->id] = $hideInnerLines;
676 676
 
677
-				$hidedetails= GETPOST('hidedetails', 'int');
678
-				if(empty($_SESSION[$sessname2]) || !is_array($_SESSION[$sessname2][$object->id]) ) $_SESSION[$sessname2] = array(); // prevent old system
677
+				$hidedetails = GETPOST('hidedetails', 'int');
678
+				if (empty($_SESSION[$sessname2]) || !is_array($_SESSION[$sessname2][$object->id])) $_SESSION[$sessname2] = array(); // prevent old system
679 679
 				$_SESSION[$sessname2][$object->id] = $hidedetails;
680 680
 
681
-				$hideprices= GETPOST('hideprices', 'int');
682
-				if(empty($_SESSION[$sessname3]) || !is_array($_SESSION[$sessname3][$object->id]) ) $_SESSION[$sessname3] = array(); // prevent old system
681
+				$hideprices = GETPOST('hideprices', 'int');
682
+				if (empty($_SESSION[$sessname3]) || !is_array($_SESSION[$sessname3][$object->id])) $_SESSION[$sessname3] = array(); // prevent old system
683 683
 				$_SESSION[$sessname3][$object->id] = $hideprices;
684 684
 
685
-				foreach($object->lines as &$line) {
685
+				foreach ($object->lines as &$line) {
686 686
 					if ($line->product_type == 9 && $line->special_code == $this->module_number) {
687 687
 
688
-                        if($line->qty>=90) {
688
+                        if ($line->qty >= 90) {
689 689
                             $line->modsubtotal_total = 1;
690 690
                         }
691
-                        else{
691
+                        else {
692 692
                             $line->modsubtotal_title = 1;
693 693
                         }
694 694
 
@@ -698,36 +698,36 @@  discard block
 block discarded – undo
698 698
 	        }
699 699
 
700 700
 		}
701
-		else if($action === 'confirm_delete_all_lines' && GETPOST('confirm', 'none')=='yes') {
701
+		else if ($action === 'confirm_delete_all_lines' && GETPOST('confirm', 'none') == 'yes') {
702 702
 
703 703
 			$Tab = TSubtotal::getLinesFromTitleId($object, GETPOST('lineid', 'int'), true);
704
-			foreach($Tab as $line) {
704
+			foreach ($Tab as $line) {
705 705
                 $result = 0;
706 706
 
707 707
 				$idLine = $line->id;
708 708
 				/**
709 709
 				 * @var $object Facture
710 710
 				 */
711
-				if($object->element=='facture') $result = $object->deleteline($idLine);
711
+				if ($object->element == 'facture') $result = $object->deleteline($idLine);
712 712
 				/**
713 713
 				 * @var $object Facture fournisseur
714 714
 				 */
715
-				else if($object->element=='invoice_supplier')
715
+				else if ($object->element == 'invoice_supplier')
716 716
 				{
717 717
 					$result = $object->deleteline($idLine);
718 718
 				}
719 719
 				/**
720 720
 				 * @var $object Propal
721 721
 				 */
722
-				else if($object->element=='propal') $result = $object->deleteline($idLine);
722
+				else if ($object->element == 'propal') $result = $object->deleteline($idLine);
723 723
 				/**
724 724
 				 * @var $object Propal Fournisseur
725 725
 				 */
726
-				else if($object->element=='supplier_proposal') $result = $object->deleteline($idLine);
726
+				else if ($object->element == 'supplier_proposal') $result = $object->deleteline($idLine);
727 727
 				/**
728 728
 				 * @var $object Commande
729 729
 				 */
730
-				else if($object->element=='commande')
730
+				else if ($object->element == 'commande')
731 731
 				{
732 732
 					if ((float) DOL_VERSION >= 5.0) $result = $object->deleteline($user, $idLine);
733 733
 					else $result = $object->deleteline($idLine);
@@ -735,18 +735,18 @@  discard block
 block discarded – undo
735 735
 				/**
736 736
 				 * @var $object Commande fournisseur
737 737
 				 */
738
-				else if($object->element=='order_supplier')
738
+				else if ($object->element == 'order_supplier')
739 739
 				{
740 740
                     			$result = $object->deleteline($idLine);
741 741
 				}
742 742
 				/**
743 743
 				 * @var $object Facturerec
744 744
 				 */
745
-				else if($object->element=='facturerec') $result = $object->deleteline($idLine);
745
+				else if ($object->element == 'facturerec') $result = $object->deleteline($idLine);
746 746
 				/**
747 747
 				 * @var $object Expedition
748 748
 				 */
749
-				else if($object->element=='shipping') $result = $object->deleteline($user, $idLine);
749
+				else if ($object->element == 'shipping') $result = $object->deleteline($user, $idLine);
750 750
 
751 751
                 if ($result < 0) $error++;
752 752
 			}
@@ -778,7 +778,7 @@  discard block
 block discarded – undo
778 778
 		return 0;
779 779
 	}
780 780
 
781
-	function formAddObjectLine ($parameters, &$object, &$action, $hookmanager) {
781
+	function formAddObjectLine($parameters, &$object, &$action, $hookmanager) {
782 782
 		return 0;
783 783
 	}
784 784
 
@@ -796,8 +796,8 @@  discard block
 block discarded – undo
796 796
 			if (!empty($parameters['fk_element']))
797 797
 			{
798 798
 
799
-				if($obj->fetch($parameters['fk_element'])){
800
-					$obj->id= $obj->rowid;
799
+				if ($obj->fetch($parameters['fk_element'])) {
800
+					$obj->id = $obj->rowid;
801 801
 					if (empty($obj->array_options))
802 802
 						$obj->fetch_optionals();
803 803
 					if (!empty($obj->array_options['options_subtotal_nc']))
@@ -813,18 +813,18 @@  discard block
 block discarded – undo
813 813
 		$qty_line = 0;
814 814
         $qty_end_line = 0;
815 815
 		$found = false;
816
-		$Tab= array();
816
+		$Tab = array();
817 817
 
818
-		foreach($object->lines as $l) {
818
+		foreach ($object->lines as $l) {
819 819
 		    $lid = (!empty($l->rowid) ? $l->rowid : $l->id);
820 820
 
821
-			if($lid == $lineid && $l->qty > 0 && $l->qty < 10) {
821
+			if ($lid == $lineid && $l->qty > 0 && $l->qty < 10) {
822 822
 				$found = true;
823 823
 				$qty_line = $l->qty;
824 824
                 $qty_end_line = 100 - $qty_line;
825 825
 			}
826 826
 
827
-			if($found) {
827
+			if ($found) {
828 828
                 if ($l->special_code == $this->module_number && $lid != $lineid && ($l->qty <= $qty_line || $l->qty >= $qty_end_line)) {
829 829
                     if ($l->qty == $qty_end_line) $Tab[] = $lid;
830 830
                     break;
@@ -836,7 +836,7 @@  discard block
 block discarded – undo
836 836
 		return $Tab;
837 837
 	}
838 838
 
839
-	function getTotalLineFromObject(&$object, &$line, $use_level=false, $return_all=0) {
839
+	function getTotalLineFromObject(&$object, &$line, $use_level = false, $return_all = 0) {
840 840
 		global $conf;
841 841
 
842 842
 		$rang = $line->rang;
@@ -852,8 +852,8 @@  discard block
 block discarded – undo
852 852
 		$TTotal_tva = array();
853 853
 
854 854
 
855
-		$sign=1;
856
-		if (isset($object->type) && $object->type == 2 && ! empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) $sign=-1;
855
+		$sign = 1;
856
+		if (isset($object->type) && $object->type == 2 && !empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) $sign = -1;
857 857
 
858 858
 		if (GETPOST('action', 'none') == 'builddoc') $builddoc = true;
859 859
 		else $builddoc = false;
@@ -862,18 +862,18 @@  discard block
 block discarded – undo
862 862
 
863 863
 		$TLineReverse = array_reverse($object->lines);
864 864
 
865
-		foreach($TLineReverse as $l)
865
+		foreach ($TLineReverse as $l)
866 866
 		{
867 867
 			$l->total_ttc = doubleval($l->total_ttc);
868 868
 			$l->total_ht = doubleval($l->total_ht);
869 869
 
870 870
 			//print $l->rang.'>='.$rang.' '.$total.'<br/>';
871
-            if ($l->rang>=$rang) continue;
871
+            if ($l->rang >= $rang) continue;
872 872
             if (!empty($title_break) && $title_break->id == $l->id) break;
873 873
             elseif (!TSubtotal::isModSubtotalLine($l))
874 874
             {
875 875
                 // TODO retirer le test avec $builddoc quand Dolibarr affichera le total progression sur la card et pas seulement dans le PDF
876
-                if ($builddoc && $object->element == 'facture' && $object->type==Facture::TYPE_SITUATION)
876
+                if ($builddoc && $object->element == 'facture' && $object->type == Facture::TYPE_SITUATION)
877 877
                 {
878 878
                     if ($l->situation_percent > 0 && !empty($l->total_ht))
879 879
                     {
@@ -886,7 +886,7 @@  discard block
 block discarded – undo
886 886
                         }
887 887
 
888 888
                         $result = $sign * ($l->total_ht / ($l->situation_percent / 100)) * $progress;
889
-                        $total+= $result;
889
+                        $total += $result;
890 890
                         // TODO check si les 3 lignes du dessous sont corrects
891 891
                         $total_tva += $sign * ($l->total_tva / ($l->situation_percent / 100)) * $progress;
892 892
                         $TTotal_tva[$l->tva_tx] += $sign * ($l->total_tva / ($l->situation_percent / 100)) * $progress;
@@ -918,8 +918,8 @@  discard block
 block discarded – undo
918 918
 	 * @param $w            float               width
919 919
 	 * @param $h            float               height
920 920
 	 */
921
-	function pdf_add_total(&$pdf,&$object, &$line, $label, $description,$posx, $posy, $w, $h) {
922
-		global $conf,$subtotal_last_title_posy,$langs;
921
+	function pdf_add_total(&$pdf, &$object, &$line, $label, $description, $posx, $posy, $w, $h) {
922
+		global $conf, $subtotal_last_title_posy, $langs;
923 923
 
924 924
 		$hideInnerLines = GETPOST('hideInnerLines', 'int');
925 925
 		if (!empty($conf->global->SUBTOTAL_ONE_LINE_IF_HIDE_INNERLINES) && $hideInnerLines && !empty($subtotal_last_title_posy))
@@ -930,62 +930,62 @@  discard block
 block discarded – undo
930 930
 
931 931
 		$hidePriceOnSubtotalLines = GETPOST('hide_price_on_subtotal_lines', 'int');
932 932
 
933
-		if($object->element == 'shipping' || $object->element == 'delivery')
933
+		if ($object->element == 'shipping' || $object->element == 'delivery')
934 934
 		{
935 935
 			$hidePriceOnSubtotalLines = 1;
936 936
 		}
937 937
 
938 938
 		$set_pagebreak_margin = false;
939
-		if(method_exists('Closure','bind')) {
939
+		if (method_exists('Closure', 'bind')) {
940 940
 			$pageBreakOriginalValue = $pdf->AcceptPageBreak();
941
-			$sweetsThief = function ($pdf) {
942
-		    		return $pdf->bMargin ;
941
+			$sweetsThief = function($pdf) {
942
+		    		return $pdf->bMargin;
943 943
 			};
944 944
 			$sweetsThief = Closure::bind($sweetsThief, null, $pdf);
945 945
 
946
-			$bMargin  = $sweetsThief($pdf);
946
+			$bMargin = $sweetsThief($pdf);
947 947
 
948
-			$pdf->SetAutoPageBreak( false );
948
+			$pdf->SetAutoPageBreak(false);
949 949
 
950 950
 			$set_pagebreak_margin = true;
951 951
 		}
952 952
 
953 953
 
954
-		if($line->qty==99)
955
-			$pdf->SetFillColor(220,220,220);
956
-		elseif ($line->qty==98)
957
-			$pdf->SetFillColor(230,230,230);
954
+		if ($line->qty == 99)
955
+			$pdf->SetFillColor(220, 220, 220);
956
+		elseif ($line->qty == 98)
957
+			$pdf->SetFillColor(230, 230, 230);
958 958
 		else
959
-			$pdf->SetFillColor(240,240,240);
959
+			$pdf->SetFillColor(240, 240, 240);
960 960
 
961 961
 		$style = 'B';
962 962
 		if (!empty($conf->global->SUBTOTAL_SUBTOTAL_STYLE)) $style = $conf->global->SUBTOTAL_SUBTOTAL_STYLE;
963 963
 
964 964
 		$pdf->SetFont('', $style, 9);
965 965
 
966
-		$pdf->writeHTMLCell($w, $h, $posx, $posy, $label, 0, 1, false, true, 'R',true);
966
+		$pdf->writeHTMLCell($w, $h, $posx, $posy, $label, 0, 1, false, true, 'R', true);
967 967
 //		var_dump($bMargin);
968 968
 		$pageAfter = $pdf->getPage();
969 969
 
970 970
 		//Print background
971 971
 		$cell_height = $pdf->getStringHeight($w, $label);
972 972
 
973
-		if(!empty($object->subtotalPdfModelInfo->cols)){
974
-			include_once __DIR__ . '/staticPdf.model.php';
973
+		if (!empty($object->subtotalPdfModelInfo->cols)) {
974
+			include_once __DIR__.'/staticPdf.model.php';
975 975
 			$staticPdfModel = new ModelePDFStatic($object->db);
976 976
 			$staticPdfModel->marge_droite 	= $object->subtotalPdfModelInfo->marge_droite;
977 977
 			$staticPdfModel->marge_gauche 	= $object->subtotalPdfModelInfo->marge_gauche;
978 978
 			$staticPdfModel->page_largeur 	= $object->subtotalPdfModelInfo->page_largeur;
979 979
 			$staticPdfModel->page_hauteur 	= $object->subtotalPdfModelInfo->page_hauteur;
980
-			$staticPdfModel->cols 			= $object->subtotalPdfModelInfo->cols;
981
-			$staticPdfModel->defaultTitlesFieldsStyle 	= $object->subtotalPdfModelInfo->defaultTitlesFieldsStyle;
980
+			$staticPdfModel->cols = $object->subtotalPdfModelInfo->cols;
981
+			$staticPdfModel->defaultTitlesFieldsStyle = $object->subtotalPdfModelInfo->defaultTitlesFieldsStyle;
982 982
 			$staticPdfModel->defaultContentsFieldsStyle = $object->subtotalPdfModelInfo->defaultContentsFieldsStyle;
983 983
 			$staticPdfModel->prepareArrayColumnField($object, $langs);
984 984
 
985 985
 			$pdf->SetXY($object->subtotalPdfModelInfo->marge_droite, $posy);
986 986
 			$pdf->MultiCell($object->subtotalPdfModelInfo->page_largeur - $object->subtotalPdfModelInfo->marge_gauche - $object->subtotalPdfModelInfo->marge_droite, $cell_height, '', 0, '', 1);
987 987
 		}
988
-		else{
988
+		else {
989 989
 			$pdf->SetXY($posx, $posy);
990 990
 			$pdf->MultiCell($pdf->page_largeur - $pdf->marge_droite, $cell_height, '', 0, '', 1);
991 991
 		}
@@ -1006,7 +1006,7 @@  discard block
 block discarded – undo
1006 1006
 				}
1007 1007
 			}
1008 1008
 
1009
-			if($total_to_print !== '') {
1009
+			if ($total_to_print !== '') {
1010 1010
 
1011 1011
 				if (GETPOST('hideInnerLines', 'int'))
1012 1012
 				{
@@ -1033,17 +1033,17 @@  discard block
 block discarded – undo
1033 1033
 			}
1034 1034
 
1035 1035
 			$pdf->SetXY($pdf->postotalht, $posy);
1036
-			if($set_pagebreak_margin) $pdf->SetAutoPageBreak( $pageBreakOriginalValue , $bMargin);
1036
+			if ($set_pagebreak_margin) $pdf->SetAutoPageBreak($pageBreakOriginalValue, $bMargin);
1037 1037
 
1038
-			if(!empty($object->subtotalPdfModelInfo->cols)){
1038
+			if (!empty($object->subtotalPdfModelInfo->cols)) {
1039 1039
 				$staticPdfModel->printStdColumnContent($pdf, $posy, 'totalexcltax', $total_to_print);
1040 1040
 			}
1041
-			else{
1042
-				$pdf->MultiCell($pdf->page_largeur-$pdf->marge_droite-$pdf->postotalht, 3, $total_to_print, 0, 'R', 0);
1041
+			else {
1042
+				$pdf->MultiCell($pdf->page_largeur - $pdf->marge_droite - $pdf->postotalht, 3, $total_to_print, 0, 'R', 0);
1043 1043
 			}
1044 1044
 		}
1045
-		else{
1046
-			if($set_pagebreak_margin) $pdf->SetAutoPageBreak( $pageBreakOriginalValue , $bMargin);
1045
+		else {
1046
+			if ($set_pagebreak_margin) $pdf->SetAutoPageBreak($pageBreakOriginalValue, $bMargin);
1047 1047
 		}
1048 1048
 
1049 1049
 		$posy = $posy + $cell_height;
@@ -1063,22 +1063,22 @@  discard block
 block discarded – undo
1063 1063
 	 * @param $w            float               width
1064 1064
 	 * @param $h            float               height
1065 1065
 	 */
1066
-	function pdf_add_title(&$pdf,&$object, &$line, $label, $description,$posx, $posy, $w, $h) {
1066
+	function pdf_add_title(&$pdf, &$object, &$line, $label, $description, $posx, $posy, $w, $h) {
1067 1067
 
1068
-		global $db,$conf,$subtotal_last_title_posy;
1068
+		global $db, $conf, $subtotal_last_title_posy;
1069 1069
 
1070 1070
 		$subtotal_last_title_posy = $posy;
1071
-		$pdf->SetXY ($posx, $posy);
1071
+		$pdf->SetXY($posx, $posy);
1072 1072
 
1073 1073
 		$hideInnerLines = GETPOST('hideInnerLines', 'int');
1074 1074
 
1075 1075
 
1076 1076
 
1077
-		$style = ($line->qty==1) ? 'BU' : 'BUI';
1077
+		$style = ($line->qty == 1) ? 'BU' : 'BUI';
1078 1078
 		if (!empty($conf->global->SUBTOTAL_TITLE_STYLE)) $style = $conf->global->SUBTOTAL_TITLE_STYLE;
1079 1079
 
1080
-		if($hideInnerLines) {
1081
-			if($line->qty==1)$pdf->SetFont('', $style, 9);
1080
+		if ($hideInnerLines) {
1081
+			if ($line->qty == 1)$pdf->SetFont('', $style, 9);
1082 1082
 			else
1083 1083
 			{
1084 1084
 				if (!empty($conf->global->SUBTOTAL_STYLE_TITRES_SI_LIGNES_CACHEES)) $style = $conf->global->SUBTOTAL_STYLE_TITRES_SI_LIGNES_CACHEES;
@@ -1087,44 +1087,44 @@  discard block
 block discarded – undo
1087 1087
 		}
1088 1088
 		else {
1089 1089
 
1090
-			if($line->qty==1)$pdf->SetFont('', $style, 9); //TODO if super utile
1090
+			if ($line->qty == 1)$pdf->SetFont('', $style, 9); //TODO if super utile
1091 1091
 			else $pdf->SetFont('', $style, 9);
1092 1092
 
1093 1093
 		}
1094 1094
 
1095 1095
 		if ($label === strip_tags($label) && $label === dol_html_entity_decode($label, ENT_QUOTES)) $pdf->MultiCell($w, $h, $label, 0, 'L'); // Pas de HTML dans la chaine
1096
-		else $pdf->writeHTMLCell($w, $h, $posx, $posy, $label, 0, 1, false, true, 'J',true); // et maintenant avec du HTML
1096
+		else $pdf->writeHTMLCell($w, $h, $posx, $posy, $label, 0, 1, false, true, 'J', true); // et maintenant avec du HTML
1097 1097
 
1098
-		if($description && !$hidedesc) {
1098
+		if ($description && !$hidedesc) {
1099 1099
 			$posy = $pdf->GetY();
1100 1100
 
1101 1101
 			$pdf->SetFont('', '', 8);
1102 1102
 
1103
-			$pdf->writeHTMLCell($w, $h, $posx, $posy, $description, 0, 1, false, true, 'J',true);
1103
+			$pdf->writeHTMLCell($w, $h, $posx, $posy, $description, 0, 1, false, true, 'J', true);
1104 1104
 
1105 1105
 		}
1106 1106
 
1107 1107
 	}
1108 1108
 
1109
-	function pdf_writelinedesc_ref($parameters=array(), &$object, &$action='') {
1109
+	function pdf_writelinedesc_ref($parameters = array(), &$object, &$action = '') {
1110 1110
 	// ultimate PDF hook O_o
1111 1111
 
1112
-		return $this->pdf_writelinedesc($parameters,$object,$action);
1112
+		return $this->pdf_writelinedesc($parameters, $object, $action);
1113 1113
 
1114 1114
 	}
1115 1115
 
1116 1116
 	function isModSubtotalLine(&$parameters, &$object) {
1117 1117
 
1118
-		if(is_array($parameters)) {
1118
+		if (is_array($parameters)) {
1119 1119
 			$i = & $parameters['i'];
1120 1120
 		}
1121 1121
 		else {
1122
-			$i = (int)$parameters;
1122
+			$i = (int) $parameters;
1123 1123
 		}
1124 1124
 
1125 1125
 		$line = $object->lines[$i];
1126 1126
 
1127
-		if($object->element == 'shipping' || $object->element == 'delivery')
1127
+		if ($object->element == 'shipping' || $object->element == 'delivery')
1128 1128
 		{
1129 1129
 			dol_include_once('/commande/class/commande.class.php');
1130 1130
 			$line = new OrderLine($object->db);
@@ -1132,7 +1132,7 @@  discard block
 block discarded – undo
1132 1132
 		}
1133 1133
 
1134 1134
 
1135
-		if($line->special_code == $this->module_number && $line->product_type == 9) {
1135
+		if ($line->special_code == $this->module_number && $line->product_type == 9) {
1136 1136
 			return true;
1137 1137
 		}
1138 1138
 
@@ -1140,21 +1140,21 @@  discard block
 block discarded – undo
1140 1140
 
1141 1141
 	}
1142 1142
 
1143
-	function pdf_getlineqty($parameters=array(), &$object, &$action='') {
1144
-		global $conf,$hideprices;
1143
+	function pdf_getlineqty($parameters = array(), &$object, &$action = '') {
1144
+		global $conf, $hideprices;
1145 1145
 
1146
-		if($this->isModSubtotalLine($parameters,$object) ){
1146
+		if ($this->isModSubtotalLine($parameters, $object)) {
1147 1147
 			$this->resprints = ' ';
1148 1148
 
1149
-			if((float)DOL_VERSION<=3.6) {
1149
+			if ((float) DOL_VERSION <= 3.6) {
1150 1150
 				return '';
1151 1151
 			}
1152
-			else if((float)DOL_VERSION>=3.8) {
1152
+			else if ((float) DOL_VERSION >= 3.8) {
1153 1153
 				return 1;
1154 1154
 			}
1155 1155
 
1156 1156
 		}
1157
-		elseif(!empty($hideprices)) {
1157
+		elseif (!empty($hideprices)) {
1158 1158
 			$this->resprints = $object->lines[$parameters['i']]->qty;
1159 1159
 			return 1;
1160 1160
 		}
@@ -1168,15 +1168,15 @@  discard block
 block discarded – undo
1168 1168
 			}
1169 1169
 		}
1170 1170
 
1171
-		if(is_array($parameters)) $i = & $parameters['i'];
1172
-		else $i = (int)$parameters;
1171
+		if (is_array($parameters)) $i = & $parameters['i'];
1172
+		else $i = (int) $parameters;
1173 1173
 
1174 1174
 		/** Attention, ici on peut ce retrouver avec un objet de type stdClass à cause de l'option cacher le détail des ensembles avec la notion de Non Compris (@see beforePDFCreation()) et dû à l'appel de TSubtotal::hasNcTitle() */
1175 1175
 		if (empty($object->lines[$i]->id)) return 0; // hideInnerLines => override $object->lines et Dolibarr ne nous permet pas de mettre à jour la variable qui conditionne la boucle sur les lignes (PR faite pour 6.0)
1176 1176
 
1177
-		if(empty($object->lines[$i]->array_options)) $object->lines[$i]->fetch_optionals();
1177
+		if (empty($object->lines[$i]->array_options)) $object->lines[$i]->fetch_optionals();
1178 1178
 
1179
-		if (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])) )
1179
+		if (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])))
1180 1180
 		{
1181 1181
 			if (!in_array(__FUNCTION__, explode(',', $conf->global->SUBTOTAL_TFIELD_TO_KEEP_WITH_NC)))
1182 1182
 			{
@@ -1188,20 +1188,20 @@  discard block
 block discarded – undo
1188 1188
 		return 0;
1189 1189
 	}
1190 1190
 
1191
-	function pdf_getlinetotalexcltax($parameters=array(), &$object, &$action='') {
1191
+	function pdf_getlinetotalexcltax($parameters = array(), &$object, &$action = '') {
1192 1192
 	    global $conf, $hideprices, $hookmanager;
1193 1193
 
1194
-		if(is_array($parameters)) $i = & $parameters['i'];
1195
-		else $i = (int)$parameters;
1194
+		if (is_array($parameters)) $i = & $parameters['i'];
1195
+		else $i = (int) $parameters;
1196 1196
 
1197
-		if($this->isModSubtotalLine($parameters,$object) ){
1197
+		if ($this->isModSubtotalLine($parameters, $object)) {
1198 1198
 
1199 1199
 			$this->resprints = ' ';
1200 1200
 
1201
-			if((float)DOL_VERSION<=3.6) {
1201
+			if ((float) DOL_VERSION <= 3.6) {
1202 1202
 				return '';
1203 1203
 			}
1204
-			else if((float)DOL_VERSION>=3.8) {
1204
+			else if ((float) DOL_VERSION >= 3.8) {
1205 1205
 				return 1;
1206 1206
 			}
1207 1207
 
@@ -1227,7 +1227,7 @@  discard block
 block discarded – undo
1227 1227
 				}
1228 1228
 			}
1229 1229
 		}
1230
-		if (GETPOST('hideInnerLines', 'int') && !empty($conf->global->SUBTOTAL_REPLACE_WITH_VAT_IF_HIDE_INNERLINES)){
1230
+		if (GETPOST('hideInnerLines', 'int') && !empty($conf->global->SUBTOTAL_REPLACE_WITH_VAT_IF_HIDE_INNERLINES)) {
1231 1231
 		    $this->resprints = price($object->lines[$i]->total_ht);
1232 1232
 		}
1233 1233
 
@@ -1272,7 +1272,7 @@  discard block
 block discarded – undo
1272 1272
 	 */
1273 1273
 	private function callHook(&$object, &$hookmanager, $action, $params, $defaultReturn = 1)
1274 1274
 	{
1275
-		$reshook=$hookmanager->executeHooks('subtotalHidePrices',$params, $object, $action);
1275
+		$reshook = $hookmanager->executeHooks('subtotalHidePrices', $params, $object, $action);
1276 1276
 		if ($reshook < 0)
1277 1277
 		{
1278 1278
 			$this->error = $hookmanager->error;
@@ -1288,7 +1288,7 @@  discard block
 block discarded – undo
1288 1288
 			$this->resprints = $hookmanager->resprints;
1289 1289
 
1290 1290
 			// override return (use  $this->results['overrideReturn'] or $this->resArray['overrideReturn'] in other module action_xxxx.class.php )
1291
-			if(isset($hookmanager->resArray['overrideReturn']))
1291
+			if (isset($hookmanager->resArray['overrideReturn']))
1292 1292
 			{
1293 1293
 				return $hookmanager->resArray['overrideReturn'];
1294 1294
 			}
@@ -1297,25 +1297,25 @@  discard block
 block discarded – undo
1297 1297
 		return $defaultReturn;
1298 1298
 	}
1299 1299
 
1300
-	function pdf_getlinetotalwithtax($parameters=array(), &$object, &$action='') {
1300
+	function pdf_getlinetotalwithtax($parameters = array(), &$object, &$action = '') {
1301 1301
 		global $conf;
1302 1302
 
1303
-		if($this->isModSubtotalLine($parameters,$object) ){
1303
+		if ($this->isModSubtotalLine($parameters, $object)) {
1304 1304
 
1305 1305
 			$this->resprints = ' ';
1306 1306
 
1307
-			if((float)DOL_VERSION<=3.6) {
1307
+			if ((float) DOL_VERSION <= 3.6) {
1308 1308
 				return '';
1309 1309
 			}
1310
-			else if((float)DOL_VERSION>=3.8) {
1310
+			else if ((float) DOL_VERSION >= 3.8) {
1311 1311
 				return 1;
1312 1312
 			}
1313 1313
 		}
1314 1314
 
1315
-		if(is_array($parameters)) $i = & $parameters['i'];
1316
-		else $i = (int)$parameters;
1315
+		if (is_array($parameters)) $i = & $parameters['i'];
1316
+		else $i = (int) $parameters;
1317 1317
 
1318
-		if (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])) )
1318
+		if (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])))
1319 1319
 		{
1320 1320
 			if (!in_array(__FUNCTION__, explode(',', $conf->global->SUBTOTAL_TFIELD_TO_KEEP_WITH_NC)))
1321 1321
 			{
@@ -1327,24 +1327,24 @@  discard block
 block discarded – undo
1327 1327
 		return 0;
1328 1328
 	}
1329 1329
 
1330
-	function pdf_getlineunit($parameters=array(), &$object, &$action='') {
1330
+	function pdf_getlineunit($parameters = array(), &$object, &$action = '') {
1331 1331
 		global $conf;
1332 1332
 
1333
-		if($this->isModSubtotalLine($parameters,$object) ){
1333
+		if ($this->isModSubtotalLine($parameters, $object)) {
1334 1334
 			$this->resprints = ' ';
1335 1335
 
1336
-			if((float)DOL_VERSION<=3.6) {
1336
+			if ((float) DOL_VERSION <= 3.6) {
1337 1337
 				return '';
1338 1338
 			}
1339
-			else if((float)DOL_VERSION>=3.8) {
1339
+			else if ((float) DOL_VERSION >= 3.8) {
1340 1340
 				return 1;
1341 1341
 			}
1342 1342
 		}
1343 1343
 
1344
-		if(is_array($parameters)) $i = & $parameters['i'];
1345
-		else $i = (int)$parameters;
1344
+		if (is_array($parameters)) $i = & $parameters['i'];
1345
+		else $i = (int) $parameters;
1346 1346
 
1347
-		if (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])) )
1347
+		if (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])))
1348 1348
 		{
1349 1349
 			if (!in_array(__FUNCTION__, explode(',', $conf->global->SUBTOTAL_TFIELD_TO_KEEP_WITH_NC)))
1350 1350
 			{
@@ -1356,32 +1356,32 @@  discard block
 block discarded – undo
1356 1356
 		return 0;
1357 1357
 	}
1358 1358
 
1359
-	function pdf_getlineupexcltax($parameters=array(), &$object, &$action='') {
1360
-	    global $conf,$hideprices,$hookmanager;
1359
+	function pdf_getlineupexcltax($parameters = array(), &$object, &$action = '') {
1360
+	    global $conf, $hideprices, $hookmanager;
1361 1361
 
1362
-		if(is_array($parameters)) $i = & $parameters['i'];
1363
-		else $i = (int)$parameters;
1362
+		if (is_array($parameters)) $i = & $parameters['i'];
1363
+		else $i = (int) $parameters;
1364 1364
 
1365
-		if($this->isModSubtotalLine($parameters,$object) ) {
1365
+		if ($this->isModSubtotalLine($parameters, $object)) {
1366 1366
 			$this->resprints = ' ';
1367 1367
 
1368 1368
             $line = $object->lines[$i];
1369 1369
 
1370 1370
             // On récupère les montants du bloc pour les afficher dans la ligne de sous-total
1371
-            if(TSubtotal::isSubtotal($line)) {
1371
+            if (TSubtotal::isSubtotal($line)) {
1372 1372
                 $parentTitle = TSubtotal::getParentTitleOfLine($object, $line->rang);
1373 1373
 
1374
-                if(is_object($parentTitle) && empty($parentTitle->array_options)) $parentTitle->fetch_optionals();
1375
-                if(! empty($parentTitle->array_options['options_show_total_ht'])) {
1374
+                if (is_object($parentTitle) && empty($parentTitle->array_options)) $parentTitle->fetch_optionals();
1375
+                if (!empty($parentTitle->array_options['options_show_total_ht'])) {
1376 1376
                     $TTotal = TSubtotal::getTotalBlockFromTitle($object, $parentTitle);
1377 1377
                     $this->resprints = price($TTotal['total_unit_subprice']);
1378 1378
                 }
1379 1379
             }
1380 1380
 
1381
-			if((float)DOL_VERSION<=3.6) {
1381
+			if ((float) DOL_VERSION <= 3.6) {
1382 1382
 				return '';
1383 1383
 			}
1384
-			else if((float)DOL_VERSION>=3.8) {
1384
+			else if ((float) DOL_VERSION >= 3.8) {
1385 1385
 				return 1;
1386 1386
 			}
1387 1387
 		}
@@ -1423,37 +1423,37 @@  discard block
 block discarded – undo
1423 1423
 		return 0;
1424 1424
 	}
1425 1425
 
1426
-	function pdf_getlineremisepercent($parameters=array(), &$object, &$action='') {
1427
-	    global $conf,$hideprices,$hookmanager;
1426
+	function pdf_getlineremisepercent($parameters = array(), &$object, &$action = '') {
1427
+	    global $conf, $hideprices, $hookmanager;
1428 1428
 
1429
-        if(is_array($parameters)) $i = & $parameters['i'];
1429
+        if (is_array($parameters)) $i = & $parameters['i'];
1430 1430
         else $i = (int) $parameters;
1431 1431
 
1432
-		if($this->isModSubtotalLine($parameters,$object) ) {
1432
+		if ($this->isModSubtotalLine($parameters, $object)) {
1433 1433
 			$this->resprints = ' ';
1434 1434
 
1435 1435
             $line = $object->lines[$i];
1436 1436
 
1437 1437
             // Affichage de la remise
1438
-            if(TSubtotal::isSubtotal($line)) {
1438
+            if (TSubtotal::isSubtotal($line)) {
1439 1439
                 $parentTitle = TSubtotal::getParentTitleOfLine($object, $line->rang);
1440 1440
 
1441
-                if(empty($parentTitle->array_options)) $parentTitle->fetch_optionals();
1442
-                if(! empty($parentTitle->array_options['options_show_reduc'])) {
1441
+                if (empty($parentTitle->array_options)) $parentTitle->fetch_optionals();
1442
+                if (!empty($parentTitle->array_options['options_show_reduc'])) {
1443 1443
                     $TTotal = TSubtotal::getTotalBlockFromTitle($object, $parentTitle);
1444
-                    $this->resprints = price((1-$TTotal['total_ht'] / $TTotal['total_subprice'])*100, 0, '', 1, 2, 2).'%';
1444
+                    $this->resprints = price((1 - $TTotal['total_ht'] / $TTotal['total_subprice']) * 100, 0, '', 1, 2, 2).'%';
1445 1445
                 }
1446 1446
             }
1447 1447
 
1448
-			if((float)DOL_VERSION<=3.6) {
1448
+			if ((float) DOL_VERSION <= 3.6) {
1449 1449
 				return '';
1450 1450
 			}
1451
-			else if((float)DOL_VERSION>=3.8) {
1451
+			else if ((float) DOL_VERSION >= 3.8) {
1452 1452
 				return 1;
1453 1453
 			}
1454 1454
 		}
1455 1455
 		elseif (!empty($hideprices)
1456
-		        || (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])) )
1456
+		        || (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])))
1457 1457
 		        )
1458 1458
 		    {
1459 1459
 		        if (!empty($hideprices) || !in_array(__FUNCTION__, explode(',', $conf->global->SUBTOTAL_TFIELD_TO_KEEP_WITH_NC)))
@@ -1466,24 +1466,24 @@  discard block
 block discarded – undo
1466 1466
 		return 0;
1467 1467
 	}
1468 1468
 
1469
-	function pdf_getlineupwithtax($parameters=array(), &$object, &$action='') {
1470
-		global $conf,$hideprices;
1469
+	function pdf_getlineupwithtax($parameters = array(), &$object, &$action = '') {
1470
+		global $conf, $hideprices;
1471 1471
 
1472
-		if($this->isModSubtotalLine($parameters,$object) ){
1472
+		if ($this->isModSubtotalLine($parameters, $object)) {
1473 1473
 			$this->resprints = ' ';
1474
-			if((float)DOL_VERSION<=3.6) {
1474
+			if ((float) DOL_VERSION <= 3.6) {
1475 1475
 				return '';
1476 1476
 			}
1477
-			else if((float)DOL_VERSION>=3.8) {
1477
+			else if ((float) DOL_VERSION >= 3.8) {
1478 1478
 				return 1;
1479 1479
 			}
1480 1480
 		}
1481 1481
 
1482
-		if(is_array($parameters)) $i = & $parameters['i'];
1483
-		else $i = (int)$parameters;
1482
+		if (is_array($parameters)) $i = & $parameters['i'];
1483
+		else $i = (int) $parameters;
1484 1484
 
1485 1485
 		if (!empty($hideprices)
1486
-				|| (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])) )
1486
+				|| (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])))
1487 1487
 		)
1488 1488
 		{
1489 1489
 			if (!empty($hideprices) || !in_array(__FUNCTION__, explode(',', $conf->global->SUBTOTAL_TFIELD_TO_KEEP_WITH_NC)))
@@ -1496,22 +1496,22 @@  discard block
 block discarded – undo
1496 1496
 		return 0;
1497 1497
 	}
1498 1498
 
1499
-	function pdf_getlinevatrate($parameters=array(), &$object, &$action='') {
1500
-	    global $conf,$hideprices,$hookmanager;
1499
+	function pdf_getlinevatrate($parameters = array(), &$object, &$action = '') {
1500
+	    global $conf, $hideprices, $hookmanager;
1501 1501
 
1502
-		if($this->isModSubtotalLine($parameters,$object) ){
1502
+		if ($this->isModSubtotalLine($parameters, $object)) {
1503 1503
 			$this->resprints = ' ';
1504 1504
 
1505
-			if((float)DOL_VERSION<=3.6) {
1505
+			if ((float) DOL_VERSION <= 3.6) {
1506 1506
 				return '';
1507 1507
 			}
1508
-			else if((float)DOL_VERSION>=3.8) {
1508
+			else if ((float) DOL_VERSION >= 3.8) {
1509 1509
 				return 1;
1510 1510
 			}
1511 1511
 		}
1512 1512
 
1513
-		if(is_array($parameters)) $i = & $parameters['i'];
1514
-		else $i = (int)$parameters;
1513
+		if (is_array($parameters)) $i = & $parameters['i'];
1514
+		else $i = (int) $parameters;
1515 1515
 
1516 1516
 		if (empty($object->lines[$i])) return 0; // hideInnerLines => override $object->lines et Dolibarr ne nous permet pas de mettre à jour la variable qui conditionne la boucle sur les lignes (PR faite pour 6.0)
1517 1517
 
@@ -1552,23 +1552,23 @@  discard block
 block discarded – undo
1552 1552
 		return 0;
1553 1553
 	}
1554 1554
 
1555
-	function pdf_getlineprogress($parameters=array(), &$object, &$action) {
1555
+	function pdf_getlineprogress($parameters = array(), &$object, &$action) {
1556 1556
 		global $conf;
1557 1557
 
1558
-		if($this->isModSubtotalLine($parameters,$object) ){
1558
+		if ($this->isModSubtotalLine($parameters, $object)) {
1559 1559
 			$this->resprints = ' ';
1560
-			if((float)DOL_VERSION<=3.6) {
1560
+			if ((float) DOL_VERSION <= 3.6) {
1561 1561
 				return '';
1562 1562
 			}
1563
-			else if((float)DOL_VERSION>=3.8) {
1563
+			else if ((float) DOL_VERSION >= 3.8) {
1564 1564
 				return 1;
1565 1565
 			}
1566 1566
 		}
1567 1567
 
1568
-		if(is_array($parameters)) $i = & $parameters['i'];
1569
-		else $i = (int)$parameters;
1568
+		if (is_array($parameters)) $i = & $parameters['i'];
1569
+		else $i = (int) $parameters;
1570 1570
 
1571
-		if (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])) )
1571
+		if (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])))
1572 1572
 		{
1573 1573
 			if (!in_array(__FUNCTION__, explode(',', $conf->global->SUBTOTAL_TFIELD_TO_KEEP_WITH_NC)))
1574 1574
 			{
@@ -1583,13 +1583,13 @@  discard block
 block discarded – undo
1583 1583
 	function add_numerotation(&$object) {
1584 1584
 		global $conf;
1585 1585
 
1586
-		if(!empty($conf->global->SUBTOTAL_USE_NUMEROTATION)) {
1586
+		if (!empty($conf->global->SUBTOTAL_USE_NUMEROTATION)) {
1587 1587
 
1588 1588
 			$TLineTitle = $TTitle = $TLineSubtotal = array();
1589 1589
 			$prevlevel = 0;
1590 1590
 			dol_include_once('/subtotal/class/subtotal.class.php');
1591 1591
 
1592
-			foreach($object->lines as $k=>&$line)
1592
+			foreach ($object->lines as $k=>&$line)
1593 1593
 			{
1594 1594
 				if ($line->id > 0 && $this->isModSubtotalLine($k, $object) && $line->qty <= 10)
1595 1595
 				{
@@ -1615,7 +1615,7 @@  discard block
 block discarded – undo
1615 1615
 						$parentTitle = TSubtotal::getParentTitleOfLine($object, $stLine->rang);
1616 1616
 						if (!empty($parentTitle) && array_key_exists($parentTitle->id, $TTitle))
1617 1617
 						{
1618
-							$stLine->label = $TTitle[$parentTitle->id]['numerotation'] . ' ' . $stLine->label;
1618
+							$stLine->label = $TTitle[$parentTitle->id]['numerotation'].' '.$stLine->label;
1619 1619
 						}
1620 1620
 					}
1621 1621
 				}
@@ -1643,12 +1643,12 @@  discard block
 block discarded – undo
1643 1643
 	}
1644 1644
 
1645 1645
 	// TODO ne gère pas encore la numération des lignes "Totaux"
1646
-	private function formatNumerotation(&$TLineTitle, $line_reference='', $level=1, $prefix_num=0)
1646
+	private function formatNumerotation(&$TLineTitle, $line_reference = '', $level = 1, $prefix_num = 0)
1647 1647
 	{
1648 1648
 		$TTitle = array();
1649 1649
 
1650
-		$i=1;
1651
-		$j=0;
1650
+		$i = 1;
1651
+		$j = 0;
1652 1652
 		foreach ($TLineTitle as $k => &$line)
1653 1653
 		{
1654 1654
 			if (!empty($line_reference) && $line->rang <= $line_reference->rang) continue;
@@ -1658,7 +1658,7 @@  discard block
 block discarded – undo
1658 1658
 			{
1659 1659
 				$TTitle[$j]['numerotation'] = ($prefix_num == 0) ? $i : $prefix_num.'.'.$i;
1660 1660
 				//var_dump('Prefix == '.$prefix_num.' // '.$line->desc.' ==> numerotation == '.$TTitle[$j]['numerotation'].'   ###    '.$line->qty .'=='. $level);
1661
-				if (empty($line->label) && (float)DOL_VERSION < 6)
1661
+				if (empty($line->label) && (float) DOL_VERSION < 6)
1662 1662
 				{
1663 1663
 					$line->label = !empty($line->desc) ? $line->desc : $line->description;
1664 1664
 					$line->desc = $line->description = '';
@@ -1686,19 +1686,19 @@  discard block
 block discarded – undo
1686 1686
 
1687 1687
 		$hidedetails = GETPOST('hidedetails', 'int');
1688 1688
 
1689
-		if(empty($hidedetails)) return false;
1689
+		if (empty($hidedetails)) return false;
1690 1690
 
1691 1691
 		// TODO can't add VAT to document without lines... :-/
1692 1692
 
1693 1693
 		return true;
1694 1694
 	}
1695 1695
 
1696
-	function beforePDFCreation($parameters=array(), &$object, &$action)
1696
+	function beforePDFCreation($parameters = array(), &$object, &$action)
1697 1697
 	{
1698 1698
 		/**
1699 1699
 		 * @var $pdf    TCPDF
1700 1700
 		 */
1701
-		global $pdf,$conf, $langs;
1701
+		global $pdf, $conf, $langs;
1702 1702
 
1703 1703
 		$object->subtotalPdfModelInfo = new stdClass(); // see defineColumnFiel method in this class
1704 1704
 		$object->subtotalPdfModelInfo->cols = false;
@@ -1707,7 +1707,7 @@  discard block
 block discarded – undo
1707 1707
 		dol_include_once('/subtotal/class/subtotal.class.php');
1708 1708
 
1709 1709
 		$i = $parameters['i'];
1710
-		foreach($parameters as $key=>$value) {
1710
+		foreach ($parameters as $key=>$value) {
1711 1711
 			${$key} = $value;
1712 1712
 		}
1713 1713
 
@@ -1715,18 +1715,18 @@  discard block
 block discarded – undo
1715 1715
 
1716 1716
 		$this->add_numerotation($object);
1717 1717
 
1718
-        foreach($object->lines as $k => &$l) {
1719
-            if(TSubtotal::isSubtotal($l)) {
1718
+        foreach ($object->lines as $k => &$l) {
1719
+            if (TSubtotal::isSubtotal($l)) {
1720 1720
                 $parentTitle = TSubtotal::getParentTitleOfLine($object, $l->rang);
1721
-                if(is_object($parentTitle) && empty($parentTitle->array_options)) $parentTitle->fetch_optionals();
1722
-                if(! empty($parentTitle->id) && ! empty($parentTitle->array_options['options_show_reduc'])) {
1723
-                    $l->remise_percent = 100;    // Affichage de la réduction sur la ligne de sous-total
1721
+                if (is_object($parentTitle) && empty($parentTitle->array_options)) $parentTitle->fetch_optionals();
1722
+                if (!empty($parentTitle->id) && !empty($parentTitle->array_options['options_show_reduc'])) {
1723
+                    $l->remise_percent = 100; // Affichage de la réduction sur la ligne de sous-total
1724 1724
                 }
1725 1725
             }
1726 1726
 
1727 1727
 
1728 1728
             // Pas de hook sur les colonnes du PDF expédition, on unset les bonnes variables
1729
-            if(($object->element == 'shipping' || $object->element == 'delivery') && $this->isModSubtotalLine($k, $object))
1729
+            if (($object->element == 'shipping' || $object->element == 'delivery') && $this->isModSubtotalLine($k, $object))
1730 1730
 			{
1731 1731
 				$l->qty = $l->qty_asked;
1732 1732
 				unset($l->qty_asked, $l->qty_shipped, $l->volume, $l->weight);
@@ -1737,21 +1737,21 @@  discard block
 block discarded – undo
1737 1737
 		$hidedetails = GETPOST('hidedetails', 'int');
1738 1738
 
1739 1739
 		if ($hideInnerLines) { // si c une ligne de titre
1740
-	    	$fk_parent_line=0;
1741
-			$TLines =array();
1740
+	    	$fk_parent_line = 0;
1741
+			$TLines = array();
1742 1742
 
1743
-			$original_count=count($object->lines);
1743
+			$original_count = count($object->lines);
1744 1744
 		    $TTvas = array(); // tableau de tva
1745 1745
 
1746
-			foreach($object->lines as $k=>&$line)
1746
+			foreach ($object->lines as $k=>&$line)
1747 1747
 			{
1748 1748
 
1749
-				if($line->product_type==9 && $line->rowid>0)
1749
+				if ($line->product_type == 9 && $line->rowid > 0)
1750 1750
 				{
1751 1751
 					$fk_parent_line = $line->rowid;
1752 1752
 
1753 1753
 					// Fix tk7201 - si on cache le détail, la TVA est renseigné au niveau du sous-total, l'erreur c'est s'il y a plusieurs sous-totaux pour les même lignes, ça va faire la somme
1754
-					if(TSubtotal::isSubtotal($line))
1754
+					if (TSubtotal::isSubtotal($line))
1755 1755
 					{
1756 1756
 						/*$total = $this->getTotalLineFromObject($object, $line, '');
1757 1757
 
@@ -1782,22 +1782,22 @@  discard block
 block discarded – undo
1782 1782
 
1783 1783
 				if ($hideInnerLines)
1784 1784
 				{
1785
-				    if(!empty($conf->global->SUBTOTAL_REPLACE_WITH_VAT_IF_HIDE_INNERLINES))
1785
+				    if (!empty($conf->global->SUBTOTAL_REPLACE_WITH_VAT_IF_HIDE_INNERLINES))
1786 1786
 				    {
1787
-				        if($line->tva_tx != '0.000' && $line->product_type!=9){
1787
+				        if ($line->tva_tx != '0.000' && $line->product_type != 9) {
1788 1788
 
1789 1789
     				        // on remplit le tableau de tva pour substituer les lignes cachées
1790 1790
     				        $TTvas[$line->tva_tx]['total_tva'] += $line->total_tva;
1791 1791
     				        $TTvas[$line->tva_tx]['total_ht'] += $line->total_ht;
1792 1792
     				        $TTvas[$line->tva_tx]['total_ttc'] += $line->total_ttc;
1793 1793
     				    }
1794
-    					if($line->product_type==9 && $line->rowid>0)
1794
+    					if ($line->product_type == 9 && $line->rowid > 0)
1795 1795
     					{
1796 1796
     					    //Cas où je doit cacher les produits et afficher uniquement les sous-totaux avec les titres
1797 1797
     					    // génère des lignes d'affichage des montants HT soumis à tva
1798 1798
     					    $nbtva = count($TTvas);
1799
-    					    if(!empty($nbtva)){
1800
-    					        foreach ($TTvas as $tx =>$val){
1799
+    					    if (!empty($nbtva)) {
1800
+    					        foreach ($TTvas as $tx =>$val) {
1801 1801
     					            $l = clone $line;
1802 1802
     					            $l->product_type = 1;
1803 1803
     					            $l->special_code = '';
@@ -1818,7 +1818,7 @@  discard block
 block discarded – undo
1818 1818
     					}
1819 1819
 				    } else {
1820 1820
 
1821
-				        if($line->product_type==9 && $line->rowid>0)
1821
+				        if ($line->product_type == 9 && $line->rowid > 0)
1822 1822
 				        {
1823 1823
 				            // ajoute la ligne de sous-total
1824 1824
 				            $TLines[] = $line;
@@ -1846,9 +1846,9 @@  discard block
 block discarded – undo
1846 1846
 
1847 1847
 			// cas incongru où il y aurait des produits en dessous du dernier sous-total
1848 1848
 			$nbtva = count($TTvas);
1849
-			if(!empty($nbtva) && $hideInnerLines && !empty($conf->global->SUBTOTAL_REPLACE_WITH_VAT_IF_HIDE_INNERLINES))
1849
+			if (!empty($nbtva) && $hideInnerLines && !empty($conf->global->SUBTOTAL_REPLACE_WITH_VAT_IF_HIDE_INNERLINES))
1850 1850
 			{
1851
-			    foreach ($TTvas as $tx =>$val){
1851
+			    foreach ($TTvas as $tx =>$val) {
1852 1852
 			        $l = clone $line;
1853 1853
 			        $l->product_type = 1;
1854 1854
 			        $l->special_code = '';
@@ -1865,11 +1865,11 @@  discard block
 block discarded – undo
1865 1865
 			}
1866 1866
 
1867 1867
 			global $nblignes;
1868
-			$nblignes=count($TLines);
1868
+			$nblignes = count($TLines);
1869 1869
 
1870 1870
 			$object->lines = $TLines;
1871 1871
 
1872
-			if($i>count($object->lines)) {
1872
+			if ($i > count($object->lines)) {
1873 1873
 				$this->resprints = '';
1874 1874
 				return 0;
1875 1875
 			}
@@ -1878,14 +1878,14 @@  discard block
 block discarded – undo
1878 1878
 		return 0;
1879 1879
 	}
1880 1880
 
1881
-	function pdf_writelinedesc($parameters=array(), &$object, &$action)
1881
+	function pdf_writelinedesc($parameters = array(), &$object, &$action)
1882 1882
 	{
1883 1883
 		/**
1884 1884
 		 * @var $pdf    TCPDF
1885 1885
 		 */
1886
-		global $pdf,$conf;
1886
+		global $pdf, $conf;
1887 1887
 
1888
-		foreach($parameters as $key=>$value) {
1888
+		foreach ($parameters as $key=>$value) {
1889 1889
 			${$key} = $value;
1890 1890
 		}
1891 1891
 
@@ -1899,42 +1899,42 @@  discard block
 block discarded – undo
1899 1899
 		$hideInnerLines = GETPOST('hideInnerLines', 'int');
1900 1900
 		$hidedetails = GETPOST('hidedetails', 'int');
1901 1901
 
1902
-		if($this->isModSubtotalLine($parameters,$object) ){
1902
+		if ($this->isModSubtotalLine($parameters, $object)) {
1903 1903
 
1904 1904
 				global $hideprices;
1905 1905
 
1906
-				if(!empty($hideprices)) {
1907
-					foreach($object->lines as &$line) {
1908
-						if($line->fk_product_type!=9) $line->fk_parent_line = -1;
1906
+				if (!empty($hideprices)) {
1907
+					foreach ($object->lines as &$line) {
1908
+						if ($line->fk_product_type != 9) $line->fk_parent_line = -1;
1909 1909
 					}
1910 1910
 				}
1911 1911
 
1912 1912
 				$line = &$object->lines[$i];
1913 1913
 
1914
-				if($object->element == 'delivery' && ! empty($object->commande->expeditions[$line->fk_origin_line])) unset($object->commande->expeditions[$line->fk_origin_line]);
1914
+				if ($object->element == 'delivery' && !empty($object->commande->expeditions[$line->fk_origin_line])) unset($object->commande->expeditions[$line->fk_origin_line]);
1915 1915
 
1916 1916
 				$margin = $pdf->getMargins();
1917
-				if(!empty($margin) && $line->info_bits>0) { // PAGE BREAK
1917
+				if (!empty($margin) && $line->info_bits > 0) { // PAGE BREAK
1918 1918
 					$pdf->addPage();
1919 1919
 					$posy = $margin['top'];
1920 1920
 				}
1921 1921
 
1922 1922
 				$label = $line->label;
1923
-				$description= !empty($line->desc) ? $outputlangs->convToOutputCharset($line->desc) : $outputlangs->convToOutputCharset($line->description);
1923
+				$description = !empty($line->desc) ? $outputlangs->convToOutputCharset($line->desc) : $outputlangs->convToOutputCharset($line->description);
1924 1924
 
1925
-				if(empty($label)) {
1925
+				if (empty($label)) {
1926 1926
 					$label = $description;
1927
-					$description='';
1927
+					$description = '';
1928 1928
 				}
1929 1929
 
1930
-				if($line->qty>90) {
1930
+				if ($line->qty > 90) {
1931 1931
 					if ($conf->global->SUBTOTAL_USE_NEW_FORMAT)	$label .= ' '.$this->getTitle($object, $line);
1932 1932
 
1933 1933
 					$pageBefore = $pdf->getPage();
1934
-					$this->pdf_add_total($pdf,$object, $line, $label, $description,$posx, $posy, $w, $h);
1934
+					$this->pdf_add_total($pdf, $object, $line, $label, $description, $posx, $posy, $w, $h);
1935 1935
 					$pageAfter = $pdf->getPage();
1936 1936
 
1937
-					if($pageAfter>$pageBefore) {
1937
+					if ($pageAfter > $pageBefore) {
1938 1938
 						//print "ST $pageAfter>$pageBefore<br>";
1939 1939
 						$pdf->rollbackTransaction(true);
1940 1940
 						$pdf->addPage('', '', true);
@@ -1945,9 +1945,9 @@  discard block
 block discarded – undo
1945 1945
 					}
1946 1946
 
1947 1947
 					// On delivery PDF, we don't want quantities to appear and there are no hooks => setting text color to background color;
1948
-					if($object->element == 'delivery')
1948
+					if ($object->element == 'delivery')
1949 1949
 					{
1950
-						switch($line->qty)
1950
+						switch ($line->qty)
1951 1951
 						{
1952 1952
 							case 99:
1953 1953
 								$grey = 220;
@@ -1970,17 +1970,17 @@  discard block
 block discarded – undo
1970 1970
 				else if ($line->qty < 10) {
1971 1971
 					$pageBefore = $pdf->getPage();
1972 1972
 
1973
-					$this->pdf_add_title($pdf,$object, $line, $label, $description,$posx, $posy, $w, $h);
1973
+					$this->pdf_add_title($pdf, $object, $line, $label, $description, $posx, $posy, $w, $h);
1974 1974
 					$pageAfter = $pdf->getPage();
1975 1975
 
1976
-					if($object->element == 'delivery')
1976
+					if ($object->element == 'delivery')
1977 1977
 					{
1978
-						$pdf->SetTextColor(255,255,255);
1978
+						$pdf->SetTextColor(255, 255, 255);
1979 1979
 					}
1980 1980
 
1981 1981
 					$posy = $pdf->GetY();
1982 1982
 					return 1;
1983
-				} elseif(!empty($margin)) {
1983
+				} elseif (!empty($margin)) {
1984 1984
 
1985 1985
 					$labelproductservice = pdf_getlinedesc($object, $i, $outputlangs, $parameters['hideref'], $parameters['hidedesc'], $parameters['issupplierline']);
1986 1986
 
@@ -2032,9 +2032,9 @@  discard block
 block discarded – undo
2032 2032
 	 * @param $hookmanager  HookManager
2033 2033
 	 * @return int
2034 2034
 	 */
2035
-	function printObjectLine ($parameters, &$object, &$action, $hookmanager)
2035
+	function printObjectLine($parameters, &$object, &$action, $hookmanager)
2036 2036
 	{
2037
-		global $conf,$langs,$user,$db,$bc;
2037
+		global $conf, $langs, $user, $db, $bc;
2038 2038
 
2039 2039
 		$num = &$parameters['num'];
2040 2040
 		$line = &$parameters['line'];
@@ -2042,33 +2042,33 @@  discard block
 block discarded – undo
2042 2042
 
2043 2043
 		$var = &$parameters['var'];
2044 2044
 
2045
-		$contexts = explode(':',$parameters['context']);
2046
-		if($parameters['currentcontext'] === 'paiementcard') return 0;
2045
+		$contexts = explode(':', $parameters['context']);
2046
+		if ($parameters['currentcontext'] === 'paiementcard') return 0;
2047 2047
 		$originline = null;
2048 2048
 
2049 2049
 		$createRight = $user->rights->{$object->element}->creer;
2050
-		if($object->element == 'facturerec' )
2050
+		if ($object->element == 'facturerec')
2051 2051
 		{
2052 2052
 			$object->statut = 0; // hack for facture rec
2053 2053
 			$createRight = $user->rights->facture->creer;
2054 2054
 		}
2055
-		elseif($object->element == 'order_supplier' )
2055
+		elseif ($object->element == 'order_supplier')
2056 2056
 		{
2057 2057
 		    $createRight = $user->rights->fournisseur->commande->creer;
2058 2058
 		}
2059
-		elseif($object->element == 'invoice_supplier' )
2059
+		elseif ($object->element == 'invoice_supplier')
2060 2060
 		{
2061 2061
 		    $createRight = $user->rights->fournisseur->facture->creer;
2062 2062
 		}
2063
-		elseif($object->element == 'commande' && in_array('ordershipmentcard', $contexts))
2063
+		elseif ($object->element == 'commande' && in_array('ordershipmentcard', $contexts))
2064 2064
 		{
2065 2065
 			// H4cK 4n0nYm0u$-style : $line n'est pas un objet instancié mais provient d'un fetch_object d'une requête SQL
2066 2066
 			$line->id = $line->rowid;
2067 2067
 			$line->product_type = $line->type;
2068 2068
 		}
2069
-		elseif($object->element == 'shipping' || $object->element == 'delivery')
2069
+		elseif ($object->element == 'shipping' || $object->element == 'delivery')
2070 2070
 		{
2071
-			if(empty($line->origin_line_id) && ! empty($line->fk_origin_line))
2071
+			if (empty($line->origin_line_id) && !empty($line->fk_origin_line))
2072 2072
 			{
2073 2073
 				$line->origin_line_id = $line->fk_origin_line;
2074 2074
 			}
@@ -2076,9 +2076,9 @@  discard block
 block discarded – undo
2076 2076
 			$originline = new OrderLine($db);
2077 2077
 			$originline->fetch($line->fk_origin_line);
2078 2078
 
2079
-			foreach(get_object_vars($line) as $property => $value)
2079
+			foreach (get_object_vars($line) as $property => $value)
2080 2080
 			{
2081
-				if(empty($originline->{ $property }))
2081
+				if (empty($originline->{ $property }))
2082 2082
 				{
2083 2083
 					$originline->{ $property } = $value;
2084 2084
 				}
@@ -2086,13 +2086,13 @@  discard block
 block discarded – undo
2086 2086
 
2087 2087
 			$line = $originline;
2088 2088
 		}
2089
- 		if($object->element=='facture')$idvar = 'facid';
2090
-        else $idvar='id';
2091
-		if($line->special_code!=$this->module_number || $line->product_type!=9) {
2092
-			if ($object->statut == 0  && $createRight && !empty($conf->global->SUBTOTAL_ALLOW_DUPLICATE_LINE) && $object->element !== 'invoice_supplier')
2089
+ 		if ($object->element == 'facture')$idvar = 'facid';
2090
+        else $idvar = 'id';
2091
+		if ($line->special_code != $this->module_number || $line->product_type != 9) {
2092
+			if ($object->statut == 0 && $createRight && !empty($conf->global->SUBTOTAL_ALLOW_DUPLICATE_LINE) && $object->element !== 'invoice_supplier')
2093 2093
             {
2094
-                if(!(TSubtotal::isModSubtotalLine($line)) && ( $line->fk_prev_id === null ) && !($action == "editline" && GETPOST('lineid', 'int') == $line->id)) {
2095
-                    echo '<a name="duplicate-'.$line->id.'" href="' . $_SERVER['PHP_SELF'] . '?' . $idvar . '=' . $object->id . '&action=duplicate&lineid=' . $line->id . '"><i class="fa fa-clone" aria-hidden="true"></i></a>';
2094
+                if (!(TSubtotal::isModSubtotalLine($line)) && ($line->fk_prev_id === null) && !($action == "editline" && GETPOST('lineid', 'int') == $line->id)) {
2095
+                    echo '<a name="duplicate-'.$line->id.'" href="'.$_SERVER['PHP_SELF'].'?'.$idvar.'='.$object->id.'&action=duplicate&lineid='.$line->id.'"><i class="fa fa-clone" aria-hidden="true"></i></a>';
2096 2096
 
2097 2097
                     ?>
2098 2098
                         <script type="text/javascript">
@@ -2106,11 +2106,11 @@  discard block
 block discarded – undo
2106 2106
             }
2107 2107
 			return 0;
2108 2108
 		}
2109
-		else if (in_array('invoicecard',$contexts) || in_array('invoicesuppliercard',$contexts) || in_array('propalcard',$contexts) || in_array('supplier_proposalcard',$contexts) || in_array('ordercard',$contexts) || in_array('ordersuppliercard',$contexts) || in_array('invoicereccard',$contexts))
2109
+		else if (in_array('invoicecard', $contexts) || in_array('invoicesuppliercard', $contexts) || in_array('propalcard', $contexts) || in_array('supplier_proposalcard', $contexts) || in_array('ordercard', $contexts) || in_array('ordersuppliercard', $contexts) || in_array('invoicereccard', $contexts))
2110 2110
         {
2111 2111
 
2112 2112
 
2113
-			if((float)DOL_VERSION <= 3.4)
2113
+			if ((float) DOL_VERSION <= 3.4)
2114 2114
 			{
2115 2115
 				?>
2116 2116
 				<script type="text/javascript">
@@ -2133,24 +2133,24 @@  discard block
 block discarded – undo
2133 2133
 				</script>
2134 2134
 				<?php
2135 2135
 			}
2136
-			if(empty($line->description)) $line->description = $line->desc;
2136
+			if (empty($line->description)) $line->description = $line->desc;
2137 2137
 			$colspan = 5;
2138
-			if($object->element == 'facturerec' ) $colspan = 3;
2139
-			if($object->element == 'order_supplier') (float) DOL_VERSION < 7.0 ? $colspan = 3 : $colspan = 6;
2140
-			if($object->element == 'invoice_supplier') (float) DOL_VERSION < 7.0 ? $colspan = 4: $colspan = 7;
2141
-			if($object->element == 'supplier_proposal') (float) DOL_VERSION < 6.0 ? $colspan = 4 : $colspan = 3;
2142
-			if(!empty($conf->multicurrency->enabled) && ((float) DOL_VERSION < 8.0 || $object->multicurrency_code != $conf->currency)) {
2138
+			if ($object->element == 'facturerec') $colspan = 3;
2139
+			if ($object->element == 'order_supplier') (float) DOL_VERSION < 7.0 ? $colspan = 3 : $colspan = 6;
2140
+			if ($object->element == 'invoice_supplier') (float) DOL_VERSION < 7.0 ? $colspan = 4 : $colspan = 7;
2141
+			if ($object->element == 'supplier_proposal') (float) DOL_VERSION < 6.0 ? $colspan = 4 : $colspan = 3;
2142
+			if (!empty($conf->multicurrency->enabled) && ((float) DOL_VERSION < 8.0 || $object->multicurrency_code != $conf->currency)) {
2143 2143
 				$colspan++; // Colonne PU Devise
2144 2144
 			}
2145
-			if($object->element == 'commande' && $object->statut < 3 && !empty($conf->shippableorder->enabled)) $colspan++;
2145
+			if ($object->element == 'commande' && $object->statut < 3 && !empty($conf->shippableorder->enabled)) $colspan++;
2146 2146
 			$margins_hidden_by_module = empty($conf->affmarges->enabled) ? false : !($_SESSION['marginsdisplayed']);
2147
-			if(!empty($conf->margin->enabled) && !$margins_hidden_by_module) $colspan++;
2148
-			if(!empty($conf->margin->enabled) && !empty($conf->global->DISPLAY_MARGIN_RATES) && !$margins_hidden_by_module) $colspan++;
2149
-			if(!empty($conf->margin->enabled) && !empty($conf->global->DISPLAY_MARK_RATES) && !$margins_hidden_by_module) $colspan++;
2150
-			if($object->element == 'facture' && !empty($conf->global->INVOICE_USE_SITUATION) && $object->type == Facture::TYPE_SITUATION) $colspan++;
2151
-			if(!empty($conf->global->PRODUCT_USE_UNITS)) $colspan++;
2147
+			if (!empty($conf->margin->enabled) && !$margins_hidden_by_module) $colspan++;
2148
+			if (!empty($conf->margin->enabled) && !empty($conf->global->DISPLAY_MARGIN_RATES) && !$margins_hidden_by_module) $colspan++;
2149
+			if (!empty($conf->margin->enabled) && !empty($conf->global->DISPLAY_MARK_RATES) && !$margins_hidden_by_module) $colspan++;
2150
+			if ($object->element == 'facture' && !empty($conf->global->INVOICE_USE_SITUATION) && $object->type == Facture::TYPE_SITUATION) $colspan++;
2151
+			if (!empty($conf->global->PRODUCT_USE_UNITS)) $colspan++;
2152 2152
 			// Compatibility module showprice
2153
-			if(!empty($conf->showprice->enabled)) $colspan++;
2153
+			if (!empty($conf->showprice->enabled)) $colspan++;
2154 2154
 
2155 2155
 			/* Titre */
2156 2156
 			//var_dump($line);
@@ -2160,39 +2160,39 @@  discard block
 block discarded – undo
2160 2160
 
2161 2161
 
2162 2162
 			?>
2163
-			<tr <?php echo $bc[$var]; $var=!$var; echo $data; ?> rel="subtotal" id="row-<?php echo $line->id ?>" style="<?php
2163
+			<tr <?php echo $bc[$var]; $var = !$var; echo $data; ?> rel="subtotal" id="row-<?php echo $line->id ?>" style="<?php
2164 2164
 					if (!empty($conf->global->SUBTOTAL_USE_NEW_FORMAT))
2165 2165
 					{
2166
-						if($line->qty==99) print 'background:#adadcf';
2167
-						else if($line->qty==98) print 'background:#ddddff;';
2168
-						else if($line->qty<=97 && $line->qty>=91) print 'background:#eeeeff;';
2169
-						else if($line->qty==1) print 'background:#adadcf;';
2170
-						else if($line->qty==2) print 'background:#ddddff;';
2171
-						else if($line->qty==50) print '';
2166
+						if ($line->qty == 99) print 'background:#adadcf';
2167
+						else if ($line->qty == 98) print 'background:#ddddff;';
2168
+						else if ($line->qty <= 97 && $line->qty >= 91) print 'background:#eeeeff;';
2169
+						else if ($line->qty == 1) print 'background:#adadcf;';
2170
+						else if ($line->qty == 2) print 'background:#ddddff;';
2171
+						else if ($line->qty == 50) print '';
2172 2172
 						else print 'background:#eeeeff;';
2173 2173
 
2174 2174
 						//A compléter si on veux plus de nuances de couleurs avec les niveau 4,5,6,7,8 et 9
2175 2175
 					}
2176 2176
 					else
2177 2177
 					{
2178
-						if($line->qty==99) print 'background:#ddffdd';
2179
-						else if($line->qty==98) print 'background:#ddddff;';
2180
-						else if($line->qty==2) print 'background:#eeeeff; ';
2181
-						else if($line->qty==50) print '';
2182
-						else print 'background:#eeffee;' ;
2178
+						if ($line->qty == 99) print 'background:#ddffdd';
2179
+						else if ($line->qty == 98) print 'background:#ddddff;';
2180
+						else if ($line->qty == 2) print 'background:#eeeeff; ';
2181
+						else if ($line->qty == 50) print '';
2182
+						else print 'background:#eeffee;';
2183 2183
 					}
2184 2184
 
2185 2185
 			?>;">
2186 2186
 
2187
-				<?php if(! empty($conf->global->MAIN_VIEW_LINE_NUMBER)) { ?>
2187
+				<?php if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER)) { ?>
2188 2188
 				<td class="linecolnum"><?php echo $i + 1; ?></td>
2189 2189
 				<?php } ?>
2190 2190
 
2191
-				<td colspan="<?php echo $colspan; ?>" style="<?php TSubtotal::isFreeText($line) ? '' : 'font-weight:bold;'; ?>  <?php echo ($line->qty>90)?'text-align:right':'' ?> "><?php
2192
-					if($action=='editline' && GETPOST('lineid', 'int') == $line->id && TSubtotal::isModSubtotalLine($line) ) {
2191
+				<td colspan="<?php echo $colspan; ?>" style="<?php TSubtotal::isFreeText($line) ? '' : 'font-weight:bold;'; ?>  <?php echo ($line->qty > 90) ? 'text-align:right' : '' ?> "><?php
2192
+					if ($action == 'editline' && GETPOST('lineid', 'int') == $line->id && TSubtotal::isModSubtotalLine($line)) {
2193 2193
 
2194
-						$params=array('line'=>$line);
2195
-						$reshook=$hookmanager->executeHooks('formEditProductOptions',$params,$object,$action);
2194
+						$params = array('line'=>$line);
2195
+						$reshook = $hookmanager->executeHooks('formEditProductOptions', $params, $object, $action);
2196 2196
 
2197 2197
 						echo '<div id="line_'.$line->id.'"></div>'; // Imitation Dolibarr
2198 2198
 						echo '<input type="hidden" value="'.$line->id.'" name="lineid">';
@@ -2200,7 +2200,7 @@  discard block
 block discarded – undo
2200 2200
 						echo '<input id="product_id" type="hidden" value="'.$line->fk_product.'" name="type">';
2201 2201
 						echo '<input id="special_code" type="hidden" value="'.$line->special_code.'" name="type">';
2202 2202
 
2203
-						$isFreeText=false;
2203
+						$isFreeText = false;
2204 2204
 						if (TSubtotal::isTitle($line))
2205 2205
 						{
2206 2206
 							$qty_displayed = $line->qty;
@@ -2222,13 +2222,13 @@  discard block
 block discarded – undo
2222 2222
 						    $line->description = '';
2223 2223
 						}
2224 2224
 						$newlabel = $line->label;
2225
-						if($line->label=='' && !$isFreeText) {
2226
-							if(TSubtotal::isSubtotal($line)) {
2225
+						if ($line->label == '' && !$isFreeText) {
2226
+							if (TSubtotal::isSubtotal($line)) {
2227 2227
 								$newlabel = $line->description.' '.$this->getTitle($object, $line);
2228
-								$line->description='';
2229
-							} elseif( (float)DOL_VERSION < 6 ) {
2230
-								$newlabel= $line->description;
2231
-								$line->description='';
2228
+								$line->description = '';
2229
+							} elseif ((float) DOL_VERSION < 6) {
2230
+								$newlabel = $line->description;
2231
+								$line->description = '';
2232 2232
 							}
2233 2233
 						}
2234 2234
 
@@ -2237,10 +2237,10 @@  discard block
 block discarded – undo
2237 2237
 
2238 2238
 						if (!$isFreeText) echo '<input type="text" name="line-title" id-line="'.$line->id.'" value="'.$newlabel.'" size="80" '.$readonlyForSituation.'/>&nbsp;';
2239 2239
 
2240
-						if (!empty($conf->global->SUBTOTAL_USE_NEW_FORMAT) && (TSubtotal::isTitle($line) || TSubtotal::isSubtotal($line)) )
2240
+						if (!empty($conf->global->SUBTOTAL_USE_NEW_FORMAT) && (TSubtotal::isTitle($line) || TSubtotal::isSubtotal($line)))
2241 2241
 						{
2242 2242
 							$select = '<select name="subtotal_level">';
2243
-							for ($j=1; $j<10; $j++)
2243
+							for ($j = 1; $j < 10; $j++)
2244 2244
 							{
2245 2245
 								if (!empty($readonlyForSituation)) {
2246 2246
 									if ($qty_displayed == $j) $select .= '<option selected="selected" value="'.$j.'">'.$langs->trans('Level').' '.$j.'</option>';
@@ -2254,7 +2254,7 @@  discard block
 block discarded – undo
2254 2254
 
2255 2255
 						echo '<div class="subtotal_underline" style="margin-left:24px; line-height: 25px;">';
2256 2256
                         echo '<div>';
2257
-                        echo '<input style="vertical-align:sub;"  type="checkbox" name="line-pagebreak" id="subtotal-pagebreak" value="8" '.(($line->info_bits > 0) ? 'checked="checked"' : '') .' />&nbsp;';
2257
+                        echo '<input style="vertical-align:sub;"  type="checkbox" name="line-pagebreak" id="subtotal-pagebreak" value="8" '.(($line->info_bits > 0) ? 'checked="checked"' : '').' />&nbsp;';
2258 2258
                         echo '<label for="subtotal-pagebreak">'.$langs->trans('AddBreakPageBefore').'</label>';
2259 2259
                         echo '</div>';
2260 2260
 
@@ -2275,12 +2275,12 @@  discard block
 block discarded – undo
2275 2275
                                 echo '</div>';
2276 2276
                             }
2277 2277
                             echo '<div>';
2278
-                            echo '<input style="vertical-align:sub;"  type="checkbox" name="line-showTotalHT" id="subtotal-showTotalHT" value="9" '.(($line->array_options['options_show_total_ht'] > 0) ? 'checked="checked"' : '') .' />&nbsp;';
2278
+                            echo '<input style="vertical-align:sub;"  type="checkbox" name="line-showTotalHT" id="subtotal-showTotalHT" value="9" '.(($line->array_options['options_show_total_ht'] > 0) ? 'checked="checked"' : '').' />&nbsp;';
2279 2279
                             echo '<label for="subtotal-showTotalHT">'.$langs->trans('ShowTotalHTOnSubtotalBlock').'</label>';
2280 2280
                             echo '</div>';
2281 2281
 
2282 2282
                             echo '<div>';
2283
-                            echo '<input style="vertical-align:sub;"  type="checkbox" name="line-showReduc" id="subtotal-showReduc" value="1" '.(($line->array_options['options_show_reduc'] > 0) ? 'checked="checked"' : '') .' />&nbsp;';
2283
+                            echo '<input style="vertical-align:sub;"  type="checkbox" name="line-showReduc" id="subtotal-showReduc" value="1" '.(($line->array_options['options_show_reduc'] > 0) ? 'checked="checked"' : '').' />&nbsp;';
2284 2284
                             echo '<label for="subtotal-showReduc">'.$langs->trans('ShowReducOnSubtotalBlock').'</label>';
2285 2285
                             echo '</div>';
2286 2286
                         }
@@ -2290,7 +2290,7 @@  discard block
 block discarded – undo
2290 2290
 						if (TSubtotal::isTitle($line))
2291 2291
 						{
2292 2292
 							// WYSIWYG editor
2293
-							require_once DOL_DOCUMENT_ROOT . '/core/class/doleditor.class.php';
2293
+							require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
2294 2294
 							$nbrows = ROWS_2;
2295 2295
 							$cked_enabled = (!empty($conf->global->FCKEDITOR_ENABLE_DETAILS) ? $conf->global->FCKEDITOR_ENABLE_DETAILS : 0);
2296 2296
 							if (!empty($conf->global->MAIN_INPUT_DESC_HEIGHT)) {
@@ -2332,25 +2332,25 @@  discard block
 block discarded – undo
2332 2332
 
2333 2333
 						 if ($conf->global->SUBTOTAL_USE_NEW_FORMAT)
2334 2334
 						 {
2335
-							if(TSubtotal::isTitle($line) || TSubtotal::isSubtotal($line))
2335
+							if (TSubtotal::isTitle($line) || TSubtotal::isSubtotal($line))
2336 2336
 							{
2337
-								echo str_repeat('&nbsp;&nbsp;&nbsp;', $line->qty-1);
2337
+								echo str_repeat('&nbsp;&nbsp;&nbsp;', $line->qty - 1);
2338 2338
 
2339 2339
 								if (TSubtotal::isTitle($line)) print img_picto('', 'subtotal@subtotal').'<span style="font-size:9px;margin-left:-3px;">'.$line->qty.'</span>&nbsp;&nbsp;';
2340
-								else print img_picto('', 'subtotal2@subtotal').'<span style="font-size:9px;margin-left:-1px;">'.(100-$line->qty).'</span>&nbsp;&nbsp;';
2340
+								else print img_picto('', 'subtotal2@subtotal').'<span style="font-size:9px;margin-left:-1px;">'.(100 - $line->qty).'</span>&nbsp;&nbsp;';
2341 2341
 							}
2342 2342
 						 }
2343 2343
 						 else
2344 2344
 						 {
2345
-							if($line->qty<=1) print img_picto('', 'subtotal@subtotal');
2346
-							else if($line->qty==2) print img_picto('', 'subsubtotal@subtotal').'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
2345
+							if ($line->qty <= 1) print img_picto('', 'subtotal@subtotal');
2346
+							else if ($line->qty == 2) print img_picto('', 'subsubtotal@subtotal').'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
2347 2347
 						 }
2348 2348
 
2349 2349
 
2350 2350
 						 // Get display styles and apply them
2351 2351
 						 $titleStyleItalic = strpos($conf->global->SUBTOTAL_TITLE_STYLE, 'I') === false ? '' : ' font-style: italic;';
2352
-						 $titleStyleBold =  strpos($conf->global->SUBTOTAL_TITLE_STYLE, 'B') === false ? '' : ' font-weight:bold;';
2353
-						 $titleStyleUnderline =  strpos($conf->global->SUBTOTAL_TITLE_STYLE, 'U') === false ? '' : ' text-decoration: underline;';
2352
+						 $titleStyleBold = strpos($conf->global->SUBTOTAL_TITLE_STYLE, 'B') === false ? '' : ' font-weight:bold;';
2353
+						 $titleStyleUnderline = strpos($conf->global->SUBTOTAL_TITLE_STYLE, 'U') === false ? '' : ' text-decoration: underline;';
2354 2354
 
2355 2355
 						 if (empty($line->label)) {
2356 2356
 							if ($line->qty >= 91 && $line->qty <= 99 && $conf->global->SUBTOTAL_USE_NEW_FORMAT) print  $line->description.' '.$this->getTitle($object, $line);
@@ -2358,16 +2358,16 @@  discard block
 block discarded – undo
2358 2358
 						 }
2359 2359
 						 else {
2360 2360
 
2361
-							if (! empty($conf->global->PRODUIT_DESC_IN_FORM) && !empty($line->description)) {
2361
+							if (!empty($conf->global->PRODUIT_DESC_IN_FORM) && !empty($line->description)) {
2362 2362
 								print '<span class="subtotal_label" style="'.$titleStyleItalic.$titleStyleBold.$titleStyleUnderline.'" >'.$line->label.'</span><br><div class="subtotal_desc">'.dol_htmlentitiesbr($line->description).'</div>';
2363 2363
 							}
2364
-							else{
2364
+							else {
2365 2365
 								print '<span class="subtotal_label classfortooltip '.$titleStyleItalic.$titleStyleBold.$titleStyleUnderline.'" title="'.$line->description.'">'.$line->label.'</span>';
2366 2366
 							}
2367 2367
 
2368 2368
 						 }
2369
-						if($line->qty>90) print ' : ';
2370
-						if($line->info_bits > 0) echo img_picto($langs->trans('Pagebreak'), 'pagebreak@subtotal');
2369
+						if ($line->qty > 90) print ' : ';
2370
+						if ($line->info_bits > 0) echo img_picto($langs->trans('Pagebreak'), 'pagebreak@subtotal');
2371 2371
 
2372 2372
 
2373 2373
 
@@ -2376,7 +2376,7 @@  discard block
 block discarded – undo
2376 2376
 			?></td>
2377 2377
 
2378 2378
 			<?php
2379
-				if($line->qty>90) {
2379
+				if ($line->qty > 90) {
2380 2380
 					/* Total */
2381 2381
 					$total_line = $this->getTotalLineFromObject($object, $line, '');
2382 2382
 					echo '<td class="linecolht nowrap" align="right" style="font-weight:bold;" rel="subtotal_total">'.price($total_line).'</td>';
@@ -2395,7 +2395,7 @@  discard block
 block discarded – undo
2395 2395
 				<?php
2396 2396
 				if ($action != 'selectlines') {
2397 2397
 
2398
-					if($action=='editline' && GETPOST('lineid', 'int') == $line->id && TSubtotal::isModSubtotalLine($line) ) {
2398
+					if ($action == 'editline' && GETPOST('lineid', 'int') == $line->id && TSubtotal::isModSubtotalLine($line)) {
2399 2399
 						?>
2400 2400
 						<input id="savelinebutton" class="button" type="submit" name="save" value="<?php echo $langs->trans('Save') ?>" />
2401 2401
 						<br />
@@ -2411,13 +2411,13 @@  discard block
 block discarded – undo
2411 2411
 						<?php
2412 2412
 
2413 2413
 					}
2414
-					else{
2415
-						if ($object->statut == 0  && $createRight && !empty($conf->global->SUBTOTAL_ALLOW_DUPLICATE_BLOCK) && $object->element !== 'invoice_supplier')
2414
+					else {
2415
+						if ($object->statut == 0 && $createRight && !empty($conf->global->SUBTOTAL_ALLOW_DUPLICATE_BLOCK) && $object->element !== 'invoice_supplier')
2416 2416
 						{
2417
-							if(TSubtotal::isTitle($line) && ( $line->fk_prev_id === null )) echo '<a href="'.$_SERVER['PHP_SELF'].'?'.$idvar.'='.$object->id.'&action=duplicate&lineid='.$line->id.'">'. img_picto($langs->trans('Duplicate'), 'duplicate@subtotal').'</a>';
2417
+							if (TSubtotal::isTitle($line) && ($line->fk_prev_id === null)) echo '<a href="'.$_SERVER['PHP_SELF'].'?'.$idvar.'='.$object->id.'&action=duplicate&lineid='.$line->id.'">'.img_picto($langs->trans('Duplicate'), 'duplicate@subtotal').'</a>';
2418 2418
 						}
2419 2419
 
2420
-						if ($object->statut == 0  && $createRight && !empty($conf->global->SUBTOTAL_ALLOW_EDIT_BLOCK))
2420
+						if ($object->statut == 0 && $createRight && !empty($conf->global->SUBTOTAL_ALLOW_EDIT_BLOCK))
2421 2421
 						{
2422 2422
 							echo '<a href="'.$_SERVER['PHP_SELF'].'?'.$idvar.'='.$object->id.'&action=editline&lineid='.$line->id.'#row-'.$line->id.'">'.img_edit().'</a>';
2423 2423
 						}
@@ -2432,7 +2432,7 @@  discard block
 block discarded – undo
2432 2432
 				<?php
2433 2433
 
2434 2434
 				if ($action != 'editline' && $action != 'selectlines') {
2435
-						if ($object->statut == 0  && $createRight && !empty($conf->global->SUBTOTAL_ALLOW_REMOVE_BLOCK))
2435
+						if ($object->statut == 0 && $createRight && !empty($conf->global->SUBTOTAL_ALLOW_REMOVE_BLOCK))
2436 2436
 						{
2437 2437
 
2438 2438
 							if ($line->fk_prev_id === null)
@@ -2440,12 +2440,12 @@  discard block
 block discarded – undo
2440 2440
 								echo '<a href="'.$_SERVER['PHP_SELF'].'?'.$idvar.'='.$object->id.'&action=ask_deleteline&lineid='.$line->id.'">'.img_delete().'</a>';
2441 2441
 							}
2442 2442
 
2443
-							if(TSubtotal::isTitle($line) && ($line->fk_prev_id === null) )
2443
+							if (TSubtotal::isTitle($line) && ($line->fk_prev_id === null))
2444 2444
 							{
2445 2445
 								if ((float) DOL_VERSION >= 8.0) {
2446 2446
 									$img_delete = img_delete($langs->trans('deleteWithAllLines'), ' style="color:#be3535 !important;" class="pictodelete pictodeleteallline"');
2447 2447
 								} elseif ((float) DOL_VERSION >= 3.8) {
2448
-									$img_delete = img_picto($langs->trans('deleteWithAllLines'), 'delete_all.3.8@subtotal',' class="pictodelete" ');
2448
+									$img_delete = img_picto($langs->trans('deleteWithAllLines'), 'delete_all.3.8@subtotal', ' class="pictodelete" ');
2449 2449
 								} else {
2450 2450
 									$img_delete = img_picto($langs->trans('deleteWithAllLines'), 'delete_all@subtotal');
2451 2451
 								}
@@ -2458,7 +2458,7 @@  discard block
 block discarded – undo
2458 2458
 			</td>
2459 2459
 
2460 2460
 			<?php
2461
-			if ($object->statut == 0  && $createRight && !empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && TSubtotal::isTitle($line) && $action != 'editline')
2461
+			if ($object->statut == 0 && $createRight && !empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && TSubtotal::isTitle($line) && $action != 'editline')
2462 2462
 			{
2463 2463
 				echo '<td class="subtotal_nc">';
2464 2464
 				echo '<input id="subtotal_nc-'.$line->id.'" class="subtotal_nc_chkbx" data-lineid="'.$line->id.'" type="checkbox" name="subtotal_nc" value="1" '.(!empty($line->array_options['options_subtotal_nc']) ? 'checked="checked"' : '').' />';
@@ -2469,12 +2469,12 @@  discard block
 block discarded – undo
2469 2469
 			<td align="center" class="linecolmove tdlineupdown">
2470 2470
 			</td>
2471 2471
 			<?php } else { ?>
2472
-			<td align="center"<?php echo ((empty($conf->browser->phone) && ($object->statut == 0  && $createRight ))?' class="tdlineupdown"':''); ?>></td>
2472
+			<td align="center"<?php echo ((empty($conf->browser->phone) && ($object->statut == 0 && $createRight)) ? ' class="tdlineupdown"' : ''); ?>></td>
2473 2473
 			<?php } ?>
2474 2474
 
2475 2475
 
2476
-			<?php  if($action == 'selectlines'){ // dolibarr 8 ?>
2477
-			<td class="linecolcheck" align="center"><input type="checkbox" class="linecheckbox" name="line_checkbox[<?php echo $i+1; ?>]" value="<?php echo $line->id; ?>" ></td>
2476
+			<?php  if ($action == 'selectlines') { // dolibarr 8 ?>
2477
+			<td class="linecolcheck" align="center"><input type="checkbox" class="linecheckbox" name="line_checkbox[<?php echo $i + 1; ?>]" value="<?php echo $line->id; ?>" ></td>
2478 2478
 			<?php } ?>
2479 2479
 
2480 2480
 			</tr>
@@ -2482,29 +2482,29 @@  discard block
 block discarded – undo
2482 2482
 
2483 2483
 
2484 2484
 			// Affichage des extrafields à la Dolibarr (car sinon non affiché sur les titres)
2485
-			if(TSubtotal::isTitle($line) && !empty($conf->global->SUBTOTAL_ALLOW_EXTRAFIELDS_ON_TITLE)) {
2485
+			if (TSubtotal::isTitle($line) && !empty($conf->global->SUBTOTAL_ALLOW_EXTRAFIELDS_ON_TITLE)) {
2486 2486
 
2487
-				require_once DOL_DOCUMENT_ROOT . '/core/class/extrafields.class.php';
2487
+				require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
2488 2488
 
2489 2489
 				// Extrafields
2490 2490
 				$extrafieldsline = new ExtraFields($db);
2491 2491
 				$extralabelsline = $extrafieldsline->fetch_name_optionals_label($object->table_element_line);
2492 2492
 
2493
-				$colspan+=3; $mode = 'view';
2494
-				if($action === 'editline' && $line->rowid == GETPOST('lineid', 'int')) $mode = 'edit';
2493
+				$colspan += 3; $mode = 'view';
2494
+				if ($action === 'editline' && $line->rowid == GETPOST('lineid', 'int')) $mode = 'edit';
2495 2495
 
2496 2496
 				$ex_element = $line->element;
2497 2497
 				$line->element = 'tr_extrafield_title '.$line->element; // Pour pouvoir manipuler ces tr
2498
-				print $line->showOptionals($extrafieldsline, $mode, array('style'=>' style="background:#eeffee;" ','colspan'=>$colspan));
2498
+				print $line->showOptionals($extrafieldsline, $mode, array('style'=>' style="background:#eeffee;" ', 'colspan'=>$colspan));
2499 2499
 				$isExtraSelected = false;
2500
-				foreach($line->array_options as $option) {
2501
-					if(!empty($option) && $option != "-1") {
2500
+				foreach ($line->array_options as $option) {
2501
+					if (!empty($option) && $option != "-1") {
2502 2502
 						$isExtraSelected = true;
2503 2503
 						break;
2504 2504
 					}
2505 2505
 				}
2506 2506
 
2507
-				if($mode === 'edit') {
2507
+				if ($mode === 'edit') {
2508 2508
 					?>
2509 2509
 					<script>
2510 2510
 						$(document).ready(function(){
@@ -2512,7 +2512,7 @@  discard block
 block discarded – undo
2512 2512
 							var all_tr_extrafields = $("tr.tr_extrafield_title");
2513 2513
 							<?php
2514 2514
 							// Si un extrafield est rempli alors on affiche directement les extrafields
2515
-							if(!$isExtraSelected) {
2515
+							if (!$isExtraSelected) {
2516 2516
 								echo 'all_tr_extrafields.hide();';
2517 2517
 								echo 'var trad = "'.$langs->trans('showExtrafields').'";';
2518 2518
 								echo 'var extra = 0;';
@@ -2551,61 +2551,61 @@  discard block
 block discarded – undo
2551 2551
 			return 1;
2552 2552
 
2553 2553
 		}
2554
-		elseif(($object->element == 'commande' && in_array('ordershipmentcard', $contexts)) || (in_array('expeditioncard', $contexts) && $action == 'create'))
2554
+		elseif (($object->element == 'commande' && in_array('ordershipmentcard', $contexts)) || (in_array('expeditioncard', $contexts) && $action == 'create'))
2555 2555
 		{
2556 2556
 			$colspan = 4;
2557 2557
 
2558 2558
 			// HTML 5 data for js
2559 2559
 			$data = $this->_getHtmlData($parameters, $object, $action, $hookmanager);
2560 2560
 ?>
2561
-			<tr <?php echo $bc[$var]; $var=!$var; echo $data; ?> rel="subtotal" id="row-<?php echo $line->id ?>" style="<?php
2561
+			<tr <?php echo $bc[$var]; $var = !$var; echo $data; ?> rel="subtotal" id="row-<?php echo $line->id ?>" style="<?php
2562 2562
 					if (!empty($conf->global->SUBTOTAL_USE_NEW_FORMAT))
2563 2563
 					{
2564
-						if($line->qty==99) print 'background:#adadcf';
2565
-						else if($line->qty==98) print 'background:#ddddff;';
2566
-						else if($line->qty<=97 && $line->qty>=91) print 'background:#eeeeff;';
2567
-						else if($line->qty==1) print 'background:#adadcf;';
2568
-						else if($line->qty==2) print 'background:#ddddff;';
2569
-						else if($line->qty==50) print '';
2564
+						if ($line->qty == 99) print 'background:#adadcf';
2565
+						else if ($line->qty == 98) print 'background:#ddddff;';
2566
+						else if ($line->qty <= 97 && $line->qty >= 91) print 'background:#eeeeff;';
2567
+						else if ($line->qty == 1) print 'background:#adadcf;';
2568
+						else if ($line->qty == 2) print 'background:#ddddff;';
2569
+						else if ($line->qty == 50) print '';
2570 2570
 						else print 'background:#eeeeff;';
2571 2571
 
2572 2572
 						//A compléter si on veux plus de nuances de couleurs avec les niveau 4,5,6,7,8 et 9
2573 2573
 					}
2574 2574
 					else
2575 2575
 					{
2576
-						if($line->qty==99) print 'background:#ddffdd';
2577
-						else if($line->qty==98) print 'background:#ddddff;';
2578
-						else if($line->qty==2) print 'background:#eeeeff; ';
2579
-						else if($line->qty==50) print '';
2580
-						else print 'background:#eeffee;' ;
2576
+						if ($line->qty == 99) print 'background:#ddffdd';
2577
+						else if ($line->qty == 98) print 'background:#ddddff;';
2578
+						else if ($line->qty == 2) print 'background:#eeeeff; ';
2579
+						else if ($line->qty == 50) print '';
2580
+						else print 'background:#eeffee;';
2581 2581
 					}
2582 2582
 
2583 2583
 			?>;">
2584 2584
 
2585
-				<td style="<?php TSubtotal::isFreeText($line) ? '' : 'font-weight:bold;'; ?>  <?php echo ($line->qty>90)?'text-align:right':'' ?> "><?php
2585
+				<td style="<?php TSubtotal::isFreeText($line) ? '' : 'font-weight:bold;'; ?>  <?php echo ($line->qty > 90) ? 'text-align:right' : '' ?> "><?php
2586 2586
 
2587 2587
 
2588 2588
 						 if ($conf->global->SUBTOTAL_USE_NEW_FORMAT)
2589 2589
 						 {
2590
-							if(TSubtotal::isTitle($line) || TSubtotal::isSubtotal($line))
2590
+							if (TSubtotal::isTitle($line) || TSubtotal::isSubtotal($line))
2591 2591
 							{
2592
-								echo str_repeat('&nbsp;&nbsp;&nbsp;', $line->qty-1);
2592
+								echo str_repeat('&nbsp;&nbsp;&nbsp;', $line->qty - 1);
2593 2593
 
2594 2594
 								if (TSubtotal::isTitle($line)) print img_picto('', 'subtotal@subtotal').'<span style="font-size:9px;margin-left:-3px;">'.$line->qty.'</span>&nbsp;&nbsp;';
2595
-								else print img_picto('', 'subtotal2@subtotal').'<span style="font-size:9px;margin-left:-1px;">'.(100-$line->qty).'</span>&nbsp;&nbsp;';
2595
+								else print img_picto('', 'subtotal2@subtotal').'<span style="font-size:9px;margin-left:-1px;">'.(100 - $line->qty).'</span>&nbsp;&nbsp;';
2596 2596
 							}
2597 2597
 						 }
2598 2598
 						 else
2599 2599
 						 {
2600
-							if($line->qty<=1) print img_picto('', 'subtotal@subtotal');
2601
-							else if($line->qty==2) print img_picto('', 'subsubtotal@subtotal').'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
2600
+							if ($line->qty <= 1) print img_picto('', 'subtotal@subtotal');
2601
+							else if ($line->qty == 2) print img_picto('', 'subsubtotal@subtotal').'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
2602 2602
 						 }
2603 2603
 
2604 2604
 
2605 2605
 						 // Get display styles and apply them
2606 2606
 						 $titleStyleItalic = strpos($conf->global->SUBTOTAL_TITLE_STYLE, 'I') === false ? '' : ' font-style: italic;';
2607
-						 $titleStyleBold =  strpos($conf->global->SUBTOTAL_TITLE_STYLE, 'B') === false ? '' : ' font-weight:bold;';
2608
-						 $titleStyleUnderline =  strpos($conf->global->SUBTOTAL_TITLE_STYLE, 'U') === false ? '' : ' text-decoration: underline;';
2607
+						 $titleStyleBold = strpos($conf->global->SUBTOTAL_TITLE_STYLE, 'B') === false ? '' : ' font-weight:bold;';
2608
+						 $titleStyleUnderline = strpos($conf->global->SUBTOTAL_TITLE_STYLE, 'U') === false ? '' : ' text-decoration: underline;';
2609 2609
 
2610 2610
 						 if (empty($line->label)) {
2611 2611
 							if ($line->qty >= 91 && $line->qty <= 99 && $conf->global->SUBTOTAL_USE_NEW_FORMAT) print  $line->description.' '.$this->getTitle($object, $line);
@@ -2613,22 +2613,22 @@  discard block
 block discarded – undo
2613 2613
 						 }
2614 2614
 						 else {
2615 2615
 
2616
-							if (! empty($conf->global->PRODUIT_DESC_IN_FORM) && !empty($line->description)) {
2616
+							if (!empty($conf->global->PRODUIT_DESC_IN_FORM) && !empty($line->description)) {
2617 2617
 								print '<span class="subtotal_label" style="'.$titleStyleItalic.$titleStyleBold.$titleStyleUnderline.'" >'.$line->label.'</span><br><div class="subtotal_desc">'.dol_htmlentitiesbr($line->description).'</div>';
2618 2618
 							}
2619
-							else{
2619
+							else {
2620 2620
 								print '<span class="subtotal_label classfortooltip '.$titleStyleItalic.$titleStyleBold.$titleStyleUnderline.'" title="'.$line->description.'">'.$line->label.'</span>';
2621 2621
 							}
2622 2622
 
2623 2623
 						 }
2624 2624
 						//if($line->qty>90) print ' : ';
2625
-						if($line->info_bits > 0) echo img_picto($langs->trans('Pagebreak'), 'pagebreak@subtotal');
2625
+						if ($line->info_bits > 0) echo img_picto($langs->trans('Pagebreak'), 'pagebreak@subtotal');
2626 2626
 
2627 2627
 			?>
2628 2628
 				</td>
2629 2629
 				 <td colspan="<?php echo $colspan; ?>">
2630 2630
 <?php
2631
-						if(in_array('expeditioncard', $contexts) && $action == 'create')
2631
+						if (in_array('expeditioncard', $contexts) && $action == 'create')
2632 2632
 						{
2633 2633
 							$fk_entrepot = GETPOST('entrepot_id', 'int');
2634 2634
 ?>
@@ -2655,106 +2655,106 @@  discard block
 block discarded – undo
2655 2655
 			$shipment_static = new Expedition($db);
2656 2656
 			$warehousestatic = new Entrepot($db);
2657 2657
 			$extrafieldsline = new ExtraFields($db);
2658
-			$extralabelslines=$extrafieldsline->fetch_name_optionals_label($object->table_element_line);
2658
+			$extralabelslines = $extrafieldsline->fetch_name_optionals_label($object->table_element_line);
2659 2659
 
2660 2660
 			$colspan = 4;
2661
-			if($object->origin && $object->origin_id > 0) $colspan++;
2662
-			if(! empty($conf->stock->enabled)) $colspan++;
2663
-			if(! empty($conf->productbatch->enabled)) $colspan++;
2664
-			if($object->statut == 0) $colspan++;
2665
-			if($object->statut == 0 && empty($conf->global->SUBTOTAL_ALLOW_REMOVE_BLOCK)) $colspan++;
2661
+			if ($object->origin && $object->origin_id > 0) $colspan++;
2662
+			if (!empty($conf->stock->enabled)) $colspan++;
2663
+			if (!empty($conf->productbatch->enabled)) $colspan++;
2664
+			if ($object->statut == 0) $colspan++;
2665
+			if ($object->statut == 0 && empty($conf->global->SUBTOTAL_ALLOW_REMOVE_BLOCK)) $colspan++;
2666 2666
 
2667
-			if($object->element == 'delivery') $colspan = 2;
2667
+			if ($object->element == 'delivery') $colspan = 2;
2668 2668
 
2669 2669
 			print '<!-- origin line id = '.$line->origin_line_id.' -->'; // id of order line
2670 2670
 
2671 2671
 			// HTML 5 data for js
2672 2672
 			$data = $this->_getHtmlData($parameters, $object, $action, $hookmanager);
2673 2673
 			?>
2674
-			<tr <?php echo $bc[$var]; $var=!$var; echo $data; ?> rel="subtotal" id="row-<?php echo $line->id ?>" style="<?php
2674
+			<tr <?php echo $bc[$var]; $var = !$var; echo $data; ?> rel="subtotal" id="row-<?php echo $line->id ?>" style="<?php
2675 2675
 					if (!empty($conf->global->SUBTOTAL_USE_NEW_FORMAT))
2676 2676
 					{
2677
-						if($line->qty==99) print 'background:#adadcf';
2678
-						else if($line->qty==98) print 'background:#ddddff;';
2679
-						else if($line->qty<=97 && $line->qty>=91) print 'background:#eeeeff;';
2680
-						else if($line->qty==1) print 'background:#adadcf;';
2681
-						else if($line->qty==2) print 'background:#ddddff;';
2682
-						else if($line->qty==50) print '';
2677
+						if ($line->qty == 99) print 'background:#adadcf';
2678
+						else if ($line->qty == 98) print 'background:#ddddff;';
2679
+						else if ($line->qty <= 97 && $line->qty >= 91) print 'background:#eeeeff;';
2680
+						else if ($line->qty == 1) print 'background:#adadcf;';
2681
+						else if ($line->qty == 2) print 'background:#ddddff;';
2682
+						else if ($line->qty == 50) print '';
2683 2683
 						else print 'background:#eeeeff;';
2684 2684
 
2685 2685
 						//A compléter si on veux plus de nuances de couleurs avec les niveau 4,5,6,7,8 et 9
2686 2686
 					}
2687 2687
 					else
2688 2688
 					{
2689
-						if($line->qty==99) print 'background:#ddffdd';
2690
-						else if($line->qty==98) print 'background:#ddddff;';
2691
-						else if($line->qty==2) print 'background:#eeeeff; ';
2692
-						else if($line->qty==50) print '';
2693
-						else print 'background:#eeffee;' ;
2689
+						if ($line->qty == 99) print 'background:#ddffdd';
2690
+						else if ($line->qty == 98) print 'background:#ddddff;';
2691
+						else if ($line->qty == 2) print 'background:#eeeeff; ';
2692
+						else if ($line->qty == 50) print '';
2693
+						else print 'background:#eeffee;';
2694 2694
 					}
2695 2695
 
2696 2696
 			?>;">
2697 2697
 
2698 2698
 			<?php
2699 2699
 			// #
2700
-			if (! empty($conf->global->MAIN_VIEW_LINE_NUMBER))
2700
+			if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER))
2701 2701
 			{
2702
-				print '<td align="center">'.($i+1).'</td>';
2702
+				print '<td align="center">'.($i + 1).'</td>';
2703 2703
 			}
2704 2704
 			?>
2705 2705
 
2706
-			<td style="<?php TSubtotal::isFreeText($line) ? '' : 'font-weight:bold;'; ?>  <?php echo ($line->qty>90)?'text-align:right':'' ?> "><?php
2706
+			<td style="<?php TSubtotal::isFreeText($line) ? '' : 'font-weight:bold;'; ?>  <?php echo ($line->qty > 90) ? 'text-align:right' : '' ?> "><?php
2707 2707
 
2708 2708
 
2709 2709
 			if ($conf->global->SUBTOTAL_USE_NEW_FORMAT)
2710 2710
 			{
2711
-				if(TSubtotal::isTitle($line) || TSubtotal::isSubtotal($line))
2711
+				if (TSubtotal::isTitle($line) || TSubtotal::isSubtotal($line))
2712 2712
 				{
2713
-					echo str_repeat('&nbsp;&nbsp;&nbsp;', $line->qty-1);
2713
+					echo str_repeat('&nbsp;&nbsp;&nbsp;', $line->qty - 1);
2714 2714
 
2715 2715
 					if (TSubtotal::isTitle($line)) print img_picto('', 'subtotal@subtotal').'<span style="font-size:9px;margin-left:-3px;">'.$line->qty.'</span>&nbsp;&nbsp;';
2716
-					else print img_picto('', 'subtotal2@subtotal').'<span style="font-size:9px;margin-left:-1px;">'.(100-$line->qty).'</span>&nbsp;&nbsp;';
2716
+					else print img_picto('', 'subtotal2@subtotal').'<span style="font-size:9px;margin-left:-1px;">'.(100 - $line->qty).'</span>&nbsp;&nbsp;';
2717 2717
 				}
2718 2718
 			}
2719 2719
 			else
2720 2720
 			{
2721
-				if($line->qty<=1) print img_picto('', 'subtotal@subtotal');
2722
-				else if($line->qty==2) print img_picto('', 'subsubtotal@subtotal').'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
2721
+				if ($line->qty <= 1) print img_picto('', 'subtotal@subtotal');
2722
+				else if ($line->qty == 2) print img_picto('', 'subsubtotal@subtotal').'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
2723 2723
 			}
2724 2724
 
2725 2725
 
2726 2726
 			// Get display styles and apply them
2727 2727
 			$titleStyleItalic = strpos($conf->global->SUBTOTAL_TITLE_STYLE, 'I') === false ? '' : ' font-style: italic;';
2728
-			$titleStyleBold =  strpos($conf->global->SUBTOTAL_TITLE_STYLE, 'B') === false ? '' : ' font-weight:bold;';
2729
-			$titleStyleUnderline =  strpos($conf->global->SUBTOTAL_TITLE_STYLE, 'U') === false ? '' : ' text-decoration: underline;';
2728
+			$titleStyleBold = strpos($conf->global->SUBTOTAL_TITLE_STYLE, 'B') === false ? '' : ' font-weight:bold;';
2729
+			$titleStyleUnderline = strpos($conf->global->SUBTOTAL_TITLE_STYLE, 'U') === false ? '' : ' text-decoration: underline;';
2730 2730
 
2731 2731
 			if (empty($line->label)) {
2732 2732
 				if ($line->qty >= 91 && $line->qty <= 99 && $conf->global->SUBTOTAL_USE_NEW_FORMAT) print  $line->description.' '.$this->getTitle($object, $line);
2733 2733
 				else print  $line->description;
2734 2734
 			}
2735 2735
 			else {
2736
-				if (! empty($conf->global->PRODUIT_DESC_IN_FORM) && !empty($line->description)) {
2736
+				if (!empty($conf->global->PRODUIT_DESC_IN_FORM) && !empty($line->description)) {
2737 2737
 					print '<span class="subtotal_label" style="'.$titleStyleItalic.$titleStyleBold.$titleStyleUnderline.'" >'.$line->label.'</span><br><div class="subtotal_desc">'.dol_htmlentitiesbr($line->description).'</div>';
2738 2738
 				}
2739
-				else{
2739
+				else {
2740 2740
 					print '<span class="subtotal_label classfortooltip '.$titleStyleItalic.$titleStyleBold.$titleStyleUnderline.'" title="'.$line->description.'">'.$line->label.'</span>';
2741 2741
 				}
2742 2742
 			}
2743 2743
 			//if($line->qty>90) print ' : ';
2744
-			if($line->info_bits > 0) echo img_picto($langs->trans('Pagebreak'), 'pagebreak@subtotal');
2744
+			if ($line->info_bits > 0) echo img_picto($langs->trans('Pagebreak'), 'pagebreak@subtotal');
2745 2745
 
2746 2746
 			?>
2747 2747
 				</td>
2748 2748
 				<td colspan="<?php echo $colspan; ?>">&nbsp;</td>
2749 2749
 			<?php
2750 2750
 
2751
-			if ($object->element == 'shipping' && $object->statut == 0 && ! empty($conf->global->SUBTOTAL_ALLOW_REMOVE_BLOCK))
2751
+			if ($object->element == 'shipping' && $object->statut == 0 && !empty($conf->global->SUBTOTAL_ALLOW_REMOVE_BLOCK))
2752 2752
 			{
2753 2753
 				print '<td class="linecoldelete nowrap" width="10">';
2754 2754
 				$lineid = $line->id;
2755
-				if($line->element === 'commandedet') {
2756
-					foreach($object->lines as $shipmentLine) {
2757
-						if(!empty($shipmentLine->fk_origin_line) && $shipmentLine->fk_origin == 'orderline' && $shipmentLine->fk_origin_line == $line->id) {
2755
+				if ($line->element === 'commandedet') {
2756
+					foreach ($object->lines as $shipmentLine) {
2757
+						if (!empty($shipmentLine->fk_origin_line) && $shipmentLine->fk_origin == 'orderline' && $shipmentLine->fk_origin_line == $line->id) {
2758 2758
 							$lineid = $shipmentLine->id;
2759 2759
 						}
2760 2760
 					}
@@ -2764,12 +2764,12 @@  discard block
 block discarded – undo
2764 2764
 					echo '<a href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&amp;action=deleteline&amp;lineid='.$lineid.'">'.img_delete().'</a>';
2765 2765
 				}
2766 2766
 
2767
-				if(TSubtotal::isTitle($line) && ($line->fk_prev_id === null) )
2767
+				if (TSubtotal::isTitle($line) && ($line->fk_prev_id === null))
2768 2768
 				{
2769 2769
 					if ((float) DOL_VERSION >= 8.0) {
2770 2770
 						$img_delete = img_delete($langs->trans('deleteWithAllLines'), ' style="color:#be3535 !important;" class="pictodelete pictodeleteallline"');
2771 2771
 					} elseif ((float) DOL_VERSION >= 3.8) {
2772
-						$img_delete = img_picto($langs->trans('deleteWithAllLines'), 'delete_all.3.8@subtotal',' class="pictodelete" ');
2772
+						$img_delete = img_picto($langs->trans('deleteWithAllLines'), 'delete_all.3.8@subtotal', ' class="pictodelete" ');
2773 2773
 					} else {
2774 2774
 						$img_delete = img_picto($langs->trans('deleteWithAllLines'), 'delete_all@subtotal');
2775 2775
 					}
@@ -2783,11 +2783,11 @@  discard block
 block discarded – undo
2783 2783
 			print "</tr>";
2784 2784
 
2785 2785
 			// Display lines extrafields
2786
-			if ($object->element == 'shipping' && ! empty($conf->global->SUBTOTAL_ALLOW_EXTRAFIELDS_ON_TITLE) && is_array($extralabelslines) && count($extralabelslines)>0) {
2786
+			if ($object->element == 'shipping' && !empty($conf->global->SUBTOTAL_ALLOW_EXTRAFIELDS_ON_TITLE) && is_array($extralabelslines) && count($extralabelslines) > 0) {
2787 2787
 				$line = new ExpeditionLigne($db);
2788 2788
 				$line->fetch_optionals($line->id);
2789 2789
 				print '<tr class="oddeven">';
2790
-				print $line->showOptionals($extrafieldsline, 'view', array('style'=>$bc[$var], 'colspan'=>$colspan),$i);
2790
+				print $line->showOptionals($extrafieldsline, 'view', array('style'=>$bc[$var], 'colspan'=>$colspan), $i);
2791 2791
 			}
2792 2792
 
2793 2793
 			return 1;
@@ -2799,20 +2799,20 @@  discard block
 block discarded – undo
2799 2799
 
2800 2800
 	function printOriginObjectLine($parameters, &$object, &$action, $hookmanager)
2801 2801
 	{
2802
-		global $conf,$langs,$user,$db,$bc, $restrictlist, $selectedLines;
2802
+		global $conf, $langs, $user, $db, $bc, $restrictlist, $selectedLines;
2803 2803
 
2804 2804
 		$line = &$parameters['line'];
2805 2805
 		$i = &$parameters['i'];
2806 2806
 
2807 2807
 		$var = &$parameters['var'];
2808 2808
 
2809
-		$contexts = explode(':',$parameters['context']);
2809
+		$contexts = explode(':', $parameters['context']);
2810 2810
 
2811
-		if (in_array('ordercard',$contexts) || in_array('invoicecard',$contexts))
2811
+		if (in_array('ordercard', $contexts) || in_array('invoicecard', $contexts))
2812 2812
 		{
2813 2813
 			/** @var Commande $object */
2814 2814
 
2815
-			if(class_exists('TSubtotal')){ dol_include_once('/subtotal/class/subtotal.class.php'); }
2815
+			if (class_exists('TSubtotal')) { dol_include_once('/subtotal/class/subtotal.class.php'); }
2816 2816
 
2817 2817
 			if (TSubtotal::isModSubtotalLine($line))
2818 2818
 			{
@@ -2823,69 +2823,69 @@  discard block
 block discarded – undo
2823 2823
 				$object->tpl['sub-tr-style'] = '';
2824 2824
 				if (!empty($conf->global->SUBTOTAL_USE_NEW_FORMAT))
2825 2825
 				{
2826
-					if($line->qty==99) $object->tpl['sub-tr-style'].= 'background:#adadcf';
2827
-					else if($line->qty==98) $object->tpl['sub-tr-style'].= 'background:#ddddff;';
2828
-					else if($line->qty<=97 && $line->qty>=91) $object->tpl['sub-tr-style'].= 'background:#eeeeff;';
2829
-					else if($line->qty==1) $object->tpl['sub-tr-style'].= 'background:#adadcf;';
2830
-					else if($line->qty==2) $object->tpl['sub-tr-style'].= 'background:#ddddff;';
2831
-					else if($line->qty==50) $object->tpl['sub-tr-style'].= '';
2832
-					else $object->tpl['sub-tr-style'].= 'background:#eeeeff;';
2826
+					if ($line->qty == 99) $object->tpl['sub-tr-style'] .= 'background:#adadcf';
2827
+					else if ($line->qty == 98) $object->tpl['sub-tr-style'] .= 'background:#ddddff;';
2828
+					else if ($line->qty <= 97 && $line->qty >= 91) $object->tpl['sub-tr-style'] .= 'background:#eeeeff;';
2829
+					else if ($line->qty == 1) $object->tpl['sub-tr-style'] .= 'background:#adadcf;';
2830
+					else if ($line->qty == 2) $object->tpl['sub-tr-style'] .= 'background:#ddddff;';
2831
+					else if ($line->qty == 50) $object->tpl['sub-tr-style'] .= '';
2832
+					else $object->tpl['sub-tr-style'] .= 'background:#eeeeff;';
2833 2833
 
2834 2834
 					//A compléter si on veux plus de nuances de couleurs avec les niveau 4,5,6,7,8 et 9
2835 2835
 				}
2836 2836
 				else
2837 2837
 				{
2838
-					if($line->qty==99) $object->tpl['sub-tr-style'].= 'background:#ddffdd';
2839
-					else if($line->qty==98) $object->tpl['sub-tr-style'].= 'background:#ddddff;';
2840
-					else if($line->qty==2) $object->tpl['sub-tr-style'].= 'background:#eeeeff; ';
2841
-					else if($line->qty==50) $object->tpl['sub-tr-style'].= '';
2842
-					else $object->tpl['sub-tr-style'].= 'background:#eeffee;' ;
2838
+					if ($line->qty == 99) $object->tpl['sub-tr-style'] .= 'background:#ddffdd';
2839
+					else if ($line->qty == 98) $object->tpl['sub-tr-style'] .= 'background:#ddddff;';
2840
+					else if ($line->qty == 2) $object->tpl['sub-tr-style'] .= 'background:#eeeeff; ';
2841
+					else if ($line->qty == 50) $object->tpl['sub-tr-style'] .= '';
2842
+					else $object->tpl['sub-tr-style'] .= 'background:#eeffee;';
2843 2843
 				}
2844 2844
 
2845 2845
 				$object->tpl['sub-td-style'] = '';
2846
-				if ($line->qty>90) $object->tpl['sub-td-style'] = 'style="text-align:right"';
2846
+				if ($line->qty > 90) $object->tpl['sub-td-style'] = 'style="text-align:right"';
2847 2847
 
2848 2848
 
2849 2849
 				if ($conf->global->SUBTOTAL_USE_NEW_FORMAT)
2850 2850
 				{
2851
-					if(TSubtotal::isTitle($line) || TSubtotal::isSubtotal($line))
2851
+					if (TSubtotal::isTitle($line) || TSubtotal::isSubtotal($line))
2852 2852
 					{
2853
-						$object->tpl["sublabel"] = str_repeat('&nbsp;&nbsp;&nbsp;', $line->qty-1);
2853
+						$object->tpl["sublabel"] = str_repeat('&nbsp;&nbsp;&nbsp;', $line->qty - 1);
2854 2854
 
2855
-						if (TSubtotal::isTitle($line)) $object->tpl["sublabel"].= img_picto('', 'subtotal@subtotal').'<span style="font-size:9px;margin-left:-3px;">'.$line->qty.'</span>&nbsp;&nbsp;';
2856
-						else $object->tpl["sublabel"].= img_picto('', 'subtotal2@subtotal').'<span style="font-size:9px;margin-left:-1px;">'.(100-$line->qty).'</span>&nbsp;&nbsp;';
2855
+						if (TSubtotal::isTitle($line)) $object->tpl["sublabel"] .= img_picto('', 'subtotal@subtotal').'<span style="font-size:9px;margin-left:-3px;">'.$line->qty.'</span>&nbsp;&nbsp;';
2856
+						else $object->tpl["sublabel"] .= img_picto('', 'subtotal2@subtotal').'<span style="font-size:9px;margin-left:-1px;">'.(100 - $line->qty).'</span>&nbsp;&nbsp;';
2857 2857
 					}
2858 2858
 				}
2859 2859
 				else
2860 2860
 				{
2861 2861
 					$object->tpl["sublabel"] = '';
2862
-					if($line->qty<=1) $object->tpl["sublabel"] = img_picto('', 'subtotal@subtotal');
2863
-					else if($line->qty==2) $object->tpl["sublabel"] = img_picto('', 'subsubtotal@subtotal').'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
2862
+					if ($line->qty <= 1) $object->tpl["sublabel"] = img_picto('', 'subtotal@subtotal');
2863
+					else if ($line->qty == 2) $object->tpl["sublabel"] = img_picto('', 'subsubtotal@subtotal').'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
2864 2864
 				}
2865 2865
 
2866 2866
 				// Get display styles and apply them
2867 2867
 				$titleStyleItalic = strpos($conf->global->SUBTOTAL_TITLE_STYLE, 'I') === false ? '' : ' font-style: italic;';
2868
-				$titleStyleBold =  strpos($conf->global->SUBTOTAL_TITLE_STYLE, 'B') === false ? '' : ' font-weight:bold;';
2869
-				$titleStyleUnderline =  strpos($conf->global->SUBTOTAL_TITLE_STYLE, 'U') === false ? '' : ' text-decoration: underline;';
2868
+				$titleStyleBold = strpos($conf->global->SUBTOTAL_TITLE_STYLE, 'B') === false ? '' : ' font-weight:bold;';
2869
+				$titleStyleUnderline = strpos($conf->global->SUBTOTAL_TITLE_STYLE, 'U') === false ? '' : ' text-decoration: underline;';
2870 2870
 
2871 2871
 				if (empty($line->label)) {
2872
-					if ($line->qty >= 91 && $line->qty <= 99 && $conf->global->SUBTOTAL_USE_NEW_FORMAT) $object->tpl["sublabel"].=  $line->description.' '.$this->getTitle($object, $line);
2873
-					else $object->tpl["sublabel"].=  $line->description;
2872
+					if ($line->qty >= 91 && $line->qty <= 99 && $conf->global->SUBTOTAL_USE_NEW_FORMAT) $object->tpl["sublabel"] .= $line->description.' '.$this->getTitle($object, $line);
2873
+					else $object->tpl["sublabel"] .= $line->description;
2874 2874
 				}
2875 2875
 				else {
2876 2876
 
2877
-					if (! empty($conf->global->PRODUIT_DESC_IN_FORM) && !empty($line->description)) {
2878
-						$object->tpl["sublabel"].= '<span class="subtotal_label" style="'.$titleStyleItalic.$titleStyleBold.$titleStyleUnderline.'" >'.$line->label.'</span><br><div class="subtotal_desc">'.dol_htmlentitiesbr($line->description).'</div>';
2877
+					if (!empty($conf->global->PRODUIT_DESC_IN_FORM) && !empty($line->description)) {
2878
+						$object->tpl["sublabel"] .= '<span class="subtotal_label" style="'.$titleStyleItalic.$titleStyleBold.$titleStyleUnderline.'" >'.$line->label.'</span><br><div class="subtotal_desc">'.dol_htmlentitiesbr($line->description).'</div>';
2879 2879
 					}
2880
-					else{
2881
-						$object->tpl["sublabel"].= '<span class="subtotal_label classfortooltip '.$titleStyleItalic.$titleStyleBold.$titleStyleUnderline.'" title="'.$line->description.'">'.$line->label.'</span>';
2880
+					else {
2881
+						$object->tpl["sublabel"] .= '<span class="subtotal_label classfortooltip '.$titleStyleItalic.$titleStyleBold.$titleStyleUnderline.'" title="'.$line->description.'">'.$line->label.'</span>';
2882 2882
 					}
2883 2883
 
2884 2884
 				}
2885
-				if($line->qty>90)
2885
+				if ($line->qty > 90)
2886 2886
 				{
2887 2887
 					$total = $this->getTotalLineFromObject($object, $line, '');
2888
-					$object->tpl["sublabel"].= ' : <b>'.$total.'</b>';
2888
+					$object->tpl["sublabel"] .= ' : <b>'.$total.'</b>';
2889 2889
 				}
2890 2890
 
2891 2891
 
@@ -2906,20 +2906,20 @@  discard block
 block discarded – undo
2906 2906
 
2907 2907
 
2908 2908
 	function addMoreActionsButtons($parameters, &$object, &$action, $hookmanager) {
2909
-		global $conf,$langs;
2909
+		global $conf, $langs;
2910 2910
 
2911 2911
 		if ($object->statut == 0 && !empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && $action != 'editline')
2912 2912
 		{
2913 2913
 
2914
-		    if($object->element == 'invoice_supplier' || $object->element == 'order_supplier')
2914
+		    if ($object->element == 'invoice_supplier' || $object->element == 'order_supplier')
2915 2915
 		    {
2916 2916
 		        foreach ($object->lines as $line)
2917 2917
 		        {
2918 2918
 		            // fetch optionals attributes and labels
2919 2919
 		            require_once(DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php');
2920
-		            $extrafields=new ExtraFields($this->db);
2921
-		            $extralabels=$extrafields->fetch_name_optionals_label($object->table_element_line,true);
2922
-		            $line->fetch_optionals($line->id,$extralabels);
2920
+		            $extrafields = new ExtraFields($this->db);
2921
+		            $extralabels = $extrafields->fetch_name_optionals_label($object->table_element_line, true);
2922
+		            $line->fetch_optionals($line->id, $extralabels);
2923 2923
 		        }
2924 2924
 		    }
2925 2925
 
@@ -3021,7 +3021,7 @@  discard block
 block discarded – undo
3021 3021
 	function getlinetotalremise($parameters, &$object, &$action, $hookmanager)
3022 3022
 	{
3023 3023
 	    // Les lignes NC ne sont pas censées afficher de montant total de remise, nouveau hook en v11 dans pdf_sponge
3024
-	    if (! empty($object->lines[$parameters['i']]->array_options['options_subtotal_nc']))
3024
+	    if (!empty($object->lines[$parameters['i']]->array_options['options_subtotal_nc']))
3025 3025
 	    {
3026 3026
             $this->resprints = '';
3027 3027
             return 1;
@@ -3042,23 +3042,23 @@  discard block
 block discarded – undo
3042 3042
 	    $ThtmlData['data-qty']          = 0; //$line->qty;
3043 3043
 	    $ThtmlData['data-level']        = TSubtotal::getNiveau($line);
3044 3044
 
3045
-	    if(TSubtotal::isTitle($line)){
3045
+	    if (TSubtotal::isTitle($line)) {
3046 3046
 	        $ThtmlData['data-issubtotal'] = 'title';
3047
-	    }elseif(TSubtotal::isSubtotal($line)){
3047
+	    }elseif (TSubtotal::isSubtotal($line)) {
3048 3048
 	        $ThtmlData['data-issubtotal'] = 'subtotal';
3049 3049
 	    }
3050
-	    else{
3050
+	    else {
3051 3051
 	        $ThtmlData['data-issubtotal'] = 'freetext';
3052 3052
 	    }
3053 3053
 
3054 3054
 
3055 3055
 	    // Change or add data  from hooks
3056
-	    $parameters = array_replace($parameters , array(  'ThtmlData' => $ThtmlData )  );
3056
+	    $parameters = array_replace($parameters, array('ThtmlData' => $ThtmlData));
3057 3057
 
3058 3058
 	    // hook
3059
-	    $reshook = $hookmanager->executeHooks('subtotalLineHtmlData',$parameters,$object,$action); // Note that $action and $object may have been modified by hook
3059
+	    $reshook = $hookmanager->executeHooks('subtotalLineHtmlData', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
3060 3060
 	    if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
3061
-	    if ($reshook>0)
3061
+	    if ($reshook > 0)
3062 3062
 	    {
3063 3063
 	        $ThtmlData = $hookmanager->resArray;
3064 3064
 	    }
@@ -3071,14 +3071,14 @@  discard block
 block discarded – undo
3071 3071
 	function implodeHtmlData($ThtmlData = array())
3072 3072
 	{
3073 3073
 	    $data = '';
3074
-	    foreach($ThtmlData as $k => $h )
3074
+	    foreach ($ThtmlData as $k => $h)
3075 3075
 	    {
3076
-	        if(is_array($h))
3076
+	        if (is_array($h))
3077 3077
 	        {
3078 3078
 	            $h = json_encode($h);
3079 3079
 	        }
3080 3080
 
3081
-	        $data .= $k . '="'.dol_htmlentities($h, ENT_QUOTES).'" ';
3081
+	        $data .= $k.'="'.dol_htmlentities($h, ENT_QUOTES).'" ';
3082 3082
 	    }
3083 3083
 
3084 3084
 	    return $data;
@@ -3086,26 +3086,26 @@  discard block
 block discarded – undo
3086 3086
 
3087 3087
 	function _ajax_block_order_js($object)
3088 3088
 	{
3089
-	    global $conf,$tagidfortablednd,$filepath,$langs;
3089
+	    global $conf, $tagidfortablednd, $filepath, $langs;
3090 3090
 
3091 3091
 	    /*
3092 3092
 	     * this part of js is base on dolibarr htdocs/core/tpl/ajaxrow.tpl.php
3093 3093
 	     * for compatibility reasons we don't use tableDnD but jquery sortable
3094 3094
 	     */
3095 3095
 
3096
-	    $id=$object->id;
3097
-	    $nboflines=(isset($object->lines)?count($object->lines):0);
3098
-	    $forcereloadpage=empty($conf->global->MAIN_FORCE_RELOAD_PAGE)?0:1;
3096
+	    $id = $object->id;
3097
+	    $nboflines = (isset($object->lines) ?count($object->lines) : 0);
3098
+	    $forcereloadpage = empty($conf->global->MAIN_FORCE_RELOAD_PAGE) ? 0 : 1;
3099 3099
 
3100
-	    $id=$object->id;
3101
-	    $fk_element=$object->fk_element;
3102
-	    $table_element_line=$object->table_element_line;
3103
-	    $nboflines=(isset($object->lines)?count($object->lines):(empty($nboflines)?0:$nboflines));
3104
-	    $tagidfortablednd=(empty($tagidfortablednd)?'tablelines':$tagidfortablednd);
3105
-	    $filepath=(empty($filepath)?'':$filepath);
3100
+	    $id = $object->id;
3101
+	    $fk_element = $object->fk_element;
3102
+	    $table_element_line = $object->table_element_line;
3103
+	    $nboflines = (isset($object->lines) ?count($object->lines) : (empty($nboflines) ? 0 : $nboflines));
3104
+	    $tagidfortablednd = (empty($tagidfortablednd) ? 'tablelines' : $tagidfortablednd);
3105
+	    $filepath = (empty($filepath) ? '' : $filepath);
3106 3106
 
3107 3107
 
3108
-	    if (GETPOST('action','aZ09') != 'editline' && $nboflines > 1)
3108
+	    if (GETPOST('action', 'aZ09') != 'editline' && $nboflines > 1)
3109 3109
 	    {
3110 3110
 
3111 3111
 	        ?>
@@ -3123,7 +3123,7 @@  discard block
 block discarded – undo
3123 3123
 				moveBlockCol.disableSelection(); // prevent selection
3124 3124
 <?php if ($object->statut == 0) { ?>
3125 3125
 				// apply some graphical stuff
3126
-				moveBlockCol.css("background-image",'url(<?php echo dol_buildpath('subtotal/img/grip_all.png',2);  ?>)');
3126
+				moveBlockCol.css("background-image",'url(<?php echo dol_buildpath('subtotal/img/grip_all.png', 2); ?>)');
3127 3127
 				moveBlockCol.css("background-repeat","no-repeat");
3128 3128
 				moveBlockCol.css("background-position","center center");
3129 3129
 				moveBlockCol.css("cursor","move");
@@ -3270,20 +3270,20 @@  discard block
 block discarded – undo
3270 3270
      * @param $action
3271 3271
      * @param $hookmanager
3272 3272
      */
3273
-	function handleExpeditionTitleAndTotal($parameters, &$object, &$action, $hookmanager){
3273
+	function handleExpeditionTitleAndTotal($parameters, &$object, &$action, $hookmanager) {
3274 3274
         global $conf;
3275 3275
         //var_dump($parameters['line']);
3276 3276
 	    dol_include_once('subtotal/class/subtotal.class.php');
3277 3277
         $currentcontext = explode(':', $parameters['context']);
3278 3278
 
3279
-	    if ( in_array('shippableorderlist',$currentcontext)) {
3279
+	    if (in_array('shippableorderlist', $currentcontext)) {
3280 3280
 
3281 3281
             //var_dump($parameters['line']);
3282
-            if(TSubtotal::isModSubtotalLine($parameters['line'])) {
3282
+            if (TSubtotal::isModSubtotalLine($parameters['line'])) {
3283 3283
 
3284 3284
                 $confOld = $conf->global->STOCK_MUST_BE_ENOUGH_FOR_SHIPMENT;
3285 3285
                 $conf->global->STOCK_MUST_BE_ENOUGH_FOR_SHIPMENT = 0;
3286
-                $res =  $parameters['shipping']->addline($parameters['TEnt_comm'][$object->order->id], $parameters['line']->id, $parameters['line']->qty);
3286
+                $res = $parameters['shipping']->addline($parameters['TEnt_comm'][$object->order->id], $parameters['line']->id, $parameters['line']->qty);
3287 3287
                 $conf->global->STOCK_MUST_BE_ENOUGH_FOR_SHIPMENT = $confOld;
3288 3288
             }
3289 3289
 
@@ -3311,7 +3311,7 @@  discard block
 block discarded – undo
3311 3311
 		$parameters['object']->subtotalPdfModelInfo->marge_gauche 	= $pdfDoc->marge_gauche;
3312 3312
 		$parameters['object']->subtotalPdfModelInfo->page_largeur 	= $pdfDoc->page_largeur;
3313 3313
 		$parameters['object']->subtotalPdfModelInfo->page_hauteur 	= $pdfDoc->page_hauteur;
3314
-		$parameters['object']->subtotalPdfModelInfo->format 		= $pdfDoc->format;
3314
+		$parameters['object']->subtotalPdfModelInfo->format = $pdfDoc->format;
3315 3315
 		$parameters['object']->subtotalPdfModelInfo->defaultTitlesFieldsStyle = $pdfDoc->subtotalPdfModelInfo->defaultTitlesFieldsStyle;
3316 3316
 		$parameters['object']->subtotalPdfModelInfo->defaultContentsFieldsStyle = $pdfDoc->subtotalPdfModelInfo->defaultContentsFieldsStyle;
3317 3317
 
Please login to merge, or discard this patch.
Braces   +603 added lines, -354 removed lines patch added patch discarded remove patch
@@ -49,7 +49,9 @@  discard block
 block discarded – undo
49 49
 				$value = '';
50 50
 				$sql = 'SELECT content FROM '.MAIN_DB_PREFIX.'c_subtotal_free_text WHERE rowid = '.GETPOST('rowid', 'int');
51 51
 				$resql = $this->db->query($sql);
52
-				if ($resql && ($obj = $this->db->fetch_object($resql))) $value = $obj->content;
52
+				if ($resql && ($obj = $this->db->fetch_object($resql))) {
53
+					$value = $obj->content;
54
+				}
53 55
 			}
54 56
 
55 57
 			?>
@@ -130,8 +132,7 @@  discard block
 block discarded – undo
130 132
 			} elseif($object->element == 'invoice_supplier' )
131 133
 			{
132 134
 			    $createRight = $user->rights->fournisseur->facture->creer;
133
-			}
134
-			elseif($object->element == 'shipping')
135
+			} elseif($object->element == 'shipping')
135 136
 			{
136 137
 				$createRight = true; // No rights management for shipments
137 138
 			}
@@ -139,8 +140,11 @@  discard block
 block discarded – undo
139 140
 			if ($object->statut == 0  && $createRight) {
140 141
 
141 142
 
142
-				if($object->element=='facture')$idvar = 'facid';
143
-				else $idvar='id';
143
+				if($object->element=='facture') {
144
+					$idvar = 'facid';
145
+				} else {
146
+					$idvar='id';
147
+				}
144 148
 
145 149
 				if(in_array($action, array('add_title_line', 'add_total_line', 'add_subtitle_line', 'add_subtotal_line', 'add_free_text')) )
146 150
 				{
@@ -148,10 +152,11 @@  discard block
 block discarded – undo
148 152
 
149 153
 					if($action=='add_title_line') {
150 154
 						$title = GETPOST('title', 'none');
151
-						if(empty($title)) $title = $langs->trans('title');
155
+						if(empty($title)) {
156
+							$title = $langs->trans('title');
157
+						}
152 158
 						$qty = $level<1 ? 1 : $level ;
153
-					}
154
-					else if($action=='add_free_text') {
159
+					} else if($action=='add_free_text') {
155 160
 						$title = GETPOST('title', 'restricthtml');
156 161
 
157 162
 						if (empty($title)) {
@@ -163,29 +168,31 @@  discard block
 block discarded – undo
163 168
 								}
164 169
 							}
165 170
 						}
166
-						if(empty($title)) $title = $langs->trans('subtotalAddLineDescription');
171
+						if(empty($title)) {
172
+							$title = $langs->trans('subtotalAddLineDescription');
173
+						}
167 174
 						$qty = 50;
168
-					}
169
-					else if($action=='add_subtitle_line') {
175
+					} else if($action=='add_subtitle_line') {
170 176
 						$title = GETPOST('title', 'none');
171
-						if(empty($title)) $title = $langs->trans('subtitle');
177
+						if(empty($title)) {
178
+							$title = $langs->trans('subtitle');
179
+						}
172 180
 						$qty = 2;
173
-					}
174
-					else if($action=='add_subtotal_line') {
181
+					} else if($action=='add_subtotal_line') {
175 182
 						$title = $langs->trans('SubSubTotal');
176 183
 						$qty = 98;
177
-					}
178
-					else {
184
+					} else {
179 185
 						$title = GETPOST('title', 'none') ? GETPOST('title', 'none') : $langs->trans('SubTotal');
180 186
 						$qty = $level ? 100-$level : 99;
181 187
 					}
182 188
 					dol_include_once('/subtotal/class/subtotal.class.php');
183 189
 
184
-					if (!empty($conf->global->SUBTOTAL_AUTO_ADD_SUBTOTAL_ON_ADDING_NEW_TITLE) && $qty < 10) TSubtotal::addSubtotalMissing($object, $qty);
190
+					if (!empty($conf->global->SUBTOTAL_AUTO_ADD_SUBTOTAL_ON_ADDING_NEW_TITLE) && $qty < 10) {
191
+						TSubtotal::addSubtotalMissing($object, $qty);
192
+					}
185 193
 
186 194
 	    			TSubtotal::addSubTotalLine($object, $title, $qty);
187
-				}
188
-				else if($action==='ask_deleteallline') {
195
+				} else if($action==='ask_deleteallline') {
189 196
 						$form=new Form($db);
190 197
 
191 198
 						$lineid = GETPOST('lineid','integer');
@@ -208,8 +215,7 @@  discard block
 block discarded – undo
208 215
 					$this->printNewFormat($object, $conf, $langs, $idvar);
209 216
 				}
210 217
 			}
211
-		}
212
-		elseif ((!empty($parameters['currentcontext']) && $parameters['currentcontext'] == 'orderstoinvoice') || in_array('orderstoinvoice',$contexts) || in_array('orderstoinvoicesupplier',$contexts))
218
+		} elseif ((!empty($parameters['currentcontext']) && $parameters['currentcontext'] == 'orderstoinvoice') || in_array('orderstoinvoice',$contexts) || in_array('orderstoinvoicesupplier',$contexts))
213 219
 		{
214 220
 			?>
215 221
 			<script type="text/javascript">
@@ -227,8 +233,13 @@  discard block
 block discarded – undo
227 233
 
228 234
 	function printNewFormat(&$object, &$conf, &$langs, $idvar)
229 235
 	{
230
-		if (empty($conf->global->SUBTOTAL_ALLOW_ADD_BLOCK)) return false;
231
-		if ($line->fk_prev_id != null && !empty($line->fk_prev_id)) return false; // Si facture de situation
236
+		if (empty($conf->global->SUBTOTAL_ALLOW_ADD_BLOCK)) {
237
+			return false;
238
+		}
239
+		if ($line->fk_prev_id != null && !empty($line->fk_prev_id)) {
240
+			return false;
241
+		}
242
+		// Si facture de situation
232 243
 		?>
233 244
 		 	<script type="text/javascript">
234 245
 				$(document).ready(function() {
@@ -524,8 +535,7 @@  discard block
 block discarded – undo
524 535
 				}
525 536
 
526 537
 
527
-			}
528
-			else{
538
+			} else{
529 539
 				$substitutionarray['line_not_modsubtotal'] = true;
530 540
 				$substitutionarray['line_modsubtotal'] = 0;
531 541
 			}
@@ -551,7 +561,9 @@  discard block
 block discarded – undo
551 561
 
552 562
 			$objFrom = $parameters['objFrom'];
553 563
 
554
-			if(empty($object->lines) && method_exists($object, 'fetch_lines')) $object->fetch_lines();
564
+			if(empty($object->lines) && method_exists($object, 'fetch_lines')) {
565
+				$object->fetch_lines();
566
+			}
555 567
 
556 568
 			foreach($objFrom->lines as $k=> &$lineOld) {
557 569
 
@@ -589,8 +601,11 @@  discard block
 block discarded – undo
589 601
 
590 602
 		$showBlockExtrafields = GETPOST('showBlockExtrafields', 'none');
591 603
 
592
-		if($object->element=='facture') $idvar = 'facid';
593
-		else $idvar = 'id';
604
+		if($object->element=='facture') {
605
+			$idvar = 'facid';
606
+		} else {
607
+			$idvar = 'id';
608
+		}
594 609
 
595 610
 		if ($action == 'updateligne' || $action == 'updateline')
596 611
 		{
@@ -620,8 +635,7 @@  discard block
 block discarded – undo
620 635
 				header('Location: '.$_SERVER['PHP_SELF'].'?'.$idvar.'='.$object->id);
621 636
 				exit; // Surtout ne pas laisser Dolibarr faire du traitement sur le updateligne sinon ça plante les données de la ligne
622 637
 			}
623
-		}
624
-		else if($action === 'builddoc') {
638
+		} else if($action === 'builddoc') {
625 639
 
626 640
 			if (
627 641
 				in_array('invoicecard',explode(':',$parameters['context']))
@@ -636,33 +650,27 @@  discard block
 block discarded – undo
636 650
 					$sessname = 'subtotal_hideInnerLines_facture';
637 651
 					$sessname2 = 'subtotal_hidedetails_facture';
638 652
 					$sessname3 = 'subtotal_hideprices_facture';
639
-				}
640
-				elseif(in_array('invoicesuppliercard',explode(':',$parameters['context']))) {
653
+				} elseif(in_array('invoicesuppliercard',explode(':',$parameters['context']))) {
641 654
 				    $sessname = 'subtotal_hideInnerLines_facture_fournisseur';
642 655
 				    $sessname2 = 'subtotal_hidedetails_facture_fournisseur';
643 656
 				    $sessname3 = 'subtotal_hideprices_facture_fournisseur';
644
-				}
645
-				elseif(in_array('propalcard',explode(':',$parameters['context']))) {
657
+				} elseif(in_array('propalcard',explode(':',$parameters['context']))) {
646 658
 					$sessname = 'subtotal_hideInnerLines_propal';
647 659
 					$sessname2 = 'subtotal_hidedetails_propal';
648 660
 					$sessname3 = 'subtotal_hideprices_propal';
649
-				}
650
-				elseif(in_array('supplier_proposalcard',explode(':',$parameters['context']))) {
661
+				} elseif(in_array('supplier_proposalcard',explode(':',$parameters['context']))) {
651 662
 				    $sessname = 'subtotal_hideInnerLines_supplier_proposal';
652 663
 				    $sessname2 = 'subtotal_hidedetails_supplier_proposal';
653 664
 				    $sessname3 = 'subtotal_hideprices_supplier_proposal';
654
-				}
655
-				elseif(in_array('ordercard',explode(':',$parameters['context']))) {
665
+				} elseif(in_array('ordercard',explode(':',$parameters['context']))) {
656 666
 					$sessname = 'subtotal_hideInnerLines_commande';
657 667
 					$sessname2 = 'subtotal_hidedetails_commande';
658 668
 					$sessname3 = 'subtotal_hideprices_commande';
659
-				}
660
-				elseif(in_array('ordersuppliercard',explode(':',$parameters['context']))) {
669
+				} elseif(in_array('ordersuppliercard',explode(':',$parameters['context']))) {
661 670
 				    $sessname = 'subtotal_hideInnerLines_commande_fournisseur';
662 671
 				    $sessname2 = 'subtotal_hidedetails_commande_fournisseur';
663 672
 				    $sessname3 = 'subtotal_hideprices_commande_fournisseur';
664
-				}
665
-				else {
673
+				} else {
666 674
 					$sessname = 'subtotal_hideInnerLines_unknown';
667 675
 					$sessname2 = 'subtotal_hidedetails_unknown';
668 676
 					$sessname3 = 'subtotal_hideprices_unknown';
@@ -671,15 +679,24 @@  discard block
 block discarded – undo
671 679
 				global $hideprices;
672 680
 
673 681
 				$hideInnerLines = GETPOST('hideInnerLines', 'int');
674
-				if(empty($_SESSION[$sessname]) || !is_array($_SESSION[$sessname][$object->id]) ) $_SESSION[$sessname] = array(); // prevent old system
682
+				if(empty($_SESSION[$sessname]) || !is_array($_SESSION[$sessname][$object->id]) ) {
683
+					$_SESSION[$sessname] = array();
684
+				}
685
+				// prevent old system
675 686
 				$_SESSION[$sessname][$object->id] = $hideInnerLines;
676 687
 
677 688
 				$hidedetails= GETPOST('hidedetails', 'int');
678
-				if(empty($_SESSION[$sessname2]) || !is_array($_SESSION[$sessname2][$object->id]) ) $_SESSION[$sessname2] = array(); // prevent old system
689
+				if(empty($_SESSION[$sessname2]) || !is_array($_SESSION[$sessname2][$object->id]) ) {
690
+					$_SESSION[$sessname2] = array();
691
+				}
692
+				// prevent old system
679 693
 				$_SESSION[$sessname2][$object->id] = $hidedetails;
680 694
 
681 695
 				$hideprices= GETPOST('hideprices', 'int');
682
-				if(empty($_SESSION[$sessname3]) || !is_array($_SESSION[$sessname3][$object->id]) ) $_SESSION[$sessname3] = array(); // prevent old system
696
+				if(empty($_SESSION[$sessname3]) || !is_array($_SESSION[$sessname3][$object->id]) ) {
697
+					$_SESSION[$sessname3] = array();
698
+				}
699
+				// prevent old system
683 700
 				$_SESSION[$sessname3][$object->id] = $hideprices;
684 701
 
685 702
 				foreach($object->lines as &$line) {
@@ -687,8 +704,7 @@  discard block
 block discarded – undo
687 704
 
688 705
                         if($line->qty>=90) {
689 706
                             $line->modsubtotal_total = 1;
690
-                        }
691
-                        else{
707
+                        } else{
692 708
                             $line->modsubtotal_title = 1;
693 709
                         }
694 710
 
@@ -697,8 +713,7 @@  discard block
 block discarded – undo
697 713
 	        	}
698 714
 	        }
699 715
 
700
-		}
701
-		else if($action === 'confirm_delete_all_lines' && GETPOST('confirm', 'none')=='yes') {
716
+		} else if($action === 'confirm_delete_all_lines' && GETPOST('confirm', 'none')=='yes') {
702 717
 
703 718
 			$Tab = TSubtotal::getLinesFromTitleId($object, GETPOST('lineid', 'int'), true);
704 719
 			foreach($Tab as $line) {
@@ -708,7 +723,9 @@  discard block
 block discarded – undo
708 723
 				/**
709 724
 				 * @var $object Facture
710 725
 				 */
711
-				if($object->element=='facture') $result = $object->deleteline($idLine);
726
+				if($object->element=='facture') {
727
+					$result = $object->deleteline($idLine);
728
+				}
712 729
 				/**
713 730
 				 * @var $object Facture fournisseur
714 731
 				 */
@@ -719,18 +736,25 @@  discard block
 block discarded – undo
719 736
 				/**
720 737
 				 * @var $object Propal
721 738
 				 */
722
-				else if($object->element=='propal') $result = $object->deleteline($idLine);
739
+				else if($object->element=='propal') {
740
+					$result = $object->deleteline($idLine);
741
+				}
723 742
 				/**
724 743
 				 * @var $object Propal Fournisseur
725 744
 				 */
726
-				else if($object->element=='supplier_proposal') $result = $object->deleteline($idLine);
745
+				else if($object->element=='supplier_proposal') {
746
+					$result = $object->deleteline($idLine);
747
+				}
727 748
 				/**
728 749
 				 * @var $object Commande
729 750
 				 */
730 751
 				else if($object->element=='commande')
731 752
 				{
732
-					if ((float) DOL_VERSION >= 5.0) $result = $object->deleteline($user, $idLine);
733
-					else $result = $object->deleteline($idLine);
753
+					if ((float) DOL_VERSION >= 5.0) {
754
+						$result = $object->deleteline($user, $idLine);
755
+					} else {
756
+						$result = $object->deleteline($idLine);
757
+					}
734 758
 				}
735 759
 				/**
736 760
 				 * @var $object Commande fournisseur
@@ -742,13 +766,19 @@  discard block
 block discarded – undo
742 766
 				/**
743 767
 				 * @var $object Facturerec
744 768
 				 */
745
-				else if($object->element=='facturerec') $result = $object->deleteline($idLine);
769
+				else if($object->element=='facturerec') {
770
+					$result = $object->deleteline($idLine);
771
+				}
746 772
 				/**
747 773
 				 * @var $object Expedition
748 774
 				 */
749
-				else if($object->element=='shipping') $result = $object->deleteline($user, $idLine);
775
+				else if($object->element=='shipping') {
776
+					$result = $object->deleteline($user, $idLine);
777
+				}
750 778
 
751
-                if ($result < 0) $error++;
779
+                if ($result < 0) {
780
+                	$error++;
781
+                }
752 782
 			}
753 783
 
754 784
             if ($error) {
@@ -761,15 +791,18 @@  discard block
 block discarded – undo
761 791
 			header('location:?id='.$object->id);
762 792
 			exit;
763 793
 
764
-		}
765
-		else if ($action == 'duplicate')
794
+		} else if ($action == 'duplicate')
766 795
 		{
767 796
 			$lineid = GETPOST('lineid', 'int');
768 797
 			$nbDuplicate = TSubtotal::duplicateLines($object, $lineid, true);
769 798
 
770
-			if ($nbDuplicate > 0) setEventMessage($langs->trans('subtotal_duplicate_success', $nbDuplicate));
771
-			elseif ($nbDuplicate == 0) setEventMessage($langs->trans('subtotal_duplicate_lineid_not_found'), 'warnings');
772
-			else setEventMessage($langs->trans('subtotal_duplicate_error'), 'errors');
799
+			if ($nbDuplicate > 0) {
800
+				setEventMessage($langs->trans('subtotal_duplicate_success', $nbDuplicate));
801
+			} elseif ($nbDuplicate == 0) {
802
+				setEventMessage($langs->trans('subtotal_duplicate_lineid_not_found'), 'warnings');
803
+			} else {
804
+				setEventMessage($langs->trans('subtotal_duplicate_error'), 'errors');
805
+			}
773 806
 
774 807
 			header('Location: ?id='.$object->id);
775 808
 			exit;
@@ -787,21 +820,26 @@  discard block
 block discarded – undo
787 820
 		global $conf;
788 821
 		if (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && !empty($object->table_element_line) && in_array($object->element, array('commande', 'facture', 'propal')))
789 822
 		{
790
-			if ($object->element == 'commande')
791
-				$obj = new OrderLine($object->db);
792
-			if ($object->element == 'propal')
793
-				$obj = new PropaleLigne($object->db);
794
-			if ($object->element == 'facture')
795
-				$obj = new FactureLigne($object->db);
823
+			if ($object->element == 'commande') {
824
+							$obj = new OrderLine($object->db);
825
+			}
826
+			if ($object->element == 'propal') {
827
+							$obj = new PropaleLigne($object->db);
828
+			}
829
+			if ($object->element == 'facture') {
830
+							$obj = new FactureLigne($object->db);
831
+			}
796 832
 			if (!empty($parameters['fk_element']))
797 833
 			{
798 834
 
799 835
 				if($obj->fetch($parameters['fk_element'])){
800 836
 					$obj->id= $obj->rowid;
801
-					if (empty($obj->array_options))
802
-						$obj->fetch_optionals();
803
-					if (!empty($obj->array_options['options_subtotal_nc']))
804
-						return 1;
837
+					if (empty($obj->array_options)) {
838
+											$obj->fetch_optionals();
839
+					}
840
+					if (!empty($obj->array_options['options_subtotal_nc'])) {
841
+											return 1;
842
+					}
805 843
 				}
806 844
 			}
807 845
 		}
@@ -826,10 +864,13 @@  discard block
 block discarded – undo
826 864
 
827 865
 			if($found) {
828 866
                 if ($l->special_code == $this->module_number && $lid != $lineid && ($l->qty <= $qty_line || $l->qty >= $qty_end_line)) {
829
-                    if ($l->qty == $qty_end_line) $Tab[] = $lid;
867
+                    if ($l->qty == $qty_end_line) {
868
+                    	$Tab[] = $lid;
869
+                    }
830 870
                     break;
871
+                } else {
872
+                	$Tab[] = $lid;
831 873
                 }
832
-                else $Tab[] = $lid;
833 874
 			}
834 875
 		}
835 876
 
@@ -842,7 +883,9 @@  discard block
 block discarded – undo
842 883
 		$rang = $line->rang;
843 884
 		$qty_line = $line->qty;
844 885
 		$lvl = 0;
845
-        if (TSubtotal::isSubtotal($line)) $lvl = TSubtotal::getNiveau($line);
886
+        if (TSubtotal::isSubtotal($line)) {
887
+        	$lvl = TSubtotal::getNiveau($line);
888
+        }
846 889
 
847 890
 		$title_break = TSubtotal::getParentTitleOfLine($object, $rang, $lvl);
848 891
 
@@ -853,10 +896,15 @@  discard block
 block discarded – undo
853 896
 
854 897
 
855 898
 		$sign=1;
856
-		if (isset($object->type) && $object->type == 2 && ! empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) $sign=-1;
899
+		if (isset($object->type) && $object->type == 2 && ! empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) {
900
+			$sign=-1;
901
+		}
857 902
 
858
-		if (GETPOST('action', 'none') == 'builddoc') $builddoc = true;
859
-		else $builddoc = false;
903
+		if (GETPOST('action', 'none') == 'builddoc') {
904
+			$builddoc = true;
905
+		} else {
906
+			$builddoc = false;
907
+		}
860 908
 
861 909
 		dol_include_once('/subtotal/class/subtotal.class.php');
862 910
 
@@ -868,9 +916,12 @@  discard block
 block discarded – undo
868 916
 			$l->total_ht = doubleval($l->total_ht);
869 917
 
870 918
 			//print $l->rang.'>='.$rang.' '.$total.'<br/>';
871
-            if ($l->rang>=$rang) continue;
872
-            if (!empty($title_break) && $title_break->id == $l->id) break;
873
-            elseif (!TSubtotal::isModSubtotalLine($l))
919
+            if ($l->rang>=$rang) {
920
+            	continue;
921
+            }
922
+            if (!empty($title_break) && $title_break->id == $l->id) {
923
+            	break;
924
+            } elseif (!TSubtotal::isModSubtotalLine($l))
874 925
             {
875 926
                 // TODO retirer le test avec $builddoc quand Dolibarr affichera le total progression sur la card et pas seulement dans le PDF
876 927
                 if ($builddoc && $object->element == 'facture' && $object->type==Facture::TYPE_SITUATION)
@@ -893,8 +944,7 @@  discard block
 block discarded – undo
893 944
                         $total_ttc += $sign * ($l->total_tva / ($l->total_ttc / 100)) * $progress;
894 945
 
895 946
                     }
896
-                }
897
-                else
947
+                } else
898 948
                 {
899 949
                     $total += $l->total_ht;
900 950
                     $total_tva += $l->total_tva;
@@ -903,8 +953,11 @@  discard block
 block discarded – undo
903 953
                 }
904 954
             }
905 955
 		}
906
-		if (!$return_all) return $total;
907
-		else return array($total, $total_tva, $total_ttc, $TTotal_tva);
956
+		if (!$return_all) {
957
+			return $total;
958
+		} else {
959
+			return array($total, $total_tva, $total_ttc, $TTotal_tva);
960
+		}
908 961
 	}
909 962
 
910 963
 	/**
@@ -951,15 +1004,18 @@  discard block
 block discarded – undo
951 1004
 		}
952 1005
 
953 1006
 
954
-		if($line->qty==99)
955
-			$pdf->SetFillColor(220,220,220);
956
-		elseif ($line->qty==98)
957
-			$pdf->SetFillColor(230,230,230);
958
-		else
959
-			$pdf->SetFillColor(240,240,240);
1007
+		if($line->qty==99) {
1008
+					$pdf->SetFillColor(220,220,220);
1009
+		} elseif ($line->qty==98) {
1010
+					$pdf->SetFillColor(230,230,230);
1011
+		} else {
1012
+					$pdf->SetFillColor(240,240,240);
1013
+		}
960 1014
 
961 1015
 		$style = 'B';
962
-		if (!empty($conf->global->SUBTOTAL_SUBTOTAL_STYLE)) $style = $conf->global->SUBTOTAL_SUBTOTAL_STYLE;
1016
+		if (!empty($conf->global->SUBTOTAL_SUBTOTAL_STYLE)) {
1017
+			$style = $conf->global->SUBTOTAL_SUBTOTAL_STYLE;
1018
+		}
963 1019
 
964 1020
 		$pdf->SetFont('', $style, 9);
965 1021
 
@@ -984,8 +1040,7 @@  discard block
 block discarded – undo
984 1040
 
985 1041
 			$pdf->SetXY($object->subtotalPdfModelInfo->marge_droite, $posy);
986 1042
 			$pdf->MultiCell($object->subtotalPdfModelInfo->page_largeur - $object->subtotalPdfModelInfo->marge_gauche - $object->subtotalPdfModelInfo->marge_droite, $cell_height, '', 0, '', 1);
987
-		}
988
-		else{
1043
+		} else{
989 1044
 			$pdf->SetXY($posx, $posy);
990 1045
 			$pdf->MultiCell($pdf->page_largeur - $pdf->marge_droite, $cell_height, '', 0, '', 1);
991 1046
 		}
@@ -1016,8 +1071,7 @@  discard block
 block discarded – undo
1016 1071
 //					$line->total_tva
1017 1072
 //					$line->total
1018 1073
 //					$line->total_ttc
1019
-				}
1020
-				else
1074
+				} else
1021 1075
 				{
1022 1076
 					//					list($total, $total_tva, $total_ttc, $TTotal_tva) = $this->getTotalLineFromObject($object, $line, '', 1);
1023 1077
 
@@ -1027,23 +1081,27 @@  discard block
 block discarded – undo
1027 1081
 
1028 1082
                     $line->total_ht = $TInfo[0];
1029 1083
 					$line->total = $TInfo[0];
1030
-					if (!TSubtotal::isModSubtotalLine($line)) $line->total_tva = $TInfo[1];
1084
+					if (!TSubtotal::isModSubtotalLine($line)) {
1085
+						$line->total_tva = $TInfo[1];
1086
+					}
1031 1087
 					$line->total_ttc = $TInfo[2];
1032 1088
 				}
1033 1089
 			}
1034 1090
 
1035 1091
 			$pdf->SetXY($pdf->postotalht, $posy);
1036
-			if($set_pagebreak_margin) $pdf->SetAutoPageBreak( $pageBreakOriginalValue , $bMargin);
1092
+			if($set_pagebreak_margin) {
1093
+				$pdf->SetAutoPageBreak( $pageBreakOriginalValue , $bMargin);
1094
+			}
1037 1095
 
1038 1096
 			if(!empty($object->subtotalPdfModelInfo->cols)){
1039 1097
 				$staticPdfModel->printStdColumnContent($pdf, $posy, 'totalexcltax', $total_to_print);
1040
-			}
1041
-			else{
1098
+			} else{
1042 1099
 				$pdf->MultiCell($pdf->page_largeur-$pdf->marge_droite-$pdf->postotalht, 3, $total_to_print, 0, 'R', 0);
1043 1100
 			}
1044
-		}
1045
-		else{
1046
-			if($set_pagebreak_margin) $pdf->SetAutoPageBreak( $pageBreakOriginalValue , $bMargin);
1101
+		} else{
1102
+			if($set_pagebreak_margin) {
1103
+				$pdf->SetAutoPageBreak( $pageBreakOriginalValue , $bMargin);
1104
+			}
1047 1105
 		}
1048 1106
 
1049 1107
 		$posy = $posy + $cell_height;
@@ -1075,25 +1133,40 @@  discard block
 block discarded – undo
1075 1133
 
1076 1134
 
1077 1135
 		$style = ($line->qty==1) ? 'BU' : 'BUI';
1078
-		if (!empty($conf->global->SUBTOTAL_TITLE_STYLE)) $style = $conf->global->SUBTOTAL_TITLE_STYLE;
1136
+		if (!empty($conf->global->SUBTOTAL_TITLE_STYLE)) {
1137
+			$style = $conf->global->SUBTOTAL_TITLE_STYLE;
1138
+		}
1079 1139
 
1080 1140
 		if($hideInnerLines) {
1081
-			if($line->qty==1)$pdf->SetFont('', $style, 9);
1082
-			else
1141
+			if($line->qty==1) {
1142
+				$pdf->SetFont('', $style, 9);
1143
+			} else
1083 1144
 			{
1084
-				if (!empty($conf->global->SUBTOTAL_STYLE_TITRES_SI_LIGNES_CACHEES)) $style = $conf->global->SUBTOTAL_STYLE_TITRES_SI_LIGNES_CACHEES;
1145
+				if (!empty($conf->global->SUBTOTAL_STYLE_TITRES_SI_LIGNES_CACHEES)) {
1146
+					$style = $conf->global->SUBTOTAL_STYLE_TITRES_SI_LIGNES_CACHEES;
1147
+				}
1085 1148
 				$pdf->SetFont('', $style, 9);
1086 1149
 			}
1087
-		}
1088
-		else {
1150
+		} else {
1089 1151
 
1090
-			if($line->qty==1)$pdf->SetFont('', $style, 9); //TODO if super utile
1091
-			else $pdf->SetFont('', $style, 9);
1152
+			if($line->qty==1) {
1153
+				$pdf->SetFont('', $style, 9);
1154
+			}
1155
+			//TODO if super utile
1156
+			else {
1157
+				$pdf->SetFont('', $style, 9);
1158
+			}
1092 1159
 
1093 1160
 		}
1094 1161
 
1095
-		if ($label === strip_tags($label) && $label === dol_html_entity_decode($label, ENT_QUOTES)) $pdf->MultiCell($w, $h, $label, 0, 'L'); // Pas de HTML dans la chaine
1096
-		else $pdf->writeHTMLCell($w, $h, $posx, $posy, $label, 0, 1, false, true, 'J',true); // et maintenant avec du HTML
1162
+		if ($label === strip_tags($label) && $label === dol_html_entity_decode($label, ENT_QUOTES)) {
1163
+			$pdf->MultiCell($w, $h, $label, 0, 'L');
1164
+		}
1165
+		// Pas de HTML dans la chaine
1166
+		else {
1167
+			$pdf->writeHTMLCell($w, $h, $posx, $posy, $label, 0, 1, false, true, 'J',true);
1168
+		}
1169
+		// et maintenant avec du HTML
1097 1170
 
1098 1171
 		if($description && !$hidedesc) {
1099 1172
 			$posy = $pdf->GetY();
@@ -1117,8 +1190,7 @@  discard block
 block discarded – undo
1117 1190
 
1118 1191
 		if(is_array($parameters)) {
1119 1192
 			$i = & $parameters['i'];
1120
-		}
1121
-		else {
1193
+		} else {
1122 1194
 			$i = (int)$parameters;
1123 1195
 		}
1124 1196
 
@@ -1148,17 +1220,14 @@  discard block
 block discarded – undo
1148 1220
 
1149 1221
 			if((float)DOL_VERSION<=3.6) {
1150 1222
 				return '';
1151
-			}
1152
-			else if((float)DOL_VERSION>=3.8) {
1223
+			} else if((float)DOL_VERSION>=3.8) {
1153 1224
 				return 1;
1154 1225
 			}
1155 1226
 
1156
-		}
1157
-		elseif(!empty($hideprices)) {
1227
+		} elseif(!empty($hideprices)) {
1158 1228
 			$this->resprints = $object->lines[$parameters['i']]->qty;
1159 1229
 			return 1;
1160
-		}
1161
-		elseif (!empty($conf->global->SUBTOTAL_IF_HIDE_PRICES_SHOW_QTY))
1230
+		} elseif (!empty($conf->global->SUBTOTAL_IF_HIDE_PRICES_SHOW_QTY))
1162 1231
 		{
1163 1232
 			$hideInnerLines = GETPOST('hideInnerLines', 'int');
1164 1233
 			$hidedetails = GETPOST('hidedetails', 'int');
@@ -1168,13 +1237,21 @@  discard block
 block discarded – undo
1168 1237
 			}
1169 1238
 		}
1170 1239
 
1171
-		if(is_array($parameters)) $i = & $parameters['i'];
1172
-		else $i = (int)$parameters;
1240
+		if(is_array($parameters)) {
1241
+			$i = & $parameters['i'];
1242
+		} else {
1243
+			$i = (int)$parameters;
1244
+		}
1173 1245
 
1174 1246
 		/** Attention, ici on peut ce retrouver avec un objet de type stdClass à cause de l'option cacher le détail des ensembles avec la notion de Non Compris (@see beforePDFCreation()) et dû à l'appel de TSubtotal::hasNcTitle() */
1175
-		if (empty($object->lines[$i]->id)) return 0; // hideInnerLines => override $object->lines et Dolibarr ne nous permet pas de mettre à jour la variable qui conditionne la boucle sur les lignes (PR faite pour 6.0)
1247
+		if (empty($object->lines[$i]->id)) {
1248
+			return 0;
1249
+		}
1250
+		// hideInnerLines => override $object->lines et Dolibarr ne nous permet pas de mettre à jour la variable qui conditionne la boucle sur les lignes (PR faite pour 6.0)
1176 1251
 
1177
-		if(empty($object->lines[$i]->array_options)) $object->lines[$i]->fetch_optionals();
1252
+		if(empty($object->lines[$i]->array_options)) {
1253
+			$object->lines[$i]->fetch_optionals();
1254
+		}
1178 1255
 
1179 1256
 		if (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])) )
1180 1257
 		{
@@ -1191,8 +1268,11 @@  discard block
 block discarded – undo
1191 1268
 	function pdf_getlinetotalexcltax($parameters=array(), &$object, &$action='') {
1192 1269
 	    global $conf, $hideprices, $hookmanager;
1193 1270
 
1194
-		if(is_array($parameters)) $i = & $parameters['i'];
1195
-		else $i = (int)$parameters;
1271
+		if(is_array($parameters)) {
1272
+			$i = & $parameters['i'];
1273
+		} else {
1274
+			$i = (int)$parameters;
1275
+		}
1196 1276
 
1197 1277
 		if($this->isModSubtotalLine($parameters,$object) ){
1198 1278
 
@@ -1200,13 +1280,11 @@  discard block
 block discarded – undo
1200 1280
 
1201 1281
 			if((float)DOL_VERSION<=3.6) {
1202 1282
 				return '';
1203
-			}
1204
-			else if((float)DOL_VERSION>=3.8) {
1283
+			} else if((float)DOL_VERSION>=3.8) {
1205 1284
 				return 1;
1206 1285
 			}
1207 1286
 
1208
-		}
1209
-		elseif (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS))
1287
+		} elseif (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS))
1210 1288
 		{
1211 1289
 			if (!in_array(__FUNCTION__, explode(',', $conf->global->SUBTOTAL_TFIELD_TO_KEEP_WITH_NC)))
1212 1290
 			{
@@ -1278,12 +1356,10 @@  discard block
 block discarded – undo
1278 1356
 			$this->error = $hookmanager->error;
1279 1357
 			$this->errors = $hookmanager->errors;
1280 1358
 			return -1;
1281
-		}
1282
-		elseif (empty($reshook))
1359
+		} elseif (empty($reshook))
1283 1360
 		{
1284 1361
 			$this->resprints .= $hookmanager->resprints;
1285
-		}
1286
-		else
1362
+		} else
1287 1363
 		{
1288 1364
 			$this->resprints = $hookmanager->resprints;
1289 1365
 
@@ -1306,14 +1382,16 @@  discard block
 block discarded – undo
1306 1382
 
1307 1383
 			if((float)DOL_VERSION<=3.6) {
1308 1384
 				return '';
1309
-			}
1310
-			else if((float)DOL_VERSION>=3.8) {
1385
+			} else if((float)DOL_VERSION>=3.8) {
1311 1386
 				return 1;
1312 1387
 			}
1313 1388
 		}
1314 1389
 
1315
-		if(is_array($parameters)) $i = & $parameters['i'];
1316
-		else $i = (int)$parameters;
1390
+		if(is_array($parameters)) {
1391
+			$i = & $parameters['i'];
1392
+		} else {
1393
+			$i = (int)$parameters;
1394
+		}
1317 1395
 
1318 1396
 		if (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])) )
1319 1397
 		{
@@ -1335,14 +1413,16 @@  discard block
 block discarded – undo
1335 1413
 
1336 1414
 			if((float)DOL_VERSION<=3.6) {
1337 1415
 				return '';
1338
-			}
1339
-			else if((float)DOL_VERSION>=3.8) {
1416
+			} else if((float)DOL_VERSION>=3.8) {
1340 1417
 				return 1;
1341 1418
 			}
1342 1419
 		}
1343 1420
 
1344
-		if(is_array($parameters)) $i = & $parameters['i'];
1345
-		else $i = (int)$parameters;
1421
+		if(is_array($parameters)) {
1422
+			$i = & $parameters['i'];
1423
+		} else {
1424
+			$i = (int)$parameters;
1425
+		}
1346 1426
 
1347 1427
 		if (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])) )
1348 1428
 		{
@@ -1359,8 +1439,11 @@  discard block
 block discarded – undo
1359 1439
 	function pdf_getlineupexcltax($parameters=array(), &$object, &$action='') {
1360 1440
 	    global $conf,$hideprices,$hookmanager;
1361 1441
 
1362
-		if(is_array($parameters)) $i = & $parameters['i'];
1363
-		else $i = (int)$parameters;
1442
+		if(is_array($parameters)) {
1443
+			$i = & $parameters['i'];
1444
+		} else {
1445
+			$i = (int)$parameters;
1446
+		}
1364 1447
 
1365 1448
 		if($this->isModSubtotalLine($parameters,$object) ) {
1366 1449
 			$this->resprints = ' ';
@@ -1371,7 +1454,9 @@  discard block
 block discarded – undo
1371 1454
             if(TSubtotal::isSubtotal($line)) {
1372 1455
                 $parentTitle = TSubtotal::getParentTitleOfLine($object, $line->rang);
1373 1456
 
1374
-                if(is_object($parentTitle) && empty($parentTitle->array_options)) $parentTitle->fetch_optionals();
1457
+                if(is_object($parentTitle) && empty($parentTitle->array_options)) {
1458
+                	$parentTitle->fetch_optionals();
1459
+                }
1375 1460
                 if(! empty($parentTitle->array_options['options_show_total_ht'])) {
1376 1461
                     $TTotal = TSubtotal::getTotalBlockFromTitle($object, $parentTitle);
1377 1462
                     $this->resprints = price($TTotal['total_unit_subprice']);
@@ -1380,8 +1465,7 @@  discard block
 block discarded – undo
1380 1465
 
1381 1466
 			if((float)DOL_VERSION<=3.6) {
1382 1467
 				return '';
1383
-			}
1384
-			else if((float)DOL_VERSION>=3.8) {
1468
+			} else if((float)DOL_VERSION>=3.8) {
1385 1469
 				return 1;
1386 1470
 			}
1387 1471
 		}
@@ -1426,8 +1510,11 @@  discard block
 block discarded – undo
1426 1510
 	function pdf_getlineremisepercent($parameters=array(), &$object, &$action='') {
1427 1511
 	    global $conf,$hideprices,$hookmanager;
1428 1512
 
1429
-        if(is_array($parameters)) $i = & $parameters['i'];
1430
-        else $i = (int) $parameters;
1513
+        if(is_array($parameters)) {
1514
+        	$i = & $parameters['i'];
1515
+        } else {
1516
+        	$i = (int) $parameters;
1517
+        }
1431 1518
 
1432 1519
 		if($this->isModSubtotalLine($parameters,$object) ) {
1433 1520
 			$this->resprints = ' ';
@@ -1438,7 +1525,9 @@  discard block
 block discarded – undo
1438 1525
             if(TSubtotal::isSubtotal($line)) {
1439 1526
                 $parentTitle = TSubtotal::getParentTitleOfLine($object, $line->rang);
1440 1527
 
1441
-                if(empty($parentTitle->array_options)) $parentTitle->fetch_optionals();
1528
+                if(empty($parentTitle->array_options)) {
1529
+                	$parentTitle->fetch_optionals();
1530
+                }
1442 1531
                 if(! empty($parentTitle->array_options['options_show_reduc'])) {
1443 1532
                     $TTotal = TSubtotal::getTotalBlockFromTitle($object, $parentTitle);
1444 1533
                     $this->resprints = price((1-$TTotal['total_ht'] / $TTotal['total_subprice'])*100, 0, '', 1, 2, 2).'%';
@@ -1447,12 +1536,10 @@  discard block
 block discarded – undo
1447 1536
 
1448 1537
 			if((float)DOL_VERSION<=3.6) {
1449 1538
 				return '';
1450
-			}
1451
-			else if((float)DOL_VERSION>=3.8) {
1539
+			} else if((float)DOL_VERSION>=3.8) {
1452 1540
 				return 1;
1453 1541
 			}
1454
-		}
1455
-		elseif (!empty($hideprices)
1542
+		} elseif (!empty($hideprices)
1456 1543
 		        || (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])) )
1457 1544
 		        )
1458 1545
 		    {
@@ -1473,14 +1560,16 @@  discard block
 block discarded – undo
1473 1560
 			$this->resprints = ' ';
1474 1561
 			if((float)DOL_VERSION<=3.6) {
1475 1562
 				return '';
1476
-			}
1477
-			else if((float)DOL_VERSION>=3.8) {
1563
+			} else if((float)DOL_VERSION>=3.8) {
1478 1564
 				return 1;
1479 1565
 			}
1480 1566
 		}
1481 1567
 
1482
-		if(is_array($parameters)) $i = & $parameters['i'];
1483
-		else $i = (int)$parameters;
1568
+		if(is_array($parameters)) {
1569
+			$i = & $parameters['i'];
1570
+		} else {
1571
+			$i = (int)$parameters;
1572
+		}
1484 1573
 
1485 1574
 		if (!empty($hideprices)
1486 1575
 				|| (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])) )
@@ -1504,16 +1593,21 @@  discard block
 block discarded – undo
1504 1593
 
1505 1594
 			if((float)DOL_VERSION<=3.6) {
1506 1595
 				return '';
1507
-			}
1508
-			else if((float)DOL_VERSION>=3.8) {
1596
+			} else if((float)DOL_VERSION>=3.8) {
1509 1597
 				return 1;
1510 1598
 			}
1511 1599
 		}
1512 1600
 
1513
-		if(is_array($parameters)) $i = & $parameters['i'];
1514
-		else $i = (int)$parameters;
1601
+		if(is_array($parameters)) {
1602
+			$i = & $parameters['i'];
1603
+		} else {
1604
+			$i = (int)$parameters;
1605
+		}
1515 1606
 
1516
-		if (empty($object->lines[$i])) return 0; // hideInnerLines => override $object->lines et Dolibarr ne nous permet pas de mettre à jour la variable qui conditionne la boucle sur les lignes (PR faite pour 6.0)
1607
+		if (empty($object->lines[$i])) {
1608
+			return 0;
1609
+		}
1610
+		// hideInnerLines => override $object->lines et Dolibarr ne nous permet pas de mettre à jour la variable qui conditionne la boucle sur les lignes (PR faite pour 6.0)
1517 1611
 
1518 1612
 		$object->lines[$i]->fetch_optionals();
1519 1613
 		// Si la gestion C/NC est active et que je suis sur un ligne dont l'extrafield est coché
@@ -1559,14 +1653,16 @@  discard block
 block discarded – undo
1559 1653
 			$this->resprints = ' ';
1560 1654
 			if((float)DOL_VERSION<=3.6) {
1561 1655
 				return '';
1562
-			}
1563
-			else if((float)DOL_VERSION>=3.8) {
1656
+			} else if((float)DOL_VERSION>=3.8) {
1564 1657
 				return 1;
1565 1658
 			}
1566 1659
 		}
1567 1660
 
1568
-		if(is_array($parameters)) $i = & $parameters['i'];
1569
-		else $i = (int)$parameters;
1661
+		if(is_array($parameters)) {
1662
+			$i = & $parameters['i'];
1663
+		} else {
1664
+			$i = (int)$parameters;
1665
+		}
1570 1666
 
1571 1667
 		if (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])) )
1572 1668
 		{
@@ -1594,8 +1690,7 @@  discard block
 block discarded – undo
1594 1690
 				if ($line->id > 0 && $this->isModSubtotalLine($k, $object) && $line->qty <= 10)
1595 1691
 				{
1596 1692
 					$TLineTitle[] = &$line;
1597
-				}
1598
-				else if ($line->id > 0 && TSubtotal::isSubtotal($line))
1693
+				} else if ($line->id > 0 && TSubtotal::isSubtotal($line))
1599 1694
 				{
1600 1695
 					$TLineSubtotal[] = &$line;
1601 1696
 				}
@@ -1651,8 +1746,12 @@  discard block
 block discarded – undo
1651 1746
 		$j=0;
1652 1747
 		foreach ($TLineTitle as $k => &$line)
1653 1748
 		{
1654
-			if (!empty($line_reference) && $line->rang <= $line_reference->rang) continue;
1655
-			if (!empty($line_reference) && $line->qty <= $line_reference->qty) break;
1749
+			if (!empty($line_reference) && $line->rang <= $line_reference->rang) {
1750
+				continue;
1751
+			}
1752
+			if (!empty($line_reference) && $line->qty <= $line_reference->qty) {
1753
+				break;
1754
+			}
1656 1755
 
1657 1756
 			if ($line->qty == $level)
1658 1757
 			{
@@ -1686,7 +1785,9 @@  discard block
 block discarded – undo
1686 1785
 
1687 1786
 		$hidedetails = GETPOST('hidedetails', 'int');
1688 1787
 
1689
-		if(empty($hidedetails)) return false;
1788
+		if(empty($hidedetails)) {
1789
+			return false;
1790
+		}
1690 1791
 
1691 1792
 		// TODO can't add VAT to document without lines... :-/
1692 1793
 
@@ -1718,7 +1819,9 @@  discard block
 block discarded – undo
1718 1819
         foreach($object->lines as $k => &$l) {
1719 1820
             if(TSubtotal::isSubtotal($l)) {
1720 1821
                 $parentTitle = TSubtotal::getParentTitleOfLine($object, $l->rang);
1721
-                if(is_object($parentTitle) && empty($parentTitle->array_options)) $parentTitle->fetch_optionals();
1822
+                if(is_object($parentTitle) && empty($parentTitle->array_options)) {
1823
+                	$parentTitle->fetch_optionals();
1824
+                }
1722 1825
                 if(! empty($parentTitle->id) && ! empty($parentTitle->array_options['options_show_reduc'])) {
1723 1826
                     $l->remise_percent = 100;    // Affichage de la réduction sur la ligne de sous-total
1724 1827
                 }
@@ -1762,7 +1865,9 @@  discard block
 block discarded – undo
1762 1865
 
1763 1866
 						$TInfo = $this->getTotalLineFromObject($object, $line, '', 1);
1764 1867
 
1765
-						if (TSubtotal::getNiveau($line) == 1) $line->TTotal_tva = $TInfo[3];
1868
+						if (TSubtotal::getNiveau($line) == 1) {
1869
+							$line->TTotal_tva = $TInfo[3];
1870
+						}
1766 1871
 						$line->total_ht = $TInfo[0];
1767 1872
 						$line->total_tva = $TInfo[1];
1768 1873
 						$line->total = $line->total_ht;
@@ -1826,8 +1931,7 @@  discard block
 block discarded – undo
1826 1931
 				    }
1827 1932
 
1828 1933
 
1829
-				}
1830
-				elseif ($hidedetails)
1934
+				} elseif ($hidedetails)
1831 1935
 				{
1832 1936
 					$TLines[] = $line; //Cas où je cache uniquement les prix des produits
1833 1937
 				}
@@ -1905,13 +2009,17 @@  discard block
 block discarded – undo
1905 2009
 
1906 2010
 				if(!empty($hideprices)) {
1907 2011
 					foreach($object->lines as &$line) {
1908
-						if($line->fk_product_type!=9) $line->fk_parent_line = -1;
2012
+						if($line->fk_product_type!=9) {
2013
+							$line->fk_parent_line = -1;
2014
+						}
1909 2015
 					}
1910 2016
 				}
1911 2017
 
1912 2018
 				$line = &$object->lines[$i];
1913 2019
 
1914
-				if($object->element == 'delivery' && ! empty($object->commande->expeditions[$line->fk_origin_line])) unset($object->commande->expeditions[$line->fk_origin_line]);
2020
+				if($object->element == 'delivery' && ! empty($object->commande->expeditions[$line->fk_origin_line])) {
2021
+					unset($object->commande->expeditions[$line->fk_origin_line]);
2022
+				}
1915 2023
 
1916 2024
 				$margin = $pdf->getMargins();
1917 2025
 				if(!empty($margin) && $line->info_bits>0) { // PAGE BREAK
@@ -1928,7 +2036,9 @@  discard block
 block discarded – undo
1928 2036
 				}
1929 2037
 
1930 2038
 				if($line->qty>90) {
1931
-					if ($conf->global->SUBTOTAL_USE_NEW_FORMAT)	$label .= ' '.$this->getTitle($object, $line);
2039
+					if ($conf->global->SUBTOTAL_USE_NEW_FORMAT) {
2040
+						$label .= ' '.$this->getTitle($object, $line);
2041
+					}
1932 2042
 
1933 2043
 					$pageBefore = $pdf->getPage();
1934 2044
 					$this->pdf_add_total($pdf,$object, $line, $label, $description,$posx, $posy, $w, $h);
@@ -1966,8 +2076,7 @@  discard block
 block discarded – undo
1966 2076
 
1967 2077
 					$posy = $pdf->GetY();
1968 2078
 					return 1;
1969
-				}
1970
-				else if ($line->qty < 10) {
2079
+				} else if ($line->qty < 10) {
1971 2080
 					$pageBefore = $pdf->getPage();
1972 2081
 
1973 2082
 					$this->pdf_add_title($pdf,$object, $line, $label, $description,$posx, $posy, $w, $h);
@@ -1992,8 +2101,7 @@  discard block
 block discarded – undo
1992 2101
 				}
1993 2102
 
1994 2103
 			return 0;
1995
-		}
1996
-		elseif (empty($object->lines[$parameters['i']]))
2104
+		} elseif (empty($object->lines[$parameters['i']]))
1997 2105
 		{
1998 2106
 			$this->resprints = -1;
1999 2107
 		}
@@ -2012,7 +2120,9 @@  discard block
 block discarded – undo
2012 2120
 
2013 2121
 		foreach ($object->lines as $line)
2014 2122
 		{
2015
-			if ($line->id == $currentLine->id) break;
2123
+			if ($line->id == $currentLine->id) {
2124
+				break;
2125
+			}
2016 2126
 
2017 2127
 			$qty_search = 100 - $currentLine->qty;
2018 2128
 
@@ -2043,7 +2153,9 @@  discard block
 block discarded – undo
2043 2153
 		$var = &$parameters['var'];
2044 2154
 
2045 2155
 		$contexts = explode(':',$parameters['context']);
2046
-		if($parameters['currentcontext'] === 'paiementcard') return 0;
2156
+		if($parameters['currentcontext'] === 'paiementcard') {
2157
+			return 0;
2158
+		}
2047 2159
 		$originline = null;
2048 2160
 
2049 2161
 		$createRight = $user->rights->{$object->element}->creer;
@@ -2051,22 +2163,18 @@  discard block
 block discarded – undo
2051 2163
 		{
2052 2164
 			$object->statut = 0; // hack for facture rec
2053 2165
 			$createRight = $user->rights->facture->creer;
2054
-		}
2055
-		elseif($object->element == 'order_supplier' )
2166
+		} elseif($object->element == 'order_supplier' )
2056 2167
 		{
2057 2168
 		    $createRight = $user->rights->fournisseur->commande->creer;
2058
-		}
2059
-		elseif($object->element == 'invoice_supplier' )
2169
+		} elseif($object->element == 'invoice_supplier' )
2060 2170
 		{
2061 2171
 		    $createRight = $user->rights->fournisseur->facture->creer;
2062
-		}
2063
-		elseif($object->element == 'commande' && in_array('ordershipmentcard', $contexts))
2172
+		} elseif($object->element == 'commande' && in_array('ordershipmentcard', $contexts))
2064 2173
 		{
2065 2174
 			// H4cK 4n0nYm0u$-style : $line n'est pas un objet instancié mais provient d'un fetch_object d'une requête SQL
2066 2175
 			$line->id = $line->rowid;
2067 2176
 			$line->product_type = $line->type;
2068
-		}
2069
-		elseif($object->element == 'shipping' || $object->element == 'delivery')
2177
+		} elseif($object->element == 'shipping' || $object->element == 'delivery')
2070 2178
 		{
2071 2179
 			if(empty($line->origin_line_id) && ! empty($line->fk_origin_line))
2072 2180
 			{
@@ -2086,8 +2194,11 @@  discard block
 block discarded – undo
2086 2194
 
2087 2195
 			$line = $originline;
2088 2196
 		}
2089
- 		if($object->element=='facture')$idvar = 'facid';
2090
-        else $idvar='id';
2197
+ 		if($object->element=='facture') {
2198
+ 			$idvar = 'facid';
2199
+ 		} else {
2200
+        	$idvar='id';
2201
+        }
2091 2202
 		if($line->special_code!=$this->module_number || $line->product_type!=9) {
2092 2203
 			if ($object->statut == 0  && $createRight && !empty($conf->global->SUBTOTAL_ALLOW_DUPLICATE_LINE) && $object->element !== 'invoice_supplier')
2093 2204
             {
@@ -2105,8 +2216,7 @@  discard block
 block discarded – undo
2105 2216
 
2106 2217
             }
2107 2218
 			return 0;
2108
-		}
2109
-		else if (in_array('invoicecard',$contexts) || in_array('invoicesuppliercard',$contexts) || in_array('propalcard',$contexts) || in_array('supplier_proposalcard',$contexts) || in_array('ordercard',$contexts) || in_array('ordersuppliercard',$contexts) || in_array('invoicereccard',$contexts))
2219
+		} else if (in_array('invoicecard',$contexts) || in_array('invoicesuppliercard',$contexts) || in_array('propalcard',$contexts) || in_array('supplier_proposalcard',$contexts) || in_array('ordercard',$contexts) || in_array('ordersuppliercard',$contexts) || in_array('invoicereccard',$contexts))
2110 2220
         {
2111 2221
 
2112 2222
 
@@ -2133,24 +2243,48 @@  discard block
 block discarded – undo
2133 2243
 				</script>
2134 2244
 				<?php
2135 2245
 			}
2136
-			if(empty($line->description)) $line->description = $line->desc;
2246
+			if(empty($line->description)) {
2247
+				$line->description = $line->desc;
2248
+			}
2137 2249
 			$colspan = 5;
2138
-			if($object->element == 'facturerec' ) $colspan = 3;
2139
-			if($object->element == 'order_supplier') (float) DOL_VERSION < 7.0 ? $colspan = 3 : $colspan = 6;
2140
-			if($object->element == 'invoice_supplier') (float) DOL_VERSION < 7.0 ? $colspan = 4: $colspan = 7;
2141
-			if($object->element == 'supplier_proposal') (float) DOL_VERSION < 6.0 ? $colspan = 4 : $colspan = 3;
2250
+			if($object->element == 'facturerec' ) {
2251
+				$colspan = 3;
2252
+			}
2253
+			if($object->element == 'order_supplier') {
2254
+				(float) DOL_VERSION < 7.0 ? $colspan = 3 : $colspan = 6;
2255
+			}
2256
+			if($object->element == 'invoice_supplier') {
2257
+				(float) DOL_VERSION < 7.0 ? $colspan = 4: $colspan = 7;
2258
+			}
2259
+			if($object->element == 'supplier_proposal') {
2260
+				(float) DOL_VERSION < 6.0 ? $colspan = 4 : $colspan = 3;
2261
+			}
2142 2262
 			if(!empty($conf->multicurrency->enabled) && ((float) DOL_VERSION < 8.0 || $object->multicurrency_code != $conf->currency)) {
2143 2263
 				$colspan++; // Colonne PU Devise
2144 2264
 			}
2145
-			if($object->element == 'commande' && $object->statut < 3 && !empty($conf->shippableorder->enabled)) $colspan++;
2265
+			if($object->element == 'commande' && $object->statut < 3 && !empty($conf->shippableorder->enabled)) {
2266
+				$colspan++;
2267
+			}
2146 2268
 			$margins_hidden_by_module = empty($conf->affmarges->enabled) ? false : !($_SESSION['marginsdisplayed']);
2147
-			if(!empty($conf->margin->enabled) && !$margins_hidden_by_module) $colspan++;
2148
-			if(!empty($conf->margin->enabled) && !empty($conf->global->DISPLAY_MARGIN_RATES) && !$margins_hidden_by_module) $colspan++;
2149
-			if(!empty($conf->margin->enabled) && !empty($conf->global->DISPLAY_MARK_RATES) && !$margins_hidden_by_module) $colspan++;
2150
-			if($object->element == 'facture' && !empty($conf->global->INVOICE_USE_SITUATION) && $object->type == Facture::TYPE_SITUATION) $colspan++;
2151
-			if(!empty($conf->global->PRODUCT_USE_UNITS)) $colspan++;
2269
+			if(!empty($conf->margin->enabled) && !$margins_hidden_by_module) {
2270
+				$colspan++;
2271
+			}
2272
+			if(!empty($conf->margin->enabled) && !empty($conf->global->DISPLAY_MARGIN_RATES) && !$margins_hidden_by_module) {
2273
+				$colspan++;
2274
+			}
2275
+			if(!empty($conf->margin->enabled) && !empty($conf->global->DISPLAY_MARK_RATES) && !$margins_hidden_by_module) {
2276
+				$colspan++;
2277
+			}
2278
+			if($object->element == 'facture' && !empty($conf->global->INVOICE_USE_SITUATION) && $object->type == Facture::TYPE_SITUATION) {
2279
+				$colspan++;
2280
+			}
2281
+			if(!empty($conf->global->PRODUCT_USE_UNITS)) {
2282
+				$colspan++;
2283
+			}
2152 2284
 			// Compatibility module showprice
2153
-			if(!empty($conf->showprice->enabled)) $colspan++;
2285
+			if(!empty($conf->showprice->enabled)) {
2286
+				$colspan++;
2287
+			}
2154 2288
 
2155 2289
 			/* Titre */
2156 2290
 			//var_dump($line);
@@ -2163,23 +2297,36 @@  discard block
 block discarded – undo
2163 2297
 			<tr <?php echo $bc[$var]; $var=!$var; echo $data; ?> rel="subtotal" id="row-<?php echo $line->id ?>" style="<?php
2164 2298
 					if (!empty($conf->global->SUBTOTAL_USE_NEW_FORMAT))
2165 2299
 					{
2166
-						if($line->qty==99) print 'background:#adadcf';
2167
-						else if($line->qty==98) print 'background:#ddddff;';
2168
-						else if($line->qty<=97 && $line->qty>=91) print 'background:#eeeeff;';
2169
-						else if($line->qty==1) print 'background:#adadcf;';
2170
-						else if($line->qty==2) print 'background:#ddddff;';
2171
-						else if($line->qty==50) print '';
2172
-						else print 'background:#eeeeff;';
2300
+						if($line->qty==99) {
2301
+							print 'background:#adadcf';
2302
+						} else if($line->qty==98) {
2303
+							print 'background:#ddddff;';
2304
+						} else if($line->qty<=97 && $line->qty>=91) {
2305
+							print 'background:#eeeeff;';
2306
+						} else if($line->qty==1) {
2307
+							print 'background:#adadcf;';
2308
+						} else if($line->qty==2) {
2309
+							print 'background:#ddddff;';
2310
+						} else if($line->qty==50) {
2311
+							print '';
2312
+						} else {
2313
+							print 'background:#eeeeff;';
2314
+						}
2173 2315
 
2174 2316
 						//A compléter si on veux plus de nuances de couleurs avec les niveau 4,5,6,7,8 et 9
2175
-					}
2176
-					else
2317
+					} else
2177 2318
 					{
2178
-						if($line->qty==99) print 'background:#ddffdd';
2179
-						else if($line->qty==98) print 'background:#ddddff;';
2180
-						else if($line->qty==2) print 'background:#eeeeff; ';
2181
-						else if($line->qty==50) print '';
2182
-						else print 'background:#eeffee;' ;
2319
+						if($line->qty==99) {
2320
+							print 'background:#ddffdd';
2321
+						} else if($line->qty==98) {
2322
+							print 'background:#ddddff;';
2323
+						} else if($line->qty==2) {
2324
+							print 'background:#eeeeff; ';
2325
+						} else if($line->qty==50) {
2326
+							print '';
2327
+						} else {
2328
+							print 'background:#eeffee;' ;
2329
+						}
2183 2330
 					}
2184 2331
 
2185 2332
 			?>;">
@@ -2206,13 +2353,11 @@  discard block
 block discarded – undo
2206 2353
 							$qty_displayed = $line->qty;
2207 2354
 							print img_picto('', 'subsubtotal@subtotal').'<span style="font-size:9px;margin-left:-3px;color:#0075DE;">'.$qty_displayed.'</span>&nbsp;&nbsp;';
2208 2355
 
2209
-						}
2210
-						else if (TSubtotal::isSubtotal($line))
2356
+						} else if (TSubtotal::isSubtotal($line))
2211 2357
 						{
2212 2358
 							$qty_displayed = 100 - $line->qty;
2213 2359
 							print img_picto('', 'subsubtotal2@subtotal').'<span style="font-size:9px;margin-left:-1px;color:#0075DE;">'.$qty_displayed.'</span>&nbsp;&nbsp;';
2214
-						}
2215
-						else
2360
+						} else
2216 2361
 						{
2217 2362
 							$isFreeText = true;
2218 2363
 						}
@@ -2233,9 +2378,13 @@  discard block
 block discarded – undo
2233 2378
 						}
2234 2379
 
2235 2380
 						$readonlyForSituation = '';
2236
-						if (!empty($line->fk_prev_id) && $line->fk_prev_id != null) $readonlyForSituation = 'readonly';
2381
+						if (!empty($line->fk_prev_id) && $line->fk_prev_id != null) {
2382
+							$readonlyForSituation = 'readonly';
2383
+						}
2237 2384
 
2238
-						if (!$isFreeText) echo '<input type="text" name="line-title" id-line="'.$line->id.'" value="'.$newlabel.'" size="80" '.$readonlyForSituation.'/>&nbsp;';
2385
+						if (!$isFreeText) {
2386
+							echo '<input type="text" name="line-title" id-line="'.$line->id.'" value="'.$newlabel.'" size="80" '.$readonlyForSituation.'/>&nbsp;';
2387
+						}
2239 2388
 
2240 2389
 						if (!empty($conf->global->SUBTOTAL_USE_NEW_FORMAT) && (TSubtotal::isTitle($line) || TSubtotal::isSubtotal($line)) )
2241 2390
 						{
@@ -2243,8 +2392,12 @@  discard block
 block discarded – undo
2243 2392
 							for ($j=1; $j<10; $j++)
2244 2393
 							{
2245 2394
 								if (!empty($readonlyForSituation)) {
2246
-									if ($qty_displayed == $j) $select .= '<option selected="selected" value="'.$j.'">'.$langs->trans('Level').' '.$j.'</option>';
2247
-								} else $select .= '<option '.($qty_displayed == $j ? 'selected="selected"' : '').' value="'.$j.'">'.$langs->trans('Level').' '.$j.'</option>';
2395
+									if ($qty_displayed == $j) {
2396
+										$select .= '<option selected="selected" value="'.$j.'">'.$langs->trans('Level').' '.$j.'</option>';
2397
+									}
2398
+								} else {
2399
+									$select .= '<option '.($qty_displayed == $j ? 'selected="selected"' : '').' value="'.$j.'">'.$langs->trans('Level').' '.$j.'</option>';
2400
+								}
2248 2401
 							}
2249 2402
 							$select .= '</select>&nbsp;';
2250 2403
 
@@ -2264,7 +2417,9 @@  discard block
 block discarded – undo
2264 2417
                             echo '<div>';
2265 2418
                             echo '<label for="subtotal_tva_tx">'.$form->textwithpicto($langs->trans('subtotal_apply_default_tva'), $langs->trans('subtotal_apply_default_tva_help')).'</label>';
2266 2419
                             echo '<select id="subtotal_tva_tx" name="subtotal_tva_tx" class="flat"><option selected="selected" value="">-</option>';
2267
-                            if (empty($readonlyForSituation)) echo str_replace('selected', '', $form->load_tva('subtotal_tva_tx', '', $parameters['seller'], $parameters['buyer'], 0, 0, '', true));
2420
+                            if (empty($readonlyForSituation)) {
2421
+                            	echo str_replace('selected', '', $form->load_tva('subtotal_tva_tx', '', $parameters['seller'], $parameters['buyer'], 0, 0, '', true));
2422
+                            }
2268 2423
                             echo '</select>';
2269 2424
                             echo '</div>';
2270 2425
 
@@ -2283,8 +2438,9 @@  discard block
 block discarded – undo
2283 2438
                             echo '<input style="vertical-align:sub;"  type="checkbox" name="line-showReduc" id="subtotal-showReduc" value="1" '.(($line->array_options['options_show_reduc'] > 0) ? 'checked="checked"' : '') .' />&nbsp;';
2284 2439
                             echo '<label for="subtotal-showReduc">'.$langs->trans('ShowReducOnSubtotalBlock').'</label>';
2285 2440
                             echo '</div>';
2441
+                        } else if ($isFreeText) {
2442
+                        	echo TSubtotal::getFreeTextHtml($line, (bool) $readonlyForSituation);
2286 2443
                         }
2287
-                        else if ($isFreeText) echo TSubtotal::getFreeTextHtml($line, (bool) $readonlyForSituation);
2288 2444
 						echo '</div>';
2289 2445
 
2290 2446
 						if (TSubtotal::isTitle($line))
@@ -2305,9 +2461,13 @@  discard block
 block discarded – undo
2305 2461
 							$doleditor->Create();
2306 2462
 
2307 2463
 							$TKey = null;
2308
-							if ($line->element == 'propaldet') $TKey = explode(',', $conf->global->SUBTOTAL_LIST_OF_EXTRAFIELDS_PROPALDET);
2309
-							elseif ($line->element == 'commandedet') $TKey = explode(',', $conf->global->SUBTOTAL_LIST_OF_EXTRAFIELDS_COMMANDEDET);
2310
-							elseif ($line->element == 'facturedet') $TKey = explode(',', $conf->global->SUBTOTAL_LIST_OF_EXTRAFIELDS_FACTUREDET);
2464
+							if ($line->element == 'propaldet') {
2465
+								$TKey = explode(',', $conf->global->SUBTOTAL_LIST_OF_EXTRAFIELDS_PROPALDET);
2466
+							} elseif ($line->element == 'commandedet') {
2467
+								$TKey = explode(',', $conf->global->SUBTOTAL_LIST_OF_EXTRAFIELDS_COMMANDEDET);
2468
+							} elseif ($line->element == 'facturedet') {
2469
+								$TKey = explode(',', $conf->global->SUBTOTAL_LIST_OF_EXTRAFIELDS_FACTUREDET);
2470
+							}
2311 2471
 							// TODO ajouter la partie fournisseur
2312 2472
 
2313 2473
 							if (!empty($TKey))
@@ -2327,8 +2487,7 @@  discard block
 block discarded – undo
2327 2487
 							}
2328 2488
 						}
2329 2489
 
2330
-					}
2331
-					else {
2490
+					} else {
2332 2491
 
2333 2492
 						 if ($conf->global->SUBTOTAL_USE_NEW_FORMAT)
2334 2493
 						 {
@@ -2336,14 +2495,19 @@  discard block
 block discarded – undo
2336 2495
 							{
2337 2496
 								echo str_repeat('&nbsp;&nbsp;&nbsp;', $line->qty-1);
2338 2497
 
2339
-								if (TSubtotal::isTitle($line)) print img_picto('', 'subtotal@subtotal').'<span style="font-size:9px;margin-left:-3px;">'.$line->qty.'</span>&nbsp;&nbsp;';
2340
-								else print img_picto('', 'subtotal2@subtotal').'<span style="font-size:9px;margin-left:-1px;">'.(100-$line->qty).'</span>&nbsp;&nbsp;';
2498
+								if (TSubtotal::isTitle($line)) {
2499
+									print img_picto('', 'subtotal@subtotal').'<span style="font-size:9px;margin-left:-3px;">'.$line->qty.'</span>&nbsp;&nbsp;';
2500
+								} else {
2501
+									print img_picto('', 'subtotal2@subtotal').'<span style="font-size:9px;margin-left:-1px;">'.(100-$line->qty).'</span>&nbsp;&nbsp;';
2502
+								}
2341 2503
 							}
2342
-						 }
2343
-						 else
2504
+						 } else
2344 2505
 						 {
2345
-							if($line->qty<=1) print img_picto('', 'subtotal@subtotal');
2346
-							else if($line->qty==2) print img_picto('', 'subsubtotal@subtotal').'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
2506
+							if($line->qty<=1) {
2507
+								print img_picto('', 'subtotal@subtotal');
2508
+							} else if($line->qty==2) {
2509
+								print img_picto('', 'subsubtotal@subtotal').'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
2510
+							}
2347 2511
 						 }
2348 2512
 
2349 2513
 
@@ -2353,21 +2517,26 @@  discard block
 block discarded – undo
2353 2517
 						 $titleStyleUnderline =  strpos($conf->global->SUBTOTAL_TITLE_STYLE, 'U') === false ? '' : ' text-decoration: underline;';
2354 2518
 
2355 2519
 						 if (empty($line->label)) {
2356
-							if ($line->qty >= 91 && $line->qty <= 99 && $conf->global->SUBTOTAL_USE_NEW_FORMAT) print  $line->description.' '.$this->getTitle($object, $line);
2357
-							else print  $line->description;
2358
-						 }
2359
-						 else {
2520
+							if ($line->qty >= 91 && $line->qty <= 99 && $conf->global->SUBTOTAL_USE_NEW_FORMAT) {
2521
+								print  $line->description.' '.$this->getTitle($object, $line);
2522
+							} else {
2523
+								print  $line->description;
2524
+							}
2525
+						 } else {
2360 2526
 
2361 2527
 							if (! empty($conf->global->PRODUIT_DESC_IN_FORM) && !empty($line->description)) {
2362 2528
 								print '<span class="subtotal_label" style="'.$titleStyleItalic.$titleStyleBold.$titleStyleUnderline.'" >'.$line->label.'</span><br><div class="subtotal_desc">'.dol_htmlentitiesbr($line->description).'</div>';
2363
-							}
2364
-							else{
2529
+							} else{
2365 2530
 								print '<span class="subtotal_label classfortooltip '.$titleStyleItalic.$titleStyleBold.$titleStyleUnderline.'" title="'.$line->description.'">'.$line->label.'</span>';
2366 2531
 							}
2367 2532
 
2368 2533
 						 }
2369
-						if($line->qty>90) print ' : ';
2370
-						if($line->info_bits > 0) echo img_picto($langs->trans('Pagebreak'), 'pagebreak@subtotal');
2534
+						if($line->qty>90) {
2535
+							print ' : ';
2536
+						}
2537
+						if($line->info_bits > 0) {
2538
+							echo img_picto($langs->trans('Pagebreak'), 'pagebreak@subtotal');
2539
+						}
2371 2540
 
2372 2541
 
2373 2542
 
@@ -2410,11 +2579,12 @@  discard block
 block discarded – undo
2410 2579
 						</script>
2411 2580
 						<?php
2412 2581
 
2413
-					}
2414
-					else{
2582
+					} else{
2415 2583
 						if ($object->statut == 0  && $createRight && !empty($conf->global->SUBTOTAL_ALLOW_DUPLICATE_BLOCK) && $object->element !== 'invoice_supplier')
2416 2584
 						{
2417
-							if(TSubtotal::isTitle($line) && ( $line->fk_prev_id === null )) echo '<a href="'.$_SERVER['PHP_SELF'].'?'.$idvar.'='.$object->id.'&action=duplicate&lineid='.$line->id.'">'. img_picto($langs->trans('Duplicate'), 'duplicate@subtotal').'</a>';
2585
+							if(TSubtotal::isTitle($line) && ( $line->fk_prev_id === null )) {
2586
+								echo '<a href="'.$_SERVER['PHP_SELF'].'?'.$idvar.'='.$object->id.'&action=duplicate&lineid='.$line->id.'">'. img_picto($langs->trans('Duplicate'), 'duplicate@subtotal').'</a>';
2587
+							}
2418 2588
 						}
2419 2589
 
2420 2590
 						if ($object->statut == 0  && $createRight && !empty($conf->global->SUBTOTAL_ALLOW_EDIT_BLOCK))
@@ -2491,7 +2661,9 @@  discard block
 block discarded – undo
2491 2661
 				$extralabelsline = $extrafieldsline->fetch_name_optionals_label($object->table_element_line);
2492 2662
 
2493 2663
 				$colspan+=3; $mode = 'view';
2494
-				if($action === 'editline' && $line->rowid == GETPOST('lineid', 'int')) $mode = 'edit';
2664
+				if($action === 'editline' && $line->rowid == GETPOST('lineid', 'int')) {
2665
+					$mode = 'edit';
2666
+				}
2495 2667
 
2496 2668
 				$ex_element = $line->element;
2497 2669
 				$line->element = 'tr_extrafield_title '.$line->element; // Pour pouvoir manipuler ces tr
@@ -2550,8 +2722,7 @@  discard block
 block discarded – undo
2550 2722
 
2551 2723
 			return 1;
2552 2724
 
2553
-		}
2554
-		elseif(($object->element == 'commande' && in_array('ordershipmentcard', $contexts)) || (in_array('expeditioncard', $contexts) && $action == 'create'))
2725
+		} elseif(($object->element == 'commande' && in_array('ordershipmentcard', $contexts)) || (in_array('expeditioncard', $contexts) && $action == 'create'))
2555 2726
 		{
2556 2727
 			$colspan = 4;
2557 2728
 
@@ -2561,23 +2732,36 @@  discard block
 block discarded – undo
2561 2732
 			<tr <?php echo $bc[$var]; $var=!$var; echo $data; ?> rel="subtotal" id="row-<?php echo $line->id ?>" style="<?php
2562 2733
 					if (!empty($conf->global->SUBTOTAL_USE_NEW_FORMAT))
2563 2734
 					{
2564
-						if($line->qty==99) print 'background:#adadcf';
2565
-						else if($line->qty==98) print 'background:#ddddff;';
2566
-						else if($line->qty<=97 && $line->qty>=91) print 'background:#eeeeff;';
2567
-						else if($line->qty==1) print 'background:#adadcf;';
2568
-						else if($line->qty==2) print 'background:#ddddff;';
2569
-						else if($line->qty==50) print '';
2570
-						else print 'background:#eeeeff;';
2735
+						if($line->qty==99) {
2736
+							print 'background:#adadcf';
2737
+						} else if($line->qty==98) {
2738
+							print 'background:#ddddff;';
2739
+						} else if($line->qty<=97 && $line->qty>=91) {
2740
+							print 'background:#eeeeff;';
2741
+						} else if($line->qty==1) {
2742
+							print 'background:#adadcf;';
2743
+						} else if($line->qty==2) {
2744
+							print 'background:#ddddff;';
2745
+						} else if($line->qty==50) {
2746
+							print '';
2747
+						} else {
2748
+							print 'background:#eeeeff;';
2749
+						}
2571 2750
 
2572 2751
 						//A compléter si on veux plus de nuances de couleurs avec les niveau 4,5,6,7,8 et 9
2573
-					}
2574
-					else
2752
+					} else
2575 2753
 					{
2576
-						if($line->qty==99) print 'background:#ddffdd';
2577
-						else if($line->qty==98) print 'background:#ddddff;';
2578
-						else if($line->qty==2) print 'background:#eeeeff; ';
2579
-						else if($line->qty==50) print '';
2580
-						else print 'background:#eeffee;' ;
2754
+						if($line->qty==99) {
2755
+							print 'background:#ddffdd';
2756
+						} else if($line->qty==98) {
2757
+							print 'background:#ddddff;';
2758
+						} else if($line->qty==2) {
2759
+							print 'background:#eeeeff; ';
2760
+						} else if($line->qty==50) {
2761
+							print '';
2762
+						} else {
2763
+							print 'background:#eeffee;' ;
2764
+						}
2581 2765
 					}
2582 2766
 
2583 2767
 			?>;">
@@ -2591,14 +2775,19 @@  discard block
 block discarded – undo
2591 2775
 							{
2592 2776
 								echo str_repeat('&nbsp;&nbsp;&nbsp;', $line->qty-1);
2593 2777
 
2594
-								if (TSubtotal::isTitle($line)) print img_picto('', 'subtotal@subtotal').'<span style="font-size:9px;margin-left:-3px;">'.$line->qty.'</span>&nbsp;&nbsp;';
2595
-								else print img_picto('', 'subtotal2@subtotal').'<span style="font-size:9px;margin-left:-1px;">'.(100-$line->qty).'</span>&nbsp;&nbsp;';
2778
+								if (TSubtotal::isTitle($line)) {
2779
+									print img_picto('', 'subtotal@subtotal').'<span style="font-size:9px;margin-left:-3px;">'.$line->qty.'</span>&nbsp;&nbsp;';
2780
+								} else {
2781
+									print img_picto('', 'subtotal2@subtotal').'<span style="font-size:9px;margin-left:-1px;">'.(100-$line->qty).'</span>&nbsp;&nbsp;';
2782
+								}
2596 2783
 							}
2597
-						 }
2598
-						 else
2784
+						 } else
2599 2785
 						 {
2600
-							if($line->qty<=1) print img_picto('', 'subtotal@subtotal');
2601
-							else if($line->qty==2) print img_picto('', 'subsubtotal@subtotal').'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
2786
+							if($line->qty<=1) {
2787
+								print img_picto('', 'subtotal@subtotal');
2788
+							} else if($line->qty==2) {
2789
+								print img_picto('', 'subsubtotal@subtotal').'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
2790
+							}
2602 2791
 						 }
2603 2792
 
2604 2793
 
@@ -2608,21 +2797,24 @@  discard block
 block discarded – undo
2608 2797
 						 $titleStyleUnderline =  strpos($conf->global->SUBTOTAL_TITLE_STYLE, 'U') === false ? '' : ' text-decoration: underline;';
2609 2798
 
2610 2799
 						 if (empty($line->label)) {
2611
-							if ($line->qty >= 91 && $line->qty <= 99 && $conf->global->SUBTOTAL_USE_NEW_FORMAT) print  $line->description.' '.$this->getTitle($object, $line);
2612
-							else print  $line->description;
2613
-						 }
2614
-						 else {
2800
+							if ($line->qty >= 91 && $line->qty <= 99 && $conf->global->SUBTOTAL_USE_NEW_FORMAT) {
2801
+								print  $line->description.' '.$this->getTitle($object, $line);
2802
+							} else {
2803
+								print  $line->description;
2804
+							}
2805
+						 } else {
2615 2806
 
2616 2807
 							if (! empty($conf->global->PRODUIT_DESC_IN_FORM) && !empty($line->description)) {
2617 2808
 								print '<span class="subtotal_label" style="'.$titleStyleItalic.$titleStyleBold.$titleStyleUnderline.'" >'.$line->label.'</span><br><div class="subtotal_desc">'.dol_htmlentitiesbr($line->description).'</div>';
2618
-							}
2619
-							else{
2809
+							} else{
2620 2810
 								print '<span class="subtotal_label classfortooltip '.$titleStyleItalic.$titleStyleBold.$titleStyleUnderline.'" title="'.$line->description.'">'.$line->label.'</span>';
2621 2811
 							}
2622 2812
 
2623 2813
 						 }
2624 2814
 						//if($line->qty>90) print ' : ';
2625
-						if($line->info_bits > 0) echo img_picto($langs->trans('Pagebreak'), 'pagebreak@subtotal');
2815
+						if($line->info_bits > 0) {
2816
+							echo img_picto($langs->trans('Pagebreak'), 'pagebreak@subtotal');
2817
+						}
2626 2818
 
2627 2819
 			?>
2628 2820
 				</td>
@@ -2645,8 +2837,7 @@  discard block
 block discarded – undo
2645 2837
 			</tr>
2646 2838
 <?php
2647 2839
 			return 1;
2648
-		}
2649
-		elseif ($object->element == 'shipping' || $object->element == 'delivery')
2840
+		} elseif ($object->element == 'shipping' || $object->element == 'delivery')
2650 2841
 		{
2651 2842
 			global $form;
2652 2843
 
@@ -2658,13 +2849,25 @@  discard block
 block discarded – undo
2658 2849
 			$extralabelslines=$extrafieldsline->fetch_name_optionals_label($object->table_element_line);
2659 2850
 
2660 2851
 			$colspan = 4;
2661
-			if($object->origin && $object->origin_id > 0) $colspan++;
2662
-			if(! empty($conf->stock->enabled)) $colspan++;
2663
-			if(! empty($conf->productbatch->enabled)) $colspan++;
2664
-			if($object->statut == 0) $colspan++;
2665
-			if($object->statut == 0 && empty($conf->global->SUBTOTAL_ALLOW_REMOVE_BLOCK)) $colspan++;
2852
+			if($object->origin && $object->origin_id > 0) {
2853
+				$colspan++;
2854
+			}
2855
+			if(! empty($conf->stock->enabled)) {
2856
+				$colspan++;
2857
+			}
2858
+			if(! empty($conf->productbatch->enabled)) {
2859
+				$colspan++;
2860
+			}
2861
+			if($object->statut == 0) {
2862
+				$colspan++;
2863
+			}
2864
+			if($object->statut == 0 && empty($conf->global->SUBTOTAL_ALLOW_REMOVE_BLOCK)) {
2865
+				$colspan++;
2866
+			}
2666 2867
 
2667
-			if($object->element == 'delivery') $colspan = 2;
2868
+			if($object->element == 'delivery') {
2869
+				$colspan = 2;
2870
+			}
2668 2871
 
2669 2872
 			print '<!-- origin line id = '.$line->origin_line_id.' -->'; // id of order line
2670 2873
 
@@ -2674,23 +2877,36 @@  discard block
 block discarded – undo
2674 2877
 			<tr <?php echo $bc[$var]; $var=!$var; echo $data; ?> rel="subtotal" id="row-<?php echo $line->id ?>" style="<?php
2675 2878
 					if (!empty($conf->global->SUBTOTAL_USE_NEW_FORMAT))
2676 2879
 					{
2677
-						if($line->qty==99) print 'background:#adadcf';
2678
-						else if($line->qty==98) print 'background:#ddddff;';
2679
-						else if($line->qty<=97 && $line->qty>=91) print 'background:#eeeeff;';
2680
-						else if($line->qty==1) print 'background:#adadcf;';
2681
-						else if($line->qty==2) print 'background:#ddddff;';
2682
-						else if($line->qty==50) print '';
2683
-						else print 'background:#eeeeff;';
2880
+						if($line->qty==99) {
2881
+							print 'background:#adadcf';
2882
+						} else if($line->qty==98) {
2883
+							print 'background:#ddddff;';
2884
+						} else if($line->qty<=97 && $line->qty>=91) {
2885
+							print 'background:#eeeeff;';
2886
+						} else if($line->qty==1) {
2887
+							print 'background:#adadcf;';
2888
+						} else if($line->qty==2) {
2889
+							print 'background:#ddddff;';
2890
+						} else if($line->qty==50) {
2891
+							print '';
2892
+						} else {
2893
+							print 'background:#eeeeff;';
2894
+						}
2684 2895
 
2685 2896
 						//A compléter si on veux plus de nuances de couleurs avec les niveau 4,5,6,7,8 et 9
2686
-					}
2687
-					else
2897
+					} else
2688 2898
 					{
2689
-						if($line->qty==99) print 'background:#ddffdd';
2690
-						else if($line->qty==98) print 'background:#ddddff;';
2691
-						else if($line->qty==2) print 'background:#eeeeff; ';
2692
-						else if($line->qty==50) print '';
2693
-						else print 'background:#eeffee;' ;
2899
+						if($line->qty==99) {
2900
+							print 'background:#ddffdd';
2901
+						} else if($line->qty==98) {
2902
+							print 'background:#ddddff;';
2903
+						} else if($line->qty==2) {
2904
+							print 'background:#eeeeff; ';
2905
+						} else if($line->qty==50) {
2906
+							print '';
2907
+						} else {
2908
+							print 'background:#eeffee;' ;
2909
+						}
2694 2910
 					}
2695 2911
 
2696 2912
 			?>;">
@@ -2712,14 +2928,19 @@  discard block
 block discarded – undo
2712 2928
 				{
2713 2929
 					echo str_repeat('&nbsp;&nbsp;&nbsp;', $line->qty-1);
2714 2930
 
2715
-					if (TSubtotal::isTitle($line)) print img_picto('', 'subtotal@subtotal').'<span style="font-size:9px;margin-left:-3px;">'.$line->qty.'</span>&nbsp;&nbsp;';
2716
-					else print img_picto('', 'subtotal2@subtotal').'<span style="font-size:9px;margin-left:-1px;">'.(100-$line->qty).'</span>&nbsp;&nbsp;';
2931
+					if (TSubtotal::isTitle($line)) {
2932
+						print img_picto('', 'subtotal@subtotal').'<span style="font-size:9px;margin-left:-3px;">'.$line->qty.'</span>&nbsp;&nbsp;';
2933
+					} else {
2934
+						print img_picto('', 'subtotal2@subtotal').'<span style="font-size:9px;margin-left:-1px;">'.(100-$line->qty).'</span>&nbsp;&nbsp;';
2935
+					}
2717 2936
 				}
2718
-			}
2719
-			else
2937
+			} else
2720 2938
 			{
2721
-				if($line->qty<=1) print img_picto('', 'subtotal@subtotal');
2722
-				else if($line->qty==2) print img_picto('', 'subsubtotal@subtotal').'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
2939
+				if($line->qty<=1) {
2940
+					print img_picto('', 'subtotal@subtotal');
2941
+				} else if($line->qty==2) {
2942
+					print img_picto('', 'subsubtotal@subtotal').'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
2943
+				}
2723 2944
 			}
2724 2945
 
2725 2946
 
@@ -2729,19 +2950,22 @@  discard block
 block discarded – undo
2729 2950
 			$titleStyleUnderline =  strpos($conf->global->SUBTOTAL_TITLE_STYLE, 'U') === false ? '' : ' text-decoration: underline;';
2730 2951
 
2731 2952
 			if (empty($line->label)) {
2732
-				if ($line->qty >= 91 && $line->qty <= 99 && $conf->global->SUBTOTAL_USE_NEW_FORMAT) print  $line->description.' '.$this->getTitle($object, $line);
2733
-				else print  $line->description;
2734
-			}
2735
-			else {
2953
+				if ($line->qty >= 91 && $line->qty <= 99 && $conf->global->SUBTOTAL_USE_NEW_FORMAT) {
2954
+					print  $line->description.' '.$this->getTitle($object, $line);
2955
+				} else {
2956
+					print  $line->description;
2957
+				}
2958
+			} else {
2736 2959
 				if (! empty($conf->global->PRODUIT_DESC_IN_FORM) && !empty($line->description)) {
2737 2960
 					print '<span class="subtotal_label" style="'.$titleStyleItalic.$titleStyleBold.$titleStyleUnderline.'" >'.$line->label.'</span><br><div class="subtotal_desc">'.dol_htmlentitiesbr($line->description).'</div>';
2738
-				}
2739
-				else{
2961
+				} else{
2740 2962
 					print '<span class="subtotal_label classfortooltip '.$titleStyleItalic.$titleStyleBold.$titleStyleUnderline.'" title="'.$line->description.'">'.$line->label.'</span>';
2741 2963
 				}
2742 2964
 			}
2743 2965
 			//if($line->qty>90) print ' : ';
2744
-			if($line->info_bits > 0) echo img_picto($langs->trans('Pagebreak'), 'pagebreak@subtotal');
2966
+			if($line->info_bits > 0) {
2967
+				echo img_picto($langs->trans('Pagebreak'), 'pagebreak@subtotal');
2968
+			}
2745 2969
 
2746 2970
 			?>
2747 2971
 				</td>
@@ -2817,33 +3041,51 @@  discard block
 block discarded – undo
2817 3041
 			if (TSubtotal::isModSubtotalLine($line))
2818 3042
 			{
2819 3043
 				$object->tpl['subtotal'] = $line->id;
2820
-				if (TSubtotal::isTitle($line)) $object->tpl['sub-type'] = 'title';
2821
-				else if (TSubtotal::isSubtotal($line)) $object->tpl['sub-type'] = 'total';
3044
+				if (TSubtotal::isTitle($line)) {
3045
+					$object->tpl['sub-type'] = 'title';
3046
+				} else if (TSubtotal::isSubtotal($line)) {
3047
+					$object->tpl['sub-type'] = 'total';
3048
+				}
2822 3049
 
2823 3050
 				$object->tpl['sub-tr-style'] = '';
2824 3051
 				if (!empty($conf->global->SUBTOTAL_USE_NEW_FORMAT))
2825 3052
 				{
2826
-					if($line->qty==99) $object->tpl['sub-tr-style'].= 'background:#adadcf';
2827
-					else if($line->qty==98) $object->tpl['sub-tr-style'].= 'background:#ddddff;';
2828
-					else if($line->qty<=97 && $line->qty>=91) $object->tpl['sub-tr-style'].= 'background:#eeeeff;';
2829
-					else if($line->qty==1) $object->tpl['sub-tr-style'].= 'background:#adadcf;';
2830
-					else if($line->qty==2) $object->tpl['sub-tr-style'].= 'background:#ddddff;';
2831
-					else if($line->qty==50) $object->tpl['sub-tr-style'].= '';
2832
-					else $object->tpl['sub-tr-style'].= 'background:#eeeeff;';
3053
+					if($line->qty==99) {
3054
+						$object->tpl['sub-tr-style'].= 'background:#adadcf';
3055
+					} else if($line->qty==98) {
3056
+						$object->tpl['sub-tr-style'].= 'background:#ddddff;';
3057
+					} else if($line->qty<=97 && $line->qty>=91) {
3058
+						$object->tpl['sub-tr-style'].= 'background:#eeeeff;';
3059
+					} else if($line->qty==1) {
3060
+						$object->tpl['sub-tr-style'].= 'background:#adadcf;';
3061
+					} else if($line->qty==2) {
3062
+						$object->tpl['sub-tr-style'].= 'background:#ddddff;';
3063
+					} else if($line->qty==50) {
3064
+						$object->tpl['sub-tr-style'].= '';
3065
+					} else {
3066
+						$object->tpl['sub-tr-style'].= 'background:#eeeeff;';
3067
+					}
2833 3068
 
2834 3069
 					//A compléter si on veux plus de nuances de couleurs avec les niveau 4,5,6,7,8 et 9
2835
-				}
2836
-				else
3070
+				} else
2837 3071
 				{
2838
-					if($line->qty==99) $object->tpl['sub-tr-style'].= 'background:#ddffdd';
2839
-					else if($line->qty==98) $object->tpl['sub-tr-style'].= 'background:#ddddff;';
2840
-					else if($line->qty==2) $object->tpl['sub-tr-style'].= 'background:#eeeeff; ';
2841
-					else if($line->qty==50) $object->tpl['sub-tr-style'].= '';
2842
-					else $object->tpl['sub-tr-style'].= 'background:#eeffee;' ;
3072
+					if($line->qty==99) {
3073
+						$object->tpl['sub-tr-style'].= 'background:#ddffdd';
3074
+					} else if($line->qty==98) {
3075
+						$object->tpl['sub-tr-style'].= 'background:#ddddff;';
3076
+					} else if($line->qty==2) {
3077
+						$object->tpl['sub-tr-style'].= 'background:#eeeeff; ';
3078
+					} else if($line->qty==50) {
3079
+						$object->tpl['sub-tr-style'].= '';
3080
+					} else {
3081
+						$object->tpl['sub-tr-style'].= 'background:#eeffee;' ;
3082
+					}
2843 3083
 				}
2844 3084
 
2845 3085
 				$object->tpl['sub-td-style'] = '';
2846
-				if ($line->qty>90) $object->tpl['sub-td-style'] = 'style="text-align:right"';
3086
+				if ($line->qty>90) {
3087
+					$object->tpl['sub-td-style'] = 'style="text-align:right"';
3088
+				}
2847 3089
 
2848 3090
 
2849 3091
 				if ($conf->global->SUBTOTAL_USE_NEW_FORMAT)
@@ -2852,15 +3094,20 @@  discard block
 block discarded – undo
2852 3094
 					{
2853 3095
 						$object->tpl["sublabel"] = str_repeat('&nbsp;&nbsp;&nbsp;', $line->qty-1);
2854 3096
 
2855
-						if (TSubtotal::isTitle($line)) $object->tpl["sublabel"].= img_picto('', 'subtotal@subtotal').'<span style="font-size:9px;margin-left:-3px;">'.$line->qty.'</span>&nbsp;&nbsp;';
2856
-						else $object->tpl["sublabel"].= img_picto('', 'subtotal2@subtotal').'<span style="font-size:9px;margin-left:-1px;">'.(100-$line->qty).'</span>&nbsp;&nbsp;';
3097
+						if (TSubtotal::isTitle($line)) {
3098
+							$object->tpl["sublabel"].= img_picto('', 'subtotal@subtotal').'<span style="font-size:9px;margin-left:-3px;">'.$line->qty.'</span>&nbsp;&nbsp;';
3099
+						} else {
3100
+							$object->tpl["sublabel"].= img_picto('', 'subtotal2@subtotal').'<span style="font-size:9px;margin-left:-1px;">'.(100-$line->qty).'</span>&nbsp;&nbsp;';
3101
+						}
2857 3102
 					}
2858
-				}
2859
-				else
3103
+				} else
2860 3104
 				{
2861 3105
 					$object->tpl["sublabel"] = '';
2862
-					if($line->qty<=1) $object->tpl["sublabel"] = img_picto('', 'subtotal@subtotal');
2863
-					else if($line->qty==2) $object->tpl["sublabel"] = img_picto('', 'subsubtotal@subtotal').'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
3106
+					if($line->qty<=1) {
3107
+						$object->tpl["sublabel"] = img_picto('', 'subtotal@subtotal');
3108
+					} else if($line->qty==2) {
3109
+						$object->tpl["sublabel"] = img_picto('', 'subsubtotal@subtotal').'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
3110
+					}
2864 3111
 				}
2865 3112
 
2866 3113
 				// Get display styles and apply them
@@ -2869,15 +3116,16 @@  discard block
 block discarded – undo
2869 3116
 				$titleStyleUnderline =  strpos($conf->global->SUBTOTAL_TITLE_STYLE, 'U') === false ? '' : ' text-decoration: underline;';
2870 3117
 
2871 3118
 				if (empty($line->label)) {
2872
-					if ($line->qty >= 91 && $line->qty <= 99 && $conf->global->SUBTOTAL_USE_NEW_FORMAT) $object->tpl["sublabel"].=  $line->description.' '.$this->getTitle($object, $line);
2873
-					else $object->tpl["sublabel"].=  $line->description;
2874
-				}
2875
-				else {
3119
+					if ($line->qty >= 91 && $line->qty <= 99 && $conf->global->SUBTOTAL_USE_NEW_FORMAT) {
3120
+						$object->tpl["sublabel"].=  $line->description.' '.$this->getTitle($object, $line);
3121
+					} else {
3122
+						$object->tpl["sublabel"].=  $line->description;
3123
+					}
3124
+				} else {
2876 3125
 
2877 3126
 					if (! empty($conf->global->PRODUIT_DESC_IN_FORM) && !empty($line->description)) {
2878 3127
 						$object->tpl["sublabel"].= '<span class="subtotal_label" style="'.$titleStyleItalic.$titleStyleBold.$titleStyleUnderline.'" >'.$line->label.'</span><br><div class="subtotal_desc">'.dol_htmlentitiesbr($line->description).'</div>';
2879
-					}
2880
-					else{
3128
+					} else{
2881 3129
 						$object->tpl["sublabel"].= '<span class="subtotal_label classfortooltip '.$titleStyleItalic.$titleStyleBold.$titleStyleUnderline.'" title="'.$line->description.'">'.$line->label.'</span>';
2882 3130
 					}
2883 3131
 
@@ -3044,10 +3292,9 @@  discard block
 block discarded – undo
3044 3292
 
3045 3293
 	    if(TSubtotal::isTitle($line)){
3046 3294
 	        $ThtmlData['data-issubtotal'] = 'title';
3047
-	    }elseif(TSubtotal::isSubtotal($line)){
3295
+	    } elseif(TSubtotal::isSubtotal($line)){
3048 3296
 	        $ThtmlData['data-issubtotal'] = 'subtotal';
3049
-	    }
3050
-	    else{
3297
+	    } else{
3051 3298
 	        $ThtmlData['data-issubtotal'] = 'freetext';
3052 3299
 	    }
3053 3300
 
@@ -3057,7 +3304,9 @@  discard block
 block discarded – undo
3057 3304
 
3058 3305
 	    // hook
3059 3306
 	    $reshook = $hookmanager->executeHooks('subtotalLineHtmlData',$parameters,$object,$action); // Note that $action and $object may have been modified by hook
3060
-	    if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
3307
+	    if ($reshook < 0) {
3308
+	    	setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
3309
+	    }
3061 3310
 	    if ($reshook>0)
3062 3311
 	    {
3063 3312
 	        $ThtmlData = $hookmanager->resArray;
Please login to merge, or discard this patch.
lib/subtotal.lib.php 3 patches
Indentation   +34 added lines, -34 removed lines patch added patch discarded remove patch
@@ -25,25 +25,25 @@  discard block
 block discarded – undo
25 25
 
26 26
 function subtotalAdminPrepareHead()
27 27
 {
28
-    global $langs, $conf;
28
+	global $langs, $conf;
29 29
 
30
-    $langs->load("subtotal@subtotal");
30
+	$langs->load("subtotal@subtotal");
31 31
 
32
-    $h = 0;
33
-    $head = array();
32
+	$h = 0;
33
+	$head = array();
34 34
 
35
-    $head[$h][0] = dol_buildpath("/subtotal/admin/subtotal_setup.php", 1);
36
-    $head[$h][1] = $langs->trans("Parameters");
37
-    $head[$h][2] = 'settings';
38
-    $h++;
39
-    $head[$h][0] = dol_buildpath("/subtotal/admin/subtotal_about.php", 1);
40
-    $head[$h][1] = $langs->trans("About");
41
-    $head[$h][2] = 'about';
42
-    $h++;
35
+	$head[$h][0] = dol_buildpath("/subtotal/admin/subtotal_setup.php", 1);
36
+	$head[$h][1] = $langs->trans("Parameters");
37
+	$head[$h][2] = 'settings';
38
+	$h++;
39
+	$head[$h][0] = dol_buildpath("/subtotal/admin/subtotal_about.php", 1);
40
+	$head[$h][1] = $langs->trans("About");
41
+	$head[$h][2] = 'about';
42
+	$h++;
43 43
 
44
-    complete_head_from_modules($conf, $langs, $object, $head, $h, 'subtotal', $showLabel=false);
44
+	complete_head_from_modules($conf, $langs, $object, $head, $h, 'subtotal', $showLabel=false);
45 45
 
46
-    return $head;
46
+	return $head;
47 47
 }
48 48
 
49 49
 function getHtmlSelectTitle(&$object, $showLabel=false)
@@ -132,8 +132,8 @@  discard block
 block discarded – undo
132 132
 	$label = GETPOST('line-title', 'none');
133 133
 	$description = ($line->qty>90) ? '' : GETPOST('line-description', 'restricthtml');
134 134
 	$pagebreak = GETPOST('line-pagebreak', 'int');
135
-    $showTotalHT = GETPOST('line-showTotalHT', 'int');
136
-    $showReduc = GETPOST('line-showReduc', 'int');
135
+	$showTotalHT = GETPOST('line-showTotalHT', 'int');
136
+	$showReduc = GETPOST('line-showReduc', 'int');
137 137
 
138 138
 	$level = GETPOST('subtotal_level', 'int');
139 139
 	if (!empty($level))
@@ -141,8 +141,8 @@  discard block
 block discarded – undo
141 141
 		if ($line->qty > 90) $line->qty = 100 - $level; // Si on edit une ligne sous-total
142 142
 		else $line->qty = $level;
143 143
 	}
144
-    $line->array_options['options_show_total_ht'] = $showTotalHT;
145
-    $line->array_options['options_show_reduc'] = $showReduc;
144
+	$line->array_options['options_show_total_ht'] = $showTotalHT;
145
+	$line->array_options['options_show_reduc'] = $showReduc;
146 146
 	
147 147
 	$res = TSubtotal::doUpdateLine($object, $line->id, $description, 0, $line->qty, 0, '', '', 0, 9, 0, 0, 'HT', $pagebreak, 0, 1, null, 0, $label, TSubtotal::$module_number, $line->array_options);
148 148
 
@@ -279,17 +279,17 @@  discard block
 block discarded – undo
279 279
 			$classname = ucfirst($element);
280 280
 			
281 281
 			switch ($element) {
282
-			    case 'supplier_proposal':
283
-			        $classname = 'SupplierProposal';
284
-			        break;
282
+				case 'supplier_proposal':
283
+					$classname = 'SupplierProposal';
284
+					break;
285 285
 			        
286
-			    case 'order_supplier':
287
-			        $classname = 'CommandeFournisseur';
288
-			        break;
286
+				case 'order_supplier':
287
+					$classname = 'CommandeFournisseur';
288
+					break;
289 289
 			        
290
-			    case 'invoice_supplier':
291
-			        $classname = 'FactureFournisseur';
292
-			        break;
290
+				case 'invoice_supplier':
291
+					$classname = 'FactureFournisseur';
292
+					break;
293 293
 			}
294 294
 			
295 295
 			$object = new $classname($db); // Propal | Commande | Facture
@@ -363,14 +363,14 @@  discard block
 block discarded – undo
363 363
 		else $res = $line->update($user, $notrigger);
364 364
 	}
365 365
 	else {
366
-	    if(in_array($object->element, array('invoice_supplier', 'order_supplier', 'supplier_proposal'))) {
367
-	        if(empty($line->label)) $line->label = $line->description; // supplier lines don't have the field label
366
+		if(in_array($object->element, array('invoice_supplier', 'order_supplier', 'supplier_proposal'))) {
367
+			if(empty($line->label)) $line->label = $line->description; // supplier lines don't have the field label
368 368
 	        
369
-	        require_once(DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php');
370
-	        $extrafields=new ExtraFields($object->db);
371
-	        $extralabels=$extrafields->fetch_name_optionals_label($object->table_element_line,true);
372
-	        $line->fetch_optionals($line->id,$extralabels);
373
-	    }
369
+			require_once(DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php');
370
+			$extrafields=new ExtraFields($object->db);
371
+			$extralabels=$extrafields->fetch_name_optionals_label($object->table_element_line,true);
372
+			$line->fetch_optionals($line->id,$extralabels);
373
+		}
374 374
 		$line->array_options['options_subtotal_nc'] = 0;
375 375
 		if($object->element == 'order_supplier') $line->update($user);
376 376
 		$res = TSubtotal::doUpdateLine($object, $line->id, $line->desc, $line->subprice, $line->qty, $line->remise_percent, $line->date_start, $line->date_end, $line->tva_tx, $line->product_type, $line->localtax1_tx, $line->localtax2_tx, 'HT', $line->info_bits, $line->fk_parent_line, $line->skip_update_total, $line->fk_fournprice, $line->pa_ht, $line->label, $line->special_code, $line->array_options, $line->situation_percent, $line->fk_unit, $notrigger);
Please login to merge, or discard this patch.
Spacing   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -41,21 +41,21 @@  discard block
 block discarded – undo
41 41
     $head[$h][2] = 'about';
42 42
     $h++;
43 43
 
44
-    complete_head_from_modules($conf, $langs, $object, $head, $h, 'subtotal', $showLabel=false);
44
+    complete_head_from_modules($conf, $langs, $object, $head, $h, 'subtotal', $showLabel = false);
45 45
 
46 46
     return $head;
47 47
 }
48 48
 
49
-function getHtmlSelectTitle(&$object, $showLabel=false)
49
+function getHtmlSelectTitle(&$object, $showLabel = false)
50 50
 {
51 51
 	global $langs;
52 52
 	
53
-	require_once DOL_DOCUMENT_ROOT . '/core/lib/functions.lib.php';
53
+	require_once DOL_DOCUMENT_ROOT.'/core/lib/functions.lib.php';
54 54
 	dol_include_once('/subtotal/class/subtotal.class.php');
55 55
 	$TTitle = TSubtotal::getAllTitleFromDocument($object);
56 56
 	$html = '';
57
-	if ($showLabel) $html.= '<label for="under_title">'.$langs->trans('subtotalLabelForUnderTitle').'</label>';
58
-	$html.= '<select onChange="$(\'select[name=under_title]\').val(this.value);" name="under_title" class="under_title minwidth200"><option value="-1"></option>';
57
+	if ($showLabel) $html .= '<label for="under_title">'.$langs->trans('subtotalLabelForUnderTitle').'</label>';
58
+	$html .= '<select onChange="$(\'select[name=under_title]\').val(this.value);" name="under_title" class="under_title minwidth200"><option value="-1"></option>';
59 59
 	
60 60
 	$nbsp = '&nbsp;';
61 61
 	foreach ($TTitle as &$line)
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
70 70
 
71 71
 function getTFreeText()
72 72
 {
73
-	global $db,$conf;
73
+	global $db, $conf;
74 74
 	
75 75
 	$TFreeText = array();
76 76
 	
@@ -88,19 +88,19 @@  discard block
 block discarded – undo
88 88
 	return $TFreeText;
89 89
 }
90 90
 
91
-function getHtmlSelectFreeText($withEmpty=true)
91
+function getHtmlSelectFreeText($withEmpty = true)
92 92
 {
93 93
 	global $langs;
94 94
 	
95 95
 	$TFreeText = getTFreeText();
96 96
 	$html = '<label for="free_text">'.$langs->trans('subtotalLabelForFreeText').'</label>';
97
-	$html.= '<select onChange="getTFreeText($(this));" name="free_text" class="minwidth200">';
98
-	if ($withEmpty) $html.= '<option value=""></option>';
97
+	$html .= '<select onChange="getTFreeText($(this));" name="free_text" class="minwidth200">';
98
+	if ($withEmpty) $html .= '<option value=""></option>';
99 99
 
100 100
 	$TFreeTextContents = array();
101 101
 	foreach ($TFreeText as $id => $tab)
102 102
 	{
103
-		$html.= '<option value="'.$id.'">'.$tab->label.'</option>';
103
+		$html .= '<option value="'.$id.'">'.$tab->label.'</option>';
104 104
 		$TFreeTextContents[$id] = $tab->content;
105 105
 	}
106 106
 
@@ -130,7 +130,7 @@  discard block
 block discarded – undo
130 130
 	global $conf;
131 131
 
132 132
 	$label = GETPOST('line-title', 'none');
133
-	$description = ($line->qty>90) ? '' : GETPOST('line-description', 'restricthtml');
133
+	$description = ($line->qty > 90) ? '' : GETPOST('line-description', 'restricthtml');
134 134
 	$pagebreak = GETPOST('line-pagebreak', 'int');
135 135
     $showTotalHT = GETPOST('line-showTotalHT', 'int');
136 136
     $showReduc = GETPOST('line-showReduc', 'int');
@@ -182,7 +182,7 @@  discard block
 block discarded – undo
182 182
 
183 183
 function _updateSubtotalBloc($object, $line)
184 184
 {
185
-	global $conf,$langs;
185
+	global $conf, $langs;
186 186
 	
187 187
 	$subtotal_tva_tx = $subtotal_tva_tx_init = GETPOST('subtotal_tva_tx', 'int');
188 188
 	$subtotal_progress = $subtotal_progress_init = GETPOST('subtotal_progress', 'int');
@@ -261,9 +261,9 @@  discard block
 block discarded – undo
261 261
  * @param	$lineid			= title lineid
262 262
  * @param	$subtotal_nc	0 = "Compris" prise en compte des totaux des lignes; 1 = "Non compris" non prise en compte des totaux du bloc; null = update de toutes les lignes 
263 263
  */
264
-function _updateLineNC($element, $elementid, $lineid, $subtotal_nc=null, $notrigger = 0)
264
+function _updateLineNC($element, $elementid, $lineid, $subtotal_nc = null, $notrigger = 0)
265 265
 {
266
-	global $db,$langs,$tmp_object_nc;
266
+	global $db, $langs, $tmp_object_nc;
267 267
 	
268 268
 	$error = 0;
269 269
 	if (empty($element)) $error++;
@@ -303,7 +303,7 @@  discard block
 block discarded – undo
303 303
 	{
304 304
 		foreach ($object->lines as &$l)
305 305
 		{
306
-			if($l->id == $lineid) {
306
+			if ($l->id == $lineid) {
307 307
 				$line = $l;
308 308
 				break;
309 309
 			}
@@ -313,12 +313,12 @@  discard block
 block discarded – undo
313 313
 		{
314 314
 			$db->begin();
315 315
 			
316
-			if(TSubtotal::isModSubtotalLine($line))
316
+			if (TSubtotal::isModSubtotalLine($line))
317 317
 			{
318
-				if(TSubtotal::isTitle($line)) {
318
+				if (TSubtotal::isTitle($line)) {
319 319
 					// Update le contenu du titre (ainsi que le titre lui même)
320 320
 					$TTitleBlock = TSubtotal::getLinesFromTitleId($object, $lineid, true);
321
-					foreach($TTitleBlock as &$line_block)
321
+					foreach ($TTitleBlock as &$line_block)
322 322
 					{
323 323
 						$res = doUpdate($object, $line_block, $subtotal_nc, $notrigger);
324 324
 					}
@@ -352,10 +352,10 @@  discard block
 block discarded – undo
352 352
 	
353 353
 	if (TSubtotal::isFreeText($line) || TSubtotal::isSubtotal($line)) return 1;
354 354
 	// Update extrafield et total
355
-	if(! empty($subtotal_nc)) {
355
+	if (!empty($subtotal_nc)) {
356 356
 		$line->total_ht = $line->total_tva = $line->total_ttc = $line->total_localtax1 = $line->total_localtax2 = 
357 357
 			$line->multicurrency_total_ht = $line->multicurrency_total_tva = $line->multicurrency_total_ttc = 0;
358
-		if(!empty($conf->global->SUBTOTAL_NONCOMPRIS_UPDATE_PA_HT)) $line->pa_ht = '0';
358
+		if (!empty($conf->global->SUBTOTAL_NONCOMPRIS_UPDATE_PA_HT)) $line->pa_ht = '0';
359 359
 
360 360
 		$line->array_options['options_subtotal_nc'] = 1;
361 361
 
@@ -363,16 +363,16 @@  discard block
 block discarded – undo
363 363
 		else $res = $line->update($user, $notrigger);
364 364
 	}
365 365
 	else {
366
-	    if(in_array($object->element, array('invoice_supplier', 'order_supplier', 'supplier_proposal'))) {
367
-	        if(empty($line->label)) $line->label = $line->description; // supplier lines don't have the field label
366
+	    if (in_array($object->element, array('invoice_supplier', 'order_supplier', 'supplier_proposal'))) {
367
+	        if (empty($line->label)) $line->label = $line->description; // supplier lines don't have the field label
368 368
 	        
369 369
 	        require_once(DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php');
370
-	        $extrafields=new ExtraFields($object->db);
371
-	        $extralabels=$extrafields->fetch_name_optionals_label($object->table_element_line,true);
372
-	        $line->fetch_optionals($line->id,$extralabels);
370
+	        $extrafields = new ExtraFields($object->db);
371
+	        $extralabels = $extrafields->fetch_name_optionals_label($object->table_element_line, true);
372
+	        $line->fetch_optionals($line->id, $extralabels);
373 373
 	    }
374 374
 		$line->array_options['options_subtotal_nc'] = 0;
375
-		if($object->element == 'order_supplier') $line->update($user);
375
+		if ($object->element == 'order_supplier') $line->update($user);
376 376
 		$res = TSubtotal::doUpdateLine($object, $line->id, $line->desc, $line->subprice, $line->qty, $line->remise_percent, $line->date_start, $line->date_end, $line->tva_tx, $line->product_type, $line->localtax1_tx, $line->localtax2_tx, 'HT', $line->info_bits, $line->fk_parent_line, $line->skip_update_total, $line->fk_fournprice, $line->pa_ht, $line->label, $line->special_code, $line->array_options, $line->situation_percent, $line->fk_unit, $notrigger);
377 377
 	}
378 378
 	
Please login to merge, or discard this patch.
Braces   +73 added lines, -33 removed lines patch added patch discarded remove patch
@@ -54,7 +54,9 @@  discard block
 block discarded – undo
54 54
 	dol_include_once('/subtotal/class/subtotal.class.php');
55 55
 	$TTitle = TSubtotal::getAllTitleFromDocument($object);
56 56
 	$html = '';
57
-	if ($showLabel) $html.= '<label for="under_title">'.$langs->trans('subtotalLabelForUnderTitle').'</label>';
57
+	if ($showLabel) {
58
+		$html.= '<label for="under_title">'.$langs->trans('subtotalLabelForUnderTitle').'</label>';
59
+	}
58 60
 	$html.= '<select onChange="$(\'select[name=under_title]\').val(this.value);" name="under_title" class="under_title minwidth200"><option value="-1"></option>';
59 61
 	
60 62
 	$nbsp = '&nbsp;';
@@ -95,7 +97,9 @@  discard block
 block discarded – undo
95 97
 	$TFreeText = getTFreeText();
96 98
 	$html = '<label for="free_text">'.$langs->trans('subtotalLabelForFreeText').'</label>';
97 99
 	$html.= '<select onChange="getTFreeText($(this));" name="free_text" class="minwidth200">';
98
-	if ($withEmpty) $html.= '<option value=""></option>';
100
+	if ($withEmpty) {
101
+		$html.= '<option value=""></option>';
102
+	}
99 103
 
100 104
 	$TFreeTextContents = array();
101 105
 	foreach ($TFreeText as $id => $tab)
@@ -138,8 +142,13 @@  discard block
 block discarded – undo
138 142
 	$level = GETPOST('subtotal_level', 'int');
139 143
 	if (!empty($level))
140 144
 	{
141
-		if ($line->qty > 90) $line->qty = 100 - $level; // Si on edit une ligne sous-total
142
-		else $line->qty = $level;
145
+		if ($line->qty > 90) {
146
+			$line->qty = 100 - $level;
147
+		}
148
+		// Si on edit une ligne sous-total
149
+		else {
150
+			$line->qty = $level;
151
+		}
143 152
 	}
144 153
     $line->array_options['options_show_total_ht'] = $showTotalHT;
145 154
     $line->array_options['options_show_reduc'] = $showReduc;
@@ -147,9 +156,13 @@  discard block
 block discarded – undo
147 156
 	$res = TSubtotal::doUpdateLine($object, $line->id, $description, 0, $line->qty, 0, '', '', 0, 9, 0, 0, 'HT', $pagebreak, 0, 1, null, 0, $label, TSubtotal::$module_number, $line->array_options);
148 157
 
149 158
 	$TKey = null;
150
-	if ($line->element == 'propaldet') $TKey = explode(',', $conf->global->SUBTOTAL_LIST_OF_EXTRAFIELDS_PROPALDET);
151
-	elseif ($line->element == 'commandedet') $TKey = explode(',', $conf->global->SUBTOTAL_LIST_OF_EXTRAFIELDS_COMMANDEDET);
152
-	elseif ($line->element == 'facturedet') $TKey = explode(',', $conf->global->SUBTOTAL_LIST_OF_EXTRAFIELDS_FACTUREDET);
159
+	if ($line->element == 'propaldet') {
160
+		$TKey = explode(',', $conf->global->SUBTOTAL_LIST_OF_EXTRAFIELDS_PROPALDET);
161
+	} elseif ($line->element == 'commandedet') {
162
+		$TKey = explode(',', $conf->global->SUBTOTAL_LIST_OF_EXTRAFIELDS_COMMANDEDET);
163
+	} elseif ($line->element == 'facturedet') {
164
+		$TKey = explode(',', $conf->global->SUBTOTAL_LIST_OF_EXTRAFIELDS_FACTUREDET);
165
+	}
153 166
 	// TODO ajouter la partie fournisseur
154 167
 
155 168
 	// TODO remove "true"
@@ -199,13 +212,18 @@  discard block
 block discarded – undo
199 212
 			{
200 213
 				$subtotal_tva_tx = $subtotal_tva_tx_init; // ré-init car la variable peut évoluer
201 214
 					
202
-				if (!empty($showBlockExtrafields)) $line->array_options = $array_options;
203
-				if ($subtotal_tva_tx == '') $subtotal_tva_tx = $line->tva_tx;
215
+				if (!empty($showBlockExtrafields)) {
216
+					$line->array_options = $array_options;
217
+				}
218
+				if ($subtotal_tva_tx == '') {
219
+					$subtotal_tva_tx = $line->tva_tx;
220
+				}
204 221
 				if ($object->element == 'facture' && !empty($conf->global->INVOICE_USE_SITUATION) && $object->type == Facture::TYPE_SITUATION)
205 222
 				{
206 223
 					$subtotal_progress = $subtotal_progress_init;
207
-					if ($subtotal_progress == '') $subtotal_progress = $line->situation_percent;
208
-					else
224
+					if ($subtotal_progress == '') {
225
+						$subtotal_progress = $line->situation_percent;
226
+					} else
209 227
 					{
210 228
 						$prev_percent = $line->get_prev_progress($object->id);
211 229
 						if ($subtotal_progress < $prev_percent)
@@ -218,14 +236,21 @@  discard block
 block discarded – undo
218 236
 				
219 237
 				$res = TSubtotal::doUpdateLine($object, $line->id, $line->desc, $line->subprice, $line->qty, $line->remise_percent, $line->date_start, $line->date_end, $subtotal_tva_tx, $line->product_type, $line->localtax1_tx, $line->localtax2_tx, 'HT', $line->info_bits, $line->fk_parent_line, $line->skip_update_total, $line->fk_fournprice, $line->pa_ht, $line->label, $line->special_code, $line->array_options, $subtotal_progress, $line->fk_unit);
220 238
 
221
-				if ($res > 0) $success_updated_line++;
222
-				else $error_updated_line++;
239
+				if ($res > 0) {
240
+					$success_updated_line++;
241
+				} else {
242
+					$error_updated_line++;
243
+				}
223 244
 			}
224 245
 		}
225 246
 
226
-		if ($nb_progress_not_updated > 0) setEventMessage($langs->trans('subtotal_nb_progress_not_updated', $nb_progress_not_updated), 'warnings');
247
+		if ($nb_progress_not_updated > 0) {
248
+			setEventMessage($langs->trans('subtotal_nb_progress_not_updated', $nb_progress_not_updated), 'warnings');
249
+		}
227 250
 		
228
-		if ($success_updated_line > 0) setEventMessage($langs->trans('subtotal_success_updated_line', $success_updated_line));
251
+		if ($success_updated_line > 0) {
252
+			setEventMessage($langs->trans('subtotal_success_updated_line', $success_updated_line));
253
+		}
229 254
 		if ($error_updated_line > 0)
230 255
 		{
231 256
 			setEventMessage($langs->trans('subtotal_error_updated_line', $error_updated_line), 'errors');
@@ -266,15 +291,16 @@  discard block
 block discarded – undo
266 291
 	global $db,$langs,$tmp_object_nc;
267 292
 	
268 293
 	$error = 0;
269
-	if (empty($element)) $error++;
294
+	if (empty($element)) {
295
+		$error++;
296
+	}
270 297
 	
271 298
 	if (!$error)
272 299
 	{
273 300
 		if (!empty($tmp_object_nc) && $tmp_object_nc->element == $element && $tmp_object_nc->id == $elementid)
274 301
 		{
275 302
 			$object = $tmp_object_nc;
276
-		}
277
-		else
303
+		} else
278 304
 		{
279 305
 			$classname = ucfirst($element);
280 306
 			
@@ -294,8 +320,11 @@  discard block
 block discarded – undo
294 320
 			
295 321
 			$object = new $classname($db); // Propal | Commande | Facture
296 322
 			$res = $object->fetch($elementid);
297
-			if ($res < 0) $error++;
298
-			else $tmp_object_nc = $object;
323
+			if ($res < 0) {
324
+				$error++;
325
+			} else {
326
+				$tmp_object_nc = $object;
327
+			}
299 328
 		}
300 329
 	}
301 330
 	
@@ -323,21 +352,21 @@  discard block
 block discarded – undo
323 352
 						$res = doUpdate($object, $line_block, $subtotal_nc, $notrigger);
324 353
 					}
325 354
 				}
326
-			}
327
-			else
355
+			} else
328 356
 			{
329 357
 				$res = doUpdate($object, $line, $subtotal_nc, $notrigger);
330 358
 			}
331 359
 			
332 360
 			$res = $object->update_price(1);
333
-			if ($res <= 0) $error++;
361
+			if ($res <= 0) {
362
+				$error++;
363
+			}
334 364
 			
335 365
 			if (!$error)
336 366
 			{
337 367
 				setEventMessage($langs->trans('subtotal_update_nc_success'));
338 368
 				$db->commit();
339
-			}
340
-			else
369
+			} else
341 370
 			{
342 371
 				setEventMessage($langs->trans('subtotal_update_nc_error'), 'errors');
343 372
 				$db->rollback();
@@ -350,21 +379,30 @@  discard block
 block discarded – undo
350 379
 {
351 380
 	global $user, $conf;
352 381
 	
353
-	if (TSubtotal::isFreeText($line) || TSubtotal::isSubtotal($line)) return 1;
382
+	if (TSubtotal::isFreeText($line) || TSubtotal::isSubtotal($line)) {
383
+		return 1;
384
+	}
354 385
 	// Update extrafield et total
355 386
 	if(! empty($subtotal_nc)) {
356 387
 		$line->total_ht = $line->total_tva = $line->total_ttc = $line->total_localtax1 = $line->total_localtax2 = 
357 388
 			$line->multicurrency_total_ht = $line->multicurrency_total_tva = $line->multicurrency_total_ttc = 0;
358
-		if(!empty($conf->global->SUBTOTAL_NONCOMPRIS_UPDATE_PA_HT)) $line->pa_ht = '0';
389
+		if(!empty($conf->global->SUBTOTAL_NONCOMPRIS_UPDATE_PA_HT)) {
390
+			$line->pa_ht = '0';
391
+		}
359 392
 
360 393
 		$line->array_options['options_subtotal_nc'] = 1;
361 394
 
362
-		if ($line->element == 'propaldet') $res = $line->update($notrigger);
363
-		else $res = $line->update($user, $notrigger);
364
-	}
365
-	else {
395
+		if ($line->element == 'propaldet') {
396
+			$res = $line->update($notrigger);
397
+		} else {
398
+			$res = $line->update($user, $notrigger);
399
+		}
400
+	} else {
366 401
 	    if(in_array($object->element, array('invoice_supplier', 'order_supplier', 'supplier_proposal'))) {
367
-	        if(empty($line->label)) $line->label = $line->description; // supplier lines don't have the field label
402
+	        if(empty($line->label)) {
403
+	        	$line->label = $line->description;
404
+	        }
405
+	        // supplier lines don't have the field label
368 406
 	        
369 407
 	        require_once(DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php');
370 408
 	        $extrafields=new ExtraFields($object->db);
@@ -372,7 +410,9 @@  discard block
 block discarded – undo
372 410
 	        $line->fetch_optionals($line->id,$extralabels);
373 411
 	    }
374 412
 		$line->array_options['options_subtotal_nc'] = 0;
375
-		if($object->element == 'order_supplier') $line->update($user);
413
+		if($object->element == 'order_supplier') {
414
+			$line->update($user);
415
+		}
376 416
 		$res = TSubtotal::doUpdateLine($object, $line->id, $line->desc, $line->subprice, $line->qty, $line->remise_percent, $line->date_start, $line->date_end, $line->tva_tx, $line->product_type, $line->localtax1_tx, $line->localtax2_tx, 'HT', $line->info_bits, $line->fk_parent_line, $line->skip_update_total, $line->fk_fournprice, $line->pa_ht, $line->label, $line->special_code, $line->array_options, $line->situation_percent, $line->fk_unit, $notrigger);
377 417
 	}
378 418
 	
Please login to merge, or discard this patch.
config.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 		
4
-	if(is_file('../main.inc.php')) include("../main.inc.php");
5
-	else  if(is_file('../../../main.inc.php')) include("../../../main.inc.php");
4
+	if (is_file('../main.inc.php')) include("../main.inc.php");
5
+	else  if (is_file('../../../main.inc.php')) include("../../../main.inc.php");
6 6
 	else include("../../main.inc.php");
7 7
\ No newline at end of file
Please login to merge, or discard this patch.
Braces   +8 added lines, -3 removed lines patch added patch discarded remove patch
@@ -1,6 +1,11 @@
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 		
4
-	if(is_file('../main.inc.php')) include("../main.inc.php");
5
-	else  if(is_file('../../../main.inc.php')) include("../../../main.inc.php");
6
-	else include("../../main.inc.php");
7 4
\ No newline at end of file
5
+	if(is_file('../main.inc.php')) {
6
+		include("../main.inc.php");
7
+	} else  if(is_file('../../../main.inc.php')) {
8
+		include("../../../main.inc.php");
9
+	} else {
10
+		include("../../main.inc.php");
11
+	}
12
+	
8 13
\ No newline at end of file
Please login to merge, or discard this patch.