Passed
Branch master (5adaa9)
by Alexis
02:53
created
admin/subtotal_about.php 2 patches
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
 // Dolibarr environment
26 26
 $res = @include("../../main.inc.php"); // From htdocs directory
27 27
 if (! $res) {
28
-    $res = @include("../../../main.inc.php"); // From "custom" directory
28
+	$res = @include("../../../main.inc.php"); // From "custom" directory
29 29
 }
30 30
 
31 31
 // Libraries
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
 
38 38
 // Access control
39 39
 if (! $user->admin) {
40
-    accessforbidden();
40
+	accessforbidden();
41 41
 }
42 42
 
43 43
 /*
@@ -48,17 +48,17 @@  discard block
 block discarded – undo
48 48
 
49 49
 // Subheader
50 50
 $linkback = '<a href="' . DOL_URL_ROOT . '/admin/modules.php">'
51
-    . $langs->trans("BackToModuleList") . '</a>';
51
+	. $langs->trans("BackToModuleList") . '</a>';
52 52
 print_fiche_titre($langs->trans($page_name), $linkback);
53 53
 
54 54
 // Configuration header
55 55
 $head = subtotalAdminPrepareHead();
56 56
 dol_fiche_head(
57
-    $head,
58
-    'about',
59
-    $langs->trans("Module104777Name"),
60
-    0,
61
-    'subtotal@subtotal'
57
+	$head,
58
+	'about',
59
+	$langs->trans("Module104777Name"),
60
+	0,
61
+	'subtotal@subtotal'
62 62
 );
63 63
 
64 64
 // About page goes here
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -24,19 +24,19 @@  discard block
 block discarded – undo
24 24
  */
25 25
 // Dolibarr environment
26 26
 $res = @include("../../main.inc.php"); // From htdocs directory
27
-if (! $res) {
27
+if (!$res) {
28 28
     $res = @include("../../../main.inc.php"); // From "custom" directory
29 29
 }
30 30
 
31 31
 // Libraries
32
-require_once DOL_DOCUMENT_ROOT . "/core/lib/admin.lib.php";
32
+require_once DOL_DOCUMENT_ROOT."/core/lib/admin.lib.php";
33 33
 require_once '../lib/subtotal.lib.php';
34 34
 
35 35
 // Translations
36 36
 $langs->load("subtotal@subtotal");
37 37
 
38 38
 // Access control
39
-if (! $user->admin) {
39
+if (!$user->admin) {
40 40
     accessforbidden();
41 41
 }
42 42
 
@@ -47,8 +47,8 @@  discard block
 block discarded – undo
47 47
 llxHeader('', $langs->trans($page_name));
48 48
 
49 49
 // Subheader
50
-$linkback = '<a href="' . DOL_URL_ROOT . '/admin/modules.php">'
51
-    . $langs->trans("BackToModuleList") . '</a>';
50
+$linkback = '<a href="'.DOL_URL_ROOT.'/admin/modules.php">'
51
+    . $langs->trans("BackToModuleList").'</a>';
52 52
 print_fiche_titre($langs->trans($page_name), $linkback);
53 53
 
54 54
 // Configuration header
Please login to merge, or discard this patch.
admin/subtotal_setup.php 3 patches
Indentation   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
28 28
 // Dolibarr environment
29 29
 $res = @include("../../main.inc.php"); // From htdocs directory
30 30
 if (! $res) {
31
-    $res = @include("../../../main.inc.php"); // From "custom" directory
31
+	$res = @include("../../../main.inc.php"); // From "custom" directory
32 32
 }
33 33
 
34 34
 // Libraries
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
 
40 40
 // Access control
41 41
 if (! $user->admin) {
42
-    accessforbidden();
42
+	accessforbidden();
43 43
 }
44 44
 
45 45
 // Parameters
@@ -91,11 +91,11 @@  discard block
 block discarded – undo
91 91
 // Configuration header
92 92
 $head = subtotalAdminPrepareHead();
93 93
 dol_fiche_head(
94
-    $head,
95
-    'settings',
96
-    $langs->trans("Module104777Name"),
97
-    0,
98
-    "subtotal@subtotal"
94
+	$head,
95
+	'settings',
96
+	$langs->trans("Module104777Name"),
97
+	0,
98
+	"subtotal@subtotal"
99 99
 );
100 100
 
101 101
 showParameters();
Please login to merge, or discard this patch.
Spacing   +42 added lines, -42 removed lines patch added patch discarded remove patch
@@ -27,37 +27,37 @@  discard block
 block discarded – undo
27 27
 // Change this following line to use the correct relative path (../, ../../, etc)
28 28
 // Dolibarr environment
29 29
 $res = @include("../../main.inc.php"); // From htdocs directory
30
-if (! $res) {
30
+if (!$res) {
31 31
     $res = @include("../../../main.inc.php"); // From "custom" directory
32 32
 }
33 33
 
34 34
 // Libraries
35
-require_once DOL_DOCUMENT_ROOT . "/core/lib/admin.lib.php";
35
+require_once DOL_DOCUMENT_ROOT."/core/lib/admin.lib.php";
36 36
 require_once '../lib/subtotal.lib.php';
37 37
 
38 38
 $langs->load("subtotal@subtotal");
39 39
 
40 40
 // Access control
41
-if (! $user->admin) {
41
+if (!$user->admin) {
42 42
     accessforbidden();
43 43
 }
44 44
 
45 45
 // Parameters
46 46
 $action = GETPOST('action', 'alpha');
47 47
 
48
-if($action=='save') {
48
+if ($action == 'save') {
49 49
 	
50
-	foreach($_REQUEST['TDivers'] as $name=>$param) {
50
+	foreach ($_REQUEST['TDivers'] as $name=>$param) {
51 51
 		
52
-		dolibarr_set_const($db, $name, $param,'chaine', 0, '', $conf->entity);
52
+		dolibarr_set_const($db, $name, $param, 'chaine', 0, '', $conf->entity);
53 53
 		
54 54
 	}
55 55
 	
56 56
 }
57 57
 
58
-if (preg_match('/set_(.*)/',$action,$reg))
58
+if (preg_match('/set_(.*)/', $action, $reg))
59 59
 {
60
-	$code=$reg[1];
60
+	$code = $reg[1];
61 61
 	$value = GETPOST($code);
62 62
 	if ($code == 'SUBTOTAL_TFIELD_TO_KEEP_WITH_NC') $value = implode(',', $value);
63 63
 	
@@ -83,10 +83,10 @@  discard block
 block discarded – undo
83 83
 
84 84
 
85 85
 
86
-llxHeader('','Gestion de sous-total, à propos','');
86
+llxHeader('', 'Gestion de sous-total, à propos', '');
87 87
 
88
-$linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php">'.$langs->trans("BackToModuleList").'</a>';
89
-print_fiche_titre('Gestion de subtotal',$linkback,'setup');
88
+$linkback = '<a href="'.DOL_URL_ROOT.'/admin/modules.php">'.$langs->trans("BackToModuleList").'</a>';
89
+print_fiche_titre('Gestion de subtotal', $linkback, 'setup');
90 90
 
91 91
 // Configuration header
92 92
 $head = subtotalAdminPrepareHead();
@@ -101,11 +101,11 @@  discard block
 block discarded – undo
101 101
 showParameters();
102 102
 
103 103
 function showParameters() {
104
-	global $db,$conf,$langs,$bc;
104
+	global $db, $conf, $langs, $bc;
105 105
 	
106
-	$html=new Form($db);
106
+	$html = new Form($db);
107 107
 	
108
-	$var=false;
108
+	$var = false;
109 109
 	print '<table class="noborder" width="100%">';
110 110
 	print '<tr class="liste_titre">';
111 111
 	print '<td>'.$langs->trans("Parameters").'</td>'."\n";
@@ -113,7 +113,7 @@  discard block
 block discarded – undo
113 113
 	print '<td align="center" width="100">'.$langs->trans("Value").'</td>'."\n";
114 114
 	print '</tr>';
115 115
 	
116
-	$var=!$var;
116
+	$var = !$var;
117 117
 	print '<tr '.$bc[$var].'>';
118 118
 	print '<td>'.$langs->trans("SUBTOTAL_USE_NEW_FORMAT").'</td>';
119 119
 	print '<td align="center" width="20">&nbsp;</td>';
@@ -121,9 +121,9 @@  discard block
 block discarded – undo
121 121
 	print ajax_constantonoff('SUBTOTAL_USE_NEW_FORMAT');
122 122
 	print '</td></tr>';
123 123
 	
124
-	if((float)DOL_VERSION>=3.8)
124
+	if ((float) DOL_VERSION >= 3.8)
125 125
 	{
126
-		$var=!$var;
126
+		$var = !$var;
127 127
 		print '<tr '.$bc[$var].'>';
128 128
 		print '<td>'.$langs->trans("SUBTOTAL_USE_NUMEROTATION").'</td>';
129 129
 		print '<td align="center" width="20">&nbsp;</td>';
@@ -132,7 +132,7 @@  discard block
 block discarded – undo
132 132
 		print '</td></tr>';	
133 133
 	}
134 134
 	
135
-	$var=!$var;
135
+	$var = !$var;
136 136
 	print '<tr '.$bc[$var].'>';
137 137
 	print '<td>'.$langs->trans("SUBTOTAL_ALLOW_ADD_BLOCK").'</td>';
138 138
 	print '<td align="center" width="20">&nbsp;</td>';
@@ -140,7 +140,7 @@  discard block
 block discarded – undo
140 140
 	print ajax_constantonoff('SUBTOTAL_ALLOW_ADD_BLOCK');
141 141
 	print '</td></tr>';
142 142
 	
143
-	$var=!$var;
143
+	$var = !$var;
144 144
 	print '<tr '.$bc[$var].'>';
145 145
 	print '<td>'.$langs->trans("SUBTOTAL_ALLOW_EDIT_BLOCK").'</td>';
146 146
 	print '<td align="center" width="20">&nbsp;</td>';
@@ -148,7 +148,7 @@  discard block
 block discarded – undo
148 148
 	print ajax_constantonoff('SUBTOTAL_ALLOW_EDIT_BLOCK');
149 149
 	print '</td></tr>';
150 150
 	
151
-	$var=!$var;
151
+	$var = !$var;
152 152
 	print '<tr '.$bc[$var].'>';
153 153
 	print '<td>'.$langs->trans("SUBTOTAL_ALLOW_REMOVE_BLOCK").'</td>';
154 154
 	print '<td align="center" width="20">&nbsp;</td>';
@@ -156,7 +156,7 @@  discard block
 block discarded – undo
156 156
 	print ajax_constantonoff('SUBTOTAL_ALLOW_REMOVE_BLOCK');
157 157
 	print '</td></tr>';
158 158
 	
159
-	$var=!$var;
159
+	$var = !$var;
160 160
 	print '<tr '.$bc[$var].'>';
161 161
 	print '<td>'.$langs->trans("SUBTOTAL_ALLOW_DUPLICATE_BLOCK").'</td>';
162 162
 	print '<td align="center" width="20">&nbsp;</td>';
@@ -164,7 +164,7 @@  discard block
 block discarded – undo
164 164
 	print ajax_constantonoff('SUBTOTAL_ALLOW_DUPLICATE_BLOCK');
165 165
 	print '</td></tr>';
166 166
 	
167
-	$var=!$var;
167
+	$var = !$var;
168 168
 	print '<tr '.$bc[$var].'>';
169 169
 	print '<td>'.$langs->trans("SUBTOTAL_ALLOW_ADD_LINE_UNDER_TITLE").'</td>';
170 170
 	print '<td align="center" width="20">&nbsp;</td>';
@@ -172,7 +172,7 @@  discard block
 block discarded – undo
172 172
 	print ajax_constantonoff('SUBTOTAL_ALLOW_ADD_LINE_UNDER_TITLE');
173 173
 	print '</td></tr>';
174 174
 	
175
-	$var=!$var;
175
+	$var = !$var;
176 176
 	print '<tr '.$bc[$var].'>';
177 177
 	print '<td>'.$langs->trans("SUBTOTAL_ADD_LINE_UNDER_TITLE_AT_END_BLOCK").'</td>';
178 178
 	print '<td align="center" width="20">&nbsp;</td>';
@@ -180,7 +180,7 @@  discard block
 block discarded – undo
180 180
 	print ajax_constantonoff('SUBTOTAL_ADD_LINE_UNDER_TITLE_AT_END_BLOCK');
181 181
 	print '</td></tr>';
182 182
 
183
-	$var=!$var;
183
+	$var = !$var;
184 184
 	print '<tr '.$bc[$var].'>';
185 185
 	print '<td>'.$html->textwithpicto($langs->trans("SUBTOTAL_TEXT_FOR_TITLE_ORDETSTOINVOICE"), $langs->trans("SUBTOTAL_TEXT_FOR_TITLE_ORDETSTOINVOICE_info")).'</td>';
186 186
 	print '<td align="center" width="20">&nbsp;</td>';
@@ -193,7 +193,7 @@  discard block
 block discarded – undo
193 193
 	print '</form>';
194 194
 	print '</td></tr>';
195 195
 	
196
-	$var=!$var;
196
+	$var = !$var;
197 197
 	print '<tr '.$bc[$var].'>';
198 198
 	print '<td>'.$langs->trans("SUBTOTAL_TITLE_STYLE").'</td>';
199 199
 	print '<td align="center" width="20">&nbsp;</td>';
@@ -206,7 +206,7 @@  discard block
 block discarded – undo
206 206
 	print '</form>';
207 207
 	print '</td></tr>';
208 208
 	
209
-	$var=!$var;
209
+	$var = !$var;
210 210
 	print '<tr '.$bc[$var].'>';
211 211
 	print '<td>'.$langs->trans("SUBTOTAL_SUBTOTAL_STYLE").'</td>';
212 212
 	print '<td align="center" width="20">&nbsp;</td>';
@@ -219,7 +219,7 @@  discard block
 block discarded – undo
219 219
 	print '</form>';
220 220
 	print '</td></tr>';
221 221
 	
222
-	$var=!$var;
222
+	$var = !$var;
223 223
 	print '<tr '.$bc[$var].'>';
224 224
 	print '<td>'.$langs->trans("SUBTOTAL_ONE_LINE_IF_HIDE_INNERLINES", $langs->transnoentitiesnoconv('HideInnerLines')).'</td>';
225 225
 	print '<td align="center" width="20">&nbsp;</td>';
@@ -227,7 +227,7 @@  discard block
 block discarded – undo
227 227
 	print ajax_constantonoff('SUBTOTAL_ONE_LINE_IF_HIDE_INNERLINES');
228 228
 	print '</td></tr>';
229 229
 	
230
-	$var=!$var;
230
+	$var = !$var;
231 231
 	print '<tr '.$bc[$var].'>';
232 232
 	print '<td>'.$langs->trans("SUBTOTAL_REPLACE_WITH_VAT_IF_HIDE_INNERLINES", $langs->transnoentitiesnoconv('HideInnerLines')).'</td>';
233 233
 	print '<td align="center" width="20">&nbsp;</td>';
@@ -237,7 +237,7 @@  discard block
 block discarded – undo
237 237
 	
238 238
 	if ((double) DOL_VERSION >= 4.0)
239 239
 	{
240
-		$var=!$var;
240
+		$var = !$var;
241 241
 		print '<tr '.$bc[$var].'>';
242 242
 		print '<td>'.$langs->trans("SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS").'</td>';
243 243
 		print '<td align="center" width="20">&nbsp;</td>';
@@ -245,12 +245,12 @@  discard block
 block discarded – undo
245 245
 		print '<form method="POST" action="'.$_SERVER['PHP_SELF'].'">';
246 246
 		print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
247 247
 		print '<input type="hidden" name="action" value="set_SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS">';
248
-		print $html->selectyesno("SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS",$conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS,1);
248
+		print $html->selectyesno("SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS", $conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS, 1);
249 249
 		print '<input type="submit" class="button" value="'.$langs->trans("Modify").'">';
250 250
 		print '</form>';
251 251
 		print '</td></tr>';
252 252
 		
253
-		$var=!$var;
253
+		$var = !$var;
254 254
 		print '<tr '.$bc[$var].'>';
255 255
 		print '<td>'.$langs->trans("SUBTOTAL_TFIELD_TO_KEEP_WITH_NC").'</td>';
256 256
 		print '<td align="center" width="20">&nbsp;</td>';
@@ -265,7 +265,7 @@  discard block
 block discarded – undo
265 265
 		print '</td></tr>';
266 266
 	}
267 267
 	
268
-	$var=!$var;
268
+	$var = !$var;
269 269
 	print '<tr '.$bc[$var].'>';
270 270
 	print '<td>'.$langs->trans('SUBTOTAL_AUTO_ADD_SUBTOTAL_ON_ADDING_NEW_TITLE').'</td>';
271 271
 	print '<td align="center" width="20">&nbsp;</td>';
@@ -273,7 +273,7 @@  discard block
 block discarded – undo
273 273
 	print ajax_constantonoff('SUBTOTAL_AUTO_ADD_SUBTOTAL_ON_ADDING_NEW_TITLE');
274 274
 	print '</td></tr>';
275 275
 	
276
-	$var=!$var;
276
+	$var = !$var;
277 277
 	print '<tr '.$bc[$var].'>';
278 278
 	print '<td>'.$langs->trans('SUBTOTAL_ALLOW_EXTRAFIELDS_ON_TITLE').'</td>';
279 279
 	print '<td align="center" width="20">&nbsp;</td>';
@@ -285,7 +285,7 @@  discard block
 block discarded – undo
285 285
 	
286 286
 	
287 287
 	
288
-	$var=false;
288
+	$var = false;
289 289
 	print '<table class="noborder" width="100%">';
290 290
 	print '<tr class="liste_titre">';
291 291
 	print '<td>'.$langs->trans("RecapGeneration").'</td>'."\n";
@@ -293,7 +293,7 @@  discard block
 block discarded – undo
293 293
 	print '<td align="center" width="100">'.$langs->trans("Value").'</td>'."\n";
294 294
 	print '</tr>';
295 295
 	
296
-	$var=!$var;
296
+	$var = !$var;
297 297
 	print '<tr '.$bc[$var].'>';
298 298
 	print '<td>'.$langs->trans('SUBTOTAL_KEEP_RECAP_FILE').'</td>';
299 299
 	print '<td align="center" width="20">&nbsp;</td>';
@@ -301,7 +301,7 @@  discard block
 block discarded – undo
301 301
 	print ajax_constantonoff('SUBTOTAL_KEEP_RECAP_FILE');
302 302
 	print '</td></tr>';
303 303
 	
304
-	$var=!$var;
304
+	$var = !$var;
305 305
 	print '<tr '.$bc[$var].'>';
306 306
 	print '<td>'.$langs->trans('SUBTOTAL_PROPAL_ADD_RECAP').'</td>';
307 307
 	print '<td align="center" width="20">&nbsp;</td>';
@@ -309,7 +309,7 @@  discard block
 block discarded – undo
309 309
 	print ajax_constantonoff('SUBTOTAL_PROPAL_ADD_RECAP');
310 310
 	print '</td></tr>';
311 311
 	
312
-	$var=!$var;
312
+	$var = !$var;
313 313
 	print '<tr '.$bc[$var].'>';
314 314
 	print '<td>'.$langs->trans('SUBTOTAL_COMMANDE_ADD_RECAP').'</td>';
315 315
 	print '<td align="center" width="20">&nbsp;</td>';
@@ -318,7 +318,7 @@  discard block
 block discarded – undo
318 318
 	print '</td></tr>';
319 319
 	
320 320
 	
321
-	$var=!$var;
321
+	$var = !$var;
322 322
 	print '<tr '.$bc[$var].'>';
323 323
 	print '<td>'.$langs->trans('SUBTOTAL_INVOICE_ADD_RECAP').'</td>';
324 324
 	print '<td align="center" width="20">&nbsp;</td>';
@@ -342,7 +342,7 @@  discard block
 block discarded – undo
342 342
 				<form method="POST" action="<?php echo $_SERVER['PHP_SELF'] ?>">
343 343
 					<input type="hidden" name="token" value="<?php echo $_SESSION['newtoken'] ?>">
344 344
 					<input type="hidden" name="action" value="set_SUBTOTAL_IF_HIDE_PRICES_SHOW_QTY" />
345
-					<?php echo $html->selectyesno("SUBTOTAL_IF_HIDE_PRICES_SHOW_QTY",$conf->global->SUBTOTAL_IF_HIDE_PRICES_SHOW_QTY,1); ?>
345
+					<?php echo $html->selectyesno("SUBTOTAL_IF_HIDE_PRICES_SHOW_QTY", $conf->global->SUBTOTAL_IF_HIDE_PRICES_SHOW_QTY, 1); ?>
346 346
 					<input type="submit" class="button" value="<?php echo $langs->trans("Modify") ?>">
347 347
 				</form>
348 348
 			</td>				
@@ -354,7 +354,7 @@  discard block
 block discarded – undo
354 354
 				<form method="POST" action="<?php echo $_SERVER['PHP_SELF'] ?>">
355 355
 					<input type="hidden" name="token" value="<?php echo $_SESSION['newtoken'] ?>">
356 356
 					<input type="hidden" name="action" value="set_SUBTOTAL_HIDE_DOCUMENT_TOTAL" />
357
-					<?php echo $html->selectyesno("SUBTOTAL_HIDE_DOCUMENT_TOTAL",$conf->global->SUBTOTAL_HIDE_DOCUMENT_TOTAL,1); ?>
357
+					<?php echo $html->selectyesno("SUBTOTAL_HIDE_DOCUMENT_TOTAL", $conf->global->SUBTOTAL_HIDE_DOCUMENT_TOTAL, 1); ?>
358 358
 					<input type="submit" class="button" value="<?php echo $langs->trans("Modify") ?>">
359 359
 				</form>
360 360
 			</td>				
@@ -367,7 +367,7 @@  discard block
 block discarded – undo
367 367
 					<form method="POST" action="<?php echo $_SERVER['PHP_SELF'] ?>">
368 368
 						<input type="hidden" name="token" value="<?php echo $_SESSION['newtoken'] ?>">
369 369
 						<input type="hidden" name="action" value="set_SUBTOTAL_SHOW_QTY_ON_TITLES" />
370
-						<?php echo $html->selectyesno("SUBTOTAL_SHOW_QTY_ON_TITLES",$conf->global->SUBTOTAL_SHOW_QTY_ON_TITLES,1); ?>
370
+						<?php echo $html->selectyesno("SUBTOTAL_SHOW_QTY_ON_TITLES", $conf->global->SUBTOTAL_SHOW_QTY_ON_TITLES, 1); ?>
371 371
 						<input type="submit" class="button" value="<?php echo $langs->trans("Modify") ?>">
372 372
 					</form>
373 373
 				</td>				
@@ -379,7 +379,7 @@  discard block
 block discarded – undo
379 379
 					<form method="POST" action="<?php echo $_SERVER['PHP_SELF'] ?>">
380 380
 						<input type="hidden" name="token" value="<?php echo $_SESSION['newtoken'] ?>">
381 381
 						<input type="hidden" name="action" value="set_SUBTOTAL_ONLY_HIDE_SUBPRODUCTS_PRICES" />
382
-						<?php echo $html->selectyesno("SUBTOTAL_ONLY_HIDE_SUBPRODUCTS_PRICES",$conf->global->SUBTOTAL_ONLY_HIDE_SUBPRODUCTS_PRICES,1); ?>
382
+						<?php echo $html->selectyesno("SUBTOTAL_ONLY_HIDE_SUBPRODUCTS_PRICES", $conf->global->SUBTOTAL_ONLY_HIDE_SUBPRODUCTS_PRICES, 1); ?>
383 383
 						<input type="submit" class="button" value="<?php echo $langs->trans("Modify") ?>">
384 384
 					</form>
385 385
 				</td>				
Please login to merge, or discard this patch.
Braces   +7 added lines, -4 removed lines patch added patch discarded remove patch
@@ -59,16 +59,19 @@
 block discarded – undo
59 59
 {
60 60
 	$code=$reg[1];
61 61
 	$value = GETPOST($code);
62
-	if ($code == 'SUBTOTAL_TFIELD_TO_KEEP_WITH_NC') $value = implode(',', $value);
62
+	if ($code == 'SUBTOTAL_TFIELD_TO_KEEP_WITH_NC') {
63
+		$value = implode(',', $value);
64
+	}
63 65
 	
64 66
 	if (dolibarr_set_const($db, $code, $value, 'chaine', 0, '', $conf->entity) > 0)
65 67
 	{
66
-		if ($code == 'SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS' && $value == 1) _createExtraComprisNonCompris();
68
+		if ($code == 'SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS' && $value == 1) {
69
+			_createExtraComprisNonCompris();
70
+		}
67 71
 		
68 72
 		header("Location: ".$_SERVER["PHP_SELF"]);
69 73
 		exit;
70
-	}
71
-	else
74
+	} else
72 75
 	{
73 76
 		dol_print_error($db);
74 77
 	}
Please login to merge, or discard this patch.
class/actions_subtotal.class.php 3 patches
Indentation   +156 added lines, -156 removed lines patch added patch discarded remove patch
@@ -47,11 +47,11 @@  discard block
 block discarded – undo
47 47
 	 * @return     void
48 48
 	 */
49 49
     
50
-    var $module_number = 104777;
50
+	var $module_number = 104777;
51 51
     
52
-    function formObjectOptions($parameters, &$object, &$action, $hookmanager) 
53
-    {
54
-      	global $langs,$db,$user, $conf;
52
+	function formObjectOptions($parameters, &$object, &$action, $hookmanager) 
53
+	{
54
+	  	global $langs,$db,$user, $conf;
55 55
 		
56 56
 		$langs->load('subtotal@subtotal');
57 57
 		
@@ -113,7 +113,7 @@  discard block
 block discarded – undo
113 113
 					
114 114
 					if (!empty($conf->global->SUBTOTAL_AUTO_ADD_SUBTOTAL_ON_ADDING_NEW_TITLE) && $qty < 10) TSubtotal::addSubtotalMissing($object, $qty);
115 115
 					
116
-	    			TSubtotal::addSubTotalLine($object, $title, $qty);
116
+					TSubtotal::addSubTotalLine($object, $title, $qty);
117 117
 				}
118 118
 				else if($action==='ask_deleteallline') {
119 119
 						$form=new Form($db);
@@ -339,29 +339,29 @@  discard block
 block discarded – undo
339 339
 				|| in_array('ordercard',$TContext)
340 340
 				|| in_array('invoicereccard',$TContext)
341 341
 			)
342
-	        {	
342
+			{	
343 343
 				$hideInnerLines	= isset( $_SESSION['subtotal_hideInnerLines_'.$parameters['modulepart']] ) ?  $_SESSION['subtotal_hideInnerLines_'.$parameters['modulepart']] : 0;
344 344
 				$hidedetails	= isset( $_SESSION['subtotal_hidedetails_'.$parameters['modulepart']] ) ?  $_SESSION['subtotal_hidedetails_'.$parameters['modulepart']] : 0;
345 345
 				$hideprices= isset( $_SESSION['subtotal_hideprices_'.$parameters['modulepart']] ) ?  $_SESSION['subtotal_hideprices_'.$parameters['modulepart']] : 0;
346 346
 				
347 347
 				$var=false;
348
-		     	$out.= '<tr '.$bc[$var].'>
348
+			 	$out.= '<tr '.$bc[$var].'>
349 349
 		     			<td colspan="4" align="right">
350 350
 		     				<label for="hideInnerLines">'.$langs->trans('HideInnerLines').'</label>
351 351
 		     				<input type="checkbox" onclick="if($(this).is(\':checked\')) { $(\'#hidedetails\').prop(\'checked\', \'checked\')  }" id="hideInnerLines" name="hideInnerLines" value="1" '.(( $hideInnerLines ) ? 'checked="checked"' : '' ).' />
352 352
 		     			</td>
353 353
 		     			</tr>';
354 354
 				
355
-		     	$var=!$var;
356
-		     	$out.= '<tr '.$bc[$var].'>
355
+			 	$var=!$var;
356
+			 	$out.= '<tr '.$bc[$var].'>
357 357
 		     			<td colspan="4" align="right">
358 358
 		     				<label for="hidedetails">'.$langs->trans('SubTotalhidedetails').'</label>
359 359
 		     				<input type="checkbox" id="hidedetails" name="hidedetails" value="1" '.(( $hidedetails ) ? 'checked="checked"' : '' ).' />
360 360
 		     			</td>
361 361
 		     			</tr>';
362 362
 		     	
363
-		     	$var=!$var;
364
-		     	$out.= '<tr '.$bc[$var].'>
363
+			 	$var=!$var;
364
+			 	$out.= '<tr '.$bc[$var].'>
365 365
 		     			<td colspan="4" align="right">
366 366
 		     				<label for="hidedetails">'.$langs->trans('SubTotalhidePrice').'</label>
367 367
 		     				<input type="checkbox" id="hideprices" name="hideprices" value="1" '.(( $hideprices ) ? 'checked="checked"' : '' ).' />
@@ -392,19 +392,19 @@  discard block
 block discarded – undo
392 392
 			}
393 393
 			
394 394
 		
395
-        return 1;
395
+		return 1;
396 396
 	} 
397 397
 	 
398
-    function formEditProductOptions($parameters, &$object, &$action, $hookmanager) 
399
-    {
398
+	function formEditProductOptions($parameters, &$object, &$action, $hookmanager) 
399
+	{
400 400
 		
401
-    	if (in_array('invoicecard',explode(':',$parameters['context'])))
402
-        {
401
+		if (in_array('invoicecard',explode(':',$parameters['context'])))
402
+		{
403 403
         	
404
-        }
404
+		}
405 405
 		
406
-        return 0;
407
-    }
406
+		return 0;
407
+	}
408 408
 	
409 409
 	function ODTSubstitutionLine(&$parameters, &$object, $action, $hookmanager) {
410 410
 		global $conf;
@@ -534,7 +534,7 @@  discard block
 block discarded – undo
534 534
 				|| in_array('propalcard',explode(':',$parameters['context']))
535 535
 				|| in_array('ordercard',explode(':',$parameters['context']))
536 536
 			)
537
-	        {								
537
+			{								
538 538
 				if(in_array('invoicecard',explode(':',$parameters['context']))) {
539 539
 					$sessname = 'subtotal_hideInnerLines_facture';	
540 540
 					$sessname2 = 'subtotal_hidedetails_facture';
@@ -570,17 +570,17 @@  discard block
 block discarded – undo
570 570
 				foreach($object->lines as &$line) {
571 571
 					if ($line->product_type == 9 && $line->special_code == $this->module_number) {
572 572
 					    
573
-                        if($line->qty>=90) {
574
-                            $line->modsubtotal_total = 1;
575
-                        }
576
-                        else{
577
-                            $line->modsubtotal_title = 1;
578
-                        }
573
+						if($line->qty>=90) {
574
+							$line->modsubtotal_total = 1;
575
+						}
576
+						else{
577
+							$line->modsubtotal_title = 1;
578
+						}
579 579
                         
580 580
 						$line->total_ht = $this->getTotalLineFromObject($object, $line, '');
581 581
 					}
582
-	        	}
583
-	        }
582
+				}
583
+			}
584 584
 			
585 585
 		}
586 586
 		else if($action === 'confirm_delete_all_lines' && GETPOST('confirm')=='yes') {
@@ -732,17 +732,17 @@  discard block
 block discarded – undo
732 732
 			if($l->rang>=$rang) {
733 733
 				return price($total);
734 734
 			}
735
-                        if (TSubtotal::isSubtotal($l)){
736
-                            $total = 0;
737
-                        } else  if ($l->situation_percent > 0 ){
735
+						if (TSubtotal::isSubtotal($l)){
736
+							$total = 0;
737
+						} else  if ($l->situation_percent > 0 ){
738 738
                            
739 739
         	
740 740
 		 	$prev_progress = $l->get_prev_progress($object->id);
741 741
 		 	$progress = ($l->situation_percent - $prev_progress) /100;
742
-                        $total += ($l->total_ht/($l->situation_percent/100)) * $progress;
742
+						$total += ($l->total_ht/($l->situation_percent/100)) * $progress;
743 743
                         
744
-                    }
745
-                }
744
+					}
745
+				}
746 746
                 
747 747
 		return price($total);
748 748
 	}
@@ -774,7 +774,7 @@  discard block
 block discarded – undo
774 774
 		if(method_exists('Closure','bind')) {
775 775
 			$pageBreakOriginalValue = $pdf->AcceptPageBreak();
776 776
 			$sweetsThief = function ($pdf) {
777
-		    		return $pdf->bMargin ;
777
+					return $pdf->bMargin ;
778 778
 			};
779 779
 			$sweetsThief = Closure::bind($sweetsThief, null, $pdf);
780 780
 	
@@ -837,11 +837,11 @@  discard block
 block discarded – undo
837 837
 				else
838 838
 				{
839 839
 					list($total, $total_tva, $total_ttc, $TTotal_tva) = $this->getTotalLineFromObject($object, $line, '', 1);
840
-                                        if(get_class($object) == 'Facture' && $object->type==Facture::TYPE_SITUATION){//Facture de situation
841
-                                                $total_to_print = $this->getTotalToPrintSituation($object, $line);
842
-                                        } else {
843
-                                            	$total_to_print = price($total);
844
-                                        }
840
+										if(get_class($object) == 'Facture' && $object->type==Facture::TYPE_SITUATION){//Facture de situation
841
+												$total_to_print = $this->getTotalToPrintSituation($object, $line);
842
+										} else {
843
+												$total_to_print = price($total);
844
+										}
845 845
                                             
846 846
 					$line->total_ht = $total;
847 847
 					$line->total = $total;
@@ -1030,19 +1030,19 @@  discard block
 block discarded – undo
1030 1030
 			}
1031 1031
 		}
1032 1032
 		if ((int)GETPOST('hideInnerLines') && !empty($conf->global->SUBTOTAL_REPLACE_WITH_VAT_IF_HIDE_INNERLINES)){
1033
-		    if(is_array($parameters)) $i = & $parameters['i'];
1034
-		    else $i = (int)$parameters;
1035
-		    $this->resprints = price($object->lines[$i]->total_ht);
1033
+			if(is_array($parameters)) $i = & $parameters['i'];
1034
+			else $i = (int)$parameters;
1035
+			$this->resprints = price($object->lines[$i]->total_ht);
1036 1036
 		}
1037 1037
 		if (!empty($hideprices)
1038
-		    || (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])) )
1039
-		    )
1038
+			|| (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])) )
1039
+			)
1040 1040
 		{
1041
-		    if (!empty($hideprices) || !in_array(__FUNCTION__, explode(',', $conf->global->SUBTOTAL_TFIELD_TO_KEEP_WITH_NC)))
1042
-		    {
1043
-		        $this->resprints = ' ';
1044
-		        return 1;
1045
-		    }
1041
+			if (!empty($hideprices) || !in_array(__FUNCTION__, explode(',', $conf->global->SUBTOTAL_TFIELD_TO_KEEP_WITH_NC)))
1042
+			{
1043
+				$this->resprints = ' ';
1044
+				return 1;
1045
+			}
1046 1046
 		}
1047 1047
         
1048 1048
 		return 0;
@@ -1322,11 +1322,11 @@  discard block
 block discarded – undo
1322 1322
 		$hidedetails = (int)GETPOST('hidedetails');
1323 1323
 		
1324 1324
 		if ($hideInnerLines) { // si c une ligne de titre
1325
-	    	$fk_parent_line=0;
1325
+			$fk_parent_line=0;
1326 1326
 			$TLines =array();
1327 1327
 		
1328 1328
 			$original_count=count($object->lines);
1329
-		    $TTvas = array(); // tableau de tva
1329
+			$TTvas = array(); // tableau de tva
1330 1330
 		    
1331 1331
 			foreach($object->lines as $k=>&$line) 
1332 1332
 			{
@@ -1356,48 +1356,48 @@  discard block
 block discarded – undo
1356 1356
 			
1357 1357
 				if ($hideInnerLines)
1358 1358
 				{
1359
-				    if(!empty($conf->global->SUBTOTAL_REPLACE_WITH_VAT_IF_HIDE_INNERLINES))
1360
-				    {
1361
-				        if($line->tva_tx != '0.000' && $line->product_type!=9){
1359
+					if(!empty($conf->global->SUBTOTAL_REPLACE_WITH_VAT_IF_HIDE_INNERLINES))
1360
+					{
1361
+						if($line->tva_tx != '0.000' && $line->product_type!=9){
1362 1362
 				            
1363
-    				        // on remplit le tableau de tva pour substituer les lignes cachées
1364
-    				        $TTvas[$line->tva_tx]['total_tva'] += $line->total_tva;
1365
-    				        $TTvas[$line->tva_tx]['total_ht'] += $line->total_ht;
1366
-    				        $TTvas[$line->tva_tx]['total_ttc'] += $line->total_ttc; 
1367
-    				    }
1368
-    					if($line->product_type==9 && $line->rowid>0)
1369
-    					{
1370
-    					    //Cas où je doit cacher les produits et afficher uniquement les sous-totaux avec les titres
1371
-    					    // génère des lignes d'affichage des montants HT soumis à tva
1372
-    					    $nbtva = count($TTvas);
1373
-    					    if(!empty($nbtva)){
1374
-    					        foreach ($TTvas as $tx =>$val){
1375
-    					            $l = clone $line;
1376
-    					            $l->product_type = 1;
1377
-    					            $l->special_code = '';
1378
-    					            $l->qty = 1;
1379
-    					            $l->desc = 'Montant HT soumis à '.$langs->trans('VAT').' '. price($tx) .' %';
1380
-    					            $l->tva_tx = $tx;
1381
-    					            $l->total_ht = $val['total_ht'];
1382
-    					            $l->total_tva = $val['total_tva'];
1383
-    					            $l->total = $line->total_ht;
1384
-    					            $l->total_ttc = $val['total_ttc'];
1385
-    					            $TLines[] = $l;
1386
-    					            array_shift($TTvas);
1387
-    					       }
1388
-    					    }
1363
+							// on remplit le tableau de tva pour substituer les lignes cachées
1364
+							$TTvas[$line->tva_tx]['total_tva'] += $line->total_tva;
1365
+							$TTvas[$line->tva_tx]['total_ht'] += $line->total_ht;
1366
+							$TTvas[$line->tva_tx]['total_ttc'] += $line->total_ttc; 
1367
+						}
1368
+						if($line->product_type==9 && $line->rowid>0)
1369
+						{
1370
+							//Cas où je doit cacher les produits et afficher uniquement les sous-totaux avec les titres
1371
+							// génère des lignes d'affichage des montants HT soumis à tva
1372
+							$nbtva = count($TTvas);
1373
+							if(!empty($nbtva)){
1374
+								foreach ($TTvas as $tx =>$val){
1375
+									$l = clone $line;
1376
+									$l->product_type = 1;
1377
+									$l->special_code = '';
1378
+									$l->qty = 1;
1379
+									$l->desc = 'Montant HT soumis à '.$langs->trans('VAT').' '. price($tx) .' %';
1380
+									$l->tva_tx = $tx;
1381
+									$l->total_ht = $val['total_ht'];
1382
+									$l->total_tva = $val['total_tva'];
1383
+									$l->total = $line->total_ht;
1384
+									$l->total_ttc = $val['total_ttc'];
1385
+									$TLines[] = $l;
1386
+									array_shift($TTvas);
1387
+							   }
1388
+							}
1389 1389
     					    
1390
-    					    // ajoute la ligne de sous-total
1391
-    					    $TLines[] = $line; 
1392
-    					}
1393
-				    } else {
1390
+							// ajoute la ligne de sous-total
1391
+							$TLines[] = $line; 
1392
+						}
1393
+					} else {
1394 1394
 				        
1395
-				        if($line->product_type==9 && $line->rowid>0)
1396
-				        {
1397
-				            // ajoute la ligne de sous-total
1398
-				            $TLines[] = $line; 
1399
-				        }
1400
-				    }
1395
+						if($line->product_type==9 && $line->rowid>0)
1396
+						{
1397
+							// ajoute la ligne de sous-total
1398
+							$TLines[] = $line; 
1399
+						}
1400
+					}
1401 1401
 				    
1402 1402
 					
1403 1403
 				}
@@ -1422,20 +1422,20 @@  discard block
 block discarded – undo
1422 1422
 			$nbtva = count($TTvas);
1423 1423
 			if(!empty($nbtva) && $hideInnerLines && !empty($conf->global->SUBTOTAL_REPLACE_WITH_VAT_IF_HIDE_INNERLINES))
1424 1424
 			{
1425
-			    foreach ($TTvas as $tx =>$val){
1426
-			        $l = clone $line;
1427
-			        $l->product_type = 1;
1428
-			        $l->special_code = '';
1429
-			        $l->qty = 1;
1430
-			        $l->desc = 'Montant HT soumis à '.$langs->trans('VAT').' '. price($tx) .' %';
1431
-			        $l->tva_tx = $tx;
1432
-			        $l->total_ht = $val['total_ht'];
1433
-			        $l->total_tva = $val['total_tva'];
1434
-			        $l->total = $line->total_ht;
1435
-			        $l->total_ttc = $val['total_ttc'];
1436
-			        $TLines[] = $l;
1437
-			        array_shift($TTvas);
1438
-			    }
1425
+				foreach ($TTvas as $tx =>$val){
1426
+					$l = clone $line;
1427
+					$l->product_type = 1;
1428
+					$l->special_code = '';
1429
+					$l->qty = 1;
1430
+					$l->desc = 'Montant HT soumis à '.$langs->trans('VAT').' '. price($tx) .' %';
1431
+					$l->tva_tx = $tx;
1432
+					$l->total_ht = $val['total_ht'];
1433
+					$l->total_tva = $val['total_tva'];
1434
+					$l->total = $line->total_ht;
1435
+					$l->total_ttc = $val['total_ttc'];
1436
+					$TLines[] = $l;
1437
+					array_shift($TTvas);
1438
+				}
1439 1439
 			}
1440 1440
 			
1441 1441
 			global $nblignes;
@@ -1447,7 +1447,7 @@  discard block
 block discarded – undo
1447 1447
 				$this->resprints = '';
1448 1448
 				return 0;
1449 1449
 			}
1450
-	    }
1450
+		}
1451 1451
 		
1452 1452
 		return 0;
1453 1453
 	}
@@ -1613,7 +1613,7 @@  discard block
 block discarded – undo
1613 1613
 			null;
1614 1614
 		}	
1615 1615
 		else if (in_array('invoicecard',$contexts) || in_array('propalcard',$contexts) || in_array('ordercard',$contexts) || in_array('invoicereccard',$contexts)) 
1616
-        {
1616
+		{
1617 1617
 			if($object->element=='facture')$idvar = 'facid';
1618 1618
 			else $idvar='id';
1619 1619
 			
@@ -1658,7 +1658,7 @@  discard block
 block discarded – undo
1658 1658
 			//var_dump($line);
1659 1659
             
1660 1660
 			// HTML 5 data for js
1661
-            $data = $this->_getHtmlData($parameters, $object, $action, $hookmanager);
1661
+			$data = $this->_getHtmlData($parameters, $object, $action, $hookmanager);
1662 1662
             
1663 1663
 			
1664 1664
 			?>
@@ -2087,80 +2087,80 @@  discard block
 block discarded – undo
2087 2087
 	// HTML 5 data for js
2088 2088
 	private function _getHtmlData($parameters, &$object, &$action, $hookmanager)
2089 2089
 	{
2090
-	    $line = &$parameters['line'];
2090
+		$line = &$parameters['line'];
2091 2091
 	    
2092
-	    $ThtmlData['data-id']           = $line->id;
2093
-	    $ThtmlData['data-product_type'] = $line->product_type;
2094
-	    $ThtmlData['data-qty']          = 0; //$line->qty;
2095
-	    $ThtmlData['data-level']        = TSubtotal::getNiveau($line);
2092
+		$ThtmlData['data-id']           = $line->id;
2093
+		$ThtmlData['data-product_type'] = $line->product_type;
2094
+		$ThtmlData['data-qty']          = 0; //$line->qty;
2095
+		$ThtmlData['data-level']        = TSubtotal::getNiveau($line);
2096 2096
 	    
2097
-	    if(TSubtotal::isTitle($line)){
2098
-	        $ThtmlData['data-issubtotal'] = 'title';
2099
-	    }elseif(TSubtotal::isSubtotal($line)){
2100
-	        $ThtmlData['data-issubtotal'] = 'subtotal';
2101
-	    }
2102
-	    else{
2103
-	        $ThtmlData['data-issubtotal'] = 'freetext';
2104
-	    }
2097
+		if(TSubtotal::isTitle($line)){
2098
+			$ThtmlData['data-issubtotal'] = 'title';
2099
+		}elseif(TSubtotal::isSubtotal($line)){
2100
+			$ThtmlData['data-issubtotal'] = 'subtotal';
2101
+		}
2102
+		else{
2103
+			$ThtmlData['data-issubtotal'] = 'freetext';
2104
+		}
2105 2105
 	    
2106 2106
 	    
2107
-	    // Change or add data  from hooks
2108
-	    $parameters = array_replace($parameters , array(  'ThtmlData' => $ThtmlData )  );
2107
+		// Change or add data  from hooks
2108
+		$parameters = array_replace($parameters , array(  'ThtmlData' => $ThtmlData )  );
2109 2109
 	    
2110
-	    // hook 
2111
-	    $reshook = $hookmanager->executeHooks('subtotalLineHtmlData',$parameters,$object,$action); // Note that $action and $object may have been modified by hook
2112
-	    if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
2113
-	    if ($reshook>0)
2114
-	    {
2115
-	        $ThtmlData = $hookmanager->resArray;
2116
-	    }
2117
-
2118
-	    return $this->implodeHtmlData($ThtmlData);
2110
+		// hook 
2111
+		$reshook = $hookmanager->executeHooks('subtotalLineHtmlData',$parameters,$object,$action); // Note that $action and $object may have been modified by hook
2112
+		if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
2113
+		if ($reshook>0)
2114
+		{
2115
+			$ThtmlData = $hookmanager->resArray;
2116
+		}
2117
+
2118
+		return $this->implodeHtmlData($ThtmlData);
2119 2119
 	
2120 2120
 	}
2121 2121
 	
2122 2122
 	
2123 2123
 	function implodeHtmlData($ThtmlData = array())
2124 2124
 	{
2125
-	    $data = '';
2126
-	    foreach($ThtmlData as $k => $h )
2127
-	    {
2128
-	        if(is_array($h))
2129
-	        {
2130
-	            $h = json_encode($h);
2131
-	        }
2125
+		$data = '';
2126
+		foreach($ThtmlData as $k => $h )
2127
+		{
2128
+			if(is_array($h))
2129
+			{
2130
+				$h = json_encode($h);
2131
+			}
2132 2132
 	        
2133
-	        $data .= $k . '="'.dol_htmlentities($h, ENT_QUOTES).'" ';
2134
-	    }
2133
+			$data .= $k . '="'.dol_htmlentities($h, ENT_QUOTES).'" ';
2134
+		}
2135 2135
 	    
2136
-	    return $data;
2136
+		return $data;
2137 2137
 	}
2138 2138
 	
2139 2139
 	function _ajax_block_order_js($object)
2140 2140
 	{
2141
-	    global $conf,$tagidfortablednd,$filepath,$langs;
2141
+		global $conf,$tagidfortablednd,$filepath,$langs;
2142 2142
 	    
2143
-	    /*
2143
+		/*
2144 2144
 	     * this part of js is base on dolibarr htdocs/core/tpl/ajaxrow.tpl.php 
2145 2145
 	     * for compatibility reasons we don't use tableDnD but jquery sortable
2146 2146
 	     */
2147 2147
 	    
2148
-	    $id=$object->id;
2149
-	    $nboflines=(isset($object->lines)?count($object->lines):0);
2150
-	    $forcereloadpage=empty($conf->global->MAIN_FORCE_RELOAD_PAGE)?0:1;
2148
+		$id=$object->id;
2149
+		$nboflines=(isset($object->lines)?count($object->lines):0);
2150
+		$forcereloadpage=empty($conf->global->MAIN_FORCE_RELOAD_PAGE)?0:1;
2151 2151
 	    
2152
-	    $id=$object->id;
2153
-	    $fk_element=$object->fk_element;
2154
-	    $table_element_line=$object->table_element_line;
2155
-	    $nboflines=(isset($object->lines)?count($object->lines):(empty($nboflines)?0:$nboflines));
2156
-	    $tagidfortablednd=(empty($tagidfortablednd)?'tablelines':$tagidfortablednd);
2157
-	    $filepath=(empty($filepath)?'':$filepath);
2152
+		$id=$object->id;
2153
+		$fk_element=$object->fk_element;
2154
+		$table_element_line=$object->table_element_line;
2155
+		$nboflines=(isset($object->lines)?count($object->lines):(empty($nboflines)?0:$nboflines));
2156
+		$tagidfortablednd=(empty($tagidfortablednd)?'tablelines':$tagidfortablednd);
2157
+		$filepath=(empty($filepath)?'':$filepath);
2158 2158
 	    
2159 2159
 	    
2160
-	    if (GETPOST('action','aZ09') != 'editline' && $nboflines > 1)
2161
-	    {
2160
+		if (GETPOST('action','aZ09') != 'editline' && $nboflines > 1)
2161
+		{
2162 2162
 	        
2163
-	        ?>
2163
+			?>
2164 2164
 		
2165 2165
 		
2166 2166
 			<script type="text/javascript">
Please login to merge, or discard this patch.
Spacing   +355 added lines, -355 removed lines patch added patch discarded remove patch
@@ -51,37 +51,37 @@  discard block
 block discarded – undo
51 51
     
52 52
     function formObjectOptions($parameters, &$object, &$action, $hookmanager) 
53 53
     {
54
-      	global $langs,$db,$user, $conf;
54
+      	global $langs, $db, $user, $conf;
55 55
 		
56 56
 		$langs->load('subtotal@subtotal');
57 57
 		
58
-		$contexts = explode(':',$parameters['context']);
58
+		$contexts = explode(':', $parameters['context']);
59 59
 		
60
-		if(in_array('ordercard',$contexts) || in_array('propalcard',$contexts) || in_array('invoicecard',$contexts) || in_array('invoicereccard',$contexts)) {
60
+		if (in_array('ordercard', $contexts) || in_array('propalcard', $contexts) || in_array('invoicecard', $contexts) || in_array('invoicereccard', $contexts)) {
61 61
 			
62 62
 			$createRight = $user->rights->{$object->element}->creer;
63
-			if($object->element == 'facturerec' )
63
+			if ($object->element == 'facturerec')
64 64
 			{
65 65
 				$object->statut = 0; // hack for facture rec
66 66
 				$createRight = $user->rights->facture->creer;
67 67
 			}
68 68
 			
69
-			if ($object->statut == 0  && $createRight) {
69
+			if ($object->statut == 0 && $createRight) {
70 70
 			
71 71
 
72
-				if($object->element=='facture')$idvar = 'facid';
73
-				else $idvar='id';
72
+				if ($object->element == 'facture')$idvar = 'facid';
73
+				else $idvar = 'id';
74 74
 				
75
-				if(in_array($action, array('add_title_line', 'add_total_line', 'add_subtitle_line', 'add_subtotal_line', 'add_free_text')) )
75
+				if (in_array($action, array('add_title_line', 'add_total_line', 'add_subtitle_line', 'add_subtotal_line', 'add_free_text')))
76 76
 				{
77 77
 					$level = GETPOST('level', 'int'); //New avec SUBTOTAL_USE_NEW_FORMAT
78 78
 					
79
-					if($action=='add_title_line') {
79
+					if ($action == 'add_title_line') {
80 80
 						$title = GETPOST('title');
81
-						if(empty($title)) $title = $langs->trans('title');
82
-						$qty = $level<1 ? 1 : $level ;
81
+						if (empty($title)) $title = $langs->trans('title');
82
+						$qty = $level < 1 ? 1 : $level;
83 83
 					}
84
-					else if($action=='add_free_text') {
84
+					else if ($action == 'add_free_text') {
85 85
 						$title = GETPOST('title');
86 86
 
87 87
 						if (empty($title)) {
@@ -93,21 +93,21 @@  discard block
 block discarded – undo
93 93
 								}
94 94
 							}
95 95
 						}
96
-						if(empty($title)) $title = $langs->trans('subtotalAddLineDescription');
96
+						if (empty($title)) $title = $langs->trans('subtotalAddLineDescription');
97 97
 						$qty = 50;
98 98
 					}
99
-					else if($action=='add_subtitle_line') {
99
+					else if ($action == 'add_subtitle_line') {
100 100
 						$title = GETPOST('title');
101
-						if(empty($title)) $title = $langs->trans('subtitle');
101
+						if (empty($title)) $title = $langs->trans('subtitle');
102 102
 						$qty = 2;
103 103
 					}
104
-					else if($action=='add_subtotal_line') {
104
+					else if ($action == 'add_subtotal_line') {
105 105
 						$title = $langs->trans('SubSubTotal');
106 106
 						$qty = 98;
107 107
 					}
108 108
 					else {
109 109
 						$title = GETPOST('title') ? GETPOST('title') : $langs->trans('SubTotal');
110
-						$qty = $level ? 100-$level : 99;
110
+						$qty = $level ? 100 - $level : 99;
111 111
 					}
112 112
 					dol_include_once('/subtotal/class/subtotal.class.php');
113 113
 					
@@ -115,15 +115,15 @@  discard block
 block discarded – undo
115 115
 					
116 116
 	    			TSubtotal::addSubTotalLine($object, $title, $qty);
117 117
 				}
118
-				else if($action==='ask_deleteallline') {
119
-						$form=new Form($db);
118
+				else if ($action === 'ask_deleteallline') {
119
+						$form = new Form($db);
120 120
 						
121
-						$lineid = GETPOST('lineid','integer');
121
+						$lineid = GETPOST('lineid', 'integer');
122 122
 						$TIdForGroup = $this->getArrayOfLineForAGroup($object, $lineid);
123 123
 					
124 124
 						$nbLines = count($TIdForGroup);
125 125
 					
126
-						$formconfirm=$form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&lineid='.$lineid, $langs->trans('deleteWithAllLines'), $langs->trans('ConfirmDeleteAllThisLines',$nbLines), 'confirm_delete_all_lines','',0,1);
126
+						$formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&lineid='.$lineid, $langs->trans('deleteWithAllLines'), $langs->trans('ConfirmDeleteAllThisLines', $nbLines), 'confirm_delete_all_lines', '', 0, 1);
127 127
 						print $formconfirm;
128 128
 				}
129 129
 
@@ -133,13 +133,13 @@  discard block
 block discarded – undo
133 133
 				}
134 134
 
135 135
 				
136
-				if($action!='editline') {
136
+				if ($action != 'editline') {
137 137
 					// New format is for 3.8
138 138
 					$this->printNewFormat($object, $conf, $langs, $idvar);
139 139
 				}
140 140
 			}
141 141
 		}
142
-		elseif ((!empty($parameters['currentcontext']) && $parameters['currentcontext'] == 'orderstoinvoice') || in_array('orderstoinvoice',$contexts))
142
+		elseif ((!empty($parameters['currentcontext']) && $parameters['currentcontext'] == 'orderstoinvoice') || in_array('orderstoinvoice', $contexts))
143 143
 		{
144 144
 			?>
145 145
 			<script type="text/javascript">
@@ -164,7 +164,7 @@  discard block
 block discarded – undo
164 164
 				$(document).ready(function() {
165 165
 					$('div.fiche div.tabsAction').append('<br />');
166 166
 					
167
-					$('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>');
167
+					$('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>');
168 168
 					$('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>');
169 169
 					$('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>');
170 170
 
@@ -215,9 +215,9 @@  discard block
 block discarded – undo
215 215
 						$('body').append(dialog_html);
216 216
 
217 217
 						<?php 
218
-						$editorTool = empty($conf->global->FCKEDITOR_EDITORNAME)?'ckeditor':$conf->global->FCKEDITOR_EDITORNAME;
219
-						$editorConf = empty($conf->global->FCKEDITOR_ENABLE_DETAILS)?false:$conf->global->FCKEDITOR_ENABLE_DETAILS;
220
-						if($editorConf && in_array($editorTool,array('textarea','ckeditor'))){ 
218
+						$editorTool = empty($conf->global->FCKEDITOR_EDITORNAME) ? 'ckeditor' : $conf->global->FCKEDITOR_EDITORNAME;
219
+						$editorConf = empty($conf->global->FCKEDITOR_ENABLE_DETAILS) ?false:$conf->global->FCKEDITOR_ENABLE_DETAILS;
220
+						if ($editorConf && in_array($editorTool, array('textarea', 'ckeditor'))) { 
221 221
 						?>
222 222
 						if (action == 'addTitle' || action == 'addFreeTxt')
223 223
 						{
@@ -332,57 +332,57 @@  discard block
 block discarded – undo
332 332
 		global $conf, $langs, $bc;
333 333
 			
334 334
 		$action = GETPOST('action');	
335
-		$TContext = explode(':',$parameters['context']);
335
+		$TContext = explode(':', $parameters['context']);
336 336
 		if (
337
-				in_array('invoicecard',$TContext)
338
-				|| in_array('propalcard',$TContext)
339
-				|| in_array('ordercard',$TContext)
340
-				|| in_array('invoicereccard',$TContext)
337
+				in_array('invoicecard', $TContext)
338
+				|| in_array('propalcard', $TContext)
339
+				|| in_array('ordercard', $TContext)
340
+				|| in_array('invoicereccard', $TContext)
341 341
 			)
342 342
 	        {	
343
-				$hideInnerLines	= isset( $_SESSION['subtotal_hideInnerLines_'.$parameters['modulepart']] ) ?  $_SESSION['subtotal_hideInnerLines_'.$parameters['modulepart']] : 0;
344
-				$hidedetails	= isset( $_SESSION['subtotal_hidedetails_'.$parameters['modulepart']] ) ?  $_SESSION['subtotal_hidedetails_'.$parameters['modulepart']] : 0;
345
-				$hideprices= isset( $_SESSION['subtotal_hideprices_'.$parameters['modulepart']] ) ?  $_SESSION['subtotal_hideprices_'.$parameters['modulepart']] : 0;
343
+				$hideInnerLines = isset($_SESSION['subtotal_hideInnerLines_'.$parameters['modulepart']]) ? $_SESSION['subtotal_hideInnerLines_'.$parameters['modulepart']] : 0;
344
+				$hidedetails = isset($_SESSION['subtotal_hidedetails_'.$parameters['modulepart']]) ? $_SESSION['subtotal_hidedetails_'.$parameters['modulepart']] : 0;
345
+				$hideprices = isset($_SESSION['subtotal_hideprices_'.$parameters['modulepart']]) ? $_SESSION['subtotal_hideprices_'.$parameters['modulepart']] : 0;
346 346
 				
347
-				$var=false;
348
-		     	$out.= '<tr '.$bc[$var].'>
347
+				$var = false;
348
+		     	$out .= '<tr '.$bc[$var].'>
349 349
 		     			<td colspan="4" align="right">
350 350
 		     				<label for="hideInnerLines">'.$langs->trans('HideInnerLines').'</label>
351
-		     				<input type="checkbox" onclick="if($(this).is(\':checked\')) { $(\'#hidedetails\').prop(\'checked\', \'checked\')  }" id="hideInnerLines" name="hideInnerLines" value="1" '.(( $hideInnerLines ) ? 'checked="checked"' : '' ).' />
351
+		     				<input type="checkbox" onclick="if($(this).is(\':checked\')) { $(\'#hidedetails\').prop(\'checked\', \'checked\')  }" id="hideInnerLines" name="hideInnerLines" value="1" '.(($hideInnerLines) ? 'checked="checked"' : '').' />
352 352
 		     			</td>
353 353
 		     			</tr>';
354 354
 				
355
-		     	$var=!$var;
356
-		     	$out.= '<tr '.$bc[$var].'>
355
+		     	$var = !$var;
356
+		     	$out .= '<tr '.$bc[$var].'>
357 357
 		     			<td colspan="4" align="right">
358 358
 		     				<label for="hidedetails">'.$langs->trans('SubTotalhidedetails').'</label>
359
-		     				<input type="checkbox" id="hidedetails" name="hidedetails" value="1" '.(( $hidedetails ) ? 'checked="checked"' : '' ).' />
359
+		     				<input type="checkbox" id="hidedetails" name="hidedetails" value="1" '.(($hidedetails) ? 'checked="checked"' : '').' />
360 360
 		     			</td>
361 361
 		     			</tr>';
362 362
 		     	
363
-		     	$var=!$var;
364
-		     	$out.= '<tr '.$bc[$var].'>
363
+		     	$var = !$var;
364
+		     	$out .= '<tr '.$bc[$var].'>
365 365
 		     			<td colspan="4" align="right">
366 366
 		     				<label for="hidedetails">'.$langs->trans('SubTotalhidePrice').'</label>
367
-		     				<input type="checkbox" id="hideprices" name="hideprices" value="1" '.(( $hideprices ) ? 'checked="checked"' : '' ).' />
367
+		     				<input type="checkbox" id="hideprices" name="hideprices" value="1" '.(($hideprices) ? 'checked="checked"' : '').' />
368 368
 		     			</td>
369 369
 		     			</tr>';
370 370
 		     	
371 371
 		     	
372 372
 				 
373 373
 				if ( 
374
-					(in_array('propalcard',$TContext) && !empty($conf->global->SUBTOTAL_PROPAL_ADD_RECAP))
375
-					|| (in_array('ordercard',$TContext) && !empty($conf->global->SUBTOTAL_COMMANDE_ADD_RECAP))
376
-					|| (in_array('invoicecard',$TContext) && !empty($conf->global->SUBTOTAL_INVOICE_ADD_RECAP))
377
-					|| (in_array('invoicereccard',$TContext)  && !empty($conf->global->SUBTOTAL_INVOICE_ADD_RECAP ))
374
+					(in_array('propalcard', $TContext) && !empty($conf->global->SUBTOTAL_PROPAL_ADD_RECAP))
375
+					|| (in_array('ordercard', $TContext) && !empty($conf->global->SUBTOTAL_COMMANDE_ADD_RECAP))
376
+					|| (in_array('invoicecard', $TContext) && !empty($conf->global->SUBTOTAL_INVOICE_ADD_RECAP))
377
+					|| (in_array('invoicereccard', $TContext) && !empty($conf->global->SUBTOTAL_INVOICE_ADD_RECAP))
378 378
 				)
379 379
 				{
380
-					$var=!$var;
381
-					$out.= '
380
+					$var = !$var;
381
+					$out .= '
382 382
 						<tr '.$bc[$var].'>
383 383
 							<td colspan="4" align="right">
384 384
 								<label for="subtotal_add_recap">'.$langs->trans('subtotal_add_recap').'</label>
385
-								<input type="checkbox" id="subtotal_add_recap" name="subtotal_add_recap" value="1" '.( GETPOST('subtotal_add_recap') ? 'checked="checked"' : '' ).' />
385
+								<input type="checkbox" id="subtotal_add_recap" name="subtotal_add_recap" value="1" '.(GETPOST('subtotal_add_recap') ? 'checked="checked"' : '').' />
386 386
 							</td>
387 387
 						</tr>';
388 388
 				}
@@ -398,7 +398,7 @@  discard block
 block discarded – undo
398 398
     function formEditProductOptions($parameters, &$object, &$action, $hookmanager) 
399 399
     {
400 400
 		
401
-    	if (in_array('invoicecard',explode(':',$parameters['context'])))
401
+    	if (in_array('invoicecard', explode(':', $parameters['context'])))
402 402
         {
403 403
         	
404 404
         }
@@ -409,13 +409,13 @@  discard block
 block discarded – undo
409 409
 	function ODTSubstitutionLine(&$parameters, &$object, $action, $hookmanager) {
410 410
 		global $conf;
411 411
 		
412
-		if($action === 'builddoc') {
412
+		if ($action === 'builddoc') {
413 413
 			
414 414
 			$line = &$parameters['line'];
415 415
 			$object = &$parameters['object'];
416 416
 			$substitutionarray = &$parameters['substitutionarray'];
417 417
 			
418
-			if($line->product_type == 9 && $line->special_code == $this->module_number) {
418
+			if ($line->product_type == 9 && $line->special_code == $this->module_number) {
419 419
 				$substitutionarray['line_modsubtotal'] = 1;	
420 420
 				
421 421
 				$substitutionarray['line_price_ht']
@@ -426,7 +426,7 @@  discard block
 block discarded – undo
426 426
 					 = $substitutionarray['line_up'] 
427 427
 					 = '';
428 428
 				
429
-				if($line->qty>90) {
429
+				if ($line->qty > 90) {
430 430
 					$substitutionarray['line_modsubtotal_total'] = true;
431 431
 					
432 432
 					list($total, $total_tva, $total_ttc, $TTotal_tva) = $this->getTotalLineFromObject($object, $line, '', 1);
@@ -440,7 +440,7 @@  discard block
 block discarded – undo
440 440
 				
441 441
 				
442 442
 			}	
443
-			else{
443
+			else {
444 444
 				$substitutionarray['line_not_modsubtotal'] = true;
445 445
 				$substitutionarray['line_modsubtotal'] = 0;
446 446
 			}
@@ -452,26 +452,26 @@  discard block
 block discarded – undo
452 452
 	function createFrom($parameters, &$object, $action, $hookmanager) {
453 453
 	
454 454
 		if (
455
-				in_array('invoicecard',explode(':',$parameters['context']))
456
-				|| in_array('propalcard',explode(':',$parameters['context']))
457
-				|| in_array('ordercard',explode(':',$parameters['context']))
458
-				|| in_array('invoicereccard',explode(':',$parameters['context']))
455
+				in_array('invoicecard', explode(':', $parameters['context']))
456
+				|| in_array('propalcard', explode(':', $parameters['context']))
457
+				|| in_array('ordercard', explode(':', $parameters['context']))
458
+				|| in_array('invoicereccard', explode(':', $parameters['context']))
459 459
 		) {
460 460
 			
461 461
 			global $db;
462 462
 			
463 463
 			$objFrom = $parameters['objFrom'];
464 464
 			
465
-			foreach($objFrom->lines as $k=> &$lineOld) {
465
+			foreach ($objFrom->lines as $k=> &$lineOld) {
466 466
 				
467
-					if($lineOld->product_type == 9 && $lineOld->info_bits > 0 ) {
467
+					if ($lineOld->product_type == 9 && $lineOld->info_bits > 0) {
468 468
 							
469 469
 							$line = & $object->lines[$k];
470 470
 				
471 471
 							$idLine = (int) ($line->id ? $line->id : $line->rowid); 
472 472
 				
473 473
 							$db->query("UPDATE ".MAIN_DB_PREFIX.$line->table_element."
474
-							SET info_bits=".(int)$lineOld->info_bits."
474
+							SET info_bits=".(int) $lineOld->info_bits."
475 475
 							WHERE rowid = ".$idLine."
476 476
 							");
477 477
 						
@@ -487,15 +487,15 @@  discard block
 block discarded – undo
487 487
 	
488 488
 	function doActions($parameters, &$object, $action, $hookmanager)
489 489
 	{
490
-		global $db, $conf, $langs,$user;
490
+		global $db, $conf, $langs, $user;
491 491
 		
492 492
 		dol_include_once('/subtotal/class/subtotal.class.php');
493 493
 		dol_include_once('/subtotal/lib/subtotal.lib.php');
494
-		require_once DOL_DOCUMENT_ROOT . '/core/class/extrafields.class.php';
494
+		require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
495 495
 		
496 496
 		$showBlockExtrafields = GETPOST('showBlockExtrafields');
497 497
 		
498
-		if($object->element=='facture') $idvar = 'facid';
498
+		if ($object->element == 'facture') $idvar = 'facid';
499 499
 		else $idvar = 'id';
500 500
 			
501 501
 		if ($action == 'updateligne' || $action == 'updateline')
@@ -508,7 +508,7 @@  discard block
 block discarded – undo
508 508
 				if ($line->id == $lineid && TSubtotal::isModSubtotalLine($line))
509 509
 				{
510 510
 					$found = true;
511
-					if(TSubtotal::isTitle($line) && !empty($showBlockExtrafields)) {
511
+					if (TSubtotal::isTitle($line) && !empty($showBlockExtrafields)) {
512 512
 						$extrafieldsline = new ExtraFields($db);
513 513
 						$extralabelsline = $extrafieldsline->fetch_name_optionals_label($object->table_element_line);
514 514
 						$extrafieldsline->setOptionalsFromPost($extralabelsline, $line);
@@ -527,25 +527,25 @@  discard block
 block discarded – undo
527 527
 				exit; // Surtout ne pas laisser Dolibarr faire du traitement sur le updateligne sinon ça plante les données de la ligne
528 528
 			}
529 529
 		}
530
-		else if($action === 'builddoc') {
530
+		else if ($action === 'builddoc') {
531 531
 			
532 532
 			if (
533
-				in_array('invoicecard',explode(':',$parameters['context']))
534
-				|| in_array('propalcard',explode(':',$parameters['context']))
535
-				|| in_array('ordercard',explode(':',$parameters['context']))
533
+				in_array('invoicecard', explode(':', $parameters['context']))
534
+				|| in_array('propalcard', explode(':', $parameters['context']))
535
+				|| in_array('ordercard', explode(':', $parameters['context']))
536 536
 			)
537 537
 	        {								
538
-				if(in_array('invoicecard',explode(':',$parameters['context']))) {
538
+				if (in_array('invoicecard', explode(':', $parameters['context']))) {
539 539
 					$sessname = 'subtotal_hideInnerLines_facture';	
540 540
 					$sessname2 = 'subtotal_hidedetails_facture';
541 541
 					$sessname3 = 'subtotal_hideprices_facture';
542 542
 				}
543
-				elseif(in_array('propalcard',explode(':',$parameters['context']))) {
543
+				elseif (in_array('propalcard', explode(':', $parameters['context']))) {
544 544
 					$sessname = 'subtotal_hideInnerLines_propal';
545 545
 					$sessname2 = 'subtotal_hidedetails_propal';	
546 546
 					$sessname3 = 'subtotal_hideprices_propal';
547 547
 				}
548
-				elseif(in_array('ordercard',explode(':',$parameters['context']))) {
548
+				elseif (in_array('ordercard', explode(':', $parameters['context']))) {
549 549
 					$sessname = 'subtotal_hideInnerLines_commande';
550 550
 					$sessname2 = 'subtotal_hidedetails_commande';	
551 551
 					$sessname3 = 'subtotal_hideprices_commande';
@@ -558,22 +558,22 @@  discard block
 block discarded – undo
558 558
 					
559 559
 				global $hideprices;
560 560
 				
561
-				$hideInnerLines = (int)GETPOST('hideInnerLines');
561
+				$hideInnerLines = (int) GETPOST('hideInnerLines');
562 562
 				$_SESSION[$sessname] = $hideInnerLines;		
563 563
 				
564
-				$hidedetails= (int)GETPOST('hidedetails');
564
+				$hidedetails = (int) GETPOST('hidedetails');
565 565
 				$_SESSION[$sessname2] = $hidedetails;
566 566
 				
567
-				$hideprices= (int)GETPOST('hideprices');
567
+				$hideprices = (int) GETPOST('hideprices');
568 568
 				$_SESSION[$sessname3] = $hideprices;
569 569
 				
570
-				foreach($object->lines as &$line) {
570
+				foreach ($object->lines as &$line) {
571 571
 					if ($line->product_type == 9 && $line->special_code == $this->module_number) {
572 572
 					    
573
-                        if($line->qty>=90) {
573
+                        if ($line->qty >= 90) {
574 574
                             $line->modsubtotal_total = 1;
575 575
                         }
576
-                        else{
576
+                        else {
577 577
                             $line->modsubtotal_title = 1;
578 578
                         }
579 579
                         
@@ -583,23 +583,23 @@  discard block
 block discarded – undo
583 583
 	        }
584 584
 			
585 585
 		}
586
-		else if($action === 'confirm_delete_all_lines' && GETPOST('confirm')=='yes') {
586
+		else if ($action === 'confirm_delete_all_lines' && GETPOST('confirm') == 'yes') {
587 587
 			
588 588
 			$Tab = $this->getArrayOfLineForAGroup($object, GETPOST('lineid'));
589 589
 			
590
-			foreach($Tab as $idLine) {
590
+			foreach ($Tab as $idLine) {
591 591
 				/**
592 592
 				 * @var $object Facture
593 593
 				 */
594
-				if($object->element=='facture') $object->deleteline($idLine);
594
+				if ($object->element == 'facture') $object->deleteline($idLine);
595 595
 				/**
596 596
 				 * @var $object Propal
597 597
 				 */
598
-				else if($object->element=='propal') $object->deleteline($idLine);
598
+				else if ($object->element == 'propal') $object->deleteline($idLine);
599 599
 				/**
600 600
 				 * @var $object Commande
601 601
 				 */
602
-				else if($object->element=='commande') 
602
+				else if ($object->element == 'commande') 
603 603
 				{
604 604
 					if ((float) DOL_VERSION >= 5.0) $object->deleteline($user, $idLine);
605 605
 					else $object->deleteline($idLine);
@@ -607,7 +607,7 @@  discard block
 block discarded – undo
607 607
 				/**
608 608
 				 * @var $object Facturerec
609 609
 				 */
610
-				else if($object->element=='facturerec') $object->deleteline($idLine);
610
+				else if ($object->element == 'facturerec') $object->deleteline($idLine);
611 611
 			}
612 612
 			
613 613
 			header('location:?id='.$object->id);
@@ -630,7 +630,7 @@  discard block
 block discarded – undo
630 630
 		return 0;
631 631
 	}
632 632
 	
633
-	function formAddObjectLine ($parameters, &$object, &$action, $hookmanager) {
633
+	function formAddObjectLine($parameters, &$object, &$action, $hookmanager) {
634 634
 		return 0;
635 635
 	}
636 636
 
@@ -642,20 +642,20 @@  discard block
 block discarded – undo
642 642
 		
643 643
 		$found = false;
644 644
 
645
-		$Tab= array();
645
+		$Tab = array();
646 646
 		
647
-		foreach($object->lines as $l) {
647
+		foreach ($object->lines as $l) {
648 648
 		
649
-			if($l->rowid == $lineid) {
649
+			if ($l->rowid == $lineid) {
650 650
 				$found = true;
651 651
 				$qty_line = $l->qty;
652 652
 			}
653 653
 			
654
-			if($found) {
654
+			if ($found) {
655 655
 				
656 656
 				$Tab[] = $l->rowid;
657 657
 				
658
-				if($l->special_code==$this->module_number && (($l->qty==99 && $qty_line==1) || ($l->qty==98 && $qty_line==2))   ) {
658
+				if ($l->special_code == $this->module_number && (($l->qty == 99 && $qty_line == 1) || ($l->qty == 98 && $qty_line == 2))) {
659 659
 					break; // end of story
660 660
 				}
661 661
 			}
@@ -684,7 +684,7 @@  discard block
 block discarded – undo
684 684
 	 * 
685 685
 	 * @param	$use_level		isn't used anymore
686 686
 	 */
687
-	function getTotalLineFromObject(&$object, &$line, $use_level=false, $return_all=0) {
687
+	function getTotalLineFromObject(&$object, &$line, $use_level = false, $return_all = 0) {
688 688
 		
689 689
 		$rang = $line->rang;
690 690
 		$qty_line = $line->qty;
@@ -695,21 +695,21 @@  discard block
 block discarded – undo
695 695
 		$TTotal_tva = array();
696 696
 		
697 697
 		dol_include_once('/subtotal/class/subtotal.class.php');
698
-		foreach($object->lines as $l) {
698
+		foreach ($object->lines as $l) {
699 699
 			//print $l->rang.'>='.$rang.' '.$total.'<br/>';
700
-			if($l->rang>=$rang) {
700
+			if ($l->rang >= $rang) {
701 701
 				//echo 'return!<br>';
702 702
 				if (!$return_all) return $total;
703 703
 				else return array($total, $total_tva, $total_ttc, $TTotal_tva);
704 704
 			}
705
-			else if(TSubtotal::isTitle($l, 100 - $qty_line)) 
705
+			else if (TSubtotal::isTitle($l, 100 - $qty_line)) 
706 706
 		  	{
707 707
 				$total = 0;
708 708
 				$total_tva = 0;
709 709
 				$total_ttc = 0;
710 710
 				$TTotal_tva = array();
711 711
 			}
712
-			elseif(!TSubtotal::isTitle($l) && !TSubtotal::isSubtotal($l)) {
712
+			elseif (!TSubtotal::isTitle($l) && !TSubtotal::isSubtotal($l)) {
713 713
 				$total += $l->total_ht;
714 714
 				$total_tva += $l->total_tva;
715 715
 				$TTotal_tva[$l->tva_tx] += $l->total_tva;
@@ -728,18 +728,18 @@  discard block
 block discarded – undo
728 728
 		
729 729
 		$rang = $line->rang;
730 730
 		$total = 0;
731
-		foreach($object->lines as $l) {
732
-			if($l->rang>=$rang) {
731
+		foreach ($object->lines as $l) {
732
+			if ($l->rang >= $rang) {
733 733
 				return price($total);
734 734
 			}
735
-                        if (TSubtotal::isSubtotal($l)){
735
+                        if (TSubtotal::isSubtotal($l)) {
736 736
                             $total = 0;
737
-                        } else  if ($l->situation_percent > 0 ){
737
+                        } else  if ($l->situation_percent > 0) {
738 738
                            
739 739
         	
740 740
 		 	$prev_progress = $l->get_prev_progress($object->id);
741
-		 	$progress = ($l->situation_percent - $prev_progress) /100;
742
-                        $total += ($l->total_ht/($l->situation_percent/100)) * $progress;
741
+		 	$progress = ($l->situation_percent - $prev_progress) / 100;
742
+                        $total += ($l->total_ht / ($l->situation_percent / 100)) * $progress;
743 743
                         
744 744
                     }
745 745
                 }
@@ -758,10 +758,10 @@  discard block
 block discarded – undo
758 758
 	 * @param $w            float               width
759 759
 	 * @param $h            float               height
760 760
 	 */
761
-	function pdf_add_total(&$pdf,&$object, &$line, $label, $description,$posx, $posy, $w, $h) {
762
-		global $conf,$subtotal_last_title_posy;
761
+	function pdf_add_total(&$pdf, &$object, &$line, $label, $description, $posx, $posy, $w, $h) {
762
+		global $conf, $subtotal_last_title_posy;
763 763
 		
764
-		$hideInnerLines = (int)GETPOST('hideInnerLines');
764
+		$hideInnerLines = (int) GETPOST('hideInnerLines');
765 765
 		if (!empty($conf->global->SUBTOTAL_ONE_LINE_IF_HIDE_INNERLINES) && $hideInnerLines && !empty($subtotal_last_title_posy))
766 766
 		{
767 767
 			$posy = $subtotal_last_title_posy;
@@ -771,34 +771,34 @@  discard block
 block discarded – undo
771 771
 		$hidePriceOnSubtotalLines = (int) GETPOST('hide_price_on_subtotal_lines');
772 772
 		
773 773
 		$set_pagebreak_margin = false;
774
-		if(method_exists('Closure','bind')) {
774
+		if (method_exists('Closure', 'bind')) {
775 775
 			$pageBreakOriginalValue = $pdf->AcceptPageBreak();
776
-			$sweetsThief = function ($pdf) {
777
-		    		return $pdf->bMargin ;
776
+			$sweetsThief = function($pdf) {
777
+		    		return $pdf->bMargin;
778 778
 			};
779 779
 			$sweetsThief = Closure::bind($sweetsThief, null, $pdf);
780 780
 	
781
-			$bMargin  = $sweetsThief($pdf);
781
+			$bMargin = $sweetsThief($pdf);
782 782
 	
783
-			$pdf->SetAutoPageBreak( false );
783
+			$pdf->SetAutoPageBreak(false);
784 784
 
785 785
 			$set_pagebreak_margin = true;			
786 786
 		}
787 787
 		
788 788
 			
789
-		if($line->qty==99)
790
-			$pdf->SetFillColor(220,220,220);
791
-		elseif ($line->qty==98)
792
-			$pdf->SetFillColor(230,230,230);
789
+		if ($line->qty == 99)
790
+			$pdf->SetFillColor(220, 220, 220);
791
+		elseif ($line->qty == 98)
792
+			$pdf->SetFillColor(230, 230, 230);
793 793
 		else
794
-			$pdf->SetFillColor(240,240,240);
794
+			$pdf->SetFillColor(240, 240, 240);
795 795
 		
796 796
 		$style = 'B';
797 797
 		if (!empty($conf->global->SUBTOTAL_SUBTOTAL_STYLE)) $style = $conf->global->SUBTOTAL_SUBTOTAL_STYLE;
798 798
 		
799 799
 		$pdf->SetFont('', $style, 9);
800 800
 		
801
-		$pdf->writeHTMLCell($w, $h, $posx, $posy, $label, 0, 1, false, true, 'R',true);
801
+		$pdf->writeHTMLCell($w, $h, $posx, $posy, $label, 0, 1, false, true, 'R', true);
802 802
 //		var_dump($bMargin);
803 803
 		$pageAfter = $pdf->getPage();
804 804
 		
@@ -823,7 +823,7 @@  discard block
 block discarded – undo
823 823
 				}
824 824
 			}
825 825
 			
826
-			if($total_to_print) {
826
+			if ($total_to_print) {
827 827
 				
828 828
 				if (GETPOST('hideInnerLines'))
829 829
 				{
@@ -837,7 +837,7 @@  discard block
 block discarded – undo
837 837
 				else
838 838
 				{
839 839
 					list($total, $total_tva, $total_ttc, $TTotal_tva) = $this->getTotalLineFromObject($object, $line, '', 1);
840
-                                        if(get_class($object) == 'Facture' && $object->type==Facture::TYPE_SITUATION){//Facture de situation
840
+                                        if (get_class($object) == 'Facture' && $object->type == Facture::TYPE_SITUATION) {//Facture de situation
841 841
                                                 $total_to_print = $this->getTotalToPrintSituation($object, $line);
842 842
                                         } else {
843 843
                                             	$total_to_print = price($total);
@@ -851,11 +851,11 @@  discard block
 block discarded – undo
851 851
 			}
852 852
 
853 853
 			$pdf->SetXY($pdf->postotalht, $posy);
854
-			if($set_pagebreak_margin) $pdf->SetAutoPageBreak( $pageBreakOriginalValue , $bMargin);
855
-			$pdf->MultiCell($pdf->page_largeur-$pdf->marge_droite-$pdf->postotalht, 3, $total_to_print, 0, 'R', 0);
854
+			if ($set_pagebreak_margin) $pdf->SetAutoPageBreak($pageBreakOriginalValue, $bMargin);
855
+			$pdf->MultiCell($pdf->page_largeur - $pdf->marge_droite - $pdf->postotalht, 3, $total_to_print, 0, 'R', 0);
856 856
 		}
857
-		else{
858
-			if($set_pagebreak_margin) $pdf->SetAutoPageBreak( $pageBreakOriginalValue , $bMargin);
857
+		else {
858
+			if ($set_pagebreak_margin) $pdf->SetAutoPageBreak($pageBreakOriginalValue, $bMargin);
859 859
 		}
860 860
 		
861 861
 		$posy = $posy + $cell_height;
@@ -875,22 +875,22 @@  discard block
 block discarded – undo
875 875
 	 * @param $w            float               width
876 876
 	 * @param $h            float               height
877 877
 	 */
878
-	function pdf_add_title(&$pdf,&$object, &$line, $label, $description,$posx, $posy, $w, $h) {
878
+	function pdf_add_title(&$pdf, &$object, &$line, $label, $description, $posx, $posy, $w, $h) {
879 879
 		
880
-		global $db,$conf,$subtotal_last_title_posy;
880
+		global $db, $conf, $subtotal_last_title_posy;
881 881
 		
882 882
 		$subtotal_last_title_posy = $posy;
883
-		$pdf->SetXY ($posx, $posy);
883
+		$pdf->SetXY($posx, $posy);
884 884
 		
885
-		$hideInnerLines = (int)GETPOST('hideInnerLines');
885
+		$hideInnerLines = (int) GETPOST('hideInnerLines');
886 886
 		
887 887
 		
888 888
  
889
-		$style = ($line->qty==1) ? 'BU' : 'BUI';
889
+		$style = ($line->qty == 1) ? 'BU' : 'BUI';
890 890
 		if (!empty($conf->global->SUBTOTAL_TITLE_STYLE)) $style = $conf->global->SUBTOTAL_TITLE_STYLE;
891 891
 		
892
-		if($hideInnerLines) {
893
-			if($line->qty==1)$pdf->SetFont('', $style, 9);
892
+		if ($hideInnerLines) {
893
+			if ($line->qty == 1)$pdf->SetFont('', $style, 9);
894 894
 			else 
895 895
 			{
896 896
 				if (!empty($conf->global->SUBTOTAL_STYLE_TITRES_SI_LIGNES_CACHEES)) $style = $conf->global->SUBTOTAL_STYLE_TITRES_SI_LIGNES_CACHEES;
@@ -899,43 +899,43 @@  discard block
 block discarded – undo
899 899
 		}
900 900
 		else {
901 901
 
902
-			if($line->qty==1)$pdf->SetFont('', $style, 9); //TODO if super utile
902
+			if ($line->qty == 1)$pdf->SetFont('', $style, 9); //TODO if super utile
903 903
 			else $pdf->SetFont('', $style, 9);
904 904
 			
905 905
 		}
906 906
 		
907 907
 		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
908
-		else $pdf->writeHTMLCell($w, $h, $posx, $posy, $label, 0, 1, false, true, 'J',true); // et maintenant avec du HTML
908
+		else $pdf->writeHTMLCell($w, $h, $posx, $posy, $label, 0, 1, false, true, 'J', true); // et maintenant avec du HTML
909 909
 		
910
-		if($description && !$hidedesc) {
910
+		if ($description && !$hidedesc) {
911 911
 			$posy = $pdf->GetY();
912 912
 			
913 913
 			$pdf->SetFont('', '', 8);
914 914
 			
915
-			$pdf->writeHTMLCell($w, $h, $posx, $posy, $description, 0, 1, false, true, 'J',true);
915
+			$pdf->writeHTMLCell($w, $h, $posx, $posy, $description, 0, 1, false, true, 'J', true);
916 916
 
917 917
 		}
918 918
 		
919 919
 	}
920 920
 
921
-	function pdf_writelinedesc_ref($parameters=array(), &$object, &$action='') {
921
+	function pdf_writelinedesc_ref($parameters = array(), &$object, &$action = '') {
922 922
 	// ultimate PDF hook O_o
923 923
 		
924
-		return $this->pdf_writelinedesc($parameters,$object,$action);
924
+		return $this->pdf_writelinedesc($parameters, $object, $action);
925 925
 		
926 926
 	}
927 927
 
928 928
 	function isModSubtotalLine(&$parameters, &$object) {
929 929
 		
930
-		if(is_array($parameters)) {
930
+		if (is_array($parameters)) {
931 931
 			$i = & $parameters['i'];	
932 932
 		}
933 933
 		else {
934
-			$i = (int)$parameters;
934
+			$i = (int) $parameters;
935 935
 		}
936 936
 		
937 937
 		
938
-		if($object->lines[$i]->special_code == $this->module_number && $object->lines[$i]->product_type == 9) {
938
+		if ($object->lines[$i]->special_code == $this->module_number && $object->lines[$i]->product_type == 9) {
939 939
 			return true;
940 940
 		}
941 941
 		
@@ -943,42 +943,42 @@  discard block
 block discarded – undo
943 943
 		
944 944
 	}
945 945
 
946
-	function pdf_getlineqty($parameters=array(), &$object, &$action='') {
947
-		global $conf,$hideprices;
946
+	function pdf_getlineqty($parameters = array(), &$object, &$action = '') {
947
+		global $conf, $hideprices;
948 948
 		
949
-		if($this->isModSubtotalLine($parameters,$object) ){
949
+		if ($this->isModSubtotalLine($parameters, $object)) {
950 950
 			
951 951
 			$this->resprints = ' ';
952 952
 			
953
-			if((float)DOL_VERSION<=3.6) {
953
+			if ((float) DOL_VERSION <= 3.6) {
954 954
 				return '';
955 955
 			}
956
-			else if((float)DOL_VERSION>=3.8) {
956
+			else if ((float) DOL_VERSION >= 3.8) {
957 957
 				return 1;
958 958
 			}
959 959
 			
960 960
 		}
961
-		elseif(!empty($hideprices)) {
961
+		elseif (!empty($hideprices)) {
962 962
 			$this->resprints = $object->lines[$parameters['i']]->qty;
963 963
 			return 1;
964 964
 		}
965 965
 		elseif (!empty($conf->global->SUBTOTAL_IF_HIDE_PRICES_SHOW_QTY))
966 966
 		{
967
-			$hideInnerLines = (int)GETPOST('hideInnerLines');
968
-			$hidedetails = (int)GETPOST('hidedetails');
967
+			$hideInnerLines = (int) GETPOST('hideInnerLines');
968
+			$hidedetails = (int) GETPOST('hidedetails');
969 969
 			if (empty($hideInnerLines) && !empty($hidedetails))
970 970
 			{
971 971
 				$this->resprints = $object->lines[$parameters['i']]->qty;
972 972
 			}
973 973
 		}
974 974
 		
975
-		if(is_array($parameters)) $i = & $parameters['i'];
976
-		else $i = (int)$parameters;
975
+		if (is_array($parameters)) $i = & $parameters['i'];
976
+		else $i = (int) $parameters;
977 977
 
978 978
 		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)
979 979
 		
980 980
 		$object->lines[$i]->fetch_optionals();
981
-		if (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])) )
981
+		if (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])))
982 982
 		{
983 983
 			if (!in_array(__FUNCTION__, explode(',', $conf->global->SUBTOTAL_TFIELD_TO_KEEP_WITH_NC)))
984 984
 			{
@@ -990,25 +990,25 @@  discard block
 block discarded – undo
990 990
 		return 0;
991 991
 	}
992 992
 	
993
-	function pdf_getlinetotalexcltax($parameters=array(), &$object, &$action='') {
993
+	function pdf_getlinetotalexcltax($parameters = array(), &$object, &$action = '') {
994 994
 		global $conf, $hideprices;
995 995
 		
996
-		if($this->isModSubtotalLine($parameters,$object) ){
996
+		if ($this->isModSubtotalLine($parameters, $object)) {
997 997
 			
998 998
 			$this->resprints = ' ';
999 999
 			
1000
-			if((float)DOL_VERSION<=3.6) {
1000
+			if ((float) DOL_VERSION <= 3.6) {
1001 1001
 				return '';
1002 1002
 			}
1003
-			else if((float)DOL_VERSION>=3.8) {
1003
+			else if ((float) DOL_VERSION >= 3.8) {
1004 1004
 				return 1;
1005 1005
 			}
1006 1006
 			
1007 1007
 		}
1008 1008
 		elseif (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS))
1009 1009
 		{
1010
-			if(is_array($parameters)) $i = & $parameters['i'];
1011
-			else $i = (int)$parameters;
1010
+			if (is_array($parameters)) $i = & $parameters['i'];
1011
+			else $i = (int) $parameters;
1012 1012
 			
1013 1013
 			if (!in_array(__FUNCTION__, explode(',', $conf->global->SUBTOTAL_TFIELD_TO_KEEP_WITH_NC)))
1014 1014
 			{
@@ -1029,13 +1029,13 @@  discard block
 block discarded – undo
1029 1029
 				}
1030 1030
 			}
1031 1031
 		}
1032
-		if ((int)GETPOST('hideInnerLines') && !empty($conf->global->SUBTOTAL_REPLACE_WITH_VAT_IF_HIDE_INNERLINES)){
1033
-		    if(is_array($parameters)) $i = & $parameters['i'];
1034
-		    else $i = (int)$parameters;
1032
+		if ((int) GETPOST('hideInnerLines') && !empty($conf->global->SUBTOTAL_REPLACE_WITH_VAT_IF_HIDE_INNERLINES)) {
1033
+		    if (is_array($parameters)) $i = & $parameters['i'];
1034
+		    else $i = (int) $parameters;
1035 1035
 		    $this->resprints = price($object->lines[$i]->total_ht);
1036 1036
 		}
1037 1037
 		if (!empty($hideprices)
1038
-		    || (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])) )
1038
+		    || (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])))
1039 1039
 		    )
1040 1040
 		{
1041 1041
 		    if (!empty($hideprices) || !in_array(__FUNCTION__, explode(',', $conf->global->SUBTOTAL_TFIELD_TO_KEEP_WITH_NC)))
@@ -1048,25 +1048,25 @@  discard block
 block discarded – undo
1048 1048
 		return 0;
1049 1049
 	}
1050 1050
 	
1051
-	function pdf_getlinetotalwithtax($parameters=array(), &$object, &$action='') {
1051
+	function pdf_getlinetotalwithtax($parameters = array(), &$object, &$action = '') {
1052 1052
 		global $conf;
1053 1053
 		
1054
-		if($this->isModSubtotalLine($parameters,$object) ){
1054
+		if ($this->isModSubtotalLine($parameters, $object)) {
1055 1055
 			
1056 1056
 			$this->resprints = ' ';
1057 1057
 		
1058
-			if((float)DOL_VERSION<=3.6) {
1058
+			if ((float) DOL_VERSION <= 3.6) {
1059 1059
 				return '';
1060 1060
 			}
1061
-			else if((float)DOL_VERSION>=3.8) {
1061
+			else if ((float) DOL_VERSION >= 3.8) {
1062 1062
 				return 1;
1063 1063
 			}
1064 1064
 		}
1065 1065
 		
1066
-		if(is_array($parameters)) $i = & $parameters['i'];
1067
-		else $i = (int)$parameters;
1066
+		if (is_array($parameters)) $i = & $parameters['i'];
1067
+		else $i = (int) $parameters;
1068 1068
 		
1069
-		if (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])) ) 
1069
+		if (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i]))) 
1070 1070
 		{
1071 1071
 			if (!in_array(__FUNCTION__, explode(',', $conf->global->SUBTOTAL_TFIELD_TO_KEEP_WITH_NC)))
1072 1072
 			{
@@ -1078,24 +1078,24 @@  discard block
 block discarded – undo
1078 1078
 		return 0;
1079 1079
 	}
1080 1080
 	
1081
-	function pdf_getlineunit($parameters=array(), &$object, &$action='') {
1081
+	function pdf_getlineunit($parameters = array(), &$object, &$action = '') {
1082 1082
 		global $conf;
1083 1083
 		
1084
-		if($this->isModSubtotalLine($parameters,$object) ){
1084
+		if ($this->isModSubtotalLine($parameters, $object)) {
1085 1085
 			$this->resprints = ' ';
1086 1086
 		
1087
-			if((float)DOL_VERSION<=3.6) {
1087
+			if ((float) DOL_VERSION <= 3.6) {
1088 1088
 				return '';
1089 1089
 			}
1090
-			else if((float)DOL_VERSION>=3.8) {
1090
+			else if ((float) DOL_VERSION >= 3.8) {
1091 1091
 				return 1;
1092 1092
 			}
1093 1093
 		}
1094 1094
 		
1095
-		if(is_array($parameters)) $i = & $parameters['i'];
1096
-		else $i = (int)$parameters;
1095
+		if (is_array($parameters)) $i = & $parameters['i'];
1096
+		else $i = (int) $parameters;
1097 1097
 			
1098
-		if (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])) )
1098
+		if (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])))
1099 1099
 		{
1100 1100
 			if (!in_array(__FUNCTION__, explode(',', $conf->global->SUBTOTAL_TFIELD_TO_KEEP_WITH_NC)))
1101 1101
 			{
@@ -1107,24 +1107,24 @@  discard block
 block discarded – undo
1107 1107
 		return 0;
1108 1108
 	}
1109 1109
 	
1110
-	function pdf_getlineupexcltax($parameters=array(), &$object, &$action='') {
1111
-		global $conf,$hideprices;
1110
+	function pdf_getlineupexcltax($parameters = array(), &$object, &$action = '') {
1111
+		global $conf, $hideprices;
1112 1112
 
1113
-		if($this->isModSubtotalLine($parameters,$object) ){
1113
+		if ($this->isModSubtotalLine($parameters, $object)) {
1114 1114
 			$this->resprints = ' ';
1115 1115
 		
1116
-			if((float)DOL_VERSION<=3.6) {
1116
+			if ((float) DOL_VERSION <= 3.6) {
1117 1117
 				return '';
1118 1118
 			}
1119
-			else if((float)DOL_VERSION>=3.8) {
1119
+			else if ((float) DOL_VERSION >= 3.8) {
1120 1120
 				return 1;
1121 1121
 			}
1122 1122
 		}
1123
-		if(is_array($parameters)) $i = & $parameters['i'];
1124
-		else $i = (int)$parameters;
1123
+		if (is_array($parameters)) $i = & $parameters['i'];
1124
+		else $i = (int) $parameters;
1125 1125
 		
1126 1126
 		if (!empty($hideprices) 
1127
-				|| (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])) )
1127
+				|| (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])))
1128 1128
 		)
1129 1129
 		{
1130 1130
 			if (!empty($hideprices) || !in_array(__FUNCTION__, explode(',', $conf->global->SUBTOTAL_TFIELD_TO_KEEP_WITH_NC)))
@@ -1137,24 +1137,24 @@  discard block
 block discarded – undo
1137 1137
 		return 0;
1138 1138
 	}
1139 1139
 	
1140
-	function pdf_getlineupwithtax($parameters=array(), &$object, &$action='') {
1141
-		global $conf,$hideprices;
1140
+	function pdf_getlineupwithtax($parameters = array(), &$object, &$action = '') {
1141
+		global $conf, $hideprices;
1142 1142
 		
1143
-		if($this->isModSubtotalLine($parameters,$object) ){
1143
+		if ($this->isModSubtotalLine($parameters, $object)) {
1144 1144
 			$this->resprints = ' ';
1145
-			if((float)DOL_VERSION<=3.6) {
1145
+			if ((float) DOL_VERSION <= 3.6) {
1146 1146
 				return '';
1147 1147
 			}
1148
-			else if((float)DOL_VERSION>=3.8) {
1148
+			else if ((float) DOL_VERSION >= 3.8) {
1149 1149
 				return 1;
1150 1150
 			}
1151 1151
 		}
1152 1152
 		
1153
-		if(is_array($parameters)) $i = & $parameters['i'];
1154
-		else $i = (int)$parameters;
1153
+		if (is_array($parameters)) $i = & $parameters['i'];
1154
+		else $i = (int) $parameters;
1155 1155
 			
1156 1156
 		if (!empty($hideprices)
1157
-				|| (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])) )
1157
+				|| (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])))
1158 1158
 		)
1159 1159
 		{
1160 1160
 			if (!empty($hideprices) || !in_array(__FUNCTION__, explode(',', $conf->global->SUBTOTAL_TFIELD_TO_KEEP_WITH_NC)))
@@ -1167,27 +1167,27 @@  discard block
 block discarded – undo
1167 1167
 		return 0;
1168 1168
 	}
1169 1169
 	
1170
-	function pdf_getlinevatrate($parameters=array(), &$object, &$action='') {
1170
+	function pdf_getlinevatrate($parameters = array(), &$object, &$action = '') {
1171 1171
 		global $conf;
1172 1172
 		
1173
-		if($this->isModSubtotalLine($parameters,$object) ){
1173
+		if ($this->isModSubtotalLine($parameters, $object)) {
1174 1174
 			$this->resprints = ' ';
1175 1175
 			
1176
-			if((float)DOL_VERSION<=3.6) {
1176
+			if ((float) DOL_VERSION <= 3.6) {
1177 1177
 				return '';
1178 1178
 			}
1179
-			else if((float)DOL_VERSION>=3.8) {
1179
+			else if ((float) DOL_VERSION >= 3.8) {
1180 1180
 				return 1;
1181 1181
 			}
1182 1182
 		}
1183 1183
 		
1184
-		if(is_array($parameters)) $i = & $parameters['i'];
1185
-		else $i = (int)$parameters;
1184
+		if (is_array($parameters)) $i = & $parameters['i'];
1185
+		else $i = (int) $parameters;
1186 1186
 		
1187 1187
 		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)
1188 1188
 
1189 1189
 		$object->lines[$i]->fetch_optionals();
1190
-		if (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])) )
1190
+		if (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])))
1191 1191
 		{
1192 1192
 			if (!in_array(__FUNCTION__, explode(',', $conf->global->SUBTOTAL_TFIELD_TO_KEEP_WITH_NC)))
1193 1193
 			{
@@ -1199,23 +1199,23 @@  discard block
 block discarded – undo
1199 1199
 		return 0;
1200 1200
 	}
1201 1201
 		
1202
-	function pdf_getlineprogress($parameters=array(), &$object, &$action) {
1202
+	function pdf_getlineprogress($parameters = array(), &$object, &$action) {
1203 1203
 		global $conf;
1204 1204
 		
1205
-		if($this->isModSubtotalLine($parameters,$object) ){
1205
+		if ($this->isModSubtotalLine($parameters, $object)) {
1206 1206
 			$this->resprints = ' ';
1207
-			if((float)DOL_VERSION<=3.6) {
1207
+			if ((float) DOL_VERSION <= 3.6) {
1208 1208
 				return '';
1209 1209
 			}
1210
-			else if((float)DOL_VERSION>=3.8) {
1210
+			else if ((float) DOL_VERSION >= 3.8) {
1211 1211
 				return 1;
1212 1212
 			}
1213 1213
 		}
1214 1214
 		
1215
-		if(is_array($parameters)) $i = & $parameters['i'];
1216
-		else $i = (int)$parameters;
1215
+		if (is_array($parameters)) $i = & $parameters['i'];
1216
+		else $i = (int) $parameters;
1217 1217
 			
1218
-		if (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])) )
1218
+		if (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])))
1219 1219
 		{
1220 1220
 			if (!in_array(__FUNCTION__, explode(',', $conf->global->SUBTOTAL_TFIELD_TO_KEEP_WITH_NC)))
1221 1221
 			{
@@ -1230,12 +1230,12 @@  discard block
 block discarded – undo
1230 1230
 	function add_numerotation(&$object) {
1231 1231
 		global $conf;
1232 1232
 		
1233
-		if(!empty($conf->global->SUBTOTAL_USE_NUMEROTATION)) {
1233
+		if (!empty($conf->global->SUBTOTAL_USE_NUMEROTATION)) {
1234 1234
 		
1235 1235
 			$TLevelTitre = array();
1236 1236
 			$prevlevel = 0;
1237 1237
 		
1238
-			foreach($object->lines as $k=>&$line) 
1238
+			foreach ($object->lines as $k=>&$line) 
1239 1239
 			{
1240 1240
 				if ($line->id > 0 && $this->isModSubtotalLine($k, $object) && $line->qty <= 10)
1241 1241
 				{
@@ -1249,12 +1249,12 @@  discard block
 block discarded – undo
1249 1249
 	}
1250 1250
 
1251 1251
 	// TODO ne gère pas encore la numération des lignes "Totaux"
1252
-	private function formatNumerotation(&$TLineTitle, $line_reference='', $level=1, $prefix_num=0)
1252
+	private function formatNumerotation(&$TLineTitle, $line_reference = '', $level = 1, $prefix_num = 0)
1253 1253
 	{
1254 1254
 		$TTitle = array();
1255 1255
 		
1256
-		$i=1;
1257
-		$j=0;
1256
+		$i = 1;
1257
+		$j = 0;
1258 1258
 		foreach ($TLineTitle as $k => &$line)
1259 1259
 		{
1260 1260
 			if (!empty($line_reference) && $line->rang <= $line_reference->rang) continue;
@@ -1264,7 +1264,7 @@  discard block
 block discarded – undo
1264 1264
 			{
1265 1265
 				$TTitle[$j]['numerotation'] = ($prefix_num == 0) ? $i : $prefix_num.'.'.$i;
1266 1266
 				//var_dump('Prefix == '.$prefix_num.' // '.$line->desc.' ==> numerotation == '.$TTitle[$j]['numerotation'].'   ###    '.$line->qty .'=='. $level);
1267
-				if (empty($line->label) && (float)DOL_VERSION < 6)
1267
+				if (empty($line->label) && (float) DOL_VERSION < 6)
1268 1268
 				{
1269 1269
 					$line->label = !empty($line->desc) ? $line->desc : $line->description;
1270 1270
 					$line->desc = $line->description = '';
@@ -1290,26 +1290,26 @@  discard block
 block discarded – undo
1290 1290
 	
1291 1291
 	function setDocTVA(&$pdf, &$object) {
1292 1292
 		
1293
-		$hidedetails = (int)GETPOST('hidedetails');
1293
+		$hidedetails = (int) GETPOST('hidedetails');
1294 1294
 		
1295
-		if(empty($hidedetails)) return false;
1295
+		if (empty($hidedetails)) return false;
1296 1296
 		
1297 1297
 		// TODO can't add VAT to document without lines... :-/
1298 1298
 		
1299 1299
 		return true;
1300 1300
 	}
1301 1301
 	
1302
-	function beforePDFCreation($parameters=array(), &$object, &$action)
1302
+	function beforePDFCreation($parameters = array(), &$object, &$action)
1303 1303
 	{
1304 1304
 		/**
1305 1305
 		 * @var $pdf    TCPDF
1306 1306
 		 */
1307
-		global $pdf,$conf, $langs;
1307
+		global $pdf, $conf, $langs;
1308 1308
 
1309 1309
 		// var_dump($object->lines);
1310 1310
 		dol_include_once('/subtotal/class/subtotal.class.php');
1311 1311
 
1312
-		foreach($parameters as $key=>$value) {
1312
+		foreach ($parameters as $key=>$value) {
1313 1313
 			${$key} = $value;
1314 1314
 		}
1315 1315
 		
@@ -1318,25 +1318,25 @@  discard block
 block discarded – undo
1318 1318
 		$this->add_numerotation($object);	
1319 1319
 		
1320 1320
 		
1321
-		$hideInnerLines = (int)GETPOST('hideInnerLines');
1322
-		$hidedetails = (int)GETPOST('hidedetails');
1321
+		$hideInnerLines = (int) GETPOST('hideInnerLines');
1322
+		$hidedetails = (int) GETPOST('hidedetails');
1323 1323
 		
1324 1324
 		if ($hideInnerLines) { // si c une ligne de titre
1325
-	    	$fk_parent_line=0;
1326
-			$TLines =array();
1325
+	    	$fk_parent_line = 0;
1326
+			$TLines = array();
1327 1327
 		
1328
-			$original_count=count($object->lines);
1328
+			$original_count = count($object->lines);
1329 1329
 		    $TTvas = array(); // tableau de tva
1330 1330
 		    
1331
-			foreach($object->lines as $k=>&$line) 
1331
+			foreach ($object->lines as $k=>&$line) 
1332 1332
 			{
1333 1333
 			    
1334
-				if($line->product_type==9 && $line->rowid>0) 
1334
+				if ($line->product_type == 9 && $line->rowid > 0) 
1335 1335
 				{
1336 1336
 					$fk_parent_line = $line->rowid;
1337 1337
 					
1338 1338
 					// 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
1339
-					if(TSubtotal::isSubtotal($line)) 
1339
+					if (TSubtotal::isSubtotal($line)) 
1340 1340
 					{
1341 1341
 						/*$total = $this->getTotalLineFromObject($object, $line, '');
1342 1342
 						
@@ -1356,27 +1356,27 @@  discard block
 block discarded – undo
1356 1356
 			
1357 1357
 				if ($hideInnerLines)
1358 1358
 				{
1359
-				    if(!empty($conf->global->SUBTOTAL_REPLACE_WITH_VAT_IF_HIDE_INNERLINES))
1359
+				    if (!empty($conf->global->SUBTOTAL_REPLACE_WITH_VAT_IF_HIDE_INNERLINES))
1360 1360
 				    {
1361
-				        if($line->tva_tx != '0.000' && $line->product_type!=9){
1361
+				        if ($line->tva_tx != '0.000' && $line->product_type != 9) {
1362 1362
 				            
1363 1363
     				        // on remplit le tableau de tva pour substituer les lignes cachées
1364 1364
     				        $TTvas[$line->tva_tx]['total_tva'] += $line->total_tva;
1365 1365
     				        $TTvas[$line->tva_tx]['total_ht'] += $line->total_ht;
1366 1366
     				        $TTvas[$line->tva_tx]['total_ttc'] += $line->total_ttc; 
1367 1367
     				    }
1368
-    					if($line->product_type==9 && $line->rowid>0)
1368
+    					if ($line->product_type == 9 && $line->rowid > 0)
1369 1369
     					{
1370 1370
     					    //Cas où je doit cacher les produits et afficher uniquement les sous-totaux avec les titres
1371 1371
     					    // génère des lignes d'affichage des montants HT soumis à tva
1372 1372
     					    $nbtva = count($TTvas);
1373
-    					    if(!empty($nbtva)){
1374
-    					        foreach ($TTvas as $tx =>$val){
1373
+    					    if (!empty($nbtva)) {
1374
+    					        foreach ($TTvas as $tx =>$val) {
1375 1375
     					            $l = clone $line;
1376 1376
     					            $l->product_type = 1;
1377 1377
     					            $l->special_code = '';
1378 1378
     					            $l->qty = 1;
1379
-    					            $l->desc = 'Montant HT soumis à '.$langs->trans('VAT').' '. price($tx) .' %';
1379
+    					            $l->desc = 'Montant HT soumis à '.$langs->trans('VAT').' '.price($tx).' %';
1380 1380
     					            $l->tva_tx = $tx;
1381 1381
     					            $l->total_ht = $val['total_ht'];
1382 1382
     					            $l->total_tva = $val['total_tva'];
@@ -1392,7 +1392,7 @@  discard block
 block discarded – undo
1392 1392
     					}
1393 1393
 				    } else {
1394 1394
 				        
1395
-				        if($line->product_type==9 && $line->rowid>0)
1395
+				        if ($line->product_type == 9 && $line->rowid > 0)
1396 1396
 				        {
1397 1397
 				            // ajoute la ligne de sous-total
1398 1398
 				            $TLines[] = $line; 
@@ -1420,14 +1420,14 @@  discard block
 block discarded – undo
1420 1420
 			
1421 1421
 			// cas incongru où il y aurait des produits en dessous du dernier sous-total
1422 1422
 			$nbtva = count($TTvas);
1423
-			if(!empty($nbtva) && $hideInnerLines && !empty($conf->global->SUBTOTAL_REPLACE_WITH_VAT_IF_HIDE_INNERLINES))
1423
+			if (!empty($nbtva) && $hideInnerLines && !empty($conf->global->SUBTOTAL_REPLACE_WITH_VAT_IF_HIDE_INNERLINES))
1424 1424
 			{
1425
-			    foreach ($TTvas as $tx =>$val){
1425
+			    foreach ($TTvas as $tx =>$val) {
1426 1426
 			        $l = clone $line;
1427 1427
 			        $l->product_type = 1;
1428 1428
 			        $l->special_code = '';
1429 1429
 			        $l->qty = 1;
1430
-			        $l->desc = 'Montant HT soumis à '.$langs->trans('VAT').' '. price($tx) .' %';
1430
+			        $l->desc = 'Montant HT soumis à '.$langs->trans('VAT').' '.price($tx).' %';
1431 1431
 			        $l->tva_tx = $tx;
1432 1432
 			        $l->total_ht = $val['total_ht'];
1433 1433
 			        $l->total_tva = $val['total_tva'];
@@ -1439,11 +1439,11 @@  discard block
 block discarded – undo
1439 1439
 			}
1440 1440
 			
1441 1441
 			global $nblignes;
1442
-			$nblignes=count($TLines);
1442
+			$nblignes = count($TLines);
1443 1443
 
1444 1444
 			$object->lines = $TLines;
1445 1445
 			
1446
-			if($i>count($object->lines)) {
1446
+			if ($i > count($object->lines)) {
1447 1447
 				$this->resprints = '';
1448 1448
 				return 0;
1449 1449
 			}
@@ -1452,59 +1452,59 @@  discard block
 block discarded – undo
1452 1452
 		return 0;
1453 1453
 	}
1454 1454
 
1455
-	function pdf_writelinedesc($parameters=array(), &$object, &$action)
1455
+	function pdf_writelinedesc($parameters = array(), &$object, &$action)
1456 1456
 	{
1457 1457
 		/**
1458 1458
 		 * @var $pdf    TCPDF
1459 1459
 		 */
1460
-		global $pdf,$conf;
1460
+		global $pdf, $conf;
1461 1461
 
1462
-		foreach($parameters as $key=>$value) {
1462
+		foreach ($parameters as $key=>$value) {
1463 1463
 			${$key} = $value;
1464 1464
 		}
1465 1465
 		
1466
-		$hideInnerLines = (int)GETPOST('hideInnerLines');
1467
-		$hidedetails = (int)GETPOST('hidedetails');
1466
+		$hideInnerLines = (int) GETPOST('hideInnerLines');
1467
+		$hidedetails = (int) GETPOST('hidedetails');
1468 1468
 		
1469
-		if($this->isModSubtotalLine($parameters,$object) ){			
1469
+		if ($this->isModSubtotalLine($parameters, $object)) {			
1470 1470
 		
1471 1471
 				global $hideprices;
1472 1472
 				
1473
-				if(!empty($hideprices)) {
1474
-					foreach($object->lines as &$line) {
1475
-						if($line->fk_product_type!=9) $line->fk_parent_line = -1;	
1473
+				if (!empty($hideprices)) {
1474
+					foreach ($object->lines as &$line) {
1475
+						if ($line->fk_product_type != 9) $line->fk_parent_line = -1;	
1476 1476
 					}
1477 1477
 				}
1478 1478
 			
1479 1479
 				$line = &$object->lines[$i];
1480 1480
 				
1481
-				if($line->info_bits>0) { // PAGE BREAK
1481
+				if ($line->info_bits > 0) { // PAGE BREAK
1482 1482
 					$pdf->addPage();
1483 1483
 					$posy = $pdf->GetY();
1484 1484
 				}
1485 1485
 				
1486 1486
 				$label = $line->label;
1487
-				$description= !empty($line->desc) ? $outputlangs->convToOutputCharset($line->desc) : $outputlangs->convToOutputCharset($line->description);
1487
+				$description = !empty($line->desc) ? $outputlangs->convToOutputCharset($line->desc) : $outputlangs->convToOutputCharset($line->description);
1488 1488
 				
1489
-				if(empty($label)) {
1489
+				if (empty($label)) {
1490 1490
 					$label = $description;
1491
-					$description='';
1491
+					$description = '';
1492 1492
 				}
1493 1493
 				
1494
-				if($line->qty>90) {
1494
+				if ($line->qty > 90) {
1495 1495
 					
1496 1496
 					if ($conf->global->SUBTOTAL_USE_NEW_FORMAT)	$label .= ' '.$this->getTitle($object, $line);
1497 1497
 					
1498 1498
 					$pageBefore = $pdf->getPage();
1499
-					$this->pdf_add_total($pdf,$object, $line, $label, $description,$posx, $posy, $w, $h);
1499
+					$this->pdf_add_total($pdf, $object, $line, $label, $description, $posx, $posy, $w, $h);
1500 1500
 					$pageAfter = $pdf->getPage();	
1501 1501
 
1502
-					if($pageAfter>$pageBefore) {
1502
+					if ($pageAfter > $pageBefore) {
1503 1503
 						//print "ST $pageAfter>$pageBefore<br>";
1504 1504
 						$pdf->rollbackTransaction(true);	
1505
-						$pdf->addPage('','', true);
1505
+						$pdf->addPage('', '', true);
1506 1506
 						$posy = $pdf->GetY();
1507
-						$this->pdf_add_total($pdf,$object, $line, $label, $description,$posx, $posy, $w, $h);
1507
+						$this->pdf_add_total($pdf, $object, $line, $label, $description, $posx, $posy, $w, $h);
1508 1508
 						$posy = $pdf->GetY();
1509 1509
 						//print 'add ST'.$pdf->getPage().'<br />';
1510 1510
 					}
@@ -1515,7 +1515,7 @@  discard block
 block discarded – undo
1515 1515
 				else if ($line->qty < 10) {
1516 1516
 					$pageBefore = $pdf->getPage();
1517 1517
 
1518
-					$this->pdf_add_title($pdf,$object, $line, $label, $description,$posx, $posy, $w, $h); 
1518
+					$this->pdf_add_title($pdf, $object, $line, $label, $description, $posx, $posy, $w, $h); 
1519 1519
 					$pageAfter = $pdf->getPage();	
1520 1520
 
1521 1521
 					
@@ -1590,9 +1590,9 @@  discard block
 block discarded – undo
1590 1590
 	 * @param $hookmanager  HookManager
1591 1591
 	 * @return int
1592 1592
 	 */
1593
-	function printObjectLine ($parameters, &$object, &$action, $hookmanager){
1593
+	function printObjectLine($parameters, &$object, &$action, $hookmanager) {
1594 1594
 		
1595
-		global $conf,$langs,$user,$db,$bc;
1595
+		global $conf, $langs, $user, $db, $bc;
1596 1596
 		
1597 1597
 		$num = &$parameters['num'];
1598 1598
 		$line = &$parameters['line'];
@@ -1600,24 +1600,24 @@  discard block
 block discarded – undo
1600 1600
 		
1601 1601
 		$var = &$parameters['var'];
1602 1602
 
1603
-		$contexts = explode(':',$parameters['context']);
1603
+		$contexts = explode(':', $parameters['context']);
1604 1604
 
1605 1605
 		$createRight = $user->rights->{$object->element}->creer;
1606
-		if($object->element == 'facturerec' )
1606
+		if ($object->element == 'facturerec')
1607 1607
 		{
1608 1608
 			$object->statut = 0; // hack for facture rec
1609 1609
 			$createRight = $user->rights->facture->creer;
1610 1610
 		}
1611 1611
 		
1612
-		if($line->special_code!=$this->module_number || $line->product_type!=9) {
1612
+		if ($line->special_code != $this->module_number || $line->product_type != 9) {
1613 1613
 			null;
1614 1614
 		}	
1615
-		else if (in_array('invoicecard',$contexts) || in_array('propalcard',$contexts) || in_array('ordercard',$contexts) || in_array('invoicereccard',$contexts)) 
1615
+		else if (in_array('invoicecard', $contexts) || in_array('propalcard', $contexts) || in_array('ordercard', $contexts) || in_array('invoicereccard', $contexts)) 
1616 1616
         {
1617
-			if($object->element=='facture')$idvar = 'facid';
1618
-			else $idvar='id';
1617
+			if ($object->element == 'facture')$idvar = 'facid';
1618
+			else $idvar = 'id';
1619 1619
 			
1620
-			if((float)DOL_VERSION <= 3.4)
1620
+			if ((float) DOL_VERSION <= 3.4)
1621 1621
 			{
1622 1622
 				?>
1623 1623
 				<script type="text/javascript">
@@ -1641,18 +1641,18 @@  discard block
 block discarded – undo
1641 1641
 				<?php
1642 1642
 			}
1643 1643
 			
1644
-			if(empty($line->description)) $line->description = $line->desc;
1644
+			if (empty($line->description)) $line->description = $line->desc;
1645 1645
 			
1646 1646
 			$colspan = 5;
1647
-			if($object->element == 'facturerec' ) $colspan = 3;
1648
-
1649
-			if(!empty($conf->multicurrency->enabled)) $colspan+=2;
1650
-			if($object->element == 'commande' && $object->statut < 3 && !empty($conf->shippableorder->enabled)) $colspan++;
1651
-			if(!empty($conf->margin->enabled)) $colspan++;
1652
-			if(!empty($conf->global->DISPLAY_MARGIN_RATES)) $colspan++;
1653
-			if(!empty($conf->global->DISPLAY_MARK_RATES)) $colspan++;
1654
-			if($object->element == 'facture' && !empty($conf->global->INVOICE_USE_SITUATION) && $object->type == Facture::TYPE_SITUATION) $colspan++;
1655
-			if(!empty($conf->global->PRODUCT_USE_UNITS)) $colspan++;
1647
+			if ($object->element == 'facturerec') $colspan = 3;
1648
+
1649
+			if (!empty($conf->multicurrency->enabled)) $colspan += 2;
1650
+			if ($object->element == 'commande' && $object->statut < 3 && !empty($conf->shippableorder->enabled)) $colspan++;
1651
+			if (!empty($conf->margin->enabled)) $colspan++;
1652
+			if (!empty($conf->global->DISPLAY_MARGIN_RATES)) $colspan++;
1653
+			if (!empty($conf->global->DISPLAY_MARK_RATES)) $colspan++;
1654
+			if ($object->element == 'facture' && !empty($conf->global->INVOICE_USE_SITUATION) && $object->type == Facture::TYPE_SITUATION) $colspan++;
1655
+			if (!empty($conf->global->PRODUCT_USE_UNITS)) $colspan++;
1656 1656
 					
1657 1657
 			/* Titre */
1658 1658
 			//var_dump($line);
@@ -1662,35 +1662,35 @@  discard block
 block discarded – undo
1662 1662
             
1663 1663
 			
1664 1664
 			?>
1665
-			<tr <?php echo $bc[$var]; $var=!$var; echo $data; ?> rel="subtotal" id="row-<?php echo $line->id ?>" style="<?php
1665
+			<tr <?php echo $bc[$var]; $var = !$var; echo $data; ?> rel="subtotal" id="row-<?php echo $line->id ?>" style="<?php
1666 1666
 					if (!empty($conf->global->SUBTOTAL_USE_NEW_FORMAT))
1667 1667
 					{
1668
-						if($line->qty==99) print 'background:#adadcf';
1669
-						else if($line->qty==98) print 'background:#ddddff;';
1670
-						else if($line->qty<=97 && $line->qty>=91) print 'background:#eeeeff;';
1671
-						else if($line->qty==1) print 'background:#adadcf;';
1672
-						else if($line->qty==2) print 'background:#ddddff;';
1673
-						else if($line->qty==50) print '';
1668
+						if ($line->qty == 99) print 'background:#adadcf';
1669
+						else if ($line->qty == 98) print 'background:#ddddff;';
1670
+						else if ($line->qty <= 97 && $line->qty >= 91) print 'background:#eeeeff;';
1671
+						else if ($line->qty == 1) print 'background:#adadcf;';
1672
+						else if ($line->qty == 2) print 'background:#ddddff;';
1673
+						else if ($line->qty == 50) print '';
1674 1674
 						else print 'background:#eeeeff;';
1675 1675
 
1676 1676
 						//A compléter si on veux plus de nuances de couleurs avec les niveau 4,5,6,7,8 et 9
1677 1677
 					}
1678 1678
 					else 
1679 1679
 					{
1680
-						if($line->qty==99) print 'background:#ddffdd';
1681
-						else if($line->qty==98) print 'background:#ddddff;';
1682
-						else if($line->qty==2) print 'background:#eeeeff; ';
1683
-						else if($line->qty==50) print '';
1684
-						else print 'background:#eeffee;' ;
1680
+						if ($line->qty == 99) print 'background:#ddffdd';
1681
+						else if ($line->qty == 98) print 'background:#ddddff;';
1682
+						else if ($line->qty == 2) print 'background:#eeeeff; ';
1683
+						else if ($line->qty == 50) print '';
1684
+						else print 'background:#eeffee;';
1685 1685
 					}
1686 1686
 
1687 1687
 			?>;">
1688 1688
 			
1689
-				<td colspan="<?php echo $colspan; ?>" style="<?php TSubtotal::isFreeText($line) ? '' : 'font-weight:bold;'; ?>  <?php echo ($line->qty>90)?'text-align:right':'' ?> "><?php
1690
-					if($action=='editline' && GETPOST('lineid') == $line->id && TSubtotal::isModSubtotalLine($line) ) {
1689
+				<td colspan="<?php echo $colspan; ?>" style="<?php TSubtotal::isFreeText($line) ? '' : 'font-weight:bold;'; ?>  <?php echo ($line->qty > 90) ? 'text-align:right' : '' ?> "><?php
1690
+					if ($action == 'editline' && GETPOST('lineid') == $line->id && TSubtotal::isModSubtotalLine($line)) {
1691 1691
 
1692
-						$params=array('line'=>$line);
1693
-						$reshook=$hookmanager->executeHooks('formEditProductOptions',$params,$object,$action);
1692
+						$params = array('line'=>$line);
1693
+						$reshook = $hookmanager->executeHooks('formEditProductOptions', $params, $object, $action);
1694 1694
 						
1695 1695
 						echo '<div id="line_'.$line->id.'"></div>'; // Imitation Dolibarr
1696 1696
 						echo '<input type="hidden" value="'.$line->id.'" name="lineid">';
@@ -1698,7 +1698,7 @@  discard block
 block discarded – undo
1698 1698
 						echo '<input id="product_id" type="hidden" value="'.$line->fk_product.'" name="type">';
1699 1699
 						echo '<input id="special_code" type="hidden" value="'.$line->special_code.'" name="type">';
1700 1700
 
1701
-						$isFreeText=false;
1701
+						$isFreeText = false;
1702 1702
 						if (TSubtotal::isTitle($line))
1703 1703
 						{
1704 1704
 							$qty_displayed = $line->qty;
@@ -1716,13 +1716,13 @@  discard block
 block discarded – undo
1716 1716
 						}
1717 1717
 						
1718 1718
 						$newlabel = $line->label;
1719
-						if($line->label=='' && !$isFreeText) {
1720
-							if(TSubtotal::isSubtotal($line)) {
1719
+						if ($line->label == '' && !$isFreeText) {
1720
+							if (TSubtotal::isSubtotal($line)) {
1721 1721
 								$newlabel = $line->description.' '.$this->getTitle($object, $line);
1722
-								$line->description='';
1723
-							} elseif( (float)DOL_VERSION < 6 ) {
1724
-								$newlabel= $line->description;
1725
-								$line->description='';
1722
+								$line->description = '';
1723
+							} elseif ((float) DOL_VERSION < 6) {
1724
+								$newlabel = $line->description;
1725
+								$line->description = '';
1726 1726
 							}
1727 1727
 						}
1728 1728
 
@@ -1731,10 +1731,10 @@  discard block
 block discarded – undo
1731 1731
 						
1732 1732
 						if (!$isFreeText) echo '<input type="text" name="line-title" id-line="'.$line->id.'" value="'.$newlabel.'" size="80" '.$readonlyForSituation.'/>&nbsp;';
1733 1733
 						
1734
-						if (!empty($conf->global->SUBTOTAL_USE_NEW_FORMAT) && (TSubtotal::isTitle($line) || TSubtotal::isSubtotal($line)) )
1734
+						if (!empty($conf->global->SUBTOTAL_USE_NEW_FORMAT) && (TSubtotal::isTitle($line) || TSubtotal::isSubtotal($line)))
1735 1735
 						{
1736 1736
 							$select = '<select name="subtotal_level">';
1737
-							for ($j=1; $j<10; $j++)
1737
+							for ($j = 1; $j < 10; $j++)
1738 1738
 							{
1739 1739
 								if (!empty($readonlyForSituation)) {
1740 1740
 									if ($qty_displayed == $j) $select .= '<option selected="selected" value="'.$j.'">'.$langs->trans('Level').' '.$j.'</option>';
@@ -1747,7 +1747,7 @@  discard block
 block discarded – undo
1747 1747
 						
1748 1748
 
1749 1749
 						echo '<div class="subtotal_underline" style="margin-left:24px;">';
1750
-							echo '<label for="subtotal-pagebreak">'.$langs->trans('AddBreakPageBefore').'</label> <input style="vertical-align:sub;"  type="checkbox" name="line-pagebreak" id="subtotal-pagebreak" value="8" '.(($line->info_bits > 0) ? 'checked="checked"' : '') .' />&nbsp;&nbsp;';
1750
+							echo '<label for="subtotal-pagebreak">'.$langs->trans('AddBreakPageBefore').'</label> <input style="vertical-align:sub;"  type="checkbox" name="line-pagebreak" id="subtotal-pagebreak" value="8" '.(($line->info_bits > 0) ? 'checked="checked"' : '').' />&nbsp;&nbsp;';
1751 1751
 
1752 1752
 							if (TSubtotal::isTitle($line))
1753 1753
 							{
@@ -1765,9 +1765,9 @@  discard block
 block discarded – undo
1765 1765
 							else if ($isFreeText) echo TSubtotal::getFreeTextHtml($line, (bool) $readonlyForSituation);
1766 1766
 						echo '</div>';
1767 1767
 
1768
-						if($line->qty<10) {
1768
+						if ($line->qty < 10) {
1769 1769
 							// WYSIWYG editor
1770
-							require_once DOL_DOCUMENT_ROOT . '/core/class/doleditor.class.php';
1770
+							require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
1771 1771
 							$nbrows = ROWS_2;
1772 1772
 							$cked_enabled = (!empty($conf->global->FCKEDITOR_ENABLE_DETAILS) ? $conf->global->FCKEDITOR_ENABLE_DETAILS : 0);
1773 1773
 							if (!empty($conf->global->MAIN_INPUT_DESC_HEIGHT)) {
@@ -1787,25 +1787,25 @@  discard block
 block discarded – undo
1787 1787
 
1788 1788
 						 if ($conf->global->SUBTOTAL_USE_NEW_FORMAT)
1789 1789
 						 {
1790
-							if(TSubtotal::isTitle($line) || TSubtotal::isSubtotal($line)) 
1790
+							if (TSubtotal::isTitle($line) || TSubtotal::isSubtotal($line)) 
1791 1791
 							{
1792
-								echo str_repeat('&nbsp;&nbsp;&nbsp;', $line->qty-1);
1792
+								echo str_repeat('&nbsp;&nbsp;&nbsp;', $line->qty - 1);
1793 1793
 								
1794 1794
 								if (TSubtotal::isTitle($line)) print img_picto('', 'subtotal@subtotal').'<span style="font-size:9px;margin-left:-3px;">'.$line->qty.'</span>&nbsp;&nbsp;';
1795
-								else print img_picto('', 'subtotal2@subtotal').'<span style="font-size:9px;margin-left:-1px;">'.(100-$line->qty).'</span>&nbsp;&nbsp;';
1795
+								else print img_picto('', 'subtotal2@subtotal').'<span style="font-size:9px;margin-left:-1px;">'.(100 - $line->qty).'</span>&nbsp;&nbsp;';
1796 1796
 							}
1797 1797
 						 }
1798 1798
 						 else 
1799 1799
 						 {
1800
-							if($line->qty<=1) print img_picto('', 'subtotal@subtotal');
1801
-							else if($line->qty==2) print img_picto('', 'subsubtotal@subtotal').'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'; 
1800
+							if ($line->qty <= 1) print img_picto('', 'subtotal@subtotal');
1801
+							else if ($line->qty == 2) print img_picto('', 'subsubtotal@subtotal').'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'; 
1802 1802
 						 }
1803 1803
 						 
1804 1804
 						 
1805 1805
 						 // Get display styles and apply them
1806 1806
 						 $titleStyleItalic = strpos($conf->global->SUBTOTAL_TITLE_STYLE, 'I') === false ? '' : ' font-style: italic;';
1807
-						 $titleStyleBold =  strpos($conf->global->SUBTOTAL_TITLE_STYLE, 'B') === false ? '' : ' font-weight:bold;';
1808
-						 $titleStyleUnderline =  strpos($conf->global->SUBTOTAL_TITLE_STYLE, 'U') === false ? '' : ' text-decoration: underline;';
1807
+						 $titleStyleBold = strpos($conf->global->SUBTOTAL_TITLE_STYLE, 'B') === false ? '' : ' font-weight:bold;';
1808
+						 $titleStyleUnderline = strpos($conf->global->SUBTOTAL_TITLE_STYLE, 'U') === false ? '' : ' text-decoration: underline;';
1809 1809
 						 
1810 1810
 						 if (empty($line->label)) {
1811 1811
 							if ($line->qty >= 91 && $line->qty <= 99 && $conf->global->SUBTOTAL_USE_NEW_FORMAT) print  $line->description.' '.$this->getTitle($object, $line);
@@ -1813,16 +1813,16 @@  discard block
 block discarded – undo
1813 1813
 						 } 
1814 1814
 						 else {
1815 1815
 
1816
-							if (! empty($conf->global->PRODUIT_DESC_IN_FORM) && !empty($line->description)) {
1816
+							if (!empty($conf->global->PRODUIT_DESC_IN_FORM) && !empty($line->description)) {
1817 1817
 								print '<span class="subtotal_label" style="'.$titleStyleItalic.$titleStyleBold.$titleStyleUnderline.'" >'.$line->label.'</span><br><div class="subtotal_desc">'.dol_htmlentitiesbr($line->description).'</div>';
1818 1818
 							}
1819
-							else{
1819
+							else {
1820 1820
 								print '<span class="subtotal_label classfortooltip '.$titleStyleItalic.$titleStyleBold.$titleStyleUnderline.'" title="'.$line->description.'">'.$line->label.'</span>';    
1821 1821
 							}
1822 1822
 
1823 1823
 						 } 
1824
-						if($line->qty>90) print ' : ';
1825
-						if($line->info_bits > 0) echo img_picto($langs->trans('Pagebreak'), 'pagebreak@subtotal');
1824
+						if ($line->qty > 90) print ' : ';
1825
+						if ($line->info_bits > 0) echo img_picto($langs->trans('Pagebreak'), 'pagebreak@subtotal');
1826 1826
 
1827 1827
 						 
1828 1828
 
@@ -1831,7 +1831,7 @@  discard block
 block discarded – undo
1831 1831
 			?></td>
1832 1832
 					 
1833 1833
 			<?php
1834
-				if($line->qty>90) {
1834
+				if ($line->qty > 90) {
1835 1835
 					/* Total */
1836 1836
 					$total_line = $this->getTotalLineFromObject($object, $line, '');
1837 1837
 					echo '<td class="nowrap liencolht" align="right" style="font-weight:bold;" rel="subtotal_total">'.price($total_line).'</td>';
@@ -1844,7 +1844,7 @@  discard block
 block discarded – undo
1844 1844
 				<?php
1845 1845
 				if ($action != 'selectlines') {
1846 1846
 				
1847
-					if($action=='editline' && GETPOST('lineid') == $line->id && TSubtotal::isModSubtotalLine($line) ) {
1847
+					if ($action == 'editline' && GETPOST('lineid') == $line->id && TSubtotal::isModSubtotalLine($line)) {
1848 1848
 						?>
1849 1849
 						<input id="savelinebutton" class="button" type="submit" name="save" value="<?php echo $langs->trans('Save') ?>" />
1850 1850
 						<br />
@@ -1860,13 +1860,13 @@  discard block
 block discarded – undo
1860 1860
 						<?php
1861 1861
 						
1862 1862
 					}
1863
-					else{
1864
-						if ($object->statut == 0  && $createRight && !empty($conf->global->SUBTOTAL_ALLOW_DUPLICATE_BLOCK))
1863
+					else {
1864
+						if ($object->statut == 0 && $createRight && !empty($conf->global->SUBTOTAL_ALLOW_DUPLICATE_BLOCK))
1865 1865
 						{
1866
-							if(TSubtotal::isTitle($line) && ($object->situation_counter == 1 || !$object->situation_cycle_ref) ) echo '<a href="'.$_SERVER['PHP_SELF'].'?'.$idvar.'='.$object->id.'&action=duplicate&lineid='.$line->id.'">'. img_picto($langs->trans('Duplicate'), 'duplicate@subtotal').'</a>';
1866
+							if (TSubtotal::isTitle($line) && ($object->situation_counter == 1 || !$object->situation_cycle_ref)) echo '<a href="'.$_SERVER['PHP_SELF'].'?'.$idvar.'='.$object->id.'&action=duplicate&lineid='.$line->id.'">'.img_picto($langs->trans('Duplicate'), 'duplicate@subtotal').'</a>';
1867 1867
 						}
1868 1868
 
1869
-						if ($object->statut == 0  && $createRight && !empty($conf->global->SUBTOTAL_ALLOW_EDIT_BLOCK)) 
1869
+						if ($object->statut == 0 && $createRight && !empty($conf->global->SUBTOTAL_ALLOW_EDIT_BLOCK)) 
1870 1870
 						{
1871 1871
 							echo '<a href="'.$_SERVER['PHP_SELF'].'?'.$idvar.'='.$object->id.'&action=editline&lineid='.$line->id.'">'.img_edit().'</a>';
1872 1872
 						}								
@@ -1881,7 +1881,7 @@  discard block
 block discarded – undo
1881 1881
 				<?php
1882 1882
 
1883 1883
 				if ($action != 'editline' && $action != 'selectlines') {
1884
-						if ($object->statut == 0  && $createRight && !empty($conf->global->SUBTOTAL_ALLOW_REMOVE_BLOCK))
1884
+						if ($object->statut == 0 && $createRight && !empty($conf->global->SUBTOTAL_ALLOW_REMOVE_BLOCK))
1885 1885
 						{
1886 1886
 
1887 1887
 							if ($object->situation_counter == 1 || !$object->situation_cycle_ref)
@@ -1889,7 +1889,7 @@  discard block
 block discarded – undo
1889 1889
 								echo '<a href="'.$_SERVER['PHP_SELF'].'?'.$idvar.'='.$object->id.'&action=ask_deleteline&lineid='.$line->id.'">'.img_delete().'</a>';
1890 1890
 							}
1891 1891
 
1892
-							if(TSubtotal::isTitle($line) && ($object->situation_counter == 1 || !$object->situation_cycle_ref) )
1892
+							if (TSubtotal::isTitle($line) && ($object->situation_counter == 1 || !$object->situation_cycle_ref))
1893 1893
 							{
1894 1894
 								$img_delete = ((float) DOL_VERSION >= 3.8) ? img_picto($langs->trans('deleteWithAllLines'), 'delete_all.3.8@subtotal') : img_picto($langs->trans('deleteWithAllLines'), 'delete_all@subtotal');
1895 1895
 								echo '<a href="'.$_SERVER['PHP_SELF'].'?'.$idvar.'='.$object->id.'&action=ask_deleteallline&lineid='.$line->id.'">'.$img_delete.'</a>';
@@ -1900,7 +1900,7 @@  discard block
 block discarded – undo
1900 1900
 			</td>
1901 1901
 			
1902 1902
 			<?php 
1903
-			if ($object->statut == 0  && $createRight && !empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && TSubtotal::isTitle($line) && $action != 'editline')
1903
+			if ($object->statut == 0 && $createRight && !empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && TSubtotal::isTitle($line) && $action != 'editline')
1904 1904
 			{
1905 1905
 				echo '<td class="subtotal_nc">';
1906 1906
 				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"' : '').' />';
@@ -1911,11 +1911,11 @@  discard block
 block discarded – undo
1911 1911
 			<td align="center" class="tdlineupdown">
1912 1912
 			</td>
1913 1913
 			<?php } else { ?>
1914
-			<td align="center"<?php echo ((empty($conf->browser->phone) && ($object->statut == 0  && $createRight ))?' class="tdlineupdown"':''); ?>></td>
1914
+			<td align="center"<?php echo ((empty($conf->browser->phone) && ($object->statut == 0 && $createRight)) ? ' class="tdlineupdown"' : ''); ?>></td>
1915 1915
 			<?php } ?>
1916 1916
 
1917
-			<?php  if($action == 'selectlines'){ // dolibarr 8 ?>
1918
-			<td class="linecolcheck" align="center"><input type="checkbox" class="linecheckbox" name="line_checkbox[<?php echo $i+1; ?>]" value="<?php echo $line->id; ?>" ></td>
1917
+			<?php  if ($action == 'selectlines') { // dolibarr 8 ?>
1918
+			<td class="linecolcheck" align="center"><input type="checkbox" class="linecheckbox" name="line_checkbox[<?php echo $i + 1; ?>]" value="<?php echo $line->id; ?>" ></td>
1919 1919
 			<?php } ?>
1920 1920
 
1921 1921
 			</tr>
@@ -1923,29 +1923,29 @@  discard block
 block discarded – undo
1923 1923
 			
1924 1924
 			
1925 1925
 			// Affichage des extrafields à la Dolibarr (car sinon non affiché sur les titres)
1926
-			if(TSubtotal::isTitle($line) && !empty($conf->global->SUBTOTAL_ALLOW_EXTRAFIELDS_ON_TITLE)) {
1926
+			if (TSubtotal::isTitle($line) && !empty($conf->global->SUBTOTAL_ALLOW_EXTRAFIELDS_ON_TITLE)) {
1927 1927
 				
1928
-				require_once DOL_DOCUMENT_ROOT . '/core/class/extrafields.class.php';
1928
+				require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
1929 1929
 				
1930 1930
 				// Extrafields
1931 1931
 				$extrafieldsline = new ExtraFields($db);
1932 1932
 				$extralabelsline = $extrafieldsline->fetch_name_optionals_label($object->table_element_line);
1933 1933
 				
1934
-				$colspan+=3; $mode = 'view';
1935
-				if($action === 'editline' && $line->rowid == GETPOST('lineid')) $mode = 'edit';
1934
+				$colspan += 3; $mode = 'view';
1935
+				if ($action === 'editline' && $line->rowid == GETPOST('lineid')) $mode = 'edit';
1936 1936
 				
1937 1937
 				$ex_element = $line->element;
1938 1938
 				$line->element = 'tr_extrafield_title '.$line->element; // Pour pouvoir manipuler ces tr
1939
-				print $line->showOptionals($extrafieldsline, $mode, array('style'=>' style="background:#eeffee;" ','colspan'=>$colspan));
1939
+				print $line->showOptionals($extrafieldsline, $mode, array('style'=>' style="background:#eeffee;" ', 'colspan'=>$colspan));
1940 1940
 				$isExtraSelected = false;
1941
-				foreach($line->array_options as $option) {
1942
-					if(!empty($option) && $option != "-1") {
1941
+				foreach ($line->array_options as $option) {
1942
+					if (!empty($option) && $option != "-1") {
1943 1943
 						$isExtraSelected = true;
1944 1944
 						break;
1945 1945
 					}
1946 1946
 				}
1947 1947
 				
1948
-				if($mode === 'edit') {
1948
+				if ($mode === 'edit') {
1949 1949
 					?>
1950 1950
 					<script>
1951 1951
 						$(document).ready(function(){
@@ -1953,7 +1953,7 @@  discard block
 block discarded – undo
1953 1953
 							var all_tr_extrafields = $("tr.tr_extrafield_title");
1954 1954
 							<?php 
1955 1955
 							// Si un extrafield est rempli alors on affiche directement les extrafields
1956
-							if(!$isExtraSelected) {
1956
+							if (!$isExtraSelected) {
1957 1957
 								echo 'all_tr_extrafields.hide();';
1958 1958
 								echo 'var trad = "'.$langs->trans('showExtrafields').'";';
1959 1959
 								echo 'var extra = 0;';
@@ -1999,7 +1999,7 @@  discard block
 block discarded – undo
1999 1999
 
2000 2000
 	
2001 2001
 	function addMoreActionsButtons($parameters, &$object, &$action, $hookmanager) {
2002
-		global $conf,$langs;
2002
+		global $conf, $langs;
2003 2003
 		 
2004 2004
 		if ($object->statut == 0 && !empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && $action != 'editline')
2005 2005
 		{
@@ -2094,23 +2094,23 @@  discard block
 block discarded – undo
2094 2094
 	    $ThtmlData['data-qty']          = 0; //$line->qty;
2095 2095
 	    $ThtmlData['data-level']        = TSubtotal::getNiveau($line);
2096 2096
 	    
2097
-	    if(TSubtotal::isTitle($line)){
2097
+	    if (TSubtotal::isTitle($line)) {
2098 2098
 	        $ThtmlData['data-issubtotal'] = 'title';
2099
-	    }elseif(TSubtotal::isSubtotal($line)){
2099
+	    }elseif (TSubtotal::isSubtotal($line)) {
2100 2100
 	        $ThtmlData['data-issubtotal'] = 'subtotal';
2101 2101
 	    }
2102
-	    else{
2102
+	    else {
2103 2103
 	        $ThtmlData['data-issubtotal'] = 'freetext';
2104 2104
 	    }
2105 2105
 	    
2106 2106
 	    
2107 2107
 	    // Change or add data  from hooks
2108
-	    $parameters = array_replace($parameters , array(  'ThtmlData' => $ThtmlData )  );
2108
+	    $parameters = array_replace($parameters, array('ThtmlData' => $ThtmlData));
2109 2109
 	    
2110 2110
 	    // hook 
2111
-	    $reshook = $hookmanager->executeHooks('subtotalLineHtmlData',$parameters,$object,$action); // Note that $action and $object may have been modified by hook
2111
+	    $reshook = $hookmanager->executeHooks('subtotalLineHtmlData', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
2112 2112
 	    if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
2113
-	    if ($reshook>0)
2113
+	    if ($reshook > 0)
2114 2114
 	    {
2115 2115
 	        $ThtmlData = $hookmanager->resArray;
2116 2116
 	    }
@@ -2123,14 +2123,14 @@  discard block
 block discarded – undo
2123 2123
 	function implodeHtmlData($ThtmlData = array())
2124 2124
 	{
2125 2125
 	    $data = '';
2126
-	    foreach($ThtmlData as $k => $h )
2126
+	    foreach ($ThtmlData as $k => $h)
2127 2127
 	    {
2128
-	        if(is_array($h))
2128
+	        if (is_array($h))
2129 2129
 	        {
2130 2130
 	            $h = json_encode($h);
2131 2131
 	        }
2132 2132
 	        
2133
-	        $data .= $k . '="'.dol_htmlentities($h, ENT_QUOTES).'" ';
2133
+	        $data .= $k.'="'.dol_htmlentities($h, ENT_QUOTES).'" ';
2134 2134
 	    }
2135 2135
 	    
2136 2136
 	    return $data;
@@ -2138,26 +2138,26 @@  discard block
 block discarded – undo
2138 2138
 	
2139 2139
 	function _ajax_block_order_js($object)
2140 2140
 	{
2141
-	    global $conf,$tagidfortablednd,$filepath,$langs;
2141
+	    global $conf, $tagidfortablednd, $filepath, $langs;
2142 2142
 	    
2143 2143
 	    /*
2144 2144
 	     * this part of js is base on dolibarr htdocs/core/tpl/ajaxrow.tpl.php 
2145 2145
 	     * for compatibility reasons we don't use tableDnD but jquery sortable
2146 2146
 	     */
2147 2147
 	    
2148
-	    $id=$object->id;
2149
-	    $nboflines=(isset($object->lines)?count($object->lines):0);
2150
-	    $forcereloadpage=empty($conf->global->MAIN_FORCE_RELOAD_PAGE)?0:1;
2148
+	    $id = $object->id;
2149
+	    $nboflines = (isset($object->lines) ?count($object->lines) : 0);
2150
+	    $forcereloadpage = empty($conf->global->MAIN_FORCE_RELOAD_PAGE) ? 0 : 1;
2151 2151
 	    
2152
-	    $id=$object->id;
2153
-	    $fk_element=$object->fk_element;
2154
-	    $table_element_line=$object->table_element_line;
2155
-	    $nboflines=(isset($object->lines)?count($object->lines):(empty($nboflines)?0:$nboflines));
2156
-	    $tagidfortablednd=(empty($tagidfortablednd)?'tablelines':$tagidfortablednd);
2157
-	    $filepath=(empty($filepath)?'':$filepath);
2152
+	    $id = $object->id;
2153
+	    $fk_element = $object->fk_element;
2154
+	    $table_element_line = $object->table_element_line;
2155
+	    $nboflines = (isset($object->lines) ?count($object->lines) : (empty($nboflines) ? 0 : $nboflines));
2156
+	    $tagidfortablednd = (empty($tagidfortablednd) ? 'tablelines' : $tagidfortablednd);
2157
+	    $filepath = (empty($filepath) ? '' : $filepath);
2158 2158
 	    
2159 2159
 	    
2160
-	    if (GETPOST('action','aZ09') != 'editline' && $nboflines > 1)
2160
+	    if (GETPOST('action', 'aZ09') != 'editline' && $nboflines > 1)
2161 2161
 	    {
2162 2162
 	        
2163 2163
 	        ?>
@@ -2175,7 +2175,7 @@  discard block
 block discarded – undo
2175 2175
 				moveBlockCol.disableSelection(); // prevent selection
2176 2176
 
2177 2177
 				// apply some graphical stuff
2178
-				moveBlockCol.css("background-image",'url(<?php echo dol_buildpath('subtotal/img/grip_all.png',2);  ?>)');
2178
+				moveBlockCol.css("background-image",'url(<?php echo dol_buildpath('subtotal/img/grip_all.png', 2); ?>)');
2179 2179
 				moveBlockCol.css("background-repeat","no-repeat");
2180 2180
 				moveBlockCol.css("background-position","center center");
2181 2181
 				moveBlockCol.css("cursor","move");
Please login to merge, or discard this patch.
Braces   +331 added lines, -198 removed lines patch added patch discarded remove patch
@@ -69,8 +69,11 @@  discard block
 block discarded – undo
69 69
 			if ($object->statut == 0  && $createRight) {
70 70
 			
71 71
 
72
-				if($object->element=='facture')$idvar = 'facid';
73
-				else $idvar='id';
72
+				if($object->element=='facture') {
73
+					$idvar = 'facid';
74
+				} else {
75
+					$idvar='id';
76
+				}
74 77
 				
75 78
 				if(in_array($action, array('add_title_line', 'add_total_line', 'add_subtitle_line', 'add_subtotal_line', 'add_free_text')) )
76 79
 				{
@@ -78,10 +81,11 @@  discard block
 block discarded – undo
78 81
 					
79 82
 					if($action=='add_title_line') {
80 83
 						$title = GETPOST('title');
81
-						if(empty($title)) $title = $langs->trans('title');
84
+						if(empty($title)) {
85
+							$title = $langs->trans('title');
86
+						}
82 87
 						$qty = $level<1 ? 1 : $level ;
83
-					}
84
-					else if($action=='add_free_text') {
88
+					} else if($action=='add_free_text') {
85 89
 						$title = GETPOST('title');
86 90
 
87 91
 						if (empty($title)) {
@@ -93,29 +97,31 @@  discard block
 block discarded – undo
93 97
 								}
94 98
 							}
95 99
 						}
96
-						if(empty($title)) $title = $langs->trans('subtotalAddLineDescription');
100
+						if(empty($title)) {
101
+							$title = $langs->trans('subtotalAddLineDescription');
102
+						}
97 103
 						$qty = 50;
98
-					}
99
-					else if($action=='add_subtitle_line') {
104
+					} else if($action=='add_subtitle_line') {
100 105
 						$title = GETPOST('title');
101
-						if(empty($title)) $title = $langs->trans('subtitle');
106
+						if(empty($title)) {
107
+							$title = $langs->trans('subtitle');
108
+						}
102 109
 						$qty = 2;
103
-					}
104
-					else if($action=='add_subtotal_line') {
110
+					} else if($action=='add_subtotal_line') {
105 111
 						$title = $langs->trans('SubSubTotal');
106 112
 						$qty = 98;
107
-					}
108
-					else {
113
+					} else {
109 114
 						$title = GETPOST('title') ? GETPOST('title') : $langs->trans('SubTotal');
110 115
 						$qty = $level ? 100-$level : 99;
111 116
 					}
112 117
 					dol_include_once('/subtotal/class/subtotal.class.php');
113 118
 					
114
-					if (!empty($conf->global->SUBTOTAL_AUTO_ADD_SUBTOTAL_ON_ADDING_NEW_TITLE) && $qty < 10) TSubtotal::addSubtotalMissing($object, $qty);
119
+					if (!empty($conf->global->SUBTOTAL_AUTO_ADD_SUBTOTAL_ON_ADDING_NEW_TITLE) && $qty < 10) {
120
+						TSubtotal::addSubtotalMissing($object, $qty);
121
+					}
115 122
 					
116 123
 	    			TSubtotal::addSubTotalLine($object, $title, $qty);
117
-				}
118
-				else if($action==='ask_deleteallline') {
124
+				} else if($action==='ask_deleteallline') {
119 125
 						$form=new Form($db);
120 126
 						
121 127
 						$lineid = GETPOST('lineid','integer');
@@ -138,8 +144,7 @@  discard block
 block discarded – undo
138 144
 					$this->printNewFormat($object, $conf, $langs, $idvar);
139 145
 				}
140 146
 			}
141
-		}
142
-		elseif ((!empty($parameters['currentcontext']) && $parameters['currentcontext'] == 'orderstoinvoice') || in_array('orderstoinvoice',$contexts))
147
+		} elseif ((!empty($parameters['currentcontext']) && $parameters['currentcontext'] == 'orderstoinvoice') || in_array('orderstoinvoice',$contexts))
143 148
 		{
144 149
 			?>
145 150
 			<script type="text/javascript">
@@ -157,8 +162,13 @@  discard block
 block discarded – undo
157 162
      
158 163
 	function printNewFormat(&$object, &$conf, &$langs, $idvar)
159 164
 	{
160
-		if (empty($conf->global->SUBTOTAL_ALLOW_ADD_BLOCK)) return false;
161
-		if (!empty($object->situation_cycle_ref) && $object->situation_counter > 1) return false; // Si facture de situation
165
+		if (empty($conf->global->SUBTOTAL_ALLOW_ADD_BLOCK)) {
166
+			return false;
167
+		}
168
+		if (!empty($object->situation_cycle_ref) && $object->situation_counter > 1) {
169
+			return false;
170
+		}
171
+		// Si facture de situation
162 172
 		?>
163 173
 		 	<script type="text/javascript">
164 174
 				$(document).ready(function() {
@@ -439,8 +449,7 @@  discard block
 block discarded – undo
439 449
 				}
440 450
 				
441 451
 				
442
-			}	
443
-			else{
452
+			} else{
444 453
 				$substitutionarray['line_not_modsubtotal'] = true;
445 454
 				$substitutionarray['line_modsubtotal'] = 0;
446 455
 			}
@@ -495,8 +504,11 @@  discard block
 block discarded – undo
495 504
 		
496 505
 		$showBlockExtrafields = GETPOST('showBlockExtrafields');
497 506
 		
498
-		if($object->element=='facture') $idvar = 'facid';
499
-		else $idvar = 'id';
507
+		if($object->element=='facture') {
508
+			$idvar = 'facid';
509
+		} else {
510
+			$idvar = 'id';
511
+		}
500 512
 			
501 513
 		if ($action == 'updateligne' || $action == 'updateline')
502 514
 		{
@@ -526,8 +538,7 @@  discard block
 block discarded – undo
526 538
 				header('Location: '.$_SERVER['PHP_SELF'].'?'.$idvar.'='.$object->id);
527 539
 				exit; // Surtout ne pas laisser Dolibarr faire du traitement sur le updateligne sinon ça plante les données de la ligne
528 540
 			}
529
-		}
530
-		else if($action === 'builddoc') {
541
+		} else if($action === 'builddoc') {
531 542
 			
532 543
 			if (
533 544
 				in_array('invoicecard',explode(':',$parameters['context']))
@@ -539,18 +550,15 @@  discard block
 block discarded – undo
539 550
 					$sessname = 'subtotal_hideInnerLines_facture';	
540 551
 					$sessname2 = 'subtotal_hidedetails_facture';
541 552
 					$sessname3 = 'subtotal_hideprices_facture';
542
-				}
543
-				elseif(in_array('propalcard',explode(':',$parameters['context']))) {
553
+				} elseif(in_array('propalcard',explode(':',$parameters['context']))) {
544 554
 					$sessname = 'subtotal_hideInnerLines_propal';
545 555
 					$sessname2 = 'subtotal_hidedetails_propal';	
546 556
 					$sessname3 = 'subtotal_hideprices_propal';
547
-				}
548
-				elseif(in_array('ordercard',explode(':',$parameters['context']))) {
557
+				} elseif(in_array('ordercard',explode(':',$parameters['context']))) {
549 558
 					$sessname = 'subtotal_hideInnerLines_commande';
550 559
 					$sessname2 = 'subtotal_hidedetails_commande';	
551 560
 					$sessname3 = 'subtotal_hideprices_commande';
552
-				}
553
-				else {
561
+				} else {
554 562
 					$sessname = 'subtotal_hideInnerLines_unknown';
555 563
 					$sessname2 = 'subtotal_hidedetails_unknown';
556 564
 					$sessname3 = 'subtotal_hideprices_unknown';
@@ -572,8 +580,7 @@  discard block
 block discarded – undo
572 580
 					    
573 581
                         if($line->qty>=90) {
574 582
                             $line->modsubtotal_total = 1;
575
-                        }
576
-                        else{
583
+                        } else{
577 584
                             $line->modsubtotal_title = 1;
578 585
                         }
579 586
                         
@@ -582,8 +589,7 @@  discard block
 block discarded – undo
582 589
 	        	}
583 590
 	        }
584 591
 			
585
-		}
586
-		else if($action === 'confirm_delete_all_lines' && GETPOST('confirm')=='yes') {
592
+		} else if($action === 'confirm_delete_all_lines' && GETPOST('confirm')=='yes') {
587 593
 			
588 594
 			$Tab = $this->getArrayOfLineForAGroup($object, GETPOST('lineid'));
589 595
 			
@@ -591,37 +597,49 @@  discard block
 block discarded – undo
591 597
 				/**
592 598
 				 * @var $object Facture
593 599
 				 */
594
-				if($object->element=='facture') $object->deleteline($idLine);
600
+				if($object->element=='facture') {
601
+					$object->deleteline($idLine);
602
+				}
595 603
 				/**
596 604
 				 * @var $object Propal
597 605
 				 */
598
-				else if($object->element=='propal') $object->deleteline($idLine);
606
+				else if($object->element=='propal') {
607
+					$object->deleteline($idLine);
608
+				}
599 609
 				/**
600 610
 				 * @var $object Commande
601 611
 				 */
602 612
 				else if($object->element=='commande') 
603 613
 				{
604
-					if ((float) DOL_VERSION >= 5.0) $object->deleteline($user, $idLine);
605
-					else $object->deleteline($idLine);
614
+					if ((float) DOL_VERSION >= 5.0) {
615
+						$object->deleteline($user, $idLine);
616
+					} else {
617
+						$object->deleteline($idLine);
618
+					}
606 619
 				}
607 620
 				/**
608 621
 				 * @var $object Facturerec
609 622
 				 */
610
-				else if($object->element=='facturerec') $object->deleteline($idLine);
623
+				else if($object->element=='facturerec') {
624
+					$object->deleteline($idLine);
625
+				}
611 626
 			}
612 627
 			
613 628
 			header('location:?id='.$object->id);
614 629
 			exit;
615 630
 			
616
-		}
617
-		else if ($action == 'duplicate')
631
+		} else if ($action == 'duplicate')
618 632
 		{
619 633
 			$lineid = GETPOST('lineid', 'int');
620 634
 			$nbDuplicate = TSubtotal::duplicateLines($object, $lineid, true);
621 635
 			
622
-			if ($nbDuplicate > 0) setEventMessage($langs->trans('subtotal_duplicate_success', $nbDuplicate));
623
-			elseif ($nbDuplicate == 0) setEventMessage($langs->trans('subtotal_duplicate_lineid_not_found'), 'warnings');
624
-			else setEventMessage($langs->trans('subtotal_duplicate_error'), 'errors');
636
+			if ($nbDuplicate > 0) {
637
+				setEventMessage($langs->trans('subtotal_duplicate_success', $nbDuplicate));
638
+			} elseif ($nbDuplicate == 0) {
639
+				setEventMessage($langs->trans('subtotal_duplicate_lineid_not_found'), 'warnings');
640
+			} else {
641
+				setEventMessage($langs->trans('subtotal_duplicate_error'), 'errors');
642
+			}
625 643
 			
626 644
 			header('Location: ?id='.$object->id);
627 645
 			exit;
@@ -699,17 +717,18 @@  discard block
 block discarded – undo
699 717
 			//print $l->rang.'>='.$rang.' '.$total.'<br/>';
700 718
 			if($l->rang>=$rang) {
701 719
 				//echo 'return!<br>';
702
-				if (!$return_all) return $total;
703
-				else return array($total, $total_tva, $total_ttc, $TTotal_tva);
704
-			}
705
-			else if(TSubtotal::isTitle($l, 100 - $qty_line)) 
720
+				if (!$return_all) {
721
+					return $total;
722
+				} else {
723
+					return array($total, $total_tva, $total_ttc, $TTotal_tva);
724
+				}
725
+			} else if(TSubtotal::isTitle($l, 100 - $qty_line)) 
706 726
 		  	{
707 727
 				$total = 0;
708 728
 				$total_tva = 0;
709 729
 				$total_ttc = 0;
710 730
 				$TTotal_tva = array();
711
-			}
712
-			elseif(!TSubtotal::isTitle($l) && !TSubtotal::isSubtotal($l)) {
731
+			} elseif(!TSubtotal::isTitle($l) && !TSubtotal::isSubtotal($l)) {
713 732
 				$total += $l->total_ht;
714 733
 				$total_tva += $l->total_tva;
715 734
 				$TTotal_tva[$l->tva_tx] += $l->total_tva;
@@ -717,8 +736,11 @@  discard block
 block discarded – undo
717 736
 			}
718 737
 			
719 738
 		}
720
-		if (!$return_all) return $total;
721
-		else return array($total, $total_tva, $total_ttc, $TTotal_tva);
739
+		if (!$return_all) {
740
+			return $total;
741
+		} else {
742
+			return array($total, $total_tva, $total_ttc, $TTotal_tva);
743
+		}
722 744
 	}
723 745
 
724 746
 	/*
@@ -786,15 +808,18 @@  discard block
 block discarded – undo
786 808
 		}
787 809
 		
788 810
 			
789
-		if($line->qty==99)
790
-			$pdf->SetFillColor(220,220,220);
791
-		elseif ($line->qty==98)
792
-			$pdf->SetFillColor(230,230,230);
793
-		else
794
-			$pdf->SetFillColor(240,240,240);
811
+		if($line->qty==99) {
812
+					$pdf->SetFillColor(220,220,220);
813
+		} elseif ($line->qty==98) {
814
+					$pdf->SetFillColor(230,230,230);
815
+		} else {
816
+					$pdf->SetFillColor(240,240,240);
817
+		}
795 818
 		
796 819
 		$style = 'B';
797
-		if (!empty($conf->global->SUBTOTAL_SUBTOTAL_STYLE)) $style = $conf->global->SUBTOTAL_SUBTOTAL_STYLE;
820
+		if (!empty($conf->global->SUBTOTAL_SUBTOTAL_STYLE)) {
821
+			$style = $conf->global->SUBTOTAL_SUBTOTAL_STYLE;
822
+		}
798 823
 		
799 824
 		$pdf->SetFont('', $style, 9);
800 825
 		
@@ -833,8 +858,7 @@  discard block
 block discarded – undo
833 858
 //					$line->total_tva
834 859
 //					$line->total
835 860
 //					$line->total_ttc
836
-				}
837
-				else
861
+				} else
838 862
 				{
839 863
 					list($total, $total_tva, $total_ttc, $TTotal_tva) = $this->getTotalLineFromObject($object, $line, '', 1);
840 864
                                         if(get_class($object) == 'Facture' && $object->type==Facture::TYPE_SITUATION){//Facture de situation
@@ -851,11 +875,14 @@  discard block
 block discarded – undo
851 875
 			}
852 876
 
853 877
 			$pdf->SetXY($pdf->postotalht, $posy);
854
-			if($set_pagebreak_margin) $pdf->SetAutoPageBreak( $pageBreakOriginalValue , $bMargin);
878
+			if($set_pagebreak_margin) {
879
+				$pdf->SetAutoPageBreak( $pageBreakOriginalValue , $bMargin);
880
+			}
855 881
 			$pdf->MultiCell($pdf->page_largeur-$pdf->marge_droite-$pdf->postotalht, 3, $total_to_print, 0, 'R', 0);
856
-		}
857
-		else{
858
-			if($set_pagebreak_margin) $pdf->SetAutoPageBreak( $pageBreakOriginalValue , $bMargin);
882
+		} else{
883
+			if($set_pagebreak_margin) {
884
+				$pdf->SetAutoPageBreak( $pageBreakOriginalValue , $bMargin);
885
+			}
859 886
 		}
860 887
 		
861 888
 		$posy = $posy + $cell_height;
@@ -887,25 +914,40 @@  discard block
 block discarded – undo
887 914
 		
888 915
  
889 916
 		$style = ($line->qty==1) ? 'BU' : 'BUI';
890
-		if (!empty($conf->global->SUBTOTAL_TITLE_STYLE)) $style = $conf->global->SUBTOTAL_TITLE_STYLE;
917
+		if (!empty($conf->global->SUBTOTAL_TITLE_STYLE)) {
918
+			$style = $conf->global->SUBTOTAL_TITLE_STYLE;
919
+		}
891 920
 		
892 921
 		if($hideInnerLines) {
893
-			if($line->qty==1)$pdf->SetFont('', $style, 9);
894
-			else 
922
+			if($line->qty==1) {
923
+				$pdf->SetFont('', $style, 9);
924
+			} else 
895 925
 			{
896
-				if (!empty($conf->global->SUBTOTAL_STYLE_TITRES_SI_LIGNES_CACHEES)) $style = $conf->global->SUBTOTAL_STYLE_TITRES_SI_LIGNES_CACHEES;
926
+				if (!empty($conf->global->SUBTOTAL_STYLE_TITRES_SI_LIGNES_CACHEES)) {
927
+					$style = $conf->global->SUBTOTAL_STYLE_TITRES_SI_LIGNES_CACHEES;
928
+				}
897 929
 				$pdf->SetFont('', $style, 9);
898 930
 			}
899
-		}
900
-		else {
931
+		} else {
901 932
 
902
-			if($line->qty==1)$pdf->SetFont('', $style, 9); //TODO if super utile
903
-			else $pdf->SetFont('', $style, 9);
933
+			if($line->qty==1) {
934
+				$pdf->SetFont('', $style, 9);
935
+			}
936
+			//TODO if super utile
937
+			else {
938
+				$pdf->SetFont('', $style, 9);
939
+			}
904 940
 			
905 941
 		}
906 942
 		
907
-		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
908
-		else $pdf->writeHTMLCell($w, $h, $posx, $posy, $label, 0, 1, false, true, 'J',true); // et maintenant avec du HTML
943
+		if ($label === strip_tags($label) && $label === dol_html_entity_decode($label, ENT_QUOTES)) {
944
+			$pdf->MultiCell($w, $h, $label, 0, 'L');
945
+		}
946
+		// Pas de HTML dans la chaine
947
+		else {
948
+			$pdf->writeHTMLCell($w, $h, $posx, $posy, $label, 0, 1, false, true, 'J',true);
949
+		}
950
+		// et maintenant avec du HTML
909 951
 		
910 952
 		if($description && !$hidedesc) {
911 953
 			$posy = $pdf->GetY();
@@ -929,8 +971,7 @@  discard block
 block discarded – undo
929 971
 		
930 972
 		if(is_array($parameters)) {
931 973
 			$i = & $parameters['i'];	
932
-		}
933
-		else {
974
+		} else {
934 975
 			$i = (int)$parameters;
935 976
 		}
936 977
 		
@@ -952,17 +993,14 @@  discard block
 block discarded – undo
952 993
 			
953 994
 			if((float)DOL_VERSION<=3.6) {
954 995
 				return '';
955
-			}
956
-			else if((float)DOL_VERSION>=3.8) {
996
+			} else if((float)DOL_VERSION>=3.8) {
957 997
 				return 1;
958 998
 			}
959 999
 			
960
-		}
961
-		elseif(!empty($hideprices)) {
1000
+		} elseif(!empty($hideprices)) {
962 1001
 			$this->resprints = $object->lines[$parameters['i']]->qty;
963 1002
 			return 1;
964
-		}
965
-		elseif (!empty($conf->global->SUBTOTAL_IF_HIDE_PRICES_SHOW_QTY))
1003
+		} elseif (!empty($conf->global->SUBTOTAL_IF_HIDE_PRICES_SHOW_QTY))
966 1004
 		{
967 1005
 			$hideInnerLines = (int)GETPOST('hideInnerLines');
968 1006
 			$hidedetails = (int)GETPOST('hidedetails');
@@ -972,10 +1010,16 @@  discard block
 block discarded – undo
972 1010
 			}
973 1011
 		}
974 1012
 		
975
-		if(is_array($parameters)) $i = & $parameters['i'];
976
-		else $i = (int)$parameters;
1013
+		if(is_array($parameters)) {
1014
+			$i = & $parameters['i'];
1015
+		} else {
1016
+			$i = (int)$parameters;
1017
+		}
977 1018
 
978
-		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)
1019
+		if (empty($object->lines[$i])) {
1020
+			return 0;
1021
+		}
1022
+		// 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)
979 1023
 		
980 1024
 		$object->lines[$i]->fetch_optionals();
981 1025
 		if (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])) )
@@ -999,16 +1043,17 @@  discard block
 block discarded – undo
999 1043
 			
1000 1044
 			if((float)DOL_VERSION<=3.6) {
1001 1045
 				return '';
1002
-			}
1003
-			else if((float)DOL_VERSION>=3.8) {
1046
+			} else if((float)DOL_VERSION>=3.8) {
1004 1047
 				return 1;
1005 1048
 			}
1006 1049
 			
1007
-		}
1008
-		elseif (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS))
1050
+		} elseif (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS))
1009 1051
 		{
1010
-			if(is_array($parameters)) $i = & $parameters['i'];
1011
-			else $i = (int)$parameters;
1052
+			if(is_array($parameters)) {
1053
+				$i = & $parameters['i'];
1054
+			} else {
1055
+				$i = (int)$parameters;
1056
+			}
1012 1057
 			
1013 1058
 			if (!in_array(__FUNCTION__, explode(',', $conf->global->SUBTOTAL_TFIELD_TO_KEEP_WITH_NC)))
1014 1059
 			{
@@ -1030,8 +1075,11 @@  discard block
 block discarded – undo
1030 1075
 			}
1031 1076
 		}
1032 1077
 		if ((int)GETPOST('hideInnerLines') && !empty($conf->global->SUBTOTAL_REPLACE_WITH_VAT_IF_HIDE_INNERLINES)){
1033
-		    if(is_array($parameters)) $i = & $parameters['i'];
1034
-		    else $i = (int)$parameters;
1078
+		    if(is_array($parameters)) {
1079
+		    	$i = & $parameters['i'];
1080
+		    } else {
1081
+		    	$i = (int)$parameters;
1082
+		    }
1035 1083
 		    $this->resprints = price($object->lines[$i]->total_ht);
1036 1084
 		}
1037 1085
 		if (!empty($hideprices)
@@ -1057,14 +1105,16 @@  discard block
 block discarded – undo
1057 1105
 		
1058 1106
 			if((float)DOL_VERSION<=3.6) {
1059 1107
 				return '';
1060
-			}
1061
-			else if((float)DOL_VERSION>=3.8) {
1108
+			} else if((float)DOL_VERSION>=3.8) {
1062 1109
 				return 1;
1063 1110
 			}
1064 1111
 		}
1065 1112
 		
1066
-		if(is_array($parameters)) $i = & $parameters['i'];
1067
-		else $i = (int)$parameters;
1113
+		if(is_array($parameters)) {
1114
+			$i = & $parameters['i'];
1115
+		} else {
1116
+			$i = (int)$parameters;
1117
+		}
1068 1118
 		
1069 1119
 		if (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])) ) 
1070 1120
 		{
@@ -1086,14 +1136,16 @@  discard block
 block discarded – undo
1086 1136
 		
1087 1137
 			if((float)DOL_VERSION<=3.6) {
1088 1138
 				return '';
1089
-			}
1090
-			else if((float)DOL_VERSION>=3.8) {
1139
+			} else if((float)DOL_VERSION>=3.8) {
1091 1140
 				return 1;
1092 1141
 			}
1093 1142
 		}
1094 1143
 		
1095
-		if(is_array($parameters)) $i = & $parameters['i'];
1096
-		else $i = (int)$parameters;
1144
+		if(is_array($parameters)) {
1145
+			$i = & $parameters['i'];
1146
+		} else {
1147
+			$i = (int)$parameters;
1148
+		}
1097 1149
 			
1098 1150
 		if (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])) )
1099 1151
 		{
@@ -1115,13 +1167,15 @@  discard block
 block discarded – undo
1115 1167
 		
1116 1168
 			if((float)DOL_VERSION<=3.6) {
1117 1169
 				return '';
1118
-			}
1119
-			else if((float)DOL_VERSION>=3.8) {
1170
+			} else if((float)DOL_VERSION>=3.8) {
1120 1171
 				return 1;
1121 1172
 			}
1122 1173
 		}
1123
-		if(is_array($parameters)) $i = & $parameters['i'];
1124
-		else $i = (int)$parameters;
1174
+		if(is_array($parameters)) {
1175
+			$i = & $parameters['i'];
1176
+		} else {
1177
+			$i = (int)$parameters;
1178
+		}
1125 1179
 		
1126 1180
 		if (!empty($hideprices) 
1127 1181
 				|| (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])) )
@@ -1144,14 +1198,16 @@  discard block
 block discarded – undo
1144 1198
 			$this->resprints = ' ';
1145 1199
 			if((float)DOL_VERSION<=3.6) {
1146 1200
 				return '';
1147
-			}
1148
-			else if((float)DOL_VERSION>=3.8) {
1201
+			} else if((float)DOL_VERSION>=3.8) {
1149 1202
 				return 1;
1150 1203
 			}
1151 1204
 		}
1152 1205
 		
1153
-		if(is_array($parameters)) $i = & $parameters['i'];
1154
-		else $i = (int)$parameters;
1206
+		if(is_array($parameters)) {
1207
+			$i = & $parameters['i'];
1208
+		} else {
1209
+			$i = (int)$parameters;
1210
+		}
1155 1211
 			
1156 1212
 		if (!empty($hideprices)
1157 1213
 				|| (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])) )
@@ -1175,16 +1231,21 @@  discard block
 block discarded – undo
1175 1231
 			
1176 1232
 			if((float)DOL_VERSION<=3.6) {
1177 1233
 				return '';
1178
-			}
1179
-			else if((float)DOL_VERSION>=3.8) {
1234
+			} else if((float)DOL_VERSION>=3.8) {
1180 1235
 				return 1;
1181 1236
 			}
1182 1237
 		}
1183 1238
 		
1184
-		if(is_array($parameters)) $i = & $parameters['i'];
1185
-		else $i = (int)$parameters;
1239
+		if(is_array($parameters)) {
1240
+			$i = & $parameters['i'];
1241
+		} else {
1242
+			$i = (int)$parameters;
1243
+		}
1186 1244
 		
1187
-		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)
1245
+		if (empty($object->lines[$i])) {
1246
+			return 0;
1247
+		}
1248
+		// 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)
1188 1249
 
1189 1250
 		$object->lines[$i]->fetch_optionals();
1190 1251
 		if (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])) )
@@ -1206,14 +1267,16 @@  discard block
 block discarded – undo
1206 1267
 			$this->resprints = ' ';
1207 1268
 			if((float)DOL_VERSION<=3.6) {
1208 1269
 				return '';
1209
-			}
1210
-			else if((float)DOL_VERSION>=3.8) {
1270
+			} else if((float)DOL_VERSION>=3.8) {
1211 1271
 				return 1;
1212 1272
 			}
1213 1273
 		}
1214 1274
 		
1215
-		if(is_array($parameters)) $i = & $parameters['i'];
1216
-		else $i = (int)$parameters;
1275
+		if(is_array($parameters)) {
1276
+			$i = & $parameters['i'];
1277
+		} else {
1278
+			$i = (int)$parameters;
1279
+		}
1217 1280
 			
1218 1281
 		if (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])) )
1219 1282
 		{
@@ -1243,7 +1306,9 @@  discard block
 block discarded – undo
1243 1306
 				}
1244 1307
 			}
1245 1308
 			
1246
-			if (!empty($TLineTitle)) $TTitleNumeroted = $this->formatNumerotation($TLineTitle);
1309
+			if (!empty($TLineTitle)) {
1310
+				$TTitleNumeroted = $this->formatNumerotation($TLineTitle);
1311
+			}
1247 1312
 		}
1248 1313
 		
1249 1314
 	}
@@ -1257,8 +1322,12 @@  discard block
 block discarded – undo
1257 1322
 		$j=0;
1258 1323
 		foreach ($TLineTitle as $k => &$line)
1259 1324
 		{
1260
-			if (!empty($line_reference) && $line->rang <= $line_reference->rang) continue;
1261
-			if (!empty($line_reference) && $line->qty <= $line_reference->qty) break;
1325
+			if (!empty($line_reference) && $line->rang <= $line_reference->rang) {
1326
+				continue;
1327
+			}
1328
+			if (!empty($line_reference) && $line->qty <= $line_reference->qty) {
1329
+				break;
1330
+			}
1262 1331
 			
1263 1332
 			if ($line->qty == $level)
1264 1333
 			{
@@ -1292,7 +1361,9 @@  discard block
 block discarded – undo
1292 1361
 		
1293 1362
 		$hidedetails = (int)GETPOST('hidedetails');
1294 1363
 		
1295
-		if(empty($hidedetails)) return false;
1364
+		if(empty($hidedetails)) {
1365
+			return false;
1366
+		}
1296 1367
 		
1297 1368
 		// TODO can't add VAT to document without lines... :-/
1298 1369
 		
@@ -1345,7 +1416,9 @@  discard block
 block discarded – undo
1345 1416
 						*/
1346 1417
 						list($total, $total_tva, $total_ttc, $TTotal_tva) = $this->getTotalLineFromObject($object, $line, '', 1);
1347 1418
 						
1348
-						if (TSubtotal::getNiveau($line) == 1) $line->TTotal_tva = $TTotal_tva;
1419
+						if (TSubtotal::getNiveau($line) == 1) {
1420
+							$line->TTotal_tva = $TTotal_tva;
1421
+						}
1349 1422
 						$line->total_ht = $total;
1350 1423
 						$line->total_tva = $total_tva;
1351 1424
 						$line->total = $line->total_ht;
@@ -1400,8 +1473,7 @@  discard block
 block discarded – undo
1400 1473
 				    }
1401 1474
 				    
1402 1475
 					
1403
-				}
1404
-				elseif ($hidedetails)
1476
+				} elseif ($hidedetails)
1405 1477
 				{
1406 1478
 					$TLines[] = $line; //Cas où je cache uniquement les prix des produits	
1407 1479
 				}
@@ -1472,7 +1544,9 @@  discard block
 block discarded – undo
1472 1544
 				
1473 1545
 				if(!empty($hideprices)) {
1474 1546
 					foreach($object->lines as &$line) {
1475
-						if($line->fk_product_type!=9) $line->fk_parent_line = -1;	
1547
+						if($line->fk_product_type!=9) {
1548
+							$line->fk_parent_line = -1;
1549
+						}
1476 1550
 					}
1477 1551
 				}
1478 1552
 			
@@ -1493,7 +1567,9 @@  discard block
 block discarded – undo
1493 1567
 				
1494 1568
 				if($line->qty>90) {
1495 1569
 					
1496
-					if ($conf->global->SUBTOTAL_USE_NEW_FORMAT)	$label .= ' '.$this->getTitle($object, $line);
1570
+					if ($conf->global->SUBTOTAL_USE_NEW_FORMAT) {
1571
+						$label .= ' '.$this->getTitle($object, $line);
1572
+					}
1497 1573
 					
1498 1574
 					$pageBefore = $pdf->getPage();
1499 1575
 					$this->pdf_add_total($pdf,$object, $line, $label, $description,$posx, $posy, $w, $h);
@@ -1511,8 +1587,7 @@  discard block
 block discarded – undo
1511 1587
 				
1512 1588
 					$posy = $pdf->GetY();
1513 1589
 					return 1;
1514
-				}	
1515
-				else if ($line->qty < 10) {
1590
+				} else if ($line->qty < 10) {
1516 1591
 					$pageBefore = $pdf->getPage();
1517 1592
 
1518 1593
 					$this->pdf_add_title($pdf,$object, $line, $label, $description,$posx, $posy, $w, $h); 
@@ -1536,8 +1611,7 @@  discard block
 block discarded – undo
1536 1611
 //	if($line->rowid==47) exit;
1537 1612
 			
1538 1613
 			return 0;
1539
-		}
1540
-		elseif (empty($object->lines[$parameters['i']]))
1614
+		} elseif (empty($object->lines[$parameters['i']]))
1541 1615
 		{
1542 1616
 			$this->resprints = -1;
1543 1617
 		}
@@ -1570,7 +1644,9 @@  discard block
 block discarded – undo
1570 1644
 		
1571 1645
 		foreach ($object->lines as $line)
1572 1646
 		{
1573
-			if ($line->id == $currentLine->id) break;
1647
+			if ($line->id == $currentLine->id) {
1648
+				break;
1649
+			}
1574 1650
 			
1575 1651
 			$qty_search = 100 - $currentLine->qty;
1576 1652
 			
@@ -1611,11 +1687,13 @@  discard block
 block discarded – undo
1611 1687
 		
1612 1688
 		if($line->special_code!=$this->module_number || $line->product_type!=9) {
1613 1689
 			null;
1614
-		}	
1615
-		else if (in_array('invoicecard',$contexts) || in_array('propalcard',$contexts) || in_array('ordercard',$contexts) || in_array('invoicereccard',$contexts)) 
1690
+		} else if (in_array('invoicecard',$contexts) || in_array('propalcard',$contexts) || in_array('ordercard',$contexts) || in_array('invoicereccard',$contexts)) 
1616 1691
         {
1617
-			if($object->element=='facture')$idvar = 'facid';
1618
-			else $idvar='id';
1692
+			if($object->element=='facture') {
1693
+				$idvar = 'facid';
1694
+			} else {
1695
+				$idvar='id';
1696
+			}
1619 1697
 			
1620 1698
 			if((float)DOL_VERSION <= 3.4)
1621 1699
 			{
@@ -1641,18 +1719,36 @@  discard block
 block discarded – undo
1641 1719
 				<?php
1642 1720
 			}
1643 1721
 			
1644
-			if(empty($line->description)) $line->description = $line->desc;
1722
+			if(empty($line->description)) {
1723
+				$line->description = $line->desc;
1724
+			}
1645 1725
 			
1646 1726
 			$colspan = 5;
1647
-			if($object->element == 'facturerec' ) $colspan = 3;
1648
-
1649
-			if(!empty($conf->multicurrency->enabled)) $colspan+=2;
1650
-			if($object->element == 'commande' && $object->statut < 3 && !empty($conf->shippableorder->enabled)) $colspan++;
1651
-			if(!empty($conf->margin->enabled)) $colspan++;
1652
-			if(!empty($conf->global->DISPLAY_MARGIN_RATES)) $colspan++;
1653
-			if(!empty($conf->global->DISPLAY_MARK_RATES)) $colspan++;
1654
-			if($object->element == 'facture' && !empty($conf->global->INVOICE_USE_SITUATION) && $object->type == Facture::TYPE_SITUATION) $colspan++;
1655
-			if(!empty($conf->global->PRODUCT_USE_UNITS)) $colspan++;
1727
+			if($object->element == 'facturerec' ) {
1728
+				$colspan = 3;
1729
+			}
1730
+
1731
+			if(!empty($conf->multicurrency->enabled)) {
1732
+				$colspan+=2;
1733
+			}
1734
+			if($object->element == 'commande' && $object->statut < 3 && !empty($conf->shippableorder->enabled)) {
1735
+				$colspan++;
1736
+			}
1737
+			if(!empty($conf->margin->enabled)) {
1738
+				$colspan++;
1739
+			}
1740
+			if(!empty($conf->global->DISPLAY_MARGIN_RATES)) {
1741
+				$colspan++;
1742
+			}
1743
+			if(!empty($conf->global->DISPLAY_MARK_RATES)) {
1744
+				$colspan++;
1745
+			}
1746
+			if($object->element == 'facture' && !empty($conf->global->INVOICE_USE_SITUATION) && $object->type == Facture::TYPE_SITUATION) {
1747
+				$colspan++;
1748
+			}
1749
+			if(!empty($conf->global->PRODUCT_USE_UNITS)) {
1750
+				$colspan++;
1751
+			}
1656 1752
 					
1657 1753
 			/* Titre */
1658 1754
 			//var_dump($line);
@@ -1665,23 +1761,36 @@  discard block
 block discarded – undo
1665 1761
 			<tr <?php echo $bc[$var]; $var=!$var; echo $data; ?> rel="subtotal" id="row-<?php echo $line->id ?>" style="<?php
1666 1762
 					if (!empty($conf->global->SUBTOTAL_USE_NEW_FORMAT))
1667 1763
 					{
1668
-						if($line->qty==99) print 'background:#adadcf';
1669
-						else if($line->qty==98) print 'background:#ddddff;';
1670
-						else if($line->qty<=97 && $line->qty>=91) print 'background:#eeeeff;';
1671
-						else if($line->qty==1) print 'background:#adadcf;';
1672
-						else if($line->qty==2) print 'background:#ddddff;';
1673
-						else if($line->qty==50) print '';
1674
-						else print 'background:#eeeeff;';
1764
+						if($line->qty==99) {
1765
+							print 'background:#adadcf';
1766
+						} else if($line->qty==98) {
1767
+							print 'background:#ddddff;';
1768
+						} else if($line->qty<=97 && $line->qty>=91) {
1769
+							print 'background:#eeeeff;';
1770
+						} else if($line->qty==1) {
1771
+							print 'background:#adadcf;';
1772
+						} else if($line->qty==2) {
1773
+							print 'background:#ddddff;';
1774
+						} else if($line->qty==50) {
1775
+							print '';
1776
+						} else {
1777
+							print 'background:#eeeeff;';
1778
+						}
1675 1779
 
1676 1780
 						//A compléter si on veux plus de nuances de couleurs avec les niveau 4,5,6,7,8 et 9
1677
-					}
1678
-					else 
1781
+					} else 
1679 1782
 					{
1680
-						if($line->qty==99) print 'background:#ddffdd';
1681
-						else if($line->qty==98) print 'background:#ddddff;';
1682
-						else if($line->qty==2) print 'background:#eeeeff; ';
1683
-						else if($line->qty==50) print '';
1684
-						else print 'background:#eeffee;' ;
1783
+						if($line->qty==99) {
1784
+							print 'background:#ddffdd';
1785
+						} else if($line->qty==98) {
1786
+							print 'background:#ddddff;';
1787
+						} else if($line->qty==2) {
1788
+							print 'background:#eeeeff; ';
1789
+						} else if($line->qty==50) {
1790
+							print '';
1791
+						} else {
1792
+							print 'background:#eeffee;' ;
1793
+						}
1685 1794
 					}
1686 1795
 
1687 1796
 			?>;">
@@ -1704,13 +1813,11 @@  discard block
 block discarded – undo
1704 1813
 							$qty_displayed = $line->qty;
1705 1814
 							print img_picto('', 'subsubtotal@subtotal').'<span style="font-size:9px;margin-left:-3px;color:#0075DE;">'.$qty_displayed.'</span>&nbsp;&nbsp;';
1706 1815
 							
1707
-						}
1708
-						else if (TSubtotal::isSubtotal($line))
1816
+						} else if (TSubtotal::isSubtotal($line))
1709 1817
 						{
1710 1818
 							$qty_displayed = 100 - $line->qty;
1711 1819
 							print img_picto('', 'subsubtotal2@subtotal').'<span style="font-size:9px;margin-left:-1px;color:#0075DE;">'.$qty_displayed.'</span>&nbsp;&nbsp;';
1712
-						}
1713
-						else
1820
+						} else
1714 1821
 						{
1715 1822
 							$isFreeText = true;
1716 1823
 						}
@@ -1727,9 +1834,13 @@  discard block
 block discarded – undo
1727 1834
 						}
1728 1835
 
1729 1836
 						$readonlyForSituation = '';
1730
-						if (!empty($object->situation_cycle_ref) && $object->situation_counter > 1) $readonlyForSituation = 'readonly';
1837
+						if (!empty($object->situation_cycle_ref) && $object->situation_counter > 1) {
1838
+							$readonlyForSituation = 'readonly';
1839
+						}
1731 1840
 						
1732
-						if (!$isFreeText) echo '<input type="text" name="line-title" id-line="'.$line->id.'" value="'.$newlabel.'" size="80" '.$readonlyForSituation.'/>&nbsp;';
1841
+						if (!$isFreeText) {
1842
+							echo '<input type="text" name="line-title" id-line="'.$line->id.'" value="'.$newlabel.'" size="80" '.$readonlyForSituation.'/>&nbsp;';
1843
+						}
1733 1844
 						
1734 1845
 						if (!empty($conf->global->SUBTOTAL_USE_NEW_FORMAT) && (TSubtotal::isTitle($line) || TSubtotal::isSubtotal($line)) )
1735 1846
 						{
@@ -1737,8 +1848,12 @@  discard block
 block discarded – undo
1737 1848
 							for ($j=1; $j<10; $j++)
1738 1849
 							{
1739 1850
 								if (!empty($readonlyForSituation)) {
1740
-									if ($qty_displayed == $j) $select .= '<option selected="selected" value="'.$j.'">'.$langs->trans('Level').' '.$j.'</option>';
1741
-								} else $select .= '<option '.($qty_displayed == $j ? 'selected="selected"' : '').' value="'.$j.'">'.$langs->trans('Level').' '.$j.'</option>';
1851
+									if ($qty_displayed == $j) {
1852
+										$select .= '<option selected="selected" value="'.$j.'">'.$langs->trans('Level').' '.$j.'</option>';
1853
+									}
1854
+								} else {
1855
+									$select .= '<option '.($qty_displayed == $j ? 'selected="selected"' : '').' value="'.$j.'">'.$langs->trans('Level').' '.$j.'</option>';
1856
+								}
1742 1857
 							}
1743 1858
 							$select .= '</select>&nbsp;';
1744 1859
 
@@ -1754,15 +1869,18 @@  discard block
 block discarded – undo
1754 1869
 								$form = new Form($db);
1755 1870
 								echo '<label for="subtotal_tva_tx">'.$form->textwithpicto($langs->trans('subtotal_apply_default_tva'), $langs->trans('subtotal_apply_default_tva_help')).'</label>';
1756 1871
 								echo '<select id="subtotal_tva_tx" name="subtotal_tva_tx" class="flat"><option selected="selected" value="">-</option>';
1757
-								if (empty($readonlyForSituation)) echo str_replace('selected', '', $form->load_tva('subtotal_tva_tx', '', $parameters['seller'], $parameters['buyer'], 0, 0, '', true));
1872
+								if (empty($readonlyForSituation)) {
1873
+									echo str_replace('selected', '', $form->load_tva('subtotal_tva_tx', '', $parameters['seller'], $parameters['buyer'], 0, 0, '', true));
1874
+								}
1758 1875
 								echo '</select>&nbsp;&nbsp;';
1759 1876
 								
1760 1877
 								if (!empty($conf->global->INVOICE_USE_SITUATION) && $object->element == 'facture' && $object->type == Facture::TYPE_SITUATION)
1761 1878
 								{
1762 1879
 									echo '<label for="subtotal_progress">'.$langs->trans('subtotal_apply_progress').'</label> <input id="subtotal_progress" name="subtotal_progress" value="" size="1" />%';
1763 1880
 								}
1881
+							} else if ($isFreeText) {
1882
+								echo TSubtotal::getFreeTextHtml($line, (bool) $readonlyForSituation);
1764 1883
 							}
1765
-							else if ($isFreeText) echo TSubtotal::getFreeTextHtml($line, (bool) $readonlyForSituation);
1766 1884
 						echo '</div>';
1767 1885
 
1768 1886
 						if($line->qty<10) {
@@ -1782,8 +1900,7 @@  discard block
 block discarded – undo
1782 1900
 							$doleditor->Create();
1783 1901
 						}
1784 1902
 						
1785
-					}
1786
-					else {
1903
+					} else {
1787 1904
 
1788 1905
 						 if ($conf->global->SUBTOTAL_USE_NEW_FORMAT)
1789 1906
 						 {
@@ -1791,14 +1908,19 @@  discard block
 block discarded – undo
1791 1908
 							{
1792 1909
 								echo str_repeat('&nbsp;&nbsp;&nbsp;', $line->qty-1);
1793 1910
 								
1794
-								if (TSubtotal::isTitle($line)) print img_picto('', 'subtotal@subtotal').'<span style="font-size:9px;margin-left:-3px;">'.$line->qty.'</span>&nbsp;&nbsp;';
1795
-								else print img_picto('', 'subtotal2@subtotal').'<span style="font-size:9px;margin-left:-1px;">'.(100-$line->qty).'</span>&nbsp;&nbsp;';
1911
+								if (TSubtotal::isTitle($line)) {
1912
+									print img_picto('', 'subtotal@subtotal').'<span style="font-size:9px;margin-left:-3px;">'.$line->qty.'</span>&nbsp;&nbsp;';
1913
+								} else {
1914
+									print img_picto('', 'subtotal2@subtotal').'<span style="font-size:9px;margin-left:-1px;">'.(100-$line->qty).'</span>&nbsp;&nbsp;';
1915
+								}
1796 1916
 							}
1797
-						 }
1798
-						 else 
1917
+						 } else 
1799 1918
 						 {
1800
-							if($line->qty<=1) print img_picto('', 'subtotal@subtotal');
1801
-							else if($line->qty==2) print img_picto('', 'subsubtotal@subtotal').'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'; 
1919
+							if($line->qty<=1) {
1920
+								print img_picto('', 'subtotal@subtotal');
1921
+							} else if($line->qty==2) {
1922
+								print img_picto('', 'subsubtotal@subtotal').'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
1923
+							}
1802 1924
 						 }
1803 1925
 						 
1804 1926
 						 
@@ -1808,21 +1930,26 @@  discard block
 block discarded – undo
1808 1930
 						 $titleStyleUnderline =  strpos($conf->global->SUBTOTAL_TITLE_STYLE, 'U') === false ? '' : ' text-decoration: underline;';
1809 1931
 						 
1810 1932
 						 if (empty($line->label)) {
1811
-							if ($line->qty >= 91 && $line->qty <= 99 && $conf->global->SUBTOTAL_USE_NEW_FORMAT) print  $line->description.' '.$this->getTitle($object, $line);
1812
-							else print  $line->description;
1813
-						 } 
1814
-						 else {
1933
+							if ($line->qty >= 91 && $line->qty <= 99 && $conf->global->SUBTOTAL_USE_NEW_FORMAT) {
1934
+								print  $line->description.' '.$this->getTitle($object, $line);
1935
+							} else {
1936
+								print  $line->description;
1937
+							}
1938
+						 } else {
1815 1939
 
1816 1940
 							if (! empty($conf->global->PRODUIT_DESC_IN_FORM) && !empty($line->description)) {
1817 1941
 								print '<span class="subtotal_label" style="'.$titleStyleItalic.$titleStyleBold.$titleStyleUnderline.'" >'.$line->label.'</span><br><div class="subtotal_desc">'.dol_htmlentitiesbr($line->description).'</div>';
1818
-							}
1819
-							else{
1942
+							} else{
1820 1943
 								print '<span class="subtotal_label classfortooltip '.$titleStyleItalic.$titleStyleBold.$titleStyleUnderline.'" title="'.$line->description.'">'.$line->label.'</span>';    
1821 1944
 							}
1822 1945
 
1823 1946
 						 } 
1824
-						if($line->qty>90) print ' : ';
1825
-						if($line->info_bits > 0) echo img_picto($langs->trans('Pagebreak'), 'pagebreak@subtotal');
1947
+						if($line->qty>90) {
1948
+							print ' : ';
1949
+						}
1950
+						if($line->info_bits > 0) {
1951
+							echo img_picto($langs->trans('Pagebreak'), 'pagebreak@subtotal');
1952
+						}
1826 1953
 
1827 1954
 						 
1828 1955
 
@@ -1859,11 +1986,12 @@  discard block
 block discarded – undo
1859 1986
 						</script>
1860 1987
 						<?php
1861 1988
 						
1862
-					}
1863
-					else{
1989
+					} else{
1864 1990
 						if ($object->statut == 0  && $createRight && !empty($conf->global->SUBTOTAL_ALLOW_DUPLICATE_BLOCK))
1865 1991
 						{
1866
-							if(TSubtotal::isTitle($line) && ($object->situation_counter == 1 || !$object->situation_cycle_ref) ) echo '<a href="'.$_SERVER['PHP_SELF'].'?'.$idvar.'='.$object->id.'&action=duplicate&lineid='.$line->id.'">'. img_picto($langs->trans('Duplicate'), 'duplicate@subtotal').'</a>';
1992
+							if(TSubtotal::isTitle($line) && ($object->situation_counter == 1 || !$object->situation_cycle_ref) ) {
1993
+								echo '<a href="'.$_SERVER['PHP_SELF'].'?'.$idvar.'='.$object->id.'&action=duplicate&lineid='.$line->id.'">'. img_picto($langs->trans('Duplicate'), 'duplicate@subtotal').'</a>';
1994
+							}
1867 1995
 						}
1868 1996
 
1869 1997
 						if ($object->statut == 0  && $createRight && !empty($conf->global->SUBTOTAL_ALLOW_EDIT_BLOCK)) 
@@ -1932,7 +2060,9 @@  discard block
 block discarded – undo
1932 2060
 				$extralabelsline = $extrafieldsline->fetch_name_optionals_label($object->table_element_line);
1933 2061
 				
1934 2062
 				$colspan+=3; $mode = 'view';
1935
-				if($action === 'editline' && $line->rowid == GETPOST('lineid')) $mode = 'edit';
2063
+				if($action === 'editline' && $line->rowid == GETPOST('lineid')) {
2064
+					$mode = 'edit';
2065
+				}
1936 2066
 				
1937 2067
 				$ex_element = $line->element;
1938 2068
 				$line->element = 'tr_extrafield_title '.$line->element; // Pour pouvoir manipuler ces tr
@@ -2080,7 +2210,9 @@  discard block
 block discarded – undo
2080 2210
 		
2081 2211
 		if ((!empty($conf->global->SUBTOTAL_PROPAL_ADD_RECAP) && $object->element == 'propal') || (!empty($conf->global->SUBTOTAL_COMMANDE_ADD_RECAP) && $object->element == 'commande') || (!empty($conf->global->SUBTOTAL_INVOICE_ADD_RECAP) && $object->element == 'facture'))
2082 2212
 		{
2083
-			if (GETPOST('subtotal_add_recap')) TSubtotal::addRecapPage($parameters, $pdf);
2213
+			if (GETPOST('subtotal_add_recap')) {
2214
+				TSubtotal::addRecapPage($parameters, $pdf);
2215
+			}
2084 2216
 		}
2085 2217
 	}
2086 2218
 	
@@ -2096,10 +2228,9 @@  discard block
 block discarded – undo
2096 2228
 	    
2097 2229
 	    if(TSubtotal::isTitle($line)){
2098 2230
 	        $ThtmlData['data-issubtotal'] = 'title';
2099
-	    }elseif(TSubtotal::isSubtotal($line)){
2231
+	    } elseif(TSubtotal::isSubtotal($line)){
2100 2232
 	        $ThtmlData['data-issubtotal'] = 'subtotal';
2101
-	    }
2102
-	    else{
2233
+	    } else{
2103 2234
 	        $ThtmlData['data-issubtotal'] = 'freetext';
2104 2235
 	    }
2105 2236
 	    
@@ -2109,7 +2240,9 @@  discard block
 block discarded – undo
2109 2240
 	    
2110 2241
 	    // hook 
2111 2242
 	    $reshook = $hookmanager->executeHooks('subtotalLineHtmlData',$parameters,$object,$action); // Note that $action and $object may have been modified by hook
2112
-	    if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
2243
+	    if ($reshook < 0) {
2244
+	    	setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
2245
+	    }
2113 2246
 	    if ($reshook>0)
2114 2247
 	    {
2115 2248
 	        $ThtmlData = $hookmanager->resArray;
Please login to merge, or discard this patch.
class/subtotal.class.php 3 patches
Indentation   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -909,8 +909,8 @@  discard block
 block discarded – undo
909 909
 		{
910 910
 			if (is_readable($logo))
911 911
 			{
912
-			    $height=pdf_getHeightForLogo($logo);
913
-			    $pdf->Image($logo, $objmarge->marge_gauche, $posy, 0, $height);	// width=0 (auto)
912
+				$height=pdf_getHeightForLogo($logo);
913
+				$pdf->Image($logo, $objmarge->marge_gauche, $posy, 0, $height);	// width=0 (auto)
914 914
 			}
915 915
 			else
916 916
 			{
@@ -1101,13 +1101,13 @@  discard block
 block discarded – undo
1101 1101
 	 * @param	int		$hidebottom		Hide bottom
1102 1102
 	 * @return	void
1103 1103
 	 */
1104
-    private static function printRect($pdf, $x, $y, $l, $h, $hidetop=0, $hidebottom=0)
1105
-    {
1106
-	    if (empty($hidetop) || $hidetop==-1) $pdf->line($x, $y, $x+$l, $y);
1107
-	    $pdf->line($x+$l, $y, $x+$l, $y+$h);
1108
-	    if (empty($hidebottom)) $pdf->line($x+$l, $y+$h, $x, $y+$h);
1109
-	    $pdf->line($x, $y+$h, $x, $y);
1110
-    }
1104
+	private static function printRect($pdf, $x, $y, $l, $h, $hidetop=0, $hidebottom=0)
1105
+	{
1106
+		if (empty($hidetop) || $hidetop==-1) $pdf->line($x, $y, $x+$l, $y);
1107
+		$pdf->line($x+$l, $y, $x+$l, $y+$h);
1108
+		if (empty($hidebottom)) $pdf->line($x+$l, $y+$h, $x, $y+$h);
1109
+		$pdf->line($x, $y+$h, $x, $y);
1110
+	}
1111 1111
 	
1112 1112
 	
1113 1113
 	public static function concat(&$outputlangs, $files, $fileoutput='')
@@ -1117,14 +1117,14 @@  discard block
 block discarded – undo
1117 1117
 		if (empty($fileoutput)) $fileoutput = $file[0];
1118 1118
 		
1119 1119
 		$pdf=pdf_getInstance();
1120
-        if (class_exists('TCPDF'))
1121
-        {
1122
-            $pdf->setPrintHeader(false);
1123
-            $pdf->setPrintFooter(false);
1124
-        }
1125
-        $pdf->SetFont(pdf_getPDFFont($outputlangs));
1120
+		if (class_exists('TCPDF'))
1121
+		{
1122
+			$pdf->setPrintHeader(false);
1123
+			$pdf->setPrintFooter(false);
1124
+		}
1125
+		$pdf->SetFont(pdf_getPDFFont($outputlangs));
1126 1126
 
1127
-        if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
1127
+		if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
1128 1128
 
1129 1129
 		
1130 1130
 		foreach($files as $file)
Please login to merge, or discard this patch.
Spacing   +177 added lines, -177 removed lines patch added patch discarded remove patch
@@ -5,23 +5,23 @@  discard block
 block discarded – undo
5 5
 	
6 6
 	static $module_number = 104777;
7 7
 	
8
-	static function addSubTotalLine(&$object, $label, $qty, $rang=-1) {
8
+	static function addSubTotalLine(&$object, $label, $qty, $rang = -1) {
9 9
 		
10 10
 		$res = 0;
11 11
 		
12
-		if( (float)DOL_VERSION <= 3.4 ) {
12
+		if ((float) DOL_VERSION <= 3.4) {
13 13
 			/**
14 14
 			 * @var $object Facture
15 15
 			 */
16
-			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);
16
+			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);
17 17
 			/**
18 18
 			 * @var $object Propal
19 19
 			 */
20
-			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);
20
+			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);
21 21
 			/**
22 22
 			 * @var $object Commande
23 23
 			 */
24
-			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);
24
+			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);
25 25
 
26 26
 		}
27 27
 		else {
@@ -34,19 +34,19 @@  discard block
 block discarded – undo
34 34
 			/**
35 35
 			 * @var $object Facture
36 36
 			 */
37
-			if($object->element=='facture') $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);
37
+			if ($object->element == 'facture') $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);
38 38
 			/**
39 39
 			 * @var $object Propal
40 40
 			 */
41
-			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);
41
+			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);
42 42
 			/**
43 43
 			 * @var $object Commande
44 44
 			 */
45
-			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);
45
+			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);
46 46
 			/**
47 47
 			 * @var $object Facturerec
48 48
 			 */
49
-			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); 
49
+			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); 
50 50
 			
51 51
 		}
52 52
 	
@@ -57,20 +57,20 @@  discard block
 block discarded – undo
57 57
 
58 58
 	public static function generateDoc(&$object)
59 59
 	{
60
-		global $conf,$langs,$db;
60
+		global $conf, $langs, $db;
61 61
 		
62 62
 		if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE))
63 63
 		{
64
-			$hidedetails = (GETPOST('hidedetails', 'int') ? GETPOST('hidedetails', 'int') : (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS) ? 1 : 0));
65
-			$hidedesc = (GETPOST('hidedesc', 'int') ? GETPOST('hidedesc', 'int') : (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DESC) ? 1 : 0));
66
-			$hideref = (GETPOST('hideref', 'int') ? GETPOST('hideref', 'int') : (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_REF) ? 1 : 0));
64
+			$hidedetails = (GETPOST('hidedetails', 'int') ? GETPOST('hidedetails', 'int') : (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS) ? 1 : 0));
65
+			$hidedesc = (GETPOST('hidedesc', 'int') ? GETPOST('hidedesc', 'int') : (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DESC) ? 1 : 0));
66
+			$hideref = (GETPOST('hideref', 'int') ? GETPOST('hideref', 'int') : (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_REF) ? 1 : 0));
67 67
 			
68 68
 			// Define output language
69 69
 			$outputlangs = $langs;
70 70
 			$newlang = GETPOST('lang_id', 'alpha');
71
-			if (! empty($conf->global->MAIN_MULTILANGS) && empty($newlang))
71
+			if (!empty($conf->global->MAIN_MULTILANGS) && empty($newlang))
72 72
 				$newlang = !empty($object->client) ? $object->client->default_lang : $object->thirdparty->default_lang;
73
-			if (! empty($newlang)) {
73
+			if (!empty($newlang)) {
74 74
 				$outputlangs = new Translate("", $conf);
75 75
 				$outputlangs->setDefaultLang($newlang);
76 76
 			}
@@ -84,7 +84,7 @@  discard block
 block discarded – undo
84 84
 			}
85 85
 			else
86 86
 			{
87
-				if ($object->element!= 'facturerec') $object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
87
+				if ($object->element != 'facturerec') $object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
88 88
 			}
89 89
 		}
90 90
 	}
@@ -96,11 +96,11 @@  discard block
 block discarded – undo
96 96
 	 * @param type $rang_start
97 97
 	 * @param type $move_to
98 98
 	 */
99
-	public static function updateRang(&$object, $rang_start, $move_to=1)
99
+	public static function updateRang(&$object, $rang_start, $move_to = 1)
100 100
 	{
101 101
 		if (!class_exists('GenericObject')) require_once DOL_DOCUMENT_ROOT.'/core/class/genericobject.class.php';
102 102
 		
103
-		$row=new GenericObject($object->db);
103
+		$row = new GenericObject($object->db);
104 104
 		$row->table_element_line = $object->table_element_line;
105 105
 		$row->fk_element = $object->fk_element;
106 106
 		$row->id = $object->id;
@@ -109,7 +109,7 @@  discard block
 block discarded – undo
109 109
 		{
110 110
 			if ($line->rang < $rang_start) continue;
111 111
 			
112
-			$row->updateRangOfLine($line->id, $line->rang+$move_to);
112
+			$row->updateRangOfLine($line->id, $line->rang + $move_to);
113 113
 		}
114 114
 	}
115 115
 	
@@ -138,7 +138,7 @@  discard block
 block discarded – undo
138 138
 			{
139 139
 				if ($rang_to_add != -1) self::updateRang($object, $rang_to_add);
140 140
 				
141
-				self::addSubTotalLine($object, $langs->trans('SubTotal'), 100-$title_niveau, $rang_to_add);
141
+				self::addSubTotalLine($object, $langs->trans('SubTotal'), 100 - $title_niveau, $rang_to_add);
142 142
 				
143 143
 				$object->lines[] = $object->line; // ajout de la ligne dans le tableau de ligne (Dolibarr ne le fait pas)
144 144
 				if ($rang_to_add != -1) 
@@ -150,14 +150,14 @@  discard block
 block discarded – undo
150 150
 		}
151 151
 	}
152 152
 	
153
-	public static function addTitle(&$object, $label, $level, $rang=-1)
153
+	public static function addTitle(&$object, $label, $level, $rang = -1)
154 154
 	{
155 155
 		self::addSubTotalLine($object, $label, $level, $rang);
156 156
 	}
157 157
 	
158
-	public static function addTotal(&$object, $label, $level, $rang=-1)
158
+	public static function addTotal(&$object, $label, $level, $rang = -1)
159 159
 	{
160
-		self::addSubTotalLine($object, $label, (100-$level), $rang);
160
+		self::addSubTotalLine($object, $label, (100 - $level), $rang);
161 161
 	}
162 162
 
163 163
 	/**
@@ -168,7 +168,7 @@  discard block
 block discarded – undo
168 168
 	 * 
169 169
 	 * @return array
170 170
 	 */
171
-	public static function getAllTitleWithoutTotalFromDocument(&$object, $get_block_total=false)
171
+	public static function getAllTitleWithoutTotalFromDocument(&$object, $get_block_total = false)
172 172
 	{
173 173
 		$TTitle = self::getAllTitleFromDocument($object, $get_block_total);
174 174
 		
@@ -189,7 +189,7 @@  discard block
 block discarded – undo
189 189
 	 * @param boolean								$return_rang_on_false	si true alors renvoi le rang où devrait ce trouver le sous-total
190 190
 	 * @return boolean
191 191
 	 */
192
-	public static function titleHasTotalLine(&$object, &$title_line, $strict_mode=false, $return_rang_on_false=false)
192
+	public static function titleHasTotalLine(&$object, &$title_line, $strict_mode = false, $return_rang_on_false = false)
193 193
 	{
194 194
 		if (empty($object->lines) || !is_array($object->lines)) return false;
195 195
 		
@@ -215,7 +215,7 @@  discard block
 block discarded – undo
215 215
 		return ($return_rang_on_false) ? -1 : false;
216 216
 	}
217 217
 	
218
-	public static function getAllTitleFromDocument(&$object, $get_block_total=false)
218
+	public static function getAllTitleFromDocument(&$object, $get_block_total = false)
219 219
 	{
220 220
 		$TRes = array();
221 221
 		if (!empty($object->lines))
@@ -335,10 +335,10 @@  discard block
 block discarded – undo
335 335
 		return false;
336 336
 	}
337 337
 	
338
-	public static function isTitle(&$line, $level=-1)
338
+	public static function isTitle(&$line, $level = -1)
339 339
 	{
340 340
 		$res = $line->special_code == self::$module_number && $line->product_type == 9 && $line->qty <= 9;
341
-		if($res && $level > -1) {
341
+		if ($res && $level > -1) {
342 342
 			return $line->qty == $level;
343 343
 		} else return $res;
344 344
 		
@@ -359,28 +359,28 @@  discard block
 block discarded – undo
359 359
 		return self::isTitle($line) || self::isSubtotal($line) || self::isFreeText($line);
360 360
 	}
361 361
 
362
-	public static function getFreeTextHtml(&$line, $readonly=0)
362
+	public static function getFreeTextHtml(&$line, $readonly = 0)
363 363
 	{
364 364
 		global $conf;
365 365
 		
366 366
 		// Copie du fichier "objectline_edit.tpl.php"
367 367
 		// editeur wysiwyg
368 368
 		require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
369
-		$nbrows=ROWS_2;
370
-		if (! empty($conf->global->MAIN_INPUT_DESC_HEIGHT)) $nbrows=$conf->global->MAIN_INPUT_DESC_HEIGHT;
371
-		$enable=(isset($conf->global->FCKEDITOR_ENABLE_DETAILS)?$conf->global->FCKEDITOR_ENABLE_DETAILS:0);
372
-		$toolbarname='dolibarr_details';
373
-		if (! empty($conf->global->FCKEDITOR_ENABLE_DETAILS_FULL)) $toolbarname='dolibarr_notes';
374
-		$text = !empty($line->description)?$line->description:$line->label;
375
-		$doleditor=new DolEditor('line-description',$text,'',164,$toolbarname,'',false,true,$enable,$nbrows,'98%', $readonly);
369
+		$nbrows = ROWS_2;
370
+		if (!empty($conf->global->MAIN_INPUT_DESC_HEIGHT)) $nbrows = $conf->global->MAIN_INPUT_DESC_HEIGHT;
371
+		$enable = (isset($conf->global->FCKEDITOR_ENABLE_DETAILS) ? $conf->global->FCKEDITOR_ENABLE_DETAILS : 0);
372
+		$toolbarname = 'dolibarr_details';
373
+		if (!empty($conf->global->FCKEDITOR_ENABLE_DETAILS_FULL)) $toolbarname = 'dolibarr_notes';
374
+		$text = !empty($line->description) ? $line->description : $line->label;
375
+		$doleditor = new DolEditor('line-description', $text, '', 164, $toolbarname, '', false, true, $enable, $nbrows, '98%', $readonly);
376 376
 		return $doleditor->Create(1);
377 377
 	}
378 378
 	
379
-	public static function duplicateLines(&$object, $lineid, $withBlockLine=false)
379
+	public static function duplicateLines(&$object, $lineid, $withBlockLine = false)
380 380
 	{
381
-		global $db,$user,$conf;
381
+		global $db, $user, $conf;
382 382
 
383
-		if ($object->statut == 0  && $user->rights->{$object->element}->creer && !empty($conf->global->SUBTOTAL_ALLOW_DUPLICATE_BLOCK))
383
+		if ($object->statut == 0 && $user->rights->{$object->element}->creer && !empty($conf->global->SUBTOTAL_ALLOW_DUPLICATE_BLOCK))
384 384
 		{
385 385
 			dol_include_once('/subtotal/lib/subtotal.lib.php');
386 386
 			
@@ -421,7 +421,7 @@  discard block
 block discarded – undo
421 421
 					{
422 422
 						$object->line_from = $line;
423 423
 						// Call trigger
424
-						$result=$object->call_trigger('LINE_DUPLICATE',$user); // $object->line
424
+						$result = $object->call_trigger('LINE_DUPLICATE', $user); // $object->line
425 425
 						if ($result < 0)
426 426
 						{
427 427
 							$object->db->rollback();
@@ -452,7 +452,7 @@  discard block
 block discarded – undo
452 452
 		}
453 453
 	}
454 454
 	
455
-	public static function getLinesFromTitle(&$object, $key_trad, $level=1, $under_title='', $withBlockLine=false, $key_is_id=false)
455
+	public static function getLinesFromTitle(&$object, $key_trad, $level = 1, $under_title = '', $withBlockLine = false, $key_is_id = false)
456 456
 	{
457 457
 		global $langs;
458 458
 		
@@ -464,17 +464,17 @@  discard block
 block discarded – undo
464 464
 		
465 465
 		$TLine = array();
466 466
 		$add_line = false;
467
-		$under_title_found=false;
467
+		$under_title_found = false;
468 468
 		
469 469
 		foreach ($object->lines as $key => &$line)
470 470
 		{
471 471
 			if (!$under_title_found && !empty($TTitle_under_search))
472 472
 			{
473
-				if ($line->product_type == 9 && (in_array($line->desc, $TTitle_under_search) || in_array($line->label, $TTitle_under_search)) ) $under_title_found = true;
473
+				if ($line->product_type == 9 && (in_array($line->desc, $TTitle_under_search) || in_array($line->label, $TTitle_under_search))) $under_title_found = true;
474 474
 			}
475 475
 			else
476 476
 			{
477
-				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) )))
477
+				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))))
478 478
 				{
479 479
 					if ($key_is_id) $level = $line->qty;
480 480
 					
@@ -482,7 +482,7 @@  discard block
 block discarded – undo
482 482
 					if ($withBlockLine) $TLine[] = $line;
483 483
 					continue;
484 484
 				}
485
-				elseif ($add_line && $line->product_type == 9 && (100 - $line->qty == $level) ) // Si on tombe sur un sous-total, il faut que ce soit un du même niveau que le titre
485
+				elseif ($add_line && $line->product_type == 9 && (100 - $line->qty == $level)) // Si on tombe sur un sous-total, il faut que ce soit un du même niveau que le titre
486 486
 				{
487 487
 					if ($withBlockLine) $TLine[] = $line;
488 488
 					break;
@@ -490,7 +490,7 @@  discard block
 block discarded – undo
490 490
 				
491 491
 				if ($add_line)
492 492
 				{
493
-					if (!$withBlockLine && (self::isTitle($line) || self::isSubtotal($line)) ) continue;
493
+					if (!$withBlockLine && (self::isTitle($line) || self::isSubtotal($line))) continue;
494 494
 					else $TLine[] = $line;
495 495
 				}
496 496
 			}
@@ -499,12 +499,12 @@  discard block
 block discarded – undo
499 499
 		return $TLine;
500 500
 	}
501 501
 	
502
-	public static function getLinesFromTitleId(&$object, $lineid, $withBlockLine=false)
502
+	public static function getLinesFromTitleId(&$object, $lineid, $withBlockLine = false)
503 503
 	{
504 504
 		return self::getLinesFromTitle($object, $lineid, '', '', $withBlockLine, true);
505 505
 	}
506 506
 	
507
-	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)
507
+	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)
508 508
 	{
509 509
 		$res = 0;
510 510
 		$object->db->begin();
@@ -529,9 +529,9 @@  discard block
 block discarded – undo
529 529
 				$factureRecLine->fetch($rowid);
530 530
 				$factureRecLine->array_options = $array_options;
531 531
 				$factureRecLine->insertExtraFields();
532
-				$rang=$factureRecLine->rang;
532
+				$rang = $factureRecLine->rang;
533 533
 				
534
-				$fk_product=0; $fk_remise_except=''; $pu_ttc=0;	
534
+				$fk_product = 0; $fk_remise_except = ''; $pu_ttc = 0;	
535 535
 				$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);
536 536
 				break;
537 537
 		}
@@ -624,7 +624,7 @@  discard block
 block discarded – undo
624 624
 	 */
625 625
 	public static function addRecapPage(&$parameters, &$origin_pdf)
626 626
 	{
627
-		global $user,$conf,$langs;
627
+		global $user, $conf, $langs;
628 628
 		
629 629
 		$origin_file = $parameters['file'];
630 630
 		$outputlangs = $parameters['outputlangs'];
@@ -640,21 +640,21 @@  discard block
 block discarded – undo
640 640
 		$objmarge->marge_droite = 10;
641 641
 		
642 642
 		$objectref = dol_sanitizeFileName($object->ref);
643
-		if ($object->element == 'propal') $dir = $conf->propal->dir_output . '/' . $objectref;
644
-		elseif ($object->element == 'commande') $dir = $conf->commande->dir_output . '/' . $objectref;
645
-		elseif ($object->element == 'facture') $dir = $conf->facture->dir_output . '/' . $objectref;
643
+		if ($object->element == 'propal') $dir = $conf->propal->dir_output.'/'.$objectref;
644
+		elseif ($object->element == 'commande') $dir = $conf->commande->dir_output.'/'.$objectref;
645
+		elseif ($object->element == 'facture') $dir = $conf->facture->dir_output.'/'.$objectref;
646 646
 		elseif ($object->element == 'facturerec') return; // no PDF for facturerec
647 647
 		else
648 648
 		{
649 649
 			setEventMessage($langs->trans('warning_subtotal_recap_object_element_unknown', $object->element), 'warnings');
650 650
 			return -1;
651 651
 		}
652
-		$file = $dir . '/' . $objectref . '_recap.pdf';
652
+		$file = $dir.'/'.$objectref.'_recap.pdf';
653 653
 
654 654
 //		$pdf=pdf_getInstance($origin_pdf->format);
655
-		$pdf=pdf_getInstance(array(210, 297)); // Format A4 Portrait
656
-		$default_font_size = pdf_getPDFFontSize($outputlangs);	// Must be after pdf_getInstance
657
-		$pdf->SetAutoPageBreak(1,0);
655
+		$pdf = pdf_getInstance(array(210, 297)); // Format A4 Portrait
656
+		$default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance
657
+		$pdf->SetAutoPageBreak(1, 0);
658 658
 	             
659 659
 		if (class_exists('TCPDF'))
660 660
 		{
@@ -663,49 +663,49 @@  discard block
 block discarded – undo
663 663
 		}
664 664
 		$pdf->SetFont(pdf_getPDFFont($outputlangs));
665 665
 		// Set path to the background PDF File
666
-		if (empty($conf->global->MAIN_DISABLE_FPDI) && ! empty($conf->global->MAIN_ADD_PDF_BACKGROUND))
666
+		if (empty($conf->global->MAIN_DISABLE_FPDI) && !empty($conf->global->MAIN_ADD_PDF_BACKGROUND))
667 667
 		{
668 668
 			$pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND);
669 669
 			$tplidx = $pdf->importPage(1);
670 670
 		}
671 671
 
672 672
 		$pdf->Open();
673
-		$pagenb=0;
674
-		$pdf->SetDrawColor(128,128,128);
673
+		$pagenb = 0;
674
+		$pdf->SetDrawColor(128, 128, 128);
675 675
 
676 676
 		$pdf->SetTitle($outputlangs->convToOutputCharset($object->ref));
677 677
 		$pdf->SetSubject($outputlangs->transnoentities("subtotalRecap"));
678 678
 		$pdf->SetCreator("Dolibarr ".DOL_VERSION);
679 679
 		$pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
680 680
 		$pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("subtotalRecap")." ".$outputlangs->convToOutputCharset($object->thirdparty->name));
681
-		if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
681
+		if (!empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
682 682
 
683
-		$pdf->SetMargins($objmarge->marge_gauche, $objmarge->marge_haute, $objmarge->marge_droite);   // Left, Top, Right
683
+		$pdf->SetMargins($objmarge->marge_gauche, $objmarge->marge_haute, $objmarge->marge_droite); // Left, Top, Right
684 684
 
685
-		$pagenb=0;
686
-		$pdf->SetDrawColor(128,128,128);
685
+		$pagenb = 0;
686
+		$pdf->SetDrawColor(128, 128, 128);
687 687
 
688 688
 			
689 689
 		// New page
690 690
 		$pdf->AddPage();
691
-		if (! empty($tplidx)) $pdf->useTemplate($tplidx);
691
+		if (!empty($tplidx)) $pdf->useTemplate($tplidx);
692 692
 		$pagenb++;
693 693
 		
694 694
 		
695 695
 		self::pagehead($objmarge, $pdf, $object, 1, $outputlangs);
696
-		$pdf->SetFont('','', $default_font_size - 1);
697
-		$pdf->MultiCell(0, 3, '');		// Set interline to 3
698
-		$pdf->SetTextColor(0,0,0);
696
+		$pdf->SetFont('', '', $default_font_size - 1);
697
+		$pdf->MultiCell(0, 3, ''); // Set interline to 3
698
+		$pdf->SetTextColor(0, 0, 0);
699 699
 		
700
-		$heightforinfotot = 25;	// Height reserved to output the info and total part
701
-		$heightforfooter = $objmarge->marge_basse + 8;	// Height reserved to output the footer (value include bottom margin)
700
+		$heightforinfotot = 25; // Height reserved to output the info and total part
701
+		$heightforfooter = $objmarge->marge_basse + 8; // Height reserved to output the footer (value include bottom margin)
702 702
 		
703 703
 		$posx_designation = 25;
704 704
 		$posx_options = 150;
705 705
 		$posx_montant = 170;
706 706
 		
707 707
 		$tab_top = 72;
708
-		$tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)?72:20); // TODO à vérifier
708
+		$tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD) ? 72 : 20); // TODO à vérifier
709 709
 		
710 710
 		$TTot = array('total_ht' => 0, 'total_ttc' => 0, 'TTotal_tva' => array());
711 711
 		
@@ -719,14 +719,14 @@  discard block
 block discarded – undo
719 719
 			$nexY = $tab_top + 10;
720 720
 			
721 721
 			$nblignes = count($TLine);
722
-			foreach($TLine as $i => &$line)
722
+			foreach ($TLine as $i => &$line)
723 723
 			{
724 724
 				$curY = $nexY;
725 725
 				
726 726
 				if (self::getNiveau($line) == 1) 
727 727
 				{
728
-					$pdf->SetFont('','B', $default_font_size - 1);   // Into loop to work with multipage
729
-					$curY+=2;
728
+					$pdf->SetFont('', 'B', $default_font_size - 1); // Into loop to work with multipage
729
+					$curY += 2;
730 730
 					
731 731
 					$TTot['total_ht'] += $line->total_ht;
732 732
 					$TTot['total_tva'] += $line->total_tva;
@@ -745,67 +745,67 @@  discard block
 block discarded – undo
745 745
 						$TTot['TTotal_tva_multicurrency'][$tx] += $amount;
746 746
 					}	
747 747
 				}
748
-				else $pdf->SetFont('','', $default_font_size - 1);   // Into loop to work with multipage
748
+				else $pdf->SetFont('', '', $default_font_size - 1); // Into loop to work with multipage
749 749
 				
750
-				$pdf->SetTextColor(0,0,0);
750
+				$pdf->SetTextColor(0, 0, 0);
751 751
 				
752 752
 				$pdf->setTopMargin($tab_top_newpage + 10);
753
-				$pdf->setPageOrientation('', 1, $heightforfooter+$heightforinfotot);	// The only function to edit the bottom margin of current page to set it.
754
-				$pageposbefore=$pdf->getPage();
753
+				$pdf->setPageOrientation('', 1, $heightforfooter + $heightforinfotot); // The only function to edit the bottom margin of current page to set it.
754
+				$pageposbefore = $pdf->getPage();
755 755
 				
756
-				$showpricebeforepagebreak=1;
756
+				$showpricebeforepagebreak = 1;
757 757
 				
758 758
 				$decalage = (self::getNiveau($line) - 1) * 2;
759 759
 				
760 760
 				// Print: Designation
761 761
 				$label = $line->label;
762
-				if( (float)DOL_VERSION < 6 ) {
762
+				if ((float) DOL_VERSION < 6) {
763 763
 					$label = !empty($line->label) ? $line->label : $line->desc;
764 764
 				}
765 765
 				
766 766
 				
767 767
 				$pdf->startTransaction();
768
-				$pdf->writeHTMLCell($posx_options-$posx_designation-$decalage, 3, $posx_designation+$decalage, $curY, $outputlangs->convToOutputCharset($label), 0, 1, false, true, 'J',true);
769
-				$pageposafter=$pdf->getPage();
768
+				$pdf->writeHTMLCell($posx_options - $posx_designation - $decalage, 3, $posx_designation + $decalage, $curY, $outputlangs->convToOutputCharset($label), 0, 1, false, true, 'J', true);
769
+				$pageposafter = $pdf->getPage();
770 770
 				if ($pageposafter > $pageposbefore)	// There is a pagebreak
771 771
 				{
772 772
 					$pdf->rollbackTransaction(true);
773
-					$pageposafter=$pageposbefore;
773
+					$pageposafter = $pageposbefore;
774 774
 					//print $pageposafter.'-'.$pageposbefore;exit;
775
-					$pdf->setPageOrientation('', 1, $heightforfooter);	// The only function to edit the bottom margin of current page to set it.
776
-					$pdf->writeHTMLCell($posx_options-$posx_designation-$decalage, 3, $posx_designation+$decalage, $curY, $outputlangs->convToOutputCharset($label), 0, 1, false, true, 'J',true);
775
+					$pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it.
776
+					$pdf->writeHTMLCell($posx_options - $posx_designation - $decalage, 3, $posx_designation + $decalage, $curY, $outputlangs->convToOutputCharset($label), 0, 1, false, true, 'J', true);
777 777
 
778
-					$pageposafter=$pdf->getPage();
779
-					$posyafter=$pdf->GetY();
778
+					$pageposafter = $pdf->getPage();
779
+					$posyafter = $pdf->GetY();
780 780
 					//var_dump($posyafter); var_dump(($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))); exit;
781
-					if ($posyafter > ($objmarge->page_hauteur - ($heightforfooter+$heightforinfotot)))	// There is no space left for total+free text
781
+					if ($posyafter > ($objmarge->page_hauteur - ($heightforfooter + $heightforinfotot)))	// There is no space left for total+free text
782 782
 					{
783
-						if ($i == ($nblignes-1))	// No more lines, and no space left to show total, so we create a new page
783
+						if ($i == ($nblignes - 1))	// No more lines, and no space left to show total, so we create a new page
784 784
 						{
785
-							$pdf->AddPage('','',true);
786
-							if (! empty($tplidx)) $pdf->useTemplate($tplidx);
785
+							$pdf->AddPage('', '', true);
786
+							if (!empty($tplidx)) $pdf->useTemplate($tplidx);
787 787
 							if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) self::pagehead($objmarge, $pdf, $object, 0, $outputlangs);
788
-							$pdf->setPage($pageposafter+1);
788
+							$pdf->setPage($pageposafter + 1);
789 789
 						}
790 790
 					}
791 791
 					else
792 792
 					{
793 793
 						// We found a page break
794
-						$showpricebeforepagebreak=0;
794
+						$showpricebeforepagebreak = 0;
795 795
 					}
796 796
 				}
797 797
 				else	// No pagebreak
798 798
 				{
799 799
 					$pdf->commitTransaction();
800 800
 				}
801
-				$posYAfterDescription=$pdf->GetY();
801
+				$posYAfterDescription = $pdf->GetY();
802 802
 
803 803
 				$nexY = $pdf->GetY();
804
-				$pageposafter=$pdf->getPage();
804
+				$pageposafter = $pdf->getPage();
805 805
 
806 806
 				$pdf->setPage($pageposbefore);
807 807
 				$pdf->setTopMargin($objmarge->marge_haute);
808
-				$pdf->setPageOrientation('', 1, 0);	// The only function to edit the bottom margin of current page to set it.
808
+				$pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
809 809
 
810 810
 				// We suppose that a too long description or photo were moved completely on next page
811 811
 				if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) {
@@ -818,14 +818,14 @@  discard block
 block discarded – undo
818 818
 				if (!empty($line->total_options))
819 819
 				{
820 820
 					$pdf->SetXY($posx_options, $curY);
821
-					$pdf->MultiCell($posx_montant-$posx_options-0.8, 3, price($line->total_options, 0, $outputlangs), 0, 'R', 0);
821
+					$pdf->MultiCell($posx_montant - $posx_options - 0.8, 3, price($line->total_options, 0, $outputlangs), 0, 'R', 0);
822 822
 				}
823 823
 				
824 824
 				// Print: Montant
825 825
 				$pdf->SetXY($posx_montant, $curY);
826
-				$pdf->MultiCell($objmarge->page_largeur-$objmarge->marge_droite-$posx_montant-0.8, 3, price($line->total_ht, 0, $outputlangs), 0, 'R', 0);
826
+				$pdf->MultiCell($objmarge->page_largeur - $objmarge->marge_droite - $posx_montant - 0.8, 3, price($line->total_ht, 0, $outputlangs), 0, 'R', 0);
827 827
 				
828
-				$nexY+=2;    // Passe espace entre les lignes
828
+				$nexY += 2; // Passe espace entre les lignes
829 829
 
830 830
 				// Detect if some page were added automatically and output _tableau for past pages
831 831
 				while ($pagenb < $pageposafter)
@@ -842,7 +842,7 @@  discard block
 block discarded – undo
842 842
 					
843 843
 					$pagenb++;
844 844
 					$pdf->setPage($pagenb);
845
-					$pdf->setPageOrientation('', 1, 0);	// The only function to edit the bottom margin of current page to set it.
845
+					$pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
846 846
 					if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) self::pagehead($objmarge, $pdf, $object, 0, $outputlangs);
847 847
 				}
848 848
 			}
@@ -852,19 +852,19 @@  discard block
 block discarded – undo
852 852
 		if ($pagenb == 1)
853 853
 		{
854 854
 			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);
855
-			$bottomlasttab=$objmarge->page_hauteur - $heightforinfotot - $heightforfooter + 1;
855
+			$bottomlasttab = $objmarge->page_hauteur - $heightforinfotot - $heightforfooter + 1;
856 856
 		}
857 857
 		else
858 858
 		{
859 859
 			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);
860
-			$bottomlasttab=$objmarge->page_hauteur - $heightforinfotot - $heightforfooter + 1;
860
+			$bottomlasttab = $objmarge->page_hauteur - $heightforinfotot - $heightforfooter + 1;
861 861
 		}
862 862
 		
863 863
 		// Affiche zone totaux
864
-		$posy=self::tableau_tot($objmarge, $pdf, $object, $bottomlasttab, $outputlangs, $TTot);
864
+		$posy = self::tableau_tot($objmarge, $pdf, $object, $bottomlasttab, $outputlangs, $TTot);
865 865
 		
866 866
 		$pdf->Close();
867
-		$pdf->Output($file,'F');
867
+		$pdf->Output($file, 'F');
868 868
 		
869 869
 		$pagecount = self::concat($outputlangs, array($origin_file, $file), $origin_file);
870 870
 		
@@ -876,7 +876,7 @@  discard block
 block discarded – undo
876 876
 		$level = $line->qty; // TODO à améliorer
877 877
 		
878 878
 		$pdf->SetXY($objmarge->marge_gauche, $curY);
879
-		$pdf->MultiCell($posx_designation-$objmarge->marge_gauche-0.8, 5, $level, 0, 'L', 0);
879
+		$pdf->MultiCell($posx_designation - $objmarge->marge_gauche - 0.8, 5, $level, 0, 'L', 0);
880 880
 	}
881 881
 	
882 882
 	/**
@@ -890,50 +890,50 @@  discard block
 block discarded – undo
890 890
 	 */
891 891
 	private static function pagehead(&$objmarge, &$pdf, &$object, $showdetail, $outputlangs)
892 892
 	{
893
-		global $conf,$mysoc;
893
+		global $conf, $mysoc;
894 894
 
895 895
 		$default_font_size = pdf_getPDFFontSize($outputlangs);
896 896
 
897
-		pdf_pagehead($pdf,$outputlangs,$objmarge->page_hauteur);
897
+		pdf_pagehead($pdf, $outputlangs, $objmarge->page_hauteur);
898 898
 
899
-		$pdf->SetTextColor(0,0,60);
900
-		$pdf->SetFont('','B', $default_font_size + 3);
899
+		$pdf->SetTextColor(0, 0, 60);
900
+		$pdf->SetFont('', 'B', $default_font_size + 3);
901 901
 
902
-		$posy=$objmarge->marge_haute;
903
-		$posx=$objmarge->page_largeur-$objmarge->marge_droite-100;
902
+		$posy = $objmarge->marge_haute;
903
+		$posx = $objmarge->page_largeur - $objmarge->marge_droite - 100;
904 904
 		
905
-		$pdf->SetXY($objmarge->marge_gauche,$posy);
905
+		$pdf->SetXY($objmarge->marge_gauche, $posy);
906 906
 
907
-		$logo=$conf->mycompany->dir_output.'/logos/'.$mysoc->logo;
907
+		$logo = $conf->mycompany->dir_output.'/logos/'.$mysoc->logo;
908 908
 		if ($mysoc->logo)
909 909
 		{
910 910
 			if (is_readable($logo))
911 911
 			{
912
-			    $height=pdf_getHeightForLogo($logo);
913
-			    $pdf->Image($logo, $objmarge->marge_gauche, $posy, 0, $height);	// width=0 (auto)
912
+			    $height = pdf_getHeightForLogo($logo);
913
+			    $pdf->Image($logo, $objmarge->marge_gauche, $posy, 0, $height); // width=0 (auto)
914 914
 			}
915 915
 			else
916 916
 			{
917
-				$pdf->SetTextColor(200,0,0);
918
-				$pdf->SetFont('','B',$default_font_size - 2);
919
-				$pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound",$logo), 0, 'L');
917
+				$pdf->SetTextColor(200, 0, 0);
918
+				$pdf->SetFont('', 'B', $default_font_size - 2);
919
+				$pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound", $logo), 0, 'L');
920 920
 				$pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L');
921 921
 			}
922 922
 			
923
-			$posy+=35;
923
+			$posy += 35;
924 924
 		}
925 925
 		else
926 926
 		{
927
-			$text=$mysoc->name;
927
+			$text = $mysoc->name;
928 928
 			$pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0, 'L');
929 929
 			
930
-			$posy+=15;
930
+			$posy += 15;
931 931
 		}
932 932
 		
933 933
 		
934
-		$pdf->SetTextColor(0,0,0);
935
-		$pdf->SetFont('','B', $default_font_size + 2);
936
-		$pdf->SetXY($objmarge->marge_gauche,$posy);
934
+		$pdf->SetTextColor(0, 0, 0);
935
+		$pdf->SetFont('', 'B', $default_font_size + 2);
936
+		$pdf->SetXY($objmarge->marge_gauche, $posy);
937 937
 		
938 938
 		$key = 'subtotalPropalTitle';
939 939
 		if ($object->element == 'commande') $key = 'subtotalCommandeTitle';
@@ -942,14 +942,14 @@  discard block
 block discarded – undo
942 942
 		
943 943
 		$pdf->MultiCell(150, 4, $outputlangs->transnoentities($key, $object->ref, $object->thirdparty->name), '', 'L');
944 944
 		
945
-		$pdf->SetFont('','', $default_font_size);
946
-		$pdf->SetXY($objmarge->page_largeur-$objmarge->marge_droite-40,$posy);
945
+		$pdf->SetFont('', '', $default_font_size);
946
+		$pdf->SetXY($objmarge->page_largeur - $objmarge->marge_droite - 40, $posy);
947 947
 		$pdf->MultiCell(40, 4, dol_print_date($object->date, 'daytext'), '', 'R');
948 948
 		
949 949
 		$posy += 8;
950 950
 			
951
-		$pdf->SetFont('','B', $default_font_size + 2);
952
-		$pdf->SetXY($objmarge->marge_gauche,$posy);
951
+		$pdf->SetFont('', 'B', $default_font_size + 2);
952
+		$pdf->SetXY($objmarge->marge_gauche, $posy);
953 953
 		$pdf->MultiCell(70, 4, $outputlangs->transnoentities('subtotalRecapLot'), '', 'L');
954 954
 		
955 955
 	}
@@ -967,44 +967,44 @@  discard block
 block discarded – undo
967 967
 	 *   @param		string		$currency		Currency code
968 968
 	 *   @return	void
969 969
 	 */
970
-	private static function tableau(&$objmarge, &$pdf, $posx_designation, $posx_options, $posx_montant, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop=0, $hidebottom=0, $currency='')
970
+	private static function tableau(&$objmarge, &$pdf, $posx_designation, $posx_options, $posx_montant, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0, $currency = '')
971 971
 	{
972 972
 		global $conf;
973 973
 		
974 974
 		// Force to disable hidetop and hidebottom
975
-		$hidebottom=0;
976
-		if ($hidetop) $hidetop=-1;
975
+		$hidebottom = 0;
976
+		if ($hidetop) $hidetop = -1;
977 977
 
978 978
 		$currency = !empty($currency) ? $currency : $conf->currency;
979 979
 		$default_font_size = pdf_getPDFFontSize($outputlangs);
980 980
 
981 981
 		// Amount in (at tab_top - 1)
982
-		$pdf->SetTextColor(0,0,0);
983
-		$pdf->SetFont('','',$default_font_size);
982
+		$pdf->SetTextColor(0, 0, 0);
983
+		$pdf->SetFont('', '', $default_font_size);
984 984
 
985 985
 		if (empty($hidetop))
986 986
 		{
987
-			$titre = $outputlangs->transnoentities("AmountInCurrency",$outputlangs->transnoentitiesnoconv("Currency".$currency));
988
-			$pdf->SetXY($objmarge->page_largeur - $objmarge->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top-4.5);
987
+			$titre = $outputlangs->transnoentities("AmountInCurrency", $outputlangs->transnoentitiesnoconv("Currency".$currency));
988
+			$pdf->SetXY($objmarge->page_largeur - $objmarge->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top - 4.5);
989 989
 			$pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre);
990 990
 			
991
-			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));
991
+			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));
992 992
 			
993 993
 			
994
-			$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
994
+			$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
995 995
 
996
-			$pdf->SetXY($posx_designation, $tab_top+2);
997
-			$pdf->MultiCell($posx_options - $posx_designation,2, $outputlangs->transnoentities("Designation"),'','L');
998
-			$pdf->SetXY($posx_options, $tab_top+2);
999
-			$pdf->MultiCell($posx_montant - $posx_options,2, $outputlangs->transnoentities("Options"),'','R');
1000
-			$pdf->SetXY($posx_montant, $tab_top+2);
1001
-			$pdf->MultiCell($objmarge->page_largeur - $objmarge->marge_droite - $posx_montant,2, $outputlangs->transnoentities("Amount"),'','R');
996
+			$pdf->SetXY($posx_designation, $tab_top + 2);
997
+			$pdf->MultiCell($posx_options - $posx_designation, 2, $outputlangs->transnoentities("Designation"), '', 'L');
998
+			$pdf->SetXY($posx_options, $tab_top + 2);
999
+			$pdf->MultiCell($posx_montant - $posx_options, 2, $outputlangs->transnoentities("Options"), '', 'R');
1000
+			$pdf->SetXY($posx_montant, $tab_top + 2);
1001
+			$pdf->MultiCell($objmarge->page_largeur - $objmarge->marge_droite - $posx_montant, 2, $outputlangs->transnoentities("Amount"), '', 'R');
1002 1002
 			
1003
-			$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
1003
+			$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
1004 1004
 		}
1005 1005
 		else
1006 1006
 		{
1007
-			$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
1007
+			$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
1008 1008
 		}
1009 1009
 		
1010 1010
 	}
@@ -1013,29 +1013,29 @@  discard block
 block discarded – undo
1013 1013
 	{
1014 1014
 		global $conf;
1015 1015
 		
1016
-		$pdf->line($objmarge->marge_gauche, $posy, $objmarge->page_largeur-$objmarge->marge_droite, $posy);	// line prend une position y en 2eme param et 4eme param
1016
+		$pdf->line($objmarge->marge_gauche, $posy, $objmarge->page_largeur - $objmarge->marge_droite, $posy); // line prend une position y en 2eme param et 4eme param
1017 1017
 		
1018 1018
 		$default_font_size = pdf_getPDFFontSize($outputlangs);
1019 1019
 		
1020
-		$tab2_top = $posy+2;
1020
+		$tab2_top = $posy + 2;
1021 1021
 		$tab2_hl = 4;
1022
-		$pdf->SetFont('','', $default_font_size - 1);
1022
+		$pdf->SetFont('', '', $default_font_size - 1);
1023 1023
 
1024 1024
 		// Tableau total
1025 1025
 		$col1x = 120; $col2x = 170;
1026 1026
 		if ($objmarge->page_largeur < 210) // To work with US executive format
1027 1027
 		{
1028
-			$col2x-=20;
1028
+			$col2x -= 20;
1029 1029
 		}
1030 1030
 		$largcol2 = ($objmarge->page_largeur - $objmarge->marge_droite - $col2x);
1031 1031
 
1032
-		$useborder=0;
1032
+		$useborder = 0;
1033 1033
 		$index = 0;
1034 1034
 
1035 1035
 		// Total HT
1036
-		$pdf->SetFillColor(255,255,255);
1036
+		$pdf->SetFillColor(255, 255, 255);
1037 1037
 		$pdf->SetXY($col1x, $tab2_top + 0);
1038
-		$pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalHT"), 0, 'L', 1);
1038
+		$pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("TotalHT"), 0, 'L', 1);
1039 1039
 
1040 1040
 		// $total_ht = ($conf->multicurrency->enabled && $object->mylticurrency_tx != 1) ? $TTot['multicurrency_total_ht'] : $TTot['total_ht'];
1041 1041
 		$total_ht = $TTot['total_ht'];
@@ -1043,10 +1043,10 @@  discard block
 block discarded – undo
1043 1043
 		$pdf->MultiCell($largcol2, $tab2_hl, price($total_ht, 0, $outputlangs), 0, 'R', 1);
1044 1044
 
1045 1045
 		// Show VAT by rates and total
1046
-		$pdf->SetFillColor(248,248,248);
1046
+		$pdf->SetFillColor(248, 248, 248);
1047 1047
 		
1048
-		$atleastoneratenotnull=0;
1049
-		foreach($TTot['TTotal_tva'] as $tvakey => $tvaval)
1048
+		$atleastoneratenotnull = 0;
1049
+		foreach ($TTot['TTotal_tva'] as $tvakey => $tvaval)
1050 1050
 		{
1051 1051
 			if ($tvakey != 0)    // On affiche pas taux 0
1052 1052
 			{
@@ -1055,15 +1055,15 @@  discard block
 block discarded – undo
1055 1055
 				$index++;
1056 1056
 				$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1057 1057
 
1058
-				$tvacompl='';
1059
-				if (preg_match('/\*/',$tvakey))
1058
+				$tvacompl = '';
1059
+				if (preg_match('/\*/', $tvakey))
1060 1060
 				{
1061
-					$tvakey=str_replace('*','',$tvakey);
1061
+					$tvakey = str_replace('*', '', $tvakey);
1062 1062
 					$tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
1063 1063
 				}
1064
-				$totalvat =$outputlangs->transnoentities("TotalVAT").' ';
1065
-				$totalvat.=vatrate($tvakey,1).$tvacompl;
1066
-				$pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
1064
+				$totalvat = $outputlangs->transnoentities("TotalVAT").' ';
1065
+				$totalvat .= vatrate($tvakey, 1).$tvacompl;
1066
+				$pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1);
1067 1067
 
1068 1068
 				$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1069 1069
 				$pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
@@ -1073,16 +1073,16 @@  discard block
 block discarded – undo
1073 1073
 		// Total TTC
1074 1074
 		$index++;
1075 1075
 		$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1076
-		$pdf->SetTextColor(0,0,60);
1077
-		$pdf->SetFillColor(224,224,224);
1078
-		$pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalTTC"), $useborder, 'L', 1);
1076
+		$pdf->SetTextColor(0, 0, 60);
1077
+		$pdf->SetFillColor(224, 224, 224);
1078
+		$pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("TotalTTC"), $useborder, 'L', 1);
1079 1079
 
1080 1080
 		// $total_ttc = ($conf->multicurrency->enabled && $object->multiccurency_tx != 1) ? $TTot['multicurrency_total_ttc'] : $TTot['total_ttc'];
1081 1081
 		$total_ttc = $TTot['total_ttc'];
1082 1082
 		$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1083 1083
 		$pdf->MultiCell($largcol2, $tab2_hl, price($total_ttc, 0, $outputlangs), $useborder, 'R', 1);
1084 1084
 
1085
-		$pdf->SetTextColor(0,0,0);
1085
+		$pdf->SetTextColor(0, 0, 0);
1086 1086
 				
1087 1087
 		$index++;
1088 1088
 		return ($tab2_top + ($tab2_hl * $index));
@@ -1101,22 +1101,22 @@  discard block
 block discarded – undo
1101 1101
 	 * @param	int		$hidebottom		Hide bottom
1102 1102
 	 * @return	void
1103 1103
 	 */
1104
-    private static function printRect($pdf, $x, $y, $l, $h, $hidetop=0, $hidebottom=0)
1104
+    private static function printRect($pdf, $x, $y, $l, $h, $hidetop = 0, $hidebottom = 0)
1105 1105
     {
1106
-	    if (empty($hidetop) || $hidetop==-1) $pdf->line($x, $y, $x+$l, $y);
1107
-	    $pdf->line($x+$l, $y, $x+$l, $y+$h);
1108
-	    if (empty($hidebottom)) $pdf->line($x+$l, $y+$h, $x, $y+$h);
1109
-	    $pdf->line($x, $y+$h, $x, $y);
1106
+	    if (empty($hidetop) || $hidetop == -1) $pdf->line($x, $y, $x + $l, $y);
1107
+	    $pdf->line($x + $l, $y, $x + $l, $y + $h);
1108
+	    if (empty($hidebottom)) $pdf->line($x + $l, $y + $h, $x, $y + $h);
1109
+	    $pdf->line($x, $y + $h, $x, $y);
1110 1110
     }
1111 1111
 	
1112 1112
 	
1113
-	public static function concat(&$outputlangs, $files, $fileoutput='')
1113
+	public static function concat(&$outputlangs, $files, $fileoutput = '')
1114 1114
 	{
1115 1115
 		global $conf;
1116 1116
 		
1117 1117
 		if (empty($fileoutput)) $fileoutput = $file[0];
1118 1118
 		
1119
-		$pdf=pdf_getInstance();
1119
+		$pdf = pdf_getInstance();
1120 1120
         if (class_exists('TCPDF'))
1121 1121
         {
1122 1122
             $pdf->setPrintHeader(false);
@@ -1124,10 +1124,10 @@  discard block
 block discarded – undo
1124 1124
         }
1125 1125
         $pdf->SetFont(pdf_getPDFFont($outputlangs));
1126 1126
 
1127
-        if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
1127
+        if (!empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
1128 1128
 
1129 1129
 		
1130
-		foreach($files as $file)
1130
+		foreach ($files as $file)
1131 1131
 		{
1132 1132
 			$pagecount = $pdf->setSourceFile($file);
1133 1133
 			for ($i = 1; $i <= $pagecount; $i++)
@@ -1139,8 +1139,8 @@  discard block
 block discarded – undo
1139 1139
 			}
1140 1140
 		}
1141 1141
 		
1142
-		$pdf->Output($fileoutput,'F');
1143
-		if (! empty($conf->global->MAIN_UMASK)) @chmod($file, octdec($conf->global->MAIN_UMASK));
1142
+		$pdf->Output($fileoutput, 'F');
1143
+		if (!empty($conf->global->MAIN_UMASK)) @chmod($file, octdec($conf->global->MAIN_UMASK));
1144 1144
 
1145 1145
 		return $pagecount;
1146 1146
 	}
Please login to merge, or discard this patch.
Braces   +259 added lines, -124 removed lines patch added patch discarded remove patch
@@ -13,18 +13,23 @@  discard block
 block discarded – undo
13 13
 			/**
14 14
 			 * @var $object Facture
15 15
 			 */
16
-			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);
16
+			if($object->element=='facture') {
17
+				$res =  $object->addline($object->id, $label, 0,$qty,0,0,0,0,0,'','',0,0,'','HT',0,9,-1, TSubtotal::$module_number);
18
+			}
17 19
 			/**
18 20
 			 * @var $object Propal
19 21
 			 */
20
-			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);
22
+			else if($object->element=='propal') {
23
+				$res =  $object->addline($object->id,$label, 0,$qty,0,0,0,0,0,'HT',0,0,9,-1, TSubtotal::$module_number);
24
+			}
21 25
 			/**
22 26
 			 * @var $object Commande
23 27
 			 */
24
-			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);
28
+			else if($object->element=='commande') {
29
+				$res =  $object->addline($object->id,$label, 0,$qty,0,0,0,0,0,0,0,'HT',0,'','',9,-1, TSubtotal::$module_number);
30
+			}
25 31
 
26
-		}
27
-		else {
32
+		} else {
28 33
 			$desc = '';
29 34
 			if ((float) DOL_VERSION < 6) {
30 35
 				$desc = $label;
@@ -34,19 +39,27 @@  discard block
 block discarded – undo
34 39
 			/**
35 40
 			 * @var $object Facture
36 41
 			 */
37
-			if($object->element=='facture') $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);
42
+			if($object->element=='facture') {
43
+				$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);
44
+			}
38 45
 			/**
39 46
 			 * @var $object Propal
40 47
 			 */
41
-			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);
48
+			else if($object->element=='propal') {
49
+				$res = $object->addline($desc, 0,$qty,0,0,0,0,0,'HT',0,0,9,$rang, TSubtotal::$module_number, 0, 0, 0, $label);
50
+			}
42 51
 			/**
43 52
 			 * @var $object Commande
44 53
 			 */
45
-			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);
54
+			else if($object->element=='commande') {
55
+				$res =  $object->addline($desc, 0,$qty,0,0,0,0,0,0,0,'HT',0,'','',9,$rang, TSubtotal::$module_number, 0, null, 0, $label);
56
+			}
46 57
 			/**
47 58
 			 * @var $object Facturerec
48 59
 			 */
49
-			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); 
60
+			else if($object->element=='facturerec') {
61
+				$res =  $object->addline($desc, 0,$qty, 0, 0, 0, 0, 0, 'HT', 0, '', 0, 9, $rang, TSubtotal::$module_number,$label);
62
+			}
50 63
 			
51 64
 		}
52 65
 	
@@ -68,8 +81,9 @@  discard block
 block discarded – undo
68 81
 			// Define output language
69 82
 			$outputlangs = $langs;
70 83
 			$newlang = GETPOST('lang_id', 'alpha');
71
-			if (! empty($conf->global->MAIN_MULTILANGS) && empty($newlang))
72
-				$newlang = !empty($object->client) ? $object->client->default_lang : $object->thirdparty->default_lang;
84
+			if (! empty($conf->global->MAIN_MULTILANGS) && empty($newlang)) {
85
+							$newlang = !empty($object->client) ? $object->client->default_lang : $object->thirdparty->default_lang;
86
+			}
73 87
 			if (! empty($newlang)) {
74 88
 				$outputlangs = new Translate("", $conf);
75 89
 				$outputlangs->setDefaultLang($newlang);
@@ -78,13 +92,18 @@  discard block
 block discarded – undo
78 92
 			$ret = $object->fetch($object->id); // Reload to get new records
79 93
 			if ((float) DOL_VERSION <= 3.6)
80 94
 			{
81
-				if ($object->element == 'propal') propale_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
82
-				elseif ($object->element == 'commande') commande_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
83
-				elseif ($object->element == 'facture') facture_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
84
-			}
85
-			else
95
+				if ($object->element == 'propal') {
96
+					propale_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
97
+				} elseif ($object->element == 'commande') {
98
+					commande_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
99
+				} elseif ($object->element == 'facture') {
100
+					facture_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
101
+				}
102
+			} else
86 103
 			{
87
-				if ($object->element!= 'facturerec') $object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
104
+				if ($object->element!= 'facturerec') {
105
+					$object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
106
+				}
88 107
 			}
89 108
 		}
90 109
 	}
@@ -98,7 +117,9 @@  discard block
 block discarded – undo
98 117
 	 */
99 118
 	public static function updateRang(&$object, $rang_start, $move_to=1)
100 119
 	{
101
-		if (!class_exists('GenericObject')) require_once DOL_DOCUMENT_ROOT.'/core/class/genericobject.class.php';
120
+		if (!class_exists('GenericObject')) {
121
+			require_once DOL_DOCUMENT_ROOT.'/core/class/genericobject.class.php';
122
+		}
102 123
 		
103 124
 		$row=new GenericObject($object->db);
104 125
 		$row->table_element_line = $object->table_element_line;
@@ -107,7 +128,9 @@  discard block
 block discarded – undo
107 128
 		
108 129
 		foreach ($object->lines as &$line)
109 130
 		{
110
-			if ($line->rang < $rang_start) continue;
131
+			if ($line->rang < $rang_start) {
132
+				continue;
133
+			}
111 134
 			
112 135
 			$row->updateRangOfLine($line->id, $line->rang+$move_to);
113 136
 		}
@@ -130,21 +153,28 @@  discard block
 block discarded – undo
130 153
 		foreach ($TTitle_reverse as $k => $title_line)
131 154
 		{
132 155
 			$title_niveau = self::getNiveau($title_line);
133
-			if ($title_niveau < $level_new_title) break;
156
+			if ($title_niveau < $level_new_title) {
157
+				break;
158
+			}
134 159
 			
135 160
 			$rang_to_add = self::titleHasTotalLine($object, $title_line, true, true);
136 161
 			
137 162
 			if (is_numeric($rang_to_add)) 
138 163
 			{
139
-				if ($rang_to_add != -1) self::updateRang($object, $rang_to_add);
164
+				if ($rang_to_add != -1) {
165
+					self::updateRang($object, $rang_to_add);
166
+				}
140 167
 				
141 168
 				self::addSubTotalLine($object, $langs->trans('SubTotal'), 100-$title_niveau, $rang_to_add);
142 169
 				
143 170
 				$object->lines[] = $object->line; // ajout de la ligne dans le tableau de ligne (Dolibarr ne le fait pas)
144 171
 				if ($rang_to_add != -1) 
145 172
 				{
146
-					if (method_exists($object, 'fetch_lines')) $object->fetch_lines();
147
-					else $object->fetch($object->id);
173
+					if (method_exists($object, 'fetch_lines')) {
174
+						$object->fetch_lines();
175
+					} else {
176
+						$object->fetch($object->id);
177
+					}
148 178
 				}
149 179
 			}
150 180
 		}
@@ -174,7 +204,9 @@  discard block
 block discarded – undo
174 204
 		
175 205
 		foreach ($TTitle as $k => $title_line)
176 206
 		{
177
-			if (self::titleHasTotalLine($object, $title_line)) unset($TTitle[$k]);
207
+			if (self::titleHasTotalLine($object, $title_line)) {
208
+				unset($TTitle[$k]);
209
+			}
178 210
 		}
179 211
 		
180 212
 		return $TTitle;
@@ -191,23 +223,41 @@  discard block
 block discarded – undo
191 223
 	 */
192 224
 	public static function titleHasTotalLine(&$object, &$title_line, $strict_mode=false, $return_rang_on_false=false)
193 225
 	{
194
-		if (empty($object->lines) || !is_array($object->lines)) return false;
226
+		if (empty($object->lines) || !is_array($object->lines)) {
227
+			return false;
228
+		}
195 229
 		
196 230
 		$title_niveau = self::getNiveau($title_line);
197 231
 		foreach ($object->lines as &$line)
198 232
 		{
199
-			if ($line->rang <= $title_line->rang) continue;
200
-			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
201
-			if (!self::isSubtotal($line)) continue;
233
+			if ($line->rang <= $title_line->rang) {
234
+				continue;
235
+			}
236
+			if (self::isTitle($line) && self::getNiveau($line) <= $title_niveau) {
237
+				return false;
238
+			}
239
+			// 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
240
+			if (!self::isSubtotal($line)) {
241
+				continue;
242
+			}
202 243
 			
203 244
 			$subtotal_niveau = self::getNiveau($line);
204 245
 			
205 246
 			// Comparaison du niveau de la ligne de sous-total avec celui du titre
206
-			if ($subtotal_niveau == $title_niveau) return true; // niveau égale => Ok mon titre a un sous-total
207
-			elseif ($subtotal_niveau < $title_niveau) // niveau inférieur trouvé (exemple : sous-total de niveau 1 contre mon titre de niveau 3)
247
+			if ($subtotal_niveau == $title_niveau) {
248
+				return true;
249
+			}
250
+			// niveau égale => Ok mon titre a un sous-total
251
+			elseif ($subtotal_niveau < $title_niveau) {
252
+				// niveau inférieur trouvé (exemple : sous-total de niveau 1 contre mon titre de niveau 3)
208 253
 			{
209
-				if ($strict_mode) return ($return_rang_on_false) ? $line->rang : false; // mode strict niveau pas égale donc faux
210
-				else return true; // mode libre => OK je considère que mon titre à un sous-total
254
+				if ($strict_mode) return ($return_rang_on_false) ? $line->rang : false;
255
+			}
256
+			// mode strict niveau pas égale donc faux
257
+				else {
258
+					return true;
259
+				}
260
+				// mode libre => OK je considère que mon titre à un sous-total
211 261
 			}
212 262
 		}
213 263
 		
@@ -255,16 +305,19 @@  discard block
 block discarded – undo
255 305
 		
256 306
 		foreach ($object->lines as &$l)
257 307
 		{
258
-			if ($l->rang <= $line->rang) continue;
259
-			elseif (self::isSubtotal($l) && self::getNiveau($l) == $line->qty) break;
260
-			elseif (self::isModSubtotalLine($l)) continue;
308
+			if ($l->rang <= $line->rang) {
309
+				continue;
310
+			} elseif (self::isSubtotal($l) && self::getNiveau($l) == $line->qty) {
311
+				break;
312
+			} elseif (self::isModSubtotalLine($l)) {
313
+				continue;
314
+			}
261 315
 			
262 316
 			if (!empty($l->array_options['options_subtotal_nc']))
263 317
 			{
264 318
 				$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);
265 319
 				$TTot['total_options'] += $tabprice[0]; // total ht
266
-			}
267
-			else
320
+			} else
268 321
 			{
269 322
 				$TTot['total_pa_ht'] += $l->pa_ht * $l->qty;
270 323
 				$TTot['total_ht'] += $l->total_ht;
@@ -283,29 +336,41 @@  discard block
 block discarded – undo
283 336
 
284 337
 	public static function getOrderIdFromLineId(&$db, $fk_commandedet)
285 338
 	{
286
-		if (empty($fk_commandedet)) return false;
339
+		if (empty($fk_commandedet)) {
340
+			return false;
341
+		}
287 342
 		
288 343
 		$sql = 'SELECT fk_commande FROM '.MAIN_DB_PREFIX.'commandedet WHERE rowid = '.$fk_commandedet;
289 344
 		$resql = $db->query($sql);
290 345
 		
291
-		if ($resql && ($row = $db->fetch_object($resql))) return $row->fk_commande;
292
-		else return false;
346
+		if ($resql && ($row = $db->fetch_object($resql))) {
347
+			return $row->fk_commande;
348
+		} else {
349
+			return false;
350
+		}
293 351
 	}
294 352
 	
295 353
 	public static function getLastLineOrderId(&$db, $fk_commande)
296 354
 	{
297
-		if (empty($fk_commande)) return false;
355
+		if (empty($fk_commande)) {
356
+			return false;
357
+		}
298 358
 		
299 359
 		$sql = 'SELECT rowid FROM '.MAIN_DB_PREFIX.'commandedet WHERE fk_commande = '.$fk_commande.' ORDER BY rang DESC LIMIT 1';
300 360
 		$resql = $db->query($sql);
301 361
 		
302
-		if ($resql && ($row = $db->fetch_object($resql))) return $row->rowid;
303
-		else return false;
362
+		if ($resql && ($row = $db->fetch_object($resql))) {
363
+			return $row->rowid;
364
+		} else {
365
+			return false;
366
+		}
304 367
 	}
305 368
 	
306 369
 	public static function getParentTitleOfLine(&$object, $i)
307 370
 	{
308
-		if ($i <= 0) return false;
371
+		if ($i <= 0) {
372
+			return false;
373
+		}
309 374
 		
310 375
 		$skip_title = 0;
311 376
 		// Je parcours les lignes précédentes
@@ -324,8 +389,7 @@  discard block
 block discarded – undo
324 389
 				//@INFO J'ai ma ligne titre qui contient ma ligne, par contre je check pas s'il y a un sous-total
325 390
 				return $line;
326 391
 				break;
327
-			}
328
-			elseif ($line->product_type == 9 && $line->qty >= 90 && $line->qty <= 99)
392
+			} elseif ($line->product_type == 9 && $line->qty >= 90 && $line->qty <= 99)
329 393
 			{
330 394
 				// 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)
331 395
 				$skip_title++;
@@ -340,7 +404,9 @@  discard block
 block discarded – undo
340 404
 		$res = $line->special_code == self::$module_number && $line->product_type == 9 && $line->qty <= 9;
341 405
 		if($res && $level > -1) {
342 406
 			return $line->qty == $level;
343
-		} else return $res;
407
+		} else {
408
+			return $res;
409
+		}
344 410
 		
345 411
 	}
346 412
 	
@@ -367,10 +433,14 @@  discard block
 block discarded – undo
367 433
 		// editeur wysiwyg
368 434
 		require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
369 435
 		$nbrows=ROWS_2;
370
-		if (! empty($conf->global->MAIN_INPUT_DESC_HEIGHT)) $nbrows=$conf->global->MAIN_INPUT_DESC_HEIGHT;
436
+		if (! empty($conf->global->MAIN_INPUT_DESC_HEIGHT)) {
437
+			$nbrows=$conf->global->MAIN_INPUT_DESC_HEIGHT;
438
+		}
371 439
 		$enable=(isset($conf->global->FCKEDITOR_ENABLE_DETAILS)?$conf->global->FCKEDITOR_ENABLE_DETAILS:0);
372 440
 		$toolbarname='dolibarr_details';
373
-		if (! empty($conf->global->FCKEDITOR_ENABLE_DETAILS_FULL)) $toolbarname='dolibarr_notes';
441
+		if (! empty($conf->global->FCKEDITOR_ENABLE_DETAILS_FULL)) {
442
+			$toolbarname='dolibarr_notes';
443
+		}
374 444
 		$text = !empty($line->description)?$line->description:$line->label;
375 445
 		$doleditor=new DolEditor('line-description',$text,'',164,$toolbarname,'',false,true,$enable,$nbrows,'98%', $readonly);
376 446
 		return $doleditor->Create(1);
@@ -416,8 +486,9 @@  discard block
 block discarded – undo
416 486
 
417 487
 					$TLineAdded[] = $object->line;
418 488
 					// Error from addline
419
-					if ($res <= 0) break;
420
-					else
489
+					if ($res <= 0) {
490
+						break;
491
+					} else
421 492
 					{
422 493
 						$object->line_from = $line;
423 494
 						// Call trigger
@@ -440,8 +511,7 @@  discard block
 block discarded – undo
440 511
 				{
441 512
 					$object->db->commit();
442 513
 					return count($TLine);
443
-				}
444
-				else
514
+				} else
445 515
 				{
446 516
 					$object->db->rollback();
447 517
 					return -1;
@@ -457,10 +527,14 @@  discard block
 block discarded – undo
457 527
 		global $langs;
458 528
 		
459 529
 		// Besoin de comparer sur les 2 formes d'écriture
460
-		if (!$key_is_id) $TTitle_search = array($langs->trans($key_trad), $langs->transnoentitiesnoconv($key_trad));
530
+		if (!$key_is_id) {
531
+			$TTitle_search = array($langs->trans($key_trad), $langs->transnoentitiesnoconv($key_trad));
532
+		}
461 533
 		
462 534
 		$TTitle_under_search = array();
463
-		if (!empty($under_title)) $TTitle_under_search = array($langs->trans($under_title), $langs->transnoentitiesnoconv($under_title));
535
+		if (!empty($under_title)) {
536
+			$TTitle_under_search = array($langs->trans($under_title), $langs->transnoentitiesnoconv($under_title));
537
+		}
464 538
 		
465 539
 		$TLine = array();
466 540
 		$add_line = false;
@@ -470,28 +544,37 @@  discard block
 block discarded – undo
470 544
 		{
471 545
 			if (!$under_title_found && !empty($TTitle_under_search))
472 546
 			{
473
-				if ($line->product_type == 9 && (in_array($line->desc, $TTitle_under_search) || in_array($line->label, $TTitle_under_search)) ) $under_title_found = true;
474
-			}
475
-			else
547
+				if ($line->product_type == 9 && (in_array($line->desc, $TTitle_under_search) || in_array($line->label, $TTitle_under_search)) ) {
548
+					$under_title_found = true;
549
+				}
550
+			} else
476 551
 			{
477 552
 				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) )))
478 553
 				{
479
-					if ($key_is_id) $level = $line->qty;
554
+					if ($key_is_id) {
555
+						$level = $line->qty;
556
+					}
480 557
 					
481 558
 					$add_line = true;
482
-					if ($withBlockLine) $TLine[] = $line;
559
+					if ($withBlockLine) {
560
+						$TLine[] = $line;
561
+					}
483 562
 					continue;
484
-				}
485
-				elseif ($add_line && $line->product_type == 9 && (100 - $line->qty == $level) ) // Si on tombe sur un sous-total, il faut que ce soit un du même niveau que le titre
563
+				} elseif ($add_line && $line->product_type == 9 && (100 - $line->qty == $level) ) {
564
+					// Si on tombe sur un sous-total, il faut que ce soit un du même niveau que le titre
486 565
 				{
487 566
 					if ($withBlockLine) $TLine[] = $line;
567
+				}
488 568
 					break;
489 569
 				}
490 570
 				
491 571
 				if ($add_line)
492 572
 				{
493
-					if (!$withBlockLine && (self::isTitle($line) || self::isSubtotal($line)) ) continue;
494
-					else $TLine[] = $line;
573
+					if (!$withBlockLine && (self::isTitle($line) || self::isSubtotal($line)) ) {
574
+						continue;
575
+					} else {
576
+						$TLine[] = $line;
577
+					}
495 578
 				}
496 579
 			}
497 580
 		}
@@ -536,8 +619,11 @@  discard block
 block discarded – undo
536 619
 				break;
537 620
 		}
538 621
 		
539
-		if ($res <= 0) $object->db->rollback();
540
-		else $object->db->commit();
622
+		if ($res <= 0) {
623
+			$object->db->rollback();
624
+		} else {
625
+			$object->db->commit();
626
+		}
541 627
 		
542 628
 		return $res;
543 629
 	}
@@ -551,18 +637,15 @@  discard block
 block discarded – undo
551 637
 		{
552 638
 			$object = new Propal($db);
553 639
 			$object->fetch($origin_line->fk_propal);
554
-		}
555
-		else if ($origin_line->element == 'commandedet')
640
+		} else if ($origin_line->element == 'commandedet')
556 641
 		{
557 642
 			$object = new Commande($db);
558 643
 			$object->fetch($origin_line->fk_commande);
559
-		}
560
-		else if ($origin_line->element == 'facturedet')
644
+		} else if ($origin_line->element == 'facturedet')
561 645
 		{
562 646
 			$object = new Facture($db);
563 647
 			$object->fetch($origin_line->fk_facture);
564
-		}
565
-		else
648
+		} else
566 649
 		{
567 650
 			return $TTitle;
568 651
 		}
@@ -571,8 +654,11 @@  discard block
 block discarded – undo
571 654
 		$i = 0;
572 655
 		foreach ($object->lines as &$line)
573 656
 		{
574
-			if ($origin_line->id == $line->id) break;
575
-			else $i++;
657
+			if ($origin_line->id == $line->id) {
658
+				break;
659
+			} else {
660
+				$i++;
661
+			}
576 662
 		}
577 663
 		
578 664
 		$i--; // Skip la ligne d'origine
@@ -587,35 +673,43 @@  discard block
 block discarded – undo
587 673
 				if (self::isSubtotal($object->lines[$y]))
588 674
 				{
589 675
 					$next_title_lvl_to_skip = self::getNiveau($object->lines[$y]);
590
-				}
591
-				elseif (self::isTitle($object->lines[$y]))
676
+				} elseif (self::isTitle($object->lines[$y]))
592 677
 				{
593 678
 					if ($object->lines[$y]->qty == $next_title_lvl_to_skip)
594 679
 					{
595 680
 						$next_title_lvl_to_skip = 0;
596 681
 						continue;
597
-					}
598
-					else
682
+					} else
599 683
 					{
600
-						if (empty($object->lines[$y]->array_options)) $object->lines[$y]->fetch_optionals();
684
+						if (empty($object->lines[$y]->array_options)) {
685
+							$object->lines[$y]->fetch_optionals();
686
+						}
601 687
 						$TTitle[$object->lines[$y]->id] = $object->lines[$y];
602 688
 						
603
-						if ($object->lines[$y]->qty == 1) break;
689
+						if ($object->lines[$y]->qty == 1) {
690
+							break;
691
+						}
604 692
 					}
605 693
 				}
606 694
 			}
607 695
 		}
608 696
 		
609
-		if ($reverse) $TTitle = array_reverse($TTitle, true);
697
+		if ($reverse) {
698
+			$TTitle = array_reverse($TTitle, true);
699
+		}
610 700
 		
611 701
 		return $TTitle;
612 702
 	}
613 703
 	
614 704
 	public static function getNiveau(&$line)
615 705
 	{
616
-		if (self::isTitle($line)) return $line->qty;
617
-		elseif (self::isSubtotal($line)) return 100 - $line->qty;
618
-		else return 0;
706
+		if (self::isTitle($line)) {
707
+			return $line->qty;
708
+		} elseif (self::isSubtotal($line)) {
709
+			return 100 - $line->qty;
710
+		} else {
711
+			return 0;
712
+		}
619 713
 	}
620 714
 	
621 715
 	/**
@@ -640,10 +734,16 @@  discard block
 block discarded – undo
640 734
 		$objmarge->marge_droite = 10;
641 735
 		
642 736
 		$objectref = dol_sanitizeFileName($object->ref);
643
-		if ($object->element == 'propal') $dir = $conf->propal->dir_output . '/' . $objectref;
644
-		elseif ($object->element == 'commande') $dir = $conf->commande->dir_output . '/' . $objectref;
645
-		elseif ($object->element == 'facture') $dir = $conf->facture->dir_output . '/' . $objectref;
646
-		elseif ($object->element == 'facturerec') return; // no PDF for facturerec
737
+		if ($object->element == 'propal') {
738
+			$dir = $conf->propal->dir_output . '/' . $objectref;
739
+		} elseif ($object->element == 'commande') {
740
+			$dir = $conf->commande->dir_output . '/' . $objectref;
741
+		} elseif ($object->element == 'facture') {
742
+			$dir = $conf->facture->dir_output . '/' . $objectref;
743
+		} elseif ($object->element == 'facturerec') {
744
+			return;
745
+		}
746
+		// no PDF for facturerec
647 747
 		else
648 748
 		{
649 749
 			setEventMessage($langs->trans('warning_subtotal_recap_object_element_unknown', $object->element), 'warnings');
@@ -678,7 +778,9 @@  discard block
 block discarded – undo
678 778
 		$pdf->SetCreator("Dolibarr ".DOL_VERSION);
679 779
 		$pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
680 780
 		$pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("subtotalRecap")." ".$outputlangs->convToOutputCharset($object->thirdparty->name));
681
-		if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
781
+		if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) {
782
+			$pdf->SetCompression(false);
783
+		}
682 784
 
683 785
 		$pdf->SetMargins($objmarge->marge_gauche, $objmarge->marge_haute, $objmarge->marge_droite);   // Left, Top, Right
684 786
 
@@ -688,7 +790,9 @@  discard block
 block discarded – undo
688 790
 			
689 791
 		// New page
690 792
 		$pdf->AddPage();
691
-		if (! empty($tplidx)) $pdf->useTemplate($tplidx);
793
+		if (! empty($tplidx)) {
794
+			$pdf->useTemplate($tplidx);
795
+		}
692 796
 		$pagenb++;
693 797
 		
694 798
 		
@@ -744,8 +848,10 @@  discard block
 block discarded – undo
744 848
 					{
745 849
 						$TTot['TTotal_tva_multicurrency'][$tx] += $amount;
746 850
 					}	
851
+				} else {
852
+					$pdf->SetFont('','', $default_font_size - 1);
747 853
 				}
748
-				else $pdf->SetFont('','', $default_font_size - 1);   // Into loop to work with multipage
854
+				// Into loop to work with multipage
749 855
 				
750 856
 				$pdf->SetTextColor(0,0,0);
751 857
 				
@@ -767,9 +873,11 @@  discard block
 block discarded – undo
767 873
 				$pdf->startTransaction();
768 874
 				$pdf->writeHTMLCell($posx_options-$posx_designation-$decalage, 3, $posx_designation+$decalage, $curY, $outputlangs->convToOutputCharset($label), 0, 1, false, true, 'J',true);
769 875
 				$pageposafter=$pdf->getPage();
770
-				if ($pageposafter > $pageposbefore)	// There is a pagebreak
876
+				if ($pageposafter > $pageposbefore) {
877
+					// There is a pagebreak
771 878
 				{
772 879
 					$pdf->rollbackTransaction(true);
880
+				}
773 881
 					$pageposafter=$pageposbefore;
774 882
 					//print $pageposafter.'-'.$pageposbefore;exit;
775 883
 					$pdf->setPageOrientation('', 1, $heightforfooter);	// The only function to edit the bottom margin of current page to set it.
@@ -778,23 +886,27 @@  discard block
 block discarded – undo
778 886
 					$pageposafter=$pdf->getPage();
779 887
 					$posyafter=$pdf->GetY();
780 888
 					//var_dump($posyafter); var_dump(($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))); exit;
781
-					if ($posyafter > ($objmarge->page_hauteur - ($heightforfooter+$heightforinfotot)))	// There is no space left for total+free text
889
+					if ($posyafter > ($objmarge->page_hauteur - ($heightforfooter+$heightforinfotot))) {
890
+						// There is no space left for total+free text
782 891
 					{
783 892
 						if ($i == ($nblignes-1))	// No more lines, and no space left to show total, so we create a new page
784 893
 						{
785 894
 							$pdf->AddPage('','',true);
786
-							if (! empty($tplidx)) $pdf->useTemplate($tplidx);
787
-							if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) self::pagehead($objmarge, $pdf, $object, 0, $outputlangs);
895
+					}
896
+							if (! empty($tplidx)) {
897
+								$pdf->useTemplate($tplidx);
898
+							}
899
+							if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) {
900
+								self::pagehead($objmarge, $pdf, $object, 0, $outputlangs);
901
+							}
788 902
 							$pdf->setPage($pageposafter+1);
789 903
 						}
790
-					}
791
-					else
904
+					} else
792 905
 					{
793 906
 						// We found a page break
794 907
 						$showpricebeforepagebreak=0;
795 908
 					}
796
-				}
797
-				else	// No pagebreak
909
+				} else	// No pagebreak
798 910
 				{
799 911
 					$pdf->commitTransaction();
800 912
 				}
@@ -834,8 +946,7 @@  discard block
 block discarded – undo
834 946
 					if ($pagenb == 1)
835 947
 					{
836 948
 						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);
837
-					}
838
-					else
949
+					} else
839 950
 					{
840 951
 						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);
841 952
 					}
@@ -843,7 +954,9 @@  discard block
 block discarded – undo
843 954
 					$pagenb++;
844 955
 					$pdf->setPage($pagenb);
845 956
 					$pdf->setPageOrientation('', 1, 0);	// The only function to edit the bottom margin of current page to set it.
846
-					if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) self::pagehead($objmarge, $pdf, $object, 0, $outputlangs);
957
+					if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) {
958
+						self::pagehead($objmarge, $pdf, $object, 0, $outputlangs);
959
+					}
847 960
 				}
848 961
 			}
849 962
 		}
@@ -853,8 +966,7 @@  discard block
 block discarded – undo
853 966
 		{
854 967
 			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);
855 968
 			$bottomlasttab=$objmarge->page_hauteur - $heightforinfotot - $heightforfooter + 1;
856
-		}
857
-		else
969
+		} else
858 970
 		{
859 971
 			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);
860 972
 			$bottomlasttab=$objmarge->page_hauteur - $heightforinfotot - $heightforfooter + 1;
@@ -868,7 +980,9 @@  discard block
 block discarded – undo
868 980
 		
869 981
 		$pagecount = self::concat($outputlangs, array($origin_file, $file), $origin_file);
870 982
 		
871
-		if (empty($conf->global->SUBTOTAL_KEEP_RECAP_FILE)) unlink($file);
983
+		if (empty($conf->global->SUBTOTAL_KEEP_RECAP_FILE)) {
984
+			unlink($file);
985
+		}
872 986
 	}
873 987
 	
874 988
 	private static function printLevel($objmarge, $pdf, $line, $curY, $posx_designation)
@@ -911,8 +1025,7 @@  discard block
 block discarded – undo
911 1025
 			{
912 1026
 			    $height=pdf_getHeightForLogo($logo);
913 1027
 			    $pdf->Image($logo, $objmarge->marge_gauche, $posy, 0, $height);	// width=0 (auto)
914
-			}
915
-			else
1028
+			} else
916 1029
 			{
917 1030
 				$pdf->SetTextColor(200,0,0);
918 1031
 				$pdf->SetFont('','B',$default_font_size - 2);
@@ -921,8 +1034,7 @@  discard block
 block discarded – undo
921 1034
 			}
922 1035
 			
923 1036
 			$posy+=35;
924
-		}
925
-		else
1037
+		} else
926 1038
 		{
927 1039
 			$text=$mysoc->name;
928 1040
 			$pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0, 'L');
@@ -936,9 +1048,13 @@  discard block
 block discarded – undo
936 1048
 		$pdf->SetXY($objmarge->marge_gauche,$posy);
937 1049
 		
938 1050
 		$key = 'subtotalPropalTitle';
939
-		if ($object->element == 'commande') $key = 'subtotalCommandeTitle';
940
-		elseif ($object->element == 'facture') $key = 'subtotalInvoiceTitle';
941
-		elseif ($object->element == 'facturerec') $key = 'subtotalInvoiceTitle';
1051
+		if ($object->element == 'commande') {
1052
+			$key = 'subtotalCommandeTitle';
1053
+		} elseif ($object->element == 'facture') {
1054
+			$key = 'subtotalInvoiceTitle';
1055
+		} elseif ($object->element == 'facturerec') {
1056
+			$key = 'subtotalInvoiceTitle';
1057
+		}
942 1058
 		
943 1059
 		$pdf->MultiCell(150, 4, $outputlangs->transnoentities($key, $object->ref, $object->thirdparty->name), '', 'L');
944 1060
 		
@@ -973,7 +1089,9 @@  discard block
 block discarded – undo
973 1089
 		
974 1090
 		// Force to disable hidetop and hidebottom
975 1091
 		$hidebottom=0;
976
-		if ($hidetop) $hidetop=-1;
1092
+		if ($hidetop) {
1093
+			$hidetop=-1;
1094
+		}
977 1095
 
978 1096
 		$currency = !empty($currency) ? $currency : $conf->currency;
979 1097
 		$default_font_size = pdf_getPDFFontSize($outputlangs);
@@ -988,7 +1106,9 @@  discard block
 block discarded – undo
988 1106
 			$pdf->SetXY($objmarge->page_largeur - $objmarge->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top-4.5);
989 1107
 			$pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre);
990 1108
 			
991
-			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));
1109
+			if (! empty($conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)) {
1110
+				$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));
1111
+			}
992 1112
 			
993 1113
 			
994 1114
 			$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
@@ -1001,8 +1121,7 @@  discard block
 block discarded – undo
1001 1121
 			$pdf->MultiCell($objmarge->page_largeur - $objmarge->marge_droite - $posx_montant,2, $outputlangs->transnoentities("Amount"),'','R');
1002 1122
 			
1003 1123
 			$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
1004
-		}
1005
-		else
1124
+		} else
1006 1125
 		{
1007 1126
 			$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
1008 1127
 		}
@@ -1023,10 +1142,12 @@  discard block
 block discarded – undo
1023 1142
 
1024 1143
 		// Tableau total
1025 1144
 		$col1x = 120; $col2x = 170;
1026
-		if ($objmarge->page_largeur < 210) // To work with US executive format
1145
+		if ($objmarge->page_largeur < 210) {
1146
+			// To work with US executive format
1027 1147
 		{
1028 1148
 			$col2x-=20;
1029 1149
 		}
1150
+		}
1030 1151
 		$largcol2 = ($objmarge->page_largeur - $objmarge->marge_droite - $col2x);
1031 1152
 
1032 1153
 		$useborder=0;
@@ -1048,9 +1169,11 @@  discard block
 block discarded – undo
1048 1169
 		$atleastoneratenotnull=0;
1049 1170
 		foreach($TTot['TTotal_tva'] as $tvakey => $tvaval)
1050 1171
 		{
1051
-			if ($tvakey != 0)    // On affiche pas taux 0
1172
+			if ($tvakey != 0) {
1173
+				// On affiche pas taux 0
1052 1174
 			{
1053 1175
 				$atleastoneratenotnull++;
1176
+			}
1054 1177
 
1055 1178
 				$index++;
1056 1179
 				$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
@@ -1103,9 +1226,13 @@  discard block
 block discarded – undo
1103 1226
 	 */
1104 1227
     private static function printRect($pdf, $x, $y, $l, $h, $hidetop=0, $hidebottom=0)
1105 1228
     {
1106
-	    if (empty($hidetop) || $hidetop==-1) $pdf->line($x, $y, $x+$l, $y);
1229
+	    if (empty($hidetop) || $hidetop==-1) {
1230
+	    	$pdf->line($x, $y, $x+$l, $y);
1231
+	    }
1107 1232
 	    $pdf->line($x+$l, $y, $x+$l, $y+$h);
1108
-	    if (empty($hidebottom)) $pdf->line($x+$l, $y+$h, $x, $y+$h);
1233
+	    if (empty($hidebottom)) {
1234
+	    	$pdf->line($x+$l, $y+$h, $x, $y+$h);
1235
+	    }
1109 1236
 	    $pdf->line($x, $y+$h, $x, $y);
1110 1237
     }
1111 1238
 	
@@ -1114,7 +1241,9 @@  discard block
 block discarded – undo
1114 1241
 	{
1115 1242
 		global $conf;
1116 1243
 		
1117
-		if (empty($fileoutput)) $fileoutput = $file[0];
1244
+		if (empty($fileoutput)) {
1245
+			$fileoutput = $file[0];
1246
+		}
1118 1247
 		
1119 1248
 		$pdf=pdf_getInstance();
1120 1249
         if (class_exists('TCPDF'))
@@ -1124,7 +1253,9 @@  discard block
 block discarded – undo
1124 1253
         }
1125 1254
         $pdf->SetFont(pdf_getPDFFont($outputlangs));
1126 1255
 
1127
-        if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
1256
+        if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) {
1257
+        	$pdf->SetCompression(false);
1258
+        }
1128 1259
 
1129 1260
 		
1130 1261
 		foreach($files as $file)
@@ -1140,7 +1271,9 @@  discard block
 block discarded – undo
1140 1271
 		}
1141 1272
 		
1142 1273
 		$pdf->Output($fileoutput,'F');
1143
-		if (! empty($conf->global->MAIN_UMASK)) @chmod($file, octdec($conf->global->MAIN_UMASK));
1274
+		if (! empty($conf->global->MAIN_UMASK)) {
1275
+			@chmod($file, octdec($conf->global->MAIN_UMASK));
1276
+		}
1144 1277
 
1145 1278
 		return $pagecount;
1146 1279
 	}
@@ -1174,7 +1307,9 @@  discard block
 block discarded – undo
1174 1307
 	public static function getTitleLabel($line)
1175 1308
 	{
1176 1309
 		$title = $line->label;
1177
-		if (empty($title)) $title = !empty($line->description) ? $line->description : $line->desc;
1310
+		if (empty($title)) {
1311
+			$title = !empty($line->description) ? $line->description : $line->desc;
1312
+		}
1178 1313
 		return $title;
1179 1314
 	}
1180 1315
 }
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,8 +1,8 @@
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 		
4
-	if(is_file('../main.inc.php'))$dir = '../';
5
-	else  if(is_file('../../../main.inc.php'))$dir = '../../../';
4
+	if (is_file('../main.inc.php'))$dir = '../';
5
+	else  if (is_file('../../../main.inc.php'))$dir = '../../../';
6 6
 	else $dir = '../../';
7 7
 
8 8
 	include($dir."main.inc.php");
Please login to merge, or discard this patch.
Braces   +7 added lines, -3 removed lines patch added patch discarded remove patch
@@ -1,8 +1,12 @@
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 		
4
-	if(is_file('../main.inc.php'))$dir = '../';
5
-	else  if(is_file('../../../main.inc.php'))$dir = '../../../';
6
-	else $dir = '../../';
4
+	if(is_file('../main.inc.php')) {
5
+		$dir = '../';
6
+	} else  if(is_file('../../../main.inc.php')) {
7
+		$dir = '../../../';
8
+	} else {
9
+		$dir = '../../';
10
+	}
7 11
 
8 12
 	include($dir."main.inc.php");
Please login to merge, or discard this patch.
script/import-from-milestone.php 2 patches
Indentation   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -56,33 +56,33 @@
 block discarded – undo
56 56
 	}
57 57
 
58 58
 
59
-        $res = $db->query("SELECT DISTINCT(fk_facture) as fk_facture FROM ".MAIN_DB_PREFIX."facturedet WHERE special_code=104777");
60
-        while($obj = $db->fetch_object($res)) {
61
-                $resLine = $db->query("SELECT rowid FROM  ".MAIN_DB_PREFIX."facturedet WHERE fk_facture=".$obj->fk_propal." ORDER BY rang ");
62
-                $k = 1;
63
-                while($objLine = $db->fetch_object($resLine)) {
59
+		$res = $db->query("SELECT DISTINCT(fk_facture) as fk_facture FROM ".MAIN_DB_PREFIX."facturedet WHERE special_code=104777");
60
+		while($obj = $db->fetch_object($res)) {
61
+				$resLine = $db->query("SELECT rowid FROM  ".MAIN_DB_PREFIX."facturedet WHERE fk_facture=".$obj->fk_propal." ORDER BY rang ");
62
+				$k = 1;
63
+				while($objLine = $db->fetch_object($resLine)) {
64 64
 
65
-                        $sql="UPDATE ".MAIN_DB_PREFIX."facturedet SET rang=".$k.",fk_parent_line=NULL WHERE rowid=".$objLine->rowid;
65
+						$sql="UPDATE ".MAIN_DB_PREFIX."facturedet SET rang=".$k.",fk_parent_line=NULL WHERE rowid=".$objLine->rowid;
66 66
 
67
-                         print $sql.";<br />";
68
-                        $k++;
69
-                }
67
+						 print $sql.";<br />";
68
+						$k++;
69
+				}
70 70
 
71
-        }
71
+		}
72 72
 
73
-        $res = $db->query("SELECT DISTINCT(fk_commande) as fk_commande FROM ".MAIN_DB_PREFIX."commandedet WHERE special_code=104777");
74
-        while($obj = $db->fetch_object($res)) {
75
-                $resLine = $db->query("SELECT rowid FROM  ".MAIN_DB_PREFIX."commandedet WHERE fk_commande=".$obj->fk_propal." ORDER BY rang ");
76
-                $k = 1;
77
-                while($objLine = $db->fetch_object($resLine)) {
73
+		$res = $db->query("SELECT DISTINCT(fk_commande) as fk_commande FROM ".MAIN_DB_PREFIX."commandedet WHERE special_code=104777");
74
+		while($obj = $db->fetch_object($res)) {
75
+				$resLine = $db->query("SELECT rowid FROM  ".MAIN_DB_PREFIX."commandedet WHERE fk_commande=".$obj->fk_propal." ORDER BY rang ");
76
+				$k = 1;
77
+				while($objLine = $db->fetch_object($resLine)) {
78 78
 
79
-                        $sql="UPDATE ".MAIN_DB_PREFIX."commandedet SET rang=".$k.",fk_parent_line=NULL WHERE rowid=".$objLine->rowid;
79
+						$sql="UPDATE ".MAIN_DB_PREFIX."commandedet SET rang=".$k.",fk_parent_line=NULL WHERE rowid=".$objLine->rowid;
80 80
 
81
-                         print $sql.";<br />";
82
-                        $k++;
83
-                }
81
+						 print $sql.";<br />";
82
+						$k++;
83
+				}
84 84
 
85
-        }
85
+		}
86 86
 
87 87
 
88 88
 	 print $sql.";<br />";
Please login to merge, or discard this patch.
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -42,12 +42,12 @@  discard block
 block discarded – undo
42 42
 
43 43
 
44 44
 	$res = $db->query("SELECT DISTINCT(fk_propal) as fk_propal FROM ".MAIN_DB_PREFIX."propaldet WHERE special_code=104777");
45
-	while($obj = $db->fetch_object($res)) {
45
+	while ($obj = $db->fetch_object($res)) {
46 46
 		$resLine = $db->query("SELECT rowid FROM  ".MAIN_DB_PREFIX."propaldet WHERE fk_propal=".$obj->fk_propal." ORDER BY rang ");
47 47
 		$k = 1;
48
-		while($objLine = $db->fetch_object($resLine)) {
48
+		while ($objLine = $db->fetch_object($resLine)) {
49 49
 
50
-			$sql="UPDATE ".MAIN_DB_PREFIX."propaldet SET rang=".$k.",fk_parent_line=NULL WHERE rowid=".$objLine->rowid;
50
+			$sql = "UPDATE ".MAIN_DB_PREFIX."propaldet SET rang=".$k.",fk_parent_line=NULL WHERE rowid=".$objLine->rowid;
51 51
 
52 52
 			 print $sql.";<br />";
53 53
 			$k++;
@@ -57,12 +57,12 @@  discard block
 block discarded – undo
57 57
 
58 58
 
59 59
         $res = $db->query("SELECT DISTINCT(fk_facture) as fk_facture FROM ".MAIN_DB_PREFIX."facturedet WHERE special_code=104777");
60
-        while($obj = $db->fetch_object($res)) {
60
+        while ($obj = $db->fetch_object($res)) {
61 61
                 $resLine = $db->query("SELECT rowid FROM  ".MAIN_DB_PREFIX."facturedet WHERE fk_facture=".$obj->fk_propal." ORDER BY rang ");
62 62
                 $k = 1;
63
-                while($objLine = $db->fetch_object($resLine)) {
63
+                while ($objLine = $db->fetch_object($resLine)) {
64 64
 
65
-                        $sql="UPDATE ".MAIN_DB_PREFIX."facturedet SET rang=".$k.",fk_parent_line=NULL WHERE rowid=".$objLine->rowid;
65
+                        $sql = "UPDATE ".MAIN_DB_PREFIX."facturedet SET rang=".$k.",fk_parent_line=NULL WHERE rowid=".$objLine->rowid;
66 66
 
67 67
                          print $sql.";<br />";
68 68
                         $k++;
@@ -71,12 +71,12 @@  discard block
 block discarded – undo
71 71
         }
72 72
 
73 73
         $res = $db->query("SELECT DISTINCT(fk_commande) as fk_commande FROM ".MAIN_DB_PREFIX."commandedet WHERE special_code=104777");
74
-        while($obj = $db->fetch_object($res)) {
74
+        while ($obj = $db->fetch_object($res)) {
75 75
                 $resLine = $db->query("SELECT rowid FROM  ".MAIN_DB_PREFIX."commandedet WHERE fk_commande=".$obj->fk_propal." ORDER BY rang ");
76 76
                 $k = 1;
77
-                while($objLine = $db->fetch_object($resLine)) {
77
+                while ($objLine = $db->fetch_object($resLine)) {
78 78
 
79
-                        $sql="UPDATE ".MAIN_DB_PREFIX."commandedet SET rang=".$k.",fk_parent_line=NULL WHERE rowid=".$objLine->rowid;
79
+                        $sql = "UPDATE ".MAIN_DB_PREFIX."commandedet SET rang=".$k.",fk_parent_line=NULL WHERE rowid=".$objLine->rowid;
80 80
 
81 81
                          print $sql.";<br />";
82 82
                         $k++;
Please login to merge, or discard this patch.
script/interface.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -7,8 +7,8 @@  discard block
 block discarded – undo
7 7
 	dol_include_once('/commande/class/commande.class.php');
8 8
 	dol_include_once('/compta/facture/class/facture.class.php');
9 9
 	
10
-	$get=GETPOST('get');
11
-	$set=GETPOST('set');
10
+	$get = GETPOST('get');
11
+	$set = GETPOST('set');
12 12
 	
13 13
 	switch ($get) {
14 14
 		default:
@@ -17,7 +17,7 @@  discard block
 block discarded – undo
17 17
 	
18 18
 	switch ($set) {
19 19
 		case 'updateLineNC': // Gestion du Compris/Non Compris via les titres et/ou lignes
20
-			echo json_encode( _updateLineNC(GETPOST('element'), GETPOST('elementid'), GETPOST('lineid'), GETPOST('subtotal_nc')) );
20
+			echo json_encode(_updateLineNC(GETPOST('element'), GETPOST('elementid'), GETPOST('lineid'), GETPOST('subtotal_nc')));
21 21
 			
22 22
 			break;
23 23
 		default:
Please login to merge, or discard this patch.
htdocs_38/core/lib/pdf.lib.php 3 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -127,7 +127,7 @@
 block discarded – undo
127 127
 	else require_once FPDF_PATH.'fpdf.php';
128 128
 
129 129
 	// We need to instantiate tcpdi or fpdi object (instead of tcpdf) to use merging features. But we can disable it (this will break all merge features).
130
-    if (empty($conf->global->MAIN_DISABLE_TCPDI)) require_once TCPDI_PATH.'tcpdi.php';
130
+	if (empty($conf->global->MAIN_DISABLE_TCPDI)) require_once TCPDI_PATH.'tcpdi.php';
131 131
 	else if (empty($conf->global->MAIN_DISABLE_FPDI)) require_once FPDI_PATH.'fpdi.php';
132 132
 
133 133
 	//$arrayformat=pdf_getFormat();
Please login to merge, or discard this patch.
Spacing   +432 added lines, -432 removed lines patch added patch discarded remove patch
@@ -39,36 +39,36 @@  discard block
 block discarded – undo
39 39
  *	@param		Translate	$outputlangs		Output lang to use to autodetect output format if setup not done
40 40
  *  @return     array							Array('width'=>w,'height'=>h,'unit'=>u);
41 41
  */
42
-function pdf_getFormat($outputlangs='')
42
+function pdf_getFormat($outputlangs = '')
43 43
 {
44
-	global $conf,$db;
44
+	global $conf, $db;
45 45
 
46 46
 	// Default value if setup was not done and/or entry into c_paper_format not defined
47
-	$width=210; $height=297; $unit='mm';
47
+	$width = 210; $height = 297; $unit = 'mm';
48 48
 
49 49
 	if (empty($conf->global->MAIN_PDF_FORMAT))
50 50
 	{
51 51
 		include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
52
-		$pdfformat=dol_getDefaultFormat($outputlangs);
52
+		$pdfformat = dol_getDefaultFormat($outputlangs);
53 53
 	}
54
-	else $pdfformat=$conf->global->MAIN_PDF_FORMAT;
54
+	else $pdfformat = $conf->global->MAIN_PDF_FORMAT;
55 55
 
56
-	$sql="SELECT code, label, width, height, unit FROM ".MAIN_DB_PREFIX."c_paper_format";
57
-	$sql.=" WHERE code = '".$pdfformat."'";
58
-	$resql=$db->query($sql);
56
+	$sql = "SELECT code, label, width, height, unit FROM ".MAIN_DB_PREFIX."c_paper_format";
57
+	$sql .= " WHERE code = '".$pdfformat."'";
58
+	$resql = $db->query($sql);
59 59
 	if ($resql)
60 60
 	{
61
-		$obj=$db->fetch_object($resql);
61
+		$obj = $db->fetch_object($resql);
62 62
 		if ($obj)
63 63
 		{
64
-			$width=(int) $obj->width;
65
-			$height=(int) $obj->height;
66
-			$unit=$obj->unit;
64
+			$width = (int) $obj->width;
65
+			$height = (int) $obj->height;
66
+			$unit = $obj->unit;
67 67
 		}
68 68
 	}
69 69
 
70 70
 	//print "pdfformat=".$pdfformat." width=".$width." height=".$height." unit=".$unit;
71
-	return array('width'=>$width,'height'=>$height,'unit'=>$unit);
71
+	return array('width'=>$width, 'height'=>$height, 'unit'=>$unit);
72 72
 }
73 73
 
74 74
 /**
@@ -79,14 +79,14 @@  discard block
 block discarded – undo
79 79
  *      @param  string		$pagetype       'P' or 'l'
80 80
  *      @return TPDF						PDF object
81 81
  */
82
-function pdf_getInstance($format='',$metric='mm',$pagetype='P')
82
+function pdf_getInstance($format = '', $metric = 'mm', $pagetype = 'P')
83 83
 {
84 84
 	global $conf;
85 85
 
86 86
 	// Define constant for TCPDF
87
-	if (! defined('K_TCPDF_EXTERNAL_CONFIG'))
87
+	if (!defined('K_TCPDF_EXTERNAL_CONFIG'))
88 88
 	{
89
-		define('K_TCPDF_EXTERNAL_CONFIG',1);	// this avoid using tcpdf_config file
89
+		define('K_TCPDF_EXTERNAL_CONFIG', 1); // this avoid using tcpdf_config file
90 90
 		define('K_PATH_CACHE', DOL_DATA_ROOT.'/admin/temp/');
91 91
 		define('K_PATH_URL_CACHE', DOL_DATA_ROOT.'/admin/temp/');
92 92
 		dol_mkdir(K_PATH_CACHE);
@@ -113,13 +113,13 @@  discard block
 block discarded – undo
113 113
 		define('HEAD_MAGNIFICATION', 1.1);
114 114
 		define('K_CELL_HEIGHT_RATIO', 1.25);
115 115
 		define('K_TITLE_MAGNIFICATION', 1.3);
116
-		define('K_SMALL_RATIO', 2/3);
116
+		define('K_SMALL_RATIO', 2 / 3);
117 117
 		define('K_THAI_TOPCHARS', true);
118 118
 		define('K_TCPDF_CALLS_IN_HTML', true);
119 119
 		define('K_TCPDF_THROW_EXCEPTION_ERROR', false);
120 120
 	}
121 121
 
122
-	if (! empty($conf->global->MAIN_USE_FPDF) && ! empty($conf->global->MAIN_DISABLE_FPDI))
122
+	if (!empty($conf->global->MAIN_USE_FPDF) && !empty($conf->global->MAIN_DISABLE_FPDI))
123 123
 		return "Error MAIN_USE_FPDF and MAIN_DISABLE_FPDI can't be set together";
124 124
 
125 125
 	// We use by default TCPDF else FPDF
@@ -135,7 +135,7 @@  discard block
 block discarded – undo
135 135
 	//$metric=$arrayformat['unit'];
136 136
 
137 137
 	// Protection and encryption of pdf
138
-	if (empty($conf->global->MAIN_USE_FPDF) && ! empty($conf->global->PDF_SECURITY_ENCRYPTION))
138
+	if (empty($conf->global->MAIN_USE_FPDF) && !empty($conf->global->PDF_SECURITY_ENCRYPTION))
139 139
 	{
140 140
 		/* Permission supported by TCPDF
141 141
 		- print : Print the document;
@@ -148,25 +148,25 @@  discard block
 block discarded – undo
148 148
 		- print-high : Print the document to a representation from which a faithful digital copy of the PDF content could be generated. When this is not set, printing is limited to a low-level representation of the appearance, possibly of degraded quality.
149 149
 		- owner : (inverted logic - only for public-key) when set permits change of encryption and enables all other permissions.
150 150
 		*/
151
-		if (class_exists('TCPDI')) $pdf = new TCPDI($pagetype,$metric,$format);
152
-		else if (class_exists('FPDI')) $pdf = new FPDI($pagetype,$metric,$format);
153
-		else $pdf = new TCPDF($pagetype,$metric,$format);
151
+		if (class_exists('TCPDI')) $pdf = new TCPDI($pagetype, $metric, $format);
152
+		else if (class_exists('FPDI')) $pdf = new FPDI($pagetype, $metric, $format);
153
+		else $pdf = new TCPDF($pagetype, $metric, $format);
154 154
 		// For TCPDF, we specify permission we want to block
155
-		$pdfrights = array('modify','copy');
155
+		$pdfrights = array('modify', 'copy');
156 156
 
157 157
 		$pdfuserpass = ''; // Password for the end user
158 158
 		$pdfownerpass = NULL; // Password of the owner, created randomly if not defined
159
-		$pdf->SetProtection($pdfrights,$pdfuserpass,$pdfownerpass);
159
+		$pdf->SetProtection($pdfrights, $pdfuserpass, $pdfownerpass);
160 160
 	}
161 161
 	else
162 162
 	{
163
-		if (class_exists('TCPDI')) $pdf = new TCPDI($pagetype,$metric,$format);
164
-		else if (class_exists('FPDI')) $pdf = new FPDI($pagetype,$metric,$format);
165
-		else $pdf = new TCPDF($pagetype,$metric,$format);
163
+		if (class_exists('TCPDI')) $pdf = new TCPDI($pagetype, $metric, $format);
164
+		else if (class_exists('FPDI')) $pdf = new FPDI($pagetype, $metric, $format);
165
+		else $pdf = new TCPDF($pagetype, $metric, $format);
166 166
 	}
167 167
 
168 168
 	// If we use FPDF class, we may need to add method writeHTMLCell
169
-	if (! empty($conf->global->MAIN_USE_FPDF) && ! method_exists($pdf, 'writeHTMLCell'))
169
+	if (!empty($conf->global->MAIN_USE_FPDF) && !method_exists($pdf, 'writeHTMLCell'))
170 170
 	{
171 171
 		// Declare here a class to overwrite FPDI to add method writeHTMLCell
172 172
 		/**
@@ -207,17 +207,17 @@  discard block
 block discarded – undo
207 207
 			 */
208 208
 			public function writeHTMLCell($w, $h, $x, $y, $html = '', $border = 0, $ln = 0, $fill = false, $reseth = true, $align = '', $autopadding = true)
209 209
 			{
210
-				$this->SetXY($x,$y);
211
-				$val=str_replace('<br>',"\n",$html);
210
+				$this->SetXY($x, $y);
211
+				$val = str_replace('<br>', "\n", $html);
212 212
 				//$val=dol_string_nohtmltag($val,false,'ISO-8859-1');
213
-				$val=dol_string_nohtmltag($val,false,'UTF-8');
214
-				$this->MultiCell($w,$h,$val,$border,$align,$fill);
213
+				$val = dol_string_nohtmltag($val, false, 'UTF-8');
214
+				$this->MultiCell($w, $h, $val, $border, $align, $fill);
215 215
 			}
216 216
 		}
217 217
 
218
-		$pdf2=new FPDI_DolExtended($pagetype,$metric,$format);
218
+		$pdf2 = new FPDI_DolExtended($pagetype, $metric, $format);
219 219
 		unset($pdf);
220
-		$pdf=$pdf2;
220
+		$pdf = $pdf2;
221 221
 	}
222 222
 
223 223
 	return $pdf;
@@ -234,14 +234,14 @@  discard block
 block discarded – undo
234 234
 {
235 235
 	global $conf;
236 236
 
237
-	if (! empty($conf->global->MAIN_PDF_FORCE_FONT)) return $conf->global->MAIN_PDF_FORCE_FONT;
237
+	if (!empty($conf->global->MAIN_PDF_FORCE_FONT)) return $conf->global->MAIN_PDF_FORCE_FONT;
238 238
 
239
-	$font='Helvetica'; // By default, for FPDI, or ISO language on TCPDF
239
+	$font = 'Helvetica'; // By default, for FPDI, or ISO language on TCPDF
240 240
 	if (class_exists('TCPDF'))  // If TCPDF on, we can use an UTF8 one like DejaVuSans if required (slower)
241 241
 	{
242
-		if ($outputlangs->trans('FONTFORPDF')!='FONTFORPDF')
242
+		if ($outputlangs->trans('FONTFORPDF') != 'FONTFORPDF')
243 243
 		{
244
-			$font=$outputlangs->trans('FONTFORPDF');
244
+			$font = $outputlangs->trans('FONTFORPDF');
245 245
 		}
246 246
 	}
247 247
 	return $font;
@@ -255,10 +255,10 @@  discard block
 block discarded – undo
255 255
  */
256 256
 function pdf_getPDFFontSize($outputlangs)
257 257
 {
258
-	$size=10;                   // By default, for FPDI or ISO language on TCPDF
258
+	$size = 10; // By default, for FPDI or ISO language on TCPDF
259 259
 	if (class_exists('TCPDF'))  // If TCPDF on, we can use an UTF8 one like DejaVuSans if required (slower)
260 260
 	{
261
-		if ($outputlangs->trans('FONTSIZEFORPDF')!='FONTSIZEFORPDF')
261
+		if ($outputlangs->trans('FONTSIZEFORPDF') != 'FONTSIZEFORPDF')
262 262
 		{
263 263
 			$size = (int) $outputlangs->trans('FONTSIZEFORPDF');
264 264
 		}
@@ -277,14 +277,14 @@  discard block
 block discarded – undo
277 277
 function pdf_getHeightForLogo($logo, $url = false)
278 278
 {
279 279
 	global $conf;
280
-	$height=(empty($conf->global->MAIN_DOCUMENTS_LOGO_HEIGHT)?22:$conf->global->MAIN_DOCUMENTS_LOGO_HEIGHT);
281
-	$maxwidth=130;
280
+	$height = (empty($conf->global->MAIN_DOCUMENTS_LOGO_HEIGHT) ? 22 : $conf->global->MAIN_DOCUMENTS_LOGO_HEIGHT);
281
+	$maxwidth = 130;
282 282
 	include_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php';
283
-	$tmp=dol_getImageSize($logo, $url);
283
+	$tmp = dol_getImageSize($logo, $url);
284 284
 	if ($tmp['height'])
285 285
 	{
286
-		$width=round($height*$tmp['width']/$tmp['height']);
287
-		if ($width > $maxwidth) $height=$height*$maxwidth/$width;
286
+		$width = round($height * $tmp['width'] / $tmp['height']);
287
+		if ($width > $maxwidth) $height = $height * $maxwidth / $width;
288 288
 	}
289 289
 	//print $tmp['width'].' '.$tmp['height'].' '.$width; exit;
290 290
 	return $height;
@@ -328,36 +328,36 @@  discard block
 block discarded – undo
328 328
  * 		@param	int			$mode				Address type ('source', 'target', 'targetwithdetails')
329 329
  * 		@return	string							String with full address
330 330
  */
331
-function pdf_build_address($outputlangs,$sourcecompany,$targetcompany='',$targetcontact='',$usecontact=0,$mode='source')
331
+function pdf_build_address($outputlangs, $sourcecompany, $targetcompany = '', $targetcontact = '', $usecontact = 0, $mode = 'source')
332 332
 {
333 333
 	global $conf;
334 334
 	$stringaddress = '';
335 335
 
336
-	if ($mode == 'source' && ! is_object($sourcecompany)) return -1;
337
-	if ($mode == 'target' && ! is_object($targetcompany)) return -1;
338
-	if ($mode == 'delivery' && ! is_object($deliverycompany)) return -1;
336
+	if ($mode == 'source' && !is_object($sourcecompany)) return -1;
337
+	if ($mode == 'target' && !is_object($targetcompany)) return -1;
338
+	if ($mode == 'delivery' && !is_object($deliverycompany)) return -1;
339 339
 
340
-	if (! empty($sourcecompany->state_id) && empty($sourcecompany->departement)) $sourcecompany->departement=getState($sourcecompany->state_id); //TODO: Deprecated
341
-	if (! empty($sourcecompany->state_id) && empty($sourcecompany->state)) $sourcecompany->state=getState($sourcecompany->state_id);
342
-	if (! empty($targetcompany->state_id) && empty($targetcompany->departement)) $targetcompany->departement=getState($targetcompany->state_id);
340
+	if (!empty($sourcecompany->state_id) && empty($sourcecompany->departement)) $sourcecompany->departement = getState($sourcecompany->state_id); //TODO: Deprecated
341
+	if (!empty($sourcecompany->state_id) && empty($sourcecompany->state)) $sourcecompany->state = getState($sourcecompany->state_id);
342
+	if (!empty($targetcompany->state_id) && empty($targetcompany->departement)) $targetcompany->departement = getState($targetcompany->state_id);
343 343
 
344 344
 	if ($mode == 'source')
345 345
 	{
346 346
 		$withCountry = 0;
347 347
 		if (!empty($sourcecompany->country_code) && ($targetcompany->country_code != $sourcecompany->country_code)) $withCountry = 1;
348 348
 
349
-		$stringaddress .= ($stringaddress ? "\n" : '' ).$outputlangs->convToOutputCharset(dol_format_address($sourcecompany, $withCountry, "\n", $outputlangs))."\n";
349
+		$stringaddress .= ($stringaddress ? "\n" : '').$outputlangs->convToOutputCharset(dol_format_address($sourcecompany, $withCountry, "\n", $outputlangs))."\n";
350 350
 
351 351
 		if (empty($conf->global->MAIN_PDF_DISABLESOURCEDETAILS))
352 352
 		{
353 353
 			// Phone
354
-			if ($sourcecompany->phone) $stringaddress .= ($stringaddress ? "\n" : '' ).$outputlangs->transnoentities("PhoneShort").": ".$outputlangs->convToOutputCharset($sourcecompany->phone);
354
+			if ($sourcecompany->phone) $stringaddress .= ($stringaddress ? "\n" : '').$outputlangs->transnoentities("PhoneShort").": ".$outputlangs->convToOutputCharset($sourcecompany->phone);
355 355
 			// Fax
356
-			if ($sourcecompany->fax) $stringaddress .= ($stringaddress ? ($sourcecompany->phone ? " - " : "\n") : '' ).$outputlangs->transnoentities("Fax").": ".$outputlangs->convToOutputCharset($sourcecompany->fax);
356
+			if ($sourcecompany->fax) $stringaddress .= ($stringaddress ? ($sourcecompany->phone ? " - " : "\n") : '').$outputlangs->transnoentities("Fax").": ".$outputlangs->convToOutputCharset($sourcecompany->fax);
357 357
 			// EMail
358
-			if ($sourcecompany->email) $stringaddress .= ($stringaddress ? "\n" : '' ).$outputlangs->transnoentities("Email").": ".$outputlangs->convToOutputCharset($sourcecompany->email);
358
+			if ($sourcecompany->email) $stringaddress .= ($stringaddress ? "\n" : '').$outputlangs->transnoentities("Email").": ".$outputlangs->convToOutputCharset($sourcecompany->email);
359 359
 			// Web
360
-			if ($sourcecompany->url) $stringaddress .= ($stringaddress ? "\n" : '' ).$outputlangs->transnoentities("Web").": ".$outputlangs->convToOutputCharset($sourcecompany->url);
360
+			if ($sourcecompany->url) $stringaddress .= ($stringaddress ? "\n" : '').$outputlangs->transnoentities("Web").": ".$outputlangs->convToOutputCharset($sourcecompany->url);
361 361
 		}
362 362
 	}
363 363
 
@@ -365,88 +365,88 @@  discard block
 block discarded – undo
365 365
 	{
366 366
 		if ($usecontact)
367 367
 		{
368
-			$stringaddress .= ($stringaddress ? "\n" : '' ).$outputlangs->convToOutputCharset($targetcontact->getFullName($outputlangs,1));
368
+			$stringaddress .= ($stringaddress ? "\n" : '').$outputlangs->convToOutputCharset($targetcontact->getFullName($outputlangs, 1));
369 369
 
370 370
 			if (!empty($targetcontact->address)) {
371
-				$stringaddress .= ($stringaddress ? "\n" : '' ).$outputlangs->convToOutputCharset(dol_format_address($targetcontact))."\n";
372
-			}else {
373
-				$stringaddress .= ($stringaddress ? "\n" : '' ).$outputlangs->convToOutputCharset(dol_format_address($targetcompany))."\n";
371
+				$stringaddress .= ($stringaddress ? "\n" : '').$outputlangs->convToOutputCharset(dol_format_address($targetcontact))."\n";
372
+			} else {
373
+				$stringaddress .= ($stringaddress ? "\n" : '').$outputlangs->convToOutputCharset(dol_format_address($targetcompany))."\n";
374 374
 			}
375 375
 			// Country
376 376
 			if (!empty($targetcontact->country_code) && $targetcontact->country_code != $sourcecompany->country_code) {
377
-				$stringaddress.=$outputlangs->convToOutputCharset($outputlangs->transnoentitiesnoconv("Country".$targetcontact->country_code))."\n";
377
+				$stringaddress .= $outputlangs->convToOutputCharset($outputlangs->transnoentitiesnoconv("Country".$targetcontact->country_code))."\n";
378 378
 			}
379 379
 			else if (empty($targetcontact->country_code) && !empty($targetcompany->country_code) && ($targetcompany->country_code != $sourcecompany->country_code)) {
380
-				$stringaddress.=$outputlangs->convToOutputCharset($outputlangs->transnoentitiesnoconv("Country".$targetcompany->country_code))."\n";
380
+				$stringaddress .= $outputlangs->convToOutputCharset($outputlangs->transnoentitiesnoconv("Country".$targetcompany->country_code))."\n";
381 381
 			}
382 382
 
383
-			if (! empty($conf->global->MAIN_PDF_ADDALSOTARGETDETAILS) || $mode == 'targetwithdetails')
383
+			if (!empty($conf->global->MAIN_PDF_ADDALSOTARGETDETAILS) || $mode == 'targetwithdetails')
384 384
 			{
385 385
 				// Phone
386
-				if (! empty($targetcontact->phone_pro) || ! empty($targetcontact->phone_mobile)) $stringaddress .= ($stringaddress ? "\n" : '' ).$outputlangs->transnoentities("Phone").": ";
387
-				if (! empty($targetcontact->phone_pro)) $stringaddress .= $outputlangs->convToOutputCharset($targetcontact->phone_pro);
388
-				if (! empty($targetcontact->phone_pro) && ! empty($targetcontact->phone_mobile)) $stringaddress .= " / ";
389
-				if (! empty($targetcontact->phone_mobile)) $stringaddress .= $outputlangs->convToOutputCharset($targetcontact->phone_mobile);
386
+				if (!empty($targetcontact->phone_pro) || !empty($targetcontact->phone_mobile)) $stringaddress .= ($stringaddress ? "\n" : '').$outputlangs->transnoentities("Phone").": ";
387
+				if (!empty($targetcontact->phone_pro)) $stringaddress .= $outputlangs->convToOutputCharset($targetcontact->phone_pro);
388
+				if (!empty($targetcontact->phone_pro) && !empty($targetcontact->phone_mobile)) $stringaddress .= " / ";
389
+				if (!empty($targetcontact->phone_mobile)) $stringaddress .= $outputlangs->convToOutputCharset($targetcontact->phone_mobile);
390 390
 				// Fax
391
-				if ($targetcontact->fax) $stringaddress .= ($stringaddress ? "\n" : '' ).$outputlangs->transnoentities("Fax").": ".$outputlangs->convToOutputCharset($targetcontact->fax);
391
+				if ($targetcontact->fax) $stringaddress .= ($stringaddress ? "\n" : '').$outputlangs->transnoentities("Fax").": ".$outputlangs->convToOutputCharset($targetcontact->fax);
392 392
 				// EMail
393
-				if ($targetcontact->email) $stringaddress .= ($stringaddress ? "\n" : '' ).$outputlangs->transnoentities("Email").": ".$outputlangs->convToOutputCharset($targetcontact->email);
393
+				if ($targetcontact->email) $stringaddress .= ($stringaddress ? "\n" : '').$outputlangs->transnoentities("Email").": ".$outputlangs->convToOutputCharset($targetcontact->email);
394 394
 				// Web
395
-				if ($targetcontact->url) $stringaddress .= ($stringaddress ? "\n" : '' ).$outputlangs->transnoentities("Web").": ".$outputlangs->convToOutputCharset($targetcontact->url);
395
+				if ($targetcontact->url) $stringaddress .= ($stringaddress ? "\n" : '').$outputlangs->transnoentities("Web").": ".$outputlangs->convToOutputCharset($targetcontact->url);
396 396
 			}
397 397
 		}
398 398
 		else
399 399
 		{
400
-			$stringaddress .= ($stringaddress ? "\n" : '' ).$outputlangs->convToOutputCharset(dol_format_address($targetcompany))."\n";
400
+			$stringaddress .= ($stringaddress ? "\n" : '').$outputlangs->convToOutputCharset(dol_format_address($targetcompany))."\n";
401 401
 			// Country
402
-			if (!empty($targetcompany->country_code) && $targetcompany->country_code != $sourcecompany->country_code) $stringaddress.=$outputlangs->convToOutputCharset($outputlangs->transnoentitiesnoconv("Country".$targetcompany->country_code))."\n";
402
+			if (!empty($targetcompany->country_code) && $targetcompany->country_code != $sourcecompany->country_code) $stringaddress .= $outputlangs->convToOutputCharset($outputlangs->transnoentitiesnoconv("Country".$targetcompany->country_code))."\n";
403 403
 
404
-			if (! empty($conf->global->MAIN_PDF_ADDALSOTARGETDETAILS) || $mode == 'targetwithdetails')
404
+			if (!empty($conf->global->MAIN_PDF_ADDALSOTARGETDETAILS) || $mode == 'targetwithdetails')
405 405
 			{
406 406
 				// Phone
407
-				if (! empty($targetcompany->phone) || ! empty($targetcompany->phone_mobile)) $stringaddress .= ($stringaddress ? "\n" : '' ).$outputlangs->transnoentities("Phone").": ";
408
-				if (! empty($targetcompany->phone)) $stringaddress .= $outputlangs->convToOutputCharset($targetcompany->phone);
409
-				if (! empty($targetcompany->phone) && ! empty($targetcompany->phone_mobile)) $stringaddress .= " / ";
410
-				if (! empty($targetcompany->phone_mobile)) $stringaddress .= $outputlangs->convToOutputCharset($targetcompany->phone_mobile);
407
+				if (!empty($targetcompany->phone) || !empty($targetcompany->phone_mobile)) $stringaddress .= ($stringaddress ? "\n" : '').$outputlangs->transnoentities("Phone").": ";
408
+				if (!empty($targetcompany->phone)) $stringaddress .= $outputlangs->convToOutputCharset($targetcompany->phone);
409
+				if (!empty($targetcompany->phone) && !empty($targetcompany->phone_mobile)) $stringaddress .= " / ";
410
+				if (!empty($targetcompany->phone_mobile)) $stringaddress .= $outputlangs->convToOutputCharset($targetcompany->phone_mobile);
411 411
 				// Fax
412
-				if ($targetcompany->fax) $stringaddress .= ($stringaddress ? "\n" : '' ).$outputlangs->transnoentities("Fax").": ".$outputlangs->convToOutputCharset($targetcompany->fax);
412
+				if ($targetcompany->fax) $stringaddress .= ($stringaddress ? "\n" : '').$outputlangs->transnoentities("Fax").": ".$outputlangs->convToOutputCharset($targetcompany->fax);
413 413
 				// EMail
414
-				if ($targetcompany->email) $stringaddress .= ($stringaddress ? "\n" : '' ).$outputlangs->transnoentities("Email").": ".$outputlangs->convToOutputCharset($targetcompany->email);
414
+				if ($targetcompany->email) $stringaddress .= ($stringaddress ? "\n" : '').$outputlangs->transnoentities("Email").": ".$outputlangs->convToOutputCharset($targetcompany->email);
415 415
 				// Web
416
-				if ($targetcompany->url) $stringaddress .= ($stringaddress ? "\n" : '' ).$outputlangs->transnoentities("Web").": ".$outputlangs->convToOutputCharset($targetcompany->url);
416
+				if ($targetcompany->url) $stringaddress .= ($stringaddress ? "\n" : '').$outputlangs->transnoentities("Web").": ".$outputlangs->convToOutputCharset($targetcompany->url);
417 417
 			}
418 418
 		}
419 419
 
420 420
 		// Intra VAT
421 421
 		if (empty($conf->global->MAIN_TVAINTRA_NOT_IN_ADDRESS))
422 422
 		{
423
-			if ($targetcompany->tva_intra) $stringaddress.="\n".$outputlangs->transnoentities("VATIntraShort").': '.$outputlangs->convToOutputCharset($targetcompany->tva_intra);
423
+			if ($targetcompany->tva_intra) $stringaddress .= "\n".$outputlangs->transnoentities("VATIntraShort").': '.$outputlangs->convToOutputCharset($targetcompany->tva_intra);
424 424
 		}
425 425
 
426 426
 		// Professionnal Ids
427
-		if (! empty($conf->global->MAIN_PROFID1_IN_ADDRESS) && ! empty($targetcompany->idprof1))
427
+		if (!empty($conf->global->MAIN_PROFID1_IN_ADDRESS) && !empty($targetcompany->idprof1))
428 428
 		{
429
-			$tmp=$outputlangs->transcountrynoentities("ProfId1",$targetcompany->country_code);
430
-			if (preg_match('/\((.+)\)/',$tmp,$reg)) $tmp=$reg[1];
431
-			$stringaddress.="\n".$tmp.': '.$outputlangs->convToOutputCharset($targetcompany->idprof1);
429
+			$tmp = $outputlangs->transcountrynoentities("ProfId1", $targetcompany->country_code);
430
+			if (preg_match('/\((.+)\)/', $tmp, $reg)) $tmp = $reg[1];
431
+			$stringaddress .= "\n".$tmp.': '.$outputlangs->convToOutputCharset($targetcompany->idprof1);
432 432
 		}
433
-		if (! empty($conf->global->MAIN_PROFID2_IN_ADDRESS) && ! empty($targetcompany->idprof2))
433
+		if (!empty($conf->global->MAIN_PROFID2_IN_ADDRESS) && !empty($targetcompany->idprof2))
434 434
 		{
435
-			$tmp=$outputlangs->transcountrynoentities("ProfId2",$targetcompany->country_code);
436
-			if (preg_match('/\((.+)\)/',$tmp,$reg)) $tmp=$reg[1];
437
-			$stringaddress.="\n".$tmp.': '.$outputlangs->convToOutputCharset($targetcompany->idprof2);
435
+			$tmp = $outputlangs->transcountrynoentities("ProfId2", $targetcompany->country_code);
436
+			if (preg_match('/\((.+)\)/', $tmp, $reg)) $tmp = $reg[1];
437
+			$stringaddress .= "\n".$tmp.': '.$outputlangs->convToOutputCharset($targetcompany->idprof2);
438 438
 		}
439
-		if (! empty($conf->global->MAIN_PROFID3_IN_ADDRESS) && ! empty($targetcompany->idprof3))
439
+		if (!empty($conf->global->MAIN_PROFID3_IN_ADDRESS) && !empty($targetcompany->idprof3))
440 440
 		{
441
-			$tmp=$outputlangs->transcountrynoentities("ProfId3",$targetcompany->country_code);
442
-			if (preg_match('/\((.+)\)/',$tmp,$reg)) $tmp=$reg[1];
443
-			$stringaddress.="\n".$tmp.': '.$outputlangs->convToOutputCharset($targetcompany->idprof3);
441
+			$tmp = $outputlangs->transcountrynoentities("ProfId3", $targetcompany->country_code);
442
+			if (preg_match('/\((.+)\)/', $tmp, $reg)) $tmp = $reg[1];
443
+			$stringaddress .= "\n".$tmp.': '.$outputlangs->convToOutputCharset($targetcompany->idprof3);
444 444
 		}
445
-		if (! empty($conf->global->MAIN_PROFID4_IN_ADDRESS) && ! empty($targetcompany->idprof4))
445
+		if (!empty($conf->global->MAIN_PROFID4_IN_ADDRESS) && !empty($targetcompany->idprof4))
446 446
 		{
447
-			$tmp=$outputlangs->transcountrynoentities("ProfId4",$targetcompany->country_code);
448
-			if (preg_match('/\((.+)\)/',$tmp,$reg)) $tmp=$reg[1];
449
-			$stringaddress.="\n".$tmp.': '.$outputlangs->convToOutputCharset($targetcompany->idprof4);
447
+			$tmp = $outputlangs->transcountrynoentities("ProfId4", $targetcompany->country_code);
448
+			if (preg_match('/\((.+)\)/', $tmp, $reg)) $tmp = $reg[1];
449
+			$stringaddress .= "\n".$tmp.': '.$outputlangs->convToOutputCharset($targetcompany->idprof4);
450 450
 		}
451 451
 	}
452 452
 
@@ -462,16 +462,16 @@  discard block
 block discarded – undo
462 462
  * 		@param		int			$page_height	Height of page
463 463
  *      @return	void
464 464
  */
465
-function pdf_pagehead(&$pdf,$outputlangs,$page_height)
465
+function pdf_pagehead(&$pdf, $outputlangs, $page_height)
466 466
 {
467 467
 	global $conf;
468 468
 
469 469
 	// Add a background image on document
470
-	if (! empty($conf->global->MAIN_USE_BACKGROUND_ON_PDF))		// Warning, this option make TCPDF generation beeing crazy and some content disappeared behin the image
470
+	if (!empty($conf->global->MAIN_USE_BACKGROUND_ON_PDF))		// Warning, this option make TCPDF generation beeing crazy and some content disappeared behin the image
471 471
 	{
472
-		$pdf->SetAutoPageBreak(0,0);	// Disable auto pagebreak before adding image
473
-		$pdf->Image($conf->mycompany->dir_output.'/logos/'.$conf->global->MAIN_USE_BACKGROUND_ON_PDF, (isset($conf->global->MAIN_USE_BACKGROUND_ON_PDF_X)?$conf->global->MAIN_USE_BACKGROUND_ON_PDF_X:0), (isset($conf->global->MAIN_USE_BACKGROUND_ON_PDF_Y)?$conf->global->MAIN_USE_BACKGROUND_ON_PDF_Y:0), 0, $page_height);
474
-		$pdf->SetAutoPageBreak(1,0);	// Restore pagebreak
472
+		$pdf->SetAutoPageBreak(0, 0); // Disable auto pagebreak before adding image
473
+		$pdf->Image($conf->mycompany->dir_output.'/logos/'.$conf->global->MAIN_USE_BACKGROUND_ON_PDF, (isset($conf->global->MAIN_USE_BACKGROUND_ON_PDF_X) ? $conf->global->MAIN_USE_BACKGROUND_ON_PDF_X : 0), (isset($conf->global->MAIN_USE_BACKGROUND_ON_PDF_Y) ? $conf->global->MAIN_USE_BACKGROUND_ON_PDF_Y : 0), 0, $page_height);
474
+		$pdf->SetAutoPageBreak(1, 0); // Restore pagebreak
475 475
 	}
476 476
 }
477 477
 
@@ -489,29 +489,29 @@  discard block
 block discarded – undo
489 489
 function pdf_watermark(&$pdf, $outputlangs, $h, $w, $unit, $text)
490 490
 {
491 491
 	// Print Draft Watermark
492
-	if ($unit=='pt') $k=1;
493
-	elseif ($unit=='mm') $k=72/25.4;
494
-	elseif ($unit=='cm') $k=72/2.54;
495
-	elseif ($unit=='in') $k=72;
496
-
497
-	$savx=$pdf->getX(); $savy=$pdf->getY();
498
-
499
-	$watermark_angle=atan($h/$w)/2;
500
-	$watermark_x_pos=0;
501
-	$watermark_y_pos=$h/3;
502
-	$watermark_x=$w/2;
503
-	$watermark_y=$h/3;
504
-	$pdf->SetFont('','B',40);
505
-	$pdf->SetTextColor(255,192,203);
492
+	if ($unit == 'pt') $k = 1;
493
+	elseif ($unit == 'mm') $k = 72 / 25.4;
494
+	elseif ($unit == 'cm') $k = 72 / 2.54;
495
+	elseif ($unit == 'in') $k = 72;
496
+
497
+	$savx = $pdf->getX(); $savy = $pdf->getY();
498
+
499
+	$watermark_angle = atan($h / $w) / 2;
500
+	$watermark_x_pos = 0;
501
+	$watermark_y_pos = $h / 3;
502
+	$watermark_x = $w / 2;
503
+	$watermark_y = $h / 3;
504
+	$pdf->SetFont('', 'B', 40);
505
+	$pdf->SetTextColor(255, 192, 203);
506 506
 	//rotate
507
-	$pdf->_out(sprintf('q %.5F %.5F %.5F %.5F %.2F %.2F cm 1 0 0 1 %.2F %.2F cm',cos($watermark_angle),sin($watermark_angle),-sin($watermark_angle),cos($watermark_angle),$watermark_x*$k,($h-$watermark_y)*$k,-$watermark_x*$k,-($h-$watermark_y)*$k));
507
+	$pdf->_out(sprintf('q %.5F %.5F %.5F %.5F %.2F %.2F cm 1 0 0 1 %.2F %.2F cm', cos($watermark_angle), sin($watermark_angle), -sin($watermark_angle), cos($watermark_angle), $watermark_x * $k, ($h - $watermark_y) * $k, -$watermark_x * $k, -($h - $watermark_y) * $k));
508 508
 	//print watermark
509
-	$pdf->SetXY($watermark_x_pos,$watermark_y_pos);
510
-	$pdf->Cell($w-20,25,$outputlangs->convToOutputCharset($text),"",2,"C",0);
509
+	$pdf->SetXY($watermark_x_pos, $watermark_y_pos);
510
+	$pdf->Cell($w - 20, 25, $outputlangs->convToOutputCharset($text), "", 2, "C", 0);
511 511
 	//antirotate
512 512
 	$pdf->_out('Q');
513 513
 
514
-	$pdf->SetXY($savx,$savy);
514
+	$pdf->SetXY($savx, $savy);
515 515
 }
516 516
 
517 517
 
@@ -527,41 +527,41 @@  discard block
 block discarded – undo
527 527
  *  @param	int			$default_font_size		Default font size
528 528
  *  @return	float                               The Y PDF position
529 529
  */
530
-function pdf_bank(&$pdf,$outputlangs,$curx,$cury,$account,$onlynumber=0,$default_font_size=10)
530
+function pdf_bank(&$pdf, $outputlangs, $curx, $cury, $account, $onlynumber = 0, $default_font_size = 10)
531 531
 {
532 532
 	global $mysoc, $conf;
533 533
 
534
-	$diffsizetitle=(empty($conf->global->PDF_DIFFSIZE_TITLE)?3:$conf->global->PDF_DIFFSIZE_TITLE);
535
-	$diffsizecontent=(empty($conf->global->PDF_DIFFSIZE_CONTENT)?4:$conf->global->PDF_DIFFSIZE_CONTENT);
534
+	$diffsizetitle = (empty($conf->global->PDF_DIFFSIZE_TITLE) ? 3 : $conf->global->PDF_DIFFSIZE_TITLE);
535
+	$diffsizecontent = (empty($conf->global->PDF_DIFFSIZE_CONTENT) ? 4 : $conf->global->PDF_DIFFSIZE_CONTENT);
536 536
 	$pdf->SetXY($curx, $cury);
537 537
 
538 538
 	if (empty($onlynumber))
539 539
 	{
540
-		$pdf->SetFont('','B',$default_font_size - $diffsizetitle);
540
+		$pdf->SetFont('', 'B', $default_font_size - $diffsizetitle);
541 541
 		$pdf->MultiCell(100, 3, $outputlangs->transnoentities('PaymentByTransferOnThisBankAccount').':', 0, 'L', 0);
542
-		$cury+=4;
542
+		$cury += 4;
543 543
 	}
544 544
 
545 545
 	$outputlangs->load("banks");
546 546
 
547 547
 	// Use correct name of bank id according to country
548
-	$bickey="BICNumber";
549
-	if ($account->getCountryCode() == 'IN') $bickey="SWIFT";
548
+	$bickey = "BICNumber";
549
+	if ($account->getCountryCode() == 'IN') $bickey = "SWIFT";
550 550
 
551 551
 	// Get format of bank account according to its country
552
-	$usedetailedbban=$account->useDetailedBBAN();
552
+	$usedetailedbban = $account->useDetailedBBAN();
553 553
 
554 554
 	//$onlynumber=0; $usedetailedbban=1; // For tests
555 555
 	if ($usedetailedbban)
556 556
 	{
557
-		$savcurx=$curx;
557
+		$savcurx = $curx;
558 558
 
559 559
 		if (empty($onlynumber))
560 560
 		{
561
-			$pdf->SetFont('','',$default_font_size - $diffsizecontent);
561
+			$pdf->SetFont('', '', $default_font_size - $diffsizecontent);
562 562
 			$pdf->SetXY($curx, $cury);
563
-			$pdf->MultiCell(100, 3, $outputlangs->transnoentities("Bank").': ' . $outputlangs->convToOutputCharset($account->bank), 0, 'L', 0);
564
-			$cury+=3;
563
+			$pdf->MultiCell(100, 3, $outputlangs->transnoentities("Bank").': '.$outputlangs->convToOutputCharset($account->bank), 0, 'L', 0);
564
+			$cury += 3;
565 565
 		}
566 566
 
567 567
 		/*
@@ -632,69 +632,69 @@  discard block
 block discarded – undo
632 632
 	}
633 633
 	else
634 634
 	{
635
-		$pdf->SetFont('','B',$default_font_size - $diffsizecontent);
635
+		$pdf->SetFont('', 'B', $default_font_size - $diffsizecontent);
636 636
 		$pdf->SetXY($curx, $cury);
637
-		$pdf->MultiCell(100, 3, $outputlangs->transnoentities("Bank").': ' . $outputlangs->convToOutputCharset($account->bank), 0, 'L', 0);
638
-		$cury+=3;
637
+		$pdf->MultiCell(100, 3, $outputlangs->transnoentities("Bank").': '.$outputlangs->convToOutputCharset($account->bank), 0, 'L', 0);
638
+		$cury += 3;
639 639
 
640
-		$pdf->SetFont('','B',$default_font_size - $diffsizecontent);
640
+		$pdf->SetFont('', 'B', $default_font_size - $diffsizecontent);
641 641
 		$pdf->SetXY($curx, $cury);
642
-		$pdf->MultiCell(100, 3, $outputlangs->transnoentities("BankAccountNumber").': ' . $outputlangs->convToOutputCharset($account->number), 0, 'L', 0);
643
-		$cury+=3;
642
+		$pdf->MultiCell(100, 3, $outputlangs->transnoentities("BankAccountNumber").': '.$outputlangs->convToOutputCharset($account->number), 0, 'L', 0);
643
+		$cury += 3;
644 644
 
645
-		if ($diffsizecontent <= 2) $cury+=1;
645
+		if ($diffsizecontent <= 2) $cury += 1;
646 646
 	}
647 647
 
648
-	$pdf->SetFont('','',$default_font_size - $diffsizecontent);
648
+	$pdf->SetFont('', '', $default_font_size - $diffsizecontent);
649 649
 
650
-	if (empty($onlynumber) && ! empty($account->domiciliation))
650
+	if (empty($onlynumber) && !empty($account->domiciliation))
651 651
 	{
652 652
 		$pdf->SetXY($curx, $cury);
653
-		$val=$outputlangs->transnoentities("Residence").': ' . $outputlangs->convToOutputCharset($account->domiciliation);
653
+		$val = $outputlangs->transnoentities("Residence").': '.$outputlangs->convToOutputCharset($account->domiciliation);
654 654
 		$pdf->MultiCell(100, 3, $val, 0, 'L', 0);
655 655
 		//$nboflines=dol_nboflines_bis($val,120);
656 656
 		//$cury+=($nboflines*3)+2;
657
-		$tmpy=$pdf->getStringHeight(100, $val);
658
-		$cury+=$tmpy;
657
+		$tmpy = $pdf->getStringHeight(100, $val);
658
+		$cury += $tmpy;
659 659
 	}
660 660
 
661
-	if (! empty($account->proprio))
661
+	if (!empty($account->proprio))
662 662
 	{
663 663
 		$pdf->SetXY($curx, $cury);
664
-		$val=$outputlangs->transnoentities("BankAccountOwner").': ' . $outputlangs->convToOutputCharset($account->proprio);
664
+		$val = $outputlangs->transnoentities("BankAccountOwner").': '.$outputlangs->convToOutputCharset($account->proprio);
665 665
 		$pdf->MultiCell(100, 3, $val, 0, 'L', 0);
666
-		$tmpy=$pdf->getStringHeight(100, $val);
667
-		$cury+=$tmpy;
666
+		$tmpy = $pdf->getStringHeight(100, $val);
667
+		$cury += $tmpy;
668 668
 	}
669 669
 
670
-	else if (! $usedetailedbban) $cury+=1;
670
+	else if (!$usedetailedbban) $cury += 1;
671 671
 
672 672
 	// Use correct name of bank id according to country
673
-	$ibankey="IBANNumber";
674
-	if ($account->getCountryCode() == 'IN') $ibankey="IFSC";
675
-	if (! empty($account->iban))
673
+	$ibankey = "IBANNumber";
674
+	if ($account->getCountryCode() == 'IN') $ibankey = "IFSC";
675
+	if (!empty($account->iban))
676 676
 	{
677 677
 		//Remove whitespaces to ensure we are dealing with the format we expect
678 678
 		$ibanDisplay_temp = str_replace(' ', '', $outputlangs->convToOutputCharset($account->iban));
679 679
 		$ibanDisplay = "";
680 680
 
681
-		for($i = 0; $i < dol_strlen($ibanDisplay_temp); $i++)
681
+		for ($i = 0; $i < dol_strlen($ibanDisplay_temp); $i++)
682 682
 		{
683 683
 			$ibanDisplay .= $ibanDisplay_temp[$i];
684
-			if($i%4 == 3 && $i > 0)	$ibanDisplay .= " ";
684
+			if ($i % 4 == 3 && $i > 0)	$ibanDisplay .= " ";
685 685
 		}
686 686
 
687
-		$pdf->SetFont('','B',$default_font_size - 3);
687
+		$pdf->SetFont('', 'B', $default_font_size - 3);
688 688
 		$pdf->SetXY($curx, $cury);
689
-		$pdf->MultiCell(100, 3, $outputlangs->transnoentities($ibankey).': ' . $ibanDisplay, 0, 'L', 0);
690
-		$cury+=3;
689
+		$pdf->MultiCell(100, 3, $outputlangs->transnoentities($ibankey).': '.$ibanDisplay, 0, 'L', 0);
690
+		$cury += 3;
691 691
 	}
692 692
 
693
-	if (! empty($account->bic))
693
+	if (!empty($account->bic))
694 694
 	{
695
-		$pdf->SetFont('','B',$default_font_size - 3);
695
+		$pdf->SetFont('', 'B', $default_font_size - 3);
696 696
 		$pdf->SetXY($curx, $cury);
697
-		$pdf->MultiCell(100, 3, $outputlangs->transnoentities($bickey).': ' . $outputlangs->convToOutputCharset($account->bic), 0, 'L', 0);
697
+		$pdf->MultiCell(100, 3, $outputlangs->transnoentities($bickey).': '.$outputlangs->convToOutputCharset($account->bic), 0, 'L', 0);
698 698
 	}
699 699
 
700 700
 	return $pdf->getY();
@@ -715,76 +715,76 @@  discard block
 block discarded – undo
715 715
  *  @param	int			$hidefreetext	1=Hide free text, 0=Show free text
716 716
  * 	@return	int							Return height of bottom margin including footer text
717 717
  */
718
-function pdf_pagefoot(&$pdf,$outputlangs,$paramfreetext,$fromcompany,$marge_basse,$marge_gauche,$page_hauteur,$object,$showdetails=0,$hidefreetext=0)
718
+function pdf_pagefoot(&$pdf, $outputlangs, $paramfreetext, $fromcompany, $marge_basse, $marge_gauche, $page_hauteur, $object, $showdetails = 0, $hidefreetext = 0)
719 719
 {
720
-	global $conf,$user;
720
+	global $conf, $user;
721 721
 
722 722
 	$outputlangs->load("dict");
723
-	$line='';
723
+	$line = '';
724 724
 
725
-	$dims=$pdf->getPageDimensions();
725
+	$dims = $pdf->getPageDimensions();
726 726
 
727 727
 	// Line of free text
728
-	if (empty($hidefreetext) && ! empty($conf->global->$paramfreetext))
728
+	if (empty($hidefreetext) && !empty($conf->global->$paramfreetext))
729 729
 	{
730 730
 		// Make substitution
731
-		$substitutionarray=array(
731
+		$substitutionarray = array(
732 732
 			'__FROM_NAME__' => $fromcompany->name,
733 733
 			'__FROM_EMAIL__' => $fromcompany->email,
734 734
 			'__TOTAL_TTC__' => $object->total_ttc,
735 735
 			'__TOTAL_HT__' => $object->total_ht,
736 736
 			'__TOTAL_VAT__' => $object->total_vat
737 737
 		);
738
-		complete_substitutions_array($substitutionarray,$outputlangs,$object);
739
-		$newfreetext=make_substitutions($conf->global->$paramfreetext,$substitutionarray);
740
-		$line.=$outputlangs->convToOutputCharset($newfreetext);
738
+		complete_substitutions_array($substitutionarray, $outputlangs, $object);
739
+		$newfreetext = make_substitutions($conf->global->$paramfreetext, $substitutionarray);
740
+		$line .= $outputlangs->convToOutputCharset($newfreetext);
741 741
 	}
742 742
 
743 743
 	// First line of company infos
744
-	$line1=""; $line2=""; $line3=""; $line4="";
744
+	$line1 = ""; $line2 = ""; $line3 = ""; $line4 = "";
745 745
 
746 746
 	if ($showdetails)
747 747
 	{
748 748
 		// Company name
749 749
 		if ($fromcompany->name)
750 750
 		{
751
-			$line1.=($line1?" - ":"").$outputlangs->transnoentities("RegisteredOffice").": ".$fromcompany->name;
751
+			$line1 .= ($line1 ? " - " : "").$outputlangs->transnoentities("RegisteredOffice").": ".$fromcompany->name;
752 752
 		}
753 753
 		// Address
754 754
 		if ($fromcompany->address)
755 755
 		{
756
-			$line1.=($line1?" - ":"").$fromcompany->address;
756
+			$line1 .= ($line1 ? " - " : "").$fromcompany->address;
757 757
 		}
758 758
 		// Zip code
759 759
 		if ($fromcompany->zip)
760 760
 		{
761
-			$line1.=($line1?" - ":"").$fromcompany->zip;
761
+			$line1 .= ($line1 ? " - " : "").$fromcompany->zip;
762 762
 		}
763 763
 		// Town
764 764
 		if ($fromcompany->town)
765 765
 		{
766
-			$line1.=($line1?" ":"").$fromcompany->town;
766
+			$line1 .= ($line1 ? " " : "").$fromcompany->town;
767 767
 		}
768 768
 		// Phone
769 769
 		if ($fromcompany->phone)
770 770
 		{
771
-			$line1.=($line1?" - ":"").$outputlangs->transnoentities("Phone").": ".$fromcompany->phone;
771
+			$line1 .= ($line1 ? " - " : "").$outputlangs->transnoentities("Phone").": ".$fromcompany->phone;
772 772
 		}
773 773
 		// Fax
774 774
 		if ($fromcompany->fax)
775 775
 		{
776
-			$line1.=($line1?" - ":"").$outputlangs->transnoentities("Fax").": ".$fromcompany->fax;
776
+			$line1 .= ($line1 ? " - " : "").$outputlangs->transnoentities("Fax").": ".$fromcompany->fax;
777 777
 		}
778 778
 
779 779
 		// URL
780 780
 		if ($fromcompany->url)
781 781
 		{
782
-			$line2.=($line2?" - ":"").$fromcompany->url;
782
+			$line2 .= ($line2 ? " - " : "").$fromcompany->url;
783 783
 		}
784 784
 		// Email
785 785
 		if ($fromcompany->email)
786 786
 		{
787
-			$line2.=($line2?" - ":"").$fromcompany->email;
787
+			$line2 .= ($line2 ? " - " : "").$fromcompany->email;
788 788
 		}
789 789
 	}
790 790
 	if ($showdetails || ($fromcompany->country_code == 'DE'))
@@ -792,7 +792,7 @@  discard block
 block discarded – undo
792 792
 		// Managers
793 793
 		if ($fromcompany->managers)
794 794
 		{
795
-			$line2.=($line2?" - ":"").$fromcompany->managers;
795
+			$line2 .= ($line2 ? " - " : "").$fromcompany->managers;
796 796
 		}
797 797
 	}
798 798
 
@@ -800,114 +800,114 @@  discard block
 block discarded – undo
800 800
 	// Juridical status
801 801
 	if ($fromcompany->forme_juridique_code)
802 802
 	{
803
-		$line3.=($line3?" - ":"").$outputlangs->convToOutputCharset(getFormeJuridiqueLabel($fromcompany->forme_juridique_code));
803
+		$line3 .= ($line3 ? " - " : "").$outputlangs->convToOutputCharset(getFormeJuridiqueLabel($fromcompany->forme_juridique_code));
804 804
 	}
805 805
 	// Capital
806 806
 	if ($fromcompany->capital)
807 807
 	{
808 808
 		$tmpamounttoshow = price2num($fromcompany->capital); // This field is a free string
809
-		if (is_numeric($tmpamounttoshow) && $tmpamounttoshow > 0) $line3.=($line3?" - ":"").$outputlangs->transnoentities("CapitalOf",price($tmpamounttoshow, 0, $outputlangs, 0, 0, 0, $conf->currency));
810
-		else $line3.=($line3?" - ":"").$outputlangs->transnoentities("CapitalOf",$tmpamounttoshow,$outputlangs);
809
+		if (is_numeric($tmpamounttoshow) && $tmpamounttoshow > 0) $line3 .= ($line3 ? " - " : "").$outputlangs->transnoentities("CapitalOf", price($tmpamounttoshow, 0, $outputlangs, 0, 0, 0, $conf->currency));
810
+		else $line3 .= ($line3 ? " - " : "").$outputlangs->transnoentities("CapitalOf", $tmpamounttoshow, $outputlangs);
811 811
 	}
812 812
 	// Prof Id 1
813
-	if ($fromcompany->idprof1 && ($fromcompany->country_code != 'FR' || ! $fromcompany->idprof2))
813
+	if ($fromcompany->idprof1 && ($fromcompany->country_code != 'FR' || !$fromcompany->idprof2))
814 814
 	{
815
-		$field=$outputlangs->transcountrynoentities("ProfId1",$fromcompany->country_code);
816
-		if (preg_match('/\((.*)\)/i',$field,$reg)) $field=$reg[1];
817
-		$line3.=($line3?" - ":"").$field.": ".$outputlangs->convToOutputCharset($fromcompany->idprof1);
815
+		$field = $outputlangs->transcountrynoentities("ProfId1", $fromcompany->country_code);
816
+		if (preg_match('/\((.*)\)/i', $field, $reg)) $field = $reg[1];
817
+		$line3 .= ($line3 ? " - " : "").$field.": ".$outputlangs->convToOutputCharset($fromcompany->idprof1);
818 818
 	}
819 819
 	// Prof Id 2
820 820
 	if ($fromcompany->idprof2)
821 821
 	{
822
-		$field=$outputlangs->transcountrynoentities("ProfId2",$fromcompany->country_code);
823
-		if (preg_match('/\((.*)\)/i',$field,$reg)) $field=$reg[1];
824
-		$line3.=($line3?" - ":"").$field.": ".$outputlangs->convToOutputCharset($fromcompany->idprof2);
822
+		$field = $outputlangs->transcountrynoentities("ProfId2", $fromcompany->country_code);
823
+		if (preg_match('/\((.*)\)/i', $field, $reg)) $field = $reg[1];
824
+		$line3 .= ($line3 ? " - " : "").$field.": ".$outputlangs->convToOutputCharset($fromcompany->idprof2);
825 825
 	}
826 826
 
827 827
 	// Line 4 of company infos
828 828
 	// Prof Id 3
829 829
 	if ($fromcompany->idprof3)
830 830
 	{
831
-		$field=$outputlangs->transcountrynoentities("ProfId3",$fromcompany->country_code);
832
-		if (preg_match('/\((.*)\)/i',$field,$reg)) $field=$reg[1];
833
-		$line4.=($line4?" - ":"").$field.": ".$outputlangs->convToOutputCharset($fromcompany->idprof3);
831
+		$field = $outputlangs->transcountrynoentities("ProfId3", $fromcompany->country_code);
832
+		if (preg_match('/\((.*)\)/i', $field, $reg)) $field = $reg[1];
833
+		$line4 .= ($line4 ? " - " : "").$field.": ".$outputlangs->convToOutputCharset($fromcompany->idprof3);
834 834
 	}
835 835
 	// Prof Id 4
836 836
 	if ($fromcompany->idprof4)
837 837
 	{
838
-		$field=$outputlangs->transcountrynoentities("ProfId4",$fromcompany->country_code);
839
-		if (preg_match('/\((.*)\)/i',$field,$reg)) $field=$reg[1];
840
-		$line4.=($line4?" - ":"").$field.": ".$outputlangs->convToOutputCharset($fromcompany->idprof4);
838
+		$field = $outputlangs->transcountrynoentities("ProfId4", $fromcompany->country_code);
839
+		if (preg_match('/\((.*)\)/i', $field, $reg)) $field = $reg[1];
840
+		$line4 .= ($line4 ? " - " : "").$field.": ".$outputlangs->convToOutputCharset($fromcompany->idprof4);
841 841
 	}
842 842
 	// IntraCommunautary VAT
843 843
 	if ($fromcompany->tva_intra != '')
844 844
 	{
845
-		$line4.=($line4?" - ":"").$outputlangs->transnoentities("VATIntraShort").": ".$outputlangs->convToOutputCharset($fromcompany->tva_intra);
845
+		$line4 .= ($line4 ? " - " : "").$outputlangs->transnoentities("VATIntraShort").": ".$outputlangs->convToOutputCharset($fromcompany->tva_intra);
846 846
 	}
847 847
 
848
-	$pdf->SetFont('','',7);
849
-	$pdf->SetDrawColor(224,224,224);
848
+	$pdf->SetFont('', '', 7);
849
+	$pdf->SetDrawColor(224, 224, 224);
850 850
 
851 851
 	// The start of the bottom of this page footer is positioned according to # of lines
852
-	$freetextheight=0;
852
+	$freetextheight = 0;
853 853
 	if ($line)	// Free text
854 854
 	{
855
-		$width=20000; $align='L';	// By default, ask a manual break: We use a large value 20000, to not have automatic wrap. This make user understand, he need to add CR on its text.
856
-		if (! empty($conf->global->MAIN_USE_AUTOWRAP_ON_FREETEXT)) {
857
-			$width=200; $align='C';
855
+		$width = 20000; $align = 'L'; // By default, ask a manual break: We use a large value 20000, to not have automatic wrap. This make user understand, he need to add CR on its text.
856
+		if (!empty($conf->global->MAIN_USE_AUTOWRAP_ON_FREETEXT)) {
857
+			$width = 200; $align = 'C';
858 858
 		}
859
-		$freetextheight=$pdf->getStringHeight($width,$line);
859
+		$freetextheight = $pdf->getStringHeight($width, $line);
860 860
 	}
861 861
 
862
-	$marginwithfooter=$marge_basse + $freetextheight + (! empty($line1)?3:0) + (! empty($line2)?3:0) + (! empty($line3)?3:0) + (! empty($line4)?3:0);
863
-	$posy=$marginwithfooter+0;
862
+	$marginwithfooter = $marge_basse + $freetextheight + (!empty($line1) ? 3 : 0) + (!empty($line2) ? 3 : 0) + (!empty($line3) ? 3 : 0) + (!empty($line4) ? 3 : 0);
863
+	$posy = $marginwithfooter + 0;
864 864
 
865 865
 	if ($line)	// Free text
866 866
 	{
867
-		$pdf->SetXY($dims['lm'],-$posy);
867
+		$pdf->SetXY($dims['lm'], -$posy);
868 868
 		$pdf->MultiCell(0, 3, $line, 0, $align, 0);
869
-		$posy-=$freetextheight;
869
+		$posy -= $freetextheight;
870 870
 	}
871 871
 
872 872
 	$pdf->SetY(-$posy);
873
-	$pdf->line($dims['lm'], $dims['hk']-$posy, $dims['wk']-$dims['rm'], $dims['hk']-$posy);
873
+	$pdf->line($dims['lm'], $dims['hk'] - $posy, $dims['wk'] - $dims['rm'], $dims['hk'] - $posy);
874 874
 	$posy--;
875 875
 
876
-	if (! empty($line1))
876
+	if (!empty($line1))
877 877
 	{
878
-		$pdf->SetFont('','B',7);
879
-		$pdf->SetXY($dims['lm'],-$posy);
880
-		$pdf->MultiCell($dims['wk']-$dims['rm'], 2, $line1, 0, 'C', 0);
881
-		$posy-=3;
882
-		$pdf->SetFont('','',7);
878
+		$pdf->SetFont('', 'B', 7);
879
+		$pdf->SetXY($dims['lm'], -$posy);
880
+		$pdf->MultiCell($dims['wk'] - $dims['rm'], 2, $line1, 0, 'C', 0);
881
+		$posy -= 3;
882
+		$pdf->SetFont('', '', 7);
883 883
 	}
884 884
 
885
-	if (! empty($line2))
885
+	if (!empty($line2))
886 886
 	{
887
-		$pdf->SetFont('','B',7);
888
-		$pdf->SetXY($dims['lm'],-$posy);
889
-		$pdf->MultiCell($dims['wk']-$dims['rm'], 2, $line2, 0, 'C', 0);
890
-		$posy-=3;
891
-		$pdf->SetFont('','',7);
887
+		$pdf->SetFont('', 'B', 7);
888
+		$pdf->SetXY($dims['lm'], -$posy);
889
+		$pdf->MultiCell($dims['wk'] - $dims['rm'], 2, $line2, 0, 'C', 0);
890
+		$posy -= 3;
891
+		$pdf->SetFont('', '', 7);
892 892
 	}
893 893
 
894
-	if (! empty($line3))
894
+	if (!empty($line3))
895 895
 	{
896
-		$pdf->SetXY($dims['lm'],-$posy);
897
-		$pdf->MultiCell($dims['wk']-$dims['rm'], 2, $line3, 0, 'C', 0);
896
+		$pdf->SetXY($dims['lm'], -$posy);
897
+		$pdf->MultiCell($dims['wk'] - $dims['rm'], 2, $line3, 0, 'C', 0);
898 898
 	}
899 899
 
900
-	if (! empty($line4))
900
+	if (!empty($line4))
901 901
 	{
902
-		$posy-=3;
903
-		$pdf->SetXY($dims['lm'],-$posy);
904
-		$pdf->MultiCell($dims['wk']-$dims['rm'], 2, $line4, 0, 'C', 0);
902
+		$posy -= 3;
903
+		$pdf->SetXY($dims['lm'], -$posy);
904
+		$pdf->MultiCell($dims['wk'] - $dims['rm'], 2, $line4, 0, 'C', 0);
905 905
 	}
906 906
 
907 907
 	// Show page nb only on iso languages (so default Helvetica font)
908 908
 	if (strtolower(pdf_getPDFFont($outputlangs)) == 'helvetica')
909 909
 	{
910
-		$pdf->SetXY(-20,-$posy);
910
+		$pdf->SetXY(-20, -$posy);
911 911
 		//print 'xxx'.$pdf->PageNo().'-'.$pdf->getAliasNbPages().'-'.$pdf->getAliasNumPage();exit;
912 912
 		if (empty($conf->global->MAIN_USE_FPDF)) $pdf->MultiCell(13, 2, $pdf->PageNo().'/'.$pdf->getAliasNbPages(), 0, 'R', 0);
913 913
 		else $pdf->MultiCell(13, 2, $pdf->PageNo().'/{nb}', 0, 'R', 0);
@@ -930,22 +930,22 @@  discard block
 block discarded – undo
930 930
  *	@param	string		$default_font_size	Font size
931 931
  *	@return	float                           The Y PDF position
932 932
  */
933
-function pdf_writeLinkedObjects(&$pdf,$object,$outputlangs,$posx,$posy,$w,$h,$align,$default_font_size)
933
+function pdf_writeLinkedObjects(&$pdf, $object, $outputlangs, $posx, $posy, $w, $h, $align, $default_font_size)
934 934
 {
935
-	$linkedobjects = pdf_getLinkedObjects($object,$outputlangs);
936
-	if (! empty($linkedobjects))
935
+	$linkedobjects = pdf_getLinkedObjects($object, $outputlangs);
936
+	if (!empty($linkedobjects))
937 937
 	{
938
-		foreach($linkedobjects as $linkedobject)
938
+		foreach ($linkedobjects as $linkedobject)
939 939
 		{
940
-			$posy+=3;
941
-			$pdf->SetXY($posx,$posy);
942
-			$pdf->SetFont('','', $default_font_size - 2);
940
+			$posy += 3;
941
+			$pdf->SetXY($posx, $posy);
942
+			$pdf->SetFont('', '', $default_font_size - 2);
943 943
 			$pdf->MultiCell($w, $h, $linkedobject["ref_title"].' : '.$linkedobject["ref_value"], '', $align);
944 944
 
945
-			if (! empty($linkedobject["date_title"]) && ! empty($linkedobject["date_value"]))
945
+			if (!empty($linkedobject["date_title"]) && !empty($linkedobject["date_value"]))
946 946
 			{
947
-				$posy+=3;
948
-				$pdf->SetXY($posx,$posy);
947
+				$posy += 3;
948
+				$pdf->SetXY($posx, $posy);
949 949
 				$pdf->MultiCell($w, $h, $linkedobject["date_title"].' : '.$linkedobject["date_value"], '', $align);
950 950
 			}
951 951
 		}
@@ -970,24 +970,24 @@  discard block
 block discarded – undo
970 970
  * 	@param	int				$issupplierline		Is it a line for a supplier object ?
971 971
  * 	@return	string|null
972 972
  */
973
-function pdf_writelinedesc(&$pdf,$object,$i,$outputlangs,$w,$h,$posx,$posy,$hideref=0,$hidedesc=0,$issupplierline=0)
973
+function pdf_writelinedesc(&$pdf, $object, $i, $outputlangs, $w, $h, $posx, $posy, $hideref = 0, $hidedesc = 0, $issupplierline = 0)
974 974
 {
975 975
 	global $db, $conf, $langs, $hookmanager;
976 976
 
977
-	$reshook=0;
978
-	if (is_object($hookmanager) && ( (isset($object->lines[$i]->product_type) && $object->lines[$i]->product_type == 9 && ! empty($object->lines[$i]->special_code)) || ! empty($object->lines[$i]->fk_parent_line) ) )
977
+	$reshook = 0;
978
+	if (is_object($hookmanager) && ((isset($object->lines[$i]->product_type) && $object->lines[$i]->product_type == 9 && !empty($object->lines[$i]->special_code)) || !empty($object->lines[$i]->fk_parent_line)))
979 979
 	{
980 980
 		$special_code = $object->lines[$i]->special_code;
981
-		if (! empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line);
982
-		$parameters = array('pdf'=>$pdf,'i'=>$i,'outputlangs'=>$outputlangs,'w'=>$w,'h'=>$h,'posx'=>$posx,'posy'=>$posy,'hideref'=>$hideref,'hidedesc'=>$hidedesc,'issupplierline'=>$issupplierline,'special_code'=>$special_code);
983
-		$action='';
984
-		$reshook=$hookmanager->executeHooks('pdf_writelinedesc',$parameters,$object,$action);    // Note that $action and $object may have been modified by some hooks
981
+		if (!empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line);
982
+		$parameters = array('pdf'=>$pdf, 'i'=>$i, 'outputlangs'=>$outputlangs, 'w'=>$w, 'h'=>$h, 'posx'=>$posx, 'posy'=>$posy, 'hideref'=>$hideref, 'hidedesc'=>$hidedesc, 'issupplierline'=>$issupplierline, 'special_code'=>$special_code);
983
+		$action = '';
984
+		$reshook = $hookmanager->executeHooks('pdf_writelinedesc', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
985 985
 	}
986 986
 	if (empty($reshook))
987 987
 	{
988
-		$labelproductservice=pdf_getlinedesc($object,$i,$outputlangs,$hideref,$hidedesc,$issupplierline);
988
+		$labelproductservice = pdf_getlinedesc($object, $i, $outputlangs, $hideref, $hidedesc, $issupplierline);
989 989
 		// Description
990
-		$pdf->writeHTMLCell($w, $h, $posx, $posy, $outputlangs->convToOutputCharset($labelproductservice), 0, 1, false, true, 'J',true);
990
+		$pdf->writeHTMLCell($w, $h, $posx, $posy, $outputlangs->convToOutputCharset($labelproductservice), 0, 1, false, true, 'J', true);
991 991
 		return $labelproductservice;
992 992
 	}
993 993
 }
@@ -1003,16 +1003,16 @@  discard block
 block discarded – undo
1003 1003
  *  @param  int			$issupplierline      Is it a line for a supplier object ?
1004 1004
  *  @return string       				     String with line
1005 1005
  */
1006
-function pdf_getlinedesc($object,$i,$outputlangs,$hideref=0,$hidedesc=0,$issupplierline=0)
1006
+function pdf_getlinedesc($object, $i, $outputlangs, $hideref = 0, $hidedesc = 0, $issupplierline = 0)
1007 1007
 {
1008 1008
 	global $db, $conf, $langs;
1009 1009
 
1010
-	$idprod=(! empty($object->lines[$i]->fk_product)?$object->lines[$i]->fk_product:false);
1011
-	$label=(! empty($object->lines[$i]->label)?$object->lines[$i]->label:(! empty($object->lines[$i]->product_label)?$object->lines[$i]->product_label:''));
1012
-	$desc=(! empty($object->lines[$i]->desc)?$object->lines[$i]->desc:(! empty($object->lines[$i]->description)?$object->lines[$i]->description:''));
1013
-	$ref_supplier=(! empty($object->lines[$i]->ref_supplier)?$object->lines[$i]->ref_supplier:(! empty($object->lines[$i]->ref_fourn)?$object->lines[$i]->ref_fourn:''));    // TODO Not yet saved for supplier invoices, only supplier orders
1014
-	$note=(! empty($object->lines[$i]->note)?$object->lines[$i]->note:'');
1015
-	$dbatch=(! empty($object->lines[$i]->detail_batch)?$object->lines[$i]->detail_batch:false);
1010
+	$idprod = (!empty($object->lines[$i]->fk_product) ? $object->lines[$i]->fk_product : false);
1011
+	$label = (!empty($object->lines[$i]->label) ? $object->lines[$i]->label : (!empty($object->lines[$i]->product_label) ? $object->lines[$i]->product_label : ''));
1012
+	$desc = (!empty($object->lines[$i]->desc) ? $object->lines[$i]->desc : (!empty($object->lines[$i]->description) ? $object->lines[$i]->description : ''));
1013
+	$ref_supplier = (!empty($object->lines[$i]->ref_supplier) ? $object->lines[$i]->ref_supplier : (!empty($object->lines[$i]->ref_fourn) ? $object->lines[$i]->ref_fourn : '')); // TODO Not yet saved for supplier invoices, only supplier orders
1014
+	$note = (!empty($object->lines[$i]->note) ? $object->lines[$i]->note : '');
1015
+	$dbatch = (!empty($object->lines[$i]->detail_batch) ? $object->lines[$i]->detail_batch : false);
1016 1016
 
1017 1017
 	if ($issupplierline) $prodser = new ProductFournisseur($db);
1018 1018
 	else $prodser = new Product($db);
@@ -1021,9 +1021,9 @@  discard block
 block discarded – undo
1021 1021
 	{
1022 1022
 		$prodser->fetch($idprod);
1023 1023
 		// If a predefined product and multilang and on other lang, we renamed label with label translated
1024
-		if (! empty($conf->global->MAIN_MULTILANGS) && ($outputlangs->defaultlang != $langs->defaultlang))
1024
+		if (!empty($conf->global->MAIN_MULTILANGS) && ($outputlangs->defaultlang != $langs->defaultlang))
1025 1025
 		{
1026
-			$translatealsoifmodified=(! empty($conf->global->MAIN_MULTILANG_TRANSLATE_EVEN_IF_MODIFIED));	// By default if value was modified manually, we keep it (no translation because we don't have it)
1026
+			$translatealsoifmodified = (!empty($conf->global->MAIN_MULTILANG_TRANSLATE_EVEN_IF_MODIFIED)); // By default if value was modified manually, we keep it (no translation because we don't have it)
1027 1027
 
1028 1028
 			// TODO Instead of making a compare to see if param was modified, check that content contains reference translation. If yes, add the added part to the new translation
1029 1029
 			// ($textwasmodified is replaced with $textwasmodifiedorcompleted and we add completion).
@@ -1031,59 +1031,59 @@  discard block
 block discarded – undo
1031 1031
 			// Set label
1032 1032
 			// If we want another language, and if label is same than default language (we did force it to a specific value), we can use translation.
1033 1033
 			//var_dump($outputlangs->defaultlang.' - '.$langs->defaultlang.' - '.$label.' - '.$prodser->label);exit;
1034
-			$textwasmodified=($label == $prodser->label);
1035
-			if (! empty($prodser->multilangs[$outputlangs->defaultlang]["label"]) && ($textwasmodified || $translatealsoifmodified))     $label=$prodser->multilangs[$outputlangs->defaultlang]["label"];
1034
+			$textwasmodified = ($label == $prodser->label);
1035
+			if (!empty($prodser->multilangs[$outputlangs->defaultlang]["label"]) && ($textwasmodified || $translatealsoifmodified))     $label = $prodser->multilangs[$outputlangs->defaultlang]["label"];
1036 1036
 
1037 1037
 			// Set desc
1038 1038
 			// Manage HTML entities description test because $prodser->description is store with htmlentities but $desc no
1039
-			$textwasmodified=false;
1039
+			$textwasmodified = false;
1040 1040
 			if (!empty($desc) && dol_textishtml($desc) && !empty($prodser->description) && dol_textishtml($prodser->description)) {
1041
-				$textwasmodified=(strpos(dol_html_entity_decode($desc,ENT_QUOTES | ENT_HTML401),dol_html_entity_decode($prodser->description,ENT_QUOTES | ENT_HTML401))!==false);
1041
+				$textwasmodified = (strpos(dol_html_entity_decode($desc, ENT_QUOTES | ENT_HTML401), dol_html_entity_decode($prodser->description, ENT_QUOTES | ENT_HTML401)) !== false);
1042 1042
 			} else {
1043
-				$textwasmodified=($desc == $prodser->description);
1043
+				$textwasmodified = ($desc == $prodser->description);
1044 1044
 			}
1045
-			if (! empty($prodser->multilangs[$outputlangs->defaultlang]["description"]) && ($textwasmodified || $translatealsoifmodified))  $desc=$prodser->multilangs[$outputlangs->defaultlang]["description"];
1045
+			if (!empty($prodser->multilangs[$outputlangs->defaultlang]["description"]) && ($textwasmodified || $translatealsoifmodified))  $desc = $prodser->multilangs[$outputlangs->defaultlang]["description"];
1046 1046
 
1047 1047
 			// Set note
1048
-			$textwasmodified=($note == $prodser->note);
1049
-			if (! empty($prodser->multilangs[$outputlangs->defaultlang]["note"]) && ($textwasmodified || $translatealsoifmodified))  $note=$prodser->multilangs[$outputlangs->defaultlang]["note"];
1048
+			$textwasmodified = ($note == $prodser->note);
1049
+			if (!empty($prodser->multilangs[$outputlangs->defaultlang]["note"]) && ($textwasmodified || $translatealsoifmodified))  $note = $prodser->multilangs[$outputlangs->defaultlang]["note"];
1050 1050
 		}
1051 1051
 	}
1052 1052
 
1053 1053
 	// Description short of product line
1054
-	$libelleproduitservice=$label;
1054
+	$libelleproduitservice = $label;
1055 1055
 
1056 1056
 	// Description long of product line
1057
-	if (! empty($desc) && ($desc != $label))
1057
+	if (!empty($desc) && ($desc != $label))
1058 1058
 	{
1059 1059
 		if ($libelleproduitservice && empty($hidedesc))
1060 1060
 		{
1061
-			$libelleproduitservice.='__N__';
1061
+			$libelleproduitservice .= '__N__';
1062 1062
 		}
1063 1063
 
1064 1064
 		if ($desc == '(CREDIT_NOTE)' && $object->lines[$i]->fk_remise_except)
1065 1065
 		{
1066
-			$discount=new DiscountAbsolute($db);
1066
+			$discount = new DiscountAbsolute($db);
1067 1067
 			$discount->fetch($object->lines[$i]->fk_remise_except);
1068
-			$libelleproduitservice=$outputlangs->transnoentitiesnoconv("DiscountFromCreditNote",$discount->ref_facture_source);
1068
+			$libelleproduitservice = $outputlangs->transnoentitiesnoconv("DiscountFromCreditNote", $discount->ref_facture_source);
1069 1069
 		}
1070 1070
 		elseif ($desc == '(DEPOSIT)' && $object->lines[$i]->fk_remise_except)
1071 1071
 		{
1072
-			$discount=new DiscountAbsolute($db);
1072
+			$discount = new DiscountAbsolute($db);
1073 1073
 			$discount->fetch($object->lines[$i]->fk_remise_except);
1074
-			$libelleproduitservice=$outputlangs->transnoentitiesnoconv("DiscountFromDeposit",$discount->ref_facture_source);
1074
+			$libelleproduitservice = $outputlangs->transnoentitiesnoconv("DiscountFromDeposit", $discount->ref_facture_source);
1075 1075
 			// Add date of deposit
1076
-			if (! empty($conf->global->INVOICE_ADD_DEPOSIT_DATE)) echo ' ('.dol_print_date($discount->datec,'day','',$outputlangs).')';
1076
+			if (!empty($conf->global->INVOICE_ADD_DEPOSIT_DATE)) echo ' ('.dol_print_date($discount->datec, 'day', '', $outputlangs).')';
1077 1077
 		}
1078 1078
 		else
1079 1079
 		{
1080 1080
 			if ($idprod)
1081 1081
 			{
1082
-				if (empty($hidedesc)) $libelleproduitservice.=$desc;
1082
+				if (empty($hidedesc)) $libelleproduitservice .= $desc;
1083 1083
 			}
1084 1084
 			else
1085 1085
 			{
1086
-				$libelleproduitservice.=$desc;
1086
+				$libelleproduitservice .= $desc;
1087 1087
 			}
1088 1088
 		}
1089 1089
 	}
@@ -1096,7 +1096,7 @@  discard block
 block discarded – undo
1096 1096
 		{
1097 1097
 			$prefix_prodserv = "";
1098 1098
 			$ref_prodserv = "";
1099
-			if (! empty($conf->global->PRODUCT_ADD_TYPE_IN_DOCUMENTS))   // In standard mode, we do not show this
1099
+			if (!empty($conf->global->PRODUCT_ADD_TYPE_IN_DOCUMENTS))   // In standard mode, we do not show this
1100 1100
 			{
1101 1101
 				if ($prodser->isservice())
1102 1102
 				{
@@ -1110,71 +1110,71 @@  discard block
 block discarded – undo
1110 1110
 
1111 1111
 			if (empty($hideref))
1112 1112
 			{
1113
-				if ($issupplierline) $ref_prodserv = $prodser->ref.($ref_supplier ? ' ('.$outputlangs->transnoentitiesnoconv("SupplierRef").' '.$ref_supplier.')' : '');   // Show local ref and supplier ref
1113
+				if ($issupplierline) $ref_prodserv = $prodser->ref.($ref_supplier ? ' ('.$outputlangs->transnoentitiesnoconv("SupplierRef").' '.$ref_supplier.')' : ''); // Show local ref and supplier ref
1114 1114
 				else $ref_prodserv = $prodser->ref; // Show local ref only
1115 1115
 
1116
-				if (! empty($libelleproduitservice)) $ref_prodserv .= " - ";
1116
+				if (!empty($libelleproduitservice)) $ref_prodserv .= " - ";
1117 1117
 			}
1118 1118
 
1119
-			$libelleproduitservice=$prefix_prodserv.$ref_prodserv.$libelleproduitservice;
1119
+			$libelleproduitservice = $prefix_prodserv.$ref_prodserv.$libelleproduitservice;
1120 1120
 		}
1121 1121
 	}
1122 1122
 
1123 1123
 	// Add an additional description for the category products
1124
-	if (! empty($conf->global->CATEGORY_ADD_DESC_INTO_DOC) && $idprod && ! empty($conf->categorie->enabled))
1124
+	if (!empty($conf->global->CATEGORY_ADD_DESC_INTO_DOC) && $idprod && !empty($conf->categorie->enabled))
1125 1125
 	{
1126 1126
 		include_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
1127
-		$categstatic=new Categorie($db);
1127
+		$categstatic = new Categorie($db);
1128 1128
 		// recovering the list of all the categories linked to product
1129
-		$tblcateg=$categstatic->containing($idprod, Categorie::TYPE_PRODUCT);
1129
+		$tblcateg = $categstatic->containing($idprod, Categorie::TYPE_PRODUCT);
1130 1130
 		foreach ($tblcateg as $cate)
1131 1131
 		{
1132 1132
 			// Adding the descriptions if they are filled
1133
-			$desccateg=$cate->add_description;
1133
+			$desccateg = $cate->add_description;
1134 1134
 			if ($desccateg)
1135
-				$libelleproduitservice.='__N__'.$desccateg;
1135
+				$libelleproduitservice .= '__N__'.$desccateg;
1136 1136
 		}
1137 1137
 	}
1138 1138
 
1139
-	if (! empty($object->lines[$i]->date_start) || ! empty($object->lines[$i]->date_end))
1139
+	if (!empty($object->lines[$i]->date_start) || !empty($object->lines[$i]->date_end))
1140 1140
 	{
1141
-		$format='day';
1141
+		$format = 'day';
1142 1142
 		// Show duration if exists
1143 1143
 		if ($object->lines[$i]->date_start && $object->lines[$i]->date_end)
1144 1144
 		{
1145
-			$period='('.$outputlangs->transnoentitiesnoconv('DateFromTo',dol_print_date($object->lines[$i]->date_start, $format, false, $outputlangs),dol_print_date($object->lines[$i]->date_end, $format, false, $outputlangs)).')';
1145
+			$period = '('.$outputlangs->transnoentitiesnoconv('DateFromTo', dol_print_date($object->lines[$i]->date_start, $format, false, $outputlangs), dol_print_date($object->lines[$i]->date_end, $format, false, $outputlangs)).')';
1146 1146
 		}
1147
-		if ($object->lines[$i]->date_start && ! $object->lines[$i]->date_end)
1147
+		if ($object->lines[$i]->date_start && !$object->lines[$i]->date_end)
1148 1148
 		{
1149
-			$period='('.$outputlangs->transnoentitiesnoconv('DateFrom',dol_print_date($object->lines[$i]->date_start, $format, false, $outputlangs)).')';
1149
+			$period = '('.$outputlangs->transnoentitiesnoconv('DateFrom', dol_print_date($object->lines[$i]->date_start, $format, false, $outputlangs)).')';
1150 1150
 		}
1151
-		if (! $object->lines[$i]->date_start && $object->lines[$i]->date_end)
1151
+		if (!$object->lines[$i]->date_start && $object->lines[$i]->date_end)
1152 1152
 		{
1153
-			$period='('.$outputlangs->transnoentitiesnoconv('DateUntil',dol_print_date($object->lines[$i]->date_end, $format, false, $outputlangs)).')';
1153
+			$period = '('.$outputlangs->transnoentitiesnoconv('DateUntil', dol_print_date($object->lines[$i]->date_end, $format, false, $outputlangs)).')';
1154 1154
 		}
1155 1155
 		//print '>'.$outputlangs->charset_output.','.$period;
1156
-		$libelleproduitservice.="__N__".$period;
1156
+		$libelleproduitservice .= "__N__".$period;
1157 1157
 		//print $libelleproduitservice;
1158 1158
 	}
1159 1159
 
1160 1160
 	if ($dbatch)
1161 1161
 	{
1162
-		$format='day';
1162
+		$format = 'day';
1163 1163
 		foreach ($dbatch as $detail)
1164 1164
 		{
1165
-			$dte=array();
1166
-			if ($detail->eatby) $dte[]=$outputlangs->transnoentitiesnoconv('printEatby',dol_print_date($detail->eatby, $format, false, $outputlangs));
1167
-			if ($detail->sellby) $dte[]=$outputlangs->transnoentitiesnoconv('printSellby',dol_print_date($detail->sellby, $format, false, $outputlangs));
1168
-			if ($detail->batch) $dte[]=$outputlangs->transnoentitiesnoconv('printBatch',$detail->batch);
1169
-			$dte[]=$outputlangs->transnoentitiesnoconv('printQty',$detail->dluo_qty);
1170
-			$libelleproduitservice.= "__N__  ".implode($dte,"-");
1165
+			$dte = array();
1166
+			if ($detail->eatby) $dte[] = $outputlangs->transnoentitiesnoconv('printEatby', dol_print_date($detail->eatby, $format, false, $outputlangs));
1167
+			if ($detail->sellby) $dte[] = $outputlangs->transnoentitiesnoconv('printSellby', dol_print_date($detail->sellby, $format, false, $outputlangs));
1168
+			if ($detail->batch) $dte[] = $outputlangs->transnoentitiesnoconv('printBatch', $detail->batch);
1169
+			$dte[] = $outputlangs->transnoentitiesnoconv('printQty', $detail->dluo_qty);
1170
+			$libelleproduitservice .= "__N__  ".implode($dte, "-");
1171 1171
 		}
1172 1172
 	}
1173 1173
 
1174 1174
 	// Now we convert \n into br
1175
-	if (dol_textishtml($libelleproduitservice)) $libelleproduitservice=preg_replace('/__N__/','<br>',$libelleproduitservice);
1176
-	else $libelleproduitservice=preg_replace('/__N__/',"\n",$libelleproduitservice);
1177
-	$libelleproduitservice=dol_htmlentitiesbr($libelleproduitservice,1);
1175
+	if (dol_textishtml($libelleproduitservice)) $libelleproduitservice = preg_replace('/__N__/', '<br>', $libelleproduitservice);
1176
+	else $libelleproduitservice = preg_replace('/__N__/', "\n", $libelleproduitservice);
1177
+	$libelleproduitservice = dol_htmlentitiesbr($libelleproduitservice, 1);
1178 1178
 
1179 1179
 	return $libelleproduitservice;
1180 1180
 }
@@ -1188,14 +1188,14 @@  discard block
 block discarded – undo
1188 1188
  *  @param	int			$hidedetails		Hide details (0=no, 1=yes, 2=just special lines)
1189 1189
  * 	@return	null|string
1190 1190
  */
1191
-function pdf_getlinenum($object,$i,$outputlangs,$hidedetails=0)
1191
+function pdf_getlinenum($object, $i, $outputlangs, $hidedetails = 0)
1192 1192
 {
1193 1193
 	global $hookmanager;
1194 1194
 
1195
-	if (is_object($hookmanager) && (($object->lines[$i]->product_type == 9 && !empty($object->lines[$i]->special_code)) || ! empty($object->lines[$i]->fk_parent_line)))
1195
+	if (is_object($hookmanager) && (($object->lines[$i]->product_type == 9 && !empty($object->lines[$i]->special_code)) || !empty($object->lines[$i]->fk_parent_line)))
1196 1196
 	{
1197 1197
 		$special_code = $object->lines[$i]->special_code;
1198
-		if (! empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line);
1198
+		if (!empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line);
1199 1199
 		// TODO add hook function
1200 1200
 	}
1201 1201
 	else
@@ -1214,14 +1214,14 @@  discard block
 block discarded – undo
1214 1214
  *  @param	int			$hidedetails		Hide details (0=no, 1=yes, 2=just special lines)
1215 1215
  * 	@return	null|string
1216 1216
  */
1217
-function pdf_getlineref($object,$i,$outputlangs,$hidedetails=0)
1217
+function pdf_getlineref($object, $i, $outputlangs, $hidedetails = 0)
1218 1218
 {
1219 1219
 	global $hookmanager;
1220 1220
 
1221
-	if (is_object($hookmanager) && (($object->lines[$i]->product_type == 9 && !empty($object->lines[$i]->special_code)) || ! empty($object->lines[$i]->fk_parent_line)))
1221
+	if (is_object($hookmanager) && (($object->lines[$i]->product_type == 9 && !empty($object->lines[$i]->special_code)) || !empty($object->lines[$i]->fk_parent_line)))
1222 1222
 	{
1223 1223
 		$special_code = $object->lines[$i]->special_code;
1224
-		if (! empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line);
1224
+		if (!empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line);
1225 1225
 		// TODO add hook function
1226 1226
 	}
1227 1227
 	else
@@ -1239,14 +1239,14 @@  discard block
 block discarded – undo
1239 1239
  *  @param	int			$hidedetails		Hide details (0=no, 1=yes, 2=just special lines)
1240 1240
  * 	@return	null|string
1241 1241
  */
1242
-function pdf_getlineref_supplier($object,$i,$outputlangs,$hidedetails=0)
1242
+function pdf_getlineref_supplier($object, $i, $outputlangs, $hidedetails = 0)
1243 1243
 {
1244 1244
 	global $hookmanager;
1245 1245
 
1246
-	if (is_object($hookmanager) && ( ($object->lines[$i]->product_type == 9 && !empty($object->lines[$i]->special_code) ) || ! empty($object->lines[$i]->fk_parent_line) ) )
1246
+	if (is_object($hookmanager) && (($object->lines[$i]->product_type == 9 && !empty($object->lines[$i]->special_code)) || !empty($object->lines[$i]->fk_parent_line)))
1247 1247
 	{
1248 1248
 		$special_code = $object->lines[$i]->special_code;
1249
-		if (! empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line);
1249
+		if (!empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line);
1250 1250
 		// TODO add hook function
1251 1251
 	}
1252 1252
 	else
@@ -1264,24 +1264,24 @@  discard block
 block discarded – undo
1264 1264
  *  @param	int			$hidedetails		Hide details (0=no, 1=yes, 2=just special lines)
1265 1265
  * 	@return	string
1266 1266
  */
1267
-function pdf_getlinevatrate($object,$i,$outputlangs,$hidedetails=0)
1267
+function pdf_getlinevatrate($object, $i, $outputlangs, $hidedetails = 0)
1268 1268
 {
1269 1269
 	global $hookmanager;
1270 1270
 
1271
-	if (is_object($hookmanager) && (($object->lines[$i]->product_type == 9 && !empty($object->lines[$i]->special_code)) || ! empty($object->lines[$i]->fk_parent_line)))
1271
+	if (is_object($hookmanager) && (($object->lines[$i]->product_type == 9 && !empty($object->lines[$i]->special_code)) || !empty($object->lines[$i]->fk_parent_line)))
1272 1272
 	{
1273 1273
 		$special_code = $object->lines[$i]->special_code;
1274
-		if (! empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line);
1275
-		$parameters = array('i'=>$i,'outputlangs'=>$outputlangs,'hidedetails'=>$hidedetails,'special_code'=>$special_code);
1276
-		$action='';
1277
-		$reshook = $hookmanager->executeHooks('pdf_getlinevatrate',$parameters,$object,$action);    // Note that $action and $object may have been modified by some hooks
1274
+		if (!empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line);
1275
+		$parameters = array('i'=>$i, 'outputlangs'=>$outputlangs, 'hidedetails'=>$hidedetails, 'special_code'=>$special_code);
1276
+		$action = '';
1277
+		$reshook = $hookmanager->executeHooks('pdf_getlinevatrate', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
1278 1278
 		
1279
-		if(!empty($hookmanager->resPrint)) return $hookmanager->resPrint;
1279
+		if (!empty($hookmanager->resPrint)) return $hookmanager->resPrint;
1280 1280
 		else return $reshook;
1281 1281
 	}
1282 1282
 	else
1283 1283
 	{
1284
-		if (empty($hidedetails) || $hidedetails > 1) return vatrate($object->lines[$i]->tva_tx,1,$object->lines[$i]->info_bits,1);
1284
+		if (empty($hidedetails) || $hidedetails > 1) return vatrate($object->lines[$i]->tva_tx, 1, $object->lines[$i]->info_bits, 1);
1285 1285
 	}
1286 1286
 }
1287 1287
 
@@ -1294,22 +1294,22 @@  discard block
 block discarded – undo
1294 1294
  *  @param	int			$hidedetails		Hide details (0=no, 1=yes, 2=just special lines)
1295 1295
  * 	@return	string
1296 1296
  */
1297
-function pdf_getlineupexcltax($object,$i,$outputlangs,$hidedetails=0)
1297
+function pdf_getlineupexcltax($object, $i, $outputlangs, $hidedetails = 0)
1298 1298
 {
1299 1299
 	global $conf, $hookmanager;
1300 1300
 
1301
-	$sign=1;
1302
-	if (isset($object->type) && $object->type == 2 && ! empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) $sign=-1;
1301
+	$sign = 1;
1302
+	if (isset($object->type) && $object->type == 2 && !empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) $sign = -1;
1303 1303
 
1304
-	if (is_object($hookmanager) && (($object->lines[$i]->product_type == 9 && !empty($object->lines[$i]->special_code)) || ! empty($object->lines[$i]->fk_parent_line)))
1304
+	if (is_object($hookmanager) && (($object->lines[$i]->product_type == 9 && !empty($object->lines[$i]->special_code)) || !empty($object->lines[$i]->fk_parent_line)))
1305 1305
 	{
1306 1306
 		$special_code = $object->lines[$i]->special_code;
1307
-		if (! empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line);
1308
-		$parameters = array('i'=>$i,'outputlangs'=>$outputlangs,'hidedetails'=>$hidedetails,'special_code'=>$special_code);
1309
-		$action='';
1310
-		$reshook = $hookmanager->executeHooks('pdf_getlineupexcltax',$parameters,$object,$action);    // Note that $action and $object may have been modified by some hooks
1307
+		if (!empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line);
1308
+		$parameters = array('i'=>$i, 'outputlangs'=>$outputlangs, 'hidedetails'=>$hidedetails, 'special_code'=>$special_code);
1309
+		$action = '';
1310
+		$reshook = $hookmanager->executeHooks('pdf_getlineupexcltax', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
1311 1311
 		
1312
-		if(!empty($hookmanager->resPrint)) return $hookmanager->resPrint;
1312
+		if (!empty($hookmanager->resPrint)) return $hookmanager->resPrint;
1313 1313
 		else return $reshook;
1314 1314
 	}
1315 1315
 	else
@@ -1327,22 +1327,22 @@  discard block
 block discarded – undo
1327 1327
  *  @param	int			$hidedetails		Hide value (0 = no,	1 = yes, 2 = just special lines)
1328 1328
  *  @return	void
1329 1329
  */
1330
-function pdf_getlineupwithtax($object,$i,$outputlangs,$hidedetails=0)
1330
+function pdf_getlineupwithtax($object, $i, $outputlangs, $hidedetails = 0)
1331 1331
 {
1332 1332
 	global $hookmanager;
1333 1333
 
1334
-	if (is_object($hookmanager) && (($object->lines[$i]->product_type == 9 && !empty($object->lines[$i]->special_code)) || ! empty($object->lines[$i]->fk_parent_line)))
1334
+	if (is_object($hookmanager) && (($object->lines[$i]->product_type == 9 && !empty($object->lines[$i]->special_code)) || !empty($object->lines[$i]->fk_parent_line)))
1335 1335
 	{
1336 1336
 		$special_code = $object->lines[$i]->special_code;
1337
-		if (! empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line);
1338
-		foreach($object->hooks as $modules)
1337
+		if (!empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line);
1338
+		foreach ($object->hooks as $modules)
1339 1339
 		{
1340
-			if (method_exists($modules[$special_code],'pdf_getlineupwithtax')) return $modules[$special_code]->pdf_getlineupwithtax($object,$i,$outputlangs,$hidedetails);
1340
+			if (method_exists($modules[$special_code], 'pdf_getlineupwithtax')) return $modules[$special_code]->pdf_getlineupwithtax($object, $i, $outputlangs, $hidedetails);
1341 1341
 		}
1342 1342
 	}
1343 1343
 	else
1344 1344
 	{
1345
-		if (empty($hidedetails) || $hidedetails > 1) return price(($object->lines[$i]->subprice) + ($object->lines[$i]->subprice)*($object->lines[$i]->tva_tx)/100, 0, $outputlangs);
1345
+		if (empty($hidedetails) || $hidedetails > 1) return price(($object->lines[$i]->subprice) + ($object->lines[$i]->subprice) * ($object->lines[$i]->tva_tx) / 100, 0, $outputlangs);
1346 1346
 	}
1347 1347
 }
1348 1348
 
@@ -1355,21 +1355,21 @@  discard block
 block discarded – undo
1355 1355
  *  @param	int			$hidedetails		Hide details (0=no, 1=yes, 2=just special lines)
1356 1356
  *  @return	string
1357 1357
  */
1358
-function pdf_getlineqty($object,$i,$outputlangs,$hidedetails=0)
1358
+function pdf_getlineqty($object, $i, $outputlangs, $hidedetails = 0)
1359 1359
 {
1360 1360
 	global $hookmanager;
1361 1361
 
1362 1362
 	if ($object->lines[$i]->special_code != 3)
1363 1363
 	{
1364
-		if (is_object($hookmanager) && (( $object->lines[$i]->product_type == 9 && !empty($object->lines[$i]->special_code) ) || ! empty($object->lines[$i]->fk_parent_line) ) )
1364
+		if (is_object($hookmanager) && (($object->lines[$i]->product_type == 9 && !empty($object->lines[$i]->special_code)) || !empty($object->lines[$i]->fk_parent_line)))
1365 1365
 		{
1366 1366
 			$special_code = $object->lines[$i]->special_code;
1367
-			if (! empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line);
1368
-			$parameters = array('i'=>$i,'outputlangs'=>$outputlangs,'hidedetails'=>$hidedetails,'special_code'=>$special_code);
1369
-			$action='';
1370
-			$reshook = $hookmanager->executeHooks('pdf_getlineqty',$parameters,$object,$action);    // Note that $action and $object may have been modified by some hooks
1367
+			if (!empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line);
1368
+			$parameters = array('i'=>$i, 'outputlangs'=>$outputlangs, 'hidedetails'=>$hidedetails, 'special_code'=>$special_code);
1369
+			$action = '';
1370
+			$reshook = $hookmanager->executeHooks('pdf_getlineqty', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
1371 1371
 			
1372
-			if(!empty($hookmanager->resPrint)) return $hookmanager->resPrint;
1372
+			if (!empty($hookmanager->resPrint)) return $hookmanager->resPrint;
1373 1373
 			else return $reshook;
1374 1374
 			
1375 1375
 		}
@@ -1389,21 +1389,21 @@  discard block
 block discarded – undo
1389 1389
  *  @param	int			$hidedetails		Hide details (0=no, 1=yes, 2=just special lines)
1390 1390
  * 	@return	string
1391 1391
  */
1392
-function pdf_getlineqty_asked($object,$i,$outputlangs,$hidedetails=0)
1392
+function pdf_getlineqty_asked($object, $i, $outputlangs, $hidedetails = 0)
1393 1393
 {
1394 1394
 	global $hookmanager;
1395 1395
 
1396 1396
 	if ($object->lines[$i]->special_code != 3)
1397 1397
 	{
1398
-		if (is_object($hookmanager) && (( $object->lines[$i]->product_type == 9 && !empty($object->lines[$i]->special_code) ) || ! empty($object->lines[$i]->fk_parent_line) ) )
1398
+		if (is_object($hookmanager) && (($object->lines[$i]->product_type == 9 && !empty($object->lines[$i]->special_code)) || !empty($object->lines[$i]->fk_parent_line)))
1399 1399
 		{
1400 1400
 			$special_code = $object->lines[$i]->special_code;
1401
-			if (! empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line);
1402
-			$parameters = array('i'=>$i,'outputlangs'=>$outputlangs,'hidedetails'=>$hidedetails,'special_code'=>$special_code);
1403
-			$action='';
1404
-			$reshook = $hookmanager->executeHooks('pdf_getlineqty_asked',$parameters,$object,$action);    // Note that $action and $object may have been modified by some hooks
1401
+			if (!empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line);
1402
+			$parameters = array('i'=>$i, 'outputlangs'=>$outputlangs, 'hidedetails'=>$hidedetails, 'special_code'=>$special_code);
1403
+			$action = '';
1404
+			$reshook = $hookmanager->executeHooks('pdf_getlineqty_asked', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
1405 1405
 		
1406
-			if(!empty($hookmanager->resPrint)) return $hookmanager->resPrint;
1406
+			if (!empty($hookmanager->resPrint)) return $hookmanager->resPrint;
1407 1407
 			else return $reshook;
1408 1408
 		}
1409 1409
 		else
@@ -1422,21 +1422,21 @@  discard block
 block discarded – undo
1422 1422
  *  @param	int			$hidedetails		Hide details (0=no, 1=yes, 2=just special lines)
1423 1423
  * 	@return	string
1424 1424
  */
1425
-function pdf_getlineqty_shipped($object,$i,$outputlangs,$hidedetails=0)
1425
+function pdf_getlineqty_shipped($object, $i, $outputlangs, $hidedetails = 0)
1426 1426
 {
1427 1427
 	global $hookmanager;
1428 1428
 
1429 1429
 	if ($object->lines[$i]->special_code != 3)
1430 1430
 	{
1431
-		if (is_object($hookmanager) && (( $object->lines[$i]->product_type == 9 && !empty($object->lines[$i]->special_code) ) || ! empty($object->lines[$i]->fk_parent_line) ) )
1431
+		if (is_object($hookmanager) && (($object->lines[$i]->product_type == 9 && !empty($object->lines[$i]->special_code)) || !empty($object->lines[$i]->fk_parent_line)))
1432 1432
 		{
1433 1433
 			$special_code = $object->lines[$i]->special_code;
1434
-			if (! empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line);
1435
-			$parameters = array('i'=>$i,'outputlangs'=>$outputlangs,'hidedetails'=>$hidedetails,'special_code'=>$special_code);
1436
-			$action='';
1437
-			$reshook = $hookmanager->executeHooks('pdf_getlineqty_shipped',$parameters,$object,$action);    // Note that $action and $object may have been modified by some hooks
1434
+			if (!empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line);
1435
+			$parameters = array('i'=>$i, 'outputlangs'=>$outputlangs, 'hidedetails'=>$hidedetails, 'special_code'=>$special_code);
1436
+			$action = '';
1437
+			$reshook = $hookmanager->executeHooks('pdf_getlineqty_shipped', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
1438 1438
 			
1439
-			if(!empty($hookmanager->resPrint)) return $hookmanager->resPrint;
1439
+			if (!empty($hookmanager->resPrint)) return $hookmanager->resPrint;
1440 1440
 			else return $reshook;
1441 1441
 		}
1442 1442
 		else
@@ -1455,21 +1455,21 @@  discard block
 block discarded – undo
1455 1455
  *  @param	int			$hidedetails		Hide details (0=no, 1=yes, 2=just special lines)
1456 1456
  * 	@return	void
1457 1457
  */
1458
-function pdf_getlineqty_keeptoship($object,$i,$outputlangs,$hidedetails=0)
1458
+function pdf_getlineqty_keeptoship($object, $i, $outputlangs, $hidedetails = 0)
1459 1459
 {
1460 1460
 	global $hookmanager;
1461 1461
 
1462 1462
 	if ($object->lines[$i]->special_code != 3)
1463 1463
 	{
1464
-		if (is_object($hookmanager) && (( $object->lines[$i]->product_type == 9 && !empty($object->lines[$i]->special_code) ) || ! empty($object->lines[$i]->fk_parent_line) ) )
1464
+		if (is_object($hookmanager) && (($object->lines[$i]->product_type == 9 && !empty($object->lines[$i]->special_code)) || !empty($object->lines[$i]->fk_parent_line)))
1465 1465
 		{
1466 1466
 			$special_code = $object->lines[$i]->special_code;
1467
-			if (! empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line);
1468
-			$parameters = array('i'=>$i,'outputlangs'=>$outputlangs,'hidedetails'=>$hidedetails,'special_code'=>$special_code);
1469
-			$action='';
1470
-			$reshook = $hookmanager->executeHooks('pdf_getlineqty_keeptoship',$parameters,$object,$action);    // Note that $action and $object may have been modified by some hooks
1467
+			if (!empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line);
1468
+			$parameters = array('i'=>$i, 'outputlangs'=>$outputlangs, 'hidedetails'=>$hidedetails, 'special_code'=>$special_code);
1469
+			$action = '';
1470
+			$reshook = $hookmanager->executeHooks('pdf_getlineqty_keeptoship', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
1471 1471
 			
1472
-			if(!empty($hookmanager->resPrint)) return $hookmanager->resPrint;
1472
+			if (!empty($hookmanager->resPrint)) return $hookmanager->resPrint;
1473 1473
 			else return $reshook;
1474 1474
 		}
1475 1475
 		else
@@ -1506,9 +1506,9 @@  discard block
 block discarded – undo
1506 1506
 			);
1507 1507
 			$action = '';
1508 1508
 			$reshook = $hookmanager->executeHooks('pdf_getlineunit', $parameters, $object,
1509
-				$action);    // Note that $action and $object may have been modified by some hooks
1509
+				$action); // Note that $action and $object may have been modified by some hooks
1510 1510
 				
1511
-			if(!empty($hookmanager->resPrint)) return $hookmanager->resPrint;
1511
+			if (!empty($hookmanager->resPrint)) return $hookmanager->resPrint;
1512 1512
 			else return $reshook;
1513 1513
 				
1514 1514
 		} else {
@@ -1529,7 +1529,7 @@  discard block
 block discarded – undo
1529 1529
  *  @param	int			$hidedetails		Hide details (0=no, 1=yes, 2=just special lines)
1530 1530
  * 	@return	string
1531 1531
  */
1532
-function pdf_getlineremisepercent($object,$i,$outputlangs,$hidedetails=0)
1532
+function pdf_getlineremisepercent($object, $i, $outputlangs, $hidedetails = 0)
1533 1533
 {
1534 1534
 	global $hookmanager;
1535 1535
 
@@ -1537,20 +1537,20 @@  discard block
 block discarded – undo
1537 1537
 
1538 1538
 	if ($object->lines[$i]->special_code != 3)
1539 1539
 	{
1540
-		if (is_object($hookmanager) && ( ($object->lines[$i]->product_type == 9 && !empty($object->lines[$i]->special_code) ) || ! empty($object->lines[$i]->fk_parent_line) ) )
1540
+		if (is_object($hookmanager) && (($object->lines[$i]->product_type == 9 && !empty($object->lines[$i]->special_code)) || !empty($object->lines[$i]->fk_parent_line)))
1541 1541
 		{
1542 1542
 			$special_code = $object->lines[$i]->special_code;
1543
-			if (! empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line);
1544
-			$parameters = array('i'=>$i,'outputlangs'=>$outputlangs,'hidedetails'=>$hidedetails,'special_code'=>$special_code);
1545
-			$action='';
1546
-			$reshook = $hookmanager->executeHooks('pdf_getlineremisepercent',$parameters,$object,$action);    // Note that $action and $object may have been modified by some hooks
1543
+			if (!empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line);
1544
+			$parameters = array('i'=>$i, 'outputlangs'=>$outputlangs, 'hidedetails'=>$hidedetails, 'special_code'=>$special_code);
1545
+			$action = '';
1546
+			$reshook = $hookmanager->executeHooks('pdf_getlineremisepercent', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
1547 1547
 			
1548
-			if(!empty($hookmanager->resPrint)) return $hookmanager->resPrint;
1548
+			if (!empty($hookmanager->resPrint)) return $hookmanager->resPrint;
1549 1549
 			else return $reshook;
1550 1550
 		}
1551 1551
 		else
1552 1552
 		{
1553
-			if (empty($hidedetails) || $hidedetails > 1) return dol_print_reduction($object->lines[$i]->remise_percent,$outputlangs);
1553
+			if (empty($hidedetails) || $hidedetails > 1) return dol_print_reduction($object->lines[$i]->remise_percent, $outputlangs);
1554 1554
 		}
1555 1555
 	}
1556 1556
 }
@@ -1575,12 +1575,12 @@  discard block
 block discarded – undo
1575 1575
 			if (!empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line);
1576 1576
 			$parameters = array('i' => $i, 'outputlangs' => $outputlangs, 'hidedetails' => $hidedetails, 'special_code' => $special_code);
1577 1577
 			$action = '';
1578
-			$reshook = $hookmanager->executeHooks('pdf_getlineprogress', $parameters, $object, $action);    // Note that $action and $object may have been modified by some hooks
1578
+			$reshook = $hookmanager->executeHooks('pdf_getlineprogress', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
1579 1579
 			
1580
-			if(!empty($hookmanager->resPrint)) return $hookmanager->resPrint;
1580
+			if (!empty($hookmanager->resPrint)) return $hookmanager->resPrint;
1581 1581
 			else return $reshook;
1582 1582
 		} else {
1583
-			if (empty($hidedetails) || $hidedetails > 1) return $object->lines[$i]->situation_percent . '%';
1583
+			if (empty($hidedetails) || $hidedetails > 1) return $object->lines[$i]->situation_percent.'%';
1584 1584
 		}
1585 1585
 	}
1586 1586
 }
@@ -1594,12 +1594,12 @@  discard block
 block discarded – undo
1594 1594
  *  @param	int			$hidedetails		Hide details (0=no, 1=yes, 2=just special lines)
1595 1595
  * 	@return	string							Return total of line excl tax
1596 1596
  */
1597
-function pdf_getlinetotalexcltax($object,$i,$outputlangs,$hidedetails=0)
1597
+function pdf_getlinetotalexcltax($object, $i, $outputlangs, $hidedetails = 0)
1598 1598
 {
1599 1599
 	global $conf, $hookmanager;
1600 1600
 
1601
-	$sign=1;
1602
-	if (isset($object->type) && $object->type == 2 && ! empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) $sign=-1;
1601
+	$sign = 1;
1602
+	if (isset($object->type) && $object->type == 2 && !empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) $sign = -1;
1603 1603
 
1604 1604
 	if ($object->lines[$i]->special_code == 3)
1605 1605
 	{
@@ -1607,15 +1607,15 @@  discard block
 block discarded – undo
1607 1607
 	}
1608 1608
 	else
1609 1609
 	{
1610
-		if (is_object($hookmanager) && (($object->lines[$i]->product_type == 9 && ! empty($object->lines[$i]->special_code)) || ! empty($object->lines[$i]->fk_parent_line)))
1610
+		if (is_object($hookmanager) && (($object->lines[$i]->product_type == 9 && !empty($object->lines[$i]->special_code)) || !empty($object->lines[$i]->fk_parent_line)))
1611 1611
 		{
1612 1612
 			$special_code = $object->lines[$i]->special_code;
1613
-			if (! empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line);
1614
-			$parameters = array('i'=>$i,'outputlangs'=>$outputlangs,'hidedetails'=>$hidedetails,'special_code'=>$special_code);
1615
-			$action='';
1616
-			$reshook = $hookmanager->executeHooks('pdf_getlinetotalexcltax',$parameters,$object,$action);    // Note that $action and $object may have been modified by some hooks
1613
+			if (!empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line);
1614
+			$parameters = array('i'=>$i, 'outputlangs'=>$outputlangs, 'hidedetails'=>$hidedetails, 'special_code'=>$special_code);
1615
+			$action = '';
1616
+			$reshook = $hookmanager->executeHooks('pdf_getlinetotalexcltax', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
1617 1617
 			
1618
-			if(!empty($hookmanager->resPrint)) return $hookmanager->resPrint;
1618
+			if (!empty($hookmanager->resPrint)) return $hookmanager->resPrint;
1619 1619
 			else return $reshook;
1620 1620
 		}
1621 1621
 		else
@@ -1635,7 +1635,7 @@  discard block
 block discarded – undo
1635 1635
  *  @param	int			$hidedetails		Hide value (0 = no, 1 = yes, 2 = just special lines)
1636 1636
  *  @return	string							Return total of line incl tax
1637 1637
  */
1638
-function pdf_getlinetotalwithtax($object,$i,$outputlangs,$hidedetails=0)
1638
+function pdf_getlinetotalwithtax($object, $i, $outputlangs, $hidedetails = 0)
1639 1639
 {
1640 1640
 	global $hookmanager;
1641 1641
 
@@ -1645,20 +1645,20 @@  discard block
 block discarded – undo
1645 1645
 	}
1646 1646
 	else
1647 1647
 	{
1648
-		if (is_object($hookmanager) && (($object->lines[$i]->product_type == 9 && ! empty($object->lines[$i]->special_code)) || ! empty($object->lines[$i]->fk_parent_line)))
1648
+		if (is_object($hookmanager) && (($object->lines[$i]->product_type == 9 && !empty($object->lines[$i]->special_code)) || !empty($object->lines[$i]->fk_parent_line)))
1649 1649
 		{
1650 1650
 			$special_code = $object->lines[$i]->special_code;
1651
-			if (! empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line);
1652
-			$parameters = array('i'=>$i,'outputlangs'=>$outputlangs,'hidedetails'=>$hidedetails,'special_code'=>$special_code);
1653
-			$action='';
1654
-			$reshook = $hookmanager->executeHooks('pdf_getlinetotalwithtax',$parameters,$object,$action);    // Note that $action and $object may have been modified by some hooks
1651
+			if (!empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line);
1652
+			$parameters = array('i'=>$i, 'outputlangs'=>$outputlangs, 'hidedetails'=>$hidedetails, 'special_code'=>$special_code);
1653
+			$action = '';
1654
+			$reshook = $hookmanager->executeHooks('pdf_getlinetotalwithtax', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
1655 1655
 			
1656
-			if(!empty($hookmanager->resPrint)) return $hookmanager->resPrint;
1656
+			if (!empty($hookmanager->resPrint)) return $hookmanager->resPrint;
1657 1657
 			else return $reshook;
1658 1658
 		}
1659 1659
 		else
1660 1660
 		{
1661
-			if (empty($hidedetails) || $hidedetails > 1) return price(($object->lines[$i]->total_ht) + ($object->lines[$i]->total_ht)*($object->lines[$i]->tva_tx)/100, 0, $outputlangs);
1661
+			if (empty($hidedetails) || $hidedetails > 1) return price(($object->lines[$i]->total_ht) + ($object->lines[$i]->total_ht) * ($object->lines[$i]->tva_tx) / 100, 0, $outputlangs);
1662 1662
 		}
1663 1663
 	}
1664 1664
 	return '';
@@ -1672,33 +1672,33 @@  discard block
 block discarded – undo
1672 1672
  *  @param  Translate	$outputlangs		Object langs for output
1673 1673
  * 	@return	integer
1674 1674
  */
1675
-function pdf_getTotalQty($object,$type,$outputlangs)
1675
+function pdf_getTotalQty($object, $type, $outputlangs)
1676 1676
 {
1677 1677
 	global $hookmanager;
1678 1678
 
1679
-	$total=0;
1680
-	$nblignes=count($object->lines);
1679
+	$total = 0;
1680
+	$nblignes = count($object->lines);
1681 1681
 
1682 1682
 	// Loop on each lines
1683
-	for ($i = 0 ; $i < $nblignes ; $i++)
1683
+	for ($i = 0; $i < $nblignes; $i++)
1684 1684
 	{
1685 1685
 		if ($object->lines[$i]->special_code != 3)
1686 1686
 		{
1687
-			if ($type=='all')
1687
+			if ($type == 'all')
1688 1688
 			{
1689 1689
 				$total += $object->lines[$i]->qty;
1690 1690
 			}
1691
-			else if ($type==9 && is_object($hookmanager) && (($object->lines[$i]->product_type == 9 && ! empty($object->lines[$i]->special_code)) || ! empty($object->lines[$i]->fk_parent_line)))
1691
+			else if ($type == 9 && is_object($hookmanager) && (($object->lines[$i]->product_type == 9 && !empty($object->lines[$i]->special_code)) || !empty($object->lines[$i]->fk_parent_line)))
1692 1692
 			{
1693 1693
 				$special_code = $object->lines[$i]->special_code;
1694
-				if (! empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line);
1694
+				if (!empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line);
1695 1695
 				// TODO add hook function
1696 1696
 			}
1697
-			else if ($type==0 && $object->lines[$i]->product_type == 0)
1697
+			else if ($type == 0 && $object->lines[$i]->product_type == 0)
1698 1698
 			{
1699 1699
 				$total += $object->lines[$i]->qty;
1700 1700
 			}
1701
-			else if ($type==1 && $object->lines[$i]->product_type == 1)
1701
+			else if ($type == 1 && $object->lines[$i]->product_type == 1)
1702 1702
 			{
1703 1703
 				$total += $object->lines[$i]->qty;
1704 1704
 			}
@@ -1715,74 +1715,74 @@  discard block
 block discarded – undo
1715 1715
  * 	@param	Translate	$outputlangs	Object lang for output
1716 1716
  * 	@return	array   Linked objects
1717 1717
  */
1718
-function pdf_getLinkedObjects($object,$outputlangs)
1718
+function pdf_getLinkedObjects($object, $outputlangs)
1719 1719
 {
1720 1720
 	global $hookmanager;
1721 1721
 
1722
-	$linkedobjects=array();
1722
+	$linkedobjects = array();
1723 1723
 
1724 1724
 	$object->fetchObjectLinked();
1725 1725
 
1726
-	foreach($object->linkedObjects as $objecttype => $objects)
1726
+	foreach ($object->linkedObjects as $objecttype => $objects)
1727 1727
 	{
1728 1728
 		if ($objecttype == 'propal')
1729 1729
 		{
1730 1730
 			$outputlangs->load('propal');
1731 1731
 			
1732
-			foreach($objects as $elementobject)
1732
+			foreach ($objects as $elementobject)
1733 1733
 			{
1734 1734
 				$linkedobjects[$objecttype]['ref_title'] = $outputlangs->transnoentities("RefProposal");
1735 1735
 				$linkedobjects[$objecttype]['ref_value'] = $outputlangs->transnoentities($elementobject->ref);
1736 1736
 				$linkedobjects[$objecttype]['date_title'] = $outputlangs->transnoentities("DatePropal");
1737
-				$linkedobjects[$objecttype]['date_value'] = dol_print_date($elementobject->date,'day','',$outputlangs);
1737
+				$linkedobjects[$objecttype]['date_value'] = dol_print_date($elementobject->date, 'day', '', $outputlangs);
1738 1738
 			}
1739 1739
 		}
1740 1740
 		else if ($objecttype == 'commande')
1741 1741
 		{
1742 1742
 			$outputlangs->load('orders');
1743
-			foreach($objects as $elementobject)
1743
+			foreach ($objects as $elementobject)
1744 1744
 			{
1745 1745
 				$linkedobjects[$objecttype]['ref_title'] = $outputlangs->transnoentities("RefOrder");
1746
-				$linkedobjects[$objecttype]['ref_value'] = $outputlangs->transnoentities($elementobject->ref) . ($elementobject->ref_client ? ' ('.$elementobject->ref_client.')' : '');
1746
+				$linkedobjects[$objecttype]['ref_value'] = $outputlangs->transnoentities($elementobject->ref).($elementobject->ref_client ? ' ('.$elementobject->ref_client.')' : '');
1747 1747
 				$linkedobjects[$objecttype]['date_title'] = $outputlangs->transnoentities("OrderDate");
1748
-				$linkedobjects[$objecttype]['date_value'] = dol_print_date($elementobject->date,'day','',$outputlangs);
1748
+				$linkedobjects[$objecttype]['date_value'] = dol_print_date($elementobject->date, 'day', '', $outputlangs);
1749 1749
 			}
1750 1750
 		}
1751 1751
 		else if ($objecttype == 'contrat')
1752 1752
 		{
1753 1753
 			$outputlangs->load('contracts');
1754
-			foreach($objects as $elementobject)
1754
+			foreach ($objects as $elementobject)
1755 1755
 			{
1756 1756
 				$linkedobjects[$objecttype]['ref_title'] = $outputlangs->transnoentities("RefContract");
1757 1757
 				$linkedobjects[$objecttype]['ref_value'] = $outputlangs->transnoentities($elementobject->ref);
1758 1758
 				$linkedobjects[$objecttype]['date_title'] = $outputlangs->transnoentities("DateContract");
1759
-				$linkedobjects[$objecttype]['date_value'] = dol_print_date($elementobject->date_contrat,'day','',$outputlangs);
1759
+				$linkedobjects[$objecttype]['date_value'] = dol_print_date($elementobject->date_contrat, 'day', '', $outputlangs);
1760 1760
 			}
1761 1761
 		}
1762 1762
 		else if ($objecttype == 'shipping')
1763 1763
 		{
1764 1764
 			$outputlangs->load('orders');
1765 1765
 			$outputlangs->load('sendings');
1766
-			foreach($objects as $elementobject)
1766
+			foreach ($objects as $elementobject)
1767 1767
 			{
1768 1768
 				$elementobject->fetchObjectLinked();
1769 1769
 				$order = $elementobject->linkedObjects['commande'][0];
1770 1770
 
1771
-				if (! empty($object->linkedObjects['commande']))	// There is already a link to order so we show only info of shipment
1771
+				if (!empty($object->linkedObjects['commande']))	// There is already a link to order so we show only info of shipment
1772 1772
 				{
1773 1773
 					$linkedobjects[$objecttype]['ref_title'] = $outputlangs->transnoentities("RefSending");
1774
-					$linkedobjects[$objecttype]['ref_value'].= $outputlangs->transnoentities($elementobject->ref);
1774
+					$linkedobjects[$objecttype]['ref_value'] .= $outputlangs->transnoentities($elementobject->ref);
1775 1775
 					$linkedobjects[$objecttype]['date_title'] = $outputlangs->transnoentities("DateSending");
1776
-					$linkedobjects[$objecttype]['date_value'].= dol_print_date($elementobject->date_delivery,'day','',$outputlangs);
1776
+					$linkedobjects[$objecttype]['date_value'] .= dol_print_date($elementobject->date_delivery, 'day', '', $outputlangs);
1777 1777
 				}
1778 1778
 				else	// We show both info of order and shipment
1779 1779
 				{
1780
-					$linkedobjects[$objecttype]['ref_title'] = $outputlangs->transnoentities("RefOrder") . ' / ' . $outputlangs->transnoentities("RefSending");
1781
-					$linkedobjects[$objecttype]['ref_value'] = $outputlangs->transnoentities($order->ref) . ($order->ref_client ? ' ('.$order->ref_client.')' : '');
1782
-					$linkedobjects[$objecttype]['ref_value'].= ' / ' . $outputlangs->transnoentities($elementobject->ref);
1783
-					$linkedobjects[$objecttype]['date_title'] = $outputlangs->transnoentities("OrderDate") . ' / ' . $outputlangs->transnoentities("DateSending");
1784
-					$linkedobjects[$objecttype]['date_value'] = dol_print_date($order->date,'day','',$outputlangs);
1785
-					$linkedobjects[$objecttype]['date_value'].= ' / ' . dol_print_date($elementobject->date_delivery,'day','',$outputlangs);
1780
+					$linkedobjects[$objecttype]['ref_title'] = $outputlangs->transnoentities("RefOrder").' / '.$outputlangs->transnoentities("RefSending");
1781
+					$linkedobjects[$objecttype]['ref_value'] = $outputlangs->transnoentities($order->ref).($order->ref_client ? ' ('.$order->ref_client.')' : '');
1782
+					$linkedobjects[$objecttype]['ref_value'] .= ' / '.$outputlangs->transnoentities($elementobject->ref);
1783
+					$linkedobjects[$objecttype]['date_title'] = $outputlangs->transnoentities("OrderDate").' / '.$outputlangs->transnoentities("DateSending");
1784
+					$linkedobjects[$objecttype]['date_value'] = dol_print_date($order->date, 'day', '', $outputlangs);
1785
+					$linkedobjects[$objecttype]['date_value'] .= ' / '.dol_print_date($elementobject->date_delivery, 'day', '', $outputlangs);
1786 1786
 				}
1787 1787
 			}
1788 1788
 		}
@@ -1792,9 +1792,9 @@  discard block
 block discarded – undo
1792 1792
 	if (is_object($hookmanager))
1793 1793
 	{
1794 1794
 		$parameters = array('linkedobjects' => $linkedobjects, 'outputlangs'=>$outputlangs);
1795
-		$action='';
1796
-		$hookmanager->executeHooks('pdf_getLinkedObjects',$parameters,$object,$action);    // Note that $action and $object may have been modified by some hooks
1797
-		if (! empty($hookmanager->resArray)) $linkedobjects = $hookmanager->resArray;
1795
+		$action = '';
1796
+		$hookmanager->executeHooks('pdf_getLinkedObjects', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
1797
+		if (!empty($hookmanager->resArray)) $linkedobjects = $hookmanager->resArray;
1798 1798
 	}
1799 1799
 
1800 1800
 	return $linkedobjects;
@@ -1811,23 +1811,23 @@  discard block
 block discarded – undo
1811 1811
 {
1812 1812
 	global $conf;
1813 1813
 
1814
-	$maxwidth=(empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH)?20:$conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH);
1815
-	$maxheight=(empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_HEIGHT)?32:$conf->global->MAIN_DOCUMENTS_WITH_PICTURE_HEIGHT);
1814
+	$maxwidth = (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH) ? 20 : $conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH);
1815
+	$maxheight = (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_HEIGHT) ? 32 : $conf->global->MAIN_DOCUMENTS_WITH_PICTURE_HEIGHT);
1816 1816
 	include_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php';
1817
-	$tmp=dol_getImageSize($realpath);
1817
+	$tmp = dol_getImageSize($realpath);
1818 1818
 	if ($tmp['height'])
1819 1819
 	{
1820
-		$width=(int) round($maxheight*$tmp['width']/$tmp['height']);	// I try to use maxheight
1820
+		$width = (int) round($maxheight * $tmp['width'] / $tmp['height']); // I try to use maxheight
1821 1821
 		if ($width > $maxwidth)	// Pb with maxheight, so i use maxwidth
1822 1822
 		{
1823
-			$width=$maxwidth;
1824
-			$height=(int) round($maxwidth*$tmp['height']/$tmp['width']);
1823
+			$width = $maxwidth;
1824
+			$height = (int) round($maxwidth * $tmp['height'] / $tmp['width']);
1825 1825
 		}
1826 1826
 		else	// No pb with maxheight
1827 1827
 		{
1828
-			$height=$maxheight;
1828
+			$height = $maxheight;
1829 1829
 		}
1830 1830
 	}
1831
-	return array('width'=>$width,'height'=>$height);
1831
+	return array('width'=>$width, 'height'=>$height);
1832 1832
 }
1833 1833
 
Please login to merge, or discard this patch.
Braces   +430 added lines, -207 removed lines patch added patch discarded remove patch
@@ -50,8 +50,9 @@  discard block
 block discarded – undo
50 50
 	{
51 51
 		include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
52 52
 		$pdfformat=dol_getDefaultFormat($outputlangs);
53
+	} else {
54
+		$pdfformat=$conf->global->MAIN_PDF_FORMAT;
53 55
 	}
54
-	else $pdfformat=$conf->global->MAIN_PDF_FORMAT;
55 56
 
56 57
 	$sql="SELECT code, label, width, height, unit FROM ".MAIN_DB_PREFIX."c_paper_format";
57 58
 	$sql.=" WHERE code = '".$pdfformat."'";
@@ -119,16 +120,23 @@  discard block
 block discarded – undo
119 120
 		define('K_TCPDF_THROW_EXCEPTION_ERROR', false);
120 121
 	}
121 122
 
122
-	if (! empty($conf->global->MAIN_USE_FPDF) && ! empty($conf->global->MAIN_DISABLE_FPDI))
123
-		return "Error MAIN_USE_FPDF and MAIN_DISABLE_FPDI can't be set together";
123
+	if (! empty($conf->global->MAIN_USE_FPDF) && ! empty($conf->global->MAIN_DISABLE_FPDI)) {
124
+			return "Error MAIN_USE_FPDF and MAIN_DISABLE_FPDI can't be set together";
125
+	}
124 126
 
125 127
 	// We use by default TCPDF else FPDF
126
-	if (empty($conf->global->MAIN_USE_FPDF)) require_once TCPDF_PATH.'tcpdf.php';
127
-	else require_once FPDF_PATH.'fpdf.php';
128
+	if (empty($conf->global->MAIN_USE_FPDF)) {
129
+		require_once TCPDF_PATH.'tcpdf.php';
130
+	} else {
131
+		require_once FPDF_PATH.'fpdf.php';
132
+	}
128 133
 
129 134
 	// We need to instantiate tcpdi or fpdi object (instead of tcpdf) to use merging features. But we can disable it (this will break all merge features).
130
-    if (empty($conf->global->MAIN_DISABLE_TCPDI)) require_once TCPDI_PATH.'tcpdi.php';
131
-	else if (empty($conf->global->MAIN_DISABLE_FPDI)) require_once FPDI_PATH.'fpdi.php';
135
+    if (empty($conf->global->MAIN_DISABLE_TCPDI)) {
136
+    	require_once TCPDI_PATH.'tcpdi.php';
137
+    } else if (empty($conf->global->MAIN_DISABLE_FPDI)) {
138
+		require_once FPDI_PATH.'fpdi.php';
139
+	}
132 140
 
133 141
 	//$arrayformat=pdf_getFormat();
134 142
 	//$format=array($arrayformat['width'],$arrayformat['height']);
@@ -148,21 +156,28 @@  discard block
 block discarded – undo
148 156
 		- print-high : Print the document to a representation from which a faithful digital copy of the PDF content could be generated. When this is not set, printing is limited to a low-level representation of the appearance, possibly of degraded quality.
149 157
 		- owner : (inverted logic - only for public-key) when set permits change of encryption and enables all other permissions.
150 158
 		*/
151
-		if (class_exists('TCPDI')) $pdf = new TCPDI($pagetype,$metric,$format);
152
-		else if (class_exists('FPDI')) $pdf = new FPDI($pagetype,$metric,$format);
153
-		else $pdf = new TCPDF($pagetype,$metric,$format);
159
+		if (class_exists('TCPDI')) {
160
+			$pdf = new TCPDI($pagetype,$metric,$format);
161
+		} else if (class_exists('FPDI')) {
162
+			$pdf = new FPDI($pagetype,$metric,$format);
163
+		} else {
164
+			$pdf = new TCPDF($pagetype,$metric,$format);
165
+		}
154 166
 		// For TCPDF, we specify permission we want to block
155 167
 		$pdfrights = array('modify','copy');
156 168
 
157 169
 		$pdfuserpass = ''; // Password for the end user
158 170
 		$pdfownerpass = NULL; // Password of the owner, created randomly if not defined
159 171
 		$pdf->SetProtection($pdfrights,$pdfuserpass,$pdfownerpass);
160
-	}
161
-	else
172
+	} else
162 173
 	{
163
-		if (class_exists('TCPDI')) $pdf = new TCPDI($pagetype,$metric,$format);
164
-		else if (class_exists('FPDI')) $pdf = new FPDI($pagetype,$metric,$format);
165
-		else $pdf = new TCPDF($pagetype,$metric,$format);
174
+		if (class_exists('TCPDI')) {
175
+			$pdf = new TCPDI($pagetype,$metric,$format);
176
+		} else if (class_exists('FPDI')) {
177
+			$pdf = new FPDI($pagetype,$metric,$format);
178
+		} else {
179
+			$pdf = new TCPDF($pagetype,$metric,$format);
180
+		}
166 181
 	}
167 182
 
168 183
 	// If we use FPDF class, we may need to add method writeHTMLCell
@@ -234,14 +249,18 @@  discard block
 block discarded – undo
234 249
 {
235 250
 	global $conf;
236 251
 
237
-	if (! empty($conf->global->MAIN_PDF_FORCE_FONT)) return $conf->global->MAIN_PDF_FORCE_FONT;
252
+	if (! empty($conf->global->MAIN_PDF_FORCE_FONT)) {
253
+		return $conf->global->MAIN_PDF_FORCE_FONT;
254
+	}
238 255
 
239 256
 	$font='Helvetica'; // By default, for FPDI, or ISO language on TCPDF
240
-	if (class_exists('TCPDF'))  // If TCPDF on, we can use an UTF8 one like DejaVuSans if required (slower)
257
+	if (class_exists('TCPDF')) {
258
+		// If TCPDF on, we can use an UTF8 one like DejaVuSans if required (slower)
241 259
 	{
242 260
 		if ($outputlangs->trans('FONTFORPDF')!='FONTFORPDF')
243 261
 		{
244 262
 			$font=$outputlangs->trans('FONTFORPDF');
263
+	}
245 264
 		}
246 265
 	}
247 266
 	return $font;
@@ -256,11 +275,13 @@  discard block
 block discarded – undo
256 275
 function pdf_getPDFFontSize($outputlangs)
257 276
 {
258 277
 	$size=10;                   // By default, for FPDI or ISO language on TCPDF
259
-	if (class_exists('TCPDF'))  // If TCPDF on, we can use an UTF8 one like DejaVuSans if required (slower)
278
+	if (class_exists('TCPDF')) {
279
+		// If TCPDF on, we can use an UTF8 one like DejaVuSans if required (slower)
260 280
 	{
261 281
 		if ($outputlangs->trans('FONTSIZEFORPDF')!='FONTSIZEFORPDF')
262 282
 		{
263 283
 			$size = (int) $outputlangs->trans('FONTSIZEFORPDF');
284
+	}
264 285
 		}
265 286
 	}
266 287
 	return $size;
@@ -284,7 +305,9 @@  discard block
 block discarded – undo
284 305
 	if ($tmp['height'])
285 306
 	{
286 307
 		$width=round($height*$tmp['width']/$tmp['height']);
287
-		if ($width > $maxwidth) $height=$height*$maxwidth/$width;
308
+		if ($width > $maxwidth) {
309
+			$height=$height*$maxwidth/$width;
310
+		}
288 311
 	}
289 312
 	//print $tmp['width'].' '.$tmp['height'].' '.$width; exit;
290 313
 	return $height;
@@ -333,31 +356,54 @@  discard block
 block discarded – undo
333 356
 	global $conf;
334 357
 	$stringaddress = '';
335 358
 
336
-	if ($mode == 'source' && ! is_object($sourcecompany)) return -1;
337
-	if ($mode == 'target' && ! is_object($targetcompany)) return -1;
338
-	if ($mode == 'delivery' && ! is_object($deliverycompany)) return -1;
359
+	if ($mode == 'source' && ! is_object($sourcecompany)) {
360
+		return -1;
361
+	}
362
+	if ($mode == 'target' && ! is_object($targetcompany)) {
363
+		return -1;
364
+	}
365
+	if ($mode == 'delivery' && ! is_object($deliverycompany)) {
366
+		return -1;
367
+	}
339 368
 
340
-	if (! empty($sourcecompany->state_id) && empty($sourcecompany->departement)) $sourcecompany->departement=getState($sourcecompany->state_id); //TODO: Deprecated
341
-	if (! empty($sourcecompany->state_id) && empty($sourcecompany->state)) $sourcecompany->state=getState($sourcecompany->state_id);
342
-	if (! empty($targetcompany->state_id) && empty($targetcompany->departement)) $targetcompany->departement=getState($targetcompany->state_id);
369
+	if (! empty($sourcecompany->state_id) && empty($sourcecompany->departement)) {
370
+		$sourcecompany->departement=getState($sourcecompany->state_id);
371
+	}
372
+	//TODO: Deprecated
373
+	if (! empty($sourcecompany->state_id) && empty($sourcecompany->state)) {
374
+		$sourcecompany->state=getState($sourcecompany->state_id);
375
+	}
376
+	if (! empty($targetcompany->state_id) && empty($targetcompany->departement)) {
377
+		$targetcompany->departement=getState($targetcompany->state_id);
378
+	}
343 379
 
344 380
 	if ($mode == 'source')
345 381
 	{
346 382
 		$withCountry = 0;
347
-		if (!empty($sourcecompany->country_code) && ($targetcompany->country_code != $sourcecompany->country_code)) $withCountry = 1;
383
+		if (!empty($sourcecompany->country_code) && ($targetcompany->country_code != $sourcecompany->country_code)) {
384
+			$withCountry = 1;
385
+		}
348 386
 
349 387
 		$stringaddress .= ($stringaddress ? "\n" : '' ).$outputlangs->convToOutputCharset(dol_format_address($sourcecompany, $withCountry, "\n", $outputlangs))."\n";
350 388
 
351 389
 		if (empty($conf->global->MAIN_PDF_DISABLESOURCEDETAILS))
352 390
 		{
353 391
 			// Phone
354
-			if ($sourcecompany->phone) $stringaddress .= ($stringaddress ? "\n" : '' ).$outputlangs->transnoentities("PhoneShort").": ".$outputlangs->convToOutputCharset($sourcecompany->phone);
392
+			if ($sourcecompany->phone) {
393
+				$stringaddress .= ($stringaddress ? "\n" : '' ).$outputlangs->transnoentities("PhoneShort").": ".$outputlangs->convToOutputCharset($sourcecompany->phone);
394
+			}
355 395
 			// Fax
356
-			if ($sourcecompany->fax) $stringaddress .= ($stringaddress ? ($sourcecompany->phone ? " - " : "\n") : '' ).$outputlangs->transnoentities("Fax").": ".$outputlangs->convToOutputCharset($sourcecompany->fax);
396
+			if ($sourcecompany->fax) {
397
+				$stringaddress .= ($stringaddress ? ($sourcecompany->phone ? " - " : "\n") : '' ).$outputlangs->transnoentities("Fax").": ".$outputlangs->convToOutputCharset($sourcecompany->fax);
398
+			}
357 399
 			// EMail
358
-			if ($sourcecompany->email) $stringaddress .= ($stringaddress ? "\n" : '' ).$outputlangs->transnoentities("Email").": ".$outputlangs->convToOutputCharset($sourcecompany->email);
400
+			if ($sourcecompany->email) {
401
+				$stringaddress .= ($stringaddress ? "\n" : '' ).$outputlangs->transnoentities("Email").": ".$outputlangs->convToOutputCharset($sourcecompany->email);
402
+			}
359 403
 			// Web
360
-			if ($sourcecompany->url) $stringaddress .= ($stringaddress ? "\n" : '' ).$outputlangs->transnoentities("Web").": ".$outputlangs->convToOutputCharset($sourcecompany->url);
404
+			if ($sourcecompany->url) {
405
+				$stringaddress .= ($stringaddress ? "\n" : '' ).$outputlangs->transnoentities("Web").": ".$outputlangs->convToOutputCharset($sourcecompany->url);
406
+			}
361 407
 		}
362 408
 	}
363 409
 
@@ -369,83 +415,121 @@  discard block
 block discarded – undo
369 415
 
370 416
 			if (!empty($targetcontact->address)) {
371 417
 				$stringaddress .= ($stringaddress ? "\n" : '' ).$outputlangs->convToOutputCharset(dol_format_address($targetcontact))."\n";
372
-			}else {
418
+			} else {
373 419
 				$stringaddress .= ($stringaddress ? "\n" : '' ).$outputlangs->convToOutputCharset(dol_format_address($targetcompany))."\n";
374 420
 			}
375 421
 			// Country
376 422
 			if (!empty($targetcontact->country_code) && $targetcontact->country_code != $sourcecompany->country_code) {
377 423
 				$stringaddress.=$outputlangs->convToOutputCharset($outputlangs->transnoentitiesnoconv("Country".$targetcontact->country_code))."\n";
378
-			}
379
-			else if (empty($targetcontact->country_code) && !empty($targetcompany->country_code) && ($targetcompany->country_code != $sourcecompany->country_code)) {
424
+			} else if (empty($targetcontact->country_code) && !empty($targetcompany->country_code) && ($targetcompany->country_code != $sourcecompany->country_code)) {
380 425
 				$stringaddress.=$outputlangs->convToOutputCharset($outputlangs->transnoentitiesnoconv("Country".$targetcompany->country_code))."\n";
381 426
 			}
382 427
 
383 428
 			if (! empty($conf->global->MAIN_PDF_ADDALSOTARGETDETAILS) || $mode == 'targetwithdetails')
384 429
 			{
385 430
 				// Phone
386
-				if (! empty($targetcontact->phone_pro) || ! empty($targetcontact->phone_mobile)) $stringaddress .= ($stringaddress ? "\n" : '' ).$outputlangs->transnoentities("Phone").": ";
387
-				if (! empty($targetcontact->phone_pro)) $stringaddress .= $outputlangs->convToOutputCharset($targetcontact->phone_pro);
388
-				if (! empty($targetcontact->phone_pro) && ! empty($targetcontact->phone_mobile)) $stringaddress .= " / ";
389
-				if (! empty($targetcontact->phone_mobile)) $stringaddress .= $outputlangs->convToOutputCharset($targetcontact->phone_mobile);
431
+				if (! empty($targetcontact->phone_pro) || ! empty($targetcontact->phone_mobile)) {
432
+					$stringaddress .= ($stringaddress ? "\n" : '' ).$outputlangs->transnoentities("Phone").": ";
433
+				}
434
+				if (! empty($targetcontact->phone_pro)) {
435
+					$stringaddress .= $outputlangs->convToOutputCharset($targetcontact->phone_pro);
436
+				}
437
+				if (! empty($targetcontact->phone_pro) && ! empty($targetcontact->phone_mobile)) {
438
+					$stringaddress .= " / ";
439
+				}
440
+				if (! empty($targetcontact->phone_mobile)) {
441
+					$stringaddress .= $outputlangs->convToOutputCharset($targetcontact->phone_mobile);
442
+				}
390 443
 				// Fax
391
-				if ($targetcontact->fax) $stringaddress .= ($stringaddress ? "\n" : '' ).$outputlangs->transnoentities("Fax").": ".$outputlangs->convToOutputCharset($targetcontact->fax);
444
+				if ($targetcontact->fax) {
445
+					$stringaddress .= ($stringaddress ? "\n" : '' ).$outputlangs->transnoentities("Fax").": ".$outputlangs->convToOutputCharset($targetcontact->fax);
446
+				}
392 447
 				// EMail
393
-				if ($targetcontact->email) $stringaddress .= ($stringaddress ? "\n" : '' ).$outputlangs->transnoentities("Email").": ".$outputlangs->convToOutputCharset($targetcontact->email);
448
+				if ($targetcontact->email) {
449
+					$stringaddress .= ($stringaddress ? "\n" : '' ).$outputlangs->transnoentities("Email").": ".$outputlangs->convToOutputCharset($targetcontact->email);
450
+				}
394 451
 				// Web
395
-				if ($targetcontact->url) $stringaddress .= ($stringaddress ? "\n" : '' ).$outputlangs->transnoentities("Web").": ".$outputlangs->convToOutputCharset($targetcontact->url);
452
+				if ($targetcontact->url) {
453
+					$stringaddress .= ($stringaddress ? "\n" : '' ).$outputlangs->transnoentities("Web").": ".$outputlangs->convToOutputCharset($targetcontact->url);
454
+				}
396 455
 			}
397
-		}
398
-		else
456
+		} else
399 457
 		{
400 458
 			$stringaddress .= ($stringaddress ? "\n" : '' ).$outputlangs->convToOutputCharset(dol_format_address($targetcompany))."\n";
401 459
 			// Country
402
-			if (!empty($targetcompany->country_code) && $targetcompany->country_code != $sourcecompany->country_code) $stringaddress.=$outputlangs->convToOutputCharset($outputlangs->transnoentitiesnoconv("Country".$targetcompany->country_code))."\n";
460
+			if (!empty($targetcompany->country_code) && $targetcompany->country_code != $sourcecompany->country_code) {
461
+				$stringaddress.=$outputlangs->convToOutputCharset($outputlangs->transnoentitiesnoconv("Country".$targetcompany->country_code))."\n";
462
+			}
403 463
 
404 464
 			if (! empty($conf->global->MAIN_PDF_ADDALSOTARGETDETAILS) || $mode == 'targetwithdetails')
405 465
 			{
406 466
 				// Phone
407
-				if (! empty($targetcompany->phone) || ! empty($targetcompany->phone_mobile)) $stringaddress .= ($stringaddress ? "\n" : '' ).$outputlangs->transnoentities("Phone").": ";
408
-				if (! empty($targetcompany->phone)) $stringaddress .= $outputlangs->convToOutputCharset($targetcompany->phone);
409
-				if (! empty($targetcompany->phone) && ! empty($targetcompany->phone_mobile)) $stringaddress .= " / ";
410
-				if (! empty($targetcompany->phone_mobile)) $stringaddress .= $outputlangs->convToOutputCharset($targetcompany->phone_mobile);
467
+				if (! empty($targetcompany->phone) || ! empty($targetcompany->phone_mobile)) {
468
+					$stringaddress .= ($stringaddress ? "\n" : '' ).$outputlangs->transnoentities("Phone").": ";
469
+				}
470
+				if (! empty($targetcompany->phone)) {
471
+					$stringaddress .= $outputlangs->convToOutputCharset($targetcompany->phone);
472
+				}
473
+				if (! empty($targetcompany->phone) && ! empty($targetcompany->phone_mobile)) {
474
+					$stringaddress .= " / ";
475
+				}
476
+				if (! empty($targetcompany->phone_mobile)) {
477
+					$stringaddress .= $outputlangs->convToOutputCharset($targetcompany->phone_mobile);
478
+				}
411 479
 				// Fax
412
-				if ($targetcompany->fax) $stringaddress .= ($stringaddress ? "\n" : '' ).$outputlangs->transnoentities("Fax").": ".$outputlangs->convToOutputCharset($targetcompany->fax);
480
+				if ($targetcompany->fax) {
481
+					$stringaddress .= ($stringaddress ? "\n" : '' ).$outputlangs->transnoentities("Fax").": ".$outputlangs->convToOutputCharset($targetcompany->fax);
482
+				}
413 483
 				// EMail
414
-				if ($targetcompany->email) $stringaddress .= ($stringaddress ? "\n" : '' ).$outputlangs->transnoentities("Email").": ".$outputlangs->convToOutputCharset($targetcompany->email);
484
+				if ($targetcompany->email) {
485
+					$stringaddress .= ($stringaddress ? "\n" : '' ).$outputlangs->transnoentities("Email").": ".$outputlangs->convToOutputCharset($targetcompany->email);
486
+				}
415 487
 				// Web
416
-				if ($targetcompany->url) $stringaddress .= ($stringaddress ? "\n" : '' ).$outputlangs->transnoentities("Web").": ".$outputlangs->convToOutputCharset($targetcompany->url);
488
+				if ($targetcompany->url) {
489
+					$stringaddress .= ($stringaddress ? "\n" : '' ).$outputlangs->transnoentities("Web").": ".$outputlangs->convToOutputCharset($targetcompany->url);
490
+				}
417 491
 			}
418 492
 		}
419 493
 
420 494
 		// Intra VAT
421 495
 		if (empty($conf->global->MAIN_TVAINTRA_NOT_IN_ADDRESS))
422 496
 		{
423
-			if ($targetcompany->tva_intra) $stringaddress.="\n".$outputlangs->transnoentities("VATIntraShort").': '.$outputlangs->convToOutputCharset($targetcompany->tva_intra);
497
+			if ($targetcompany->tva_intra) {
498
+				$stringaddress.="\n".$outputlangs->transnoentities("VATIntraShort").': '.$outputlangs->convToOutputCharset($targetcompany->tva_intra);
499
+			}
424 500
 		}
425 501
 
426 502
 		// Professionnal Ids
427 503
 		if (! empty($conf->global->MAIN_PROFID1_IN_ADDRESS) && ! empty($targetcompany->idprof1))
428 504
 		{
429 505
 			$tmp=$outputlangs->transcountrynoentities("ProfId1",$targetcompany->country_code);
430
-			if (preg_match('/\((.+)\)/',$tmp,$reg)) $tmp=$reg[1];
506
+			if (preg_match('/\((.+)\)/',$tmp,$reg)) {
507
+				$tmp=$reg[1];
508
+			}
431 509
 			$stringaddress.="\n".$tmp.': '.$outputlangs->convToOutputCharset($targetcompany->idprof1);
432 510
 		}
433 511
 		if (! empty($conf->global->MAIN_PROFID2_IN_ADDRESS) && ! empty($targetcompany->idprof2))
434 512
 		{
435 513
 			$tmp=$outputlangs->transcountrynoentities("ProfId2",$targetcompany->country_code);
436
-			if (preg_match('/\((.+)\)/',$tmp,$reg)) $tmp=$reg[1];
514
+			if (preg_match('/\((.+)\)/',$tmp,$reg)) {
515
+				$tmp=$reg[1];
516
+			}
437 517
 			$stringaddress.="\n".$tmp.': '.$outputlangs->convToOutputCharset($targetcompany->idprof2);
438 518
 		}
439 519
 		if (! empty($conf->global->MAIN_PROFID3_IN_ADDRESS) && ! empty($targetcompany->idprof3))
440 520
 		{
441 521
 			$tmp=$outputlangs->transcountrynoentities("ProfId3",$targetcompany->country_code);
442
-			if (preg_match('/\((.+)\)/',$tmp,$reg)) $tmp=$reg[1];
522
+			if (preg_match('/\((.+)\)/',$tmp,$reg)) {
523
+				$tmp=$reg[1];
524
+			}
443 525
 			$stringaddress.="\n".$tmp.': '.$outputlangs->convToOutputCharset($targetcompany->idprof3);
444 526
 		}
445 527
 		if (! empty($conf->global->MAIN_PROFID4_IN_ADDRESS) && ! empty($targetcompany->idprof4))
446 528
 		{
447 529
 			$tmp=$outputlangs->transcountrynoentities("ProfId4",$targetcompany->country_code);
448
-			if (preg_match('/\((.+)\)/',$tmp,$reg)) $tmp=$reg[1];
530
+			if (preg_match('/\((.+)\)/',$tmp,$reg)) {
531
+				$tmp=$reg[1];
532
+			}
449 533
 			$stringaddress.="\n".$tmp.': '.$outputlangs->convToOutputCharset($targetcompany->idprof4);
450 534
 		}
451 535
 	}
@@ -467,9 +551,12 @@  discard block
 block discarded – undo
467 551
 	global $conf;
468 552
 
469 553
 	// Add a background image on document
470
-	if (! empty($conf->global->MAIN_USE_BACKGROUND_ON_PDF))		// Warning, this option make TCPDF generation beeing crazy and some content disappeared behin the image
554
+	if (! empty($conf->global->MAIN_USE_BACKGROUND_ON_PDF)) {
555
+		// Warning, this option make TCPDF generation beeing crazy and some content disappeared behin the image
471 556
 	{
472
-		$pdf->SetAutoPageBreak(0,0);	// Disable auto pagebreak before adding image
557
+		$pdf->SetAutoPageBreak(0,0);
558
+	}
559
+	// Disable auto pagebreak before adding image
473 560
 		$pdf->Image($conf->mycompany->dir_output.'/logos/'.$conf->global->MAIN_USE_BACKGROUND_ON_PDF, (isset($conf->global->MAIN_USE_BACKGROUND_ON_PDF_X)?$conf->global->MAIN_USE_BACKGROUND_ON_PDF_X:0), (isset($conf->global->MAIN_USE_BACKGROUND_ON_PDF_Y)?$conf->global->MAIN_USE_BACKGROUND_ON_PDF_Y:0), 0, $page_height);
474 561
 		$pdf->SetAutoPageBreak(1,0);	// Restore pagebreak
475 562
 	}
@@ -489,10 +576,15 @@  discard block
 block discarded – undo
489 576
 function pdf_watermark(&$pdf, $outputlangs, $h, $w, $unit, $text)
490 577
 {
491 578
 	// Print Draft Watermark
492
-	if ($unit=='pt') $k=1;
493
-	elseif ($unit=='mm') $k=72/25.4;
494
-	elseif ($unit=='cm') $k=72/2.54;
495
-	elseif ($unit=='in') $k=72;
579
+	if ($unit=='pt') {
580
+		$k=1;
581
+	} elseif ($unit=='mm') {
582
+		$k=72/25.4;
583
+	} elseif ($unit=='cm') {
584
+		$k=72/2.54;
585
+	} elseif ($unit=='in') {
586
+		$k=72;
587
+	}
496 588
 
497 589
 	$savx=$pdf->getX(); $savy=$pdf->getY();
498 590
 
@@ -546,7 +638,9 @@  discard block
 block discarded – undo
546 638
 
547 639
 	// Use correct name of bank id according to country
548 640
 	$bickey="BICNumber";
549
-	if ($account->getCountryCode() == 'IN') $bickey="SWIFT";
641
+	if ($account->getCountryCode() == 'IN') {
642
+		$bickey="SWIFT";
643
+	}
550 644
 
551 645
 	// Get format of bank account according to its country
552 646
 	$usedetailedbban=$account->useDetailedBBAN();
@@ -629,8 +723,7 @@  discard block
 block discarded – undo
629 723
 		$curx=$savcurx;
630 724
 		$cury+=9;
631 725
 		*/
632
-	}
633
-	else
726
+	} else
634 727
 	{
635 728
 		$pdf->SetFont('','B',$default_font_size - $diffsizecontent);
636 729
 		$pdf->SetXY($curx, $cury);
@@ -642,7 +735,9 @@  discard block
 block discarded – undo
642 735
 		$pdf->MultiCell(100, 3, $outputlangs->transnoentities("BankAccountNumber").': ' . $outputlangs->convToOutputCharset($account->number), 0, 'L', 0);
643 736
 		$cury+=3;
644 737
 
645
-		if ($diffsizecontent <= 2) $cury+=1;
738
+		if ($diffsizecontent <= 2) {
739
+			$cury+=1;
740
+		}
646 741
 	}
647 742
 
648 743
 	$pdf->SetFont('','',$default_font_size - $diffsizecontent);
@@ -665,13 +760,15 @@  discard block
 block discarded – undo
665 760
 		$pdf->MultiCell(100, 3, $val, 0, 'L', 0);
666 761
 		$tmpy=$pdf->getStringHeight(100, $val);
667 762
 		$cury+=$tmpy;
763
+	} else if (! $usedetailedbban) {
764
+		$cury+=1;
668 765
 	}
669 766
 
670
-	else if (! $usedetailedbban) $cury+=1;
671
-
672 767
 	// Use correct name of bank id according to country
673 768
 	$ibankey="IBANNumber";
674
-	if ($account->getCountryCode() == 'IN') $ibankey="IFSC";
769
+	if ($account->getCountryCode() == 'IN') {
770
+		$ibankey="IFSC";
771
+	}
675 772
 	if (! empty($account->iban))
676 773
 	{
677 774
 		//Remove whitespaces to ensure we are dealing with the format we expect
@@ -681,7 +778,9 @@  discard block
 block discarded – undo
681 778
 		for($i = 0; $i < dol_strlen($ibanDisplay_temp); $i++)
682 779
 		{
683 780
 			$ibanDisplay .= $ibanDisplay_temp[$i];
684
-			if($i%4 == 3 && $i > 0)	$ibanDisplay .= " ";
781
+			if($i%4 == 3 && $i > 0) {
782
+				$ibanDisplay .= " ";
783
+			}
685 784
 		}
686 785
 
687 786
 		$pdf->SetFont('','B',$default_font_size - 3);
@@ -806,21 +905,28 @@  discard block
 block discarded – undo
806 905
 	if ($fromcompany->capital)
807 906
 	{
808 907
 		$tmpamounttoshow = price2num($fromcompany->capital); // This field is a free string
809
-		if (is_numeric($tmpamounttoshow) && $tmpamounttoshow > 0) $line3.=($line3?" - ":"").$outputlangs->transnoentities("CapitalOf",price($tmpamounttoshow, 0, $outputlangs, 0, 0, 0, $conf->currency));
810
-		else $line3.=($line3?" - ":"").$outputlangs->transnoentities("CapitalOf",$tmpamounttoshow,$outputlangs);
908
+		if (is_numeric($tmpamounttoshow) && $tmpamounttoshow > 0) {
909
+			$line3.=($line3?" - ":"").$outputlangs->transnoentities("CapitalOf",price($tmpamounttoshow, 0, $outputlangs, 0, 0, 0, $conf->currency));
910
+		} else {
911
+			$line3.=($line3?" - ":"").$outputlangs->transnoentities("CapitalOf",$tmpamounttoshow,$outputlangs);
912
+		}
811 913
 	}
812 914
 	// Prof Id 1
813 915
 	if ($fromcompany->idprof1 && ($fromcompany->country_code != 'FR' || ! $fromcompany->idprof2))
814 916
 	{
815 917
 		$field=$outputlangs->transcountrynoentities("ProfId1",$fromcompany->country_code);
816
-		if (preg_match('/\((.*)\)/i',$field,$reg)) $field=$reg[1];
918
+		if (preg_match('/\((.*)\)/i',$field,$reg)) {
919
+			$field=$reg[1];
920
+		}
817 921
 		$line3.=($line3?" - ":"").$field.": ".$outputlangs->convToOutputCharset($fromcompany->idprof1);
818 922
 	}
819 923
 	// Prof Id 2
820 924
 	if ($fromcompany->idprof2)
821 925
 	{
822 926
 		$field=$outputlangs->transcountrynoentities("ProfId2",$fromcompany->country_code);
823
-		if (preg_match('/\((.*)\)/i',$field,$reg)) $field=$reg[1];
927
+		if (preg_match('/\((.*)\)/i',$field,$reg)) {
928
+			$field=$reg[1];
929
+		}
824 930
 		$line3.=($line3?" - ":"").$field.": ".$outputlangs->convToOutputCharset($fromcompany->idprof2);
825 931
 	}
826 932
 
@@ -829,14 +935,18 @@  discard block
 block discarded – undo
829 935
 	if ($fromcompany->idprof3)
830 936
 	{
831 937
 		$field=$outputlangs->transcountrynoentities("ProfId3",$fromcompany->country_code);
832
-		if (preg_match('/\((.*)\)/i',$field,$reg)) $field=$reg[1];
938
+		if (preg_match('/\((.*)\)/i',$field,$reg)) {
939
+			$field=$reg[1];
940
+		}
833 941
 		$line4.=($line4?" - ":"").$field.": ".$outputlangs->convToOutputCharset($fromcompany->idprof3);
834 942
 	}
835 943
 	// Prof Id 4
836 944
 	if ($fromcompany->idprof4)
837 945
 	{
838 946
 		$field=$outputlangs->transcountrynoentities("ProfId4",$fromcompany->country_code);
839
-		if (preg_match('/\((.*)\)/i',$field,$reg)) $field=$reg[1];
947
+		if (preg_match('/\((.*)\)/i',$field,$reg)) {
948
+			$field=$reg[1];
949
+		}
840 950
 		$line4.=($line4?" - ":"").$field.": ".$outputlangs->convToOutputCharset($fromcompany->idprof4);
841 951
 	}
842 952
 	// IntraCommunautary VAT
@@ -850,9 +960,12 @@  discard block
 block discarded – undo
850 960
 
851 961
 	// The start of the bottom of this page footer is positioned according to # of lines
852 962
 	$freetextheight=0;
853
-	if ($line)	// Free text
963
+	if ($line) {
964
+		// Free text
854 965
 	{
855
-		$width=20000; $align='L';	// By default, ask a manual break: We use a large value 20000, to not have automatic wrap. This make user understand, he need to add CR on its text.
966
+		$width=20000;
967
+	}
968
+	$align='L';	// By default, ask a manual break: We use a large value 20000, to not have automatic wrap. This make user understand, he need to add CR on its text.
856 969
 		if (! empty($conf->global->MAIN_USE_AUTOWRAP_ON_FREETEXT)) {
857 970
 			$width=200; $align='C';
858 971
 		}
@@ -862,9 +975,11 @@  discard block
 block discarded – undo
862 975
 	$marginwithfooter=$marge_basse + $freetextheight + (! empty($line1)?3:0) + (! empty($line2)?3:0) + (! empty($line3)?3:0) + (! empty($line4)?3:0);
863 976
 	$posy=$marginwithfooter+0;
864 977
 
865
-	if ($line)	// Free text
978
+	if ($line) {
979
+		// Free text
866 980
 	{
867 981
 		$pdf->SetXY($dims['lm'],-$posy);
982
+	}
868 983
 		$pdf->MultiCell(0, 3, $line, 0, $align, 0);
869 984
 		$posy-=$freetextheight;
870 985
 	}
@@ -909,8 +1024,11 @@  discard block
 block discarded – undo
909 1024
 	{
910 1025
 		$pdf->SetXY(-20,-$posy);
911 1026
 		//print 'xxx'.$pdf->PageNo().'-'.$pdf->getAliasNbPages().'-'.$pdf->getAliasNumPage();exit;
912
-		if (empty($conf->global->MAIN_USE_FPDF)) $pdf->MultiCell(13, 2, $pdf->PageNo().'/'.$pdf->getAliasNbPages(), 0, 'R', 0);
913
-		else $pdf->MultiCell(13, 2, $pdf->PageNo().'/{nb}', 0, 'R', 0);
1027
+		if (empty($conf->global->MAIN_USE_FPDF)) {
1028
+			$pdf->MultiCell(13, 2, $pdf->PageNo().'/'.$pdf->getAliasNbPages(), 0, 'R', 0);
1029
+		} else {
1030
+			$pdf->MultiCell(13, 2, $pdf->PageNo().'/{nb}', 0, 'R', 0);
1031
+		}
914 1032
 	}
915 1033
 
916 1034
 	return $marginwithfooter;
@@ -978,7 +1096,9 @@  discard block
 block discarded – undo
978 1096
 	if (is_object($hookmanager) && ( (isset($object->lines[$i]->product_type) && $object->lines[$i]->product_type == 9 && ! empty($object->lines[$i]->special_code)) || ! empty($object->lines[$i]->fk_parent_line) ) )
979 1097
 	{
980 1098
 		$special_code = $object->lines[$i]->special_code;
981
-		if (! empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line);
1099
+		if (! empty($object->lines[$i]->fk_parent_line)) {
1100
+			$special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line);
1101
+		}
982 1102
 		$parameters = array('pdf'=>$pdf,'i'=>$i,'outputlangs'=>$outputlangs,'w'=>$w,'h'=>$h,'posx'=>$posx,'posy'=>$posy,'hideref'=>$hideref,'hidedesc'=>$hidedesc,'issupplierline'=>$issupplierline,'special_code'=>$special_code);
983 1103
 		$action='';
984 1104
 		$reshook=$hookmanager->executeHooks('pdf_writelinedesc',$parameters,$object,$action);    // Note that $action and $object may have been modified by some hooks
@@ -1014,8 +1134,11 @@  discard block
 block discarded – undo
1014 1134
 	$note=(! empty($object->lines[$i]->note)?$object->lines[$i]->note:'');
1015 1135
 	$dbatch=(! empty($object->lines[$i]->detail_batch)?$object->lines[$i]->detail_batch:false);
1016 1136
 
1017
-	if ($issupplierline) $prodser = new ProductFournisseur($db);
1018
-	else $prodser = new Product($db);
1137
+	if ($issupplierline) {
1138
+		$prodser = new ProductFournisseur($db);
1139
+	} else {
1140
+		$prodser = new Product($db);
1141
+	}
1019 1142
 
1020 1143
 	if ($idprod)
1021 1144
 	{
@@ -1032,7 +1155,9 @@  discard block
 block discarded – undo
1032 1155
 			// If we want another language, and if label is same than default language (we did force it to a specific value), we can use translation.
1033 1156
 			//var_dump($outputlangs->defaultlang.' - '.$langs->defaultlang.' - '.$label.' - '.$prodser->label);exit;
1034 1157
 			$textwasmodified=($label == $prodser->label);
1035
-			if (! empty($prodser->multilangs[$outputlangs->defaultlang]["label"]) && ($textwasmodified || $translatealsoifmodified))     $label=$prodser->multilangs[$outputlangs->defaultlang]["label"];
1158
+			if (! empty($prodser->multilangs[$outputlangs->defaultlang]["label"]) && ($textwasmodified || $translatealsoifmodified)) {
1159
+				$label=$prodser->multilangs[$outputlangs->defaultlang]["label"];
1160
+			}
1036 1161
 
1037 1162
 			// Set desc
1038 1163
 			// Manage HTML entities description test because $prodser->description is store with htmlentities but $desc no
@@ -1042,11 +1167,15 @@  discard block
 block discarded – undo
1042 1167
 			} else {
1043 1168
 				$textwasmodified=($desc == $prodser->description);
1044 1169
 			}
1045
-			if (! empty($prodser->multilangs[$outputlangs->defaultlang]["description"]) && ($textwasmodified || $translatealsoifmodified))  $desc=$prodser->multilangs[$outputlangs->defaultlang]["description"];
1170
+			if (! empty($prodser->multilangs[$outputlangs->defaultlang]["description"]) && ($textwasmodified || $translatealsoifmodified)) {
1171
+				$desc=$prodser->multilangs[$outputlangs->defaultlang]["description"];
1172
+			}
1046 1173
 
1047 1174
 			// Set note
1048 1175
 			$textwasmodified=($note == $prodser->note);
1049
-			if (! empty($prodser->multilangs[$outputlangs->defaultlang]["note"]) && ($textwasmodified || $translatealsoifmodified))  $note=$prodser->multilangs[$outputlangs->defaultlang]["note"];
1176
+			if (! empty($prodser->multilangs[$outputlangs->defaultlang]["note"]) && ($textwasmodified || $translatealsoifmodified)) {
1177
+				$note=$prodser->multilangs[$outputlangs->defaultlang]["note"];
1178
+			}
1050 1179
 		}
1051 1180
 	}
1052 1181
 
@@ -1066,22 +1195,23 @@  discard block
 block discarded – undo
1066 1195
 			$discount=new DiscountAbsolute($db);
1067 1196
 			$discount->fetch($object->lines[$i]->fk_remise_except);
1068 1197
 			$libelleproduitservice=$outputlangs->transnoentitiesnoconv("DiscountFromCreditNote",$discount->ref_facture_source);
1069
-		}
1070
-		elseif ($desc == '(DEPOSIT)' && $object->lines[$i]->fk_remise_except)
1198
+		} elseif ($desc == '(DEPOSIT)' && $object->lines[$i]->fk_remise_except)
1071 1199
 		{
1072 1200
 			$discount=new DiscountAbsolute($db);
1073 1201
 			$discount->fetch($object->lines[$i]->fk_remise_except);
1074 1202
 			$libelleproduitservice=$outputlangs->transnoentitiesnoconv("DiscountFromDeposit",$discount->ref_facture_source);
1075 1203
 			// Add date of deposit
1076
-			if (! empty($conf->global->INVOICE_ADD_DEPOSIT_DATE)) echo ' ('.dol_print_date($discount->datec,'day','',$outputlangs).')';
1077
-		}
1078
-		else
1204
+			if (! empty($conf->global->INVOICE_ADD_DEPOSIT_DATE)) {
1205
+				echo ' ('.dol_print_date($discount->datec,'day','',$outputlangs).')';
1206
+			}
1207
+		} else
1079 1208
 		{
1080 1209
 			if ($idprod)
1081 1210
 			{
1082
-				if (empty($hidedesc)) $libelleproduitservice.=$desc;
1083
-			}
1084
-			else
1211
+				if (empty($hidedesc)) {
1212
+					$libelleproduitservice.=$desc;
1213
+				}
1214
+			} else
1085 1215
 			{
1086 1216
 				$libelleproduitservice.=$desc;
1087 1217
 			}
@@ -1096,13 +1226,14 @@  discard block
 block discarded – undo
1096 1226
 		{
1097 1227
 			$prefix_prodserv = "";
1098 1228
 			$ref_prodserv = "";
1099
-			if (! empty($conf->global->PRODUCT_ADD_TYPE_IN_DOCUMENTS))   // In standard mode, we do not show this
1229
+			if (! empty($conf->global->PRODUCT_ADD_TYPE_IN_DOCUMENTS)) {
1230
+				// In standard mode, we do not show this
1100 1231
 			{
1101 1232
 				if ($prodser->isservice())
1102 1233
 				{
1103 1234
 					$prefix_prodserv = $outputlangs->transnoentitiesnoconv("Service")." ";
1104
-				}
1105
-				else
1235
+			}
1236
+				} else
1106 1237
 				{
1107 1238
 					$prefix_prodserv = $outputlangs->transnoentitiesnoconv("Product")." ";
1108 1239
 				}
@@ -1110,10 +1241,18 @@  discard block
 block discarded – undo
1110 1241
 
1111 1242
 			if (empty($hideref))
1112 1243
 			{
1113
-				if ($issupplierline) $ref_prodserv = $prodser->ref.($ref_supplier ? ' ('.$outputlangs->transnoentitiesnoconv("SupplierRef").' '.$ref_supplier.')' : '');   // Show local ref and supplier ref
1114
-				else $ref_prodserv = $prodser->ref; // Show local ref only
1244
+				if ($issupplierline) {
1245
+					$ref_prodserv = $prodser->ref.($ref_supplier ? ' ('.$outputlangs->transnoentitiesnoconv("SupplierRef").' '.$ref_supplier.')' : '');
1246
+				}
1247
+				// Show local ref and supplier ref
1248
+				else {
1249
+					$ref_prodserv = $prodser->ref;
1250
+				}
1251
+				// Show local ref only
1115 1252
 
1116
-				if (! empty($libelleproduitservice)) $ref_prodserv .= " - ";
1253
+				if (! empty($libelleproduitservice)) {
1254
+					$ref_prodserv .= " - ";
1255
+				}
1117 1256
 			}
1118 1257
 
1119 1258
 			$libelleproduitservice=$prefix_prodserv.$ref_prodserv.$libelleproduitservice;
@@ -1131,8 +1270,9 @@  discard block
 block discarded – undo
1131 1270
 		{
1132 1271
 			// Adding the descriptions if they are filled
1133 1272
 			$desccateg=$cate->add_description;
1134
-			if ($desccateg)
1135
-				$libelleproduitservice.='__N__'.$desccateg;
1273
+			if ($desccateg) {
1274
+							$libelleproduitservice.='__N__'.$desccateg;
1275
+			}
1136 1276
 		}
1137 1277
 	}
1138 1278
 
@@ -1163,17 +1303,26 @@  discard block
 block discarded – undo
1163 1303
 		foreach ($dbatch as $detail)
1164 1304
 		{
1165 1305
 			$dte=array();
1166
-			if ($detail->eatby) $dte[]=$outputlangs->transnoentitiesnoconv('printEatby',dol_print_date($detail->eatby, $format, false, $outputlangs));
1167
-			if ($detail->sellby) $dte[]=$outputlangs->transnoentitiesnoconv('printSellby',dol_print_date($detail->sellby, $format, false, $outputlangs));
1168
-			if ($detail->batch) $dte[]=$outputlangs->transnoentitiesnoconv('printBatch',$detail->batch);
1306
+			if ($detail->eatby) {
1307
+				$dte[]=$outputlangs->transnoentitiesnoconv('printEatby',dol_print_date($detail->eatby, $format, false, $outputlangs));
1308
+			}
1309
+			if ($detail->sellby) {
1310
+				$dte[]=$outputlangs->transnoentitiesnoconv('printSellby',dol_print_date($detail->sellby, $format, false, $outputlangs));
1311
+			}
1312
+			if ($detail->batch) {
1313
+				$dte[]=$outputlangs->transnoentitiesnoconv('printBatch',$detail->batch);
1314
+			}
1169 1315
 			$dte[]=$outputlangs->transnoentitiesnoconv('printQty',$detail->dluo_qty);
1170 1316
 			$libelleproduitservice.= "__N__  ".implode($dte,"-");
1171 1317
 		}
1172 1318
 	}
1173 1319
 
1174 1320
 	// Now we convert \n into br
1175
-	if (dol_textishtml($libelleproduitservice)) $libelleproduitservice=preg_replace('/__N__/','<br>',$libelleproduitservice);
1176
-	else $libelleproduitservice=preg_replace('/__N__/',"\n",$libelleproduitservice);
1321
+	if (dol_textishtml($libelleproduitservice)) {
1322
+		$libelleproduitservice=preg_replace('/__N__/','<br>',$libelleproduitservice);
1323
+	} else {
1324
+		$libelleproduitservice=preg_replace('/__N__/',"\n",$libelleproduitservice);
1325
+	}
1177 1326
 	$libelleproduitservice=dol_htmlentitiesbr($libelleproduitservice,1);
1178 1327
 
1179 1328
 	return $libelleproduitservice;
@@ -1195,10 +1344,11 @@  discard block
 block discarded – undo
1195 1344
 	if (is_object($hookmanager) && (($object->lines[$i]->product_type == 9 && !empty($object->lines[$i]->special_code)) || ! empty($object->lines[$i]->fk_parent_line)))
1196 1345
 	{
1197 1346
 		$special_code = $object->lines[$i]->special_code;
1198
-		if (! empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line);
1347
+		if (! empty($object->lines[$i]->fk_parent_line)) {
1348
+			$special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line);
1349
+		}
1199 1350
 		// TODO add hook function
1200
-	}
1201
-	else
1351
+	} else
1202 1352
 	{
1203 1353
 		return dol_htmlentitiesbr($object->lines[$i]->num);
1204 1354
 	}
@@ -1221,10 +1371,11 @@  discard block
 block discarded – undo
1221 1371
 	if (is_object($hookmanager) && (($object->lines[$i]->product_type == 9 && !empty($object->lines[$i]->special_code)) || ! empty($object->lines[$i]->fk_parent_line)))
1222 1372
 	{
1223 1373
 		$special_code = $object->lines[$i]->special_code;
1224
-		if (! empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line);
1374
+		if (! empty($object->lines[$i]->fk_parent_line)) {
1375
+			$special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line);
1376
+		}
1225 1377
 		// TODO add hook function
1226
-	}
1227
-	else
1378
+	} else
1228 1379
 	{
1229 1380
 		return dol_htmlentitiesbr($object->lines[$i]->product_ref);
1230 1381
 	}
@@ -1246,10 +1397,11 @@  discard block
 block discarded – undo
1246 1397
 	if (is_object($hookmanager) && ( ($object->lines[$i]->product_type == 9 && !empty($object->lines[$i]->special_code) ) || ! empty($object->lines[$i]->fk_parent_line) ) )
1247 1398
 	{
1248 1399
 		$special_code = $object->lines[$i]->special_code;
1249
-		if (! empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line);
1400
+		if (! empty($object->lines[$i]->fk_parent_line)) {
1401
+			$special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line);
1402
+		}
1250 1403
 		// TODO add hook function
1251
-	}
1252
-	else
1404
+	} else
1253 1405
 	{
1254 1406
 		return dol_htmlentitiesbr($object->lines[$i]->ref_supplier);
1255 1407
 	}
@@ -1271,17 +1423,23 @@  discard block
 block discarded – undo
1271 1423
 	if (is_object($hookmanager) && (($object->lines[$i]->product_type == 9 && !empty($object->lines[$i]->special_code)) || ! empty($object->lines[$i]->fk_parent_line)))
1272 1424
 	{
1273 1425
 		$special_code = $object->lines[$i]->special_code;
1274
-		if (! empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line);
1426
+		if (! empty($object->lines[$i]->fk_parent_line)) {
1427
+			$special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line);
1428
+		}
1275 1429
 		$parameters = array('i'=>$i,'outputlangs'=>$outputlangs,'hidedetails'=>$hidedetails,'special_code'=>$special_code);
1276 1430
 		$action='';
1277 1431
 		$reshook = $hookmanager->executeHooks('pdf_getlinevatrate',$parameters,$object,$action);    // Note that $action and $object may have been modified by some hooks
1278 1432
 		
1279
-		if(!empty($hookmanager->resPrint)) return $hookmanager->resPrint;
1280
-		else return $reshook;
1281
-	}
1282
-	else
1433
+		if(!empty($hookmanager->resPrint)) {
1434
+			return $hookmanager->resPrint;
1435
+		} else {
1436
+			return $reshook;
1437
+		}
1438
+	} else
1283 1439
 	{
1284
-		if (empty($hidedetails) || $hidedetails > 1) return vatrate($object->lines[$i]->tva_tx,1,$object->lines[$i]->info_bits,1);
1440
+		if (empty($hidedetails) || $hidedetails > 1) {
1441
+			return vatrate($object->lines[$i]->tva_tx,1,$object->lines[$i]->info_bits,1);
1442
+		}
1285 1443
 	}
1286 1444
 }
1287 1445
 
@@ -1299,22 +1457,30 @@  discard block
 block discarded – undo
1299 1457
 	global $conf, $hookmanager;
1300 1458
 
1301 1459
 	$sign=1;
1302
-	if (isset($object->type) && $object->type == 2 && ! empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) $sign=-1;
1460
+	if (isset($object->type) && $object->type == 2 && ! empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) {
1461
+		$sign=-1;
1462
+	}
1303 1463
 
1304 1464
 	if (is_object($hookmanager) && (($object->lines[$i]->product_type == 9 && !empty($object->lines[$i]->special_code)) || ! empty($object->lines[$i]->fk_parent_line)))
1305 1465
 	{
1306 1466
 		$special_code = $object->lines[$i]->special_code;
1307
-		if (! empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line);
1467
+		if (! empty($object->lines[$i]->fk_parent_line)) {
1468
+			$special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line);
1469
+		}
1308 1470
 		$parameters = array('i'=>$i,'outputlangs'=>$outputlangs,'hidedetails'=>$hidedetails,'special_code'=>$special_code);
1309 1471
 		$action='';
1310 1472
 		$reshook = $hookmanager->executeHooks('pdf_getlineupexcltax',$parameters,$object,$action);    // Note that $action and $object may have been modified by some hooks
1311 1473
 		
1312
-		if(!empty($hookmanager->resPrint)) return $hookmanager->resPrint;
1313
-		else return $reshook;
1314
-	}
1315
-	else
1474
+		if(!empty($hookmanager->resPrint)) {
1475
+			return $hookmanager->resPrint;
1476
+		} else {
1477
+			return $reshook;
1478
+		}
1479
+	} else
1316 1480
 	{
1317
-		if (empty($hidedetails) || $hidedetails > 1) return price($sign * $object->lines[$i]->subprice, 0, $outputlangs);
1481
+		if (empty($hidedetails) || $hidedetails > 1) {
1482
+			return price($sign * $object->lines[$i]->subprice, 0, $outputlangs);
1483
+		}
1318 1484
 	}
1319 1485
 }
1320 1486
 
@@ -1334,15 +1500,20 @@  discard block
 block discarded – undo
1334 1500
 	if (is_object($hookmanager) && (($object->lines[$i]->product_type == 9 && !empty($object->lines[$i]->special_code)) || ! empty($object->lines[$i]->fk_parent_line)))
1335 1501
 	{
1336 1502
 		$special_code = $object->lines[$i]->special_code;
1337
-		if (! empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line);
1503
+		if (! empty($object->lines[$i]->fk_parent_line)) {
1504
+			$special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line);
1505
+		}
1338 1506
 		foreach($object->hooks as $modules)
1339 1507
 		{
1340
-			if (method_exists($modules[$special_code],'pdf_getlineupwithtax')) return $modules[$special_code]->pdf_getlineupwithtax($object,$i,$outputlangs,$hidedetails);
1508
+			if (method_exists($modules[$special_code],'pdf_getlineupwithtax')) {
1509
+				return $modules[$special_code]->pdf_getlineupwithtax($object,$i,$outputlangs,$hidedetails);
1510
+			}
1341 1511
 		}
1342
-	}
1343
-	else
1512
+	} else
1344 1513
 	{
1345
-		if (empty($hidedetails) || $hidedetails > 1) return price(($object->lines[$i]->subprice) + ($object->lines[$i]->subprice)*($object->lines[$i]->tva_tx)/100, 0, $outputlangs);
1514
+		if (empty($hidedetails) || $hidedetails > 1) {
1515
+			return price(($object->lines[$i]->subprice) + ($object->lines[$i]->subprice)*($object->lines[$i]->tva_tx)/100, 0, $outputlangs);
1516
+		}
1346 1517
 	}
1347 1518
 }
1348 1519
 
@@ -1364,18 +1535,24 @@  discard block
 block discarded – undo
1364 1535
 		if (is_object($hookmanager) && (( $object->lines[$i]->product_type == 9 && !empty($object->lines[$i]->special_code) ) || ! empty($object->lines[$i]->fk_parent_line) ) )
1365 1536
 		{
1366 1537
 			$special_code = $object->lines[$i]->special_code;
1367
-			if (! empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line);
1538
+			if (! empty($object->lines[$i]->fk_parent_line)) {
1539
+				$special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line);
1540
+			}
1368 1541
 			$parameters = array('i'=>$i,'outputlangs'=>$outputlangs,'hidedetails'=>$hidedetails,'special_code'=>$special_code);
1369 1542
 			$action='';
1370 1543
 			$reshook = $hookmanager->executeHooks('pdf_getlineqty',$parameters,$object,$action);    // Note that $action and $object may have been modified by some hooks
1371 1544
 			
1372
-			if(!empty($hookmanager->resPrint)) return $hookmanager->resPrint;
1373
-			else return $reshook;
1545
+			if(!empty($hookmanager->resPrint)) {
1546
+				return $hookmanager->resPrint;
1547
+			} else {
1548
+				return $reshook;
1549
+			}
1374 1550
 			
1375
-		}
1376
-		else
1551
+		} else
1377 1552
 		{
1378
-			if (empty($hidedetails) || $hidedetails > 1) return $object->lines[$i]->qty;
1553
+			if (empty($hidedetails) || $hidedetails > 1) {
1554
+				return $object->lines[$i]->qty;
1555
+			}
1379 1556
 		}
1380 1557
 	}
1381 1558
 }
@@ -1398,17 +1575,23 @@  discard block
 block discarded – undo
1398 1575
 		if (is_object($hookmanager) && (( $object->lines[$i]->product_type == 9 && !empty($object->lines[$i]->special_code) ) || ! empty($object->lines[$i]->fk_parent_line) ) )
1399 1576
 		{
1400 1577
 			$special_code = $object->lines[$i]->special_code;
1401
-			if (! empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line);
1578
+			if (! empty($object->lines[$i]->fk_parent_line)) {
1579
+				$special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line);
1580
+			}
1402 1581
 			$parameters = array('i'=>$i,'outputlangs'=>$outputlangs,'hidedetails'=>$hidedetails,'special_code'=>$special_code);
1403 1582
 			$action='';
1404 1583
 			$reshook = $hookmanager->executeHooks('pdf_getlineqty_asked',$parameters,$object,$action);    // Note that $action and $object may have been modified by some hooks
1405 1584
 		
1406
-			if(!empty($hookmanager->resPrint)) return $hookmanager->resPrint;
1407
-			else return $reshook;
1408
-		}
1409
-		else
1585
+			if(!empty($hookmanager->resPrint)) {
1586
+				return $hookmanager->resPrint;
1587
+			} else {
1588
+				return $reshook;
1589
+			}
1590
+		} else
1410 1591
 		{
1411
-			if (empty($hidedetails) || $hidedetails > 1) return $object->lines[$i]->qty_asked;
1592
+			if (empty($hidedetails) || $hidedetails > 1) {
1593
+				return $object->lines[$i]->qty_asked;
1594
+			}
1412 1595
 		}
1413 1596
 	}
1414 1597
 }
@@ -1431,17 +1614,23 @@  discard block
 block discarded – undo
1431 1614
 		if (is_object($hookmanager) && (( $object->lines[$i]->product_type == 9 && !empty($object->lines[$i]->special_code) ) || ! empty($object->lines[$i]->fk_parent_line) ) )
1432 1615
 		{
1433 1616
 			$special_code = $object->lines[$i]->special_code;
1434
-			if (! empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line);
1617
+			if (! empty($object->lines[$i]->fk_parent_line)) {
1618
+				$special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line);
1619
+			}
1435 1620
 			$parameters = array('i'=>$i,'outputlangs'=>$outputlangs,'hidedetails'=>$hidedetails,'special_code'=>$special_code);
1436 1621
 			$action='';
1437 1622
 			$reshook = $hookmanager->executeHooks('pdf_getlineqty_shipped',$parameters,$object,$action);    // Note that $action and $object may have been modified by some hooks
1438 1623
 			
1439
-			if(!empty($hookmanager->resPrint)) return $hookmanager->resPrint;
1440
-			else return $reshook;
1441
-		}
1442
-		else
1624
+			if(!empty($hookmanager->resPrint)) {
1625
+				return $hookmanager->resPrint;
1626
+			} else {
1627
+				return $reshook;
1628
+			}
1629
+		} else
1443 1630
 		{
1444
-			if (empty($hidedetails) || $hidedetails > 1) return $object->lines[$i]->qty_shipped;
1631
+			if (empty($hidedetails) || $hidedetails > 1) {
1632
+				return $object->lines[$i]->qty_shipped;
1633
+			}
1445 1634
 		}
1446 1635
 	}
1447 1636
 }
@@ -1464,17 +1653,23 @@  discard block
 block discarded – undo
1464 1653
 		if (is_object($hookmanager) && (( $object->lines[$i]->product_type == 9 && !empty($object->lines[$i]->special_code) ) || ! empty($object->lines[$i]->fk_parent_line) ) )
1465 1654
 		{
1466 1655
 			$special_code = $object->lines[$i]->special_code;
1467
-			if (! empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line);
1656
+			if (! empty($object->lines[$i]->fk_parent_line)) {
1657
+				$special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line);
1658
+			}
1468 1659
 			$parameters = array('i'=>$i,'outputlangs'=>$outputlangs,'hidedetails'=>$hidedetails,'special_code'=>$special_code);
1469 1660
 			$action='';
1470 1661
 			$reshook = $hookmanager->executeHooks('pdf_getlineqty_keeptoship',$parameters,$object,$action);    // Note that $action and $object may have been modified by some hooks
1471 1662
 			
1472
-			if(!empty($hookmanager->resPrint)) return $hookmanager->resPrint;
1473
-			else return $reshook;
1474
-		}
1475
-		else
1663
+			if(!empty($hookmanager->resPrint)) {
1664
+				return $hookmanager->resPrint;
1665
+			} else {
1666
+				return $reshook;
1667
+			}
1668
+		} else
1476 1669
 		{
1477
-			if (empty($hidedetails) || $hidedetails > 1) return ($object->lines[$i]->qty_asked - $object->lines[$i]->qty_shipped);
1670
+			if (empty($hidedetails) || $hidedetails > 1) {
1671
+				return ($object->lines[$i]->qty_asked - $object->lines[$i]->qty_shipped);
1672
+			}
1478 1673
 		}
1479 1674
 	}
1480 1675
 }
@@ -1508,8 +1703,11 @@  discard block
 block discarded – undo
1508 1703
 			$reshook = $hookmanager->executeHooks('pdf_getlineunit', $parameters, $object,
1509 1704
 				$action);    // Note that $action and $object may have been modified by some hooks
1510 1705
 				
1511
-			if(!empty($hookmanager->resPrint)) return $hookmanager->resPrint;
1512
-			else return $reshook;
1706
+			if(!empty($hookmanager->resPrint)) {
1707
+				return $hookmanager->resPrint;
1708
+			} else {
1709
+				return $reshook;
1710
+			}
1513 1711
 				
1514 1712
 		} else {
1515 1713
 			if (empty($hidedetails) || $hidedetails > 1) {
@@ -1540,17 +1738,23 @@  discard block
 block discarded – undo
1540 1738
 		if (is_object($hookmanager) && ( ($object->lines[$i]->product_type == 9 && !empty($object->lines[$i]->special_code) ) || ! empty($object->lines[$i]->fk_parent_line) ) )
1541 1739
 		{
1542 1740
 			$special_code = $object->lines[$i]->special_code;
1543
-			if (! empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line);
1741
+			if (! empty($object->lines[$i]->fk_parent_line)) {
1742
+				$special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line);
1743
+			}
1544 1744
 			$parameters = array('i'=>$i,'outputlangs'=>$outputlangs,'hidedetails'=>$hidedetails,'special_code'=>$special_code);
1545 1745
 			$action='';
1546 1746
 			$reshook = $hookmanager->executeHooks('pdf_getlineremisepercent',$parameters,$object,$action);    // Note that $action and $object may have been modified by some hooks
1547 1747
 			
1548
-			if(!empty($hookmanager->resPrint)) return $hookmanager->resPrint;
1549
-			else return $reshook;
1550
-		}
1551
-		else
1748
+			if(!empty($hookmanager->resPrint)) {
1749
+				return $hookmanager->resPrint;
1750
+			} else {
1751
+				return $reshook;
1752
+			}
1753
+		} else
1552 1754
 		{
1553
-			if (empty($hidedetails) || $hidedetails > 1) return dol_print_reduction($object->lines[$i]->remise_percent,$outputlangs);
1755
+			if (empty($hidedetails) || $hidedetails > 1) {
1756
+				return dol_print_reduction($object->lines[$i]->remise_percent,$outputlangs);
1757
+			}
1554 1758
 		}
1555 1759
 	}
1556 1760
 }
@@ -1572,15 +1776,22 @@  discard block
 block discarded – undo
1572 1776
 	if ($object->lines[$i]->special_code != 3) {
1573 1777
 		if (is_object($hookmanager) && (($object->lines[$i]->product_type == 9 && !empty($object->lines[$i]->special_code)) || !empty($object->lines[$i]->fk_parent_line))) {
1574 1778
 			$special_code = $object->lines[$i]->special_code;
1575
-			if (!empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line);
1779
+			if (!empty($object->lines[$i]->fk_parent_line)) {
1780
+				$special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line);
1781
+			}
1576 1782
 			$parameters = array('i' => $i, 'outputlangs' => $outputlangs, 'hidedetails' => $hidedetails, 'special_code' => $special_code);
1577 1783
 			$action = '';
1578 1784
 			$reshook = $hookmanager->executeHooks('pdf_getlineprogress', $parameters, $object, $action);    // Note that $action and $object may have been modified by some hooks
1579 1785
 			
1580
-			if(!empty($hookmanager->resPrint)) return $hookmanager->resPrint;
1581
-			else return $reshook;
1786
+			if(!empty($hookmanager->resPrint)) {
1787
+				return $hookmanager->resPrint;
1788
+			} else {
1789
+				return $reshook;
1790
+			}
1582 1791
 		} else {
1583
-			if (empty($hidedetails) || $hidedetails > 1) return $object->lines[$i]->situation_percent . '%';
1792
+			if (empty($hidedetails) || $hidedetails > 1) {
1793
+				return $object->lines[$i]->situation_percent . '%';
1794
+			}
1584 1795
 		}
1585 1796
 	}
1586 1797
 }
@@ -1599,28 +1810,35 @@  discard block
 block discarded – undo
1599 1810
 	global $conf, $hookmanager;
1600 1811
 
1601 1812
 	$sign=1;
1602
-	if (isset($object->type) && $object->type == 2 && ! empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) $sign=-1;
1813
+	if (isset($object->type) && $object->type == 2 && ! empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) {
1814
+		$sign=-1;
1815
+	}
1603 1816
 
1604 1817
 	if ($object->lines[$i]->special_code == 3)
1605 1818
 	{
1606 1819
 		return $outputlangs->transnoentities("Option");
1607
-	}
1608
-	else
1820
+	} else
1609 1821
 	{
1610 1822
 		if (is_object($hookmanager) && (($object->lines[$i]->product_type == 9 && ! empty($object->lines[$i]->special_code)) || ! empty($object->lines[$i]->fk_parent_line)))
1611 1823
 		{
1612 1824
 			$special_code = $object->lines[$i]->special_code;
1613
-			if (! empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line);
1825
+			if (! empty($object->lines[$i]->fk_parent_line)) {
1826
+				$special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line);
1827
+			}
1614 1828
 			$parameters = array('i'=>$i,'outputlangs'=>$outputlangs,'hidedetails'=>$hidedetails,'special_code'=>$special_code);
1615 1829
 			$action='';
1616 1830
 			$reshook = $hookmanager->executeHooks('pdf_getlinetotalexcltax',$parameters,$object,$action);    // Note that $action and $object may have been modified by some hooks
1617 1831
 			
1618
-			if(!empty($hookmanager->resPrint)) return $hookmanager->resPrint;
1619
-			else return $reshook;
1620
-		}
1621
-		else
1832
+			if(!empty($hookmanager->resPrint)) {
1833
+				return $hookmanager->resPrint;
1834
+			} else {
1835
+				return $reshook;
1836
+			}
1837
+		} else
1622 1838
 		{
1623
-			if (empty($hidedetails) || $hidedetails > 1) return price($sign * $object->lines[$i]->total_ht, 0, $outputlangs);
1839
+			if (empty($hidedetails) || $hidedetails > 1) {
1840
+				return price($sign * $object->lines[$i]->total_ht, 0, $outputlangs);
1841
+			}
1624 1842
 		}
1625 1843
 	}
1626 1844
 	return '';
@@ -1642,23 +1860,28 @@  discard block
 block discarded – undo
1642 1860
 	if ($object->lines[$i]->special_code == 3)
1643 1861
 	{
1644 1862
 		return $outputlangs->transnoentities("Option");
1645
-	}
1646
-	else
1863
+	} else
1647 1864
 	{
1648 1865
 		if (is_object($hookmanager) && (($object->lines[$i]->product_type == 9 && ! empty($object->lines[$i]->special_code)) || ! empty($object->lines[$i]->fk_parent_line)))
1649 1866
 		{
1650 1867
 			$special_code = $object->lines[$i]->special_code;
1651
-			if (! empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line);
1868
+			if (! empty($object->lines[$i]->fk_parent_line)) {
1869
+				$special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line);
1870
+			}
1652 1871
 			$parameters = array('i'=>$i,'outputlangs'=>$outputlangs,'hidedetails'=>$hidedetails,'special_code'=>$special_code);
1653 1872
 			$action='';
1654 1873
 			$reshook = $hookmanager->executeHooks('pdf_getlinetotalwithtax',$parameters,$object,$action);    // Note that $action and $object may have been modified by some hooks
1655 1874
 			
1656
-			if(!empty($hookmanager->resPrint)) return $hookmanager->resPrint;
1657
-			else return $reshook;
1658
-		}
1659
-		else
1875
+			if(!empty($hookmanager->resPrint)) {
1876
+				return $hookmanager->resPrint;
1877
+			} else {
1878
+				return $reshook;
1879
+			}
1880
+		} else
1660 1881
 		{
1661
-			if (empty($hidedetails) || $hidedetails > 1) return price(($object->lines[$i]->total_ht) + ($object->lines[$i]->total_ht)*($object->lines[$i]->tva_tx)/100, 0, $outputlangs);
1882
+			if (empty($hidedetails) || $hidedetails > 1) {
1883
+				return price(($object->lines[$i]->total_ht) + ($object->lines[$i]->total_ht)*($object->lines[$i]->tva_tx)/100, 0, $outputlangs);
1884
+			}
1662 1885
 		}
1663 1886
 	}
1664 1887
 	return '';
@@ -1687,18 +1910,17 @@  discard block
 block discarded – undo
1687 1910
 			if ($type=='all')
1688 1911
 			{
1689 1912
 				$total += $object->lines[$i]->qty;
1690
-			}
1691
-			else if ($type==9 && is_object($hookmanager) && (($object->lines[$i]->product_type == 9 && ! empty($object->lines[$i]->special_code)) || ! empty($object->lines[$i]->fk_parent_line)))
1913
+			} else if ($type==9 && is_object($hookmanager) && (($object->lines[$i]->product_type == 9 && ! empty($object->lines[$i]->special_code)) || ! empty($object->lines[$i]->fk_parent_line)))
1692 1914
 			{
1693 1915
 				$special_code = $object->lines[$i]->special_code;
1694
-				if (! empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line);
1916
+				if (! empty($object->lines[$i]->fk_parent_line)) {
1917
+					$special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line);
1918
+				}
1695 1919
 				// TODO add hook function
1696
-			}
1697
-			else if ($type==0 && $object->lines[$i]->product_type == 0)
1920
+			} else if ($type==0 && $object->lines[$i]->product_type == 0)
1698 1921
 			{
1699 1922
 				$total += $object->lines[$i]->qty;
1700
-			}
1701
-			else if ($type==1 && $object->lines[$i]->product_type == 1)
1923
+			} else if ($type==1 && $object->lines[$i]->product_type == 1)
1702 1924
 			{
1703 1925
 				$total += $object->lines[$i]->qty;
1704 1926
 			}
@@ -1736,8 +1958,7 @@  discard block
 block discarded – undo
1736 1958
 				$linkedobjects[$objecttype]['date_title'] = $outputlangs->transnoentities("DatePropal");
1737 1959
 				$linkedobjects[$objecttype]['date_value'] = dol_print_date($elementobject->date,'day','',$outputlangs);
1738 1960
 			}
1739
-		}
1740
-		else if ($objecttype == 'commande')
1961
+		} else if ($objecttype == 'commande')
1741 1962
 		{
1742 1963
 			$outputlangs->load('orders');
1743 1964
 			foreach($objects as $elementobject)
@@ -1747,8 +1968,7 @@  discard block
 block discarded – undo
1747 1968
 				$linkedobjects[$objecttype]['date_title'] = $outputlangs->transnoentities("OrderDate");
1748 1969
 				$linkedobjects[$objecttype]['date_value'] = dol_print_date($elementobject->date,'day','',$outputlangs);
1749 1970
 			}
1750
-		}
1751
-		else if ($objecttype == 'contrat')
1971
+		} else if ($objecttype == 'contrat')
1752 1972
 		{
1753 1973
 			$outputlangs->load('contracts');
1754 1974
 			foreach($objects as $elementobject)
@@ -1758,8 +1978,7 @@  discard block
 block discarded – undo
1758 1978
 				$linkedobjects[$objecttype]['date_title'] = $outputlangs->transnoentities("DateContract");
1759 1979
 				$linkedobjects[$objecttype]['date_value'] = dol_print_date($elementobject->date_contrat,'day','',$outputlangs);
1760 1980
 			}
1761
-		}
1762
-		else if ($objecttype == 'shipping')
1981
+		} else if ($objecttype == 'shipping')
1763 1982
 		{
1764 1983
 			$outputlangs->load('orders');
1765 1984
 			$outputlangs->load('sendings');
@@ -1768,14 +1987,15 @@  discard block
 block discarded – undo
1768 1987
 				$elementobject->fetchObjectLinked();
1769 1988
 				$order = $elementobject->linkedObjects['commande'][0];
1770 1989
 
1771
-				if (! empty($object->linkedObjects['commande']))	// There is already a link to order so we show only info of shipment
1990
+				if (! empty($object->linkedObjects['commande'])) {
1991
+					// There is already a link to order so we show only info of shipment
1772 1992
 				{
1773 1993
 					$linkedobjects[$objecttype]['ref_title'] = $outputlangs->transnoentities("RefSending");
1994
+				}
1774 1995
 					$linkedobjects[$objecttype]['ref_value'].= $outputlangs->transnoentities($elementobject->ref);
1775 1996
 					$linkedobjects[$objecttype]['date_title'] = $outputlangs->transnoentities("DateSending");
1776 1997
 					$linkedobjects[$objecttype]['date_value'].= dol_print_date($elementobject->date_delivery,'day','',$outputlangs);
1777
-				}
1778
-				else	// We show both info of order and shipment
1998
+				} else	// We show both info of order and shipment
1779 1999
 				{
1780 2000
 					$linkedobjects[$objecttype]['ref_title'] = $outputlangs->transnoentities("RefOrder") . ' / ' . $outputlangs->transnoentities("RefSending");
1781 2001
 					$linkedobjects[$objecttype]['ref_value'] = $outputlangs->transnoentities($order->ref) . ($order->ref_client ? ' ('.$order->ref_client.')' : '');
@@ -1794,7 +2014,9 @@  discard block
 block discarded – undo
1794 2014
 		$parameters = array('linkedobjects' => $linkedobjects, 'outputlangs'=>$outputlangs);
1795 2015
 		$action='';
1796 2016
 		$hookmanager->executeHooks('pdf_getLinkedObjects',$parameters,$object,$action);    // Note that $action and $object may have been modified by some hooks
1797
-		if (! empty($hookmanager->resArray)) $linkedobjects = $hookmanager->resArray;
2017
+		if (! empty($hookmanager->resArray)) {
2018
+			$linkedobjects = $hookmanager->resArray;
2019
+		}
1798 2020
 	}
1799 2021
 
1800 2022
 	return $linkedobjects;
@@ -1818,12 +2040,13 @@  discard block
 block discarded – undo
1818 2040
 	if ($tmp['height'])
1819 2041
 	{
1820 2042
 		$width=(int) round($maxheight*$tmp['width']/$tmp['height']);	// I try to use maxheight
1821
-		if ($width > $maxwidth)	// Pb with maxheight, so i use maxwidth
2043
+		if ($width > $maxwidth) {
2044
+			// Pb with maxheight, so i use maxwidth
1822 2045
 		{
1823 2046
 			$width=$maxwidth;
1824
-			$height=(int) round($maxwidth*$tmp['height']/$tmp['width']);
1825 2047
 		}
1826
-		else	// No pb with maxheight
2048
+			$height=(int) round($maxwidth*$tmp['height']/$tmp['width']);
2049
+		} else	// No pb with maxheight
1827 2050
 		{
1828 2051
 			$height=$maxheight;
1829 2052
 		}
Please login to merge, or discard this patch.
lib/subtotal.lib.php 3 patches
Indentation   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -25,25 +25,25 @@
 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)
Please login to merge, or discard this patch.
Spacing   +19 added lines, -19 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
 
@@ -128,7 +128,7 @@  discard block
 block discarded – undo
128 128
 function _updateSubtotalLine(&$object, &$line)
129 129
 {
130 130
 	$label = GETPOST('line-title');
131
-	$description = ($line->qty>90) ? '' : GETPOST('line-description');
131
+	$description = ($line->qty > 90) ? '' : GETPOST('line-description');
132 132
 	$pagebreak = (int) GETPOST('line-pagebreak');
133 133
 
134 134
 	$level = GETPOST('subtotal_level', 'int');
@@ -145,7 +145,7 @@  discard block
 block discarded – undo
145 145
 
146 146
 function _updateSubtotalBloc($object, $line)
147 147
 {
148
-	global $conf,$langs;
148
+	global $conf, $langs;
149 149
 	
150 150
 	$subtotal_tva_tx = $subtotal_tva_tx_init = GETPOST('subtotal_tva_tx', 'int');
151 151
 	$subtotal_progress = $subtotal_progress_init = GETPOST('subtotal_progress', 'int');
@@ -221,9 +221,9 @@  discard block
 block discarded – undo
221 221
  * @param	$lineid			= title lineid
222 222
  * @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 
223 223
  */
224
-function _updateLineNC($element, $elementid, $lineid, $subtotal_nc=null)
224
+function _updateLineNC($element, $elementid, $lineid, $subtotal_nc = null)
225 225
 {
226
-	global $db,$langs,$tmp_object_nc;
226
+	global $db, $langs, $tmp_object_nc;
227 227
 	
228 228
 	$error = 0;
229 229
 	if (empty($element)) $error++;
@@ -248,7 +248,7 @@  discard block
 block discarded – undo
248 248
 	{
249 249
 		foreach ($object->lines as &$l)
250 250
 		{
251
-			if($l->id == $lineid) {
251
+			if ($l->id == $lineid) {
252 252
 				$line = $l;
253 253
 				break;
254 254
 			}
@@ -258,12 +258,12 @@  discard block
 block discarded – undo
258 258
 		{
259 259
 			$db->begin();
260 260
 			
261
-			if(TSubtotal::isModSubtotalLine($line))
261
+			if (TSubtotal::isModSubtotalLine($line))
262 262
 			{
263
-				if(TSubtotal::isTitle($line)) {
263
+				if (TSubtotal::isTitle($line)) {
264 264
 					// Update le contenu du titre (ainsi que le titre lui même)
265 265
 					$TTitleBlock = TSubtotal::getLinesFromTitleId($object, $lineid, true);
266
-					foreach($TTitleBlock as &$line_block)
266
+					foreach ($TTitleBlock as &$line_block)
267 267
 					{
268 268
 						$res = doUpdate($object, $line_block, $subtotal_nc);
269 269
 					}
@@ -295,7 +295,7 @@  discard block
 block discarded – undo
295 295
 {
296 296
 	if (TSubtotal::isFreeText($line) || TSubtotal::isSubtotal($line)) return 1;
297 297
 	// Update extrafield et total
298
-	if(! empty($subtotal_nc)) {
298
+	if (!empty($subtotal_nc)) {
299 299
 		$line->total_ht = $line->total_tva = $line->total_ttc = $line->total_localtax1 = $line->total_localtax2 = 
300 300
 			$line->multicurrency_total_ht = $line->multicurrency_total_tva = $line->multicurrency_total_ttc = 0;
301 301
 
Please login to merge, or discard this patch.
Braces   +51 added lines, -25 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)
@@ -134,8 +138,13 @@  discard block
 block discarded – undo
134 138
 	$level = GETPOST('subtotal_level', 'int');
135 139
 	if (!empty($level))
136 140
 	{
137
-		if ($line->qty > 90) $line->qty = 100 - $level; // Si on edit une ligne sous-total
138
-		else $line->qty = $level;
141
+		if ($line->qty > 90) {
142
+			$line->qty = 100 - $level;
143
+		}
144
+		// Si on edit une ligne sous-total
145
+		else {
146
+			$line->qty = $level;
147
+		}
139 148
 	}
140 149
 	
141 150
 	$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);
@@ -162,13 +171,18 @@  discard block
 block discarded – undo
162 171
 			{
163 172
 				$subtotal_tva_tx = $subtotal_tva_tx_init; // ré-init car la variable peut évoluer
164 173
 					
165
-				if (!empty($showBlockExtrafields)) $line->array_options = $array_options;
166
-				if ($subtotal_tva_tx == '') $subtotal_tva_tx = $line->tva_tx;
174
+				if (!empty($showBlockExtrafields)) {
175
+					$line->array_options = $array_options;
176
+				}
177
+				if ($subtotal_tva_tx == '') {
178
+					$subtotal_tva_tx = $line->tva_tx;
179
+				}
167 180
 				if ($object->element == 'facture' && !empty($conf->global->INVOICE_USE_SITUATION) && $object->type == Facture::TYPE_SITUATION)
168 181
 				{
169 182
 					$subtotal_progress = $subtotal_progress_init;
170
-					if ($subtotal_progress == '') $subtotal_progress = $line->situation_percent;
171
-					else
183
+					if ($subtotal_progress == '') {
184
+						$subtotal_progress = $line->situation_percent;
185
+					} else
172 186
 					{
173 187
 						$prev_percent = $line->get_prev_progress($object->id);
174 188
 						if ($subtotal_progress < $prev_percent)
@@ -181,14 +195,21 @@  discard block
 block discarded – undo
181 195
 				
182 196
 				$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);
183 197
 
184
-				if ($res > 0) $success_updated_line++;
185
-				else $error_updated_line++;
198
+				if ($res > 0) {
199
+					$success_updated_line++;
200
+				} else {
201
+					$error_updated_line++;
202
+				}
186 203
 			}
187 204
 		}
188 205
 
189
-		if ($nb_progress_not_updated > 0) setEventMessage($langs->trans('subtotal_nb_progress_not_updated', $nb_progress_not_updated), 'warnings');
206
+		if ($nb_progress_not_updated > 0) {
207
+			setEventMessage($langs->trans('subtotal_nb_progress_not_updated', $nb_progress_not_updated), 'warnings');
208
+		}
190 209
 		
191
-		if ($success_updated_line > 0) setEventMessage($langs->trans('subtotal_success_updated_line', $success_updated_line));
210
+		if ($success_updated_line > 0) {
211
+			setEventMessage($langs->trans('subtotal_success_updated_line', $success_updated_line));
212
+		}
192 213
 		if ($error_updated_line > 0)
193 214
 		{
194 215
 			setEventMessage($langs->trans('subtotal_error_updated_line', $error_updated_line), 'errors');
@@ -226,21 +247,25 @@  discard block
 block discarded – undo
226 247
 	global $db,$langs,$tmp_object_nc;
227 248
 	
228 249
 	$error = 0;
229
-	if (empty($element)) $error++;
250
+	if (empty($element)) {
251
+		$error++;
252
+	}
230 253
 	
231 254
 	if (!$error)
232 255
 	{
233 256
 		if (!empty($tmp_object_nc) && $tmp_object_nc->element == $element && $tmp_object_nc->id == $elementid)
234 257
 		{
235 258
 			$object = $tmp_object_nc;
236
-		}
237
-		else
259
+		} else
238 260
 		{
239 261
 			$classname = ucfirst($element);
240 262
 			$object = new $classname($db); // Propal | Commande | Facture
241 263
 			$res = $object->fetch($elementid);
242
-			if ($res < 0) $error++;
243
-			else $tmp_object_nc = $object;
264
+			if ($res < 0) {
265
+				$error++;
266
+			} else {
267
+				$tmp_object_nc = $object;
268
+			}
244 269
 		}
245 270
 	}
246 271
 	
@@ -268,21 +293,21 @@  discard block
 block discarded – undo
268 293
 						$res = doUpdate($object, $line_block, $subtotal_nc);
269 294
 					}
270 295
 				}
271
-			}
272
-			else
296
+			} else
273 297
 			{
274 298
 				$res = doUpdate($object, $line, $subtotal_nc);
275 299
 			}
276 300
 			
277 301
 			$res = $object->update_price(1);
278
-			if ($res <= 0) $error++;
302
+			if ($res <= 0) {
303
+				$error++;
304
+			}
279 305
 			
280 306
 			if (!$error)
281 307
 			{
282 308
 				setEventMessage($langs->trans('subtotal_update_nc_success'));
283 309
 				$db->commit();
284
-			}
285
-			else
310
+			} else
286 311
 			{
287 312
 				setEventMessage($langs->trans('subtotal_update_nc_error'), 'errors');
288 313
 				$db->rollback();
@@ -293,7 +318,9 @@  discard block
 block discarded – undo
293 318
 
294 319
 function doUpdate(&$object, &$line, $subtotal_nc)
295 320
 {
296
-	if (TSubtotal::isFreeText($line) || TSubtotal::isSubtotal($line)) return 1;
321
+	if (TSubtotal::isFreeText($line) || TSubtotal::isSubtotal($line)) {
322
+		return 1;
323
+	}
297 324
 	// Update extrafield et total
298 325
 	if(! empty($subtotal_nc)) {
299 326
 		$line->total_ht = $line->total_tva = $line->total_ttc = $line->total_localtax1 = $line->total_localtax2 = 
@@ -302,8 +329,7 @@  discard block
 block discarded – undo
302 329
 		$line->array_options['options_subtotal_nc'] = 1;
303 330
 
304 331
 		$res = $line->update();
305
-	}
306
-	else {
332
+	} else {
307 333
 		$line->array_options['options_subtotal_nc'] = 0;
308 334
 		$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);
309 335
 	}
Please login to merge, or discard this patch.