Passed
Pull Request — master (#2)
by
unknown
26:19
created
dolibarr/htdocs/core/lib/asset.lib.php 1 patch
Braces   +12 added lines, -4 removed lines patch added patch discarded remove patch
@@ -101,16 +101,24 @@
 block discarded – undo
101 101
 	$nbLinks=Link::count($db, $object->element, $object->id);
102 102
 	$head[$h][0] = DOL_URL_ROOT.'/asset/document.php?id='.$object->id;
103 103
 	$head[$h][1] = $langs->trans('Documents');
104
-	if (($nbFiles+$nbLinks) > 0) $head[$h][1].= ' <span class="badge">'.($nbFiles+$nbLinks).'</span>';
104
+	if (($nbFiles+$nbLinks) > 0) {
105
+	    $head[$h][1].= ' <span class="badge">'.($nbFiles+$nbLinks).'</span>';
106
+	}
105 107
 	$head[$h][2] = 'documents';
106 108
 	$h++;
107 109
 
108 110
 	$nbNote = 0;
109
-	if(!empty($object->note_private)) $nbNote++;
110
-	if(!empty($object->note_public)) $nbNote++;
111
+	if(!empty($object->note_private)) {
112
+	    $nbNote++;
113
+	}
114
+	if(!empty($object->note_public)) {
115
+	    $nbNote++;
116
+	}
111 117
 	$head[$h][0] = DOL_URL_ROOT.'/asset/note.php?id='.$object->id;
112 118
 	$head[$h][1] = $langs->trans("Notes");
113
-	if ($nbNote > 0) $head[$h][1].= ' <span class="badge">'.$nbNote.'</span>';
119
+	if ($nbNote > 0) {
120
+	    $head[$h][1].= ' <span class="badge">'.$nbNote.'</span>';
121
+	}
114 122
 	$head[$h][2] = 'note';
115 123
 	$h++;
116 124
 
Please login to merge, or discard this patch.
dolibarr/htdocs/core/lib/vat.lib.php 1 patch
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -54,7 +54,9 @@
 block discarded – undo
54 54
     $nbLinks=Link::count($db, $object->element, $object->id);
55 55
 	$head[$tab][0] = DOL_URL_ROOT.'/compta/tva/document.php?id='.$object->id;
56 56
 	$head[$tab][1] = $langs->trans("Documents");
57
-	if (($nbFiles+$nbLinks) > 0) $head[$tab][1].= ' <span class="badge">'.($nbFiles+$nbLinks).'</span>';
57
+	if (($nbFiles+$nbLinks) > 0) {
58
+	    $head[$tab][1].= ' <span class="badge">'.($nbFiles+$nbLinks).'</span>';
59
+	}
58 60
 	$head[$tab][2] = 'documents';
59 61
 	$tab++;
60 62
 
Please login to merge, or discard this patch.
dolibarr/htdocs/core/lib/donation.lib.php 1 patch
Braces   +12 added lines, -4 removed lines patch added patch discarded remove patch
@@ -85,16 +85,24 @@
 block discarded – undo
85 85
     $nbLinks=Link::count($db, $object->element, $object->id);
86 86
 	$head[$h][0] = DOL_URL_ROOT.'/don/document.php?id='.$object->id;
87 87
 	$head[$h][1] = $langs->trans('Documents');
88
-	if (($nbFiles+$nbLinks) > 0) $head[$h][1].= ' <span class="badge">'.($nbFiles+$nbLinks).'</span>';
88
+	if (($nbFiles+$nbLinks) > 0) {
89
+	    $head[$h][1].= ' <span class="badge">'.($nbFiles+$nbLinks).'</span>';
90
+	}
89 91
 	$head[$h][2] = 'documents';
90 92
 	$h++;
91 93
 
92 94
 	$nbNote = 0;
93
-	if(!empty($object->note_private)) $nbNote++;
94
-	if(!empty($object->note_public)) $nbNote++;
95
+	if(!empty($object->note_private)) {
96
+	    $nbNote++;
97
+	}
98
+	if(!empty($object->note_public)) {
99
+	    $nbNote++;
100
+	}
95 101
 	$head[$h][0] = DOL_URL_ROOT.'/don/note.php?id='.$object->id;
96 102
 	$head[$h][1] = $langs->trans("Notes");
97
-	if ($nbNote > 0) $head[$h][1].= ' <span class="badge">'.$nbNote.'</span>';
103
+	if ($nbNote > 0) {
104
+	    $head[$h][1].= ' <span class="badge">'.$nbNote.'</span>';
105
+	}
98 106
 	$head[$h][2] = 'note';
99 107
 	$h++;
100 108
 	
Please login to merge, or discard this patch.
dolibarr/htdocs/core/lib/project.lib.php 1 patch
Braces   +327 added lines, -132 removed lines patch added patch discarded remove patch
@@ -48,7 +48,9 @@  discard block
 block discarded – undo
48 48
 	$nbContact = count($object->liste_contact(-1,'internal')) + count($object->liste_contact(-1,'external'));
49 49
 	$head[$h][0] = DOL_URL_ROOT.'/projet/contact.php?id='.$object->id;
50 50
 	$head[$h][1] = $langs->trans("ProjectContact");
51
-	if ($nbContact > 0) $head[$h][1].= ' <span class="badge">'.$nbContact.'</span>';
51
+	if ($nbContact > 0) {
52
+	    $head[$h][1].= ' <span class="badge">'.$nbContact.'</span>';
53
+	}
52 54
 	$head[$h][2] = 'contact';
53 55
 	$h++;
54 56
 
@@ -61,7 +63,9 @@  discard block
 block discarded – undo
61 63
 		require_once DOL_DOCUMENT_ROOT.'/projet/class/task.class.php';
62 64
 		$taskstatic=new Task($db);
63 65
 		$nbTasks=count($taskstatic->getTasksArray(0, 0, $object->id, 0, 0));
64
-		if ($nbTasks > 0) $head[$h][1].= ' <span class="badge">'.($nbTasks).'</span>';
66
+		if ($nbTasks > 0) {
67
+		    $head[$h][1].= ' <span class="badge">'.($nbTasks).'</span>';
68
+		}
65 69
 		$head[$h][2] = 'tasks';
66 70
 		$h++;
67 71
 
@@ -76,13 +80,18 @@  discard block
 block discarded – undo
76 80
 		if ($resql)
77 81
 		{
78 82
 			$obj = $db->fetch_object($resql);
79
-			if ($obj) $nbTimeSpent=1;
83
+			if ($obj) {
84
+			    $nbTimeSpent=1;
85
+			}
86
+		} else {
87
+		    dol_print_error($db);
80 88
 		}
81
-		else dol_print_error($db);
82 89
 
83 90
 		$head[$h][0] = DOL_URL_ROOT.'/projet/tasks/time.php?withproject=1&projectid='.$object->id;
84 91
 		$head[$h][1] = $langs->trans("TimeSpent");
85
-		if ($nbTimeSpent > 0) $head[$h][1].= ' <span class="badge">...</span>';
92
+		if ($nbTimeSpent > 0) {
93
+		    $head[$h][1].= ' <span class="badge">...</span>';
94
+		}
86 95
 		$head[$h][2] = 'timespent';
87 96
 		$h++;
88 97
 	}
@@ -107,11 +116,17 @@  discard block
 block discarded – undo
107 116
 	if (empty($conf->global->MAIN_DISABLE_NOTES_TAB))
108 117
 	{
109 118
 		$nbNote = 0;
110
-		if(!empty($object->note_private)) $nbNote++;
111
-		if(!empty($object->note_public)) $nbNote++;
119
+		if(!empty($object->note_private)) {
120
+		    $nbNote++;
121
+		}
122
+		if(!empty($object->note_public)) {
123
+		    $nbNote++;
124
+		}
112 125
 		$head[$h][0] = DOL_URL_ROOT.'/projet/note.php?id='.$object->id;
113 126
 		$head[$h][1] = $langs->trans('Notes');
114
-		if ($nbNote > 0) $head[$h][1].= ' <span class="badge">'.$nbNote.'</span>';
127
+		if ($nbNote > 0) {
128
+		    $head[$h][1].= ' <span class="badge">'.$nbNote.'</span>';
129
+		}
115 130
 		$head[$h][2] = 'notes';
116 131
 		$h++;
117 132
 	}
@@ -123,7 +138,9 @@  discard block
 block discarded – undo
123 138
 	$nbLinks=Link::count($db, $object->element, $object->id);
124 139
 	$head[$h][0] = DOL_URL_ROOT.'/projet/document.php?id='.$object->id;
125 140
 	$head[$h][1] = $langs->trans('Documents');
126
-	if (($nbFiles+$nbLinks) > 0) $head[$h][1].= ' <span class="badge">'.($nbFiles+$nbLinks).'</span>';
141
+	if (($nbFiles+$nbLinks) > 0) {
142
+	    $head[$h][1].= ' <span class="badge">'.($nbFiles+$nbLinks).'</span>';
143
+	}
127 144
 	$head[$h][2] = 'document';
128 145
 	$h++;
129 146
 
@@ -133,7 +150,9 @@  discard block
 block discarded – undo
133 150
 		$nbComments = $object->getNbComments();
134 151
 		$head[$h][0] = DOL_URL_ROOT.'/projet/comment.php?id='.$object->id;
135 152
 		$head[$h][1] = $langs->trans("CommentLink");
136
-		if ($nbComments > 0) $head[$h][1].= ' <span class="badge">'.$nbComments.'</span>';
153
+		if ($nbComments > 0) {
154
+		    $head[$h][1].= ' <span class="badge">'.$nbComments.'</span>';
155
+		}
137 156
 		$head[$h][2] = 'project_comment';
138 157
 		$h++;
139 158
 	}
@@ -174,7 +193,9 @@  discard block
 block discarded – undo
174 193
 	$nbContact = count($object->liste_contact(-1,'internal')) + count($object->liste_contact(-1,'external'));
175 194
 	$head[$h][0] = DOL_URL_ROOT.'/projet/tasks/contact.php?id='.$object->id.(GETPOST('withproject')?'&withproject=1':'');
176 195
 	$head[$h][1] = $langs->trans("TaskRessourceLinks");
177
-	if ($nbContact > 0) $head[$h][1].= ' <span class="badge">'.$nbContact.'</span>';
196
+	if ($nbContact > 0) {
197
+	    $head[$h][1].= ' <span class="badge">'.$nbContact.'</span>';
198
+	}
178 199
 	$head[$h][2] = 'task_contact';
179 200
 	$h++;
180 201
 
@@ -189,13 +210,18 @@  discard block
 block discarded – undo
189 210
 	if ($resql)
190 211
 	{
191 212
 		$obj = $db->fetch_object($resql);
192
-		if ($obj) $nbTimeSpent=1;
213
+		if ($obj) {
214
+		    $nbTimeSpent=1;
215
+		}
216
+	} else {
217
+	    dol_print_error($db);
193 218
 	}
194
-	else dol_print_error($db);
195 219
 
196 220
 	$head[$h][0] = DOL_URL_ROOT.'/projet/tasks/time.php?id='.$object->id.(GETPOST('withproject')?'&withproject=1':'');
197 221
 	$head[$h][1] = $langs->trans("TimeSpent");
198
-	if ($nbTimeSpent > 0) $head[$h][1].= ' <span class="badge">...</span>';
222
+	if ($nbTimeSpent > 0) {
223
+	    $head[$h][1].= ' <span class="badge">...</span>';
224
+	}
199 225
 	$head[$h][2] = 'task_time';
200 226
 	$h++;
201 227
 
@@ -208,11 +234,17 @@  discard block
 block discarded – undo
208 234
 	if (empty($conf->global->MAIN_DISABLE_NOTES_TAB))
209 235
 	{
210 236
 		$nbNote = 0;
211
-		if(!empty($object->note_private)) $nbNote++;
212
-		if(!empty($object->note_public)) $nbNote++;
237
+		if(!empty($object->note_private)) {
238
+		    $nbNote++;
239
+		}
240
+		if(!empty($object->note_public)) {
241
+		    $nbNote++;
242
+		}
213 243
 		$head[$h][0] = DOL_URL_ROOT.'/projet/tasks/note.php?id='.$object->id.(GETPOST('withproject')?'&withproject=1':'');
214 244
 		$head[$h][1] = $langs->trans('Notes');
215
-		if ($nbNote > 0) $head[$h][1].= ' <span class="badge">'.$nbNote.'</span>';
245
+		if ($nbNote > 0) {
246
+		    $head[$h][1].= ' <span class="badge">'.$nbNote.'</span>';
247
+		}
216 248
 		$head[$h][2] = 'task_notes';
217 249
 		$h++;
218 250
 	}
@@ -224,7 +256,9 @@  discard block
 block discarded – undo
224 256
 	$nbFiles = count(dol_dir_list($filesdir,'files',0,'','(\.meta|_preview.*\.png)$'));
225 257
 	$nbLinks=Link::count($db, $object->element, $object->id);
226 258
 	$head[$h][1] = $langs->trans('Documents');
227
-	if (($nbFiles+$nbLinks) > 0) $head[$h][1].= ' <span class="badge">'.($nbFiles+$nbLinks).'</span>';
259
+	if (($nbFiles+$nbLinks) > 0) {
260
+	    $head[$h][1].= ' <span class="badge">'.($nbFiles+$nbLinks).'</span>';
261
+	}
228 262
 	$head[$h][2] = 'task_document';
229 263
 	$h++;
230 264
 
@@ -234,7 +268,9 @@  discard block
 block discarded – undo
234 268
 		$nbComments = $object->getNbComments();
235 269
 		$head[$h][0] = DOL_URL_ROOT.'/projet/tasks/comment.php?id='.$object->id.(GETPOST('withproject')?'&withproject=1':'');
236 270
 		$head[$h][1] = $langs->trans("CommentLink");
237
-		if ($nbComments > 0) $head[$h][1].= ' <span class="badge">'.$nbComments.'</span>';
271
+		if ($nbComments > 0) {
272
+		    $head[$h][1].= ' <span class="badge">'.$nbComments.'</span>';
273
+		}
238 274
 		$head[$h][2] = 'task_comment';
239 275
 		$h++;
240 276
 	}
@@ -261,7 +297,9 @@  discard block
 block discarded – undo
261 297
 
262 298
 	$param='';
263 299
 	$param.=($mode?'&mode='.$mode:'');
264
-	if (is_object($fuser) && $fuser->id > 0 && $fuser->id != $user->id) $param.='&search_usertoprocessid='.$fuser->id;
300
+	if (is_object($fuser) && $fuser->id > 0 && $fuser->id != $user->id) {
301
+	    $param.='&search_usertoprocessid='.$fuser->id;
302
+	}
265 303
 
266 304
 	if (empty($conf->global->PROJECT_DISABLE_TIMESHEET_PERWEEK))
