Passed
Branch develop (66e4de)
by Laurent
33:03
created
htdocs/core/lib/security.lib.php 1 patch
Braces   +184 added lines, -63 removed lines patch added patch discarded remove patch
@@ -37,9 +37,11 @@  discard block
 block discarded – undo
37 37
  */
38 38
 function dol_encode($chain, $key = '1')
39 39
 {
40
-	if (is_numeric($key) && $key == '1')	// rule 1 is offset of 17 for char
40
+	if (is_numeric($key) && $key == '1') {
41
+		// rule 1 is offset of 17 for char
41 42
 	{
42 43
 		$output_tab = array();
44
+	}
43 45
 		$strlength = dol_strlen($chain);
44 46
 		for ($i = 0; $i < $strlength; $i++)
45 47
 		{
@@ -74,9 +76,11 @@  discard block
 block discarded – undo
74 76
 {
75 77
 	$chain = base64_decode($chain);
76 78
 
77
-	if (is_numeric($key) && $key == '1')	// rule 1 is offset of 17 for char
79
+	if (is_numeric($key) && $key == '1') {
80
+		// rule 1 is offset of 17 for char
78 81
 	{
79 82
 		$output_tab = array();
83
+	}
80 84
 		$strlength = dol_strlen($chain);
81 85
 		for ($i = 0; $i < $strlength; $i++)
82 86
 		{
@@ -121,15 +125,27 @@  discard block
 block discarded – undo
121 125
 	}
122 126
 
123 127
 	// Salt value
124
-	if (!empty($conf->global->MAIN_SECURITY_SALT) && $type != '4' && $type !== 'md5openldap') $chain = $conf->global->MAIN_SECURITY_SALT.$chain;
128
+	if (!empty($conf->global->MAIN_SECURITY_SALT) && $type != '4' && $type !== 'md5openldap') {
129
+		$chain = $conf->global->MAIN_SECURITY_SALT.$chain;
130
+	}
125 131
 
126
-	if ($type == '1' || $type == 'sha1') return sha1($chain);
127
-	elseif ($type == '2' || $type == 'sha1md5') return sha1(md5($chain));
128
-	elseif ($type == '3' || $type == 'md5') return md5($chain);
129
-	elseif ($type == '4' || $type == 'md5openldap') return '{md5}'.base64_encode(mhash(MHASH_MD5, $chain)); // For OpenLdap with md5 (based on an unencrypted password in base)
130
-	elseif ($type == '5') return hash('sha256', $chain);
131
-	elseif (!empty($conf->global->MAIN_SECURITY_HASH_ALGO) && $conf->global->MAIN_SECURITY_HASH_ALGO == 'sha1') return sha1($chain);
132
-	elseif (!empty($conf->global->MAIN_SECURITY_HASH_ALGO) && $conf->global->MAIN_SECURITY_HASH_ALGO == 'sha1md5') return sha1(md5($chain));
132
+	if ($type == '1' || $type == 'sha1') {
133
+		return sha1($chain);
134
+	} elseif ($type == '2' || $type == 'sha1md5') {
135
+		return sha1(md5($chain));
136
+	} elseif ($type == '3' || $type == 'md5') {
137
+		return md5($chain);
138
+	} elseif ($type == '4' || $type == 'md5openldap') {
139
+		return '{md5}'.base64_encode(mhash(MHASH_MD5, $chain));
140
+	}
141
+	// For OpenLdap with md5 (based on an unencrypted password in base)
142
+	elseif ($type == '5') {
143
+		return hash('sha256', $chain);
144
+	} elseif (!empty($conf->global->MAIN_SECURITY_HASH_ALGO) && $conf->global->MAIN_SECURITY_HASH_ALGO == 'sha1') {
145
+		return sha1($chain);
146
+	} elseif (!empty($conf->global->MAIN_SECURITY_HASH_ALGO) && $conf->global->MAIN_SECURITY_HASH_ALGO == 'sha1md5') {
147
+		return sha1(md5($chain));
148
+	}
133 149
 
134 150
 	// No particular encoding defined, use default
135 151
 	return md5($chain);
@@ -151,9 +167,16 @@  discard block
 block discarded – undo
151 167
 	global $conf;
152 168
 
153 169
 	if ($type == '0' && !empty($conf->global->MAIN_SECURITY_HASH_ALGO) && $conf->global->MAIN_SECURITY_HASH_ALGO == 'password_hash' && function_exists('password_verify')) {
154
-		if ($hash[0] == '$') return password_verify($chain, $hash);
155
-		elseif (strlen($hash) == 32) return dol_verifyHash($chain, $hash, '3'); // md5
156
-		elseif (strlen($hash) == 40) return dol_verifyHash($chain, $hash, '2'); // sha1md5
170
+		if ($hash[0] == '$') {
171
+			return password_verify($chain, $hash);
172
+		} elseif (strlen($hash) == 32) {
173
+			return dol_verifyHash($chain, $hash, '3');
174
+		}
175
+		// md5
176
+		elseif (strlen($hash) == 40) {
177
+			return dol_verifyHash($chain, $hash, '2');
178
+		}
179
+		// sha1md5
157 180
 
158 181
 		return false;
159 182
 	}
@@ -189,34 +212,54 @@  discard block
 block discarded – undo
189 212
 
190 213
 	$parentfortableentity = '';
191 214
 
192
-	if ($features == 'facturerec') $features = 'facture';
193
-	if ($features == 'mo') $features = 'mrp';
194
-	if ($features == 'member') $features = 'adherent';
215
+	if ($features == 'facturerec') {
216
+		$features = 'facture';
217
+	}
218
+	if ($features == 'mo') {
219
+		$features = 'mrp';
220
+	}
221
+	if ($features == 'member') {
222
+		$features = 'adherent';
223
+	}
195 224
 	if ($features == 'subscription') { $features = 'adherent'; $feature2 = 'cotisation'; };
196 225
 	if ($features == 'websitepage') { $features = 'website'; $tableandshare = 'website_page'; $parentfortableentity = 'fk_website@website'; }
197
-	if ($features == 'project') $features = 'projet';
198
-	if ($features == 'product') $features = 'produit';
226
+	if ($features == 'project') {
227
+		$features = 'projet';
228
+	}
229
+	if ($features == 'product') {
230
+		$features = 'produit';
231
+	}
199 232
 
200 233
 	// Get more permissions checks from hooks
201 234
 	$parameters = array('features'=>$features, 'objectid'=>$objectid, 'idtype'=>$dbt_select);
202 235
 	$reshook = $hookmanager->executeHooks('restrictedArea', $parameters);
203 236
 
204 237
 	if (isset($hookmanager->resArray['result'])) {
205
-		if ($hookmanager->resArray['result'] == 0) accessforbidden(); // Module returns 0, so access forbidden
238
+		if ($hookmanager->resArray['result'] == 0) {
239
+			accessforbidden();
240
+		}
241
+		// Module returns 0, so access forbidden
206 242
 	}
207 243
 	if ($reshook > 0) {		// No other test done.
208 244
 		return 1;
209 245
 	}
210 246
 
211
-	if ($dbt_select != 'rowid' && $dbt_select != 'id') $objectid = "'".$objectid."'";
247
+	if ($dbt_select != 'rowid' && $dbt_select != 'id') {
248
+		$objectid = "'".$objectid."'";
249
+	}
212 250
 
213 251
 	// Features/modules to check
214 252
 	$featuresarray = array($features);
215
-	if (preg_match('/&/', $features)) $featuresarray = explode("&", $features);
216
-	elseif (preg_match('/\|/', $features)) $featuresarray = explode("|", $features);
253
+	if (preg_match('/&/', $features)) {
254
+		$featuresarray = explode("&", $features);
255
+	} elseif (preg_match('/\|/', $features)) {
256
+		$featuresarray = explode("|", $features);
257
+	}
217 258
 
218 259
 	// More subfeatures to check
219
-	if (!empty($feature2)) $feature2 = explode("|", $feature2);
260
+	if (!empty($feature2)) {
261
+		$feature2 = explode("|", $feature2);
262
+	}
220 263
 
221 264
 	// More parameters
222 265
 	$params = explode('&', $tableandshare);
@@ -229,7 +272,9 @@  discard block
 block discarded – undo
229 272
 	$readok = 1; $nbko = 0;
230 273
 	foreach ($featuresarray as $feature) {	// first we check nb of test ko
231 274
 		$featureforlistofmodule = $feature;
232
-		if ($featureforlistofmodule == 'produit') $featureforlistofmodule = 'product';
275
+		if ($featureforlistofmodule == 'produit') {
276
+			$featureforlistofmodule = 'product';
277
+		}
233 278
 		if (!empty($user->socid) && !empty($conf->global->MAIN_MODULES_FOR_EXTERNAL) && !in_array($featureforlistofmodule, $listofmodules)) {	// If limits on modules for external users, module must be into list of modules for external users
234 279
 			$readok = 0; $nbko++;
235 280
 			continue;
@@ -250,7 +295,10 @@  discard block
 block discarded – undo
250 295
 		} elseif (!empty($feature2)) { 													// This is for permissions on 2 levels
251 296
 			$tmpreadok = 1;
252 297
 			foreach ($feature2 as $subfeature) {
253
-				if ($subfeature == 'user' && $user->id == $objectid) continue; // A user can always read its own card
298
+				if ($subfeature == 'user' && $user->id == $objectid) {
299
+					continue;
300
+				}
301
+				// A user can always read its own card
254 302
 				if (!empty($subfeature) && empty($user->rights->$feature->$subfeature->lire) && empty($user->rights->$feature->$subfeature->read)) { $tmpreadok = 0; } elseif (empty($subfeature) && empty($user->rights->$feature->lire) && empty($user->rights->$feature->read)) { $tmpreadok = 0; } else { $tmpreadok = 1; break; } // Break is to bypass second test if the first is ok
255 303
 			}
256 304
 			if (!$tmpreadok) {	// We found a test on feature that is ko
@@ -265,9 +313,13 @@  discard block
 block discarded – undo
265 313
 	}
266 314
 
267 315
 	// If a or and at least one ok
268
-	if (preg_match('/\|/', $features) && $nbko < count($featuresarray)) $readok = 1;
316
+	if (preg_match('/\|/', $features) && $nbko < count($featuresarray)) {
317
+		$readok = 1;
318
+	}
269 319
 
270
-	if (!$readok) accessforbidden();
320
+	if (!$readok) {
321
+		accessforbidden();
322
+	}
271 323
 	//print "Read access is ok";
272 324
 
273 325
 	// Check write permission from module (we need to know write permission to create but also to delete drafts record or to upload files)
@@ -297,8 +349,14 @@  discard block
 block discarded – undo
297 349
 				if (!$user->rights->ecm->upload) { $createok = 0; $nbko++; }
298 350
 			} elseif (!empty($feature2)) {														// This is for permissions on one level
299 351
 				foreach ($feature2 as $subfeature) {
300
-					if ($subfeature == 'user' && $user->id == $objectid && $user->rights->user->self->creer) continue; // User can edit its own card
301
-					if ($subfeature == 'user' && $user->id == $objectid && $user->rights->user->self->password) continue; // User can edit its own password
352
+					if ($subfeature == 'user' && $user->id == $objectid && $user->rights->user->self->creer) {
353
+						continue;
354
+					}
355
+					// User can edit its own card
356
+					if ($subfeature == 'user' && $user->id == $objectid && $user->rights->user->self->password) {
357
+						continue;
358
+					}
359
+					// User can edit its own password
302 360
 
303 361
 					if (empty($user->rights->$feature->$subfeature->creer)
304 362
 					&& empty($user->rights->$feature->$subfeature->write)
@@ -323,9 +381,13 @@  discard block
 block discarded – undo
323 381
 		}
324 382
 
325 383
 		// If a or and at least one ok
326
-		if (preg_match('/\|/', $features) && $nbko < count($featuresarray)) $createok = 1;
384
+		if (preg_match('/\|/', $features) && $nbko < count($featuresarray)) {
385
+			$createok = 1;
386
+		}
327 387
 
328
-		if ($wemustcheckpermissionforcreate && !$createok) accessforbidden();
388
+		if ($wemustcheckpermissionforcreate && !$createok) {
389
+			accessforbidden();
390
+		}
329 391
 		//print "Write access is ok";
330 392
 	}
331 393
 
@@ -333,9 +395,13 @@  discard block
 block discarded – undo
333 395
 	$createuserok = 1;
334 396
 	if (GETPOST('action', 'aZ09') == 'confirm_create_user' && GETPOST("confirm", 'aZ09') == 'yes')
335 397
 	{
336
-		if (!$user->rights->user->user->creer) $createuserok = 0;
398
+		if (!$user->rights->user->user->creer) {
399
+			$createuserok = 0;
400
+		}
337 401
 
338
-		if (!$createuserok) accessforbidden();
402
+		if (!$createuserok) {
403
+			accessforbidden();
404
+		}
339 405
 		//print "Create user access is ok";
340 406
 	}
341 407
 
@@ -347,51 +413,76 @@  discard block
 block discarded – undo
347 413
 		{
348 414
 			if ($feature == 'contact')
349 415
 			{
350
-				if (!$user->rights->societe->contact->supprimer) $deleteok = 0;
416
+				if (!$user->rights->societe->contact->supprimer) {
417
+					$deleteok = 0;
418
+				}
351 419
 			} elseif ($feature == 'produit|service')
352 420
 			{
353
-				if (!$user->rights->produit->supprimer && !$user->rights->service->supprimer) $deleteok = 0;
421
+				if (!$user->rights->produit->supprimer && !$user->rights->service->supprimer) {
422
+					$deleteok = 0;
423
+				}
354 424
 			} elseif ($feature == 'commande_fournisseur')
355 425
 			{
356
-				if (!$user->rights->fournisseur->commande->supprimer) $deleteok = 0;
426
+				if (!$user->rights->fournisseur->commande->supprimer) {
427
+					$deleteok = 0;
428
+				}
357 429
 			} elseif ($feature == 'banque')
358 430
 			{
359
-				if (!$user->rights->banque->modifier) $deleteok = 0;
431
+				if (!$user->rights->banque->modifier) {
432
+					$deleteok = 0;
433
+				}
360 434
 			} elseif ($feature == 'cheque')
361 435
 			{
362
-				if (!$user->rights->banque->cheque) $deleteok = 0;
436
+				if (!$user->rights->banque->cheque) {
437
+					$deleteok = 0;
438
+				}
363 439
 			} elseif ($feature == 'ecm')
364 440
 			{
365
-				if (!$user->rights->ecm->upload) $deleteok = 0;
441
+				if (!$user->rights->ecm->upload) {
442
+					$deleteok = 0;
443
+				}
366 444
 			} elseif ($feature == 'ftp')
367 445
 			{
368
-				if (!$user->rights->ftp->write) $deleteok = 0;
446
+				if (!$user->rights->ftp->write) {
447
+					$deleteok = 0;
448
+				}
369 449
 			} elseif ($feature == 'salaries')
370 450
 			{
371
-				if (!$user->rights->salaries->delete) $deleteok = 0;
451
+				if (!$user->rights->salaries->delete) {
452
+					$deleteok = 0;
453
+				}
372 454
 			} elseif ($feature == 'salaries')
373 455
 			{
374
-				if (!$user->rights->salaries->delete) $deleteok = 0;
375
-			} elseif (!empty($feature2))							// This is for permissions on 2 levels
456
+				if (!$user->rights->salaries->delete) {
457
+					$deleteok = 0;
458
+				}
459
+			} elseif (!empty($feature2)) {
460
+				// This is for permissions on 2 levels
376 461
 			{
377 462
 				foreach ($feature2 as $subfeature)
378 463
 				{
379 464
 					if (empty($user->rights->$feature->$subfeature->supprimer) && empty($user->rights->$feature->$subfeature->delete)) $deleteok = 0;
380
-					else { $deleteok = 1; break; } // For bypass the second test if the first is ok
465
+			} else { $deleteok = 1; break; } // For bypass the second test if the first is ok
381 466
 				}
382
-			} elseif (!empty($feature))							// This is used for permissions on 1 level
467
+			} elseif (!empty($feature)) {
468
+				// This is used for permissions on 1 level
383 469
 			{
384 470
 				//print '<br>feature='.$feature.' creer='.$user->rights->$feature->supprimer.' write='.$user->rights->$feature->delete;
385 471
 				if (empty($user->rights->$feature->supprimer)
386 472
 					&& empty($user->rights->$feature->delete)
387 473
 					&& empty($user->rights->$feature->run)) $deleteok = 0;
388 474
 			}
475
+			}
389 476
 		}
390 477
 
391 478
 		// If a or and at least one ok
392
-		if (preg_match('/\|/', $features) && $nbko < count($featuresarray)) $deleteok = 1;
479
+		if (preg_match('/\|/', $features) && $nbko < count($featuresarray)) {
480
+			$deleteok = 1;
481
+		}
393 482
 
394
-		if (!$deleteok && !($isdraft && $createok)) accessforbidden();
483
+		if (!$deleteok && !($isdraft && $createok)) {
484
+			accessforbidden();
485
+		}
395 486
 		//print "Delete access is ok";
396 487
 	}
397 488
 
@@ -436,9 +527,15 @@  discard block
 block discarded – undo
436 527
 		$sql = '';
437 528
 
438 529
 		// For backward compatibility
439
-		if ($feature == 'member')  $feature = 'adherent';
440
-		if ($feature == 'project') $feature = 'projet';
441
-		if ($feature == 'task')    $feature = 'projet_task';
530
+		if ($feature == 'member') {
531
+			$feature = 'adherent';
532
+		}
533
+		if ($feature == 'project') {
534
+			$feature = 'projet';
535
+		}
536
+		if ($feature == 'task') {
537
+			$feature = 'projet_task';
538
+		}
442 539
 
443 540
 		$check = array('adherent', 'banque', 'bom', 'don', 'mrp', 'user', 'usergroup', 'product', 'produit', 'service', 'produit|service', 'categorie', 'resource', 'expensereport', 'holiday', 'website'); // Test on entity only (Objects with no link to company)
444 541
 		$checksoc = array('societe'); // Test for societe object
@@ -490,12 +587,14 @@  discard block
 block discarded – undo
490 587
 					$sql .= " AND dbt.entity IN (".getEntity($sharedelement, 1).")";
491 588
 				}
492 589
 			}
493
-		} elseif (in_array($feature, $checksoc))	// We check feature = checksoc
590
+		} elseif (in_array($feature, $checksoc)) {
591
+			// We check feature = checksoc
494 592
 		{
495 593
 			// If external user: Check permission for external users
496 594
 			if ($user->socid > 0)
497 595
 			{
498 596
 				if ($user->socid <> $objectid) return false;
597
+		}
499 598
 			} // If internal user: Check permission for internal users that are restricted on their objects
500 599
 			elseif (!empty($conf->societe->enabled) && ($user->rights->societe->lire && !$user->rights->societe->client->voir))
501 600
 			{
@@ -514,12 +613,14 @@  discard block
 block discarded – undo
514 613
 				$sql .= " WHERE s.rowid IN (".$objectid.")";
515 614
 				$sql .= " AND s.entity IN (".getEntity($sharedelement, 1).")";
516 615
 			}
517
-		} elseif (in_array($feature, $checkother))	// Test on entity and link to societe. Allowed if link is empty (Ex: contacts...).
616
+		} elseif (in_array($feature, $checkother)) {
617
+			// Test on entity and link to societe. Allowed if link is empty (Ex: contacts...).
518 618
 		{
519 619
 			// If external user: Check permission for external users
520 620
 			if ($user->socid > 0)
521 621
 			{
522 622
 				$sql = "SELECT COUNT(dbt.".$dbt_select.") as nb";
623
+		}
523 624
 				$sql .= " FROM ".MAIN_DB_PREFIX.$dbtablename." as dbt";
524 625
 				$sql .= " WHERE dbt.".$dbt_select." IN (".$objectid.")";
525 626
 				$sql .= " AND dbt.fk_soc = ".$user->socid;
@@ -540,10 +641,12 @@  discard block
 block discarded – undo
540 641
 				$sql .= " WHERE dbt.".$dbt_select." IN (".$objectid.")";
541 642
 				$sql .= " AND dbt.entity IN (".getEntity($sharedelement, 1).")";
542 643
 			}
543
-			if ($feature == 'agenda')// Also check owner or attendee for users without allactions->read
644
+			if ($feature == 'agenda') {
645
+				// Also check owner or attendee for users without allactions->read
544 646
 			{
545 647
 				if ($objectid > 0 && empty($user->rights->agenda->allactions->read)) {
546 648
 					require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php';
649
+			}
547 650
 					$action = new ActionComm($db);
548 651
 					$action->fetch($objectid);
549 652
 					if ($action->authorid != $user->id && $action->userownerid != $user->id && !(array_key_exists($user->id, $action->userassigned))) {
@@ -558,7 +661,9 @@  discard block
 block discarded – undo
558 661
 				$projectstatic = new Project($db);
559 662
 				$tmps = $projectstatic->getProjectsAuthorizedForUser($user, 0, 1, 0);
560 663
 				$tmparray = explode(',', $tmps);
561
-				if (!in_array($objectid, $tmparray)) return false;
664
+				if (!in_array($objectid, $tmparray)) {
665
+					return false;
666
+				}
562 667
 			} else {
563 668
 				$sql = "SELECT COUNT(dbt.".$dbt_select.") as nb";
564 669
 				$sql .= " FROM ".MAIN_DB_PREFIX.$dbtablename." as dbt";
@@ -575,19 +680,23 @@  discard block
 block discarded – undo
575 680
 				$projectstatic = new Project($db);
576 681
 				$tmps = $projectstatic->getProjectsAuthorizedForUser($user, 0, 1, 0);
577 682
 				$tmparray = explode(',', $tmps);
578
-				if (!in_array($task->fk_project, $tmparray)) return false;
683
+				if (!in_array($task->fk_project, $tmparray)) {
684
+					return false;
685
+				}
579 686
 			} else {
580 687
 				$sql = "SELECT COUNT(dbt.".$dbt_select.") as nb";
581 688
 				$sql .= " FROM ".MAIN_DB_PREFIX.$dbtablename." as dbt";
582 689
 				$sql .= " WHERE dbt.".$dbt_select." IN (".$objectid.")";
583 690
 				$sql .= " AND dbt.entity IN (".getEntity($sharedelement, 1).")";
584 691
 			}
585
-		} elseif (!in_array($feature, $nocheck))		// By default (case of $checkdefault), we check on object entity + link to third party on field $dbt_keyfield
692
+		} elseif (!in_array($feature, $nocheck)) {
693
+			// By default (case of $checkdefault), we check on object entity + link to third party on field $dbt_keyfield
586 694
 		{
587 695
 			// If external user: Check permission for external users
588 696
 			if ($user->socid > 0)
589 697
 			{
590 698
 				if (empty($dbt_keyfield)) dol_print_error('', 'Param dbt_keyfield is required but not defined');
699
+		}
591 700
 				$sql = "SELECT COUNT(dbt.".$dbt_keyfield.") as nb";
592 701
 				$sql .= " FROM ".MAIN_DB_PREFIX.$dbtablename." as dbt";
593 702
 				$sql .= " WHERE dbt.rowid IN (".$objectid.")";
@@ -595,7 +704,9 @@  discard block
 block discarded – undo
595 704
 			} // If internal user: Check permission for internal users that are restricted on their objects
596 705
 			elseif (!empty($conf->societe->enabled) && ($user->rights->societe->lire && !$user->rights->societe->client->voir))
597 706
 			{
598
-				if (empty($dbt_keyfield)) dol_print_error('', 'Param dbt_keyfield is required but not defined');
707
+				if (empty($dbt_keyfield)) {
708
+					dol_print_error('', 'Param dbt_keyfield is required but not defined');
709
+				}
599 710
 				$sql = "SELECT COUNT(sc.fk_soc) as nb";
600 711
 				$sql .= " FROM ".MAIN_DB_PREFIX.$dbtablename." as dbt";
601 712
 				$sql .= ", ".MAIN_DB_PREFIX."societe as s";
@@ -621,7 +732,9 @@  discard block
 block discarded – undo
621 732
 			if ($resql)
622 733
 			{
623 734
 				$obj = $db->fetch_object($resql);
624
-				if (!$obj || $obj->nb < count(explode(',', $objectid))) return false;
735
+				if (!$obj || $obj->nb < count(explode(',', $objectid))) {
736
+					return false;
737
+				}
625 738
 			} else {
626 739
 				return false;
627 740
 			}
@@ -656,12 +769,18 @@  discard block
 block discarded – undo
656 769
 
657 770
 	if ($printheader)
658 771
 	{
659
-		if (function_exists("llxHeader")) llxHeader('');
660
-		elseif (function_exists("llxHeaderVierge")) llxHeaderVierge('');
772
+		if (function_exists("llxHeader")) {
773
+			llxHeader('');
774
+		} elseif (function_exists("llxHeaderVierge")) {
775
+			llxHeaderVierge('');
776
+		}
661 777
 	}
662 778
 	print '<div class="error">';
663
-	if (!$message) print $langs->trans("ErrorForbidden");
664
-	else print $message;
779
+	if (!$message) {
780
+		print $langs->trans("ErrorForbidden");
781
+	} else {
782
+		print $message;
783
+	}
665 784
 	print '</div>';
666 785
 	print '<br>';
667 786
 	if (empty($showonlymessage))
@@ -687,6 +806,8 @@  discard block
 block discarded – undo
687 806
 			}
688 807
 		}
689 808
 	}
