Passed
Push — master ( 49af33...3cffbe )
by Alxarafe
21:21
created
dolibarr/htdocs/core/actions_massactions.inc.php 1 patch
Braces   +372 added lines, -189 removed lines patch added patch discarded remove patch
@@ -54,10 +54,12 @@  discard block
 block discarded – undo
54 54
 	$error++;
55 55
 }
56 56
 
57
-if (! $error && $massaction == 'confirm_presend' && ! GETPOST('sendmail'))  // If we do not choose button send (for example when we change template or limit), we must not send email, but keep on send email form
57
+if (! $error && $massaction == 'confirm_presend' && ! GETPOST('sendmail')) {
58
+    // If we do not choose button send (for example when we change template or limit), we must not send email, but keep on send email form
58 59
 {
59 60
 	$massaction='presend';
60 61
 }
62
+}
61 63
 if (! $error && $massaction == 'confirm_presend')
62 64
 {
63 65
 	$resaction = '';
@@ -73,8 +75,12 @@  discard block
 block discarded – undo
73 75
 	if (! $error)
74 76
 	{
75 77
 		$thirdparty=new Societe($db);
76
-		if ($objecttmp->element == 'expensereport') $thirdparty=new User($db);
77
-		if ($objecttmp->element == 'holiday')       $thirdparty=new User($db);
78
+		if ($objecttmp->element == 'expensereport') {
79
+		    $thirdparty=new User($db);
80
+		}
81
+		if ($objecttmp->element == 'holiday') {
82
+		    $thirdparty=new User($db);
83
+		}
78 84
 
79 85
 		$objecttmp=new $objectclass($db);
80 86
 		foreach($toselect as $toselectid)
@@ -85,9 +91,15 @@  discard block
 block discarded – undo
85 91
 			{
86 92
 				$listofobjectid[$toselectid]=$toselectid;
87 93
 				$thirdpartyid=($objecttmp->fk_soc?$objecttmp->fk_soc:$objecttmp->socid);
88
-				if ($objecttmp->element == 'societe')       $thirdpartyid=$objecttmp->id;
89
-				if ($objecttmp->element == 'expensereport') $thirdpartyid=$objecttmp->fk_user_author;
90
-				if ($objecttmp->element == 'holiday')       $thirdpartyid=$objecttmp->fk_user;
94
+				if ($objecttmp->element == 'societe') {
95
+				    $thirdpartyid=$objecttmp->id;
96
+				}
97
+				if ($objecttmp->element == 'expensereport') {
98
+				    $thirdpartyid=$objecttmp->fk_user_author;
99
+				}
100
+				if ($objecttmp->element == 'holiday') {
101
+				    $thirdpartyid=$objecttmp->fk_user;
102
+				}
91 103
 				$listofobjectthirdparties[$thirdpartyid]=$thirdpartyid;
92 104
 				$listofobjectref[$thirdpartyid][$toselectid]=$objecttmp;
93 105
 			}
@@ -105,12 +117,17 @@  discard block
 block discarded – undo
105 117
 	$receiver=$_POST['receiver'];
106 118
 	if (! is_array($receiver))
107 119
 	{
108
-		if (empty($receiver) || $receiver == '-1') $receiver=array();
109
-		else $receiver=array($receiver);
120
+		if (empty($receiver) || $receiver == '-1') {
121
+		    $receiver=array();
122
+		} else {
123
+		    $receiver=array($receiver);
124
+		}
110 125
 	}
111
-	if (! trim($_POST['sendto']) && count($receiver) == 0 && count($listofobjectthirdparties) == 1)	// if only one recipient, receiver is mandatory
126
+	if (! trim($_POST['sendto']) && count($receiver) == 0 && count($listofobjectthirdparties) == 1) {
127
+	    // if only one recipient, receiver is mandatory
112 128
 	{
113 129
 	 	$error++;
130
+	}
114 131
 	   	setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Recipient")), null, 'warnings');
115 132
 	   	$massaction='presend';
116 133
 	}
@@ -151,13 +168,16 @@  discard block
 block discarded – undo
151 168
 				foreach($receiver as $key=>$val)
152 169
 				{
153 170
 					// Recipient was provided from combo list
154
-					if ($val == 'thirdparty') // Id of third party or user
171
+					if ($val == 'thirdparty') {
172
+					    // Id of third party or user
155 173
 					{
156 174
 						$tmparray[] = $thirdparty->name.' <'.$thirdparty->email.'>';
157 175
 					}
158
-					elseif ($val && method_exists($thirdparty, 'contact_get_property'))		// Id of contact
176
+					} elseif ($val && method_exists($thirdparty, 'contact_get_property')) {
177
+					    // Id of contact
159 178
 					{
160 179
 						$tmparray[] = $thirdparty->contact_get_property((int) $val,'email');
180
+					}
161 181
 						$sendtoid[] = $val;
162 182
 					}
163 183
 				}
@@ -168,8 +188,11 @@  discard block
 block discarded – undo
168 188
 			$receivercc=$_POST['receivercc'];
169 189
 			if (! is_array($receivercc))
170 190
 			{
171
-				if ($receivercc == '-1') $receivercc=array();
172
-				else $receivercc=array($receivercc);
191
+				if ($receivercc == '-1') {
192
+				    $receivercc=array();
193
+				} else {
194
+				    $receivercc=array($receivercc);
195
+				}
173 196
 			}
174 197
 			$tmparray=array();
175 198
 			if (trim($_POST['sendtocc']))
@@ -181,13 +204,16 @@  discard block
 block discarded – undo
181 204
 				foreach($receivercc as $key=>$val)
182 205
 				{
183 206
 					// Recipient was provided from combo list
184
-					if ($val == 'thirdparty') // Id of third party
207
+					if ($val == 'thirdparty') {
208
+					    // Id of third party
185 209
 					{
186 210
 						$tmparray[] = $thirdparty->name.' <'.$thirdparty->email.'>';
187 211
 					}
188
-					elseif ($val)	// Id du contact
212
+					} elseif ($val) {
213
+					    // Id du contact
189 214
 					{
190 215
 						$tmparray[] = $thirdparty->contact_get_property((int) $val,'email');
216
+					}
191 217
 						//$sendtoid[] = $val;  TODO Add also id of contact in CC ?
192 218
 					}
193 219
 				}
@@ -226,15 +252,16 @@  discard block
 block discarded – undo
226 252
 				}
227 253
 
228 254
 				// Test recipient
229
-				if (empty($sendto)) 	// For the case, no recipient were set (multi thirdparties send)
255
+				if (empty($sendto)) {
256
+				    // For the case, no recipient were set (multi thirdparties send)
230 257
 				{
231 258
 					if ($objectobj->element == 'expensereport')
232 259
 					{
233 260
 						$fuser = new User($db);
261
+				}
234 262
 						$fuser->fetch($objectobj->fk_user_author);
235 263
 						$sendto = $fuser->email;
236
-					}
237
-					else
264
+					} else
238 265
 					{
239 266
 						$objectobj->fetch_thirdparty();
240 267
 						$sendto = $objectobj->thirdparty->email;
@@ -271,8 +298,7 @@  discard block
 block discarded – undo
271 298
 							'names'=>array_merge($attachedfiles['names'],array($filename)),
272 299
 							'mimes'=>array_merge($attachedfiles['mimes'],array($mime))
273 300
 							);
274
-					}
275
-					else
301
+					} else
276 302
 					{
277 303
 							$nbignored++;
278 304
 							$langs->load("errors");
@@ -298,19 +324,15 @@  discard block
 block discarded – undo
298 324
 				$fromtype = GETPOST('fromtype');
299 325
 				if ($fromtype === 'user') {
300 326
 					$from = $user->getFullName($langs) .' <'.$user->email.'>';
301
-				}
302
-				elseif ($fromtype === 'company') {
327
+				} elseif ($fromtype === 'company') {
303 328
 					$from = $conf->global->MAIN_INFO_SOCIETE_NOM .' <'.$conf->global->MAIN_INFO_SOCIETE_MAIL.'>';
304
-				}
305
-				elseif (preg_match('/user_aliases_(\d+)/', $fromtype, $reg)) {
329
+				} elseif (preg_match('/user_aliases_(\d+)/', $fromtype, $reg)) {
306 330
 					$tmp=explode(',', $user->email_aliases);
307 331
 					$from = trim($tmp[($reg[1] - 1)]);
308
-				}
309
-				elseif (preg_match('/global_aliases_(\d+)/', $fromtype, $reg)) {
332
+				} elseif (preg_match('/global_aliases_(\d+)/', $fromtype, $reg)) {
310 333
 					$tmp=explode(',', $conf->global->MAIN_INFO_SOCIETE_MAIL_ALIASES);
311 334
 					$from = trim($tmp[($reg[1] - 1)]);
312
-				}
313
-				elseif (preg_match('/senderprofile_(\d+)_(\d+)/', $fromtype, $reg)) {
335
+				} elseif (preg_match('/senderprofile_(\d+)_(\d+)/', $fromtype, $reg)) {
314 336
 					$sql='SELECT rowid, label, email FROM '.MAIN_DB_PREFIX.'c_email_senderprofile WHERE rowid = '.(int) $reg[1];
315 337
 					$resql = $db->query($sql);
316 338
 					$obj = $db->fetch_object($resql);
@@ -318,8 +340,7 @@  discard block
 block discarded – undo
318 340
 					{
319 341
 						$from = $obj->label.' <'.$obj->email.'>';
320 342
 					}
321
-				}
322
-				else {
343
+				} else {
323 344
 					$from = $_POST['fromname'] . ' <' . $_POST['frommail'] .'>';
324 345
 				}
325 346
 
@@ -328,12 +349,24 @@  discard block
 block discarded – undo
328 349
 				$message = GETPOST('message','none');
329 350
 
330 351
 				$sendtobcc = GETPOST('sendtoccc');
331
-				if ($objectclass == 'Propal') 				$sendtobcc .= (empty($conf->global->MAIN_MAIL_AUTOCOPY_PROPOSAL_TO) ? '' : (($sendtobcc?", ":"").$conf->global->MAIN_MAIL_AUTOCOPY_PROPOSAL_TO));
332
-				if ($objectclass == 'Commande') 			$sendtobcc .= (empty($conf->global->MAIN_MAIL_AUTOCOPY_ORDER_TO) ? '' : (($sendtobcc?", ":"").$conf->global->MAIN_MAIL_AUTOCOPY_ORDER_TO));
333
-				if ($objectclass == 'Facture') 				$sendtobcc .= (empty($conf->global->MAIN_MAIL_AUTOCOPY_INVOICE_TO) ? '' : (($sendtobcc?", ":"").$conf->global->MAIN_MAIL_AUTOCOPY_INVOICE_TO));
334
-				if ($objectclass == 'Supplier_Proposal') 	$sendtobcc .= (empty($conf->global->MAIN_MAIL_AUTOCOPY_SUPPLIER_PROPOSAL_TO) ? '' : (($sendtobcc?", ":"").$conf->global->MAIN_MAIL_AUTOCOPY_SUPPLIER_PROPOSAL_TO));
335
-				if ($objectclass == 'CommandeFournisseur')	$sendtobcc .= (empty($conf->global->MAIN_MAIL_AUTOCOPY_SUPPLIER_ORDER_TO) ? '' : (($sendtobcc?", ":"").$conf->global->MAIN_MAIL_AUTOCOPY_SUPPLIER_ORDER_TO));
336
-				if ($objectclass == 'FactureFournisseur')	$sendtobcc .= (empty($conf->global->MAIN_MAIL_AUTOCOPY_SUPPLIER_INVOICE_TO) ? '' : (($sendtobcc?", ":"").$conf->global->MAIN_MAIL_AUTOCOPY_SUPPLIER_INVOICE_TO));
352
+				if ($objectclass == 'Propal') {
353
+				    $sendtobcc .= (empty($conf->global->MAIN_MAIL_AUTOCOPY_PROPOSAL_TO) ? '' : (($sendtobcc?", ":"").$conf->global->MAIN_MAIL_AUTOCOPY_PROPOSAL_TO));
354
+				}
355
+				if ($objectclass == 'Commande') {
356
+				    $sendtobcc .= (empty($conf->global->MAIN_MAIL_AUTOCOPY_ORDER_TO) ? '' : (($sendtobcc?", ":"").$conf->global->MAIN_MAIL_AUTOCOPY_ORDER_TO));
357
+				}
358
+				if ($objectclass == 'Facture') {
359
+				    $sendtobcc .= (empty($conf->global->MAIN_MAIL_AUTOCOPY_INVOICE_TO) ? '' : (($sendtobcc?", ":"").$conf->global->MAIN_MAIL_AUTOCOPY_INVOICE_TO));
360
+				}
361
+				if ($objectclass == 'Supplier_Proposal') {
362
+				    $sendtobcc .= (empty($conf->global->MAIN_MAIL_AUTOCOPY_SUPPLIER_PROPOSAL_TO) ? '' : (($sendtobcc?", ":"").$conf->global->MAIN_MAIL_AUTOCOPY_SUPPLIER_PROPOSAL_TO));
363
+				}
364
+				if ($objectclass == 'CommandeFournisseur') {
365
+				    $sendtobcc .= (empty($conf->global->MAIN_MAIL_AUTOCOPY_SUPPLIER_ORDER_TO) ? '' : (($sendtobcc?", ":"").$conf->global->MAIN_MAIL_AUTOCOPY_SUPPLIER_ORDER_TO));
366
+				}
367
+				if ($objectclass == 'FactureFournisseur') {
368
+				    $sendtobcc .= (empty($conf->global->MAIN_MAIL_AUTOCOPY_SUPPLIER_INVOICE_TO) ? '' : (($sendtobcc?", ":"").$conf->global->MAIN_MAIL_AUTOCOPY_SUPPLIER_INVOICE_TO));
369
+				}
337 370
 
338 371
 				// $listofqualifiedobj is array with key = object id and value is instance of qualified objects, for the current thirdparty (but thirdparty property is not loaded yet)
339 372
 				$oneemailperrecipient=(GETPOST('oneemailperrecipient')=='on'?1:0);
@@ -345,8 +378,7 @@  discard block
 block discarded – undo
345 378
 					{
346 379
 						$looparray[$key]->thirdparty = $thirdparty;
347 380
 					}
348
-				}
349
-				else
381
+				} else
350 382
 				{
351 383
 					$objectforloop=new $objectclass($db);
352 384
 					$objectforloop->thirdparty = $thirdparty;
@@ -354,10 +386,12 @@  discard block
 block discarded – undo
354 386
 				}
355 387
 				//var_dump($looparray);exit;
356 388
 