267 305
 	{
@@ -380,15 +418,20 @@  discard block
 block discarded – undo
380 418
 
381 419
 	for ($i = 0 ; $i < $numlines ; $i++)
382 420
 	{
383
-		if ($parent == 0 && $level >= 0) $level = 0;              // if $level = -1, we dont' use sublevel recursion, we show all lines
421
+		if ($parent == 0 && $level >= 0) {
422
+		    $level = 0;
423
+		}
424
+		// if $level = -1, we dont' use sublevel recursion, we show all lines
384 425
 
385 426
 		// Process line
386 427
 		// print "i:".$i."-".$lines[$i]->fk_project.'<br>';
387 428
 
388
-		if ($lines[$i]->fk_parent == $parent || $level < 0)       // if $level = -1, we dont' use sublevel recursion, we show all lines
429
+		if ($lines[$i]->fk_parent == $parent || $level < 0) {
430
+		    // if $level = -1, we dont' use sublevel recursion, we show all lines
389 431
 		{
390 432
 			// Show task line.
391 433
 			$showline=1;
434
+		}
392 435
 			$showlineingray=0;
393 436
 
394 437
 			// If there is filters to use
@@ -404,14 +447,12 @@  discard block
 block discarded – undo
404 447
 					if ($foundtaskforuserdeeper > 0)
405 448
 					{
406 449
 						$showlineingray=1;		// We will show line but in gray
407
-					}
408
-					else
450
+					} else
409 451
 					{
410 452
 						$showline=0;			// No reason to show line
411 453
 					}
412 454
 				}
413
-			}
414
-			else
455
+			} else
415 456
 			{
416 457
 				// Caller did not ask to filter on tasks of a specific user (this probably means he want also tasks of all users, into public project
417 458
 				// or into all other projects if user has permission to).
@@ -448,8 +489,11 @@  discard block
 block discarded – undo
448 489
 					$projectstatic->ref=$lines[$i]->projectref;
449 490
 					$projectstatic->public=$lines[$i]->public;
450 491
 					$projectstatic->title=$lines[$i]->projectlabel;
451
-					if ($lines[$i]->public || in_array($lines[$i]->fk_project,$projectsArrayId) || ! empty($user->rights->projet->all->lire)) print $projectstatic->getNomUrl(1);
452
-					else print $projectstatic->getNomUrl(1,'nolink');
492
+					if ($lines[$i]->public || in_array($lines[$i]->fk_project,$projectsArrayId) || ! empty($user->rights->projet->all->lire)) {
493
+					    print $projectstatic->getNomUrl(1);
494
+					} else {
495
+					    print $projectstatic->getNomUrl(1,'nolink');
496
+					}
453 497
 					//if ($showlineingray) print '</i>';
454 498
 					print "</td>";
455 499
 
@@ -465,8 +509,7 @@  discard block
 block discarded – undo
465 509
 				if ($showlineingray)
466 510
 				{
467 511
 					print '<i>'.img_object('','projecttask').' '.$lines[$i]->ref.'</i>';
468
-				}
469
-				else
512
+				} else
470 513
 				{
471 514
 					$taskstatic->id=$lines[$i]->id;
472 515
 					$taskstatic->ref=$lines[$i]->ref;
@@ -477,14 +520,18 @@  discard block
 block discarded – undo
477 520
 
478 521
 				// Title of task
479 522
 				print "<td>";
480
-				if ($showlineingray) print '<i>';
523
+				if ($showlineingray) {
524
+				    print '<i>';
525
+				}
481 526
 				//else print '<a href="'.DOL_URL_ROOT.'/projet/tasks/task.php?id='.$lines[$i]->id.'&withproject=1">';
482 527
 				for ($k = 0 ; $k < $level ; $k++)
483 528
 				{
484 529
 					print "&nbsp; &nbsp; &nbsp;";
485 530
 				}
486 531
 				print $lines[$i]->label;
487
-				if ($showlineingray) print '</i>';
532
+				if ($showlineingray) {
533
+				    print '</i>';
534
+				}
488 535
 				//else print '</a>';
489 536
 				print "</td>\n";
490 537
 
@@ -500,13 +547,19 @@  discard block
 block discarded – undo
500 547
 				$taskstatic->fk_statut = $lines[$i]->status;
501 548
 				$taskstatic->datee = $lines[$i]->date_end;
502 549
 				print dol_print_date($lines[$i]->date_end,'dayhour');
503
-				if ($taskstatic->hasDelay()) print img_warning($langs->trans("Late"));
550
+				if ($taskstatic->hasDelay()) {
551
+				    print img_warning($langs->trans("Late"));
552
+				}
504 553
 				print '</td>';
505 554
 
506 555
 				$plannedworkloadoutputformat='allhourmin';
507 556
 				$timespentoutputformat='allhourmin';
508
-				if (! empty($conf->global->PROJECT_PLANNED_WORKLOAD_FORMAT)) $plannedworkloadoutputformat=$conf->global->PROJECT_PLANNED_WORKLOAD_FORMAT;
509
-				if (! empty($conf->global->PROJECT_TIMES_SPENT_FORMAT)) $timespentoutputformat=$conf->global->PROJECT_TIME_SPENT_FORMAT;
557
+				if (! empty($conf->global->PROJECT_PLANNED_WORKLOAD_FORMAT)) {
558
+				    $plannedworkloadoutputformat=$conf->global->PROJECT_PLANNED_WORKLOAD_FORMAT;
559
+				}
560
+				if (! empty($conf->global->PROJECT_TIMES_SPENT_FORMAT)) {
561
+				    $timespentoutputformat=$conf->global->PROJECT_TIME_SPENT_FORMAT;
562
+				}
510 563
 
511 564
 				// Planned Workload (in working hours)
512 565
 				print '<td align="right">';
@@ -523,20 +576,32 @@  discard block
 block discarded – undo
523 576
 
524 577
 				// Time spent
525 578
 				print '<td align="right">';
526
-				if ($showlineingray) print '<i>';
527
-				else print '<a href="'.DOL_URL_ROOT.'/projet/tasks/time.php?id='.$lines[$i]->id.($showproject?'':'&withproject=1').'">';
528
-				if ($lines[$i]->duration) print convertSecondToTime($lines[$i]->duration,$timespentoutputformat);
529
-				else print '--:--';
530
-				if ($showlineingray) print '</i>';
531
-				else print '</a>';
579
+				if ($showlineingray) {
580
+				    print '<i>';
581
+				} else {
582
+				    print '<a href="'.DOL_URL_ROOT.'/projet/tasks/time.php?id='.$lines[$i]->id.($showproject?'':'&withproject=1').'">';
583
+				}
584
+				if ($lines[$i]->duration) {
585
+				    print convertSecondToTime($lines[$i]->duration,$timespentoutputformat);
586
+				} else {
587
+				    print '--:--';
588
+				}
589
+				if ($showlineingray) {
590
+				    print '</i>';
591
+				} else {
592
+				    print '</a>';
593
+				}
532 594
 				print '</td>';
533 595
 
534 596
 				// Progress calculated (Note: ->duration is time spent)
535 597
 				print '<td align="right">';
536 598
 				if ($lines[$i]->planned_workload || $lines[$i]->duration)
537 599
 				{
538
-					if ($lines[$i]->planned_workload) print round(100 * $lines[$i]->duration / $lines[$i]->planned_workload,2).' %';
539
-					else print '<span class="opacitymedium">'.$langs->trans('WorkloadNotDefined').'</span>';
600
+					if ($lines[$i]->planned_workload) {
601
+					    print round(100 * $lines[$i]->duration / $lines[$i]->planned_workload,2).' %';
602
+					} else {
603
+					    print '<span class="opacitymedium">'.$langs->trans('WorkloadNotDefined').'</span>';
604
+					}
540 605
 				}
541 606
 				print '</td>';
542 607
 
@@ -559,8 +624,11 @@  discard block
 block discarded – undo
559 624
 						if (!empty($num)){
560 625
 							foreach ($tab as $contacttask){
561 626
 								//var_dump($contacttask);
562
-								if ($source == 'internal') $c = new User($db);
563
-								else $c = new Contact($db);
627
+								if ($source == 'internal') {
628
+								    $c = new User($db);
629
+								} else {
630
+								    $c = new Contact($db);
631
+								}
564 632
 								$c->fetch($contacttask['id']);
565 633
 								print $c->getNomUrl(1) . ' (' . $contacttask['libelle'] . ')' . '<br>';
566 634
 							}
@@ -577,21 +645,28 @@  discard block
 block discarded – undo
577 645
 
578 646
 				print "</tr>\n";
579 647
 
580
-				if (! $showlineingray) $inc++;
648
+				if (! $showlineingray) {
649
+				    $inc++;
650
+				}
581 651
 
582
-				if ($level >= 0)    // Call sublevels
652
+				if ($level >= 0) {
653
+				    // Call sublevels
583 654
 				{
584 655
 					$level++;
585
-					if ($lines[$i]->id) projectLinesa($inc, $lines[$i]->id, $lines, $level, $var, $showproject, $taskrole, $projectsListId, $addordertick);
656
+				}
657
+					if ($lines[$i]->id) {
658
+					    projectLinesa($inc, $lines[$i]->id, $lines, $level, $var, $showproject, $taskrole, $projectsListId, $addordertick);
659
+					}
586 660
 					$level--;
587 661
 				}
588 662
 
589 663
 				$total_projectlinesa_spent += $lines[$i]->duration;
590 664
 				$total_projectlinesa_planned += $lines[$i]->planned_workload;
591
-				if ($lines[$i]->planned_workload) $total_projectlinesa_spent_if_planned += $lines[$i]->duration;
665
+				if ($lines[$i]->planned_workload) {
666
+				    $total_projectlinesa_spent_if_planned += $lines[$i]->duration;
667
+				}
592 668
 			}
593
-		}
594
-		else
669
+		} else
595 670
 		{
596 671
 			//$level--;
597 672
 		}
@@ -601,7 +676,9 @@  discard block
 block discarded – undo
601 676
 	{
602 677
 		print '<tr class="liste_total nodrag nodrop">';
603 678
 		print '<td class="liste_total">'.$langs->trans("Total").'</td>';
604
-		if ($showproject) print '<td></td><td></td>';
679
+		if ($showproject) {
680
+		    print '<td></td><td></td>';
681
+		}
605 682
 		print '<td></td>';
606 683
 		print '<td></td>';
607 684
 		print '<td></td>';
@@ -609,12 +686,18 @@  discard block
 block discarded – undo
609 686
 		print convertSecondToTime($total_projectlinesa_planned, 'allhourmin');
610 687
 		print '</td>';
611 688
 		print '<td align="right" class="nowrap liste_total">';
612
-		if ($projectidfortotallink > 0) print '<a href="'.DOL_URL_ROOT.'/projet/tasks/time.php?projectid='.$projectidfortotallink.($showproject?'':'&withproject=1').'">';
689
+		if ($projectidfortotallink > 0) {
690
+		    print '<a href="'.DOL_URL_ROOT.'/projet/tasks/time.php?projectid='.$projectidfortotallink.($showproject?'':'&withproject=1').'">';
691
+		}
613 692
 		print convertSecondToTime($total_projectlinesa_spent, 'allhourmin');
614
-		if ($projectidfortotallink > 0) print '</a>';
693
+		if ($projectidfortotallink > 0) {
694
+		    print '</a>';
695
+		}
615 696
 		print '</td>';
616 697
 		print '<td align="right" class="nowrap liste_total">';
617
-		if ($total_projectlinesa_planned) print round(100 * $total_projectlinesa_spent / $total_projectlinesa_planned,2).' %';
698
+		if ($total_projectlinesa_planned) {
699
+		    print round(100 * $total_projectlinesa_spent / $total_projectlinesa_planned,2).' %';
700
+		}
618 701
 		print '</td>';
619 702
 		print '<td></td>';
620 703
 		// Contacts of task
@@ -622,7 +705,9 @@  discard block
 block discarded – undo
622 705
 		{
623 706
 			print '<td></td>';
624 707
 		}
625
-		if ($addordertick) print '<td class="hideonsmartphone"></td>';
708
+		if ($addordertick) {
709
+		    print '<td class="hideonsmartphone"></td>';
710
+		}
626 711
 		print '</tr>';
627 712
 	}
628 713
 
@@ -660,11 +745,16 @@  discard block
 block discarded – undo
660 745
 	$numlines=count($lines);
661 746
 
662 747
 	// Create a smaller array with sublevels only to be used later. This increase dramatically performances.
663
-	if ($parent == 0) // Always and only if at first level
748
+	if ($parent == 0) {
749
+	    // Always and only if at first level
664 750
 	{
665
-		for ($i = 0 ; $i < $numlines ; $i++)
751
+		for ($i = 0 ;
752
+	}
753
+	$i < $numlines ; $i++)
666 754
 		{
667
-			if ($lines[$i]->fk_task_parent) $lineswithoutlevel0[]=$lines[$i];
755
+			if ($lines[$i]->fk_task_parent) {
756
+			    $lineswithoutlevel0[]=$lines[$i];
757
+			}
668 758
 		}
669 759
 	}
670 760
 
@@ -676,7 +766,9 @@  discard block
 block discarded – undo
676 766
 	//dol_syslog('projectLinesPerDay inc='.$inc.' preselectedday='.$preselectedday.' task parent id='.$parent.' level='.$level." count(lines)=".$numlines." count(lineswithoutlevel0)=".count($lineswithoutlevel0));
677 767
 	for ($i = 0 ; $i < $numlines ; $i++)
678 768
 	{
679
-		if ($parent == 0) $level = 0;
769
+		if ($parent == 0) {
770
+		    $level = 0;
771
+		}
680 772
 
681 773
 		//if ($lines[$i]->fk_task_parent == $parent)
682 774
 		//{
@@ -733,7 +825,9 @@  discard block
 block discarded – undo
733 825
 					print '</tr>';
734 826
 				}
735 827
 
736
-				if ($oldprojectforbreak != -1) $oldprojectforbreak = $projectstatic->id;
828
+				if ($oldprojectforbreak != -1) {
829
+				    $oldprojectforbreak = $projectstatic->id;
830
+				}
737 831
 
738 832
 				print '<tr class="oddeven">'."\n";
739 833
 
@@ -755,17 +849,23 @@  discard block
 block discarded – undo
755 849
 
756 850
 				// Thirdparty
757 851
 				print '<td class="tdoverflowmax100">';
758
-				if ($thirdpartystatic->id > 0) print $thirdpartystatic->getNomUrl(1, 'project', 10);
852
+				if ($thirdpartystatic->id > 0) {
853
+				    print $thirdpartystatic->getNomUrl(1, 'project', 10);
854
+				}
759 855
 				print '</td>';
760 856
 
761 857
 				// Ref
762 858
 				print '<td>';
763 859
 				print '<!-- Task id = '.$lines[$i]->id.' -->';
764
-				for ($k = 0 ; $k < $level ; $k++) print "&nbsp;&nbsp;&nbsp;";
860
+				for ($k = 0 ; $k < $level ; $k++) {
861
+				    print "&nbsp;&nbsp;&nbsp;";
862
+				}
765 863
 				print $taskstatic->getNomUrl(1, 'withproject', 'time');
766 864
 				// Label task
767 865
 				print '<br>';
768
-				for ($k = 0 ; $k < $level ; $k++) print "&nbsp;&nbsp;&nbsp;";
866
+				for ($k = 0 ; $k < $level ; $k++) {
867
+				    print "&nbsp;&nbsp;&nbsp;";
868
+				}
769 869
 				print $taskstatic->label;
770 870
 				//print "<br>";
771 871
 				//for ($k = 0 ; $k < $level ; $k++) print "&nbsp;&nbsp;&nbsp;";
@@ -799,9 +899,13 @@  discard block
 block discarded – undo
799 899
 				print '</td>';
800 900
 
801 901
 				$cssonholiday='';
802
-				if (! $isavailable[$preselectedday]['morning'] && ! $isavailable[$preselectedday]['afternoon'])   $cssonholiday.='onholidayallday ';
803
-				elseif (! $isavailable[$preselectedday]['morning'])   $cssonholiday.='onholidaymorning ';
804
-				elseif (! $isavailable[$preselectedday]['afternoon']) $cssonholiday.='onholidayafternoon ';
902
+				if (! $isavailable[$preselectedday]['morning'] && ! $isavailable[$preselectedday]['afternoon']) {
903
+				    $cssonholiday.='onholidayallday ';
904
+				} elseif (! $isavailable[$preselectedday]['morning']) {
905
+				    $cssonholiday.='onholidaymorning ';
906
+				} elseif (! $isavailable[$preselectedday]['afternoon']) {
907
+				    $cssonholiday.='onholidayafternoon ';
908
+				}
805 909
 
806 910
 				// Duration
807 911
 				print '<td align="center" class="duration'.($cssonholiday?' '.$cssonholiday:'').'">';
@@ -810,7 +914,9 @@  discard block
 block discarded – undo
810 914
 				$totalforeachline[$preselectedday]+=$lines[$i]->timespent_duration;
811 915
 
812 916
 				$alreadyspent='';
813
-				if ($dayWorkLoad > 0) $alreadyspent=convertSecondToTime($lines[$i]->timespent_duration,'allhourmin');
917
+				if ($dayWorkLoad > 0) {
918
+				    $alreadyspent=convertSecondToTime($lines[$i]->timespent_duration,'allhourmin');
919
+				}
814 920
 
815 921
 				print convertSecondToTime($lines[$i]->timespent_duration,'allhourmin');
816 922
 
@@ -886,11 +992,16 @@  discard block
 block discarded – undo
886 992
 	$numlines=count($lines);
887 993
 
888 994
 	// Create a smaller array with sublevels only to be used later. This increase dramatically performances.
889
-	if ($parent == 0) // Always and only if at first level
995
+	if ($parent == 0) {
996
+	    // Always and only if at first level
890 997
 	{
891
-		for ($i = 0 ; $i < $numlines ; $i++)
998
+		for ($i = 0 ;
999
+	}
1000
+	$i < $numlines ; $i++)
892 1001
 		{
893
-			if ($lines[$i]->fk_task_parent) $lineswithoutlevel0[]=$lines[$i];
1002
+			if ($lines[$i]->fk_task_parent) {
1003
+			    $lineswithoutlevel0[]=$lines[$i];
1004
+			}
894 1005
 		}
895 1006
 	}
896 1007
 
@@ -902,7 +1013,9 @@  discard block
 block discarded – undo
902 1013
 	//dol_syslog('projectLinesPerDay inc='.$inc.' preselectedday='.$preselectedday.' task parent id='.$parent.' level='.$level." count(lines)=".$numlines." count(lineswithoutlevel0)=".count($lineswithoutlevel0));
903 1014
 	for ($i = 0 ; $i < $numlines ; $i++)