690
-	if ($printfooter && function_exists("llxFooter")) llxFooter();
809
+	if ($printfooter && function_exists("llxFooter")) {
810
+		llxFooter();
811
+	}
691 812
 	exit(0);
692 813
 }
Please login to merge, or discard this patch.
htdocs/categories/class/api_categories.class.php 1 patch
Braces   +7 added lines, -5 removed lines patch added patch discarded remove patch
@@ -181,8 +181,7 @@  discard block
 block discarded – undo
181 181
 				}
182 182
 				$i++;
183 183
 			}
184
-		}
185
-		else {
184
+		} else {
186 185
 			throw new RestException(503, 'Error when retrieve category list : '.$this->db->lasterror());
187 186
 		}
188 187
 		if (!count($obj_ret)) {
@@ -238,7 +237,9 @@  discard block
 block discarded – undo
238 237
 		}
239 238
 
240 239
 		foreach ($request_data as $field => $value) {
241
-			if ($field == 'id') continue;
240
+			if ($field == 'id') {
241
+				continue;
242
+			}
242 243
 			$this->category->$field = $value;
243 244
 		}
244 245
 
@@ -721,8 +722,9 @@  discard block
 block discarded – undo
721 722
 	{
722 723
 		$category = array();
723 724
 		foreach (Categories::$FIELDS as $field) {
724
-			if (!isset($data[$field]))
725
-				throw new RestException(400, "$field field missing");
725
+			if (!isset($data[$field])) {
726
+							throw new RestException(400, "$field field missing");
727
+			}
726 728
 			$category[$field] = $data[$field];
727 729
 		}
728 730
 		return $category;
Please login to merge, or discard this patch.
htdocs/cashdesk/facturation_dhtml.php 1 patch
Braces   +33 added lines, -11 removed lines patch added patch discarded remove patch
@@ -24,12 +24,24 @@  discard block
 block discarded – undo
24 24
  */
25 25
 
26 26
 
27
-if (!defined('NOREQUIRESOC'))   define('NOREQUIRESOC', '1');
28
-if (!defined('NOCSRFCHECK'))    define('NOCSRFCHECK', '1');
29
-if (!defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1');
30
-if (!defined('NOREQUIREMENU'))  define('NOREQUIREMENU', '1');
31
-if (!defined('NOREQUIREHTML'))  define('NOREQUIREHTML', '1');
32
-if (!defined('NOREQUIREAJAX'))  define('NOREQUIREAJAX', '1');
27
+if (!defined('NOREQUIRESOC')) {
28
+	define('NOREQUIRESOC', '1');
29
+}
30
+if (!defined('NOCSRFCHECK')) {
31
+	define('NOCSRFCHECK', '1');
32
+}
33
+if (!defined('NOTOKENRENEWAL')) {
34
+	define('NOTOKENRENEWAL', '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
+}
33 45
 
34 46
 // Change this following line to use the correct relative path (../, ../../, etc)
35 47
 require '../main.inc.php';
@@ -40,12 +52,18 @@  discard block
 block discarded – undo
40 52
 $search = GETPOST("code", "alpha");
41 53
 
42 54
 // Search from criteria
43
-if (dol_strlen($search) >= 0)	// If search criteria is on char length at least
55
+if (dol_strlen($search) >= 0) {
56
+	// If search criteria is on char length at least
44 57
 {
45 58
 	$sql = "SELECT p.rowid, p.ref, p.label, p.tva_tx";
46
-	if (!empty($conf->stock->enabled) && !empty($conf_fkentrepot)) $sql .= ", ps.reel";
59
+}
60
+	if (!empty($conf->stock->enabled) && !empty($conf_fkentrepot)) {
61
+		$sql .= ", ps.reel";
62
+	}
47 63
 	$sql .= " FROM ".MAIN_DB_PREFIX."product as p";
48
-	if (!empty($conf->stock->enabled) && !empty($conf_fkentrepot)) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product_stock as ps ON p.rowid = ps.fk_product AND ps.fk_entrepot = '".$db->escape($conf_fkentrepot)."'";
64
+	if (!empty($conf->stock->enabled) && !empty($conf_fkentrepot)) {
65
+		$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product_stock as ps ON p.rowid = ps.fk_product AND ps.fk_entrepot = '".$db->escape($conf_fkentrepot)."'";
66
+	}
49 67
 	$sql .= " WHERE p.entity IN (".getEntity('product').")";
50 68
 	$sql .= " AND p.tosell = 1";
51 69
 	$sql .= " AND p.fk_product_type = 0";
@@ -53,11 +71,15 @@  discard block
 block discarded – undo
53 71
 	if (!empty($conf->global->PRODUCT_DONOTSEARCH_ANYWHERE))
54 72
 	{
55 73
 		$sql .= " AND (p.ref LIKE '".$db->escape($search)."%' OR p.label LIKE '".$db->escape($search)."%'";
56
-		if (!empty($conf->barcode->enabled)) $sql .= " OR p.barcode LIKE '".$db->escape($search)."%'";
74
+		if (!empty($conf->barcode->enabled)) {
75
+			$sql .= " OR p.barcode LIKE '".$db->escape($search)."%'";
76
+		}
57 77
 		$sql .= ")";
58 78
 	} else {
59 79
 		$sql .= " AND (p.ref LIKE '%".$db->escape($search)."%' OR p.label LIKE '%".$db->escape($search)."%'";
60
-		if (!empty($conf->barcode->enabled)) $sql .= " OR p.barcode LIKE '%".$db->escape($search)."%'";
80
+		if (!empty($conf->barcode->enabled)) {
81
+			$sql .= " OR p.barcode LIKE '%".$db->escape($search)."%'";
82
+		}
61 83
 		$sql .= ")";
62 84
 	}
63 85
 	$sql .= " ORDER BY label";
Please login to merge, or discard this patch.
htdocs/cashdesk/facturation.php 1 patch
Braces   +18 added lines, -6 removed lines patch added patch discarded remove patch
@@ -40,12 +40,18 @@  discard block
 block discarded – undo
40 40
 	$ret = array(); $i = 0;
41 41
 
42 42
 	$sql = "SELECT p.rowid, p.ref, p.label, p.tva_tx, p.fk_product_type";
43
-	if (!empty($conf->stock->enabled) && !empty($conf_fkentrepot)) $sql .= ", ps.reel";
43
+	if (!empty($conf->stock->enabled) && !empty($conf_fkentrepot)) {
44
+		$sql .= ", ps.reel";
45
+	}
44 46
 	$sql .= " FROM ".MAIN_DB_PREFIX."product as p";
45
-	if (!empty($conf->stock->enabled) && !empty($conf_fkentrepot)) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product_stock as ps ON p.rowid = ps.fk_product AND ps.fk_entrepot = '".$db->escape($conf_fkentrepot)."'";
47
+	if (!empty($conf->stock->enabled) && !empty($conf_fkentrepot)) {
48
+		$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product_stock as ps ON p.rowid = ps.fk_product AND ps.fk_entrepot = '".$db->escape($conf_fkentrepot)."'";
49
+	}
46 50
 	$sql .= " WHERE p.entity IN (".getEntity('product').")";
47 51
 	$sql .= " AND p.tosell = 1";
48
-	if (!$conf->global->CASHDESK_SERVICES) $sql .= " AND p.fk_product_type = 0";
52
+	if (!$conf->global->CASHDESK_SERVICES) {
53
+		$sql .= " AND p.fk_product_type = 0";
54
+	}
49 55
 	$sql .= " AND (";
50 56
 	$sql .= "p.ref LIKE '%".$db->escape(GETPOST('filtre'))."%' OR p.label LIKE '%".$db->escape(GETPOST('filtre'))."%'";
51 57
 	if (!empty($conf->barcode->enabled))
@@ -90,12 +96,18 @@  discard block
 block discarded – undo
90 96
 	$i = 0;
91 97
 
92 98
 	$sql = "SELECT p.rowid, ref, label, tva_tx, p.fk_product_type";
93
-	if (!empty($conf->stock->enabled) && !empty($conf_fkentrepot)) $sql .= ", ps.reel";
99
+	if (!empty($conf->stock->enabled) && !empty($conf_fkentrepot)) {
100
+		$sql .= ", ps.reel";
101
+	}
94 102
 	$sql .= " FROM ".MAIN_DB_PREFIX."product as p";
95
-	if (!empty($conf->stock->enabled) && !empty($conf_fkentrepot)) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product_stock as ps ON p.rowid = ps.fk_product AND ps.fk_entrepot = '".$db->escape($conf_fkentrepot)."'";
103
+	if (!empty($conf->stock->enabled) && !empty($conf_fkentrepot)) {
104
+		$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product_stock as ps ON p.rowid = ps.fk_product AND ps.fk_entrepot = '".$db->escape($conf_fkentrepot)."'";
105
+	}
96 106
 	$sql .= " WHERE p.entity IN (".getEntity('product').")";
97 107
 	$sql .= " AND p.tosell = 1";
98
-	if (!$conf->global->CASHDESK_SERVICES) $sql .= " AND p.fk_product_type = 0";
108
+	if (!$conf->global->CASHDESK_SERVICES) {
109
+		$sql .= " AND p.fk_product_type = 0";
110
+	}
99 111
 	$sql .= " ORDER BY p.label";
100 112
 
101 113
 	dol_syslog($sql);
Please login to merge, or discard this patch.
htdocs/core/modules/DolibarrModules.class.php 2 patches
Braces   +29 added lines, -10 removed lines patch added patch discarded remove patch
@@ -624,9 +624,11 @@  discard block
 block discarded – undo
624 624
 
625 625
 		$pathoffile = $this->getDescLongReadmeFound();
626 626
 
627
-		if ($pathoffile)     // Mostly for external modules
627
+		if ($pathoffile) {
628
+			// Mostly for external modules
628 629
 		{
629 630
 			$content = file_get_contents($pathoffile);
631
+		}
630 632
 
631 633
 			if ((float) DOL_VERSION >= 6.0) {
632 634
 				@include_once DOL_DOCUMENT_ROOT.'/core/lib/parsemd.lib.php';
@@ -724,9 +726,11 @@  discard block
 block discarded – undo
724 726
 			}
725 727
 		}
726 728
 
727
-		if ($filefound)     // Mostly for external modules
729
+		if ($filefound) {
730
+			// Mostly for external modules
728 731
 		{
729 732
 			$content = file_get_contents($pathoffile);
733
+		}
730 734
 
731 735
 			if ((float) DOL_VERSION >= 6.0) {
732 736
 				@include_once DOL_DOCUMENT_ROOT.'/core/lib/parsemd.lib.php';
@@ -1581,9 +1585,11 @@  discard block
 block discarded – undo
1581 1585
 			if ($result) {
1582 1586
 				$row = $this->db->fetch_row($result);
1583 1587
 
1584
-				if ($row[0] == 0)   // If not found
1588
+				if ($row[0] == 0) {
1589
+					// If not found
1585 1590
 				{
1586 1591
 					$sql = "INSERT INTO ".MAIN_DB_PREFIX."const (name,type,value,note,visible,entity)";
1592
+				}
1587 1593
 					$sql .= " VALUES (";
1588 1594
 					$sql .= $this->db->encrypt($name, 1);
1589 1595
 					$sql .= ",'".$this->db->escape($type)."'";
@@ -1762,10 +1768,12 @@  discard block
 block discarded – undo
1762 1768
 					}
1763 1769
 				}
1764 1770
 
1765
-				if ($reinitadminperms && !empty($user->admin))  // Reload permission for current user if defined
1771
+				if ($reinitadminperms && !empty($user->admin)) {
1772
+					// Reload permission for current user if defined
1766 1773
 				{
1767 1774
 					// We reload permissions
1768 1775
 					$user->clearrights();
1776
+				}
1769 1777
 					$user->getrights();
1770 1778
 				}
1771 1779
 			}
@@ -1840,9 +1848,11 @@  discard block
 block discarded – undo
1840 1848
 			} else {
1841 1849
 				$foundparent = 0;
1842 1850
 				$fk_parent = $this->menu[$key]['fk_menu'];
1843
-				if (preg_match('/^r=/', $fk_parent))    // old deprecated method
1851
+				if (preg_match('/^r=/', $fk_parent)) {
1852
+					// old deprecated method
1844 1853
 				{
1845 1854
 					$fk_parent = str_replace('r=', '', $fk_parent);
1855
+				}
1846 1856
 					if (isset($this->menu[$fk_parent]['rowid'])) {
1847 1857
 						$menu->fk_menu = $this->menu[$fk_parent]['rowid'];
1848 1858
 						$foundparent = 1;
@@ -2218,9 +2228,15 @@  discard block
 block discarded – undo
2218 2228
 
2219 2229
 		$version = $this->getVersion(0);
2220 2230
 		$versiontrans = '';
2221
-		if (preg_match('/development/i', $version))  $versiontrans .= 'warning';
2222
-		if (preg_match('/experimental/i', $version)) $versiontrans .= 'warning';
2223
-		if (preg_match('/deprecated/i', $version))   $versiontrans .= 'warning';
2231
+		if (preg_match('/development/i', $version)) {
2232
+			$versiontrans .= 'warning';
2233
+		}
2234
+		if (preg_match('/experimental/i', $version)) {
2235
+			$versiontrans .= 'warning';
2236
+		}
2237
+		if (preg_match('/deprecated/i', $version)) {
2238
+			$versiontrans .= 'warning';
2239
+		}
2224 2240
 
2225 2241
 		print '
2226 2242
     	<div class="box-flex-item info-box-module'.(empty($conf->global->$const_name) ? ' info-box-module-disabled' : '').($this->isCoreOrExternalModule() == 'external' ? ' info-box-module-external' : '').'">
@@ -2232,8 +2248,11 @@  discard block
 block discarded – undo
2232 2248
 		//if (is_array($objMod->phpmin)) $alttext.=($alttext?' - ':'').'PHP >= '.join('.',$objMod->phpmin);
2233 2249
 		if (!empty($this->picto))
2234 2250
 		{
2235
-			if (preg_match('/^\//i', $this->picto)) print img_picto($alttext, $this->picto, 'class="inline-block valignmiddle"', 1);
2236
-			else print img_object($alttext, $this->picto, 'class="inline-block valignmiddle"');
2251
+			if (preg_match('/^\//i', $this->picto)) {
2252
+				print img_picto($alttext, $this->picto, 'class="inline-block valignmiddle"', 1);
2253
+			} else {
2254
+				print img_object($alttext, $this->picto, 'class="inline-block valignmiddle"');
2255
+			}
2237 2256
 		} else {
2238 2257
 			print img_object($alttext, 'generic', 'class="inline-block valignmiddle"');
2239 2258
 		}
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1285,7 +1285,7 @@
 block discarded – undo
1285 1285
 
1286 1286
 				$sql = "DELETE FROM ".MAIN_DB_PREFIX."boxes_def";
1287 1287
 				$sql .= " WHERE file = '".$this->db->escape($file)."'";
1288
-				$sql .= " AND entity = ".$conf->entity;		// Do not use getEntity here, we want to delete only in current company
1288
+				$sql .= " AND entity = ".$conf->entity; // Do not use getEntity here, we want to delete only in current company
1289 1289
 
1290 1290
 				dol_syslog(get_class($this)."::delete_boxes", LOG_DEBUG);
1291 1291
 				$resql = $this->db->query($sql);
Please login to merge, or discard this patch.
htdocs/core/modules/movement/doc/pdf_standard.modules.php 1 patch
Braces   +148 added lines, -54 removed lines patch added patch discarded remove patch
@@ -144,7 +144,10 @@  discard block
 block discarded – undo
144 144
 
145 145
 		// Recupere emetteur
146 146
 		$this->emetteur = $mysoc;
147
-		if (!$this->emetteur->country_code) $this->emetteur->country_code = substr($langs->defaultlang, -2); // By default if not defined
147
+		if (!$this->emetteur->country_code) {
148
+			$this->emetteur->country_code = substr($langs->defaultlang, -2);
149
+		}
150
+		// By default if not defined
148 151
 
149 152
 		// Define position of columns
150 153
 		$this->wref = 15;
@@ -159,11 +162,15 @@  discard block
 block discarded – undo
159 162
 		$this->posxdiscount = 167;
160 163
 		$this->postotalht = 180;
161 164
 
162
-		if (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT) || !empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_COLUMN)) $this->posxtva = $this->posxup;
165
+		if (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT) || !empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_COLUMN)) {
166
+			$this->posxtva = $this->posxup;
167
+		}
163 168
 		$this->posxpicture = $this->posxtva - (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH) ? 20 : $conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH); // width of images
164
-		if ($this->page_largeur < 210) // To work with US executive format
169
+		if ($this->page_largeur < 210) {
170
+			// To work with US executive format
165 171
 		{
166 172
 			$this->posxpicture -= 20;
173
+		}
167 174
 			$this->posxtva -= 20;
168 175
 			$this->posxup -= 20;
169 176
 			$this->posxqty -= 20;
@@ -196,9 +203,13 @@  discard block
 block discarded – undo
196 203
 		// phpcs:enable
197 204
 		global $user, $langs, $conf, $mysoc, $db, $hookmanager;
198 205
 
199
-		if (!is_object($outputlangs)) $outputlangs = $langs;
206
+		if (!is_object($outputlangs)) {
207
+			$outputlangs = $langs;
208
+		}
200 209
 		// For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
201
-		if (!empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output = 'ISO-8859-1';
210
+		if (!empty($conf->global->MAIN_USE_FPDF)) {
211
+			$outputlangs->charset_output = 'ISO-8859-1';
212
+		}
202 213
 
203 214
 		// Load traductions files required by page
204 215
 		$outputlangs->loadLangs(array("main", "dict", "companies", "bills", "stocks", "orders", "deliveries"));
@@ -235,8 +246,12 @@  discard block
 block discarded – undo
235 246
 		$sortorder = GETPOST("sortorder", 'alpha');
236 247
 		if (empty($page) || $page == -1) { $page = 0; }     // If $page is not defined, or '' or -1
237 248
 		$offset = $limit * $page;
238
-		if (!$sortfield) $sortfield = "m.datem";
239
-		if (!$sortorder) $sortorder = "DESC";
249
+		if (!$sortfield) {
250
+			$sortfield = "m.datem";
251
+		}
252
+		if (!$sortorder) {
253
+			$sortorder = "DESC";
254
+		}
240 255
 
241 256
 		$pdluoid = GETPOST('pdluoid', 'int');
242 257
 
@@ -264,7 +279,9 @@  discard block
 block discarded – undo
264 279
 		$sql .= " u.login, u.photo, u.lastname, u.firstname";
265 280
 		// Add fields from extrafields
266 281
 		if (!empty($extrafields->attributes[$element]['label'])) {
267
-			foreach ($extrafields->attributes[$element]['label'] as $key => $val) $sql .= ($extrafields->attributes[$element]['type'][$key] != 'separate' ? ", ef.".$key.' as options_'.$key : '');
282
+			foreach ($extrafields->attributes[$element]['label'] as $key => $val) {
283
+				$sql .= ($extrafields->attributes[$element]['type'][$key] != 'separate' ? ", ef.".$key.' as options_'.$key : '');
284
+			}
268 285
 		}
269 286
 		// Add fields from hooks
270 287
 		$parameters = array();
@@ -273,35 +290,67 @@  discard block
 block discarded – undo
273 290
 		$sql .= " FROM ".MAIN_DB_PREFIX."entrepot as e,";
274 291
 		$sql .= " ".MAIN_DB_PREFIX."product as p,";
275 292
 		$sql .= " ".MAIN_DB_PREFIX."stock_mouvement as m";
276
-		if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (m.rowid = ef.fk_object)";
293
+		if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) {
294
+			$sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (m.rowid = ef.fk_object)";
295
+		}
277 296
 		$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."user as u ON m.fk_user_author = u.rowid";
278 297
 		$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product_lot as pl ON m.batch = pl.batch AND m.fk_product = pl.fk_product";
279 298
 		$sql .= " WHERE m.fk_product = p.rowid";
280
-		if ($msid > 0) $sql .= " AND m.rowid = ".$msid;
299
+		if ($msid > 0) {
300
+			$sql .= " AND m.rowid = ".$msid;
301
+		}
281 302
 		$sql .= " AND m.fk_entrepot = e.rowid";
282 303
 		$sql .= " AND e.entity IN (".getEntity('stock').")";
283
-		if (empty($conf->global->STOCK_SUPPORTS_SERVICES)) $sql .= " AND p.fk_product_type = 0";
284
-		if ($id > 0) $sql .= " AND e.rowid ='".$id."'";
304
+		if (empty($conf->global->STOCK_SUPPORTS_SERVICES)) {
305
+			$sql .= " AND p.fk_product_type = 0";
306
+		}
307
+		if ($id > 0) {
308
+			$sql .= " AND e.rowid ='".$id."'";
309
+		}
285 310
 		if ($month > 0)
286 311
 		{
287
-			if ($year > 0)
288
-				$sql .= " AND m.datem BETWEEN '".$this->db->idate(dol_get_first_day($year, $month, false))."' AND '".$this->db->idate(dol_get_last_day($year, $month, false))."'";
289
-			else $sql .= " AND date_format(m.datem, '%m') = '$month'";
312
+			if ($year > 0) {
313
+							$sql .= " AND m.datem BETWEEN '".$this->db->idate(dol_get_first_day($year, $month, false))."' AND '".$this->db->idate(dol_get_last_day($year, $month, false))."'";
314
+			} else {
315
+				$sql .= " AND date_format(m.datem, '%m') = '$month'";
316
+			}
290 317
 		} elseif ($year > 0)
291 318
 		{
292 319
 			$sql .= " AND m.datem BETWEEN '".$this->db->idate(dol_get_first_day($year, 1, false))."' AND '".$this->db->idate(dol_get_last_day($year, 12, false))."'";
293 320
 		}
294
-		if ($idproduct > 0) $sql .= " AND p.rowid = ".((int) $idproduct);
295
-		if (!empty($search_ref))			$sql .= natural_search('m.rowid', $search_ref, 1);
296
-		if (!empty($search_movement))      $sql .= natural_search('m.label', $search_movement);
297
-		if (!empty($search_inventorycode)) $sql .= natural_search('m.inventorycode', $search_inventorycode);
298
-		if (!empty($search_product_ref))   $sql .= natural_search('p.ref', $search_product_ref);
299
-		if (!empty($search_product))       $sql .= natural_search('p.label', $search_product);
300
-		if ($search_warehouse > 0)          $sql .= " AND e.rowid = ".((int) $this->db->escape($search_warehouse));
301
-		if (!empty($search_user))          $sql .= natural_search('u.login', $search_user);
302
-		if (!empty($search_batch))         $sql .= natural_search('m.batch', $search_batch);
303
-		if ($search_qty != '')				$sql .= natural_search('m.value', $search_qty, 1);
304
-		if ($search_type_mouvement > 0)		$sql .= " AND m.type_mouvement = '".$this->db->escape($search_type_mouvement)."'";
321
+		if ($idproduct > 0) {
322
+			$sql .= " AND p.rowid = ".((int) $idproduct);
323
+		}
324
+		if (!empty($search_ref)) {
325
+			$sql .= natural_search('m.rowid', $search_ref, 1);
326
+		}
327
+		if (!empty($search_movement)) {
328
+			$sql .= natural_search('m.label', $search_movement);
329
+		}
330
+		if (!empty($search_inventorycode)) {
331
+			$sql .= natural_search('m.inventorycode', $search_inventorycode);
332
+		}
333
+		if (!empty($search_product_ref)) {
334
+			$sql .= natural_search('p.ref', $search_product_ref);
335
+		}
336
+		if (!empty($search_product)) {
337
+			$sql .= natural_search('p.label', $search_product);
338
+		}
339
+		if ($search_warehouse > 0) {
340
+			$sql .= " AND e.rowid = ".((int) $this->db->escape($search_warehouse));
341
+		}
342
+		if (!empty($search_user)) {
343
+			$sql .= natural_search('u.login', $search_user);
344
+		}
345
+		if (!empty($search_batch)) {
346
+			$sql .= natural_search('m.batch', $search_batch);
347
+		}
348
+		if ($search_qty != '') {
349
+			$sql .= natural_search('m.value', $search_qty, 1);
350
+		}
351
+		if ($search_type_mouvement > 0) {
352
+			$sql .= " AND m.type_mouvement = '".$this->db->escape($search_type_mouvement)."'";
353
+		}
305 354
 		// Add where from extra fields
306 355
 		include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php';
307 356
 		// Add where from hooks
@@ -315,14 +364,18 @@  discard block
 block discarded – undo
315 364
 		{
316 365
 			$result = $this->db->query($sql);
317 366
 			$nbtotalofrecords = $this->db->num_rows($result);
318
-			if (($page * $limit) > $nbtotalofrecords)	// if total resultset is smaller then paging size (filtering), goto and load page 0
367
+			if (($page * $limit) > $nbtotalofrecords) {
368
+				// if total resultset is smaller then paging size (filtering), goto and load page 0
319 369
 			{
320 370
 				$page = 0;
371
+			}
321 372
 				$offset = 0;
322 373
 			}
323 374
 		}
324 375
 
325
-		if (empty($search_inventorycode)) $sql .= $this->db->plimit($limit + 1, $offset);
376
+		if (empty($search_inventorycode)) {
377
+			$sql .= $this->db->plimit($limit + 1, $offset);
378
+		}
326 379
 
327 380
 
328 381
 		$resql = $this->db->query($sql);
@@ -360,10 +413,13 @@  discard block
 block discarded – undo
360 413
 
361 414
 				$i = 0;
362 415
 				$help_url = 'EN:Module_Stocks_En|FR:Module_Stock|ES:M&oacute;dulo_Stocks';
363
-				if ($msid) $texte = $langs->trans('StockMovementForId', $msid);
364
-				else {
416
+				if ($msid) {
417
+					$texte = $langs->trans('StockMovementForId', $msid);
418
+				} else {
365 419
 					$texte = $langs->trans("ListOfStockMovements");
366
-					if ($id) $texte .= ' ('.$langs->trans("ForThisWarehouse").')';
420
+					if ($id) {
421
+						$texte .= ' ('.$langs->trans("ForThisWarehouse").')';
422
+					}
367 423
 				}
368 424
 			}
369 425
 
@@ -374,8 +430,12 @@  discard block
 block discarded – undo
374 430
 				$file = $dir."/SPECIMEN.pdf";
375 431
 			} else {
376 432
 				$objectref = dol_sanitizeFileName($object->ref);
377
-				if (!empty($search_inventorycode)) $objectref .= "_".$id."_".$search_inventorycode;
378
-				if ($search_type_mouvement) $objectref .= "_".$search_type_mouvement;
433
+				if (!empty($search_inventorycode)) {
434
+					$objectref .= "_".$id."_".$search_inventorycode;
435
+				}
436
+				if ($search_type_mouvement) {
437
+					$objectref .= "_".$search_type_mouvement;
438
+				}
379 439
 				$dir = $conf->stock->dir_output."/movement/".$objectref;
380 440
 				$file = $dir."/".$objectref.".pdf";
381 441
 			}
@@ -439,14 +499,18 @@  discard block
 block discarded – undo
439 499
 				$pdf->SetCreator("Dolibarr ".DOL_VERSION);
440 500
 				$pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
441 501
 				$pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("Stock")." ".$outputlangs->convToOutputCharset($object->label));
442
-				if (!empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
502
+				if (!empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) {
503
+					$pdf->SetCompression(false);
504
+				}
443 505
 
444 506
 				$pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right
445 507
 
446 508
 
447 509
 				// New page
448 510
 				$pdf->AddPage();
449
-				if (!empty($tplidx)) $pdf->useTemplate($tplidx);
511
+				if (!empty($tplidx)) {
512
+					$pdf->useTemplate($tplidx);
513
+				}
450 514
 				$pagenb++;
451 515
 				$this->_pagehead($pdf, $object, 1, $outputlangs);
452 516
 				$pdf->SetFont('', '', $default_font_size - 1);
@@ -484,9 +548,11 @@  discard block
 block discarded – undo
484 548
 						$objp = $this->db->fetch_object($resql);
485 549
 
486 550
 						// Multilangs
487
-						if (!empty($conf->global->MAIN_MULTILANGS)) // si l'option est active
551
+						if (!empty($conf->global->MAIN_MULTILANGS)) {
552
+							// si l'option est active
488 553
 						{
489 554
 							$sql = "SELECT label";
555
+						}
490 556
 							$sql .= " FROM ".MAIN_DB_PREFIX."product_lang";
491 557
 							$sql .= " WHERE fk_product=".$objp->rowid;
492 558
 							$sql .= " AND lang='".$this->db->escape($langs->getDefaultLang())."'";
@@ -496,7 +562,9 @@  discard block
 block discarded – undo
496 562
 							if ($result)
497 563
 							{
498 564
 								$objtp = $this->db->fetch_object($result);
499
-								if ($objtp->label != '') $objp->produit = $objtp->label;
565
+								if ($objtp->label != '') {
566
+									$objp->produit = $objtp->label;
567
+								}
500 568
 							}
501 569
 						}
502 570
 
@@ -516,31 +584,41 @@  discard block
 block discarded – undo
516 584
 						$pdf->startTransaction();
517 585
 						pdf_writelinedesc($pdf, $object, $i, $outputlangs, $this->posxtva - $curX, 3, $curX, $curY, $hideref, $hidedesc);
518 586
 						$pageposafter = $pdf->getPage();
519
-						if ($pageposafter > $pageposbefore)	// There is a pagebreak
587
+						if ($pageposafter > $pageposbefore) {
588
+							// There is a pagebreak
520 589
 						{
521 590
 							$pdf->rollbackTransaction(true);
591
+						}
522 592
 							$pageposafter = $pageposbefore;
523 593
 							//print $pageposafter.'-'.$pageposbefore;exit;
524 594
 							$pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it.
525 595
 							pdf_writelinedesc($pdf, $object, $i, $outputlangs, $this->posxtva - $curX, 4, $curX, $curY, $hideref, $hidedesc);
526 596
 							$pageposafter = $pdf->getPage();
527 597
 							$posyafter = $pdf->GetY();
528
-							if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot)))	// There is no space left for total+free text
598
+							if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) {
599
+								// There is no space left for total+free text
529 600
 							{
530 601
 								if ($i == ($nblines - 1))	// No more lines, and no space left to show total, so we create a new page
531 602
 								{
532 603
 									$pdf->AddPage('', '', true);
533
-									if (!empty($tplidx)) $pdf->useTemplate($tplidx);
534
-									if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
604
+							}
605
+									if (!empty($tplidx)) {
606
+										$pdf->useTemplate($tplidx);
607
+									}
608
+									if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) {
609
+										$this->_pagehead($pdf, $object, 0, $outputlangs);
610
+									}
535 611
 									$pdf->setPage($pageposafter + 1);
536 612
 								}