357
-				foreach ($looparray as $objecttmp)		// $objecttmp is a real object or an empty object if we choose to send one email per thirdparty instead of one per record
389
+				foreach ($looparray as $objecttmp) {
390
+				    // $objecttmp is a real object or an empty object if we choose to send one email per thirdparty instead of one per record
358 391
 				{
359 392
 					// Make substitution in email content
360 393
 					$substitutionarray=getCommonSubstitutionArray($langs, 0, null, $objecttmp);
394
+				}
361 395
 					$substitutionarray['__ID__']    = ($oneemailperrecipient ? join(', ',array_keys($listofqualifiedobj)) : $objecttmp->id);
362 396
 					$substitutionarray['__REF__']   = ($oneemailperrecipient ? join(', ',$listofqualifiedref) : $objecttmp->ref);
363 397
 					$substitutionarray['__EMAIL__'] = $thirdparty->email;
@@ -385,19 +419,36 @@  discard block
 block discarded – undo
385 419
 					if ($oneemailperrecipient)
386 420
 					{
387 421
 						$trackid='thi'.$thirdparty->id;
388
-						if ($objecttmp->element == 'expensereport') $trackid='use'.$thirdparty->id;
389
-						if ($objecttmp->element == 'holiday') $trackid='use'.$thirdparty->id;
390
-					}
391
-					else
422
+						if ($objecttmp->element == 'expensereport') {
423
+						    $trackid='use'.$thirdparty->id;
424
+						}
425
+						if ($objecttmp->element == 'holiday') {
426
+						    $trackid='use'.$thirdparty->id;
427
+						}
428
+					} else
392 429
 					{
393 430
 						$trackid=strtolower(get_class($objecttmp));
394
-						if (get_class($objecttmp)=='Contrat')  $trackid='con';
395
-						if (get_class($objecttmp)=='Propal')   $trackid='pro';
396
-						if (get_class($objecttmp)=='Commande') $trackid='ord';
397
-						if (get_class($objecttmp)=='Facture')  $trackid='inv';
398
-						if (get_class($objecttmp)=='Supplier_Proposal')   $trackid='spr';
399
-						if (get_class($objecttmp)=='CommandeFournisseur') $trackid='sor';
400
-						if (get_class($objecttmp)=='FactureFournisseur')  $trackid='sin';
431
+						if (get_class($objecttmp)=='Contrat') {
432
+						    $trackid='con';
433
+						}
434
+						if (get_class($objecttmp)=='Propal') {
435
+						    $trackid='pro';
436
+						}
437
+						if (get_class($objecttmp)=='Commande') {
438
+						    $trackid='ord';
439
+						}
440
+						if (get_class($objecttmp)=='Facture') {
441
+						    $trackid='inv';
442
+						}
443
+						if (get_class($objecttmp)=='Supplier_Proposal') {
444
+						    $trackid='spr';
445
+						}
446
+						if (get_class($objecttmp)=='CommandeFournisseur') {
447
+						    $trackid='sor';
448
+						}
449
+						if (get_class($objecttmp)=='FactureFournisseur') {
450
+						    $trackid='sin';
451
+						}
401 452
 
402 453
 						$trackid.=$objecttmp->id;
403 454
 					}
@@ -410,8 +461,7 @@  discard block
 block discarded – undo
410 461
 					if ($mailfile->error)
411 462
 					{
412 463
 						$resaction.='<div class="error">'.$mailfile->error.'</div>';
413
-					}
414
-					else
464
+					} else
415 465
 					{
416 466
 						$result=$mailfile->sendfile();
417 467
 						if ($result)
@@ -433,7 +483,9 @@  discard block
 block discarded – undo
433 483
 								$actionmsg=$langs->transnoentities('MailSentBy').' '.$from.' '.$langs->transnoentities('To').' '.$sendto;
434 484
 								if ($message)
435 485
 								{
436
-									if ($sendtocc) $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('Bcc') . ": " . $sendtocc);
486
+									if ($sendtocc) {
487
+									    $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('Bcc') . ": " . $sendtocc);
488
+									}
437 489
 									$actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('MailTopic') . ": " . $subject);
438 490
 									$actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('TextUsedInTheMessageBody') . ":");
439 491
 									$actionmsg = dol_concatdesc($actionmsg, $message);
@@ -448,14 +500,30 @@  discard block
 block discarded – undo
448 500
 								$objectobj->elementtype	= $objectobj->element;
449 501
 
450 502
 								$triggername = strtoupper(get_class($objectobj)) .'_SENTBYMAIL';
451
-								if ($triggername == 'SOCIETE_SENTBYMAIL')    $triggername = 'COMPANY_SENTBYEMAIL';
452
-								if ($triggername == 'CONTRAT_SENTBYMAIL')    $triggername = 'CONTRACT_SENTBYEMAIL';
453
-								if ($triggername == 'COMMANDE_SENTBYMAIL')   $triggername = 'ORDER_SENTBYEMAIL';
454
-								if ($triggername == 'FACTURE_SENTBYMAIL')    $triggername = 'BILL_SENTBYMAIL';
455
-								if ($triggername == 'EXPEDITION_SENTBYMAIL') $triggername = 'SHIPPING_SENTBYEMAIL';
456
-								if ($triggername == 'COMMANDEFOURNISSEUR_SENTBYMAIL') $triggername = 'ORDER_SUPPLIER_SENTBYMAIL';
457
-								if ($triggername == 'FACTUREFOURNISSEUR_SENTBYMAIL') $triggername = 'BILL_SUPPLIER_SENTBYEMAIL';
458
-								if ($triggername == 'SUPPLIERPROPOSAL_SENTBYMAIL') $triggername = 'PROPOSAL_SUPPLIER_SENTBYEMAIL';
503
+								if ($triggername == 'SOCIETE_SENTBYMAIL') {
504
+								    $triggername = 'COMPANY_SENTBYEMAIL';
505
+								}
506
+								if ($triggername == 'CONTRAT_SENTBYMAIL') {
507
+								    $triggername = 'CONTRACT_SENTBYEMAIL';
508
+								}
509
+								if ($triggername == 'COMMANDE_SENTBYMAIL') {
510
+								    $triggername = 'ORDER_SENTBYEMAIL';
511
+								}
512
+								if ($triggername == 'FACTURE_SENTBYMAIL') {
513
+								    $triggername = 'BILL_SENTBYMAIL';
514
+								}
515
+								if ($triggername == 'EXPEDITION_SENTBYMAIL') {
516
+								    $triggername = 'SHIPPING_SENTBYEMAIL';
517
+								}
518
+								if ($triggername == 'COMMANDEFOURNISSEUR_SENTBYMAIL') {
519
+								    $triggername = 'ORDER_SUPPLIER_SENTBYMAIL';
520
+								}
521
+								if ($triggername == 'FACTUREFOURNISSEUR_SENTBYMAIL') {
522
+								    $triggername = 'BILL_SUPPLIER_SENTBYEMAIL';
523
+								}
524
+								if ($triggername == 'SUPPLIERPROPOSAL_SENTBYMAIL') {
525
+								    $triggername = 'PROPOSAL_SUPPLIER_SENTBYEMAIL';
526
+								}
459 527
 
460 528
 								if (! empty($triggername))
461 529
 								{
@@ -475,16 +543,14 @@  discard block
 block discarded – undo
475 543
 
476 544
 								$nbsent++;
477 545
 							}
478
-						}
479
-						else
546
+						} else
480 547
 						{
481 548
 							$langs->load("other");
482 549
 							if ($mailfile->error)
483 550
 							{
484 551
 								$resaction.=$langs->trans('ErrorFailedToSendMail',$from,$sendto);
485 552
 								$resaction.='<br><div class="error">'.$mailfile->error.'</div>';
486
-							}
487
-							else
553
+							} else
488 554
 							{
489 555
 								$resaction.='<div class="warning">No mail sent. Feature is disabled by option MAIN_DISABLE_ALL_MAILS</div>';
490 556
 							}
@@ -506,8 +572,7 @@  discard block
 block discarded – undo
506 572
 			//setEventMessages($langs->trans("EMailSentToNRecipients", $nbsent.'/'.count($toselect)), null, 'mesgs');
507 573
 			setEventMessages($langs->trans("EMailSentForNElements", $nbsent.'/'.count($toselect)), null, 'mesgs');
508 574
 			setEventMessages($resaction, null, 'mesgs');
509
-		}
510
-		else
575
+		} else
511 576
 		{
512 577
 			//setEventMessages($langs->trans("EMailSentToNRecipients", 0), null, 'warnings');  // May be object has no generated PDF file
513 578
 			setEventMessages($resaction, null, 'warnings');
@@ -534,10 +599,15 @@  discard block
 block discarded – undo
534 599
 	foreach($orders as $id_order)
535 600
 	{
536 601
 		$cmd = new Commande($db);
537
-		if ($cmd->fetch($id_order) <= 0) continue;
602
+		if ($cmd->fetch($id_order) <= 0) {
603
+		    continue;
604
+		}
538 605
 
539 606
 		$objecttmp = new Facture($db);
540
-		if (!empty($createbills_onebythird) && !empty($TFactThird[$cmd->socid])) $objecttmp = $TFactThird[$cmd->socid]; // If option "one bill per third" is set, we use already created order.
607
+		if (!empty($createbills_onebythird) && !empty($TFactThird[$cmd->socid])) {
608
+		    $objecttmp = $TFactThird[$cmd->socid];
609
+		}
610
+		// If option "one bill per third" is set, we use already created order.
541 611
 		else {
542 612
 
543 613
 			$objecttmp->socid = $cmd->socid;
@@ -558,7 +628,9 @@  discard block
 block discarded – undo
558 628
 
559 629
 			$res = $objecttmp->create($user);
560 630
 
561
-			if($res > 0) $nb_bills_created++;
631
+			if($res > 0) {
632
+			    $nb_bills_created++;
633
+			}
562 634
 		}
563 635
 
564 636
 		if ($objecttmp->id > 0)
@@ -611,28 +683,38 @@  discard block
 block discarded – undo
611 683
 						{
612 684
 							$result=$objecttmp->insert_discount($discountid);
613 685
 							//$result=$discount->link_to_invoice($lineid,$id);
614
-						}
615
-						else
686
+						} else
616 687
 						{
617 688
 							setEventMessages($discount->error, $discount->errors, 'errors');
618 689
 							$error++;
619 690
 							break;
620 691
 						}
621
-					}
622
-					else
692
+					} else
623 693
 					{
624 694
 						// Positive line
625 695
 						$product_type=($lines[$i]->product_type?$lines[$i]->product_type:0);
626 696
 						// Date start
627 697
 						$date_start=false;
628
-						if ($lines[$i]->date_debut_prevue) $date_start=$lines[$i]->date_debut_prevue;
629
-						if ($lines[$i]->date_debut_reel) $date_start=$lines[$i]->date_debut_reel;
630
-						if ($lines[$i]->date_start) $date_start=$lines[$i]->date_start;
698
+						if ($lines[$i]->date_debut_prevue) {
699
+						    $date_start=$lines[$i]->date_debut_prevue;
700
+						}
701
+						if ($lines[$i]->date_debut_reel) {
702
+						    $date_start=$lines[$i]->date_debut_reel;
703
+						}
704
+						if ($lines[$i]->date_start) {
705
+						    $date_start=$lines[$i]->date_start;
706
+						}
631 707
 						//Date end
632 708
 						$date_end=false;
633
-						if ($lines[$i]->date_fin_prevue) $date_end=$lines[$i]->date_fin_prevue;
634
-						if ($lines[$i]->date_fin_reel) $date_end=$lines[$i]->date_fin_reel;
635
-						if ($lines[$i]->date_end) $date_end=$lines[$i]->date_end;
709
+						if ($lines[$i]->date_fin_prevue) {
710
+						    $date_end=$lines[$i]->date_fin_prevue;
711
+						}
712
+						if ($lines[$i]->date_fin_reel) {
713
+						    $date_end=$lines[$i]->date_fin_reel;
714
+						}
715
+						if ($lines[$i]->date_end) {
716
+						    $date_end=$lines[$i]->date_end;
717
+						}
636 718
 						// Reset fk_parent_line for no child products and special product
637 719
 						if (($lines[$i]->product_type != 9 && empty($lines[$i]->fk_parent_line)) || $lines[$i]->product_type == 9)
638 720
 						{
@@ -675,8 +757,7 @@  discard block
 block discarded – undo
675 757
 						if ($result > 0)
676 758
 						{
677 759
 							$lineid=$result;
678
-						}
679
-						else
760
+						} else
680 761
 						{
681 762
 							$lineid=0;
682 763
 							$error++;
@@ -694,8 +775,11 @@  discard block
 block discarded – undo
694 775
 
695 776
 		//$cmd->classifyBilled($user);        // Disabled. This behavior must be set or not using the workflow module.
696 777
 
697
-		if(!empty($createbills_onebythird) && empty($TFactThird[$cmd->socid])) $TFactThird[$cmd->socid] = $objecttmp;
698
-		else $TFact[$objecttmp->id] = $objecttmp;
778
+		if(!empty($createbills_onebythird) && empty($TFactThird[$cmd->socid])) {
779
+		    $TFactThird[$cmd->socid] = $objecttmp;
780
+		} else {
781
+		    $TFact[$objecttmp->id] = $objecttmp;
782
+		}
699 783
 	}
700 784
 
701 785
 	// Build doc with all invoices
@@ -734,34 +818,79 @@  discard block
 block discarded – undo
734 818
 
735 819
 		// Make a redirect to avoid to bill twice if we make a refresh or back
736 820
 		$param='';
737
-		if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.urlencode($contextpage);
738
-		if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.urlencode($limit);
739
-		if ($sall)					$param.='&sall='.urlencode($sall);
740
-		if ($socid > 0)             $param.='&socid='.urlencode($socid);
741
-		if ($viewstatut != '')      $param.='&viewstatut='.urlencode($viewstatut);
742
-		if ($search_orderday)      		$param.='&search_orderday='.urlencode($search_orderday);
743
-		if ($search_ordermonth)      		$param.='&search_ordermonth='.urlencode($search_ordermonth);
744
-		if ($search_orderyear)       		$param.='&search_orderyear='.urlencode($search_orderyear);
745
-		if ($search_deliveryday)   		$param.='&search_deliveryday='.urlencode($search_deliveryday);
746
-		if ($search_deliverymonth)   		$param.='&search_deliverymonth='.urlencode($search_deliverymonth);
747
-		if ($search_deliveryyear)    		$param.='&search_deliveryyear='.urlencode($search_deliveryyear);
748
-		if ($search_ref)      		$param.='&search_ref='.urlencode($search_ref);
749
-		if ($search_company)  		$param.='&search_company='.urlencode($search_company);
750
-		if ($search_ref_customer)	$param.='&search_ref_customer='.urlencode($search_ref_customer);
751
-		if ($search_user > 0) 		$param.='&search_user='.urlencode($search_user);
752
-		if ($search_sale > 0) 		$param.='&search_sale='.urlencode($search_sale);
753
-		if ($search_total_ht != '') $param.='&search_total_ht='.urlencode($search_total_ht);
754
-		if ($search_total_vat != '') $param.='&search_total_vat='.urlencode($search_total_vat);
755
-		if ($search_total_ttc != '') $param.='&search_total_ttc='.urlencode($search_total_ttc);
756
-		if ($search_project_ref >= 0)  	$param.="&search_project_ref=".urlencode($search_project_ref);
757
-		if ($show_files)            $param.='&show_files=' .urlencode($show_files);
758
-		if ($optioncss != '')       $param.='&optioncss='.urlencode($optioncss);
759
-		if ($billed != '')			$param.='&billed='.urlencode($billed);
821
+		if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
822
+		    $param.='&contextpage='.urlencode($contextpage);
823
+		}
824
+		if ($limit > 0 && $limit != $conf->liste_limit) {
825
+		    $param.='&limit='.urlencode($limit);
826
+		}
827
+		if ($sall) {
828
+		    $param.='&sall='.urlencode($sall);
829
+		}
830
+		if ($socid > 0) {
831
+		    $param.='&socid='.urlencode($socid);
832
+		}
833
+		if ($viewstatut != '') {
834
+		    $param.='&viewstatut='.urlencode($viewstatut);
835
+		}
836
+		if ($search_orderday) {
837
+		    $param.='&search_orderday='.urlencode($search_orderday);
838
+		}
839
+		if ($search_ordermonth) {
840
+		    $param.='&search_ordermonth='.urlencode($search_ordermonth);
841
+		}
842
+		if ($search_orderyear) {
843
+		    $param.='&search_orderyear='.urlencode($search_orderyear);
844
+		}
845
+		if ($search_deliveryday) {
846
+		    $param.='&search_deliveryday='.urlencode($search_deliveryday);
847
+		}
848
+		if ($search_deliverymonth) {
849
+		    $param.='&search_deliverymonth='.urlencode($search_deliverymonth);
850
+		}
851
+		if ($search_deliveryyear) {
852
+		    $param.='&search_deliveryyear='.urlencode($search_deliveryyear);
853
+		}
854
+		if ($search_ref) {
855
+		    $param.='&search_ref='.urlencode($search_ref);
856
+		}
857
+		if ($search_company) {
858
+		    $param.='&search_company='.urlencode($search_company);
859
+		}
860
+		if ($search_ref_customer) {
861
+		    $param.='&search_ref_customer='.urlencode($search_ref_customer);
862
+		}
863
+		if ($search_user > 0) {
864
+		    $param.='&search_user='.urlencode($search_user);
865
+		}
866
+		if ($search_sale > 0) {
867
+		    $param.='&search_sale='.urlencode($search_sale);
868
+		}
869
+		if ($search_total_ht != '') {
870
+		    $param.='&search_total_ht='.urlencode($search_total_ht);
871
+		}
872
+		if ($search_total_vat != '') {
873
+		    $param.='&search_total_vat='.urlencode($search_total_vat);
874
+		}
875
+		if ($search_total_ttc != '') {
876
+		    $param.='&search_total_ttc='.urlencode($search_total_ttc);
877
+		}
878
+		if ($search_project_ref >= 0) {
879
+		    $param.="&search_project_ref=".urlencode($search_project_ref);
880
+		}
881
+		if ($show_files) {
882
+		    $param.='&show_files=' .urlencode($show_files);
883
+		}
884
+		if ($optioncss != '') {
885
+		    $param.='&optioncss='.urlencode($optioncss);
886
+		}
887
+		if ($billed != '') {
888
+		    $param.='&billed='.urlencode($billed);
889
+		}
760 890
 