904 1015
 	{
905
-		if ($parent == 0) $level = 0;
1016
+		if ($parent == 0) {
1017
+		    $level = 0;
1018
+		}
906 1019
 
907 1020
 		if ($lines[$i]->fk_task_parent == $parent)
908 1021
 		{
@@ -911,10 +1024,12 @@  discard block
 block discarded – undo
911 1024
 			{
912 1025
 				//dol_syslog("projectLinesPerWeek Found line ".$i.", a qualified task (i have role or want to show all tasks) with id=".$lines[$i]->id." project id=".$lines[$i]->fk_project);
913 1026
 
914
-				if ($restricteditformytask == 2 && empty($tasksrole[$lines[$i]->id]))	// we have no role on task and we request to hide such cases
1027
+				if ($restricteditformytask == 2 && empty($tasksrole[$lines[$i]->id])) {
1028
+				    // we have no role on task and we request to hide such cases
915 1029
 				{
916 1030
 					continue;
917 1031
 				}
1032
+				}
918 1033
 
919 1034
 				// Break on a new project
920 1035
 				if ($parent == 0 && $lines[$i]->fk_project != $lastprojectid)
@@ -955,7 +1070,9 @@  discard block
 block discarded – undo
955 1070
 					print '<tr class="oddeven trforbreak">'."\n";
956 1071
 					print '<td colspan="9">';
957 1072
 					print $projectstatic->getNomUrl(1,'',0,'<strong>'.$langs->transnoentitiesnoconv("YourRole").':</strong> '.$projectsrole[$lines[$i]->fk_project]);
958
-					if ($thirdpartystatic->id > 0) print ' - '.$thirdpartystatic->getNomUrl(1);
1073
+					if ($thirdpartystatic->id > 0) {
1074
+					    print ' - '.$thirdpartystatic->getNomUrl(1);
1075
+					}
959 1076
 					if ($projectstatic->title)
960 1077
 					{
961 1078
 						print ' - ';
@@ -965,7 +1082,9 @@  discard block
 block discarded – undo
965 1082
 					print '</tr>';
966 1083
 				}
967 1084
 
968
-				if ($oldprojectforbreak != -1) $oldprojectforbreak = $projectstatic->id;
1085
+				if ($oldprojectforbreak != -1) {
1086
+				    $oldprojectforbreak = $projectstatic->id;
1087
+				}
969 1088
 
970 1089
 				print '<tr class="oddeven">'."\n";
971 1090
 
@@ -989,11 +1108,15 @@  discard block
 block discarded – undo
989 1108
 				// Ref
990 1109
 				print '<td>';
991 1110
 				print '<!-- Task id = '.$lines[$i]->id.' -->';
992
-				for ($k = 0 ; $k < $level ; $k++) print "&nbsp;&nbsp;&nbsp;";
1111
+				for ($k = 0 ; $k < $level ; $k++) {
1112
+				    print "&nbsp;&nbsp;&nbsp;";
1113
+				}
993 1114
 				print $taskstatic->getNomUrl(1, 'withproject', 'time');
994 1115
 				// Label task
995 1116
 				print '<br>';
996
-				for ($k = 0 ; $k < $level ; $k++) print "&nbsp;&nbsp;&nbsp;";
1117
+				for ($k = 0 ; $k < $level ; $k++) {
1118
+				    print "&nbsp;&nbsp;&nbsp;";
1119
+				}
997 1120
 				print $taskstatic->label;
998 1121
 				//print "<br>";
999 1122
 				//for ($k = 0 ; $k < $level ; $k++) print "&nbsp;&nbsp;&nbsp;";
@@ -1002,8 +1125,11 @@  discard block
 block discarded – undo
1002 1125
 
1003 1126
 				// Planned Workload
1004 1127
 				print '<td align="right" class="leftborder plannedworkload">';
1005
-				if ($lines[$i]->planned_workload) print convertSecondToTime($lines[$i]->planned_workload,'allhourmin');
1006
-				else print '--:--';
1128
+				if ($lines[$i]->planned_workload) {
1129
+				    print convertSecondToTime($lines[$i]->planned_workload,'allhourmin');
1130
+				} else {
1131
+				    print '--:--';
1132
+				}
1007 1133
 				print '</td>';
1008 1134
 
1009 1135
 				// Progress declared %
@@ -1019,15 +1145,19 @@  discard block
 block discarded – undo
1019 1145
 					print '<a href="'.DOL_URL_ROOT.'/projet/tasks/time.php?id='.$lines[$i]->id.'">';
1020 1146
 					print convertSecondToTime($lines[$i]->duration,'allhourmin');
1021 1147
 					print '</a>';
1148
+				} else {
1149
+				    print '--:--';
1022 1150
 				}
1023
-				else print '--:--';
1024 1151
 				print "</td>\n";
1025 1152
 
1026 1153
 				// Time spent by user
1027 1154
 				print '<td align="right">';
1028 1155
 				$tmptimespent=$taskstatic->getSummaryOfTimeSpent($fuser->id);
1029
-				if ($tmptimespent['total_duration']) print convertSecondToTime($tmptimespent['total_duration'],'allhourmin');
1030
-				else print '--:--';
1156
+				if ($tmptimespent['total_duration']) {
1157
+				    print convertSecondToTime($tmptimespent['total_duration'],'allhourmin');
1158
+				} else {
1159
+				    print '--:--';
1160
+				}
1031 1161
 				print "</td>\n";
1032 1162
 
1033 1163
 				$disabledproject=1;$disabledtask=1;
@@ -1053,9 +1183,13 @@  discard block
 block discarded – undo
1053 1183
 				print '</td>';
1054 1184
 
1055 1185
 				$cssonholiday='';
1056
-				if (! $isavailable[$preselectedday]['morning'] && ! $isavailable[$preselectedday]['afternoon'])   $cssonholiday.='onholidayallday ';
1057
-				elseif (! $isavailable[$preselectedday]['morning'])   $cssonholiday.='onholidaymorning ';
1058
-				elseif (! $isavailable[$preselectedday]['afternoon']) $cssonholiday.='onholidayafternoon ';
1186
+				if (! $isavailable[$preselectedday]['morning'] && ! $isavailable[$preselectedday]['afternoon']) {
1187
+				    $cssonholiday.='onholidayallday ';
1188
+				} elseif (! $isavailable[$preselectedday]['morning']) {
1189
+				    $cssonholiday.='onholidaymorning ';
1190
+				} elseif (! $isavailable[$preselectedday]['afternoon']) {
1191
+				    $cssonholiday.='onholidayafternoon ';
1192
+				}
1059 1193
 
1060 1194
 				global $daytoparse;
1061 1195
 				$tmparray = dol_getdate($daytoparse,true);	// detail of current day
@@ -1063,10 +1197,12 @@  discard block
 block discarded – undo
1063 1197
 
1064 1198
 				global $numstartworkingday, $numendworkingday;
1065 1199
 				$cssweekend='';
1066
-				if (($idw + 1) < $numstartworkingday || ($idw + 1) > $numendworkingday)	// This is a day is not inside the setup of working days, so we use a week-end css.
1200
+				if (($idw + 1) < $numstartworkingday || ($idw + 1) > $numendworkingday) {
1201
+				    // This is a day is not inside the setup of working days, so we use a week-end css.
1067 1202
 				{
1068 1203
 					$cssweekend='weekend';
1069 1204
 				}
1205
+				}
1070 1206
 
1071 1207
 				// Duration
1072 1208
 				print '<td class="center duration'.($cssonholiday?' '.$cssonholiday:'').($cssweekend?' '.$cssweekend:'').'">';
@@ -1074,7 +1210,9 @@  discard block
 block discarded – undo
1074 1210
 				$totalforeachday[$preselectedday]+=$dayWorkLoad;
1075 1211
 
1076 1212
 				$alreadyspent='';
1077
-				if ($dayWorkLoad > 0) $alreadyspent=convertSecondToTime($dayWorkLoad,'allhourmin');
1213
+				if ($dayWorkLoad > 0) {
1214
+				    $alreadyspent=convertSecondToTime($dayWorkLoad,'allhourmin');
1215
+				}
1078 1216
 
1079 1217
 				$idw = 0;
1080 1218
 
@@ -1104,11 +1242,14 @@  discard block
 block discarded – undo
1104 1242
 
1105 1243
 				// Warning
1106 1244
 				print '<td align="right">';
1107
-   				if ((! $lines[$i]->public) && $disabledproject) print $form->textwithpicto('',$langs->trans("UserIsNotContactOfProject"));
1108
-   				else if ($disabledtask)
1245
+   				if ((! $lines[$i]->public) && $disabledproject) {
1246
+   				    print $form->textwithpicto('',$langs->trans("UserIsNotContactOfProject"));
1247
+   				} else if ($disabledtask)
1109 1248
    				{
1110 1249
    					$titleassigntask = $langs->trans("AssignTaskToMe");
1111
-   					if ($fuser->id != $user->id) $titleassigntask = $langs->trans("AssignTaskToUser", '...');
1250
+   					if ($fuser->id != $user->id) {
1251
+   					    $titleassigntask = $langs->trans("AssignTaskToUser", '...');
1252
+   					}
1112 1253
 
1113 1254
    					print $form->textwithpicto('',$langs->trans("TaskIsNotAssignedToUser", $titleassigntask));
1114 1255
    				}
@@ -1134,8 +1275,7 @@  discard block
 block discarded – undo
1134 1275
 				//var_dump($totalforeachday);
1135 1276
 			}
1136 1277
 			$level--;
1137
-		}
1138
-		else
1278
+		} else
1139 1279
 		{
1140 1280
 			//$level--;
1141 1281
 		}
@@ -1175,11 +1315,16 @@  discard block
 block discarded – undo
1175 1315
 	$lineswithoutlevel0=array();
1176 1316
 
1177 1317
 	// Create a smaller array with sublevels only to be used later. This increase dramatically performances.
1178
-	if ($parent == 0) // Always and only if at first level
1318
+	if ($parent == 0) {
1319
+	    // Always and only if at first level
1179 1320
 	{
1180
-		for ($i = 0 ; $i < $numlines ; $i++)
1321
+		for ($i = 0 ;
1322
+	}
1323
+	$i < $numlines ; $i++)
1181 1324
 		{
1182
-		   if ($lines[$i]->fk_task_parent) $lineswithoutlevel0[]=$lines[$i];
1325
+		   if ($lines[$i]->fk_task_parent) {
1326
+		       $lineswithoutlevel0[]=$lines[$i];
1327
+		   }
1183 1328
 		}
1184 1329
 	}
1185 1330
 
@@ -1192,7 +1337,9 @@  discard block
 block discarded – undo
1192 1337
 
1193 1338
 	for ($i = 0 ; $i < $numlines ; $i++)
1194 1339
 	{
1195
-		if ($parent == 0) $level = 0;
1340
+		if ($parent == 0) {
1341
+		    $level = 0;
1342
+		}
1196 1343
 
1197 1344
 		if ($lines[$i]->fk_task_parent == $parent)
1198 1345
 		{
@@ -1201,10 +1348,12 @@  discard block
 block discarded – undo
1201 1348
 			{
1202 1349
 				//dol_syslog("projectLinesPerWeek Found line ".$i.", a qualified task (i have role or want to show all tasks) with id=".$lines[$i]->id." project id=".$lines[$i]->fk_project);
1203 1350
 
1204
-				if ($restricteditformytask == 2 && empty($tasksrole[$lines[$i]->id]))	// we have no role on task and we request to hide such cases
1351
+				if ($restricteditformytask == 2 && empty($tasksrole[$lines[$i]->id])) {
1352
+				    // we have no role on task and we request to hide such cases
1205 1353
 				{
1206 1354
 					continue;
1207 1355
 				}
1356
+				}
1208 1357
 
1209 1358
 				// Break on a new project
1210 1359
 				if ($parent == 0 && $lines[$i]->fk_project != $lastprojectid)
@@ -1244,7 +1393,9 @@  discard block
 block discarded – undo
1244 1393
 					print '<tr class="oddeven trforbreak">'."\n";
1245 1394
 					print '<td colspan="13">';
1246 1395
 					print $projectstatic->getNomUrl(1,'',0,'<strong>'.$langs->transnoentitiesnoconv("YourRole").':</strong> '.$projectsrole[$lines[$i]->fk_project]);
1247
-					if ($thirdpartystatic->id > 0) print ' - '.$thirdpartystatic->getNomUrl(1);
1396
+					if ($thirdpartystatic->id > 0) {
1397
+					    print ' - '.$thirdpartystatic->getNomUrl(1);
1398
+					}
1248 1399
 					if ($projectstatic->title)
1249 1400
 					{
1250 1401
 						print ' - ';
@@ -1254,7 +1405,9 @@  discard block
 block discarded – undo
1254 1405
 					print '</tr>';
1255 1406
 				}
1256 1407
 
1257
-				if ($oldprojectforbreak != -1) $oldprojectforbreak = $projectstatic->id;
1408
+				if ($oldprojectforbreak != -1) {
1409
+				    $oldprojectforbreak = $projectstatic->id;
1410
+				}
1258 1411
 
1259 1412
 				print '<tr class="oddeven">'."\n";
1260 1413
 
@@ -1278,11 +1431,15 @@  discard block
 block discarded – undo
1278 1431
 				// Ref
1279 1432
 				print '<td class="nowrap">';
1280 1433
 				print '<!-- Task id = '.$lines[$i]->id.' -->';
1281
-				for ($k = 0 ; $k < $level ; $k++) print "&nbsp;&nbsp;&nbsp;";
1434
+				for ($k = 0 ; $k < $level ; $k++) {
1435
+				    print "&nbsp;&nbsp;&nbsp;";
1436
+				}
1282 1437
 				print $taskstatic->getNomUrl(1, 'withproject', 'time');
1283 1438
 				// Label task
1284 1439
 				print '<br>';
1285
-				for ($k = 0 ; $k < $level ; $k++) print "&nbsp;&nbsp;&nbsp;";
1440
+				for ($k = 0 ; $k < $level ; $k++) {
1441
+				    print "&nbsp;&nbsp;&nbsp;";
1442
+				}
1286 1443
 				//print $taskstatic->getNomUrl(0, 'withproject', 'time');
1287 1444
 				print $taskstatic->label;
1288 1445
 				//print "<br>";
@@ -1292,8 +1449,11 @@  discard block
 block discarded – undo
1292 1449
 
1293 1450
 				// Planned Workload
1294 1451
 				print '<td align="right" class="leftborder plannedworkload">';
1295
-				if ($lines[$i]->planned_workload) print convertSecondToTime($lines[$i]->planned_workload,'allhourmin');
1296
-				else print '--:--';
1452
+				if ($lines[$i]->planned_workload) {
1453
+				    print convertSecondToTime($lines[$i]->planned_workload,'allhourmin');
1454
+				} else {
1455
+				    print '--:--';
1456
+				}
1297 1457
 				print '</td>';
1298 1458
 
1299 1459
 				// Progress declared %
@@ -1309,15 +1469,19 @@  discard block
 block discarded – undo
1309 1469
 					print '<a href="'.DOL_URL_ROOT.'/projet/tasks/time.php?id='.$lines[$i]->id.'">';
1310 1470
 					print convertSecondToTime($lines[$i]->duration,'allhourmin');
1311 1471
 					print '</a>';
1472
+				} else {
1473
+				    print '--:--';
1312 1474
 				}
1313
-				else print '--:--';
1314 1475
 				print "</td>\n";
1315 1476
 
1316 1477
 				// Time spent by user
1317 1478
 				print '<td align="right">';
1318 1479
 				$tmptimespent=$taskstatic->getSummaryOfTimeSpent($fuser->id);
1319
-				if ($tmptimespent['total_duration']) print convertSecondToTime($tmptimespent['total_duration'],'allhourmin');
1320
-				else print '--:--';
1480
+				if ($tmptimespent['total_duration']) {
1481
+				    print convertSecondToTime($tmptimespent['total_duration'],'allhourmin');
1482
+				} else {
1483
+				    print '--:--';
1484
+				}
1321 1485
 				print "</td>\n";
1322 1486
 
1323 1487
 				$disabledproject=1;$disabledtask=1;
@@ -1345,24 +1509,32 @@  discard block
 block discarded – undo
1345 1509
 					$tmpday=dol_time_plus_duree($firstdaytoshow, $idw, 'd');
1346 1510
 
1347 1511
 					$cssonholiday='';
1348
-					if (! $isavailable[$tmpday]['morning'] && ! $isavailable[$tmpday]['afternoon'])   $cssonholiday.='onholidayallday ';
1349
-					elseif (! $isavailable[$tmpday]['morning'])   $cssonholiday.='onholidaymorning ';
1350
-					elseif (! $isavailable[$tmpday]['afternoon']) $cssonholiday.='onholidayafternoon ';
1512
+					if (! $isavailable[$tmpday]['morning'] && ! $isavailable[$tmpday]['afternoon']) {
1513
+					    $cssonholiday.='onholidayallday ';
1514
+					} elseif (! $isavailable[$tmpday]['morning']) {
1515
+					    $cssonholiday.='onholidaymorning ';
1516
+					} elseif (! $isavailable[$tmpday]['afternoon']) {
1517
+					    $cssonholiday.='onholidayafternoon ';
1518
+					}
1351 1519
 
1352 1520
 					$tmparray=dol_getdate($tmpday);
1353 1521
 					$dayWorkLoad = $projectstatic->weekWorkLoadPerTask[$tmpday][$lines[$i]->id];
1354 1522
 					$totalforeachday[$tmpday]+=$dayWorkLoad;
1355 1523
 
1356 1524
 					$alreadyspent='';
1357
-					if ($dayWorkLoad > 0) $alreadyspent=convertSecondToTime($dayWorkLoad,'allhourmin');
1525
+					if ($dayWorkLoad > 0) {
1526
+					    $alreadyspent=convertSecondToTime($dayWorkLoad,'allhourmin');
1527
+					}
1358 1528
 					$alttitle=$langs->trans("AddHereTimeSpentForDay",$tmparray['day'],$tmparray['mon']);
1359 1529
 
1360 1530
 					global $numstartworkingday, $numendworkingday;
1361 1531
 					$cssweekend='';
1362
-					if (($idw + 1) < $numstartworkingday || ($idw + 1) > $numendworkingday)	// This is a day is not inside the setup of working days, so we use a week-end css.
1532
+					if (($idw + 1) < $numstartworkingday || ($idw + 1) > $numendworkingday) {
1533
+					    // This is a day is not inside the setup of working days, so we use a week-end css.
1363 1534
 					{
1364 1535
 						$cssweekend='weekend';
1365 1536
 					}
1537
+					}
1366 1538
 
1367 1539
 					$tableCell ='<td align="center" class="hide'.$idw.($cssonholiday?' '.$cssonholiday:'').($cssweekend?' '.$cssweekend:'').'">';
1368 1540
 					$placeholder='';
@@ -1382,11 +1554,14 @@  discard block
 block discarded – undo
1382 1554
 
1383 1555
 				// Warning
1384 1556
 				print '<td align="right">';
1385
-   				if ((! $lines[$i]->public) && $disabledproject) print $form->textwithpicto('',$langs->trans("UserIsNotContactOfProject"));
1386
-   				else if ($disabledtask)
1557
+   				if ((! $lines[$i]->public) && $disabledproject) {
1558
+   				    print $form->textwithpicto('',$langs->trans("UserIsNotContactOfProject"));
1559
+   				} else if ($disabledtask)
1387 1560
    				{
1388 1561
    					$titleassigntask = $langs->trans("AssignTaskToMe");
1389
-   					if ($fuser->id != $user->id) $titleassigntask = $langs->trans("AssignTaskToUser", '...');
1562
+   					if ($fuser->id != $user->id) {
1563
+   					    $titleassigntask = $langs->trans("AssignTaskToUser", '...');
1564
+   					}
1390 1565
 
1391 1566
    					print $form->textwithpicto('',$langs->trans("TaskIsNotAssignedToUser", $titleassigntask));
1392 1567
    				}
@@ -1413,8 +1588,7 @@  discard block
 block discarded – undo
1413 1588
 				//var_dump($totalforeachday);
1414 1589
 			}
1415 1590
 			$level--;
1416
-		}
1417
-		else
1591
+		} else
1418 1592
 		{
1419 1593
 			//$level--;
1420 1594
 		}