537 613
 							} else {
538 614
 								// We found a page break
539 615
 
540 616
 								// Allows data in the first page if description is long enough to break in multiples pages
541
-								if (!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE))
542
-									$showpricebeforepagebreak = 1;
543
-								else $showpricebeforepagebreak = 0;
617
+								if (!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE)) {
618
+																	$showpricebeforepagebreak = 1;
619
+								} else {
620
+									$showpricebeforepagebreak = 0;
621
+								}
544 622
 							}
545 623
 						} else // No pagebreak
546 624
 						{
@@ -664,7 +742,9 @@  discard block
 block discarded – undo
664 742
 							$pagenb++;
665 743
 							$pdf->setPage($pagenb);
666 744
 							$pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
667
-							if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
745
+							if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) {
746
+								$this->_pagehead($pdf, $object, 0, $outputlangs);
747
+							}
668 748
 						}
669 749
 						if (isset($object->lines[$i + 1]->pagebreak) && $object->lines[$i + 1]->pagebreak)
670 750
 						{
@@ -677,9 +757,13 @@  discard block
 block discarded – undo
677 757
 							$this->_pagefoot($pdf, $object, $outputlangs, 1);
678 758
 							// New page
679 759
 							$pdf->AddPage();
680
-							if (!empty($tplidx)) $pdf->useTemplate($tplidx);
760
+							if (!empty($tplidx)) {
761
+								$pdf->useTemplate($tplidx);
762
+							}
681 763
 							$pagenb++;
682
-							if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
764
+							if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) {
765
+								$this->_pagehead($pdf, $object, 0, $outputlangs);
766
+							}
683 767
 						}