761 891
 		header("Location: ".$_SERVER['PHP_SELF'].'?'.$param);
762 892
 		exit;
763
-	}
764
-	else
893
+	} else
765 894
 	{
766 895
 		$db->rollback();
767 896
 		$action='create';
@@ -785,8 +914,9 @@  discard block
 block discarded – undo
785 914
 	{
786 915
 
787 916
 		$cmd = new Commande($db);
788
-		if ($cmd->fetch($id_order) <= 0)
789
-			continue;
917
+		if ($cmd->fetch($id_order) <= 0) {
918
+					continue;
919
+		}
790 920
 
791 921
 		if ($cmd->statut != Commande::STATUS_VALIDATED)
792 922
 		{
@@ -794,28 +924,28 @@  discard block
 block discarded – undo
794 924
 			setEventMessages($langs->trans("ErrorObjectMustHaveStatusValidToBeCanceled", $cmd->ref), null, 'errors');
795 925
 			$error++;
796 926
 			break;
927
+		} else {
928
+					$result = $cmd->cancel();
797 929
 		}
798
-		else
799
-			$result = $cmd->cancel();
800 930
 
801 931
 		if ($result < 0)
802 932
 		{
803 933
 			setEventMessages($cmd->error, $cmd->errors, 'errors');
804 934
 			$error++;
805 935
 			break;
936
+		} else {
937
+					$nbok++;
806 938
 		}
807
-		else
808
-			$nbok++;
809 939
 	}
810 940
 	if (!$error)
811 941
 	{
812
-		if ($nbok > 1)
813
-			setEventMessages($langs->trans("RecordsModified", $nbok), null, 'mesgs');
814
-		else
815
-			setEventMessages($langs->trans("RecordsModified", $nbok), null, 'mesgs');
942
+		if ($nbok > 1) {
943
+					setEventMessages($langs->trans("RecordsModified", $nbok), null, 'mesgs');
944
+		} else {
945
+					setEventMessages($langs->trans("RecordsModified", $nbok), null, 'mesgs');
946
+		}
816 947
 		$db->commit();
817
-	}
818
-	else
948
+	} else
819 949
 	{
820 950
 		$db->rollback();
821 951
 	}
@@ -852,8 +982,13 @@  discard block
 block discarded – undo
852 982
 	}
853 983
 
854 984
 	$arrayofinclusion=array();
855
-	foreach($listofobjectref as $tmppdf) $arrayofinclusion[]='^'.preg_quote(dol_sanitizeFileName($tmppdf),'/').'\.pdf$';
856
-	foreach($listofobjectref as $tmppdf) $arrayofinclusion[]='^'.preg_quote(dol_sanitizeFileName($tmppdf),'/').'_[a-zA-Z0-9-_]+\.pdf$';	// To include PDF generated from ODX files
985
+	foreach($listofobjectref as $tmppdf) {
986
+	    $arrayofinclusion[]='^'.preg_quote(dol_sanitizeFileName($tmppdf),'/').'\.pdf$';
987
+	}
988
+	foreach($listofobjectref as $tmppdf) {
989
+	    $arrayofinclusion[]='^'.preg_quote(dol_sanitizeFileName($tmppdf),'/').'_[a-zA-Z0-9-_]+\.pdf$';
990
+	}
991
+	// To include PDF generated from ODX files
857 992
 	$listoffiles = dol_dir_list($uploaddir,'all',1,implode('|',$arrayofinclusion),'\.meta$|\.png','date',SORT_DESC,0,true);
858 993
 
859 994
 	// build list of files with full path
@@ -874,8 +1009,12 @@  discard block
 block discarded – undo
874 1009
 	// Define output language (Here it is not used because we do only merging existing PDF)
875 1010
 	$outputlangs = $langs;
876 1011
 	$newlang='';
877
-	if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id','aZ09')) $newlang=GETPOST('lang_id','aZ09');
878
-	if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$objecttmp->thirdparty->default_lang;
1012
+	if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id','aZ09')) {
1013
+	    $newlang=GETPOST('lang_id','aZ09');
1014
+	}
1015
+	if ($conf->global->MAIN_MULTILANGS && empty($newlang)) {
1016
+	    $newlang=$objecttmp->thirdparty->default_lang;
1017
+	}
879 1018
 	if (! empty($newlang))
880 1019
 	{
881 1020
 		$outputlangs = new Translate("",$conf);
@@ -894,11 +1033,18 @@  discard block
 block discarded – undo
894 1033
 		// Save merged file
895 1034
 		if (in_array($objecttmp->element, array('facture', 'facture_fournisseur')) && $search_status == Facture::STATUS_VALIDATED)
896 1035
 		{
897
-			if ($option=='late') $filename.='_'.strtolower(dol_sanitizeFileName($langs->transnoentities("Unpaid"))).'_'.strtolower(dol_sanitizeFileName($langs->transnoentities("Late")));
898
-			else $filename.='_'.strtolower(dol_sanitizeFileName($langs->transnoentities("Unpaid")));
1036
+			if ($option=='late') {
1037
+			    $filename.='_'.strtolower(dol_sanitizeFileName($langs->transnoentities("Unpaid"))).'_'.strtolower(dol_sanitizeFileName($langs->transnoentities("Late")));
1038
+			} else {
1039
+			    $filename.='_'.strtolower(dol_sanitizeFileName($langs->transnoentities("Unpaid")));
1040
+			}
1041
+		}
1042
+		if ($year) {
1043
+		    $filename.='_'.$year;
1044
+		}
1045
+		if ($month) {
1046
+		    $filename.='_'.$month;
899 1047
 		}
900
-		if ($year) $filename.='_'.$year;
901
-		if ($month) $filename.='_'.$month;
902 1048
 
903 1049
 		if (count($files)>0)
904 1050
 		{
@@ -913,18 +1059,17 @@  discard block
 block discarded – undo
913 1059
 			$cmd = 'pdftk '.escapeshellarg($input_files).' cat output '.escapeshellarg($file);
914 1060
 			exec($cmd);
915 1061
 
916
-			if (! empty($conf->global->MAIN_UMASK))
917
-				@chmod($file, octdec($conf->global->MAIN_UMASK));
1062
+			if (! empty($conf->global->MAIN_UMASK)) {
1063
+							@chmod($file, octdec($conf->global->MAIN_UMASK));
1064
+			}
918 1065
 
919 1066
 			$langs->load("exports");
920 1067
 			setEventMessages($langs->trans('FileSuccessfullyBuilt',$filename.'_'.dol_print_date($now,'dayhourlog')), null, 'mesgs');
921
-		}
922
-		else
1068
+		} else
923 1069
 		{
924 1070
 			setEventMessages($langs->trans('NoPDFAvailableForDocGenAmongChecked'), null, 'errors');
925 1071
 		}
926
-	}
927
-	else {
1072
+	} else {
928 1073
 		// Create empty PDF
929 1074
 		$formatarray=pdf_getFormat();
930 1075
 		$page_largeur = $formatarray['width'];
@@ -940,7 +1085,9 @@  discard block
 block discarded – undo
940 1085
 		}
941 1086
 		$pdf->SetFont(pdf_getPDFFont($outputlangs));
942 1087
 
943
-		if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
1088
+		if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) {
1089
+		    $pdf->SetCompression(false);
1090
+		}
944 1091
 
945 1092
 		// Add all others
946 1093
 		foreach($files as $file)
@@ -966,23 +1113,30 @@  discard block
 block discarded – undo
966 1113
 		// Save merged file
967 1114
 		if (in_array($objecttmp->element, array('facture', 'facture_fournisseur')) && $search_status == Facture::STATUS_VALIDATED)
968 1115
 		{
969
-			if ($option=='late') $filename.='_'.strtolower(dol_sanitizeFileName($langs->transnoentities("Unpaid"))).'_'.strtolower(dol_sanitizeFileName($langs->transnoentities("Late")));
970
-			else $filename.='_'.strtolower(dol_sanitizeFileName($langs->transnoentities("Unpaid")));
1116
+			if ($option=='late') {
1117
+			    $filename.='_'.strtolower(dol_sanitizeFileName($langs->transnoentities("Unpaid"))).'_'.strtolower(dol_sanitizeFileName($langs->transnoentities("Late")));
1118
+			} else {
1119
+			    $filename.='_'.strtolower(dol_sanitizeFileName($langs->transnoentities("Unpaid")));
1120
+			}
1121
+		}
1122
+		if ($year) {
1123
+		    $filename.='_'.$year;
1124
+		}
1125
+		if ($month) {
1126
+		    $filename.='_'.$month;
971 1127
 		}
972
-		if ($year) $filename.='_'.$year;
973
-		if ($month) $filename.='_'.$month;
974 1128
 		if ($pagecount)
975 1129
 		{
976 1130
 			$now=dol_now();
977 1131
 			$file=$diroutputmassaction.'/'.$filename.'_'.dol_print_date($now,'dayhourlog').'.pdf';
978 1132
 			$pdf->Output($file,'F');
979
-			if (! empty($conf->global->MAIN_UMASK))
980
-				@chmod($file, octdec($conf->global->MAIN_UMASK));
1133
+			if (! empty($conf->global->MAIN_UMASK)) {
1134
+							@chmod($file, octdec($conf->global->MAIN_UMASK));
1135
+			}
981 1136
 
982 1137
 			$langs->load("exports");
983 1138
 			setEventMessages($langs->trans('FileSuccessfullyBuilt',$filename.'_'.dol_print_date($now,'dayhourlog')), null, 'mesgs');
984
-		}
985
-		else
1139
+		} else
986 1140
 		{
987 1141
 		setEventMessages($langs->trans('NoPDFAvailableForDocGenAmongChecked'), null, 'errors');
988 1142
 		}
@@ -998,8 +1152,11 @@  discard block
 block discarded – undo
998 1152
 	$upload_dir = $diroutputmassaction;
999 1153
 	$file = $upload_dir . '/' . GETPOST('file');
1000 1154
 	$ret=dol_delete_file($file);
1001
-	if ($ret) setEventMessages($langs->trans("FileWasRemoved", GETPOST('file')), null, 'mesgs');
1002
-	else setEventMessages($langs->trans("ErrorFailToDeleteFile", GETPOST('file')), null, 'errors');
1155
+	if ($ret) {
1156
+	    setEventMessages($langs->trans("FileWasRemoved", GETPOST('file')), null, 'mesgs');
1157
+	} else {
1158
+	    setEventMessages($langs->trans("ErrorFailToDeleteFile", GETPOST('file')), null, 'errors');
1159
+	}
1003 1160
 	$action='';
1004 1161
 }
1005 1162
 
@@ -1039,16 +1196,15 @@  discard block
 block discarded – undo
1039 1196
 					setEventMessages($langs->trans("ErrorObjectMustHaveStatusDraftToBeValidated", $objecttmp->ref), null, 'errors');
1040 1197
 					$error++;