@@ -1453,7 +1627,9 @@  discard block
 block discarded – undo
1453 1627
 			searchTaskInChild($inc, $lines[$i]->id, $lines, $taskrole);
1454 1628
 			//print 'Found inc='.$inc.'<br>';
1455 1629
 
1456
-			if ($inc > 0) return $inc;
1630
+			if ($inc > 0) {
1631
+			    return $inc;
1632
+			}
1457 1633
 		}
1458 1634
 	}
1459 1635
 
@@ -1487,7 +1663,9 @@  discard block
 block discarded – undo
1487 1663
 	$project_year_filter=0;
1488 1664
 
1489 1665
 	$title=$langs->trans("Projects");
1490
-	if (strcmp($statut, '') && $statut >= 0) $title=$langs->trans("Projects").' '.$langs->trans($projectstatic->statuts_long[$statut]);
1666
+	if (strcmp($statut, '') && $statut >= 0) {
1667
+	    $title=$langs->trans("Projects").' '.$langs->trans($projectstatic->statuts_long[$statut]);
1668
+	}
1491 1669
 
1492 1670
 	$arrayidtypeofcontact=array();
1493 1671
 
@@ -1500,14 +1678,15 @@  discard block
 block discarded – undo
1500 1678
 		$sql.= ", ".MAIN_DB_PREFIX."projet_task as t";
1501 1679
 		$sql.= ", ".MAIN_DB_PREFIX."element_contact as ec";
1502 1680
 		$sql.= ", ".MAIN_DB_PREFIX."c_type_contact as ctc";
1503
-	}
1504
-	else
1681
+	} else
1505 1682
 	{
1506 1683
 		$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."projet_task as t ON p.rowid = t.fk_projet";
1507 1684
 	}
1508 1685
 	$sql.= " WHERE p.entity IN (".getEntity('project').")";
1509 1686
 	$sql.= " AND p.rowid IN (".$projectsListId.")";
1510
-	if ($socid) $sql.= "  AND (p.fk_soc IS NULL OR p.fk_soc = 0 OR p.fk_soc = ".$socid.")";
1687
+	if ($socid) {
1688
+	    $sql.= "  AND (p.fk_soc IS NULL OR p.fk_soc = 0 OR p.fk_soc = ".$socid.")";
1689
+	}
1511 1690
 	if ($mytasks)
1512 1691
 	{
1513 1692
 		$sql.= " AND p.rowid = t.fk_projet";
@@ -1550,9 +1729,12 @@  discard block
 block discarded – undo
1550 1729
 			$arrayidofprojects[$objp->projectid]=$objp->projectid;
1551 1730
 			$i++;
1552 1731
 		}
1732
+	} else {
1733
+	    dol_print_error($db);
1734
+	}
1735
+	if (empty($arrayidofprojects)) {
1736
+	    $arrayidofprojects[0]=-1;
1553 1737
 	}
1554
-	else dol_print_error($db);
1555
-	if (empty($arrayidofprojects)) $arrayidofprojects[0]=-1;
1556 1738
 
1557 1739
 	// Get list of project with calculation on tasks
1558 1740
 	$sql2 = "SELECT p.rowid as projectid, p.ref, p.title, p.fk_soc, s.nom as socname, p.fk_user_creat, p.public, p.fk_statut as status, p.fk_opp_status as opp_status, p.opp_amount,";
@@ -1586,8 +1768,12 @@  discard block
 block discarded – undo
1586 1768
 		if (empty($conf->global->PROJECT_HIDE_TASKS))
1587 1769
 		{
1588 1770
 			print_liste_field_titre("Tasks","","","","",'align="right"',$sortfield,$sortorder);
1589
-			if (! in_array('plannedworkload', $hiddenfields))  print_liste_field_titre("PlannedWorkload","","","","",'align="right"',$sortfield,$sortorder);
1590
-			if (! in_array('declaredprogress', $hiddenfields)) print_liste_field_titre("ProgressDeclared","","","","",'align="right"',$sortfield,$sortorder);
1771
+			if (! in_array('plannedworkload', $hiddenfields)) {
1772
+			    print_liste_field_titre("PlannedWorkload","","","","",'align="right"',$sortfield,$sortorder);
1773
+			}
1774
+			if (! in_array('declaredprogress', $hiddenfields)) {
1775
+			    print_liste_field_titre("ProgressDeclared","","","","",'align="right"',$sortfield,$sortorder);
1776
+			}
1591 1777
 		}
1592 1778
 		print_liste_field_titre("Status","","","","",'align="right"',$sortfield,$sortorder);
1593 1779
 		print "</tr>\n";
@@ -1616,7 +1802,9 @@  discard block
 block discarded – undo
1616 1802
 				print '<tr class="oddeven">';
1617 1803
 				print '<td>';
1618 1804
 				print $projectstatic->getNomUrl(1);
1619
-				if (! in_array('projectlabel', $hiddenfields)) print '<br>'.dol_trunc($objp->title,24);
1805
+				if (! in_array('projectlabel', $hiddenfields)) {
1806
+				    print '<br>'.dol_trunc($objp->title,24);
1807
+				}
1620 1808
 				print '</td>';
1621 1809
 				print '<td>';
1622 1810
 				if ($objp->fk_soc > 0)
@@ -1630,11 +1818,15 @@  discard block
 block discarded – undo
1630 1818
 				if (! empty($conf->global->PROJECT_USE_OPPORTUNITIES))
1631 1819
 				{
1632 1820
 					print '<td align="right">';
1633
-					if ($objp->opp_amount) print price($objp->opp_amount, 0, '', 1, -1, -1, $conf->currency);
1821
+					if ($objp->opp_amount) {
1822
+					    print price($objp->opp_amount, 0, '', 1, -1, -1, $conf->currency);
1823
+					}
1634 1824
 					print '</td>';
1635 1825
 					print '<td align="right">';
1636 1826
 					$code = dol_getIdFromCode($db, $objp->opp_status, 'c_lead_status', 'rowid', 'code');
1637
-					if ($code) print $langs->trans("OppStatus".$code);
1827
+					if ($code) {
1828
+					    print $langs->trans("OppStatus".$code);
1829
+					}
1638 1830
 					print '</td>';
1639 1831
 				}
1640 1832
 				if (empty($conf->global->PROJECT_HIDE_TASKS))
@@ -1679,15 +1871,18 @@  discard block
 block discarded – undo
1679 1871
 		if (empty($conf->global->PROJECT_HIDE_TASKS))
1680 1872
 		{
1681 1873
 			print '<td class="liste_total" align="right">'.$total_task.'</td>';
1682
-			if (! in_array('plannedworkload', $hiddenfields))  print '<td class="liste_total" align="right">'.($total_plannedworkload?convertSecondToTime($total_plannedworkload):'').'</td>';
1683
-			if (! in_array('declaredprogress', $hiddenfields)) print '<td class="liste_total" align="right">'.($total_plannedworkload?round(100*$total_declaredprogressworkload/$total_plannedworkload,0).'%':'').'</td>';
1874
+			if (! in_array('plannedworkload', $hiddenfields)) {
1875
+			    print '<td class="liste_total" align="right">'.($total_plannedworkload?convertSecondToTime($total_plannedworkload):'').'</td>';
1876
+			}
1877
+			if (! in_array('declaredprogress', $hiddenfields)) {
1878
+			    print '<td class="liste_total" align="right">'.($total_plannedworkload?round(100*$total_declaredprogressworkload/$total_plannedworkload,0).'%':'').'</td>';
1879
+			}
1684 1880
 		}
1685 1881
 		print '<td class="liste_total"></td>';
1686 1882
 		print '</tr>';
1687 1883
 
1688 1884
 		$db->free($resql);
1689
-	}
1690
-	else
1885
+	} else
1691 1886
 	{
1692 1887
 		dol_print_error($db);
1693 1888
 	}
Please login to merge, or discard this patch.
dolibarr/htdocs/core/lib/json.lib.php 1 patch
Braces   +60 added lines, -27 removed lines patch added patch discarded remove patch
@@ -50,11 +50,12 @@  discard block
 block discarded – undo
50 50
 	dol_syslog("For better performance, enable the native json in your PHP", LOG_WARNING);
51 51
 
52 52
 	$num=0;
53
-	if (is_object($elements))	// Count number of properties for an object
53
+	if (is_object($elements)) {
54
+	    // Count number of properties for an object
54 55
 	{
55 56
 		foreach($elements as $key => $value) $num++;
56 57
 	}
57
-	else
58
+	} else
58 59
 	{
59 60
 	    $num=count($elements);
60 61
 	}
@@ -68,28 +69,43 @@  discard block
 block discarded – undo
68 69
 		$output = '[';
69 70
 		for ($i = 0, $last = ($num - 1); $i < $num; $i++)
70 71
 		{
71
-			if (! isset($elements[$keysofelements[$i]])) continue;
72
-			if (is_array($elements[$keysofelements[$i]]) || is_object($elements[$keysofelements[$i]])) $output.= json_encode($elements[$keysofelements[$i]]);
73
-			else $output .= _val($elements[$keysofelements[$i]]);
74
-			if ($i !== $last) $output.= ',';
72
+			if (! isset($elements[$keysofelements[$i]])) {
73
+			    continue;
74
+			}
75
+			if (is_array($elements[$keysofelements[$i]]) || is_object($elements[$keysofelements[$i]])) {
76
+			    $output.= json_encode($elements[$keysofelements[$i]]);
77
+			} else {
78
+			    $output .= _val($elements[$keysofelements[$i]]);
79
+			}
80
+			if ($i !== $last) {
81
+			    $output.= ',';
82
+			}
75 83
 		}
76 84
 		$output.= ']';
77
-	}
78
-	else
85
+	} else
79 86
 	{
80 87
 		// associative (object)
81 88
 		$output = '{';
82 89
 		$last = $num - 1;
83 90
 		$i = 0;
84 91
 		$tmpelements=array();
85
-		if (is_array($elements)) $tmpelements=$elements;
86
-		if (is_object($elements)) $tmpelements=get_object_vars($elements);
92
+		if (is_array($elements)) {
93
+		    $tmpelements=$elements;
94
+		}
95
+		if (is_object($elements)) {
96
+		    $tmpelements=get_object_vars($elements);
97
+		}
87 98
 		foreach($tmpelements as $key => $value)
88 99
 		{
89 100
 			$output .= '"'.$key.'":';
90
-			if (is_array($value)) $output.= json_encode($value);
91
-			else $output .= _val($value);
92
-			if ($i !== $last) $output.= ',';
101
+			if (is_array($value)) {
102
+			    $output.= json_encode($value);
103
+			} else {
104
+			    $output .= _val($value);
105
+			}
106
+			if ($i !== $last) {
107
+			    $output.= ',';
108
+			}
93 109
 			++$i;
94 110
 		}
95 111
 		$output.= '}';
@@ -198,12 +214,16 @@  discard block
 block discarded – undo
198 214
 	    }
199 215
 
200 216
 	    return '"'.$ascii.'"';
217
+	} elseif (is_int($val)) {
218
+	    return sprintf('%d', $val);
219
+	} elseif (is_float($val)) {
220
+	    return sprintf('%F', $val);
221
+	} elseif (is_bool($val)) {
222
+	    return ($val ? 'true' : 'false');
223
+	} else {
224
+	    return 'null';
225
+	}
201 226
 	}
202
-	elseif (is_int($val)) return sprintf('%d', $val);
203
-	elseif (is_float($val)) return sprintf('%F', $val);
204
-	elseif (is_bool($val)) return ($val ? 'true' : 'false');
205
-	else  return 'null';
206
-}
207 227
 
208 228
 if (! function_exists('json_decode'))
209 229
 {
@@ -241,20 +261,31 @@  discard block
 block discarded – undo
241 261
 	{
242 262
 		if (! $comment)
243 263
 		{
244
-			if (($json[$i] == '{') || ($json[$i] == '[')) $out.= 'array(';
245
-			else if (($json[$i] == '}') || ($json[$i] == ']')) $out.= ')';
246
-			else if ($json[$i] == ':') $out.= ' => ';
247
-			else $out.=$json[$i];
264
+			if (($json[$i] == '{') || ($json[$i] == '[')) {
265
+			    $out.= 'array(';
266
+			} else if (($json[$i] == '}') || ($json[$i] == ']')) {
267
+			    $out.= ')';
268
+			} else if ($json[$i] == ':') {
269
+			    $out.= ' => ';
270
+			} else {
271
+			    $out.=$json[$i];
272
+			}
273
+		} else {
274
+		    $out.= $json[$i];
275
+		}
276
+		if ($json[$i] == '"' && $json[($i-1)]!="\\") {
277
+		    $comment = !$comment;
248 278
 		}
249
-		else $out.= $json[$i];
250
-		if ($json[$i] == '"' && $json[($i-1)]!="\\") $comment = !$comment;
251 279
 	}
252 280
 
253 281
 	$out=_unval($out);
254 282
 
255 283
 	// Return an array
256
-	if ($out != '') eval('$array = '.$out.';');
257
-	else $array=array();
284
+	if ($out != '') {
285
+	    eval('$array = '.$out.';');
286
+	} else {
287
+	    $array=array();
288
+	}
258 289
 
259 290
 	// Return an object
260 291
 	if (! $assoc)
@@ -267,7 +298,9 @@  discard block
 block discarded – undo
267 298
 			}
268 299
 			foreach ($array as $key => $value)
269 300
 			{
270
-				if ($key) $object->{$key} = $value;
301
+				if ($key) {
302
+				    $object->{$key} = $value;
303
+				}
271 304
 			}
272 305
 
273 306
 			return $object;
Please login to merge, or discard this patch.
dolibarr/htdocs/core/lib/doc.lib.php 1 patch
Braces   +37 added lines, -22 removed lines patch added patch discarded remove patch
@@ -48,8 +48,11 @@  discard block
 block discarded – undo
48 48
 	$ref_supplier=(! empty($line->ref_supplier)?$line->ref_supplier:(! empty($line->ref_fourn)?$line->ref_fourn:''));    // TODO Not yet saved for supplier invoices, only supplier orders
49 49
 	$note=(! empty($line->note)?$line->note:'');
50 50
 
51
-	if ($issupplierline) $prodser = new ProductFournisseur($db);
52
-	else $prodser = new Product($db);
51
+	if ($issupplierline) {
52
+	    $prodser = new ProductFournisseur($db);
53
+	} else {
54
+	    $prodser = new Product($db);
55
+	}
53 56
 
54 57
 	if ($idprod)
55 58
 	{
@@ -57,9 +60,15 @@  discard block
 block discarded – undo
57 60
 		// If a predefined product and multilang and on other lang, we renamed label with label translated
58 61
 		if (! empty($conf->global->MAIN_MULTILANGS) && ($outputlangs->defaultlang != $langs->defaultlang))
59 62
 		{
60
-			if (! empty($prodser->multilangs[$outputlangs->defaultlang]["label"]) && $label == $prodser->label)     $label=$prodser->multilangs[$outputlangs->defaultlang]["label"];
61
-			if (! empty($prodser->multilangs[$outputlangs->defaultlang]["description"]) && $desc == $prodser->description) $desc=$prodser->multilangs[$outputlangs->defaultlang]["description"];
62
-			if (! empty($prodser->multilangs[$outputlangs->defaultlang]["note"]) && $note == $prodser->note)        $note=$prodser->multilangs[$outputlangs->defaultlang]["note"];
63
+			if (! empty($prodser->multilangs[$outputlangs->defaultlang]["label"]) && $label == $prodser->label) {
64
+			    $label=$prodser->multilangs[$outputlangs->defaultlang]["label"];
65
+			}
66
+			if (! empty($prodser->multilangs[$outputlangs->defaultlang]["description"]) && $desc == $prodser->description) {
67
+			    $desc=$prodser->multilangs[$outputlangs->defaultlang]["description"];
68
+			}
69
+			if (! empty($prodser->multilangs[$outputlangs->defaultlang]["note"]) && $note == $prodser->note) {
70
+			    $note=$prodser->multilangs[$outputlangs->defaultlang]["note"];
71
+			}
63 72
 		}
64 73
 	}
65 74
 
@@ -75,35 +84,34 @@  discard block
 block discarded – undo
75 84
 			$discount->fetch($line->fk_remise_except);
76 85
 			$sourceref=!empty($discount->discount_type)?$discount->ref_invoive_supplier_source:$discount->ref_facture_source;
77 86
 			$libelleproduitservice=$outputlangs->transnoentitiesnoconv("DiscountFromCreditNote",$sourceref);