684 768
 					}
685 769
 
@@ -760,7 +844,9 @@  discard block
 block discarded – undo
760 844
 
761 845
 				// Pied de page
762 846
 				$this->_pagefoot($pdf, $object, $outputlangs);
763
-				if (method_exists($pdf, 'AliasNbPages')) $pdf->AliasNbPages();
847
+				if (method_exists($pdf, 'AliasNbPages')) {
848
+					$pdf->AliasNbPages();
849
+				}
764 850
 
765 851
 				$pdf->Close();
766 852
 
@@ -777,8 +863,9 @@  discard block
 block discarded – undo
777 863
 					$this->errors = $hookmanager->errors;
778 864
 				}
779 865
 
780
-				if (!empty($conf->global->MAIN_UMASK))
781
-					@chmod($file, octdec($conf->global->MAIN_UMASK));
866
+				if (!empty($conf->global->MAIN_UMASK)) {
867
+									@chmod($file, octdec($conf->global->MAIN_UMASK));
868
+				}
782 869
 
783 870
 				$this->result = array('fullpath'=>$file);
784 871
 
@@ -813,7 +900,9 @@  discard block
 block discarded – undo
813 900
 
814 901
 		// Force to disable hidetop and hidebottom
815 902
 		$hidebottom = 0;
816
-		if ($hidetop) $hidetop = -1;
903
+		if ($hidetop) {
904
+			$hidetop = -1;
905
+		}
817 906
 