1041 1198
 					break;
1042
-				}
1043
-				elseif ($result < 0)
1199
+				} elseif ($result < 0)
1044 1200
 				{
1045 1201
 					setEventMessages($objecttmp->error, $objecttmp->errors, 'errors');
1046 1202
 					$error++;
1047 1203
 					break;
1204
+				} else {
1205
+				    $nbok++;
1048 1206
 				}
1049
-				else $nbok++;
1050
-			}
1051
-			else
1207
+			} else
1052 1208
 			{
1053 1209
 				setEventMessages($objecttmp->error, $objecttmp->errors, 'errors');
1054 1210
 				$error++;
@@ -1058,11 +1214,13 @@  discard block
 block discarded – undo
1058 1214
 
1059 1215
 		if (! $error)
1060 1216
 		{
1061
-			if ($nbok > 1) setEventMessages($langs->trans("RecordsModified", $nbok), null, 'mesgs');
1062
-			else setEventMessages($langs->trans("RecordsModified", $nbok), null, 'mesgs');
1217
+			if ($nbok > 1) {
1218
+			    setEventMessages($langs->trans("RecordsModified", $nbok), null, 'mesgs');
1219
+			} else {
1220
+			    setEventMessages($langs->trans("RecordsModified", $nbok), null, 'mesgs');
1221
+			}
1063 1222
 			$db->commit();
1064
-		}
1065
-		else
1223
+		} else
1066 1224
 		{
1067 1225
 			$db->rollback();
1068 1226
 		}
@@ -1083,10 +1241,10 @@  discard block
 block discarded – undo
1083 1241
                 setEventMessages($objecttmp->error, $objecttmp->errors, 'errors');
1084 1242
                 $error++;
1085 1243
                 break;
1086
-            } else
1087
-                $nbok++;
1088
-        }
1089
-        else {
1244
+            } else {
1245
+                            $nbok++;
1246
+            }
1247
+        } else {
1090 1248
             setEventMessages($objecttmp->error, $objecttmp->errors, 'errors');
1091 1249
             $error++;
1092 1250
             break;
@@ -1094,13 +1252,13 @@  discard block
 block discarded – undo
1094 1252
     }
1095 1253
 
1096 1254
     if (!$error) {
1097
-        if ($nbok > 1)
1098
-            setEventMessages($langs->trans("RecordsModified", $nbok), null, 'mesgs');
1099
-        else
1100
-            setEventMessages($langs->trans("RecordsModified", $nbok), null, 'mesgs');
1255
+        if ($nbok > 1) {
1256
+                    setEventMessages($langs->trans("RecordsModified", $nbok), null, 'mesgs');
1257
+        } else {
1258
+                    setEventMessages($langs->trans("RecordsModified", $nbok), null, 'mesgs');
1259
+        }
1101 1260
         $db->commit();
1102
-    }
1103
-    else {
1261
+    } else {
1104 1262
         $db->rollback();
1105 1263
     }
1106 1264
 }
@@ -1137,18 +1295,21 @@  discard block
 block discarded – undo
1137 1295
 				}
1138 1296
 			}
1139 1297
 
1140
-			if (in_array($objecttmp->element, array('societe', 'member'))) $result = $objecttmp->delete($objecttmp->id, $user, 1);
1141
-			else $result = $objecttmp->delete($user);
1298
+			if (in_array($objecttmp->element, array('societe', 'member'))) {
1299
+			    $result = $objecttmp->delete($objecttmp->id, $user, 1);
1300
+			} else {
1301
+			    $result = $objecttmp->delete($user);
1302
+			}
1142 1303
 
1143 1304
 			if ($result <= 0)
1144 1305
 			{
1145 1306
 			    setEventMessages($objecttmp->error, $objecttmp->errors, 'errors');
1146 1307
 			    $error++;
1147 1308
 			    break;
1309
+			} else {
1310
+			    $nbok++;
1148 1311
 			}
1149
-			else $nbok++;
1150
-		}
1151
-		else
1312
+		} else
1152 1313
 		{
1153 1314
 			setEventMessages($objecttmp->error, $objecttmp->errors, 'errors');
1154 1315
 			$error++;
@@ -1158,11 +1319,13 @@  discard block
 block discarded – undo
1158 1319
 
1159 1320
 	if (! $error)
1160 1321
 	{
1161
-		if ($nbok > 1) setEventMessages($langs->trans("RecordsDeleted", $nbok), null, 'mesgs');
1162
-		else setEventMessages($langs->trans("RecordDeleted", $nbok), null, 'mesgs');
1322
+		if ($nbok > 1) {
1323
+		    setEventMessages($langs->trans("RecordsDeleted", $nbok), null, 'mesgs');
1324
+		} else {
1325
+		    setEventMessages($langs->trans("RecordDeleted", $nbok), null, 'mesgs');
1326
+		}
1163 1327
 		$db->commit();
1164
-	}
1165
-	else
1328
+	} else
1166 1329
 	{
1167 1330
 		$db->rollback();
1168 1331
 	}
@@ -1185,9 +1348,17 @@  discard block
 block discarded – undo
1185 1348
 			$outputlangs = $langs;
1186 1349
 			$newlang='';
1187 1350
 	
1188
-			if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id','aZ09')) $newlang=GETPOST('lang_id','aZ09');
1189
-			if ($conf->global->MAIN_MULTILANGS && empty($newlang) && isset($objecttmp->thirdparty->default_lang)) $newlang=$objecttmp->thirdparty->default_lang;  // for proposal, order, invoice, ...
1190
-			if ($conf->global->MAIN_MULTILANGS && empty($newlang) && isset($objecttmp->default_lang)) $newlang=$objecttmp->default_lang;                  // for thirdparty
1351
+			if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id','aZ09')) {
1352
+			    $newlang=GETPOST('lang_id','aZ09');
1353
+			}
1354
+			if ($conf->global->MAIN_MULTILANGS && empty($newlang) && isset($objecttmp->thirdparty->default_lang)) {
1355
+			    $newlang=$objecttmp->thirdparty->default_lang;
1356
+			}
1357
+			// for proposal, order, invoice, ...
1358
+			if ($conf->global->MAIN_MULTILANGS && empty($newlang) && isset($objecttmp->default_lang)) {
1359
+			    $newlang=$objecttmp->default_lang;
1360
+			}
1361
+			// for thirdparty
1191 1362
 			if (! empty($newlang))
1192 1363
 			{
1193 1364
 				$outputlangs = new Translate("",$conf);
@@ -1195,10 +1366,18 @@  discard block
 block discarded – undo
1195 1366
 			}
1196 1367
 	
1197 1368
 			// To be sure vars is defined
1198
-			if (empty($hidedetails)) $hidedetails=0;
1199
-			if (empty($hidedesc)) $hidedesc=0;
1200
-			if (empty($hideref)) $hideref=0;
1201
-			if (empty($moreparams)) $moreparams=null;
1369
+			if (empty($hidedetails)) {
1370
+			    $hidedetails=0;
1371
+			}
1372
+			if (empty($hidedesc)) {
1373
+			    $hidedesc=0;
1374
+			}
1375
+			if (empty($hideref)) {
1376
+			    $hideref=0;
1377
+			}
1378
+			if (empty($moreparams)) {
1379
+			    $moreparams=null;
1380
+			}
1202 1381
 			
1203 1382
 			$result= $objecttmp->generateDocument($objecttmp->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref, $moreparams);
1204 1383
 
@@ -1207,10 +1386,10 @@  discard block
 block discarded – undo
1207 1386
 				setEventMessages($objecttmp->error, $objecttmp->errors, 'errors');
1208 1387
 				$error++;
1209 1388
 				break;
1389
+			} else {
1390
+			    $nbok++;
1210 1391
 			}
1211
-			else $nbok++;
1212
-		}
1213
-		else
1392
+		} else
1214 1393
 		{
1215 1394
 			setEventMessages($objecttmp->error, $objecttmp->errors, 'errors');
1216 1395
 			$error++;
@@ -1220,11 +1399,13 @@  discard block
 block discarded – undo
1220 1399
 
1221 1400
 	if (! $error)
1222 1401
 	{
1223
-		if ($nbok > 1) setEventMessages($langs->trans("RecordsGenerated", $nbok), null, 'mesgs');
1224
-		else setEventMessages($langs->trans("RecordGenerated", $nbok), null, 'mesgs');
1402
+		if ($nbok > 1) {
1403
+		    setEventMessages($langs->trans("RecordsGenerated", $nbok), null, 'mesgs');
1404
+		} else {
1405
+		    setEventMessages($langs->trans("RecordGenerated", $nbok), null, 'mesgs');
1406
+		}
1225 1407
 		$db->commit();
1226
-	}
1227
-	else
1408
+	} else
1228 1409
 	{
1229 1410
 		$db->rollback();
1230 1411
 	}
@@ -1234,7 +1415,9 @@  discard block
 block discarded – undo
1234 1415
 $parameters['uploaddir']=$uploaddir;
1235 1416
 
1236 1417
 $reshook=$hookmanager->executeHooks('doMassActions',$parameters, $object, $action);    // Note that $action and $object may have been modified by some hooks
1237
-if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
1418
+if ($reshook < 0) {
1419
+    setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
1420
+}
1238 1421
 
1239 1422
 
1240 1423
 
Please login to merge, or discard this patch.
dolibarr/htdocs/core/js/lib_notification.js.php 1 patch
Braces   +21 added lines, -7 removed lines patch added patch discarded remove patch
@@ -18,13 +18,27 @@
 block discarded – undo
18 18
  * Library javascript to enable Browser notifications
19 19
  */
20 20
 
21
-if (!defined('NOREQUIREUSER')) define('NOREQUIREUSER', '1');
22
-if (!defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1');
23
-if (!defined('NOCSRFCHECK')) define('NOCSRFCHECK', 1);
24
-if (!defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', 1);
25
-if (!defined('NOLOGIN')) define('NOLOGIN', 1);
26
-if (!defined('NOREQUIREMENU')) define('NOREQUIREMENU', 1);
27
-if (!defined('NOREQUIREHTML')) define('NOREQUIREHTML', 1);
21
+if (!defined('NOREQUIREUSER')) {
22
+    define('NOREQUIREUSER', '1');
23
+}
24
+if (!defined('NOREQUIRESOC')) {
25
+    define('NOREQUIRESOC', '1');
26
+}
27
+if (!defined('NOCSRFCHECK')) {
28
+    define('NOCSRFCHECK', 1);
29
+}
30
+if (!defined('NOTOKENRENEWAL')) {
31
+    define('NOTOKENRENEWAL', 1);
32
+}
33
+if (!defined('NOLOGIN')) {
34
+    define('NOLOGIN', 1);
35
+}
36
+if (!defined('NOREQUIREMENU')) {
37
+    define('NOREQUIREMENU', 1);
38
+}
39
+if (!defined('NOREQUIREHTML')) {
40
+    define('NOREQUIREHTML', 1);
41
+}
28 42
 
29 43
 require_once '../../main.inc.php';
30 44
 
Please login to merge, or discard this patch.
dolibarr/htdocs/core/js/lib_gravatar.js.php 1 patch
Braces   +26 added lines, -9 removed lines patch added patch discarded remove patch
@@ -24,14 +24,28 @@  discard block
 block discarded – undo
24 24
 
25 25
 //if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER','1');	// Not disabled cause need to load personalized language
26 26
 //if (! defined('NOREQUIREDB'))   define('NOREQUIREDB','1');
27
-if (! defined('NOREQUIRESOC'))    define('NOREQUIRESOC','1');
27
+if (! defined('NOREQUIRESOC')) {
28
+    define('NOREQUIRESOC','1');
29
+}
28 30
 //if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1');	// Not disabled cause need to do translations
29
-if (! defined('NOCSRFCHECK'))     define('NOCSRFCHECK',1);
30
-if (! defined('NOTOKENRENEWAL'))  define('NOTOKENRENEWAL',1);
31
-if (! defined('NOLOGIN'))         define('NOLOGIN',1);
32
-if (! defined('NOREQUIREMENU'))   define('NOREQUIREMENU',1);
33
-if (! defined('NOREQUIREHTML'))   define('NOREQUIREHTML',1);
34
-if (! defined('NOREQUIREAJAX'))   define('NOREQUIREAJAX','1');
31
+if (! defined('NOCSRFCHECK')) {
32
+    define('NOCSRFCHECK',1);
33
+}
34
+if (! defined('NOTOKENRENEWAL')) {
35
+    define('NOTOKENRENEWAL',1);
36
+}
37
+if (! defined('NOLOGIN')) {
38
+    define('NOLOGIN',1);
39
+}
40
+if (! defined('NOREQUIREMENU')) {
41
+    define('NOREQUIREMENU',1);
42
+}
43
+if (! defined('NOREQUIREHTML')) {
44
+    define('NOREQUIREHTML',1);
45
+}
46
+if (! defined('NOREQUIREAJAX')) {
47
+    define('NOREQUIREAJAX','1');
48
+}
35 49
 
36 50
 session_cache_limiter('public');
37 51
 
@@ -40,8 +54,11 @@  discard block
 block discarded – undo
40 54
 // Define javascript type
41 55
 top_httphead('text/javascript; charset=UTF-8');
42 56
 // Important: Following code is to avoid page request by browser and PHP CPU at each Dolibarr page access.
43
-if (empty($dolibarr_nocache)) header('Cache-Control: max-age=10800, public, must-revalidate');
44
-else header('Cache-Control: no-cache');
57
+if (empty($dolibarr_nocache)) {
58
+    header('Cache-Control: max-age=10800, public, must-revalidate');
59
+} else {
60
+    header('Cache-Control: no-cache');
61
+}
45 62
 
46 63
 ?>
47 64
 
Please login to merge, or discard this patch.
dolibarr/htdocs/core/js/timepicker.js.php 1 patch
Braces   +29 added lines, -10 removed lines patch added patch discarded remove patch
@@ -21,13 +21,27 @@  discard block
 block discarded – undo
21 21
  * \brief      File that include javascript functions for timepicker
22 22
  */
23 23
 
24
-if (! defined('NOREQUIRESOC'))    define('NOREQUIRESOC','1');
25
-if (! defined('NOCSRFCHECK'))     define('NOCSRFCHECK',1);
26
-if (! defined('NOTOKENRENEWAL'))  define('NOTOKENRENEWAL',1);
27
-if (! defined('NOLOGIN'))         define('NOLOGIN',1);
28
-if (! defined('NOREQUIREMENU'))   define('NOREQUIREMENU',1);
29
-if (! defined('NOREQUIREHTML'))   define('NOREQUIREHTML',1);
30
-if (! defined('NOREQUIREAJAX'))   define('NOREQUIREAJAX','1');
24
+if (! defined('NOREQUIRESOC')) {
25
+    define('NOREQUIRESOC','1');
26
+}
27
+if (! defined('NOCSRFCHECK')) {
28
+    define('NOCSRFCHECK',1);
29
+}
30
+if (! defined('NOTOKENRENEWAL')) {
31
+    define('NOTOKENRENEWAL',1);
32
+}
33
+if (! defined('NOLOGIN')) {
34
+    define('NOLOGIN',1);
35
+}
36
+if (! defined('NOREQUIREMENU')) {
37
+    define('NOREQUIREMENU',1);
38
+}
39
+if (! defined('NOREQUIREHTML')) {
40
+    define('NOREQUIREHTML',1);
41
+}
42
+if (! defined('NOREQUIREAJAX')) {
43
+    define('NOREQUIREAJAX','1');
44
+}
31 45
 
32 46
 session_cache_limiter('public');
33 47
 
@@ -36,8 +50,11 @@  discard block
 block discarded – undo
36 50
 // Define javascript type
37 51
 top_httphead('text/javascript; charset=UTF-8');
38 52
 // Important: Following code is to avoid page request by browser and PHP CPU at each Dolibarr page access.
39
-if (empty($dolibarr_nocache)) header('Cache-Control: max-age=10800, public, must-revalidate');
40
-else header('Cache-Control: no-cache');
53
+if (empty($dolibarr_nocache)) {
54
+    header('Cache-Control: max-age=10800, public, must-revalidate');
55
+} else {
56
+    header('Cache-Control: no-cache');
57
+}
41 58
 ?>
42 59
 
43 60
 // For JQuery Timepicker
@@ -61,4 +78,6 @@  discard block
 block discarded – undo
61 78
 });