78
-		}
79
-		elseif ($desc == '(DEPOSIT)' && $line->fk_remise_except)
87
+		} elseif ($desc == '(DEPOSIT)' && $line->fk_remise_except)
80 88
 		{
81 89
 		    $discount=new DiscountAbsolute($db);
82 90
 		    $discount->fetch($line->fk_remise_except);
83 91
 		    $sourceref=!empty($discount->discount_type)?$discount->ref_invoive_supplier_source:$discount->ref_facture_source;
84 92
 		    $libelleproduitservice=$outputlangs->transnoentitiesnoconv("DiscountFromDeposit",$sourceref);
85 93
 		    // Add date of deposit
86
-		    if (! empty($conf->global->INVOICE_ADD_DEPOSIT_DATE)) $libelleproduitservice.=' ('.dol_print_date($discount->datec,'day','',$outputlangs).')';
87
-		}
88
-		elseif ($desc == '(EXCESS RECEIVED)' && $line->fk_remise_except)
94
+		    if (! empty($conf->global->INVOICE_ADD_DEPOSIT_DATE)) {
95
+		        $libelleproduitservice.=' ('.dol_print_date($discount->datec,'day','',$outputlangs).')';
96
+		    }
97
+		} elseif ($desc == '(EXCESS RECEIVED)' && $line->fk_remise_except)
89 98
 		{
90 99
 			$discount=new DiscountAbsolute($db);
91 100
 			$discount->fetch($line->fk_remise_except);
92 101
 			$libelleproduitservice=$outputlangs->transnoentitiesnoconv("DiscountFromExcessReceived",$discount->ref_facture_source);
93
-		}
94
-		elseif ($desc == '(EXCESS PAID)' && $line->fk_remise_except)
102
+		} elseif ($desc == '(EXCESS PAID)' && $line->fk_remise_except)
95 103
 		{
96 104
 			$discount=new DiscountAbsolute($db);
97 105
 			$discount->fetch($line->fk_remise_except);
98 106
 			$libelleproduitservice=$outputlangs->transnoentitiesnoconv("DiscountFromExcessPaid",$discount->ref_invoice_supplier_source);
99
-		}
100
-		else
107
+		} else
101 108
 		{
102 109
 			if ($idprod)
103 110
 			{
104
-				if (empty($hidedesc)) $libelleproduitservice=dol_concatdesc($libelleproduitservice, $desc);
105
-			}
106
-			else
111
+				if (empty($hidedesc)) {
112
+				    $libelleproduitservice=dol_concatdesc($libelleproduitservice, $desc);
113
+				}
114
+			} else
107 115
 			{
108 116
 				$libelleproduitservice=dol_concatdesc($libelleproduitservice, $desc);
109 117
 			}
@@ -118,13 +126,14 @@  discard block
 block discarded – undo
118 126
 		{
119 127
 			$prefix_prodserv = "";
120 128
 			$ref_prodserv = "";
121
-			if (! empty($conf->global->PRODUCT_ADD_TYPE_IN_DOCUMENTS))   // In standard mode, we do not show this
129
+			if (! empty($conf->global->PRODUCT_ADD_TYPE_IN_DOCUMENTS)) {
130
+			    // In standard mode, we do not show this
122 131
 			{
123 132
 				if ($prodser->isService())
124 133
 				{
125 134
 					$prefix_prodserv = $outputlangs->transnoentitiesnoconv("Service")." ";
126
-				}
127
-				else
135
+			}
136
+				} else
128 137
 				{
129 138
 					$prefix_prodserv = $outputlangs->transnoentitiesnoconv("Product")." ";
130 139
 				}
@@ -132,8 +141,14 @@  discard block
 block discarded – undo
132 141
 
133 142
 			if (empty($hideref))
134 143
 			{
135
-				if ($issupplierline) $ref_prodserv = $prodser->ref.' ('.$outputlangs->trans("SupplierRef").' '.$ref_supplier.')';   // Show local ref and supplier ref
136
-				else $ref_prodserv = $prodser->ref; // Show local ref only
144
+				if ($issupplierline) {
145
+				    $ref_prodserv = $prodser->ref.' ('.$outputlangs->trans("SupplierRef").' '.$ref_supplier.')';
146
+				}
147
+				// Show local ref and supplier ref
148
+				else {
149
+				    $ref_prodserv = $prodser->ref;
150
+				}
151
+				// Show local ref only
137 152
 
138 153
 				$ref_prodserv .= " - ";
139 154
 			}
Please login to merge, or discard this patch.
dolibarr/htdocs/core/lib/tax.lib.php 1 patch
Braces   +278 added lines, -129 removed lines patch added patch discarded remove patch
@@ -59,7 +59,9 @@  discard block
 block discarded – undo
59 59
     $nbLinks=Link::count($db, $object->element, $object->id);
60 60
 	$head[$h][0] = DOL_URL_ROOT.'/compta/sociales/document.php?id='.$object->id;
61 61
 	$head[$h][1] = $langs->trans("Documents");
62
-	if (($nbFiles+$nbLinks) > 0) $head[$h][1].= ' <span class="badge">'.($nbFiles+$nbLinks).'</span>';
62
+	if (($nbFiles+$nbLinks) > 0) {
63
+	    $head[$h][1].= ' <span class="badge">'.($nbFiles+$nbLinks).'</span>';
64
+	}
63 65
 	$head[$h][2] = 'documents';
64 66
 	$h++;
65 67
 
@@ -154,28 +156,35 @@  discard block
 block discarded – undo
154 156
     	$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p on d.fk_product = p.rowid";
155 157
     	$sql.= " WHERE f.entity = " . $conf->entity;
156 158
     	$sql.= " AND f.fk_statut in (1,2)"; // Validated or paid (partially or completely)
157
-    	if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) $sql.= " AND f.type IN (0,1,2,5)";
158
-    	else $sql.= " AND f.type IN (0,1,2,3,5)";
159
+    	if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) {
160
+    	    $sql.= " AND f.type IN (0,1,2,5)";
161
+    	} else {
162
+    	    $sql.= " AND f.type IN (0,1,2,3,5)";
163
+    	}
159 164
     	$sql.= " AND f.rowid = d.".$fk_facture;
160 165
     	$sql.= " AND s.rowid = f.fk_soc";
161 166
     	if ($y && $m)
162 167
     	{
163 168
     		$sql.= " AND f.datef >= '".$db->idate(dol_get_first_day($y,$m,false))."'";
164 169
     		$sql.= " AND f.datef <= '".$db->idate(dol_get_last_day($y,$m,false))."'";
165
-    	}
166
-    	else if ($y)
170
+    	} else if ($y)
167 171
     	{
168 172
     		$sql.= " AND f.datef >= '".$db->idate(dol_get_first_day($y,1,false))."'";
169 173
     		$sql.= " AND f.datef <= '".$db->idate(dol_get_last_day($y,12,false))."'";
170 174
     	}
171
-    	if ($q) $sql.= " AND (date_format(f.datef,'%m') > ".(($q-1)*3)." AND date_format(f.datef,'%m') <= ".($q*3).")";
172
-    	if ($date_start && $date_end) $sql.= " AND f.datef >= '".$db->idate($date_start)."' AND f.datef <= '".$db->idate($date_end)."'";
175
+    	if ($q) {
176
+    	    $sql.= " AND (date_format(f.datef,'%m') > ".(($q-1)*3)." AND date_format(f.datef,'%m') <= ".($q*3).")";
177
+    	}
178
+    	if ($date_start && $date_end) {
179
+    	    $sql.= " AND f.datef >= '".$db->idate($date_start)."' AND f.datef <= '".$db->idate($date_end)."'";
180
+    	}
173 181
     	$sql.= " AND (d.product_type = 0";                              // Limit to products
174 182
     	$sql.= " AND d.date_start is null AND d.date_end IS NULL)";     // enhance detection of products
175
-    	if (empty($conf->global->MAIN_INCLUDE_ZERO_VAT_IN_REPORTS)) $sql.= " AND (d.".$f_rate." <> 0 OR d.".$total_tva." <> 0)";
183
+    	if (empty($conf->global->MAIN_INCLUDE_ZERO_VAT_IN_REPORTS)) {
184
+    	    $sql.= " AND (d.".$f_rate." <> 0 OR d.".$total_tva." <> 0)";
185
+    	}
176 186
     	$sql.= " ORDER BY d.rowid, d.".$fk_facture;
177
-    }
178
-    else
187
+    } else
179 188
     {
180 189
     	// Count on payments date
181 190
     	$sql = "SELECT d.rowid, d.product_type as dtype, d.".$fk_facture." as facid, d.$f_rate as rate, d.total_ht as total_ht, d.total_ttc as total_ttc, d.".$total_tva." as total_vat, d.description as descr,";
@@ -193,8 +202,11 @@  discard block
 block discarded – undo
193 202
     	$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p on d.fk_product = p.rowid";
194 203
     	$sql.= " WHERE f.entity = " . $conf->entity;
195 204
     	$sql.= " AND f.fk_statut in (1,2)"; // Paid (partially or completely)
196
-    	if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) $sql.= " AND f.type IN (0,1,2,5)";
197
-    	else $sql.= " AND f.type IN (0,1,2,3,5)";
205
+    	if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) {
206
+    	    $sql.= " AND f.type IN (0,1,2,5)";
207
+    	} else {
208
+    	    $sql.= " AND f.type IN (0,1,2,3,5)";
209
+    	}
198 210
     	$sql.= " AND f.rowid = d.".$fk_facture;
199 211
     	$sql.= " AND s.rowid = f.fk_soc";
200 212
     	$sql.= " AND pf.".$fk_facture2." = f.rowid";
@@ -203,22 +215,31 @@  discard block
 block discarded – undo
203 215
     	{
204 216
     		$sql.= " AND pa.datep >= '".$db->idate(dol_get_first_day($y,$m,false))."'";
205 217
     		$sql.= " AND pa.datep <= '".$db->idate(dol_get_last_day($y,$m,false))."'";
206
-    	}
207
-    	else if ($y)
218
+    	} else if ($y)
208 219
     	{
209 220
     		$sql.= " AND pa.datep >= '".$db->idate(dol_get_first_day($y,1,false))."'";
210 221
     		$sql.= " AND pa.datep <= '".$db->idate(dol_get_last_day($y,12,false))."'";
211 222
     	}
212
-    	if ($q) $sql.= " AND (date_format(pa.datep,'%m') > ".(($q-1)*3)." AND date_format(pa.datep,'%m') <= ".($q*3).")";
213
-    	if ($date_start && $date_end) $sql.= " AND pa.datep >= '".$db->idate($date_start)."' AND pa.datep <= '".$db->idate($date_end)."'";
223
+    	if ($q) {
224
+    	    $sql.= " AND (date_format(pa.datep,'%m') > ".(($q-1)*3)." AND date_format(pa.datep,'%m') <= ".($q*3).")";
225
+    	}
226
+    	if ($date_start && $date_end) {
227
+    	    $sql.= " AND pa.datep >= '".$db->idate($date_start)."' AND pa.datep <= '".$db->idate($date_end)."'";
228
+    	}
214 229
     	$sql.= " AND (d.product_type = 0";                              // Limit to products
215 230
     	$sql.= " AND d.date_start is null AND d.date_end IS NULL)";     // enhance detection of products
216
-    	if (empty($conf->global->MAIN_INCLUDE_ZERO_VAT_IN_REPORTS)) $sql.= " AND (d.".$f_rate." <> 0 OR d.".$total_tva." <> 0)";
231
+    	if (empty($conf->global->MAIN_INCLUDE_ZERO_VAT_IN_REPORTS)) {
232
+    	    $sql.= " AND (d.".$f_rate." <> 0 OR d.".$total_tva." <> 0)";
233
+    	}
217 234
     	$sql.= " ORDER BY d.rowid, d.".$fk_facture.", pf.rowid";
218 235
     }
219 236
 
220
-    if (! $sql) return -1;
221
-    if ($sql == 'TODO') return -2;
237
+    if (! $sql) {
238
+        return -1;
239
+    }
240
+    if ($sql == 'TODO') {
241
+        return -2;
242
+    }
222 243
     if ($sql != 'TODO')
223 244
     {
224 245
     	dol_syslog("Tax.lib.php::tax_by_thirdparty", LOG_DEBUG);
@@ -230,14 +251,24 @@  discard block
 block discarded – undo
230 251
     		$oldrowid='';
231 252
     		while($assoc = $db->fetch_array($resql))
232 253
     		{
233
-    			if (! isset($list[$assoc['company_id']]['totalht']))  $list[$assoc['company_id']]['totalht']=0;
234
-    			if (! isset($list[$assoc['company_id']]['vat']))      $list[$assoc['company_id']]['vat']=0;
235
-    			if (! isset($list[$assoc['company_id']]['localtax1']))      $list[$assoc['company_id']]['localtax1']=0;
236
-    			if (! isset($list[$assoc['company_id']]['localtax2']))      $list[$assoc['company_id']]['localtax2']=0;
254
+    			if (! isset($list[$assoc['company_id']]['totalht'])) {
255
+    			    $list[$assoc['company_id']]['totalht']=0;
256
+    			}
257
+    			if (! isset($list[$assoc['company_id']]['vat'])) {
258
+    			    $list[$assoc['company_id']]['vat']=0;
259
+    			}
260
+    			if (! isset($list[$assoc['company_id']]['localtax1'])) {
261
+    			    $list[$assoc['company_id']]['localtax1']=0;
262
+    			}
263
+    			if (! isset($list[$assoc['company_id']]['localtax2'])) {
264
+    			    $list[$assoc['company_id']]['localtax2']=0;
265
+    			}
237 266
 
238
-    			if ($assoc['rowid'] != $oldrowid)       // Si rupture sur d.rowid
267
+    			if ($assoc['rowid'] != $oldrowid) {
268
+    			    // Si rupture sur d.rowid
239 269
     			{
240 270
     				$oldrowid=$assoc['rowid'];
271
+    			}
241 272
     				$list[$assoc['company_id']]['totalht']  += $assoc['total_ht'];
242 273
     				$list[$assoc['company_id']]['vat']      += $assoc['total_vat'];
243 274
     				$list[$assoc['company_id']]['localtax1']      += $assoc['total_localtax1'];
@@ -273,8 +304,7 @@  discard block
 block discarded – undo
273 304
 
274 305
     			$company_id = $assoc['company_id'];
275 306
     		}
276
-    	}
277
-    	else
307
+    	} else
278 308
     	{
279 309
     		dol_print_error($db);
280 310
     		return -3;
@@ -302,28 +332,35 @@  discard block
 block discarded – undo
302 332
     	$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p on d.fk_product = p.rowid";
303 333
     	$sql.= " WHERE f.entity = " . $conf->entity;
304 334
     	$sql.= " AND f.fk_statut in (1,2)"; // Validated or paid (partially or completely)
305
-    	if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) $sql.= " AND f.type IN (0,1,2,5)";
306
-    	else $sql.= " AND f.type IN (0,1,2,3,5)";
335
+    	if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) {
336
+    	    $sql.= " AND f.type IN (0,1,2,5)";
337
+    	} else {
338
+    	    $sql.= " AND f.type IN (0,1,2,3,5)";
339
+    	}
307 340
     	$sql.= " AND f.rowid = d.".$fk_facture;
308 341
     	$sql.= " AND s.rowid = f.fk_soc";
309 342
     	if ($y && $m)
310 343
     	{
311 344
     		$sql.= " AND f.datef >= '".$db->idate(dol_get_first_day($y,$m,false))."'";
312 345
     		$sql.= " AND f.datef <= '".$db->idate(dol_get_last_day($y,$m,false))."'";
313
-    	}
314
-    	else if ($y)
346
+    	} else if ($y)
315 347
     	{
316 348
     		$sql.= " AND f.datef >= '".$db->idate(dol_get_first_day($y,1,false))."'";
317 349
     		$sql.= " AND f.datef <= '".$db->idate(dol_get_last_day($y,12,false))."'";
318 350
     	}
319
-    	if ($q) $sql.= " AND (date_format(f.datef,'%m') > ".(($q-1)*3)." AND date_format(f.datef,'%m') <= ".($q*3).")";
320
-    	if ($date_start && $date_end) $sql.= " AND f.datef >= '".$db->idate($date_start)."' AND f.datef <= '".$db->idate($date_end)."'";
351
+    	if ($q) {
352
+    	    $sql.= " AND (date_format(f.datef,'%m') > ".(($q-1)*3)." AND date_format(f.datef,'%m') <= ".($q*3).")";
353
+    	}
354
+    	if ($date_start && $date_end) {
355
+    	    $sql.= " AND f.datef >= '".$db->idate($date_start)."' AND f.datef <= '".$db->idate($date_end)."'";
356
+    	}
321 357
     	$sql.= " AND (d.product_type = 1";                              // Limit to services
322 358
     	$sql.= " OR d.date_start is NOT null OR d.date_end IS NOT NULL)";       // enhance detection of service
323
-    	if (empty($conf->global->MAIN_INCLUDE_ZERO_VAT_IN_REPORTS)) $sql.= " AND (d.".$f_rate." <> 0 OR d.".$total_tva." <> 0)";
359
+    	if (empty($conf->global->MAIN_INCLUDE_ZERO_VAT_IN_REPORTS)) {
360
+    	    $sql.= " AND (d.".$f_rate." <> 0 OR d.".$total_tva." <> 0)";
361
+    	}
324 362
     	$sql.= " ORDER BY d.rowid, d.".$fk_facture;
325
-    }
326
-    else
363
+    } else
327 364
     {
328 365
     	// Count on payments date
329 366
     	$sql = "SELECT d.rowid, d.product_type as dtype, d.".$fk_facture." as facid, d.$f_rate as rate, d.total_ht as total_ht, d.total_ttc as total_ttc, d.".$total_tva." as total_vat, d.description as descr,";
@@ -341,8 +378,11 @@  discard block
 block discarded – undo
341 378
     	$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p on d.fk_product = p.rowid";
342 379
     	$sql.= " WHERE f.entity = " . $conf->entity;
343 380
     	$sql.= " AND f.fk_statut in (1,2)"; // Paid (partially or completely)
344
-    	if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) $sql.= " AND f.type IN (0,1,2,5)";
345
-    	else $sql.= " AND f.type IN (0,1,2,3,5)";
381
+    	if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) {
382
+    	    $sql.= " AND f.type IN (0,1,2,5)";
383
+    	} else {
384
+    	    $sql.= " AND f.type IN (0,1,2,3,5)";
385
+    	}
346 386
     	$sql.= " AND f.rowid = d.".$fk_facture;
347 387
     	$sql.= " AND s.rowid = f.fk_soc";