818 907
 		$currency = !empty($currency) ? $currency : $conf->currency;
819 908
 		$default_font_size = pdf_getPDFFontSize($outputlangs);
@@ -829,7 +918,9 @@  discard block
 block discarded – undo
829 918
 			$pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre);
830 919
 
831 920
 			//$conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR='230,230,230';
832
-			if (!empty($conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)) $pdf->Rect($this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_droite - $this->marge_gauche, 5, 'F', null, explode(',', $conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR));
921
+			if (!empty($conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)) {
922
+				$pdf->Rect($this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_droite - $this->marge_gauche, 5, 'F', null, explode(',', $conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR));
923
+			}
833 924
 		}
834 925
 
835 926
 		$pdf->SetDrawColor(128, 128, 128);
@@ -943,8 +1034,11 @@  discard block
 block discarded – undo
943 1034
 
944 1035
 		$default_font_size = pdf_getPDFFontSize($outputlangs);
945 1036
 
946
-		if ($object->type == 1) $titlekey = 'ServiceSheet';
947
-		else $titlekey = 'StockSheet';
1037
+		if ($object->type == 1) {
1038
+			$titlekey = 'ServiceSheet';
1039
+		} else {
1040
+			$titlekey = 'StockSheet';
1041
+		}
948 1042
 