62 79
 
63 80
 <?php
64
-if (is_object($db)) $db->close();
81
+if (is_object($db)) {
82
+    $db->close();
83
+}
Please login to merge, or discard this patch.
dolibarr/htdocs/core/actions_linkedfiles.inc.php 1 patch
Braces   +44 added lines, -34 removed lines patch added patch discarded remove patch
@@ -31,8 +31,11 @@  discard block
 block discarded – undo
31 31
 {
32 32
 	if (! empty($_FILES))
33 33
 	{
34
-		if (is_array($_FILES['userfile']['tmp_name'])) $userfiles=$_FILES['userfile']['tmp_name'];
35
-		else $userfiles=array($_FILES['userfile']['tmp_name']);
34
+		if (is_array($_FILES['userfile']['tmp_name'])) {
35
+		    $userfiles=$_FILES['userfile']['tmp_name'];
36
+		} else {
37
+		    $userfiles=array($_FILES['userfile']['tmp_name']);
38
+		}
36 39
 
37 40
 		foreach($userfiles as $key => $userfile)
38 41
 		{
@@ -41,8 +44,7 @@  discard block
 block discarded – undo
41 44
 				$error++;
42 45
 				if ($_FILES['userfile']['error'][$key] == 1 || $_FILES['userfile']['error'][$key] == 2){
43 46
 					setEventMessages($langs->trans('ErrorFileSizeTooLarge'), null, 'errors');
44
-				}
45
-				else {
47
+				} else {
46 48
 					setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("File")), null, 'errors');
47 49
 				}
48 50
 			}
@@ -52,20 +54,20 @@  discard block
 block discarded – undo
52 54
 		{
53 55
 			// Define if we have to generate thumbs or not
54 56
 			$generatethumbs = 1;
55
-			if (GETPOST('section_dir')) $generatethumbs=0;
57
+			if (GETPOST('section_dir')) {
58
+			    $generatethumbs=0;
59
+			}
56 60
 
57 61
 			if (! empty($upload_dirold) && ! empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO))
58 62
 			{
59 63
 				$result = dol_add_file_process($upload_dirold, 0, 1, 'userfile', GETPOST('savingdocmask', 'alpha'), null, '', $generatethumbs);
60
-			}
61
-			elseif (! empty($upload_dir))
64
+			} elseif (! empty($upload_dir))
62 65
 			{
63 66
 				$result = dol_add_file_process($upload_dir, 0, 1, 'userfile', GETPOST('savingdocmask', 'alpha'), null, '', $generatethumbs);
64 67
 			}
65 68
 		}
66 69
 	}
67
-}
68
-elseif (GETPOST('linkit','none') && ! empty($conf->global->MAIN_UPLOAD_DOC))
70
+} elseif (GETPOST('linkit','none') && ! empty($conf->global->MAIN_UPLOAD_DOC))
69 71
 {
70 72
     $link = GETPOST('link', 'alpha');
71 73
     if ($link)
@@ -82,25 +84,34 @@  discard block
 block discarded – undo
82 84
 if ($action == 'confirm_deletefile' && $confirm == 'yes')
83 85
 {
84 86
         $urlfile = GETPOST('urlfile', 'alpha', 0, null, null, 1);				// Do not use urldecode here ($_GET and $_REQUEST are already decoded by PHP).
85
-        if (GETPOST('section', 'alpha')) 	// For a delete from the ECM module, upload_dir is ECM root dir and urlfile contains relative path from upload_dir
87
+        if (GETPOST('section', 'alpha')) {
88
+            // For a delete from the ECM module, upload_dir is ECM root dir and urlfile contains relative path from upload_dir
86 89
         {
87 90
         	$file = $upload_dir . (preg_match('/\/$/', $upload_dir) ? '' : '/') . $urlfile;
88 91
         }
89
-        else								// For a delete from the file manager into another module, or from documents pages, upload_dir contains already path to file from module dir, so we clean path into urlfile.
92
+        } else								// For a delete from the file manager into another module, or from documents pages, upload_dir contains already path to file from module dir, so we clean path into urlfile.
90 93
 		{
91 94
        		$urlfile=basename($urlfile);
92 95
        		$file = $upload_dir . (preg_match('/\/$/', $upload_dir) ? '' : '/') . $urlfile;
93
-			if (! empty($upload_dirold)) $fileold = $upload_dirold . "/" . $urlfile;
96
+			if (! empty($upload_dirold)) {
97
+			    $fileold = $upload_dirold . "/" . $urlfile;
98
+			}
94 99
 		}
95 100
         $linkid = GETPOST('linkid', 'int');
96 101
 
97
-        if ($urlfile)		// delete of a file
102
+        if ($urlfile) {
103
+            // delete of a file
98 104
         {
99
-	        $dir = dirname($file).'/';		// Chemin du dossier contenant l'image d'origine
105
+	        $dir = dirname($file).'/';
106
+        }
107
+        // Chemin du dossier contenant l'image d'origine
100 108
 	        $dirthumb = $dir.'/thumbs/';	// Chemin du dossier contenant la vignette (if file is an image)
101 109
 
102 110
 	        $ret = dol_delete_file($file, 0, 0, 0, (is_object($object)?$object:null));
103
-            if (! empty($fileold)) dol_delete_file($fileold, 0, 0, 0, (is_object($object)?$object:null));     // Delete file using old path
111
+            if (! empty($fileold)) {
112
+                dol_delete_file($fileold, 0, 0, 0, (is_object($object)?$object:null));
113
+            }
114
+            // Delete file using old path
104 115
 
105 116
 	        // Si elle existe, on efface la vignette
106 117
 	        if (preg_match('/(\.jpg|\.jpeg|\.bmp|\.gif|\.png|\.tiff)$/i',$file,$regs))
@@ -118,12 +129,16 @@  discard block
 block discarded – undo
118 129
 		        }
119 130
 	        }
120 131
 
121
-            if ($ret) setEventMessages($langs->trans("FileWasRemoved", $urlfile), null, 'mesgs');
122
-            else setEventMessages($langs->trans("ErrorFailToDeleteFile", $urlfile), null, 'errors');
123
-        }
124
-        elseif ($linkid)	// delete of external link
132
+            if ($ret) {
133
+                setEventMessages($langs->trans("FileWasRemoved", $urlfile), null, 'mesgs');
134
+            } else {
135
+                setEventMessages($langs->trans("ErrorFailToDeleteFile", $urlfile), null, 'errors');
136
+            }
137
+        } elseif ($linkid) {
138
+            // delete of external link
125 139
         {
126 140
             require_once DOL_DOCUMENT_ROOT . '/core/class/link.class.php';
141
+        }
127 142
             $link = new Link($db);
128 143
             $link->id = $linkid;
129 144
             $link->fetch();
@@ -147,15 +162,13 @@  discard block
 block discarded – undo
147 162
         	{
148 163
         		header('Location: ' . $backtopage);
149 164
         		exit;
150
-        	}
151
-        	else
165
+        	} else
152 166
         	{
153 167
         		header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id.(GETPOST('section_dir','alpha')?'&section_dir='.urlencode(GETPOST('section_dir','alpha')):'').(!empty($withproject)?'&withproject=1':''));
154 168
         		exit;
155 169
         	}
156 170
         }
157
-}
158
-elseif ($action == 'confirm_updateline' && GETPOST('save','alpha') && GETPOST('link', 'alpha'))
171
+} elseif ($action == 'confirm_updateline' && GETPOST('save','alpha') && GETPOST('link', 'alpha'))
159 172
 {
160 173
     require_once DOL_DOCUMENT_ROOT . '/core/class/link.class.php';
161 174
     $langs->load('link');
@@ -175,13 +188,11 @@  discard block
 block discarded – undo
175 188
         {
176 189
             setEventMessages($langs->trans("ErrorFailedToUpdateLink", $link->label), null, 'mesgs');
177 190
         }
178
-    }
179
-    else
191
+    } else
180 192
     {
181 193
         //error fetching
182 194
     }
183
-}
184
-elseif ($action == 'renamefile' && GETPOST('renamefilesave','alpha'))
195
+} elseif ($action == 'renamefile' && GETPOST('renamefilesave','alpha'))
185 196
 {
186 197
 	// For documents pages, upload_dir contains already path to file from module dir, so we clean path into urlfile.
187 198
 	if (! empty($upload_dir))
@@ -220,7 +231,9 @@  discard block
 block discarded – undo
220 231
 			            	// When we rename a file from the file manager in ecm, we must not regenerate thumbs (not a problem, we do pass here)
221 232
 			            	// When we rename a file from the website module, we must not regenerate thumbs (module = medias in such a case)
222 233
 			            	// but when we rename from a tab "Documents", we must regenerate thumbs
223
-			            	if (GETPOST('modulepart') == 'medias') $generatethumbs=0;
234
+			            	if (GETPOST('modulepart') == 'medias') {
235
+			            	    $generatethumbs=0;
236
+			            	}
224 237
 
225 238
 			            	if ($generatethumbs)
226 239
 			            	{
@@ -234,14 +247,12 @@  discard block
 block discarded – undo
234 247
 			            	}
235 248
 
236 249
 			                setEventMessages($langs->trans("FileRenamed"), null);
237
-			            }
238
-			            else
250
+			            } else
239 251
 			            {
240 252
 			                $langs->load("errors"); // key must be loaded because we can't rely on loading during output, we need var substitution to be done now.
241 253
 			                setEventMessages($langs->trans("ErrorFailToRenameFile", $filenamefrom, $filenameto), null, 'errors');
242 254
 			            }
243
-	            	}
244
-	            	else
255
+	            	} else
245 256
 	            	{
246 257
 	            		$langs->load("errors"); // key must be loaded because we can't rely on loading during output, we need var substitution to be done now.
247 258
 	            		setEventMessages($langs->trans("ErrorDestinationAlreadyExists", $filenameto), null, 'errors');
@@ -268,8 +279,7 @@  discard block
 block discarded – undo
268 279
 		    		require_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php';
269 280
 		    		$ecmfile->share = getRandomPassword(true);
270 281
 		    	}
271
-		    }
272
-		    else
282
+		    } else
273 283
 		    {
274 284
 		    	$ecmfile->share = '';
275 285
 		    }
Please login to merge, or discard this patch.
dolibarr/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php 1 patch
Braces   +138 added lines, -70 removed lines patch added patch discarded remove patch
@@ -137,7 +137,10 @@  discard block
 block discarded – undo
137 137
 
138 138
 		// Get source company
139 139
 		$this->emetteur=$mysoc;
140
-		if (! $this->emetteur->country_code) $this->emetteur->country_code=substr($langs->defaultlang,-2);    // By default if not defined
140
+		if (! $this->emetteur->country_code) {
141
+		    $this->emetteur->country_code=substr($langs->defaultlang,-2);
142
+		}
143
+		// By default if not defined
141 144
 
142 145
 		// Define position of columns
143 146
 		$this->posxdesc=$this->marge_gauche+1;
@@ -156,9 +159,11 @@  discard block
 block discarded – undo
156 159
 
157 160
 		$this->posxpicture=$this->posxweightvol - (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH)?20:$conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH);	// width of images
158 161
 
159
-		if ($this->page_largeur < 210) // To work with US executive format
162
+		if ($this->page_largeur < 210) {
163
+		    // To work with US executive format
160 164
 		{
161 165
 		    $this->posxweightvol-=20;
166
+		}
162 167
 		    $this->posxpicture-=20;
163 168
 		    $this->posxqtyordered-=20;
164 169
 		    $this->posxqtytoship-=20;
@@ -191,9 +196,13 @@  discard block
 block discarded – undo
191 196
 
192 197
 		$object->fetch_thirdparty();
193 198
 
194
-		if (! is_object($outputlangs)) $outputlangs=$langs;
199
+		if (! is_object($outputlangs)) {
200
+		    $outputlangs=$langs;
201
+		}
195 202
 		// For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
196
-		if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1';
203
+		if (! empty($conf->global->MAIN_USE_FPDF)) {
204
+		    $outputlangs->charset_output='ISO-8859-1';
205
+		}
197 206
 
198 207
 		// Load traductions files requiredby by page
199 208
 		$outputlangs->loadLangs(array("main", "bills", "products", "dict", "companies", "propal", "deliveries", "sendings", "productbatch"));
@@ -208,7 +217,9 @@  discard block
 block discarded – undo
208 217
 
209 218
             for ($i = 0 ; $i < $nblignes ; $i++)
210 219
             {
211
-                if (empty($object->lines[$i]->fk_product)) continue;
220
+                if (empty($object->lines[$i]->fk_product)) {
221
+                    continue;
222
+                }
212 223
 
213 224
 				$objphoto = new Product($this->db);
214 225
 				$objphoto->fetch($object->lines[$i]->fk_product);
@@ -220,18 +231,18 @@  discard block
 block discarded – undo
220 231
 
221 232
                 foreach ($objphoto->liste_photos($dir,1) as $key => $obj)
222 233
                         {
223
-                            if (empty($conf->global->CAT_HIGH_QUALITY_IMAGES))		// If CAT_HIGH_QUALITY_IMAGES not defined, we use thumb if defined and then original photo
234
+                            if (empty($conf->global->CAT_HIGH_QUALITY_IMAGES)) {
235
+                                // If CAT_HIGH_QUALITY_IMAGES not defined, we use thumb if defined and then original photo
224 236
                             {
225 237
                                 if ($obj['photo_vignette'])
226 238
                                 {
227 239
                                     $filename= $obj['photo_vignette'];
228
-                                }
229
-                                else
240
+                            }
241
+                                } else
230 242
                                 {
231 243
                                     $filename=$obj['photo'];
232 244
                                 }
233
-                            }
234
-                            else
245
+                            } else
235 246
                             {
236 247
                                 $filename=$obj['photo'];
237 248
                             }
@@ -240,11 +251,15 @@  discard block
 block discarded – undo
240 251
                             break;
241 252
                 }