348 388
     	$sql.= " AND pf.".$fk_facture2." = f.rowid";
@@ -351,17 +391,22 @@  discard block
 block discarded – undo
351 391
     	{
352 392
     		$sql.= " AND pa.datep >= '".$db->idate(dol_get_first_day($y,$m,false))."'";
353 393
     		$sql.= " AND pa.datep <= '".$db->idate(dol_get_last_day($y,$m,false))."'";
354
-    	}
355
-    	else if ($y)
394
+    	} else if ($y)
356 395
     	{
357 396
     		$sql.= " AND pa.datep >= '".$db->idate(dol_get_first_day($y,1,false))."'";
358 397
     		$sql.= " AND pa.datep <= '".$db->idate(dol_get_last_day($y,12,false))."'";
359 398
     	}
360
-    	if ($q) $sql.= " AND (date_format(pa.datep,'%m') > ".(($q-1)*3)." AND date_format(pa.datep,'%m') <= ".($q*3).")";
361
-    	if ($date_start && $date_end) $sql.= " AND pa.datep >= '".$db->idate($date_start)."' AND pa.datep <= '".$db->idate($date_end)."'";
399
+    	if ($q) {
400
+    	    $sql.= " AND (date_format(pa.datep,'%m') > ".(($q-1)*3)." AND date_format(pa.datep,'%m') <= ".($q*3).")";
401
+    	}
402
+    	if ($date_start && $date_end) {
403
+    	    $sql.= " AND pa.datep >= '".$db->idate($date_start)."' AND pa.datep <= '".$db->idate($date_end)."'";
404
+    	}
362 405
     	$sql.= " AND (d.product_type = 1";                              		// Limit to services
363 406
     	$sql.= " OR d.date_start is NOT null OR d.date_end IS NOT NULL)";       // enhance detection of service
364
-    	if (empty($conf->global->MAIN_INCLUDE_ZERO_VAT_IN_REPORTS)) $sql.= " AND (d.".$f_rate." <> 0 OR d.".$total_tva." <> 0)";
407
+    	if (empty($conf->global->MAIN_INCLUDE_ZERO_VAT_IN_REPORTS)) {
408
+    	    $sql.= " AND (d.".$f_rate." <> 0 OR d.".$total_tva." <> 0)";
409
+    	}
365 410
     	$sql.= " ORDER BY d.rowid, d.".$fk_facture.", pf.rowid";
366 411
     }
367 412
 
@@ -370,7 +415,10 @@  discard block
 block discarded – undo
370 415
     	dol_syslog("Tax.lib.php::tax_by_rate no accountancy module enabled".$sql,LOG_ERR);
371 416
     	return -1;  // -1 = Not accountancy module enabled
372 417
     }
373
-    if ($sql == 'TODO') return -2; // -2 = Feature not yet available
418
+    if ($sql == 'TODO') {
419
+        return -2;
420
+    }
421
+    // -2 = Feature not yet available
374 422
     if ($sql != 'TODO')
375 423
     {
376 424
     	dol_syslog("Tax.lib.php::tax_by_rate", LOG_DEBUG);
@@ -381,14 +429,24 @@  discard block
 block discarded – undo
381 429
     		$oldrowid='';
382 430
     		while($assoc = $db->fetch_array($resql))
383 431
     		{
384
-    			if (! isset($list[$assoc['company_id']]['totalht']))  $list[$assoc['company_id']]['totalht']=0;
385
-    			if (! isset($list[$assoc['company_id']]['vat']))      $list[$assoc['company_id']]['vat']=0;
386
-    			if (! isset($list[$assoc['company_id']]['localtax1']))      $list[$assoc['company_id']]['localtax1']=0;
387
-    			if (! isset($list[$assoc['company_id']]['localtax2']))      $list[$assoc['company_id']]['localtax2']=0;
432
+    			if (! isset($list[$assoc['company_id']]['totalht'])) {
433
+    			    $list[$assoc['company_id']]['totalht']=0;
434
+    			}
435
+    			if (! isset($list[$assoc['company_id']]['vat'])) {
436
+    			    $list[$assoc['company_id']]['vat']=0;
437
+    			}
438
+    			if (! isset($list[$assoc['company_id']]['localtax1'])) {
439
+    			    $list[$assoc['company_id']]['localtax1']=0;
440
+    			}
441
+    			if (! isset($list[$assoc['company_id']]['localtax2'])) {
442
+    			    $list[$assoc['company_id']]['localtax2']=0;
443
+    			}
388 444
 
389
-    			if ($assoc['rowid'] != $oldrowid)       // Si rupture sur d.rowid
445
+    			if ($assoc['rowid'] != $oldrowid) {
446
+    			    // Si rupture sur d.rowid
390 447
     			{
391 448
     				$oldrowid=$assoc['rowid'];
449
+    			}
392 450
     				$list[$assoc['company_id']]['totalht']  += $assoc['total_ht'];
393 451
     				$list[$assoc['company_id']]['vat']      += $assoc['total_vat'];
394 452
     				$list[$assoc['company_id']]['localtax1']	 += $assoc['total_localtax1'];
@@ -424,8 +482,7 @@  discard block
 block discarded – undo
424 482
 
425 483
     			$company_id = $assoc['company_id'];
426 484
     		}
427
-    	}
428
-    	else
485
+    	} else
429 486
     	{
430 487
     		dol_print_error($db);
431 488
     		return -3;
@@ -435,10 +492,12 @@  discard block
 block discarded – undo
435 492
 
436 493
     // CASE OF EXPENSE REPORT
437 494
 
438
-    if ($direction == 'buy')		// buy only for expense reports
495
+    if ($direction == 'buy') {
496
+        // buy only for expense reports
439 497
     {
440 498
     	// Define sql request
441 499
     	$sql='';
500
+    }
442 501
 
443 502
     	// Count on payments date
444 503
     	$sql = "SELECT d.rowid, d.product_type as dtype, e.rowid as facid, d.$f_rate as rate, d.total_ht as total_ht, d.total_ttc as total_ttc, d.total_tva as total_vat, e.note_private as descr,";
@@ -455,17 +514,22 @@  discard block
 block discarded – undo
455 514
     	{
456 515
     		$sql.= " AND p.datep >= '".$db->idate(dol_get_first_day($y,$m,false))."'";
457 516
     		$sql.= " AND p.datep <= '".$db->idate(dol_get_last_day($y,$m,false))."'";
458
-    	}
459
-    	else if ($y)
517
+    	} else if ($y)
460 518
     	{
461 519
     		$sql.= " AND p.datep >= '".$db->idate(dol_get_first_day($y,1,false))."'";
462 520
     		$sql.= " AND p.datep <= '".$db->idate(dol_get_last_day($y,12,false))."'";
463 521
     	}
464
-    	if ($q) $sql.= " AND (date_format(p.datep,'%m') > ".(($q-1)*3)." AND date_format(p.datep,'%m') <= ".($q*3).")";
465
-    	if ($date_start && $date_end) $sql.= " AND p.datep >= '".$db->idate($date_start)."' AND p.datep <= '".$db->idate($date_end)."'";
522
+    	if ($q) {
523
+    	    $sql.= " AND (date_format(p.datep,'%m') > ".(($q-1)*3)." AND date_format(p.datep,'%m') <= ".($q*3).")";
524
+    	}
525
+    	if ($date_start && $date_end) {
526
+    	    $sql.= " AND p.datep >= '".$db->idate($date_start)."' AND p.datep <= '".$db->idate($date_end)."'";
527
+    	}
466 528
     	$sql.= " AND (d.product_type = -1";
467 529
     	$sql.= " OR e.date_debut is NOT null OR e.date_fin IS NOT NULL)";       // enhance detection of service
468
-    	if (empty($conf->global->MAIN_INCLUDE_ZERO_VAT_IN_REPORTS)) $sql.= " AND (d.".$f_rate." <> 0 OR d.total_tva <> 0)";
530
+    	if (empty($conf->global->MAIN_INCLUDE_ZERO_VAT_IN_REPORTS)) {
531
+    	    $sql.= " AND (d.".$f_rate." <> 0 OR d.total_tva <> 0)";
532
+    	}
469 533
     	$sql.= " ORDER BY e.rowid";
470 534
 
471 535
     	if (! $sql)
@@ -473,7 +537,10 @@  discard block
 block discarded – undo
473 537
     		dol_syslog("Tax.lib.php::tax_by_rate no accountancy module enabled".$sql,LOG_ERR);
474 538
     		return -1;  // -1 = Not accountancy module enabled
475 539
     	}
476
-    	if ($sql == 'TODO') return -2; // -2 = Feature not yet available
540
+    	if ($sql == 'TODO') {
541
+    	    return -2;
542
+    	}
543
+    	// -2 = Feature not yet available
477 544
     	if ($sql != 'TODO')
478 545
     	{
479 546
     		dol_syslog("Tax.lib.php::tax_by_rate", LOG_DEBUG);
@@ -484,14 +551,24 @@  discard block
 block discarded – undo
484 551
     			$oldrowid='';
485 552
     			while($assoc = $db->fetch_array($resql))
486 553
     			{
487
-    				if (! isset($list[$assoc['company_id']]['totalht']))  $list[$assoc['company_id']]['totalht']=0;
488
-    				if (! isset($list[$assoc['company_id']]['vat']))      $list[$assoc['company_id']]['vat']=0;
489
-    				if (! isset($list[$assoc['company_id']]['localtax1']))      $list[$assoc['company_id']]['localtax1']=0;
490
-    				if (! isset($list[$assoc['company_id']]['localtax2']))      $list[$assoc['company_id']]['localtax2']=0;
554
+    				if (! isset($list[$assoc['company_id']]['totalht'])) {
555
+    				    $list[$assoc['company_id']]['totalht']=0;
556
+    				}
557
+    				if (! isset($list[$assoc['company_id']]['vat'])) {
558
+    				    $list[$assoc['company_id']]['vat']=0;
559
+    				}
560
+    				if (! isset($list[$assoc['company_id']]['localtax1'])) {
561
+    				    $list[$assoc['company_id']]['localtax1']=0;
562
+    				}
563
+    				if (! isset($list[$assoc['company_id']]['localtax2'])) {
564
+    				    $list[$assoc['company_id']]['localtax2']=0;
565
+    				}
491 566
 
492
-    				if ($assoc['rowid'] != $oldrowid)       // Si rupture sur d.rowid
567
+    				if ($assoc['rowid'] != $oldrowid) {
568
+    				    // Si rupture sur d.rowid
493 569
     				{
494 570
     					$oldrowid=$assoc['rowid'];
571
+    				}
495 572
     					$list[$assoc['company_id']]['totalht']  += $assoc['total_ht'];
496 573
     					$list[$assoc['company_id']]['vat'] += $assoc['total_vat'];
497 574
     					$list[$assoc['company_id']]['localtax1']	 += $assoc['total_localtax1'];
@@ -528,8 +605,7 @@  discard block
 block discarded – undo
528 605
 
529 606
     				$company_id = $assoc['company_id'];
530 607
     			}
531
-    		}
532
-    		else
608
+    		} else
533 609
     		{
534 610
     			dol_print_error($db);
535 611
     			return -3;
@@ -579,8 +655,7 @@  discard block
 block discarded – undo
579 655
         $paymenttable='paiement';
580 656
         $paymentfacturetable='paiement_facture';
581 657
         $invoicefieldref='ref';
582
-    }
583
-    else
658
+    } else
584 659
     {
585 660
         $invoicetable='facture_fourn';
586 661
         $invoicedettable='facture_fourn_det';
@@ -623,28 +698,35 @@  discard block
 block discarded – undo
623 698
         $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p on d.fk_product = p.rowid";
624 699
         $sql.= " WHERE f.entity = " . $conf->entity;
625 700
         $sql.= " AND f.fk_statut in (1,2)"; // Validated or paid (partially or completely)
626
-        if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) $sql.= " AND f.type IN (0,1,2,5)";
627
-        else $sql.= " AND f.type IN (0,1,2,3,5)";
701
+        if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) {
702
+            $sql.= " AND f.type IN (0,1,2,5)";
703
+        } else {
704
+            $sql.= " AND f.type IN (0,1,2,3,5)";
705
+        }
628 706
         $sql.= " AND f.rowid = d.".$fk_facture;
629 707
         $sql.= " AND s.rowid = f.fk_soc";
630 708
         if ($y && $m)
631 709
         {
632 710
             $sql.= " AND f.datef >= '".$db->idate(dol_get_first_day($y,$m,false))."'";
633 711
             $sql.= " AND f.datef <= '".$db->idate(dol_get_last_day($y,$m,false))."'";
634
-        }
635
-        else if ($y)
712
+        } else if ($y)
636 713
         {
637 714
             $sql.= " AND f.datef >= '".$db->idate(dol_get_first_day($y,1,false))."'";
638 715
             $sql.= " AND f.datef <= '".$db->idate(dol_get_last_day($y,12,false))."'";
639 716
         }
640
-        if ($q) $sql.= " AND (date_format(f.datef,'%m') > ".(($q-1)*3)." AND date_format(f.datef,'%m') <= ".($q*3).")";
641
-        if ($date_start && $date_end) $sql.= " AND f.datef >= '".$db->idate($date_start)."' AND f.datef <= '".$db->idate($date_end)."'";
717
+        if ($q) {
718
+            $sql.= " AND (date_format(f.datef,'%m') > ".(($q-1)*3)." AND date_format(f.datef,'%m') <= ".($q*3).")";
719
+        }
720
+        if ($date_start && $date_end) {
721
+            $sql.= " AND f.datef >= '".$db->idate($date_start)."' AND f.datef <= '".$db->idate($date_end)."'";
722
+        }
642 723
         $sql.= " AND (d.product_type = 0";                              // Limit to products
643 724
         $sql.= " AND d.date_start is null AND d.date_end IS NULL)";     // enhance detection of products
644
-        if (empty($conf->global->MAIN_INCLUDE_ZERO_VAT_IN_REPORTS)) $sql.= " AND (d.".$f_rate." <> 0 OR d.".$total_tva." <> 0)";
725
+        if (empty($conf->global->MAIN_INCLUDE_ZERO_VAT_IN_REPORTS)) {
726
+            $sql.= " AND (d.".$f_rate." <> 0 OR d.".$total_tva." <> 0)";
727
+        }
645 728
         $sql.= " ORDER BY d.rowid, d.".$fk_facture;
646
-    }
647
-    else
729
+    } else
648 730
     {
649 731
     	// Count on payments date
650 732
     	$sql = "SELECT d.rowid, d.product_type as dtype, d.".$fk_facture." as facid, d.$f_rate as rate, d.total_ht as total_ht, d.total_ttc as total_ttc, d.".$total_tva." as total_vat, d.description as descr,";
@@ -662,8 +744,11 @@  discard block
 block discarded – undo
662 744
     	$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p on d.fk_product = p.rowid";
663 745
     	$sql.= " WHERE f.entity = " . $conf->entity;
664 746
     	$sql.= " AND f.fk_statut in (1,2)"; // Paid (partially or completely)
665
-    	if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) $sql.= " AND f.type IN (0,1,2,5)";
666
-    	else $sql.= " AND f.type IN (0,1,2,3,5)";
747
+    	if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) {
748
+    	    $sql.= " AND f.type IN (0,1,2,5)";
749
+    	} else {
750
+    	    $sql.= " AND f.type IN (0,1,2,3,5)";
751
+    	}
667 752
     	$sql.= " AND f.rowid = d.".$fk_facture;
668 753
     	$sql.= " AND s.rowid = f.fk_soc";
669 754
     	$sql.= " AND pf.".$fk_facture2." = f.rowid";
@@ -672,22 +757,31 @@  discard block
 block discarded – undo
672 757
     	{
673 758
     		$sql.= " AND pa.datep >= '".$db->idate(dol_get_first_day($y,$m,false))."'";
674 759
     		$sql.= " AND pa.datep <= '".$db->idate(dol_get_last_day($y,$m,false))."'";
675
-    	}
676
-    	else if ($y)
760
+    	} else if ($y)
677 761
     	{
678 762
     		$sql.= " AND pa.datep >= '".$db->idate(dol_get_first_day($y,1,false))."'";
679 763
     		$sql.= " AND pa.datep <= '".$db->idate(dol_get_last_day($y,12,false))."'";
680 764
     	}
681
-    	if ($q) $sql.= " AND (date_format(pa.datep,'%m') > ".(($q-1)*3)." AND date_format(pa.datep,'%m') <= ".($q*3).")";
682
-    	if ($date_start && $date_end) $sql.= " AND pa.datep >= '".$db->idate($date_start)."' AND pa.datep <= '".$db->idate($date_end)."'";
765
+    	if ($q) {
766
+    	    $sql.= " AND (date_format(pa.datep,'%m') > ".(($q-1)*3)." AND date_format(pa.datep,'%m') <= ".($q*3).")";
767
+    	}
768
+    	if ($date_start && $date_end) {
769
+    	    $sql.= " AND pa.datep >= '".$db->idate($date_start)."' AND pa.datep <= '".$db->idate($date_end)."'";
770
+    	}
683 771
     	$sql.= " AND (d.product_type = 0";                              // Limit to products
684 772
     	$sql.= " AND d.date_start is null AND d.date_end IS NULL)";     // enhance detection of products
685
-    	if (empty($conf->global->MAIN_INCLUDE_ZERO_VAT_IN_REPORTS)) $sql.= " AND (d.".$f_rate." <> 0 OR d.".$total_tva." <> 0)";
773
+    	if (empty($conf->global->MAIN_INCLUDE_ZERO_VAT_IN_REPORTS)) {
774
+    	    $sql.= " AND (d.".$f_rate." <> 0 OR d.".$total_tva." <> 0)";
775
+    	}
686 776
     	$sql.= " ORDER BY d.rowid, d.".$fk_facture.", pf.rowid";