949 1043
 		pdf_pagehead($pdf, $outputlangs, $this->page_hauteur);
950 1044
 
Please login to merge, or discard this patch.
htdocs/core/modules/societe/mod_codeclient_monkey.php 1 patch
Braces   +20 added lines, -7 removed lines patch added patch discarded remove patch
@@ -142,8 +142,11 @@  discard block
 block discarded – undo
142 142
 		if ($resql)
143 143
 		{
144 144
 			$obj = $db->fetch_object($resql);
145
-			if ($obj) $max = intval($obj->max);
146
-			else $max = 0;
145
+			if ($obj) {
146
+				$max = intval($obj->max);
147
+			} else {
148
+				$max = 0;
149
+			}
147 150
 		} else {
148 151
 			return -1;
149 152
 		}
@@ -151,8 +154,13 @@  discard block
 block discarded – undo
151 154
 		$date	= dol_now();
152 155
 		$yymm	= strftime("%y%m", $date);
153 156
 
154
-		if ($max >= (pow(10, 5) - 1)) $num = $max + 1; // If counter > 99999, we do not format on 5 chars, we take number as it is
155
-		else $num = sprintf("%05s", $max + 1);
157
+		if ($max >= (pow(10, 5) - 1)) {
158
+			$num = $max + 1;
159
+		}
160
+		// If counter > 99999, we do not format on 5 chars, we take number as it is
161
+		else {
162
+			$num = sprintf("%05s", $max + 1);
163
+		}
156 164
 