242 253
 
243
-                if ($realpath) $realpatharray[$i]=$realpath;
254
+                if ($realpath) {
255
+                    $realpatharray[$i]=$realpath;
256
+                }
244 257
             }
245 258
         }
246 259
 
247
-        if (count($realpatharray) == 0) $this->posxpicture=$this->posxweightvol;
260
+        if (count($realpatharray) == 0) {
261
+            $this->posxpicture=$this->posxweightvol;
262
+        }
248 263
 
249 264
 		if ($conf->expedition->dir_output)
250 265
 		{
@@ -253,8 +268,7 @@  discard block
 block discarded – undo
253 268
 			{
254 269
 				$dir = $conf->expedition->dir_output."/sending";
255 270
 				$file = $dir . "/SPECIMEN.pdf";
256
-			}
257
-			else
271
+			} else
258 272
 			{
259 273
 				$expref = dol_sanitizeFileName($object->ref);
260 274
 				$dir = $conf->expedition->dir_output."/sending/" . $expref;
@@ -291,7 +305,9 @@  discard block
 block discarded – undo
291 305
 				$heightforinfotot = 8;	// Height reserved to output the info and total part
292 306
 		        $heightforfreetext= (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT)?$conf->global->MAIN_PDF_FREETEXT_HEIGHT:5);	// Height reserved to output the free text on last page
293 307
 	            $heightforfooter = $this->marge_basse + 8;	// Height reserved to output the footer (value include bottom margin)
294
-	            if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS >0) $heightforfooter+= 6;
308
+	            if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS >0) {
309
+	                $heightforfooter+= 6;
310
+	            }
295 311
                 $pdf->SetAutoPageBreak(1,0);
296 312
 
297 313
                 if (class_exists('TCPDF'))
@@ -311,20 +327,26 @@  discard block
 block discarded – undo
311 327
 				$pagenb=0;
312 328
 				$pdf->SetDrawColor(128,128,128);
313 329
 
314
-				if (method_exists($pdf,'AliasNbPages')) $pdf->AliasNbPages();
330
+				if (method_exists($pdf,'AliasNbPages')) {
331
+				    $pdf->AliasNbPages();
332
+				}
315 333
 
316 334
 				$pdf->SetTitle($outputlangs->convToOutputCharset($object->ref));
317 335
 				$pdf->SetSubject($outputlangs->transnoentities("Shipment"));
318 336
 				$pdf->SetCreator("Dolibarr ".DOL_VERSION);
319 337
 				$pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
320 338
 				$pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("Shipment"));
321
-				if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
339
+				if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) {
340
+				    $pdf->SetCompression(false);
341
+				}
322 342
 
323 343
 				$pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);   // Left, Top, Right
324 344
 
325 345
 				// New page
326 346
 				$pdf->AddPage();
327
-				if (! empty($tplidx)) $pdf->useTemplate($tplidx);
347
+				if (! empty($tplidx)) {
348
+				    $pdf->useTemplate($tplidx);
349
+				}
328 350
 				$pagenb++;
329 351
 				$this->_pagehead($pdf, $object, 1, $outputlangs);
330 352
 				$pdf->SetFont('','', $default_font_size - 1);
@@ -381,7 +403,9 @@  discard block
 block discarded – undo
381 403
 								// Get code using getLabelFromKey
382 404
 								$code=$outputlangs->getLabelFromKey($this->db,$object->shipping_method_id,'c_shipment_mode','rowid','code');
383 405
 								$label='';
384
-								if ($object->tracking_url != $object->tracking_number) $label.=$outputlangs->trans("LinkToTrackYourPackage")."<br>";
406
+								if ($object->tracking_url != $object->tracking_number) {
407
+								    $label.=$outputlangs->trans("LinkToTrackYourPackage")."<br>";
408
+								}
385 409
 								$label.=$outputlangs->trans("SendingMethod").": ".$outputlangs->trans("SendingMethod".strtoupper($code));
386 410
 								//var_dump($object->tracking_url != $object->tracking_number);exit;
387 411
 								if ($object->tracking_url != $object->tracking_number)
@@ -413,8 +437,7 @@  discard block
 block discarded – undo
413 437
 
414 438
 					$tab_height = $tab_height - $height_note;
415 439
 					$tab_top = $nexY+6;
416
-				}
417
-				else
440
+				} else
418 441
 				{
419 442
 					$height_note=0;
420 443
 				}
@@ -432,7 +455,9 @@  discard block
 block discarded – undo
432 455
 
433 456
 					// Define size of image if we need it
434 457
 					$imglinesize=array();
435
-					if (! empty($realpatharray[$i])) $imglinesize=pdf_getSizeForImage($realpatharray[$i]);
458
+					if (! empty($realpatharray[$i])) {
459
+					    $imglinesize=pdf_getSizeForImage($realpatharray[$i]);
460
+					}
436 461
 
437 462
 					$pdf->setTopMargin($tab_top_newpage);
438 463
 					$pdf->setPageOrientation('', 1, $heightforfooter+$heightforfreetext+$heightforinfotot);	// The only function to edit the bottom margin of current page to set it.
@@ -443,11 +468,17 @@  discard block
 block discarded – undo
443 468
 					$posYAfterDescription=0;
444 469
 
445 470
 					// We start with Photo of product line
446
-					if (isset($imglinesize['width']) && isset($imglinesize['height']) && ($curY + $imglinesize['height']) > ($this->page_hauteur-($heightforfooter+$heightforfreetext+$heightforinfotot)))	// If photo too high, we moved completely on new page
471
+					if (isset($imglinesize['width']) && isset($imglinesize['height']) && ($curY + $imglinesize['height']) > ($this->page_hauteur-($heightforfooter+$heightforfreetext+$heightforinfotot))) {
472
+					    // If photo too high, we moved completely on new page
447 473
 					{
448 474
 						$pdf->AddPage('','',true);
449
-						if (! empty($tplidx)) $pdf->useTemplate($tplidx);
450
-						if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
475
+					}
476
+						if (! empty($tplidx)) {
477
+						    $pdf->useTemplate($tplidx);
478
+						}
479
+						if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) {
480
+						    $this->_pagehead($pdf, $object, 0, $outputlangs);
481
+						}
451 482
 						$pdf->setPage($pageposbefore+1);
452 483
 
453 484
 						$curY = $tab_top_newpage;
@@ -469,9 +500,11 @@  discard block
 block discarded – undo
469 500
 					pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->posxpicture-$curX,3,$curX,$curY,$hideref,$hidedesc);
470 501
 
471 502
 					$pageposafter=$pdf->getPage();
472
-					if ($pageposafter > $pageposbefore)	// There is a pagebreak
503
+					if ($pageposafter > $pageposbefore) {
504
+					    // There is a pagebreak
473 505
 					{
474 506
 						$pdf->rollbackTransaction(true);
507
+					}
475 508
 						$pageposafter=$pageposbefore;
476 509
 						//print $pageposafter.'-'.$pageposbefore;exit;
477 510
 						$pdf->setPageOrientation('', 1, $heightforfooter);	// The only function to edit the bottom margin of current page to set it.
@@ -480,23 +513,27 @@  discard block
 block discarded – undo
480 513
 						$pageposafter=$pdf->getPage();
481 514
 						$posyafter=$pdf->GetY();
482 515
 						//var_dump($posyafter); var_dump(($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))); exit;
483
-						if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot)))	// There is no space left for total+free text
516
+						if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))) {
517
+						    // There is no space left for total+free text
484 518
 						{
485 519
 							if ($i == ($nblignes-1))	// No more lines, and no space left to show total, so we create a new page
486 520
 							{
487 521
 								$pdf->AddPage('','',true);
488
-								if (! empty($tplidx)) $pdf->useTemplate($tplidx);
489
-								if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
522
+						}
523
+								if (! empty($tplidx)) {
524
+								    $pdf->useTemplate($tplidx);
525
+								}
526
+								if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) {
527
+								    $this->_pagehead($pdf, $object, 0, $outputlangs);
528
+								}
490 529
 								$pdf->setPage($pageposafter+1);
491 530
 							}
492
-						}
493
-						else
531
+						} else
494 532
 						{
495 533
 							// We found a page break
496 534
 							$showpricebeforepagebreak=0;
497 535
 						}
498
-					}
499
-					else	// No pagebreak
536
+					} else	// No pagebreak
500 537
 					{
501 538
 						$pdf->commitTransaction();
502 539
 					}
@@ -561,7 +598,9 @@  discard block
 block discarded – undo
561 598
 					}
562 599
 
563 600
 					$nexY+=3;
564
-					if ($weighttxt && $voltxt) $nexY+=2;
601
+					if ($weighttxt && $voltxt) {
602
+					    $nexY+=2;
603
+					}
565 604
 
566 605
 					// Add line
567 606
 					if (! empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblignes - 1))
@@ -580,8 +619,7 @@  discard block
 block discarded – undo
580 619
 						if ($pagenb == 1)
581 620
 						{
582 621
 							$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1);
583
-						}
584
-						else
622
+						} else
585 623
 						{
586 624
 							$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
587 625
 						}
@@ -589,24 +627,29 @@  discard block
 block discarded – undo
589 627
 						$pagenb++;
590 628
 						$pdf->setPage($pagenb);
591 629
 						$pdf->setPageOrientation('', 1, 0);	// The only function to edit the bottom margin of current page to set it.
592
-						if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
630
+						if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) {
631
+						    $this->_pagehead($pdf, $object, 0, $outputlangs);
632
+						}
593 633
 					}
594 634
 					if (isset($object->lines[$i+1]->pagebreak) && $object->lines[$i+1]->pagebreak)
595 635
 					{
596 636
 						if ($pagenb == 1)
597 637
 						{
598 638
 							$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1);
599
-						}
600
-						else
639
+						} else
601 640
 						{
602 641
 							$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
603 642
 						}
604 643
 						$this->_pagefoot($pdf,$object,$outputlangs,1);
605 644
 						// New page
606 645
 						$pdf->AddPage();
607
-						if (! empty($tplidx)) $pdf->useTemplate($tplidx);
646
+						if (! empty($tplidx)) {
647
+						    $pdf->useTemplate($tplidx);
648
+						}
608 649
 						$pagenb++;
609
-						if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
650
+						if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) {
651
+						    $this->_pagehead($pdf, $object, 0, $outputlangs);
652
+						}
610 653
 					}
611 654
 				}
612 655
 
@@ -615,8 +658,7 @@  discard block
 block discarded – undo
615 658
 				{
616 659
 					$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0);
617 660
 					$bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
618
-				}
619
-				else
661
+				} else
620 662
 				{
621 663
 					$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0);
622 664
 					$bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
@@ -627,7 +669,9 @@  discard block
 block discarded – undo
627 669
 
628 670
 				// Pied de page
629 671
 				$this->_pagefoot($pdf,$object,$outputlangs);
630
-				if (method_exists($pdf,'AliasNbPages')) $pdf->AliasNbPages();
672
+				if (method_exists($pdf,'AliasNbPages')) {
673
+				    $pdf->AliasNbPages();
674
+				}
631 675
 
632 676
 				$pdf->Close();
633 677
 
@@ -639,20 +683,19 @@  discard block
 block discarded – undo
639 683
 				global $action;
640 684
 				$reshook=$hookmanager->executeHooks('afterPDFCreation',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
641 685
 
642
-				if (! empty($conf->global->MAIN_UMASK))
643
-				@chmod($file, octdec($conf->global->MAIN_UMASK));
686
+				if (! empty($conf->global->MAIN_UMASK)) {
687
+								@chmod($file, octdec($conf->global->MAIN_UMASK));
688
+				}
644 689
 
645 690
 				$this->result = array('fullpath'=>$file);
646 691
 
647 692
 				return 1;	// No error
648
-			}
649
-			else
693
+			} else
650 694
 			{
651 695
 				$this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
652 696
 				return 0;
653 697
 			}
654
-		}
655
-		else
698
+		} else
656 699
 		{
657 700
 			$this->error=$langs->transnoentities("ErrorConstantNotDefined","EXP_OUTPUTDIR");
658 701
 			return 0;
@@ -689,8 +732,11 @@  discard block
 block discarded – undo
689 732
 		{
690 733
 			$col2x-=20;
691 734
 		}*/
692
-		if (empty($conf->global->SHIPPING_PDF_HIDE_ORDERED)) $largcol2 = ($this->posxqtyordered - $this->posxweightvol);
693
-		else $largcol2 = ($this->posxqtytoship - $this->posxweightvol);
735
+		if (empty($conf->global->SHIPPING_PDF_HIDE_ORDERED)) {
736
+		    $largcol2 = ($this->posxqtyordered - $this->posxweightvol);
737
+		} else {
738
+		    $largcol2 = ($this->posxqtytoship - $this->posxweightvol);
739
+		}
694 740
 
695 741
 		$useborder=0;
696 742
 		$index = 0;
@@ -711,10 +757,18 @@  discard block
 block discarded – undo
711 757
 		    $object->volume_units=$object->size_units * 3;
712 758
 		}
713 759
 
714
-		if ($totalWeight!='') $totalWeighttoshow=showDimensionInBestUnit($totalWeight, 0, "weight", $outputlangs);
715
-		if ($totalVolume!='') $totalVolumetoshow=showDimensionInBestUnit($totalVolume, 0, "volume", $outputlangs);
716
-		if ($object->trueWeight) $totalWeighttoshow=showDimensionInBestUnit($object->trueWeight, $object->weight_units, "weight", $outputlangs);
717
-		if ($object->trueVolume) $totalVolumetoshow=showDimensionInBestUnit($object->trueVolume, $object->volume_units, "volume", $outputlangs);
760
+		if ($totalWeight!='') {
761
+		    $totalWeighttoshow=showDimensionInBestUnit($totalWeight, 0, "weight", $outputlangs);
762
+		}
763
+		if ($totalVolume!='') {
764
+		    $totalVolumetoshow=showDimensionInBestUnit($totalVolume, 0, "volume", $outputlangs);
765
+		}
766
+		if ($object->trueWeight) {
767
+		    $totalWeighttoshow=showDimensionInBestUnit($object->trueWeight, $object->weight_units, "weight", $outputlangs);
768
+		}
769
+		if ($object->trueVolume) {
770
+		    $totalVolumetoshow=showDimensionInBestUnit($object->trueVolume, $object->volume_units, "volume", $outputlangs);
771
+		}
718 772
 