687 777
     }
688 778
 
689
-    if (! $sql) return -1;
690
-    if ($sql == 'TODO') return -2;
779
+    if (! $sql) {
780
+        return -1;
781
+    }
782
+    if ($sql == 'TODO') {
783
+        return -2;
784
+    }
691 785
     if ($sql != 'TODO')
692 786
     {
693 787
         dol_syslog("Tax.lib.php::tax_by_rate", LOG_DEBUG);
@@ -700,14 +794,24 @@  discard block
 block discarded – undo
700 794
             while($assoc = $db->fetch_array($resql))
701 795
             {
702 796
             	// Code to avoid warnings when array entry not defined
703
-            	if (! isset($list[$assoc['rate']]['totalht']))   $list[$assoc['rate']]['totalht']=0;
704
-                if (! isset($list[$assoc['rate']]['vat']))       $list[$assoc['rate']]['vat']=0;
705
-                if (! isset($list[$assoc['rate']]['localtax1'])) $list[$assoc['rate']]['localtax1']=0;
706
-                if (! isset($list[$assoc['rate']]['localtax2'])) $list[$assoc['rate']]['localtax2']=0;
797
+            	if (! isset($list[$assoc['rate']]['totalht'])) {
798
+            	    $list[$assoc['rate']]['totalht']=0;
799
+            	}
800
+                if (! isset($list[$assoc['rate']]['vat'])) {
801
+                    $list[$assoc['rate']]['vat']=0;
802
+                }
803
+                if (! isset($list[$assoc['rate']]['localtax1'])) {
804
+                    $list[$assoc['rate']]['localtax1']=0;
805
+                }
806
+                if (! isset($list[$assoc['rate']]['localtax2'])) {
807
+                    $list[$assoc['rate']]['localtax2']=0;
808
+                }
707 809
 
708
-                if ($assoc['rowid'] != $oldrowid)       // Si rupture sur d.rowid
810
+                if ($assoc['rowid'] != $oldrowid) {
811
+                    // Si rupture sur d.rowid
709 812
                 {
710 813
                     $oldrowid=$assoc['rowid'];
814
+                }
711 815
                     $list[$assoc['rate']]['totalht']   += $assoc['total_ht'];
712 816
                     $list[$assoc['rate']]['vat']       += $assoc['total_vat'];
713 817
                     $list[$assoc['rate']]['localtax1'] += $assoc['total_localtax1'];
@@ -742,8 +846,7 @@  discard block
 block discarded – undo
742 846
 
743 847
                 $rate = $assoc['rate'];
744 848
             }
745
-        }
746
-        else
849
+        } else
747 850
         {
748 851
             dol_print_error($db);
749 852
             return -3;
@@ -771,28 +874,35 @@  discard block
 block discarded – undo
771 874
         $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p on d.fk_product = p.rowid";
772 875
         $sql.= " WHERE f.entity = " . $conf->entity;
773 876
         $sql.= " AND f.fk_statut in (1,2)"; // Validated or paid (partially or completely)
774
-        if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) $sql.= " AND f.type IN (0,1,2,5)";
775
-		else $sql.= " AND f.type IN (0,1,2,3,5)";
877
+        if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) {
878
+            $sql.= " AND f.type IN (0,1,2,5)";
879
+        } else {
880
+		    $sql.= " AND f.type IN (0,1,2,3,5)";
881
+		}
776 882
         $sql.= " AND f.rowid = d.".$fk_facture;
777 883
         $sql.= " AND s.rowid = f.fk_soc";
778 884
         if ($y && $m)
779 885
         {
780 886
             $sql.= " AND f.datef >= '".$db->idate(dol_get_first_day($y,$m,false))."'";
781 887
             $sql.= " AND f.datef <= '".$db->idate(dol_get_last_day($y,$m,false))."'";
782
-        }
783
-        else if ($y)
888
+        } else if ($y)
784 889
         {
785 890
             $sql.= " AND f.datef >= '".$db->idate(dol_get_first_day($y,1,false))."'";
786 891
             $sql.= " AND f.datef <= '".$db->idate(dol_get_last_day($y,12,false))."'";
787 892
         }
788
-        if ($q) $sql.= " AND (date_format(f.datef,'%m') > ".(($q-1)*3)." AND date_format(f.datef,'%m') <= ".($q*3).")";
789
-        if ($date_start && $date_end) $sql.= " AND f.datef >= '".$db->idate($date_start)."' AND f.datef <= '".$db->idate($date_end)."'";
893
+        if ($q) {
894
+            $sql.= " AND (date_format(f.datef,'%m') > ".(($q-1)*3)." AND date_format(f.datef,'%m') <= ".($q*3).")";
895
+        }
896
+        if ($date_start && $date_end) {
897
+            $sql.= " AND f.datef >= '".$db->idate($date_start)."' AND f.datef <= '".$db->idate($date_end)."'";
898
+        }
790 899
         $sql.= " AND (d.product_type = 1";                              // Limit to services
791 900
         $sql.= " OR d.date_start is NOT null OR d.date_end IS NOT NULL)";       // enhance detection of service
792
-        if (empty($conf->global->MAIN_INCLUDE_ZERO_VAT_IN_REPORTS)) $sql.= " AND (d.".$f_rate." <> 0 OR d.".$total_tva." <> 0)";
901
+        if (empty($conf->global->MAIN_INCLUDE_ZERO_VAT_IN_REPORTS)) {
902
+            $sql.= " AND (d.".$f_rate." <> 0 OR d.".$total_tva." <> 0)";
903
+        }
793 904
         $sql.= " ORDER BY d.rowid, d.".$fk_facture;
794
-    }
795
-    else
905
+    } else
796 906
     {
797 907
         // Count on payments date
798 908
         $sql = "SELECT d.rowid, d.product_type as dtype, d.".$fk_facture." as facid, d.$f_rate as rate, d.total_ht as total_ht, d.total_ttc as total_ttc, d.".$total_tva." as total_vat, d.description as descr,";
@@ -810,8 +920,11 @@  discard block
 block discarded – undo
810 920
         $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p on d.fk_product = p.rowid";
811 921
         $sql.= " WHERE f.entity = " . $conf->entity;
812 922
         $sql.= " AND f.fk_statut in (1,2)"; // Paid (partially or completely)
813
-        if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) $sql.= " AND f.type IN (0,1,2,5)";
814
-		else $sql.= " AND f.type IN (0,1,2,3,5)";
923
+        if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) {
924
+            $sql.= " AND f.type IN (0,1,2,5)";
925
+        } else {
926
+		    $sql.= " AND f.type IN (0,1,2,3,5)";
927
+		}
815 928
         $sql.= " AND f.rowid = d.".$fk_facture;
816 929
         $sql.= " AND s.rowid = f.fk_soc";
817 930
         $sql.= " AND pf.".$fk_facture2." = f.rowid";
@@ -820,17 +933,22 @@  discard block
 block discarded – undo
820 933
         {
821 934
             $sql.= " AND pa.datep >= '".$db->idate(dol_get_first_day($y,$m,false))."'";
822 935
             $sql.= " AND pa.datep <= '".$db->idate(dol_get_last_day($y,$m,false))."'";
823
-        }
824
-        else if ($y)
936
+        } else if ($y)
825 937
         {
826 938
             $sql.= " AND pa.datep >= '".$db->idate(dol_get_first_day($y,1,false))."'";
827 939
             $sql.= " AND pa.datep <= '".$db->idate(dol_get_last_day($y,12,false))."'";
828 940
         }
829
-        if ($q) $sql.= " AND (date_format(pa.datep,'%m') > ".(($q-1)*3)." AND date_format(pa.datep,'%m') <= ".($q*3).")";
830
-        if ($date_start && $date_end) $sql.= " AND pa.datep >= '".$db->idate($date_start)."' AND pa.datep <= '".$db->idate($date_end)."'";
941
+        if ($q) {
942
+            $sql.= " AND (date_format(pa.datep,'%m') > ".(($q-1)*3)." AND date_format(pa.datep,'%m') <= ".($q*3).")";
943
+        }
944
+        if ($date_start && $date_end) {
945
+            $sql.= " AND pa.datep >= '".$db->idate($date_start)."' AND pa.datep <= '".$db->idate($date_end)."'";
946
+        }
831 947
         $sql.= " AND (d.product_type = 1";                              		// Limit to services
832 948
         $sql.= " OR d.date_start is NOT null OR d.date_end IS NOT NULL)";       // enhance detection of service
833
-        if (empty($conf->global->MAIN_INCLUDE_ZERO_VAT_IN_REPORTS)) $sql.= " AND (d.".$f_rate." <> 0 OR d.".$total_tva." <> 0)";
949
+        if (empty($conf->global->MAIN_INCLUDE_ZERO_VAT_IN_REPORTS)) {
950
+            $sql.= " AND (d.".$f_rate." <> 0 OR d.".$total_tva." <> 0)";
951
+        }
834 952
         $sql.= " ORDER BY d.rowid, d.".$fk_facture.", pf.rowid";
835 953
     }
836 954
 
@@ -839,7 +957,10 @@  discard block
 block discarded – undo
839 957
         dol_syslog("Tax.lib.php::tax_by_rate no accountancy module enabled".$sql,LOG_ERR);
840 958
         return -1;  // -1 = Not accountancy module enabled
841 959
     }
842
-    if ($sql == 'TODO') return -2; // -2 = Feature not yet available
960
+    if ($sql == 'TODO') {
961
+        return -2;
962
+    }
963
+    // -2 = Feature not yet available
843 964
     if ($sql != 'TODO')
844 965
     {
845 966
         dol_syslog("Tax.lib.php::tax_by_rate", LOG_DEBUG);
@@ -851,14 +972,24 @@  discard block
 block discarded – undo
851 972
             while($assoc = $db->fetch_array($resql))
852 973
             {
853 974
             	// Code to avoid warnings when array entry not defined
854
-            	if (! isset($list[$assoc['rate']]['totalht']))   $list[$assoc['rate']]['totalht']=0;
855
-                if (! isset($list[$assoc['rate']]['vat']))       $list[$assoc['rate']]['vat']=0;
856
-				if (! isset($list[$assoc['rate']]['localtax1'])) $list[$assoc['rate']]['localtax1']=0;
857
-                if (! isset($list[$assoc['rate']]['localtax2'])) $list[$assoc['rate']]['localtax2']=0;
975
+            	if (! isset($list[$assoc['rate']]['totalht'])) {
976
+            	    $list[$assoc['rate']]['totalht']=0;
977
+            	}
978
+                if (! isset($list[$assoc['rate']]['vat'])) {
979
+                    $list[$assoc['rate']]['vat']=0;
980
+                }
981
+				if (! isset($list[$assoc['rate']]['localtax1'])) {
982
+				    $list[$assoc['rate']]['localtax1']=0;
983
+				}
984
+                if (! isset($list[$assoc['rate']]['localtax2'])) {
985
+                    $list[$assoc['rate']]['localtax2']=0;
986
+                }
858 987
 
859
-                if ($assoc['rowid'] != $oldrowid)       // Si rupture sur d.rowid
988
+                if ($assoc['rowid'] != $oldrowid) {
989
+                    // Si rupture sur d.rowid
860 990
                 {
861 991
                     $oldrowid=$assoc['rowid'];
992
+                }
862 993
                     $list[$assoc['rate']]['totalht']   += $assoc['total_ht'];
863 994
                     $list[$assoc['rate']]['vat']       += $assoc['total_vat'];
864 995
                     $list[$assoc['rate']]['localtax1'] += $assoc['total_localtax1'];
@@ -893,8 +1024,7 @@  discard block
 block discarded – undo
893 1024
 
894 1025
                 $rate = $assoc['rate'];
895 1026
             }
896
-        }
897
-        else
1027
+        } else
898 1028
         {
899 1029
             dol_print_error($db);
900 1030
             return -3;
@@ -904,10 +1034,12 @@  discard block
 block discarded – undo
904 1034
 
905 1035
     // CASE OF EXPENSE REPORT
906 1036
 
907
-	if ($direction == 'buy')		// buy only for expense reports
1037
+	if ($direction == 'buy') {
1038
+	    // buy only for expense reports
908 1039
 	{
909 1040
 		// Define sql request
910 1041
 		$sql='';
1042
+	}
911 1043
 
912 1044
 		// Count on payments date
913 1045
 		$sql = "SELECT d.rowid, d.product_type as dtype, e.rowid as facid, d.$f_rate as rate, d.total_ht as total_ht, d.total_ttc as total_ttc, d.total_tva as total_vat, e.note_private as descr,";
@@ -924,17 +1056,22 @@  discard block
 block discarded – undo
924 1056
 		{
925 1057
 			$sql.= " AND p.datep >= '".$db->idate(dol_get_first_day($y,$m,false))."'";
926 1058
 			$sql.= " AND p.datep <= '".$db->idate(dol_get_last_day($y,$m,false))."'";
927
-		}
928
-		else if ($y)
1059
+		} else if ($y)
929 1060
 		{
930 1061
 			$sql.= " AND p.datep >= '".$db->idate(dol_get_first_day($y,1,false))."'";
931 1062
 			$sql.= " AND p.datep <= '".$db->idate(dol_get_last_day($y,12,false))."'";
932 1063
 		}
933
-		if ($q) $sql.= " AND (date_format(p.datep,'%m') > ".(($q-1)*3)." AND date_format(p.datep,'%m') <= ".($q*3).")";
934
-		if ($date_start && $date_end) $sql.= " AND p.datep >= '".$db->idate($date_start)."' AND p.datep <= '".$db->idate($date_end)."'";
1064
+		if ($q) {
1065
+		    $sql.= " AND (date_format(p.datep,'%m') > ".(($q-1)*3)." AND date_format(p.datep,'%m') <= ".($q*3).")";
1066
+		}
1067
+		if ($date_start && $date_end) {
1068
+		    $sql.= " AND p.datep >= '".$db->idate($date_start)."' AND p.datep <= '".$db->idate($date_end)."'";
1069
+		}
935 1070
 		$sql.= " AND (d.product_type = -1";
936 1071
 		$sql.= " OR e.date_debut is NOT null OR e.date_fin IS NOT NULL)";       // enhance detection of service
937
-		if (empty($conf->global->MAIN_INCLUDE_ZERO_VAT_IN_REPORTS)) $sql.= " AND (d.".$f_rate." <> 0 OR d.total_tva <> 0)";
1072
+		if (empty($conf->global->MAIN_INCLUDE_ZERO_VAT_IN_REPORTS)) {
1073
+		    $sql.= " AND (d.".$f_rate." <> 0 OR d.total_tva <> 0)";
1074
+		}
938 1075
 		$sql.= " ORDER BY e.rowid";
939 1076
 
940 1077
 		if (! $sql)
@@ -942,7 +1079,10 @@  discard block
 block discarded – undo
942 1079
 			dol_syslog("Tax.lib.php::tax_by_rate no accountancy module enabled".$sql,LOG_ERR);
943 1080
 			return -1;  // -1 = Not accountancy module enabled
944 1081
 		}
945
-		if ($sql == 'TODO') return -2; // -2 = Feature not yet available
1082
+		if ($sql == 'TODO') {
1083
+		    return -2;
1084
+		}
1085
+		// -2 = Feature not yet available
946 1086
 		if ($sql != 'TODO')