157 165
 		dol_syslog(get_class($this)."::getNextValue return ".$prefix.$yymm."-".$num);
158 166
 		return $prefix.$yymm."-".$num;
@@ -226,10 +234,15 @@  discard block
 block discarded – undo
226 234
 		global $conf, $mc;
227 235
 
228 236
 		$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."societe";
229
-		if ($type == 1) $sql .= " WHERE code_fournisseur = '".$db->escape($code)."'";
230
-		else $sql .= " WHERE code_client = '".$db->escape($code)."'";
237
+		if ($type == 1) {
238
+			$sql .= " WHERE code_fournisseur = '".$db->escape($code)."'";
239
+		} else {
240
+			$sql .= " WHERE code_client = '".$db->escape($code)."'";
241
+		}
231 242
 		$sql .= " AND entity IN (".getEntity('societe').")";
232
-		if ($soc->id > 0) $sql .= " AND rowid <> ".$soc->id;
243
+		if ($soc->id > 0) {
244
+			$sql .= " AND rowid <> ".$soc->id;
245
+		}
233 246
 
234 247
 		dol_syslog(get_class($this)."::verif_dispo", LOG_DEBUG);
235 248
 		$resql = $db->query($sql);
Please login to merge, or discard this patch.
htdocs/core/modules/stock/doc/pdf_standard.modules.php 1 patch
Braces   +71 added lines, -26 removed lines patch added patch discarded remove patch
@@ -144,7 +144,10 @@  discard block
 block discarded – undo
144 144
 
145 145
 		// Recupere emetteur
146 146
 		$this->emetteur = $mysoc;
147
-		if (!$this->emetteur->country_code) $this->emetteur->country_code = substr($langs->defaultlang, -2); // By default if not defined
147
+		if (!$this->emetteur->country_code) {
148
+			$this->emetteur->country_code = substr($langs->defaultlang, -2);
149
+		}
150
+		// By default if not defined
148 151
 
149 152
 		// Define position of columns
150 153
 		$this->wref = 35;
@@ -157,11 +160,15 @@  discard block
 block discarded – undo
157 160
 		$this->posxdiscount = 155;
158 161
 		$this->postotalht = 175;
159 162
 
160
-		if (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT) || !empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_COLUMN)) $this->posxtva = $this->posxup;
163
+		if (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT) || !empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_COLUMN)) {
164
+			$this->posxtva = $this->posxup;
165
+		}
161 166
 		$this->posxpicture = $this->posxtva - (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH) ? 20 : $conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH); // width of images