719 773
     	$pdf->SetFillColor(255,255,255);
720 774
     	$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
@@ -758,7 +812,9 @@  discard block
 block discarded – undo
758 812
 
759 813
 			    $index++;
760 814
 			}
761
-			if (! $totalWeighttoshow && ! $totalVolumetoshow) $index++;
815
+			if (! $totalWeighttoshow && ! $totalVolumetoshow) {
816
+			    $index++;
817
+			}
762 818
 		}
763 819
 
764 820
 		$pdf->SetTextColor(0,0,0);
@@ -784,7 +840,9 @@  discard block
 block discarded – undo
784 840
 
785 841
 		// Force to disable hidetop and hidebottom
786 842
 		$hidebottom=0;
787
-		if ($hidetop) $hidetop=-1;
843
+		if ($hidetop) {
844
+		    $hidetop=-1;
845
+		}
788 846
 
789 847
 		$default_font_size = pdf_getPDFFontSize($outputlangs);
790 848
 
@@ -898,16 +956,14 @@  discard block
 block discarded – undo
898 956
 			{
899 957
 			    $height=pdf_getHeightForLogo($logo);
900 958
 			    $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);	// width=0 (auto)
901
-			}
902
-			else
959
+			} else
903 960
 			{
904 961
 				$pdf->SetTextColor(200,0,0);
905 962
 				$pdf->SetFont('','B', $default_font_size - 2);
906 963
 				$pdf->MultiCell($w, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound",$logo), 0, 'L');
907 964
 				$pdf->MultiCell($w, 3, $outputlangs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L');
908 965
 			}
909
-		}
910
-		else
966
+		} else
911 967
 		{
912 968
 			$text=$this->emetteur->name;
913 969
 			$pdf->MultiCell($w, 4, $outputlangs->convToOutputCharset($text), 0, 'L');
@@ -917,8 +973,7 @@  discard block
 block discarded – undo
917 973
 		if (! empty($conf->barcode->enabled))
918 974
 		{
919 975
 			$posx=105;
920
-		}
921
-		else
976
+		} else
922 977
 		{
923 978
 			$posx=$this->marge_gauche+3;
924 979
 		}
@@ -982,9 +1037,11 @@  discard block
 block discarded – undo
982 1037
 		$origin_id 	= $object->origin_id;
983 1038
 
984 1039
 	    // TODO move to external function
985
-		if (! empty($conf->$origin->enabled))     // commonly $origin='commande'
1040
+		if (! empty($conf->$origin->enabled)) {
1041
+		    // commonly $origin='commande'
986 1042
 		{
987 1043
 			$outputlangs->load('orders');
1044
+		}
988 1045
 
989 1046
 			$classname = ucfirst($origin);
990 1047
 			$linkedobject = new $classname($this->db);
@@ -995,7 +1052,9 @@  discard block
 block discarded – undo
995 1052
 
996 1053
 				$pdf->SetFont('','', $default_font_size - 2);
997 1054
 				$text=$linkedobject->ref;
998
-				if ($linkedobject->ref_client) $text.=' ('.$linkedobject->ref_client.')';
1055
+				if ($linkedobject->ref_client) {
1056
+				    $text.=' ('.$linkedobject->ref_client.')';
1057
+				}
999 1058
 				$Yoff = $Yoff+8;
1000 1059
 				$pdf->SetXY($this->page_largeur - $this->marge_droite - $w,$Yoff);
1001 1060
 				$pdf->MultiCell($w, 2, $outputlangs->transnoentities("RefOrder") ." : ".$outputlangs->transnoentities($text), 0, 'R');
@@ -1011,7 +1070,9 @@  discard block
 block discarded – undo
1011 1070
 			$carac_emetteur='';
1012 1071
 		 	// Add internal contact of origin element if defined
1013 1072
 			$arrayidcontact=array();
1014
-			if (! empty($origin) && is_object($object->$origin)) $arrayidcontact=$object->$origin->getIdContact('internal','SALESREPFOLL');
1073
+			if (! empty($origin) && is_object($object->$origin)) {
1074
+			    $arrayidcontact=$object->$origin->getIdContact('internal','SALESREPFOLL');
1075
+			}
1015 1076
 		 	if (count($arrayidcontact) > 0)
1016 1077
 		 	{
1017 1078
 		 		$object->fetch_user(reset($arrayidcontact));
@@ -1023,7 +1084,9 @@  discard block
 block discarded – undo
1023 1084
 			// Show sender
1024 1085
 			$posy=!empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 40 : 42;
1025 1086
 			$posx=$this->marge_gauche;
1026
-			if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->page_largeur-$this->marge_droite-80;
1087
+			if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) {
1088
+			    $posx=$this->page_largeur-$this->marge_droite-80;
1089
+			}
1027 1090
 
1028 1091
 			$hautcadre=!empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 38 : 40;
1029 1092
 			$widthrecbox=!empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 92 : 82;
@@ -1074,10 +1137,15 @@  discard block
 block discarded – undo
1074 1137
 
1075 1138
 			// Show recipient
1076 1139
 			$widthrecbox=!empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 92 : 100;
1077
-			if ($this->page_largeur < 210) $widthrecbox=84;	// To work with US executive format
1140
+			if ($this->page_largeur < 210) {
1141
+			    $widthrecbox=84;
1142
+			}
1143
+			// To work with US executive format
1078 1144
 			$posy=!empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 40 : 42;
1079 1145
 			$posx=$this->page_largeur - $this->marge_droite - $widthrecbox;
1080
-			if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->marge_gauche;
1146
+			if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) {
1147
+			    $posx=$this->marge_gauche;
1148
+			}
1081 1149
 
1082 1150
 			// Show recipient frame
1083 1151
 			$pdf->SetTextColor(0,0,0);
Please login to merge, or discard this patch.
dolibarr/htdocs/core/modules/expedition/doc/pdf_merou.modules.php 1 patch
Braces   +41 added lines, -31 removed lines patch added patch discarded remove patch
@@ -138,7 +138,10 @@  discard block
 block discarded – undo
138 138
 
139 139
 		// Get source company
140 140
 		$this->emetteur=$mysoc;
141
-		if (! $this->emetteur->country_code) $this->emetteur->country_code=substr($langs->defaultlang,-2);    // By default if not defined
141
+		if (! $this->emetteur->country_code) {
142
+		    $this->emetteur->country_code=substr($langs->defaultlang,-2);
143
+		}
144
+		// By default if not defined
142 145
 	}
143 146
 
144 147
 
@@ -161,9 +164,13 @@  discard block
 block discarded – undo
161 164
 
162 165
 		$object->fetch_thirdparty();
163 166
 
164
-		if (! is_object($outputlangs)) $outputlangs=$langs;
167
+		if (! is_object($outputlangs)) {
168
+		    $outputlangs=$langs;
169
+		}
165 170
 		// For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
166
-		if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1';
171
+		if (! empty($conf->global->MAIN_USE_FPDF)) {
172
+		    $outputlangs->charset_output='ISO-8859-1';
173
+		}
167 174
 
168 175
 		// Load traductions files requiredby by page
169 176
 		$outputlangs->loadLangs(array("main", "bills", "products", "dict", "companies", "propal", "deliveries", "sendings", "productbatch"));
@@ -180,20 +187,23 @@  discard block
 block discarded – undo
180 187
 			//Creation du destinataire
181 188
 			$idcontact = $object->$origin->getIdContact('external','SHIPPING');
182 189
             $this->destinataire = new Contact($this->db);
183
-			if (! empty($idcontact[0])) $this->destinataire->fetch($idcontact[0]);
190
+			if (! empty($idcontact[0])) {
191
+			    $this->destinataire->fetch($idcontact[0]);
192
+			}
184 193
 
185 194
 			//Creation du livreur
186 195
 			$idcontact = $object->$origin->getIdContact('internal','LIVREUR');
187 196
 			$this->livreur = new User($this->db);
188
-			if (! empty($idcontact[0])) $this->livreur->fetch($idcontact[0]);
197
+			if (! empty($idcontact[0])) {
198
+			    $this->livreur->fetch($idcontact[0]);
199
+			}
189 200
 
190 201
 			// Definition de $dir et $file
191 202
 			if ($object->specimen)
192 203
 			{
193 204
 				$dir = $conf->expedition->dir_output."/sending";
194 205
 				$file = $dir . "/SPECIMEN.pdf";
195
-			}
196
-			else
206
+			} else
197 207
 			{
198 208
 				$expref = dol_sanitizeFileName($object->ref);
199 209
 				$dir = $conf->expedition->dir_output . "/sending/" . $expref;
@@ -229,7 +239,9 @@  discard block
 block discarded – undo
229 239
 				$heightforinfotot = 0;	// Height reserved to output the info and total part
230 240
 		        $heightforfreetext= (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT)?$conf->global->MAIN_PDF_FREETEXT_HEIGHT:5);	// Height reserved to output the free text on last page
231 241
 	            $heightforfooter = $this->marge_basse + 8;	// Height reserved to output the footer (value include bottom margin)
232
-	            if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS >0) $heightforfooter+= 6;
242
+	            if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS >0) {
243
+	                $heightforfooter+= 6;
244
+	            }
233 245
                 $pdf->SetAutoPageBreak(1,0);
234 246
 
235 247
 			    if (class_exists('TCPDF'))
@@ -249,14 +261,18 @@  discard block
 block discarded – undo
249 261
 				$pagenb=0;
250 262
 				$pdf->SetDrawColor(128,128,128);
251 263
 
252
-				if (method_exists($pdf,'AliasNbPages')) $pdf->AliasNbPages();
264
+				if (method_exists($pdf,'AliasNbPages')) {
265
+				    $pdf->AliasNbPages();
266
+				}
253 267
 
254 268
 				$pdf->SetTitle($outputlangs->convToOutputCharset($object->ref));
255 269
 				$pdf->SetSubject($outputlangs->transnoentities("Shipment"));
256 270
 				$pdf->SetCreator("Dolibarr ".DOL_VERSION);
257 271
 				$pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
258 272
 				$pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("Shipment"));
259
-				if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
273
+				if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) {
274
+				    $pdf->SetCompression(false);
275
+				}
260 276
 
261 277
 				$pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);   // Left, Top, Right
262 278
 
@@ -287,8 +303,7 @@  discard block
 block discarded – undo
287 303
 
288 304
 					$tab_height = $tab_height - $height_note;
289 305
 					$tab_top = $nexY+6;
290
-				}
291
-				else
306
+				} else
292 307
 				{
293 308
 					$height_note=0;
294 309
 				}
@@ -365,8 +380,7 @@  discard block
 block discarded – undo
365 380
 						if ($pagenb == 1)
366 381
 						{
367 382
 							$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1);
368
-						}
369
-						else
383
+						} else
370 384
 						{
371 385
 							$this->_tableau($pdf, $tab_top_newpage - 1, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
372 386
 						}
@@ -380,8 +394,7 @@  discard block
 block discarded – undo
380 394
 						if ($pagenb == 1)
381 395
 						{
382 396
 							$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1);
383
-						}
384
-						else
397
+						} else
385 398
 						{
386 399
 							$this->_tableau($pdf, $tab_top_newpage - 1, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
387 400
 						}
@@ -397,8 +410,7 @@  discard block
 block discarded – undo
397 410
 				{
398 411
 					$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0);
399 412
 					$bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
400
-				}
401
-				else
413
+				} else
402 414
 				{
403 415
 					$this->_tableau($pdf, $tab_top_newpage - 1, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0);
404 416
 					$bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
@@ -406,7 +418,9 @@  discard block
 block discarded – undo
406 418
 
407 419
 				// Pied de page
408 420
 				$this->_pagefoot($pdf, $object, $outputlangs);
409
-				if (method_exists($pdf,'AliasNbPages')) $pdf->AliasNbPages();
421
+				if (method_exists($pdf,'AliasNbPages')) {
422
+				    $pdf->AliasNbPages();
423
+				}
410 424
 
411 425
 				$pdf->Close();
412 426
 
@@ -423,20 +437,19 @@  discard block
 block discarded – undo
423 437
 				global $action;
424 438
 				$reshook=$hookmanager->executeHooks('afterPDFCreation',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
425 439
 
426
-                if (! empty($conf->global->MAIN_UMASK))
427
-                    @chmod($file, octdec($conf->global->MAIN_UMASK));
440
+                if (! empty($conf->global->MAIN_UMASK)) {
441
+                                    @chmod($file, octdec($conf->global->MAIN_UMASK));
442
+                }
428 443
 
429 444
 				$this->result = array('fullpath'=>$file);
430 445
 
431 446
 				return 1;
432
-			}
433
-			else
447
+			} else
434 448
 			{
435 449
 				$this->error=$outputlangs->transnoentities("ErrorCanNotCreateDir",$dir);
436 450
 				return 0;
437 451
 			}
438
-		}
439
-		else
452
+		} else
440 453
 		{
441 454
 			$this->error=$outputlangs->transnoentities("ErrorConstantNotDefined","EXP_OUTPUTDIR");
442 455
 			return 0;
@@ -556,16 +569,14 @@  discard block
 block discarded – undo
556 569
 			{
557 570
 			    $height=pdf_getHeightForLogo($logo);
558 571
 			    $pdf->Image($logo,10, 5, 0, $height);	// width=0 (auto)
559
-			}
560
-			else
572
+			} else
561 573
 			{
562 574
 				$pdf->SetTextColor(200,0,0);
563 575
 				$pdf->SetFont('','B', $default_font_size - 2);
564 576
 				$pdf->MultiCell(100, 3, $langs->transnoentities("ErrorLogoFileNotFound",$logo), 0, 'L');
565 577
 				$pdf->MultiCell(100, 3, $langs->transnoentities("ErrorGoToModuleSetup"), 0, 'L');
566 578
 			}
567
-		}
568
-		else
579
+		} else
569 580
 		{
570 581
 			$text=$this->emetteur->name;
571 582
 			$pdf->MultiCell(70, 3, $outputlangs->convToOutputCharset($text), 0, 'L');
@@ -665,8 +676,7 @@  discard block
 block discarded – undo
665 676
 					$pdf->writeHTMLCell(50, 8, '', '', $label, '', 'L');
666 677
 				}