947 1087
 		{
948 1088
 			dol_syslog("Tax.lib.php::tax_by_rate", LOG_DEBUG);
@@ -954,14 +1094,24 @@  discard block
 block discarded – undo
954 1094
 				while($assoc = $db->fetch_array($resql))
955 1095
 				{
956 1096
 					// Code to avoid warnings when array entry not defined
957
-					if (! isset($list[$assoc['rate']]['totalht']))   $list[$assoc['rate']]['totalht']=0;
958
-					if (! isset($list[$assoc['rate']]['vat']))       $list[$assoc['rate']]['vat']=0;
959
-					if (! isset($list[$assoc['rate']]['localtax1'])) $list[$assoc['rate']]['localtax1']=0;
960
-					if (! isset($list[$assoc['rate']]['localtax2'])) $list[$assoc['rate']]['localtax2']=0;
1097
+					if (! isset($list[$assoc['rate']]['totalht'])) {
1098
+					    $list[$assoc['rate']]['totalht']=0;
1099
+					}
1100
+					if (! isset($list[$assoc['rate']]['vat'])) {
1101
+					    $list[$assoc['rate']]['vat']=0;
1102
+					}
1103
+					if (! isset($list[$assoc['rate']]['localtax1'])) {
1104
+					    $list[$assoc['rate']]['localtax1']=0;
1105
+					}
1106
+					if (! isset($list[$assoc['rate']]['localtax2'])) {
1107
+					    $list[$assoc['rate']]['localtax2']=0;
1108
+					}
961 1109
 
962
-					if ($assoc['rowid'] != $oldrowid)       // Si rupture sur d.rowid
1110
+					if ($assoc['rowid'] != $oldrowid) {
1111
+					    // Si rupture sur d.rowid
963 1112
 					{
964 1113
 						$oldrowid=$assoc['rowid'];
1114
+					}
965 1115
 						$list[$assoc['rate']]['totalht']   += $assoc['total_ht'];
966 1116
                         $list[$assoc['rate']]['vat']       += $assoc['total_vat'];
967 1117
 						$list[$assoc['rate']]['localtax1'] += $assoc['total_localtax1'];
@@ -997,8 +1147,7 @@  discard block
 block discarded – undo
997 1147
 
998 1148
 					$rate = $assoc['rate'];
999 1149
 				}
1000
-			}
1001
-			else
1150
+			} else
1002 1151
 			{
1003 1152
 				dol_print_error($db);
1004 1153
 				return -3;
Please login to merge, or discard this patch.
dolibarr/htdocs/core/lib/ajax.lib.php 1 patch
Braces   +36 added lines, -14 removed lines patch added patch discarded remove patch
@@ -45,13 +45,19 @@  discard block
 block discarded – undo
45 45
  */
46 46
 function ajax_autocompleter($selected, $htmlname, $url, $urloption='', $minLength=2, $autoselect=0, $ajaxoptions=array())
47 47
 {
48
-    if (empty($minLength)) $minLength=1;
48
+    if (empty($minLength)) {
49
+        $minLength=1;
50
+    }
49 51
 
50 52
     $dataforrenderITem='ui-autocomplete';
51 53
     $dataforitem='ui-autocomplete-item';
52 54
     // Allow two constant to use other values for backward compatibility
53
-    if (defined('JS_QUERY_AUTOCOMPLETE_RENDERITEM')) $dataforrenderITem=constant('JS_QUERY_AUTOCOMPLETE_RENDERITEM');
54
-    if (defined('JS_QUERY_AUTOCOMPLETE_ITEM'))       $dataforitem=constant('JS_QUERY_AUTOCOMPLETE_ITEM');
55
+    if (defined('JS_QUERY_AUTOCOMPLETE_RENDERITEM')) {
56
+        $dataforrenderITem=constant('JS_QUERY_AUTOCOMPLETE_RENDERITEM');
57
+    }
58
+    if (defined('JS_QUERY_AUTOCOMPLETE_ITEM')) {
59
+        $dataforitem=constant('JS_QUERY_AUTOCOMPLETE_ITEM');
60
+    }
55 61
 
56 62
     // Input search_htmlname is original field
57 63
     // Input htmlname is a second input field used when using ajax autocomplete.
@@ -377,13 +383,23 @@  discard block
 block discarded – undo
377 383
 
378 384
 	// select2 disabled for smartphones with standard browser.
379 385
 	// TODO With select2 v4, it seems ok, except that responsive style on table become crazy when scrolling at end of array)
380
-	if (! empty($conf->browser->layout) && $conf->browser->layout == 'phone') return '';
386
+	if (! empty($conf->browser->layout) && $conf->browser->layout == 'phone') {
387
+	    return '';
388
+	}
381 389
 
382
-	if (! empty($conf->global->MAIN_DISABLE_AJAX_COMBOX)) return '';
383
-	if (empty($conf->use_javascript_ajax)) return '';
384
-	if (empty($conf->global->MAIN_USE_JQUERY_MULTISELECT) && ! defined('REQUIRE_JQUERY_MULTISELECT')) return '';
390
+	if (! empty($conf->global->MAIN_DISABLE_AJAX_COMBOX)) {
391
+	    return '';
392
+	}
393
+	if (empty($conf->use_javascript_ajax)) {
394
+	    return '';
395
+	}
396
+	if (empty($conf->global->MAIN_USE_JQUERY_MULTISELECT) && ! defined('REQUIRE_JQUERY_MULTISELECT')) {
397
+	    return '';
398
+	}
385 399
 
386
-	if (empty($minLengthToAutocomplete)) $minLengthToAutocomplete=0;
400
+	if (empty($minLengthToAutocomplete)) {
401
+	    $minLengthToAutocomplete=0;
402
+	}
387 403
 
388 404
     $tmpplugin='select2';
389 405
     $msg="\n".'<!-- JS CODE TO ENABLE '.$tmpplugin.' for id = '.$htmlname.' -->
@@ -410,10 +426,13 @@  discard block
 block discarded – undo
410 426
 					},
411 427
 					dropdownCssClass: \'ui-dialog\'
412 428
 				})';
413
-	if ($forcefocus) $msg.= '.select2(\'focus\')';
429
+	if ($forcefocus) {
430
+	    $msg.= '.select2(\'focus\')';
431
+	}
414 432
 	$msg.= ';'."\n";
415 433
 
416
-	if (is_array($events) && count($events))    // If an array of js events to do were provided.
434
+	if (is_array($events) && count($events)) {
435
+	    // If an array of js events to do were provided.
417 436
 	{
418 437
 		$msg.= '
419 438
 			jQuery("#'.$htmlname.'").change(function () {
@@ -463,6 +482,7 @@  discard block
 block discarded – undo
463 482
 				);
464 483
 			}';
465 484
 	}
485
+	}
466 486
 
467 487
 	$msg.= '});'."\n";
468 488
     $msg.= "</script>\n";
@@ -488,10 +508,12 @@  discard block
 block discarded – undo
488 508
 
489 509
 	if (empty($conf->use_javascript_ajax))
490 510
 	{
491
-		if (empty($conf->global->$code)) print '<a href="'.$_SERVER['PHP_SELF'].'?action=set_'.$code.'&entity='.$entity.'">'.img_picto($langs->trans("Disabled"),'off').'</a>';
492
-		else print '<a href="'.$_SERVER['PHP_SELF'].'?action=del_'.$code.'&entity='.$entity.'">'.img_picto($langs->trans("Enabled"),'on').'</a>';
493
-	}
494
-	else
511
+		if (empty($conf->global->$code)) {
512
+		    print '<a href="'.$_SERVER['PHP_SELF'].'?action=set_'.$code.'&entity='.$entity.'">'.img_picto($langs->trans("Disabled"),'off').'</a>';
513
+		} else {
514
+		    print '<a href="'.$_SERVER['PHP_SELF'].'?action=del_'.$code.'&entity='.$entity.'">'.img_picto($langs->trans("Enabled"),'on').'</a>';
515
+		}
516
+	} else
495 517
 	{
496 518
 		$out= "\n<!-- Ajax code to switch constant ".$code." -->".'
497 519
 		<script type="text/javascript">
Please login to merge, or discard this patch.
dolibarr/htdocs/core/lib/invoice2.lib.php 1 patch
Braces   +104 added lines, -46 removed lines patch added patch discarded remove patch
@@ -60,8 +60,11 @@  discard block
 block discarded – undo
60 60
 	}
61 61
 	if (in_array('date',$filter))
62 62
 	{
63
-		if (empty($sqlwhere)) $sqlwhere=' WHERE ';
64
-		else $sqlwhere.=" AND";
63
+		if (empty($sqlwhere)) {
64
+		    $sqlwhere=' WHERE ';
65
+		} else {
66
+		    $sqlwhere.=" AND";
67
+		}
65 68
 		$sqlwhere.= " f.fk_statut > 0";
66 69
 		$sqlwhere.= " AND f.datef >= '".$db->idate($dateafterdate)."'";
67 70
 		$sqlwhere.= " AND f.datef <= '".$db->idate($datebeforedate)."'";
@@ -70,17 +73,25 @@  discard block
 block discarded – undo
70 73
 	if (in_array('nopayment',$filter))
71 74
 	{
72 75
 		$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."paiement_facture as pf ON f.rowid = pf.fk_facture";
73
-		if (empty($sqlwhere)) $sqlwhere=' WHERE ';
74
-		else $sqlwhere.=" AND";
76
+		if (empty($sqlwhere)) {
77
+		    $sqlwhere=' WHERE ';
78
+		} else {
79
+		    $sqlwhere.=" AND";
80
+		}
75 81
 		$sqlwhere.= " f.fk_statut > 0";
76 82
 		$sqlwhere.= " AND pf.fk_paiement IS NULL";
77 83
 	}
78 84
 	if (in_array('payments',$filter) || in_array('bank',$filter))
79 85
 	{
80 86
 		$sql.= ", ".MAIN_DB_PREFIX."paiement_facture as pf, ".MAIN_DB_PREFIX."paiement as p";
81
-		if (in_array('bank',$filter)) $sql.= ", ".MAIN_DB_PREFIX."bank as b";
82
-		if (empty($sqlwhere)) $sqlwhere=' WHERE ';
83
-		else $sqlwhere.=" AND";
87
+		if (in_array('bank',$filter)) {
88
+		    $sql.= ", ".MAIN_DB_PREFIX."bank as b";
89
+		}
90
+		if (empty($sqlwhere)) {
91
+		    $sqlwhere=' WHERE ';
92
+		} else {
93
+		    $sqlwhere.=" AND";
94
+		}
84 95
 		$sqlwhere.= " f.fk_statut > 0";
85 96
 		$sqlwhere.= " AND f.rowid = pf.fk_facture";
86 97
 		$sqlwhere.= " AND pf.fk_paiement = p.rowid";
@@ -98,41 +109,62 @@  discard block
 block discarded – undo
98 109
 	}
99 110
 	if (in_array('nodeposit',$filter))
100 111
 	{
101
-	    if (empty($sqlwhere)) $sqlwhere=' WHERE ';
102
-	    else $sqlwhere.=" AND";
112
+	    if (empty($sqlwhere)) {
113
+	        $sqlwhere=' WHERE ';
114
+	    } else {
115
+	        $sqlwhere.=" AND";
116
+	    }
103 117
 	    $sqlwhere.=' type <> 3';
104 118
 	}
105 119
 	if (in_array('noreplacement',$filter))
106 120
 	{
107
-	    if (empty($sqlwhere)) $sqlwhere=' WHERE ';
108
-	    else $sqlwhere.=" AND";
121
+	    if (empty($sqlwhere)) {
122
+	        $sqlwhere=' WHERE ';
123
+	    } else {
124
+	        $sqlwhere.=" AND";
125
+	    }
109 126
 	    $sqlwhere.=' type <> 1';
110 127
 	}
111 128
 	if (in_array('nocreditnote',$filter))
112 129
 	{
113
-	    if (empty($sqlwhere)) $sqlwhere=' WHERE ';
114
-	    else $sqlwhere.=" AND";
130
+	    if (empty($sqlwhere)) {
131
+	        $sqlwhere=' WHERE ';
132
+	    } else {
133
+	        $sqlwhere.=" AND";
134
+	    }
115 135
 	    $sqlwhere.=' type <> 2';
116 136
 	}
117 137
 	if (in_array('excludethirdparties',$filter) && is_array($thirdpartiesid))
118 138
 	{
119
-	    if (empty($sqlwhere)) $sqlwhere=' WHERE ';
120
-	    else $sqlwhere.=" AND";
139
+	    if (empty($sqlwhere)) {
140
+	        $sqlwhere=' WHERE ';
141
+	    } else {
142
+	        $sqlwhere.=" AND";
143
+	    }
121 144
 	    $sqlwhere.=' f.fk_soc NOT IN ('.join(',',$thirdpartiesid).')';
122 145
 	}
123 146
 	if (in_array('onlythirdparties',$filter) && is_array($thirdpartiesid))
124 147
 	{
125
-	    if (empty($sqlwhere)) $sqlwhere=' WHERE ';
126
-	    else $sqlwhere.=" AND";
148
+	    if (empty($sqlwhere)) {
149
+	        $sqlwhere=' WHERE ';
150
+	    } else {
151
+	        $sqlwhere.=" AND";
152
+	    }
127 153
 	    $sqlwhere.=' f.fk_soc IN ('.join(',',$thirdpartiesid).')';
128 154
 	}
129
-	if ($sqlwhere) $sql.=$sqlwhere;
130
-	if ($sqlorder) $sql.=$sqlorder;
155
+	if ($sqlwhere) {
156
+	    $sql.=$sqlwhere;
157
+	}
158
+	if ($sqlorder) {
159
+	    $sql.=$sqlorder;
160
+	}
131 161
 
132 162
 	//print $sql; exit;
133 163
 	dol_syslog("scripts/invoices/rebuild_merge.php:", LOG_DEBUG);
134 164
 
135
-	if ($usestdout) print '--- start'."\n";
165
+	if ($usestdout) {
166
+	    print '--- start'."\n";
167
+	}
136 168
 
137 169
 	// Start of transaction
138 170
 	//$db->begin();
@@ -175,11 +207,14 @@  discard block
 block discarded – undo
175 207
 					$filename=$conf->facture->dir_output.'/'.$fac->ref.'/'.$fac->ref.'.pdf';
176 208
 					if ($regenerate || ! dol_is_file($filename))
177 209
 					{
178
-	            	    if ($usestdout) print "Build PDF for invoice ".$obj->ref." - Lang = ".$outputlangs->defaultlang."\n";
210
+	            	    if ($usestdout) {
211
+	            	        print "Build PDF for invoice ".$obj->ref." - Lang = ".$outputlangs->defaultlang."\n";
212
+	            	    }
179 213
 	    				$result= $fac->generateDocument($regenerate?$regenerate:$fac->modelpdf, $outputlangs);
180
-					}
181
-					else {
182
-					    if ($usestdout) print "PDF for invoice ".$obj->ref." already exists\n";
214
+					} else {
215
+					    if ($usestdout) {
216
+					        print "PDF for invoice ".$obj->ref." already exists\n";
217
+					    }
183 218
 					}
184 219
 
185 220
 					// Add file into files array
@@ -189,8 +224,11 @@  discard block
 block discarded – undo
189 224
 				if ($result <= 0)
190 225
 				{
191 226
 					$error++;
192
-					if ($usestdout) print "Error: Failed to build PDF for invoice ".($fac->ref?$fac->ref:' id '.$obj->rowid)."\n";
193
-					else dol_syslog("Failed to build PDF for invoice ".($fac->ref?$fac->ref:' id '.$obj->rowid), LOG_ERR);
227
+					if ($usestdout) {
228
+					    print "Error: Failed to build PDF for invoice ".($fac->ref?$fac->ref:' id '.$obj->rowid)."\n";
229
+					} else {
230
+					    dol_syslog("Failed to build PDF for invoice ".($fac->ref?$fac->ref:' id '.$obj->rowid), LOG_ERR);
231
+					}
194 232
 				}
195 233
 
196 234
 	            $cpt++;
@@ -203,8 +241,11 @@  discard block
 block discarded – undo
203 241
 	        $page_hauteur = $formatarray['height'];
204 242
 	        $format = array($page_largeur,$page_hauteur);
205 243
 
206
-	        if ($usestdout) print "Using output PDF format ".join('x',$format)."\n";
207
-	        else dol_syslog("Using output PDF format ".join('x',$format), LOG_ERR);
244
+	        if ($usestdout) {
245
+	            print "Using output PDF format ".join('x',$format)."\n";
246
+	        } else {
247
+	            dol_syslog("Using output PDF format ".join('x',$format), LOG_ERR);
248
+	        }
208 249
 
209 250
 
210 251
 	        // Now, build a merged files with all files in $files array
@@ -219,14 +260,19 @@  discard block
 block discarded – undo
219 260
 	        }
220 261
 	        $pdf->SetFont(pdf_getPDFFont($langs));
221 262
 
222
-	        if ($conf->global->MAIN_DISABLE_PDF_COMPRESSION) $pdf->SetCompression(false);
263
+	        if ($conf->global->MAIN_DISABLE_PDF_COMPRESSION) {
264
+	            $pdf->SetCompression(false);
265
+	        }
223 266
 			//$pdf->SetCompression(false);
224 267
 
225 268
 			// Add all others
226 269
 			foreach($files as $file)
227 270
 			{
228
-	            if ($usestdout) print "Merge PDF file for invoice ".$file."\n";
229
-	            else dol_syslog("Merge PDF file for invoice ".$file);
271
+	            if ($usestdout) {
272
+	                print "Merge PDF file for invoice ".$file."\n";
273
+	            } else {
274
+	                dol_syslog("Merge PDF file for invoice ".$file);
275
+	            }
230 276
 
231 277
 				// Charge un document PDF depuis un fichier.
232 278
 				$pagecount = $pdf->setSourceFile($file);
@@ -244,40 +290,52 @@  discard block
 block discarded – undo
244 290
 
245 291
 			// Save merged file
246 292
 			$filename=$fileprefix;
247
-			if (empty($filename)) $filename='mergedpdf';
248
-			if (! empty($filesuffix)) $filename.='_'.$filesuffix;
293
+			if (empty($filename)) {
294
+			    $filename='mergedpdf';
295
+			}
296
+			if (! empty($filesuffix)) {
297
+			    $filename.='_'.$filesuffix;
298
+			}
249 299
 			$file=$diroutputpdf.'/'.$filename.'.pdf';
250 300
 
251 301
 			if (! $error && $pagecount)
252 302
 			{
253 303
 				$pdf->Output($file,'F');
254
-				if (! empty($conf->global->MAIN_UMASK))
255
-					@chmod($file, octdec($conf->global->MAIN_UMASK));
304
+				if (! empty($conf->global->MAIN_UMASK)) {
305
+									@chmod($file, octdec($conf->global->MAIN_UMASK));
306
+				}
256 307
 			}
257 308
 
258 309
 			if ($usestdout)
259 310
 			{
260
-				if (! $error) print "Merged PDF has been built in ".$file."\n";
261
-				else print "Can't build PDF ".$file."\n";
311
+				if (! $error) {
312
+				    print "Merged PDF has been built in ".$file."\n";
313
+				} else {
314
+				    print "Can't build PDF ".$file."\n";
315
+				}
262 316
 			}
263 317
 
264 318
 			$result = 1;
265
-	    }
266
-	    else
319
+	    } else
267 320
 	    {
268
-	        if ($usestdout) print "No invoices found for criteria.\n";
269
-	        else dol_syslog("No invoices found for criteria");
321
+	        if ($usestdout) {
322
+	            print "No invoices found for criteria.\n";
323
+	        } else {
324
+	            dol_syslog("No invoices found for criteria");
325
+	        }
270 326
 	        $result = 0;
271 327
 	    }
272
-	}
273
-	else
328
+	} else
274 329
 	{
275 330
 	    dol_print_error($db);
276 331
 	    dol_syslog("scripts/invoices/rebuild_merge.php: Error");
277 332
 	    $error++;
278 333
 	}
279 334
 
280
-	if ($error) return -1;
281
-	else return $result;
282
-}
335
+	if ($error) {
336
+	    return -1;
337
+	} else {
338
+	    return $result;
339
+	}
340
+	}
283 341
 
Please login to merge, or discard this patch.