162
-		if ($this->page_largeur < 210) // To work with US executive format
167
+		if ($this->page_largeur < 210) {
168
+			// To work with US executive format
163 169
 		{
164 170
 			$this->posxpicture -= 20;
171
+		}
165 172
 			$this->posxtva -= 20;
166 173
 			$this->posxup -= 20;
167 174
 			$this->posxqty -= 20;
@@ -194,9 +201,13 @@  discard block
 block discarded – undo
194 201
 		// phpcs:enable
195 202
 		global $user, $langs, $conf, $mysoc, $db, $hookmanager;
196 203
 
197
-		if (!is_object($outputlangs)) $outputlangs = $langs;
204
+		if (!is_object($outputlangs)) {
205
+			$outputlangs = $langs;
206
+		}
198 207
 		// For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
199
-		if (!empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output = 'ISO-8859-1';
208
+		if (!empty($conf->global->MAIN_USE_FPDF)) {
209
+			$outputlangs->charset_output = 'ISO-8859-1';
210
+		}
200 211
 
201 212
 		// Load traductions files required by page
202 213
 		$outputlangs->loadLangs(array("main", "dict", "companies", "bills", "stocks", "orders", "deliveries"));
@@ -275,14 +286,18 @@  discard block
 block discarded – undo
275 286
 				$pdf->SetCreator("Dolibarr ".DOL_VERSION);
276 287
 				$pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
277 288
 				$pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("Stock")." ".$outputlangs->convToOutputCharset($object->label));
278
-				if (!empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
289
+				if (!empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) {
290
+					$pdf->SetCompression(false);
291
+				}
279 292
 
280 293
 				$pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right
281 294
 
282 295
 
283 296
 				// New page
284 297
 				$pdf->AddPage();
285
-				if (!empty($tplidx)) $pdf->useTemplate($tplidx);
298
+				if (!empty($tplidx)) {
299
+					$pdf->useTemplate($tplidx);
300
+				}
286 301
 				$pagenb++;
287 302
 				$top_shift = $this->_pagehead($pdf, $object, 1, $outputlangs);
288 303
 				$pdf->SetFont('', '', $default_font_size - 1);
@@ -333,9 +348,11 @@  discard block
 block discarded – undo
333 348
 						$objp = $this->db->fetch_object($resql);
334 349
 
335 350
 						// Multilangs
336
-						if (!empty($conf->global->MAIN_MULTILANGS)) // si l'option est active
351
+						if (!empty($conf->global->MAIN_MULTILANGS)) {
352
+							// si l'option est active
337 353
 						{
338 354
 							$sql = "SELECT label";
355
+						}
339 356
 							$sql .= " FROM ".MAIN_DB_PREFIX."product_lang";
340 357
 							$sql .= " WHERE fk_product=".$objp->rowid;
341 358
 							$sql .= " AND lang='".$this->db->escape($langs->getDefaultLang())."'";
@@ -345,7 +362,9 @@  discard block
 block discarded – undo
345 362
 							if ($result)
346 363
 							{
347 364
 								$objtp = $this->db->fetch_object($result);
348
-								if ($objtp->label != '') $objp->produit = $objtp->label;
365
+								if ($objtp->label != '') {
366
+									$objp->produit = $objtp->label;
367
+								}
349 368
 							}
350 369
 						}
351 370
 
@@ -364,31 +383,41 @@  discard block
 block discarded – undo
364 383
 						$pdf->startTransaction();
365 384
 						pdf_writelinedesc($pdf, $object, $i, $outputlangs, $this->posxtva - $curX, 3, $curX, $curY, $hideref, $hidedesc);
366 385
 						$pageposafter = $pdf->getPage();
367
-						if ($pageposafter > $pageposbefore)	// There is a pagebreak
386
+						if ($pageposafter > $pageposbefore) {
387
+							// There is a pagebreak
368 388
 						{
369 389
 							$pdf->rollbackTransaction(true);
390
+						}
370 391
 							$pageposafter = $pageposbefore;
371 392
 							//print $pageposafter.'-'.$pageposbefore;exit;
372 393
 							$pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it.
373 394
 							pdf_writelinedesc($pdf, $object, $i, $outputlangs, $this->posxtva - $curX, 4, $curX, $curY, $hideref, $hidedesc);
374 395
 							$pageposafter = $pdf->getPage();
375 396
 							$posyafter = $pdf->GetY();
376
-							if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot)))	// There is no space left for total+free text
397
+							if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) {
398
+								// There is no space left for total+free text
377 399
 							{
378 400
 								if ($i == ($nblines - 1))	// No more lines, and no space left to show total, so we create a new page
379 401
 								{
380 402
 									$pdf->AddPage('', '', true);
381
-									if (!empty($tplidx)) $pdf->useTemplate($tplidx);
382
-									if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
403
+							}
404
+									if (!empty($tplidx)) {
405
+										$pdf->useTemplate($tplidx);
406
+									}
407
+									if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) {
408
+										$this->_pagehead($pdf, $object, 0, $outputlangs);
409
+									}
383 410
 									$pdf->setPage($pageposafter + 1);
384 411
 								}
385 412
 							} else {
386 413
 								// We found a page break
387 414
 
388 415
 								// Allows data in the first page if description is long enough to break in multiples pages
389
-								if (!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE))
390
-									$showpricebeforepagebreak = 1;
391
-								else $showpricebeforepagebreak = 0;
416
+								if (!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE)) {
417
+																	$showpricebeforepagebreak = 1;
418
+								} else {
419
+									$showpricebeforepagebreak = 0;
420
+								}
392 421
 							}
393 422
 						} else // No pagebreak
394 423
 						{
@@ -482,7 +511,9 @@  discard block
 block discarded – undo
482 511
 							$pagenb++;
483 512
 							$pdf->setPage($pagenb);
484 513
 							$pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
485
-							if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
514
+							if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) {
515
+								$this->_pagehead($pdf, $object, 0, $outputlangs);
516
+							}
486 517
 						}
487 518
 						if (isset($object->lines[$i + 1]->pagebreak) && $object->lines[$i + 1]->pagebreak)
488 519
 						{
@@ -495,9 +526,13 @@  discard block
 block discarded – undo
495 526
 							$this->_pagefoot($pdf, $object, $outputlangs, 1);
496 527
 							// New page
497 528
 							$pdf->AddPage();
498
-							if (!empty($tplidx)) $pdf->useTemplate($tplidx);
529
+							if (!empty($tplidx)) {
530
+								$pdf->useTemplate($tplidx);
531
+							}
499 532
 							$pagenb++;
500
-							if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
533
+							if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) {
534
+								$this->_pagehead($pdf, $object, 0, $outputlangs);
535
+							}
501 536
 						}
502 537
 					}
503 538
 
@@ -598,7 +633,9 @@  discard block
 block discarded – undo
598 633
 
599 634
 				// Pied de page
600 635
 				$this->_pagefoot($pdf, $object, $outputlangs);
601
-				if (method_exists($pdf, 'AliasNbPages')) $pdf->AliasNbPages();
636
+				if (method_exists($pdf, 'AliasNbPages')) {
637
+					$pdf->AliasNbPages();
638
+				}
602 639
 
603 640
 				$pdf->Close();
604 641
 
@@ -615,8 +652,9 @@  discard block
 block discarded – undo
615 652
 					$this->errors = $hookmanager->errors;
616 653
 				}
617 654
 
618
-				if (!empty($conf->global->MAIN_UMASK))
619
-					@chmod($file, octdec($conf->global->MAIN_UMASK));
655
+				if (!empty($conf->global->MAIN_UMASK)) {
656
+									@chmod($file, octdec($conf->global->MAIN_UMASK));
657
+				}
620 658
 
621 659
 				$this->result = array('fullpath'=>$file);
622 660
 
@@ -651,7 +689,9 @@  discard block
 block discarded – undo
651 689
 
652 690
 		// Force to disable hidetop and hidebottom
653 691
 		$hidebottom = 0;
654
-		if ($hidetop) $hidetop = -1;
692
+		if ($hidetop) {
693
+			$hidetop = -1;
694
+		}
655 695
 
656 696
 		$currency = !empty($currency) ? $currency : $conf->currency;
657 697
 		$default_font_size = pdf_getPDFFontSize($outputlangs);
@@ -667,7 +707,9 @@  discard block
 block discarded – undo
667 707
 			$pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre);
668 708
 
669 709
 			//$conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR='230,230,230';
670
-			if (!empty($conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)) $pdf->Rect($this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_droite - $this->marge_gauche, 5, 'F', null, explode(',', $conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR));
710
+			if (!empty($conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)) {
711
+				$pdf->Rect($this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_droite - $this->marge_gauche, 5, 'F', null, explode(',', $conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR));
712
+			}
671 713
 		}
672 714
 
673 715
 		$pdf->SetDrawColor(128, 128, 128);
@@ -758,8 +800,11 @@  discard block
 block discarded – undo
758 800
 
759 801
 		$default_font_size = pdf_getPDFFontSize($outputlangs);
760 802
 
761
-		if ($object->type == 1) $titlekey = 'ServiceSheet';
762
-		else $titlekey = 'StockSheet';
803
+		if ($object->type == 1) {
804
+			$titlekey = 'ServiceSheet';
805
+		} else {
806
+			$titlekey = 'StockSheet';
807
+		}
763 808
 
764 809
 		pdf_pagehead($pdf, $outputlangs, $this->page_hauteur);
765 810
 
Please login to merge, or discard this patch.
htdocs/core/extrafieldsinexport.inc.php 1 patch
Braces   +6 added lines, -2 removed lines patch added patch discarded remove patch
@@ -12,11 +12,13 @@  discard block
 block discarded – undo
12 12
 $sql .= " WHERE elementtype = '".$this->db->escape($keyforselect)."' AND type != 'separate' AND entity IN (0, ".$conf->entity.') ORDER BY pos ASC';
13 13
 //print $sql;
14 14
 $resql = $this->db->query($sql);
15
-if ($resql)    // This can fail when class is used on old database (during migration for example)
15
+if ($resql) {
16
+	// This can fail when class is used on old database (during migration for example)
16 17
 {
17 18
 	while ($obj = $this->db->fetch_object($resql))
18 19
 	{
19 20
 		$fieldname = $keyforaliasextra.'.'.$obj->name;
21
+}
20 22
 		$fieldlabel = ucfirst($obj->label);
21 23
 		$typeFilter = "Text";
22 24
 		$typefield = preg_replace('/\(.*$/', '', $obj->type); // double(24,8) -> double
@@ -51,7 +53,9 @@  discard block
 block discarded – undo
51 53
 					$tmpkeys = array_keys($tmpparam['options']);
52 54
 					$tmp = array_shift($tmpkeys);
53 55
 				}
54
-				if (preg_match('/[a-z0-9_]+:[a-z0-9_]+:[a-z0-9_]+/', $tmp)) $typeFilter = "List:".$tmp;
56
+				if (preg_match('/[a-z0-9_]+:[a-z0-9_]+:[a-z0-9_]+/', $tmp)) {
57
+					$typeFilter = "List:".$tmp;
58
+				}
55 59
 				break;
56 60
 		}
57 61
 		if ($obj->type != 'separate')
Please login to merge, or discard this patch.