667 678
 			}
668
-		}
669
-		else
679
+		} else
670 680
 		{
671 681
 			$pdf->MultiCell(50, 8, $outputlangs->transnoentities("Deliverer")." ".$outputlangs->convToOutputCharset($this->livreur->getFullName($outputlangs)), '', 'L');
672 682
 		}
Please login to merge, or discard this patch.
htdocs/core/modules/expedition/doc/doc_generic_shipment_odt.modules.php 1 patch
Braces   +70 added lines, -62 removed lines patch added patch discarded remove patch
@@ -99,7 +99,10 @@  discard block
 block discarded – undo
99 99
 
100 100
 		// Recupere emetteur
101 101
 		$this->emetteur=$mysoc;
102
-		if (! $this->emetteur->country_code) $this->emetteur->country_code=substr($langs->defaultlang,-2);    // By default if not defined
102
+		if (! $this->emetteur->country_code) {
103
+		    $this->emetteur->country_code=substr($langs->defaultlang,-2);
104
+		}
105
+		// By default if not defined
103 106
 	}
104 107
 
105 108
 
@@ -137,11 +140,14 @@  discard block
 block discarded – undo
137 140
 			if (! $tmpdir) {
138 141
 				unset($listofdir[$key]); continue;
139 142
 			}
140
-			if (! is_dir($tmpdir)) $texttitle.=img_warning($langs->trans("ErrorDirNotFound",$tmpdir),0);
141
-			else
143
+			if (! is_dir($tmpdir)) {
144
+			    $texttitle.=img_warning($langs->trans("ErrorDirNotFound",$tmpdir),0);
145
+			} else
142 146
 			{
143 147
 				$tmpfiles=dol_dir_list($tmpdir,'files',0,'\.(ods|odt)');
144
-				if (count($tmpfiles)) $listoffiles=array_merge($listoffiles,$tmpfiles);
148
+				if (count($tmpfiles)) {
149
+				    $listoffiles=array_merge($listoffiles,$tmpfiles);
150
+				}
145 151
 			}
146 152
 		}
147 153
 		$texthelp=$langs->trans("ListOfDirectoriesForModelGenODT");
@@ -223,7 +229,9 @@  discard block
 block discarded – undo
223 229
 		$hookmanager->initHooks(array('odtgeneration'));
224 230
 		global $action;
225 231
 
226
-		if (! is_object($outputlangs)) $outputlangs=$langs;
232
+		if (! is_object($outputlangs)) {
233
+		    $outputlangs=$langs;
234
+		}
227 235
 		$sav_charset_output=$outputlangs->charset_output;
228 236
 		$outputlangs->charset_output='UTF-8';
229 237
 
@@ -247,7 +255,9 @@  discard block
 block discarded – undo
247 255
 
248 256
 			$dir = $conf->expedition->dir_output."/sending";
249 257
 			$objectref = dol_sanitizeFileName($object->ref);
250
-			if (! preg_match('/specimen/i',$objectref)) $dir.= "/" . $objectref;
258
+			if (! preg_match('/specimen/i',$objectref)) {
259
+			    $dir.= "/" . $objectref;
260
+			}
251 261
 			$file = $dir . "/" . $objectref . ".odt";
252 262
 
253 263
 			if (! file_exists($dir))
@@ -273,10 +283,11 @@  discard block
 block discarded – undo
273 283
 				if ( ! empty($conf->global->MAIN_DOC_USE_TIMING))
274 284
 				{
275 285
 				    $format=$conf->global->MAIN_DOC_USE_TIMING;
276
-				    if ($format == '1') $format='%Y%m%d%H%M%S';
286
+				    if ($format == '1') {
287
+				        $format='%Y%m%d%H%M%S';
288
+				    }
277 289
 					$filename=$newfiletmp.'-'.dol_print_date(dol_now(),$format).'.'.$newfileformat;
278
-				}
279
-				else
290
+				} else
280 291
 				{
281 292
 					$filename=$newfiletmp.'.'.$newfileformat;
282 293
 				}
@@ -302,9 +313,9 @@  discard block
 block discarded – undo
302 313
 				$contactobject = null;
303 314
 				if (! empty($usecontact)) {
304 315
 					// On peut utiliser le nom de la societe du contact
305
-					if (! empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT))
306
-						$socobject = $object->contact;
307
-					else {
316
+					if (! empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) {
317
+											$socobject = $object->contact;
318
+					} else {
308 319
 						$socobject = $object->thirdparty;
309 320
 						// if we have a SHIIPPING contact and we dont use it as recipient we store the contact object for later use
310 321
 						$contactobject = $object->contact;
@@ -346,8 +357,7 @@  discard block
 block discarded – undo
346 357
 						'DELIMITER_RIGHT' => '}'
347 358
 						)
348 359
 					);
349
-				}
350
-				catch(Exception $e)
360
+				} catch(Exception $e)
351 361
 				{
352 362
 					$this->error=$e->getMessage();
353 363
 					dol_syslog($e->getMessage(), LOG_INFO);
@@ -363,8 +373,7 @@  discard block
 block discarded – undo
363 373
 				// Make substitutions into odt of freetext
364 374
 				try {
365 375
 					$odfHandler->setVars('free_text', $newfreetext, true, 'UTF-8');
366
-				}
367
-				catch(OdfException $e)
376
+				} catch(OdfException $e)
368 377
 				{
369 378
 					dol_syslog($e->getMessage(), LOG_INFO);
370 379
 				}
@@ -375,18 +384,19 @@  discard block
 block discarded – undo
375 384
 				foreach($tmparray as $key=>$value)
376 385
 				{
377 386
 					try {
378
-						if (preg_match('/logo$/',$key)) // Image
387
+						if (preg_match('/logo$/',$key)) {
388
+						    // Image
379 389
 						{
380 390
 							//var_dump($value);exit;
381 391
 							if (file_exists($value)) $odfHandler->setImage($key, $value);
382
-							else $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8');
383
-						}
384
-						else    // Text
392
+						} else {
393
+							    $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8');
394
+							}
395
+						} else    // Text
385 396
 						{
386 397
 							$odfHandler->setVars($key, $value, true, 'UTF-8');
387 398
 						}
388
-					}
389
-					catch (OdfException $e)
399
+					} catch (OdfException $e)
390 400
 					{
391 401
                         dol_syslog($e->getMessage(), LOG_INFO);
392 402
 					}
@@ -397,18 +407,19 @@  discard block
 block discarded – undo
397 407
 				foreach($tmparray as $key=>$value)
398 408
 				{
399 409
 					try {
400
-						if (preg_match('/logo$/',$key))	// Image
410
+						if (preg_match('/logo$/',$key)) {
411
+						    // Image
401 412
 						{
402 413
 							//var_dump($value);exit;
403 414
 							if (file_exists($value)) $odfHandler->setImage($key, $value);
404
-							else $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8');
405
-						}
406
-						else	// Text
415
+						} else {
416
+							    $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8');
417
+							}
418
+						} else	// Text
407 419
 						{
408 420
 							$odfHandler->setVars($key, $value, true, 'UTF-8');
409 421
 						}
410
-					}
411
-					catch (OdfException $e)
422
+					} catch (OdfException $e)
412 423
 					{
413 424
                         dol_syslog($e->getMessage(), LOG_INFO);
414 425
 					}
@@ -418,17 +429,18 @@  discard block
 block discarded – undo
418 429
 				foreach($tmparray as $key=>$value)
419 430
 				{
420 431
 					try {
421
-						if (preg_match('/logo$/',$key))	// Image
432
+						if (preg_match('/logo$/',$key)) {
433
+						    // Image
422 434
 						{
423 435
 							if (file_exists($value)) $odfHandler->setImage($key, $value);
424
-							else $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8');
425
-						}
426
-						else	// Text
436
+						} else {
437
+							    $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8');
438
+							}
439
+						} else	// Text
427 440
 						{
428 441
 							$odfHandler->setVars($key, $value, true, 'UTF-8');
429 442
 						}
430
-					}
431
-					catch (OdfException $e)
443
+					} catch (OdfException $e)
432 444
 					{
433 445
                         dol_syslog($e->getMessage(), LOG_INFO);
434 446
 					}
@@ -439,17 +451,18 @@  discard block
 block discarded – undo
439 451
 					foreach($tmparray as $key=>$value)
440 452
 					{
441 453
 						try {
442
-							if (preg_match('/logo$/',$key))	// Image
454
+							if (preg_match('/logo$/',$key)) {
455
+							    // Image
443 456
 							{
444 457
 								if (file_exists($value)) $odfHandler->setImage($key, $value);
445
-								else $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8');
446
-							}
447
-							else	// Text
458
+							} else {
459
+								    $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8');
460
+								}
461
+							} else	// Text
448 462
 							{
449 463
 								$odfHandler->setVars($key, $value, true, 'UTF-8');
450 464
 							}
451
-						}
452
-						catch(OdfException $e)
465
+						} catch(OdfException $e)
453 466
 						{
454 467
                             dol_syslog($e->getMessage(), LOG_INFO);
455 468
 						}
@@ -465,17 +478,18 @@  discard block
 block discarded – undo
465 478
 				foreach($tmparray as $key=>$value)
466 479
 				{
467 480
 					try {
468
-						if (preg_match('/logo$/',$key)) // Image
481
+						if (preg_match('/logo$/',$key)) {
482
+						    // Image
469 483
 						{
470 484
 							if (file_exists($value)) $odfHandler->setImage($key, $value);
471
-							else $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8');
472
-						}
473
-						else    // Text
485
+						} else {
486
+							    $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8');
487
+							}
488
+						} else    // Text
474 489
 						{
475 490
 							$odfHandler->setVars($key, $value, true, 'UTF-8');
476 491
 						}
477
-					}
478
-					catch(OdfException $e)
492
+					} catch(OdfException $e)
479 493
 					{
480 494
                         dol_syslog($e->getMessage(), LOG_INFO);
481 495
 					}
@@ -486,8 +500,7 @@  discard block
 block discarded – undo
486 500
 					$foundtagforlines = 1;
487 501
 					try {
488 502
 						$listlines = $odfHandler->setSegment('lines');
489
-					}
490
-					catch(OdfException $e)
503
+					} catch(OdfException $e)
491 504
 					{
492 505
 						// We may arrive here if tags for lines not present into template
493 506
 						$foundtagforlines = 0;
@@ -507,12 +520,10 @@  discard block
 block discarded – undo
507 520
 								try
508 521
 								{
509 522
 									$listlines->setVars($key, $val, true, 'UTF-8');
510
-								}
511
-								catch(OdfException $e)
523
+								} catch(OdfException $e)
512 524
 								{
513 525
 									dol_syslog($e->getMessage(), LOG_INFO);
514
-								}
515
-								catch(SegmentException $e)
526
+								} catch(SegmentException $e)
516 527
 								{
517 528
 									dol_syslog($e->getMessage(), LOG_INFO);
518 529
 								}
@@ -521,8 +532,7 @@  discard block
 block discarded – undo
521 532
 						}
522 533
 						$odfHandler->mergeSegment($listlines);
523 534
 					}
524
-				}
525
-				catch (OdfException $e)
535
+				} catch (OdfException $e)
526 536
 				{
527 537
 					$this->error=$e->getMessage();
528 538
 					dol_syslog($this->error, LOG_WARNING);
@@ -535,8 +545,7 @@  discard block
 block discarded – undo
535 545
 				{
536 546
 					try {
537 547
 						$odfHandler->setVars($key, $value, true, 'UTF-8');
538
-					}
539
-					catch (OdfException $e)
548
+					} catch (OdfException $e)
540 549
 					{
541 550
                         dol_syslog($e->getMessage(), LOG_INFO);
542 551
 					}
@@ -555,8 +564,7 @@  discard block
 block discarded – undo
555 564
                         dol_syslog($e->getMessage(), LOG_INFO);
556 565
 						return -1;
557 566
 					}
558
-				}
559
-				else {
567
+				} else {
560 568
 					try {
561 569
 					$odfHandler->saveToDisk($file);
562 570
 					} catch (Exception $e) {
@@ -568,16 +576,16 @@  discard block
 block discarded – undo
568 576
 				$parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray);
569 577
 				$reshook=$hookmanager->executeHooks('afterODTCreation',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
570 578
 
571
-				if (! empty($conf->global->MAIN_UMASK))
572
-					@chmod($file, octdec($conf->global->MAIN_UMASK));
579
+				if (! empty($conf->global->MAIN_UMASK)) {
580
+									@chmod($file, octdec($conf->global->MAIN_UMASK));
581
+				}
573 582
 
574 583
 				$odfHandler=null;	// Destroy object
575 584
 
576 585
 				$this->result = array('fullpath'=>$file);
577 586
 
578 587
 				return 1;   // Success
579
-			}
580
-			else
588
+			} else
581 589
 			{
582 590
 				$this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
583 591
 				return -1;
Please login to merge, or discard this patch.
dolibarr/htdocs/core/modules/expedition/mod_expedition_safor.php 1 patch
Braces   +13 added lines, -6 removed lines patch added patch discarded remove patch
@@ -131,10 +131,12 @@  discard block
 block discarded – undo
131 131
 		if ($resql)
132 132
 		{
133 133
 			$obj = $db->fetch_object($resql);
134
-			if ($obj) $max = intval($obj->max);
135
-			else $max=0;
136
-		}
137
-		else
134
+			if ($obj) {
135
+			    $max = intval($obj->max);
136
+			} else {
137
+			    $max=0;
138
+			}
139
+		} else
138 140
 		{
139 141
 			dol_syslog("mod_expedition_safor::getNextValue", LOG_DEBUG);
140 142
 			return -1;
@@ -143,8 +145,13 @@  discard block
 block discarded – undo
143 145
 		$date=time();
144 146
 		$yymm = strftime("%y%m",$date);
145 147
 
146
-		if ($max >= (pow(10, 4) - 1)) $num=$max+1;	// If counter > 9999, we do not format on 4 chars, we take number as it is
147
-		else $num = sprintf("%04s",$max+1);
148
+		if ($max >= (pow(10, 4) - 1)) {
149
+		    $num=$max+1;
150
+		}
151
+		// If counter > 9999, we do not format on 4 chars, we take number as it is
152
+		else {
153
+		    $num = sprintf("%04s",$max+1);
154
+		}
148 155
 
149 156
 		dol_syslog("mod_expedition_safor::getNextValue return ".$this->prefix.$yymm."-".$num);
150 157
 		return $this->prefix.$yymm."-".$num;
Please login to merge, or discard this patch.