Passed
Push — master ( 49af33...3cffbe )
by Alxarafe
21:21
created
dolibarr/htdocs/core/lib/supplier_proposal.lib.php 1 patch
Braces   +15 added lines, -5 removed lines patch added patch discarded remove patch
@@ -49,7 +49,9 @@  discard block
 block discarded – undo
49 49
 		$nbContact = count($object->liste_contact(-1,'internal')) + count($object->liste_contact(-1,'external'));
50 50
 		$head[$h][0] = DOL_URL_ROOT.'/supplier_proposal/contact.php?id='.$object->id;
51 51
 		$head[$h][1] = $langs->trans('ContactsAddresses');
52
-		if ($nbContact > 0) $head[$h][1].= ' <span class="badge">'.$nbContact.'</span>';
52
+		if ($nbContact > 0) {
53
+		    $head[$h][1].= ' <span class="badge">'.$nbContact.'</span>';
54
+		}
53 55
 		$head[$h][2] = 'contact';
54 56
 		$h++;
55 57
 	}
@@ -63,11 +65,17 @@  discard block
 block discarded – undo
63 65
     if (empty($conf->global->MAIN_DISABLE_NOTES_TAB))
64 66
     {
65 67
     	$nbNote = 0;
66
-        if(!empty($object->note_private)) $nbNote++;
67
-		if(!empty($object->note_public)) $nbNote++;
68
+        if(!empty($object->note_private)) {
69
+            $nbNote++;
70
+        }
71
+		if(!empty($object->note_public)) {
72
+		    $nbNote++;
73
+		}
68 74
 	    $head[$h][0] = DOL_URL_ROOT.'/supplier_proposal/note.php?id='.$object->id;
69 75
 		$head[$h][1] = $langs->trans('Notes');
70
-		if ($nbNote > 0) $head[$h][1].= ' <span class="badge">'.$nbNote.'</span>';
76
+		if ($nbNote > 0) {
77
+		    $head[$h][1].= ' <span class="badge">'.$nbNote.'</span>';
78
+		}
71 79
 		$head[$h][2] = 'note';
72 80
 		$h++;
73 81
     }
@@ -79,7 +87,9 @@  discard block
 block discarded – undo
79 87
     $nbLinks=Link::count($db, $object->element, $object->id);
80 88
 	$head[$h][0] = DOL_URL_ROOT.'/supplier_proposal/document.php?id='.$object->id;
81 89
 	$head[$h][1] = $langs->trans('Documents');
82
-	if (($nbFiles+$nbLinks) > 0) $head[$h][1].= ' <span class="badge">'.($nbFiles+$nbLinks).'</span>';
90
+	if (($nbFiles+$nbLinks) > 0) {
91
+	    $head[$h][1].= ' <span class="badge">'.($nbFiles+$nbLinks).'</span>';
92
+	}
83 93
 	$head[$h][2] = 'document';
84 94
 	$h++;
85 95
 
Please login to merge, or discard this patch.
dolibarr/htdocs/core/lib/date.lib.php 1 patch
Braces   +331 added lines, -119 removed lines patch added patch discarded remove patch
@@ -87,16 +87,19 @@  discard block
 block discarded – undo
87 87
     {
88 88
         // Method 1 (include daylight)
89 89
         $gmtnow=dol_now('gmt'); $yearref=dol_print_date($gmtnow,'%Y'); $monthref=dol_print_date($gmtnow,'%m'); $dayref=dol_print_date($gmtnow,'%d');
90
-        if ($refgmtdate == 'now') $newrefgmtdate=$yearref.'-'.$monthref.'-'.$dayref;
91
-        elseif ($refgmtdate == 'summer') $newrefgmtdate=$yearref.'-08-01';
92
-        else $newrefgmtdate=$yearref.'-01-01';
90
+        if ($refgmtdate == 'now') {
91
+            $newrefgmtdate=$yearref.'-'.$monthref.'-'.$dayref;
92
+        } elseif ($refgmtdate == 'summer') {
93
+            $newrefgmtdate=$yearref.'-08-01';
94
+        } else {
95
+            $newrefgmtdate=$yearref.'-01-01';
96
+        }
93 97
         $newrefgmtdate.='T00:00:00+00:00';
94 98
         $localtz = new DateTimeZone(getServerTimeZoneString());
95 99
         $localdt = new DateTime($newrefgmtdate, $localtz);
96 100
         $tmp=-1*$localtz->getOffset($localdt);
97 101
         //print $refgmtdate.'='.$tmp;
98
-    }
99
-    else
102
+    } else
100 103
     {
101 104
     	$tmp=0;
102 105
     	dol_print_error('','PHP version must be 5.3+');
@@ -118,9 +121,15 @@  discard block
 block discarded – undo
118 121
 {
119 122
 	global $conf;
120 123
 
121
-	if ($duration_value == 0)  return $time;
122
-	if ($duration_unit == 'h') return $time + (3600*$duration_value);
123
-	if ($duration_unit == 'w') return $time + (3600*24*7*$duration_value);
124
+	if ($duration_value == 0) {
125
+	    return $time;
126
+	}
127
+	if ($duration_unit == 'h') {
128
+	    return $time + (3600*$duration_value);
129
+	}
130
+	if ($duration_unit == 'w') {
131
+	    return $time + (3600*24*7*$duration_value);
132
+	}
124 133
 
125 134
 	$deltastring='P';
126 135
 
@@ -131,12 +140,17 @@  discard block
 block discarded – undo
131 140
 	if ($duration_unit == 'y') { $deltastring.="Y"; }
132 141
 
133 142
 	$date = new DateTime();
134
-	if (! empty($conf->global->MAIN_DATE_IN_MEMORY_ARE_GMT)) $date->setTimezone(new DateTimeZone('UTC'));
143
+	if (! empty($conf->global->MAIN_DATE_IN_MEMORY_ARE_GMT)) {
144
+	    $date->setTimezone(new DateTimeZone('UTC'));
145
+	}
135 146
 	$date->setTimestamp($time);
136 147
 	$interval = new DateInterval($deltastring);
137 148
 
138
-	if($sub) $date->sub($interval);
139
-	else $date->add( $interval );
149
+	if($sub) {
150
+	    $date->sub($interval);
151
+	} else {
152
+	    $date->add( $interval );
153
+	}
140 154
 
141 155
 	return $date->getTimestamp();
142 156
 }
@@ -182,12 +196,21 @@  discard block
 block discarded – undo
182 196
 {
183 197
 	global $langs;
184 198
 
185
-	if (empty($lengthOfDay))  $lengthOfDay = 86400;         // 1 day = 24 hours
186
-    if (empty($lengthOfWeek)) $lengthOfWeek = 7;            // 1 week = 7 days
199
+	if (empty($lengthOfDay)) {
200
+	    $lengthOfDay = 86400;
201
+	}
202
+	// 1 day = 24 hours
203
+    if (empty($lengthOfWeek)) {
204
+        $lengthOfWeek = 7;
205
+    }
206
+    // 1 week = 7 days
187 207
 
188 208
 	if ($format == 'all' || $format == 'allwithouthour' || $format == 'allhour' || $format == 'allhourmin')
189 209
 	{
190
-		if ((int) $iSecond === 0) return '0';	// This is to avoid having 0 return a 12:00 AM for en_US
210
+		if ((int) $iSecond === 0) {
211
+		    return '0';
212
+		}
213
+		// This is to avoid having 0 return a 12:00 AM for en_US
191 214
 
192 215
         $sTime='';
193 216
         $sDay=0;
@@ -201,7 +224,9 @@  discard block
 block discarded – undo
201 224
 				$iSecond-=$lengthOfDay;
202 225
 			}
203 226
 			$dayTranslate = $langs->trans("Day");
204
-			if ($iSecond >= ($lengthOfDay*2)) $dayTranslate = $langs->trans("Days");
227
+			if ($iSecond >= ($lengthOfDay*2)) {
228
+			    $dayTranslate = $langs->trans("Days");
229
+			}
205 230
 		}
206 231
 
207 232
 		if ($lengthOfWeek < 7)
@@ -213,7 +238,9 @@  discard block
 block discarded – undo
213 238
                     $sWeek = (int) (($sDay - $sDay % $lengthOfWeek ) / $lengthOfWeek);
214 239
                     $sDay = $sDay % $lengthOfWeek;
215 240
                     $weekTranslate = $langs->trans("DurationWeek");
216
-                    if ($sWeek >= 2) $weekTranslate = $langs->trans("DurationWeeks");
241
+                    if ($sWeek >= 2) {
242
+                        $weekTranslate = $langs->trans("DurationWeeks");
243
+                    }
217 244
                     $sTime.=$sWeek.' '.$weekTranslate.' ';
218 245
                 }
219 246
             }
@@ -221,7 +248,9 @@  discard block
 block discarded – undo
221 248
 		if ($sDay>0)
222 249
 		{
223 250
 			$dayTranslate = $langs->trans("Day");
224
-			if ($sDay > 1) $dayTranslate = $langs->trans("Days");
251
+			if ($sDay > 1) {
252
+			    $dayTranslate = $langs->trans("Days");
253
+			}
225 254
 			$sTime.=$sDay.' '.$dayTranslate.' ';
226 255
 		}
227 256
 
@@ -240,37 +269,40 @@  discard block
 block discarded – undo
240 269
 		{
241 270
 			return sprintf("%02d",($sWeek*$lengthOfWeek*24 + $sDay*24 + (int) floor($iSecond/3600)));
242 271
 		}
243
-	}
244
-	else if ($format == 'hour')	// only hour part
272
+	} else if ($format == 'hour') {
273
+	    // only hour part
245 274
 	{
246 275
 		$sTime=dol_print_date($iSecond,'%H',true);
247 276
 	}
248
-	else if ($format == 'fullhour')
277
+	} else if ($format == 'fullhour')
249 278
 	{
250 279
 		if (!empty($iSecond)) {
251 280
 			$iSecond=$iSecond/3600;
252
-		}
253
-		else {
281
+		} else {
254 282
 			$iSecond=0;
255 283
 		}
256 284
 		$sTime=$iSecond;
257
-	}
258
-	else if ($format == 'min')	// only min part
285
+	} else if ($format == 'min') {
286
+	    // only min part
259 287
 	{
260 288
 		$sTime=dol_print_date($iSecond,'%M',true);
261 289
 	}
262
-    else if ($format == 'sec')	// only sec part
290
+	} else if ($format == 'sec') {
291
+        // only sec part
263 292
     {
264 293
         $sTime=dol_print_date($iSecond,'%S',true);
265 294
     }
266
-    else if ($format == 'month')	// only month part
295
+    } else if ($format == 'month') {
296
+        // only month part
267 297
     {
268 298
         $sTime=dol_print_date($iSecond,'%m',true);
269 299
     }
270
-    else if ($format == 'year')	// only year part
300
+    } else if ($format == 'year') {
301
+        // only year part
271 302
     {
272 303
         $sTime=dol_print_date($iSecond,'%Y',true);
273 304
     }
305
+    }
274 306
     return trim($sTime);
275 307
 }
276 308
 
@@ -295,8 +327,9 @@  discard block
 block discarded – undo
295 327
 		} else if ($year_date > 0 && ! empty($day_date)) {
296 328
 			$sqldate.= " AND ".$datefield." BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $month_date, $day_date, $year_date));
297 329
 			$sqldate.= "' AND '".$db->idate(dol_mktime(23, 59, 59, $month_date, $day_date, $year_date))."'";
298
-		} else
299
-			$sqldate.= " AND date_format( ".$datefield.", '%m') = '".$db->escape($month_date)."'";
330
+		} else {
331
+					$sqldate.= " AND date_format( ".$datefield.", '%m') = '".$db->escape($month_date)."'";
332
+		}
300 333
 	} else if ($year_date > 0){
301 334
 		$sqldate.= " AND ".$datefield." BETWEEN '".$db->idate(dol_get_first_day($year_date, 1, false));
302 335
 		$sqldate.= "' AND '".$db->idate(dol_get_last_day($year_date, 12, false))."'";
@@ -336,11 +369,14 @@  discard block
 block discarded – undo
336 369
         $shour = $reg[4];
337 370
         $smin = $reg[5];
338 371
         $ssec = $reg[6];
339
-        if ($syear < 50) $syear+=1900;
340
-        if ($syear >= 50 && $syear < 100) $syear+=2000;
372
+        if ($syear < 50) {
373
+            $syear+=1900;
374
+        }
375
+        if ($syear >= 50 && $syear < 100) {
376
+            $syear+=2000;
377
+        }
341 378
         $string=sprintf("%04d%02d%02d%02d%02d%02d",$syear,$smonth,$sday,$shour,$smin,$ssec);
342
-    }
343
-    else if (
379
+    } else if (
344 380
     	   preg_match('/^([0-9]{4})-([0-9]{2})-([0-9]{2})T([0-9]{2}):([0-9]{2}):([0-9]{2})Z$/i',$string,$reg)	// Convert date with format YYYY-MM-DDTHH:MM:SSZ (RFC3339)
345 381
     	|| preg_match('/^([0-9]{4})-([0-9]{2})-([0-9]{2}) ([0-9]{2}):([0-9]{2}):([0-9]{2})$/i',$string,$reg)	// Convert date with format YYYY-MM-DD HH:MM:SS
346 382
    		|| preg_match('/^([0-9]{4})([0-9]{2})([0-9]{2})T([0-9]{2})([0-9]{2})([0-9]{2})Z$/i',$string,$reg)		// Convert date with format YYYYMMDDTHHMMSSZ
@@ -404,8 +440,7 @@  discard block
 block discarded – undo
404 440
 	{
405 441
 		$prev_month = 12;
406 442
 		$prev_year  = $year - 1;
407
-	}
408
-	else
443
+	} else
409 444
 	{
410 445
 		$prev_month = $month-1;
411 446
 		$prev_year  = $year;
@@ -425,8 +460,7 @@  discard block
 block discarded – undo
425 460
 	{
426 461
 		$next_month = 1;
427 462
 		$next_year  = $year + 1;
428
-	}
429
-	else
463
+	} else
430 464
 	{
431 465
 		$next_month = $month + 1;
432 466
 		$next_year  = $year;
@@ -482,7 +516,9 @@  discard block
 block discarded – undo
482 516
  */
483 517
 function dol_get_first_day($year,$month=1,$gm=false)
484 518
 {
485
-	if ($year > 9999) return '';
519
+	if ($year > 9999) {
520
+	    return '';
521
+	}
486 522
 	return dol_mktime(0,0,0,$month,1,$year,$gm);
487 523
 }
488 524
 
@@ -496,13 +532,14 @@  discard block
 block discarded – undo
496 532
  */
497 533
 function dol_get_last_day($year,$month=12,$gm=false)
498 534
 {
499
-	if ($year > 9999) return '';
535
+	if ($year > 9999) {
536
+	    return '';
537
+	}
500 538
 	if ($month == 12)
501 539
 	{
502 540
 		$month = 1;
503 541
 		$year += 1;
504
-	}
505
-	else
542
+	} else
506 543
 	{
507 544
 		$month += 1;
508 545
 	}
@@ -536,7 +573,9 @@  discard block
 block discarded – undo
536 573
 
537 574
 	//Calculate days = offset from current day
538 575
 	$days = $start_week - $tmparray['wday'];
539
- 	if ($days>=1) $days=7-$days;
576
+ 	if ($days>=1) {
577
+ 	    $days=7-$days;
578
+ 	}
540 579
  	$days = abs($days);
541 580
     $seconds = $days*24*60*60;
542 581
 	//print 'start_week='.$start_week.' tmparray[wday]='.$tmparray['wday'].' day offset='.$days.' seconds offset='.$seconds.'<br>';
@@ -556,8 +595,7 @@  discard block
 block discarded – undo
556 595
     		$prev_month = 12;
557 596
     		$prev_year  = $year-1;
558 597
     	}
559
-    }
560
-    else
598
+    } else
561 599
     {
562 600
     	$prev_month = $month;
563 601
 		$prev_year  = $year;
@@ -607,13 +645,17 @@  discard block
 block discarded – undo
607 645
 	$nbFerie = 0;
608 646
 
609 647
 	// Check to ensure we use correct parameters
610
-	if ((($timestampEnd - $timestampStart) % 86400) != 0) return 'ErrorDates must use same hours and must be GMT dates';
648
+	if ((($timestampEnd - $timestampStart) % 86400) != 0) {
649
+	    return 'ErrorDates must use same hours and must be GMT dates';
650
+	}
611 651
 
612 652
 	$i=0;
613 653
 	while (( ($lastday == 0 && $timestampStart < $timestampEnd) || ($lastday && $timestampStart <= $timestampEnd) )
614
-	    && ($i < 50000))		// Loop end when equals (Test on i is a security loop to avoid infinite loop)
654
+	    && ($i < 50000)) {
655
+	    // Loop end when equals (Test on i is a security loop to avoid infinite loop)
615 656
 	{
616 657
 		$ferie=false;
658
+	}
617 659
 		$countryfound=0;
618 660
 		$includesaturdayandsunday=1;
619 661
 
@@ -631,11 +673,14 @@  discard block
 block discarded – undo
631 673
 				$tmp=explode('-',$daystring);
632 674
 				if ($tmp[2])
633 675
 				{
634
-					if ($tmp[0] == $annee && $tmp[1] == $mois && $tmp[2] == $jour) $ferie=true;
635
-				}
636
-				else
676
+					if ($tmp[0] == $annee && $tmp[1] == $mois && $tmp[2] == $jour) {
677
+					    $ferie=true;
678
+					}
679
+				} else
637 680
 				{
638
-					if ($tmp[0] == $mois && $tmp[1] == $jour) $ferie=true;
681
+					if ($tmp[0] == $mois && $tmp[1] == $jour) {
682
+					    $ferie=true;
683
+					}
639 684
 				}
640 685
 			}
641 686
 		}
@@ -645,20 +690,46 @@  discard block
 block discarded – undo
645 690
 			$countryfound=1;
646 691
 
647 692
 			// Definition of fixed working days
648
-			if($jour == 1 && $mois == 1)   $ferie=true; // 1er january
649
-			if($jour == 1 && $mois == 5)   $ferie=true; // 1er may
650
-			if($jour == 8 && $mois == 5)   $ferie=true; // 5 may
651
-			if($jour == 14 && $mois == 7)  $ferie=true; // 14 july
652
-			if($jour == 15 && $mois == 8)  $ferie=true; // 15 august
653
-			if($jour == 1 && $mois == 11)  $ferie=true; // 1 november
654
-			if($jour == 11 && $mois == 11) $ferie=true; // 11 november
655
-			if($jour == 25 && $mois == 12) $ferie=true; // 25 december
693
+			if($jour == 1 && $mois == 1) {
694
+			    $ferie=true;
695
+			}
696
+			// 1er january
697
+			if($jour == 1 && $mois == 5) {
698
+			    $ferie=true;
699
+			}
700
+			// 1er may
701
+			if($jour == 8 && $mois == 5) {
702
+			    $ferie=true;
703
+			}
704
+			// 5 may
705
+			if($jour == 14 && $mois == 7) {
706
+			    $ferie=true;
707
+			}
708
+			// 14 july
709
+			if($jour == 15 && $mois == 8) {
710
+			    $ferie=true;
711
+			}
712
+			// 15 august
713
+			if($jour == 1 && $mois == 11) {
714
+			    $ferie=true;
715
+			}
716
+			// 1 november
717
+			if($jour == 11 && $mois == 11) {
718
+			    $ferie=true;
719
+			}
720
+			// 11 november
721
+			if($jour == 25 && $mois == 12) {
722
+			    $ferie=true;
723
+			}
724
+			// 25 december
656 725
 
657 726
 			// Calculation for easter date
658 727
 			$date_paques = easter_date($annee);
659 728
 			$jour_paques = date("d", $date_paques);
660 729
 			$mois_paques = date("m", $date_paques);
661
-			if($jour_paques == $jour && $mois_paques == $mois) $ferie=true;
730
+			if($jour_paques == $jour && $mois_paques == $mois) {
731
+			    $ferie=true;
732
+			}
662 733
 			// Pâques
663 734
 
664 735
 			// Calculation for the monday of easter date
@@ -672,7 +743,9 @@  discard block
 block discarded – undo
672 743
             );
673 744
 			$jour_lundi_ascension = date("d", $date_lundi_paques);
674 745
 			$mois_lundi_ascension = date("m", $date_lundi_paques);
675
-			if($jour_lundi_ascension == $jour && $mois_lundi_ascension == $mois) $ferie=true;
746
+			if($jour_lundi_ascension == $jour && $mois_lundi_ascension == $mois) {
747
+			    $ferie=true;
748
+			}
676 749
 			// Lundi de Pâques
677 750
 
678 751
 			// Calcul du jour de l'ascension (38 days after easter day)
@@ -686,7 +759,9 @@  discard block
 block discarded – undo
686 759
             );
687 760
 			$jour_ascension = date("d", $date_ascension);
688 761
 			$mois_ascension = date("m", $date_ascension);
689
-			if($jour_ascension == $jour && $mois_ascension == $mois) $ferie=true;
762
+			if($jour_ascension == $jour && $mois_ascension == $mois) {
763
+			    $ferie=true;
764
+			}
690 765
 			// Ascension
691 766
 
692 767
 			// Calculation of "Pentecote" (11 days after easter day)
@@ -700,7 +775,9 @@  discard block
 block discarded – undo
700 775
             );
701 776
 			$jour_pentecote = date("d", $date_pentecote);
702 777
 			$mois_pentecote = date("m", $date_pentecote);
703
-			if($jour_pentecote == $jour && $mois_pentecote == $mois) $ferie=true;
778
+			if($jour_pentecote == $jour && $mois_pentecote == $mois) {
779
+			    $ferie=true;
780
+			}
704 781
 			// "Pentecote"
705 782
 		}
706 783
 
@@ -711,22 +788,54 @@  discard block
 block discarded – undo
711 788
 			$countryfound=1;
712 789
 
713 790
 			// Definition des dates feriees fixes
714
-			if($jour == 1 && $mois == 1) $ferie=true; // Capodanno
715
-			if($jour == 6 && $mois == 1) $ferie=true; // Epifania
716
-			if($jour == 25 && $mois == 4) $ferie=true; // Anniversario Liberazione
717
-			if($jour == 1 && $mois == 5) $ferie=true; // Festa del Lavoro
718
-			if($jour == 2 && $mois == 6) $ferie=true; // Festa della Repubblica
719
-			if($jour == 15 && $mois == 8) $ferie=true; // Ferragosto
720
-			if($jour == 1 && $mois == 11) $ferie=true; // Tutti i Santi
721
-			if($jour == 8 && $mois == 12) $ferie=true; // Immacolata Concezione
722
-			if($jour == 25 && $mois == 12) $ferie=true; // 25 decembre
723
-			if($jour == 26 && $mois == 12) $ferie=true; // Santo Stefano
791
+			if($jour == 1 && $mois == 1) {
792
+			    $ferie=true;
793
+			}
794
+			// Capodanno
795
+			if($jour == 6 && $mois == 1) {
796
+			    $ferie=true;
797
+			}
798
+			// Epifania
799
+			if($jour == 25 && $mois == 4) {
800
+			    $ferie=true;
801
+			}
802
+			// Anniversario Liberazione
803
+			if($jour == 1 && $mois == 5) {
804
+			    $ferie=true;
805
+			}
806
+			// Festa del Lavoro
807
+			if($jour == 2 && $mois == 6) {
808
+			    $ferie=true;
809
+			}
810
+			// Festa della Repubblica
811
+			if($jour == 15 && $mois == 8) {
812
+			    $ferie=true;
813
+			}
814
+			// Ferragosto
815
+			if($jour == 1 && $mois == 11) {
816
+			    $ferie=true;
817
+			}
818
+			// Tutti i Santi
819
+			if($jour == 8 && $mois == 12) {
820
+			    $ferie=true;
821
+			}
822
+			// Immacolata Concezione
823
+			if($jour == 25 && $mois == 12) {
824
+			    $ferie=true;
825
+			}
826
+			// 25 decembre
827
+			if($jour == 26 && $mois == 12) {
828
+			    $ferie=true;
829
+			}
830
+			// Santo Stefano
724 831
 
725 832
 			// Calcul du jour de paques
726 833
 			$date_paques = easter_date($annee);
727 834
 			$jour_paques = date("d", $date_paques);
728 835
 			$mois_paques = date("m", $date_paques);
729
-			if($jour_paques == $jour && $mois_paques == $mois) $ferie=true;
836
+			if($jour_paques == $jour && $mois_paques == $mois) {
837
+			    $ferie=true;
838
+			}
730 839
 			// Paques
731 840
 		}
732 841
 
@@ -734,12 +843,30 @@  discard block
 block discarded – undo
734 843
 		{
735 844
 			$countryfound=1;
736 845
 
737
-			if($jour == 1 && $mois == 1) $ferie=true; // New Year's Day
738
-			if($jour == 26 && $mois == 1) $ferie=true; // Republic Day
739
-			if($jour == 1 && $mois == 5) $ferie=true; // May Day
740
-			if($jour == 15 && $mois == 8) $ferie=true; // Independence Day
741
-			if($jour == 2 && $mois == 10) $ferie=true; // Gandhi Jayanti
742
-			if($jour == 25 && $mois == 12) $ferie=true; // Christmas
846
+			if($jour == 1 && $mois == 1) {
847
+			    $ferie=true;
848
+			}
849
+			// New Year's Day
850
+			if($jour == 26 && $mois == 1) {
851
+			    $ferie=true;
852
+			}
853
+			// Republic Day
854
+			if($jour == 1 && $mois == 5) {
855
+			    $ferie=true;
856
+			}
857
+			// May Day
858
+			if($jour == 15 && $mois == 8) {
859
+			    $ferie=true;
860
+			}
861
+			// Independence Day
862
+			if($jour == 2 && $mois == 10) {
863
+			    $ferie=true;
864
+			}
865
+			// Gandhi Jayanti
866
+			if($jour == 25 && $mois == 12) {
867
+			    $ferie=true;
868
+			}
869
+			// Christmas
743 870
 		}
744 871
 
745 872
 		if ($countrycode == 'ES')
@@ -747,21 +874,50 @@  discard block
 block discarded – undo
747 874
 			$countryfound=1;
748 875
 
749 876
 			// Definition des dates feriees fixes
750
-			if($jour == 1 && $mois == 1)   $ferie=true; // Año nuevo
751
-			if($jour == 6 && $mois == 1)   $ferie=true; // Día Reyes
752
-			if($jour == 1 && $mois == 5)   $ferie=true; // 1 Mayo
753
-			if($jour == 15 && $mois == 8)  $ferie=true; // 15 Agosto
754
-			if($jour == 12 && $mois == 10)  $ferie=true; // Día Hispanidad
755
-			if($jour == 1 && $mois == 11)  $ferie=true; // 1 noviembre
756
-			if($jour == 6 && $mois == 12) $ferie=true; // Constitución
757
-			if($jour == 8 && $mois == 12)  $ferie=true; // Inmaculada
758
-			if($jour == 25 && $mois == 12) $ferie=true; // 25 diciembre
877
+			if($jour == 1 && $mois == 1) {
878
+			    $ferie=true;
879
+			}
880
+			// Año nuevo
881
+			if($jour == 6 && $mois == 1) {
882
+			    $ferie=true;
883
+			}
884
+			// Día Reyes
885
+			if($jour == 1 && $mois == 5) {
886
+			    $ferie=true;
887
+			}
888
+			// 1 Mayo
889
+			if($jour == 15 && $mois == 8) {
890
+			    $ferie=true;
891
+			}
892
+			// 15 Agosto
893
+			if($jour == 12 && $mois == 10) {
894
+			    $ferie=true;
895
+			}
896
+			// Día Hispanidad
897
+			if($jour == 1 && $mois == 11) {
898
+			    $ferie=true;
899
+			}
900
+			// 1 noviembre
901
+			if($jour == 6 && $mois == 12) {
902
+			    $ferie=true;
903
+			}
904
+			// Constitución
905
+			if($jour == 8 && $mois == 12) {
906
+			    $ferie=true;
907
+			}
908
+			// Inmaculada
909
+			if($jour == 25 && $mois == 12) {
910
+			    $ferie=true;
911
+			}
912
+			// 25 diciembre
759 913
 
760 914
 			// Calcul día de Pascua
761 915
 			$date_paques = easter_date($annee);
762 916
 			$jour_paques = date("d", $date_paques);
763 917
 			$mois_paques = date("m", $date_paques);
764
-			if($jour_paques == $jour && $mois_paques == $mois) $ferie=true;
918
+			if($jour_paques == $jour && $mois_paques == $mois) {
919
+			    $ferie=true;
920
+			}
765 921
 			// Paques
766 922
 
767 923
 			// Viernes Santo
@@ -775,7 +931,9 @@  discard block
 block discarded – undo
775 931
             );
776 932
 			$jour_viernes = date("d", $date_viernes);
777 933
 			$mois_viernes = date("m", $date_viernes);
778
-			if($jour_viernes == $jour && $mois_viernes == $mois) $ferie=true;
934
+			if($jour_viernes == $jour && $mois_viernes == $mois) {
935
+			    $ferie=true;
936
+			}
779 937
 			//Viernes Santo
780 938
 		}
781 939
 
@@ -784,23 +942,58 @@  discard block
 block discarded – undo
784 942
 		    $countryfound=1;
785 943
 
786 944
 		    // Definition des dates feriees fixes
787
-		    if($jour == 1 && $mois == 1)   $ferie=true; // Neujahr
788
-		    if($jour == 6 && $mois == 1)   $ferie=true; // Hl. 3 Koenige
789
-		    if($jour == 1 && $mois == 5)   $ferie=true; // 1. Mai
790
-		    if($jour == 15 && $mois == 8)  $ferie=true; // Mariae Himmelfahrt
791
-		    if($jour == 26 && $mois == 10) $ferie=true; // 26. Oktober
792
-		    if($jour == 1 && $mois == 11)  $ferie=true; // Allerheiligen
793
-		    if($jour == 8 && $mois == 12)  $ferie=true; // Mariae Empfaengnis
794
-		    if($jour == 24 && $mois == 12) $ferie=true; // Heilig abend
795
-		    if($jour == 25 && $mois == 12) $ferie=true; // Christtag
796
-		    if($jour == 26 && $mois == 12) $ferie=true; // Stefanietag
797
-		    if($jour == 31 && $mois == 12) $ferie=true; // Silvester
945
+		    if($jour == 1 && $mois == 1) {
946
+		        $ferie=true;
947
+		    }
948
+		    // Neujahr
949
+		    if($jour == 6 && $mois == 1) {
950
+		        $ferie=true;
951
+		    }
952
+		    // Hl. 3 Koenige
953
+		    if($jour == 1 && $mois == 5) {
954
+		        $ferie=true;
955
+		    }
956
+		    // 1. Mai
957
+		    if($jour == 15 && $mois == 8) {
958
+		        $ferie=true;
959
+		    }
960
+		    // Mariae Himmelfahrt
961
+		    if($jour == 26 && $mois == 10) {
962
+		        $ferie=true;
963
+		    }
964
+		    // 26. Oktober
965
+		    if($jour == 1 && $mois == 11) {
966
+		        $ferie=true;
967
+		    }
968
+		    // Allerheiligen
969
+		    if($jour == 8 && $mois == 12) {
970
+		        $ferie=true;
971
+		    }
972
+		    // Mariae Empfaengnis
973
+		    if($jour == 24 && $mois == 12) {
974
+		        $ferie=true;
975
+		    }
976
+		    // Heilig abend
977
+		    if($jour == 25 && $mois == 12) {
978
+		        $ferie=true;
979
+		    }
980
+		    // Christtag
981
+		    if($jour == 26 && $mois == 12) {
982
+		        $ferie=true;
983
+		    }
984
+		    // Stefanietag
985
+		    if($jour == 31 && $mois == 12) {
986
+		        $ferie=true;
987
+		    }
988
+		    // Silvester
798 989
 
799 990
 		    // Easter calculation
800 991
 		    $date_paques = easter_date($annee);
801 992
 		    $jour_paques = date("d", $date_paques);
802 993
 		    $mois_paques = date("m", $date_paques);
803
-		    if($jour_paques == $jour && $mois_paques == $mois) $ferie=true;
994
+		    if($jour_paques == $jour && $mois_paques == $mois) {
995
+		        $ferie=true;
996
+		    }
804 997
 		    // Easter sunday
805 998
 
806 999
 		    // Monday after easter
@@ -814,7 +1007,9 @@  discard block
 block discarded – undo
814 1007
 		        );
815 1008
 		    $jour_eastermonday = date("d", $date_eastermonday);
816 1009
 		    $mois_eastermonday = date("m", $date_eastermonday);
817
-		    if($jour_eastermonday == $jour && $mois_eastermonday == $mois) $ferie=true;
1010
+		    if($jour_eastermonday == $jour && $mois_eastermonday == $mois) {
1011
+		        $ferie=true;
1012
+		    }
818 1013
 		    // Easter monday
819 1014
 
820 1015
 		    // Christi Himmelfahrt (39 days after easter sunday)
@@ -828,7 +1023,9 @@  discard block
 block discarded – undo
828 1023
 		        );
829 1024
 		    $jour_ch = date("d", $date_ch);
830 1025
 		    $mois_ch = date("m", $date_ch);
831
-		    if($jour_ch == $jour && $mois_ch == $mois) $ferie=true;
1026
+		    if($jour_ch == $jour && $mois_ch == $mois) {
1027
+		        $ferie=true;
1028
+		    }
832 1029
 		    // Christi Himmelfahrt
833 1030
 
834 1031
 		    // Pfingsten (50 days after easter sunday)
@@ -842,7 +1039,9 @@  discard block
 block discarded – undo
842 1039
 		        );
843 1040
 		    $jour_pentecote = date("d", $date_pentecote);
844 1041
 		    $mois_pentecote = date("m", $date_pentecote);
845
-		    if($jour_pentecote == $jour && $mois_pentecote == $mois) $ferie=true;
1042
+		    if($jour_pentecote == $jour && $mois_pentecote == $mois) {
1043
+		        $ferie=true;
1044
+		    }
846 1045
 		    // Pfingsten
847 1046
 
848 1047
 		    // Fronleichnam (60 days after easter sunday)
@@ -856,7 +1055,9 @@  discard block
 block discarded – undo
856 1055
 		        );
857 1056
 		    $jour_fronleichnam = date("d", $date_fronleichnam);
858 1057
 		    $mois_fronleichnam = date("m", $date_fronleichnam);
859
-		    if($jour_fronleichnam == $jour && $mois_fronleichnam == $mois) $ferie=true;
1058
+		    if($jour_fronleichnam == $jour && $mois_fronleichnam == $mois) {
1059
+		        $ferie=true;
1060
+		    }
860 1061
 		    // Fronleichnam
861 1062
 		}
862 1063
 
@@ -865,12 +1066,16 @@  discard block
 block discarded – undo
865 1066
 		{
866 1067
 			$jour_julien = unixtojd($timestampStart);
867 1068
 			$jour_semaine = jddayofweek($jour_julien, 0);
868
-			if($jour_semaine == 0 || $jour_semaine == 6) $ferie=true;
1069
+			if($jour_semaine == 0 || $jour_semaine == 6) {
1070
+			    $ferie=true;
1071
+			}
869 1072
 			//Saturday (6) and Sunday (0)
870 1073
 		}
871 1074
 
872 1075
 		// On incremente compteur
873
-		if ($ferie) $nbFerie++;
1076
+		if ($ferie) {
1077
+		    $nbFerie++;
1078
+		}
874 1079
 
875 1080
 		// Increase number of days (on go up into loop)
876 1081
 		$timestampStart=dol_time_plus_duree($timestampStart, 1, 'd');
@@ -899,8 +1104,7 @@  discard block
 block discarded – undo
899 1104
 		if ($lastday == 1)
900 1105
 		{
901 1106
 			$bit = 0;
902
-		}
903
-		else
1107
+		} else
904 1108
 		{
905 1109
 			$bit = 1;
906 1110
 		}
@@ -926,13 +1130,19 @@  discard block
 block discarded – undo
926 1130
 {
927 1131
 	global $langs,$mysoc;
928 1132
 
929
-	if (empty($country_code)) $country_code=$mysoc->country_code;
1133
+	if (empty($country_code)) {
1134
+	    $country_code=$mysoc->country_code;
1135
+	}
930 1136
 
931 1137
 	dol_syslog('num_open_day timestampStart='.$timestampStart.' timestampEnd='.$timestampEnd.' bit='.$lastday.' country_code='.$country_code);
932 1138
 
933 1139
 	// Check parameters
934
-	if (! is_int($timestampStart) && ! is_float($timestampStart)) return 'ErrorBadParameter_num_open_day';
935
-	if (! is_int($timestampEnd) && ! is_float($timestampEnd)) return 'ErrorBadParameter_num_open_day';
1140
+	if (! is_int($timestampStart) && ! is_float($timestampStart)) {
1141
+	    return 'ErrorBadParameter_num_open_day';
1142
+	}
1143
+	if (! is_int($timestampEnd) && ! is_float($timestampEnd)) {
1144
+	    return 'ErrorBadParameter_num_open_day';
1145
+	}
936 1146
 
937 1147
 	//print 'num_open_day timestampStart='.$timestampStart.' timestampEnd='.$timestampEnd.' bit='.$lastday;
938 1148
 	if ($timestampStart < $timestampEnd)
@@ -941,16 +1151,18 @@  discard block
 block discarded – undo
941 1151
 		$numholidays = num_public_holiday($timestampStart, $timestampEnd, $country_code, $lastday);
942 1152
 		$nbOpenDay = $numdays - $numholidays;
943 1153
 		$nbOpenDay.= " " . $langs->trans("Days");
944
-		if ($inhour == 1 && $nbOpenDay <= 3) $nbOpenDay = $nbOpenDay*24 . $langs->trans("HourShort");
1154
+		if ($inhour == 1 && $nbOpenDay <= 3) {
1155
+		    $nbOpenDay = $nbOpenDay*24 . $langs->trans("HourShort");
1156
+		}
945 1157
 		return $nbOpenDay - (($inhour == 1 ? 12 : 0.5) * abs($halfday));
946
-	}
947
-	elseif ($timestampStart == $timestampEnd)
1158
+	} elseif ($timestampStart == $timestampEnd)
948 1159
 	{
949 1160
 		$nbOpenDay=$lastday;
950
-		if ($inhour == 1) $nbOpenDay = $nbOpenDay*24 . $langs->trans("HourShort");
1161
+		if ($inhour == 1) {
1162
+		    $nbOpenDay = $nbOpenDay*24 . $langs->trans("HourShort");
1163
+		}
951 1164
 		return $nbOpenDay - (($inhour == 1 ? 12 : 0.5) * abs($halfday));
952
-	}
953
-	else
1165
+	} else
954 1166
 	{
955 1167
 		return $langs->trans("Error");
956 1168
 	}
Please login to merge, or discard this patch.
dolibarr/htdocs/core/lib/product.lib.php 1 patch
Braces   +63 added lines, -26 removed lines patch added patch discarded remove patch
@@ -53,13 +53,15 @@  discard block
 block discarded – undo
53 53
     	$h++;
54 54
 	}
55 55
 
56
-	if (! empty($object->status_buy) || (! empty($conf->margin->enabled) && ! empty($object->status)))   // If margin is on and product on sell, we may need the cost price even if product os not on purchase
56
+	if (! empty($object->status_buy) || (! empty($conf->margin->enabled) && ! empty($object->status))) {
57
+	    // If margin is on and product on sell, we may need the cost price even if product os not on purchase
57 58
 	{
58 59
     	if ((! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->lire)
59 60
     	|| (! empty($conf->margin->enabled) && $user->rights->margin->liretous)
60 61
     	)
61 62
     	{
62 63
     		$head[$h][0] = DOL_URL_ROOT."/product/fournisseurs.php?id=".$object->id;
64
+	}
63 65
     		$head[$h][1] = $langs->trans("BuyingPrices");
64 66
     		$head[$h][2] = 'suppliers';
65 67
     		$h++;
@@ -82,7 +84,9 @@  discard block
 block discarded – undo
82 84
 		$head[$h][1] = $langs->trans('AssociatedProducts');
83 85
 
84 86
 		$nbFatherAndChild = $object->hasFatherOrChild();
85
-		if ($nbFatherAndChild > 0) $head[$h][1].= ' <span class="badge">'.$nbFatherAndChild.'</span>';
87
+		if ($nbFatherAndChild > 0) {
88
+		    $head[$h][1].= ' <span class="badge">'.$nbFatherAndChild.'</span>';
89
+		}
86 90
 		$head[$h][2] = 'subproduct';
87 91
 		$h++;
88 92
 	}
@@ -111,17 +115,21 @@  discard block
 block discarded – undo
111 115
 			$head[$h][1] = $langs->trans('ProductCombinations');
112 116
 			$head[$h][2] = 'combinations';
113 117
 			$nbVariant = $prodcomb->countNbOfCombinationForFkProductParent($object->id);
114
-            if ($nbVariant > 0) $head[$h][1].= ' <span class="badge">'.$nbVariant.'</span>';
118
+            if ($nbVariant > 0) {
119
+                $head[$h][1].= ' <span class="badge">'.$nbVariant.'</span>';
120
+            }
115 121
 		}
116 122
 
117 123
 		$h++;
118 124
 	}
119 125
 
120
-    if ($object->isProduct() || ($object->isService() && ! empty($conf->global->STOCK_SUPPORTS_SERVICES)))    // If physical product we can stock (or service with option)
126
+    if ($object->isProduct() || ($object->isService() && ! empty($conf->global->STOCK_SUPPORTS_SERVICES))) {
127
+        // If physical product we can stock (or service with option)
121 128
     {
122 129
         if (! empty($conf->stock->enabled) && $user->rights->stock->lire)
123 130
         {
124 131
             $head[$h][0] = DOL_URL_ROOT."/product/stock/product.php?id=".$object->id;
132
+    }
125 133
             $head[$h][1] = $langs->trans("Stock");
126 134
             $head[$h][2] = 'stock';
127 135
             $h++;
@@ -138,11 +146,17 @@  discard block
 block discarded – undo
138 146
     if (empty($conf->global->MAIN_DISABLE_NOTES_TAB))
139 147
     {
140 148
         $nbNote = 0;
141
-        if(!empty($object->note_private)) $nbNote++;
142
-        if(!empty($object->note_public)) $nbNote++;
149
+        if(!empty($object->note_private)) {
150
+            $nbNote++;
151
+        }
152
+        if(!empty($object->note_public)) {
153
+            $nbNote++;
154
+        }
143 155
         $head[$h][0] = DOL_URL_ROOT.'/product/note.php?id='.$object->id;
144 156
         $head[$h][1] = $langs->trans('Notes');
145
-        if ($nbNote > 0) $head[$h][1].= ' <span class="badge">'.$nbNote.'</span>';
157
+        if ($nbNote > 0) {
158
+            $head[$h][1].= ' <span class="badge">'.$nbNote.'</span>';
159
+        }
146 160
         $head[$h][2] = 'note';
147 161
         $h++;
148 162
     }
@@ -150,18 +164,28 @@  discard block
 block discarded – undo
150 164
     // Attachments
151 165
 	require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
152 166
     require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php';
153
-    if (! empty($conf->product->enabled) && ($object->type==Product::TYPE_PRODUCT)) $upload_dir = $conf->product->multidir_output[$object->entity].'/'.dol_sanitizeFileName($object->ref);
154
-    if (! empty($conf->service->enabled) && ($object->type==Product::TYPE_SERVICE)) $upload_dir = $conf->service->multidir_output[$object->entity].'/'.dol_sanitizeFileName($object->ref);
167
+    if (! empty($conf->product->enabled) && ($object->type==Product::TYPE_PRODUCT)) {
168
+        $upload_dir = $conf->product->multidir_output[$object->entity].'/'.dol_sanitizeFileName($object->ref);
169
+    }
170
+    if (! empty($conf->service->enabled) && ($object->type==Product::TYPE_SERVICE)) {
171
+        $upload_dir = $conf->service->multidir_output[$object->entity].'/'.dol_sanitizeFileName($object->ref);
172
+    }
155 173
     $nbFiles = count(dol_dir_list($upload_dir,'files',0,'','(\.meta|_preview.*\.png)$'));
156 174
     if (! empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO)) {
157
-        if (! empty($conf->product->enabled) && ($object->type==Product::TYPE_PRODUCT)) $upload_dir = $conf->produit->multidir_output[$object->entity].'/'.get_exdir($object->id,2,0,0,$object,'product').$object->id.'/photos';
158
-        if (! empty($conf->service->enabled) && ($object->type==Product::TYPE_SERVICE)) $upload_dir = $conf->service->multidir_output[$object->entity].'/'.get_exdir($object->id,2,0,0,$object,'product').$object->id.'/photos';
175
+        if (! empty($conf->product->enabled) && ($object->type==Product::TYPE_PRODUCT)) {
176
+            $upload_dir = $conf->produit->multidir_output[$object->entity].'/'.get_exdir($object->id,2,0,0,$object,'product').$object->id.'/photos';
177
+        }
178
+        if (! empty($conf->service->enabled) && ($object->type==Product::TYPE_SERVICE)) {
179
+            $upload_dir = $conf->service->multidir_output[$object->entity].'/'.get_exdir($object->id,2,0,0,$object,'product').$object->id.'/photos';
180
+        }
159 181
         $nbFiles += count(dol_dir_list($upload_dir,'files',0,'','(\.meta|_preview.*\.png)$'));
160 182
     }
161 183
     $nbLinks=Link::count($db, $object->element, $object->id);
162 184
 	$head[$h][0] = DOL_URL_ROOT.'/product/document.php?id='.$object->id;
163 185
 	$head[$h][1] = $langs->trans('Documents');
164
-	if (($nbFiles+$nbLinks) > 0) $head[$h][1].= ' <span class="badge">'.($nbFiles+$nbLinks).'</span>';
186
+	if (($nbFiles+$nbLinks) > 0) {
187
+	    $head[$h][1].= ' <span class="badge">'.($nbFiles+$nbLinks).'</span>';
188
+	}
165 189
 	$head[$h][2] = 'documents';
166 190
 	$h++;
167 191
 
@@ -210,7 +234,9 @@  discard block
 block discarded – undo
210 234
     $nbLinks=Link::count($db, $object->element, $object->id);
211 235
 	$head[$h][0] = DOL_URL_ROOT."/product/stock/productlot_document.php?id=".$object->id;
212 236
 	$head[$h][1] = $langs->trans("Documents");
213
-	if (($nbFiles+$nbLinks) > 0) $head[$h][1].= ' <span class="badge">'.($nbFiles+$nbLinks).'</span>';
237
+	if (($nbFiles+$nbLinks) > 0) {
238
+	    $head[$h][1].= ' <span class="badge">'.($nbFiles+$nbLinks).'</span>';
239
+	}
214 240
     $head[$h][2] = 'documents';
215 241
 	$h++;
216 242
 
@@ -335,7 +361,9 @@  discard block
 block discarded – undo
335 361
 	{
336 362
 		$nblines++;
337 363
 		$ret=$product->load_stats_propale($socid);
338
-		if ($ret < 0) dol_print_error($db);
364
+		if ($ret < 0) {
365
+		    dol_print_error($db);
366
+		}
339 367
 		$langs->load("propal");
340 368
 		print '<tr><td>';
341 369
 		print '<a href="propal.php?id='.$product->id.'">'.img_object('','propal').' '.$langs->trans("Proposals").'</a>';
@@ -353,7 +381,9 @@  discard block
 block discarded – undo
353 381
 	{
354 382
 		$nblines++;
355 383
 		$ret=$product->load_stats_proposal_supplier($socid);
356
-		if ($ret < 0) dol_print_error($db);
384
+		if ($ret < 0) {
385
+		    dol_print_error($db);
386
+		}
357 387
 		$langs->load("propal");
358 388
 		print '<tr><td>';
359 389
 		print '<a href="supplier_proposal.php?id='.$product->id.'">'.img_object('','propal').' '.$langs->trans("SupplierProposals").'</a>';
@@ -371,7 +401,9 @@  discard block
 block discarded – undo
371 401
 	{
372 402
 		$nblines++;
373 403
 		$ret=$product->load_stats_commande($socid);
374
-		if ($ret < 0) dol_print_error($db);
404
+		if ($ret < 0) {
405
+		    dol_print_error($db);
406
+		}
375 407
 		$langs->load("orders");
376 408
 		print '<tr><td>';
377 409
 		print '<a href="commande.php?id='.$product->id.'">'.img_object('','order').' '.$langs->trans("CustomersOrders").'</a>';
@@ -389,7 +421,9 @@  discard block
 block discarded – undo
389 421
 	{
390 422
 		$nblines++;
391 423
 		$ret=$product->load_stats_commande_fournisseur($socid);
392
-		if ($ret < 0) dol_print_error($db);
424
+		if ($ret < 0) {
425
+		    dol_print_error($db);
426
+		}
393 427
 		$langs->load("orders");
394 428
 		print '<tr><td>';
395 429
 		print '<a href="commande_fournisseur.php?id='.$product->id.'">'.img_object('','order').' '.$langs->trans("SuppliersOrders").'</a>';
@@ -407,7 +441,9 @@  discard block
 block discarded – undo
407 441
 	{
408 442
 		$nblines++;
409 443
 		$ret=$product->load_stats_facture($socid);
410
-		if ($ret < 0) dol_print_error($db);
444
+		if ($ret < 0) {
445
+		    dol_print_error($db);
446
+		}
411 447
 		$langs->load("bills");
412 448
 		print '<tr><td>';
413 449
 		print '<a href="facture.php?id='.$product->id.'">'.img_object('','bill').' '.$langs->trans("CustomersInvoices").'</a>';
@@ -425,7 +461,9 @@  discard block
 block discarded – undo
425 461
 	{
426 462
 		$nblines++;
427 463
 		$ret=$product->load_stats_facture_fournisseur($socid);
428
-		if ($ret < 0) dol_print_error($db);
464
+		if ($ret < 0) {
465
+		    dol_print_error($db);
466
+		}
429 467
 		$langs->load("bills");
430 468
 		print '<tr><td>';
431 469
 		print '<a href="facture_fournisseur.php?id='.$product->id.'">'.img_object('','bill').' '.$langs->trans("SuppliersInvoices").'</a>';
@@ -444,7 +482,9 @@  discard block
 block discarded – undo
444 482
 	{
445 483
 		$nblines++;
446 484
 		$ret=$product->load_stats_contrat($socid);
447
-		if ($ret < 0) dol_print_error($db);
485
+		if ($ret < 0) {
486
+		    dol_print_error($db);
487
+		}
448 488
 		$langs->load("contracts");
449 489
 		print '<tr><td>';
450 490
 		print '<a href="contrat.php?id='.$product->id.'">'.img_object('','contract').' '.$langs->trans("Contracts").'</a>';
@@ -483,8 +523,7 @@  discard block
 block discarded – undo
483 523
 		$measuring_units[-6] = $langs->transnoentitiesnoconv("WeightUnitmg");
484 524
 		$measuring_units[98] = $langs->transnoentitiesnoconv("WeightUnitounce");
485 525
 		$measuring_units[99] = $langs->transnoentitiesnoconv("WeightUnitpound");
486
-	}
487
-	else if ($measuring_style == 'size')
526
+	} else if ($measuring_style == 'size')
488 527
 	{
489 528
 		$measuring_units[0] = $langs->transnoentitiesnoconv("SizeUnitm");
490 529
 		$measuring_units[-1] = $langs->transnoentitiesnoconv("SizeUnitdm");
@@ -492,8 +531,7 @@  discard block
 block discarded – undo
492 531
 		$measuring_units[-3] = $langs->transnoentitiesnoconv("SizeUnitmm");
493 532
         $measuring_units[98] = $langs->transnoentitiesnoconv("SizeUnitfoot");
494 533
 		$measuring_units[99] = $langs->transnoentitiesnoconv("SizeUnitinch");
495
-	}
496
-	else if ($measuring_style == 'surface')
534
+	} else if ($measuring_style == 'surface')
497 535
 	{
498 536
 		$measuring_units[0] = $langs->transnoentitiesnoconv("SurfaceUnitm2");
499 537
 		$measuring_units[-2] = $langs->transnoentitiesnoconv("SurfaceUnitdm2");
@@ -501,8 +539,7 @@  discard block
 block discarded – undo
501 539
 		$measuring_units[-6] = $langs->transnoentitiesnoconv("SurfaceUnitmm2");
502 540
         $measuring_units[98] = $langs->transnoentitiesnoconv("SurfaceUnitfoot2");
503 541
 		$measuring_units[99] = $langs->transnoentitiesnoconv("SurfaceUnitinch2");
504
-	}
505
-	else if ($measuring_style == 'volume')
542
+	} else if ($measuring_style == 'volume')
506 543
 	{
507 544
 		$measuring_units[0] = $langs->transnoentitiesnoconv("VolumeUnitm3");
508 545
 		$measuring_units[-3] = $langs->transnoentitiesnoconv("VolumeUnitdm3");
Please login to merge, or discard this patch.
dolibarr/htdocs/core/lib/ecm.lib.php 1 patch
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -84,8 +84,7 @@
 block discarded – undo
84 84
 		$head[$h][1] = $langs->trans("Card");
85 85
 		$head[$h][2] = 'card';
86 86
 		$h++;
87
-	}
88
-	else
87
+	} else
89 88
 	{
90 89
 		$head[$h][0] = DOL_URL_ROOT.'/ecm/dir_card.php?section='.$section.'&module='.$module;
91 90
 		$head[$h][1] = $langs->trans("Card");
Please login to merge, or discard this patch.
dolibarr/htdocs/core/lib/functionsnumtoword.lib.php 1 patch
Braces   +41 added lines, -29 removed lines patch added patch discarded remove patch
@@ -127,9 +127,13 @@  discard block
 block discarded – undo
127 127
 
128 128
 	// If we need to write cents call again this function for cents
129 129
 	if(!empty($TNum[1])) {
130
-		if(!empty($currency)) $concatWords .= ' '.$langs->transnoentities('and');
130
+		if(!empty($currency)) {
131
+		    $concatWords .= ' '.$langs->transnoentities('and');
132
+		}
131 133
 		$concatWords .= ' '.dol_convertToWord($TNum[1], $langs, $currency, true);
132
-		if(!empty($currency)) $concatWords .= ' '.$langs->transnoentities('centimes');
134
+		if(!empty($currency)) {
135
+		    $concatWords .= ' '.$langs->transnoentities('centimes');
136
+		}
133 137
 	}
134 138
     return $concatWords;
135 139
 }
@@ -147,9 +151,12 @@  discard block
 block discarded – undo
147 151
 function dolNumberToWord($numero, $langs, $numorcurrency='number')
148 152
 {
149 153
 	// If the number is negative convert to positive and return -1 if is too long
150
-	if ($numero < 0) $numero *= -1;
151
-	if ($numero >= 1000000000001)
152
-		return -1;
154
+	if ($numero < 0) {
155
+	    $numero *= -1;
156
+	}
157
+	if ($numero >= 1000000000001) {
158
+			return -1;
159
+	}
153 160
 	// Get 2 decimals to cents, another functions round or truncate
154 161
 	$strnumber = number_format ($numero,10);
155 162
 	$len=strlen($strnumber);
@@ -167,17 +174,13 @@  discard block
 block discarded – undo
167 174
 	{
168 175
 		if ($numero>=1 && $numero<2) {
169 176
 			return ("UN PESO ".$parte_decimal." / 100 M.N.");
170
-		}
171
-		elseif ($numero>=0 && $numero<1){
177
+		} elseif ($numero>=0 && $numero<1){
172 178
 			return ("CERO PESOS ".$parte_decimal." / 100 M.N.");
173
-		}
174
-		elseif ($numero>=1000000 && $numero<1000001){
179
+		} elseif ($numero>=1000000 && $numero<1000001){
175 180
 			return ("UN MILL&OacuteN DE PESOS ".$parte_decimal." / 100 M.N.");
176
-		}
177
-		elseif ($numero>=1000000000000 && $numero<1000000000001){
181
+		} elseif ($numero>=1000000000000 && $numero<1000000000001){
178 182
 			return ("UN BILL&OacuteN DE PESOS ".$parte_decimal." / 100 M.N.");
179
-		}
180
-		else {
183
+		} else {
181 184
 			$entexto ="";
182 185
 			$number = $numero;
183 186
 			if ($number >= 1000000000){
@@ -198,10 +201,11 @@  discard block
 block discarded – undo
198 201
 				$udMILLON = (int) ($numero / 1000000);
199 202
 				$numero = $numero - $udMILLON * 1000000;
200 203
 				$entexto .= hundreds2text ($CdMILLON, $DdMILLON, $udMILLON);
201
-				if (!$CdMMillon && !$DdMMillon && !$UdMMillon && !$CdMILLON && !$DdMILLON && $udMILLON==1)
202
-					$entexto .= " MILL&OacuteN ";
203
-				else
204
-					$entexto .= " MILLONES ";
204
+				if (!$CdMMillon && !$DdMMillon && !$UdMMillon && !$CdMILLON && !$DdMILLON && $udMILLON==1) {
205
+									$entexto .= " MILL&OacuteN ";
206
+				} else {
207
+									$entexto .= " MILLONES ";
208
+				}
205 209
 			}
206 210
 			if ($number >= 1000) {
207 211
 				$cdm = (int) ($numero / 100000);
@@ -211,16 +215,18 @@  discard block
 block discarded – undo
211 215
 				$udm = (int) ($numero / 1000);
212 216
 				$numero = $numero - $udm * 1000;
213 217
 				$entexto .= hundreds2text ($cdm, $ddm, $udm);
214
-				if ($cdm || $ddm || $udm)
215
-					$entexto .= " MIL ";
218
+				if ($cdm || $ddm || $udm) {
219
+									$entexto .= " MIL ";
220
+				}
216 221
 			}
217 222
 			$c = (int) ($numero / 100);
218 223
 			$numero = $numero - $c * 100;
219 224
 			$d = (int) ($numero / 10);
220 225
 			$u = (int) $numero - $d * 10;
221 226
 			$entexto .= hundreds2text ($c, $d, $u);
222
-			if (!$cdm && !$ddm && !$udm && !$c && !$d && !$u && $number>1000000)
223
-				$entexto .= " DE";
227
+			if (!$cdm && !$ddm && !$udm && !$c && !$d && !$u && $number>1000000) {
228
+							$entexto .= " DE";
229
+			}
224 230
 			$entexto .= " PESOS ".$parte_decimal." / 100 M.N.";
225 231
 		}
226 232
 		return $entexto;
@@ -250,26 +256,32 @@  discard block
 block discarded – undo
250 256
 		$entexto .= $centenas[$hundreds-1];
251 257
 	}
252 258
 	if ($tens>2){
253
-		if ($hundreds!=0) $entexto .= " ";
259
+		if ($hundreds!=0) {
260
+		    $entexto .= " ";
261
+		}
254 262
 		$entexto .= $decenas[$tens-1];
255 263
 		if ($units!=0){
256 264
 			$entexto .= " Y ";
257 265
 			$entexto .= $unidades[$units-1];
258 266
 		}
259 267
 		return $entexto;
260
-	}
261
-	elseif ($tens==2){
262
-		if ($hundreds!=0) $entexto .= " ";
268
+	} elseif ($tens==2){
269
+		if ($hundreds!=0) {
270
+		    $entexto .= " ";
271
+		}
263 272
 		$entexto .= " ".$veintis[$units];
264 273
 		return $entexto;
265
-	}
266
-	elseif ($tens==1){
267
-		if ($hundreds!=0) $entexto .= " ";
274
+	} elseif ($tens==1){
275
+		if ($hundreds!=0) {
276
+		    $entexto .= " ";
277
+		}
268 278
 		$entexto .= $diecis[$units];
269 279
 		return $entexto;
270 280
 	}
271 281
 	if ($units!=0) {
272
-		if ($hundreds!=0 || $tens!=0) $entexto .= " ";
282
+		if ($hundreds!=0 || $tens!=0) {
283
+		    $entexto .= " ";
284
+		}
273 285
 		$entexto .= $unidades[$units-1];
274 286
 	}
275 287
 	return $entexto;
Please login to merge, or discard this patch.
dolibarr/htdocs/core/lib/files.lib.php 1 patch
Braces   +512 added lines, -266 removed lines patch added patch discarded remove patch
@@ -98,16 +98,21 @@  discard block
 block discarded – undo
98 98
 	// $hookmanager->resArray may contain array stacked by other modules
99 99
 	if (empty($reshook))
100 100
 	{
101
-		if (! is_dir($newpath)) return array();
101
+		if (! is_dir($newpath)) {
102
+		    return array();
103
+		}
102 104
 
103 105
 		if ($dir = opendir($newpath))
104 106
 		{
105 107
 			$filedate='';
106 108
 			$filesize='';
107 109
 
108
-			while (false !== ($file = readdir($dir)))        // $file is always a basename (into directory $newpath)
110
+			while (false !== ($file = readdir($dir))) {
111
+			    // $file is always a basename (into directory $newpath)
109 112
 			{
110
-				if (! utf8_check($file)) $file=utf8_encode($file);	// To be sure data is stored in utf8 in memory
113
+				if (! utf8_check($file)) $file=utf8_encode($file);
114
+			}
115
+			// To be sure data is stored in utf8 in memory
111 116
 				$fullpathfile=($newpath?$newpath.'/':'').$file;
112 117
 
113 118
 				$qualified=1;
@@ -117,8 +122,9 @@  discard block
 block discarded – undo
117 122
 				if (is_array($excludefilter))
118 123
 				{
119 124
 					$excludefilterarray=array_merge($excludefilterarray,$excludefilter);
125
+				} else if ($excludefilter) {
126
+				    $excludefilterarray[]=$excludefilter;
120 127
 				}
121
-				else if ($excludefilter) $excludefilterarray[]=$excludefilter;
122 128
 				// Check if file is qualified
123 129
 				foreach($excludefilterarray as $filt)
124 130
 				{
@@ -137,12 +143,18 @@  discard block
 block discarded – undo
137 143
 						// Add entry into file_list array
138 144
 						if (($types=="directories") || ($types=="all"))
139 145
 						{
140
-							if ($loaddate || $sortcriteria == 'date') $filedate=dol_filemtime($path."/".$file);
141
-							if ($loadsize || $sortcriteria == 'size') $filesize=dol_filesize($path."/".$file);
146
+							if ($loaddate || $sortcriteria == 'date') {
147
+							    $filedate=dol_filemtime($path."/".$file);
148
+							}
149
+							if ($loadsize || $sortcriteria == 'size') {
150
+							    $filesize=dol_filesize($path."/".$file);
151
+							}
142 152
 
143
-							if (! $filter || preg_match('/'.$filter.'/i',$file))	// We do not search key $filter into all $path, only into $file part
153
+							if (! $filter || preg_match('/'.$filter.'/i',$file)) {
154
+							    // We do not search key $filter into all $path, only into $file part
144 155
 							{
145 156
 								preg_match('/([^\/]+)\/[^\/]+$/',$path.'/'.$file,$reg);
157
+							}
146 158
 								$level1name=(isset($reg[1])?$reg[1]:'');
147 159
 								$file_list[] = array(
148 160
 										"name" => $file,
@@ -166,16 +178,21 @@  discard block
 block discarded – undo
166 178
 								$file_list = array_merge($file_list, dol_dir_list($path."/".$file, $types, $recursive, $filter, $excludefilter, $sortcriteria, $sortorder, $mode, $nohook, ($relativename!=''?$relativename.'/':'').$file, $donotfollowsymlinks));
167 179
 							}
168 180
 						}
169
-					}
170
-					else if (! $isdir && (($types == "files") || ($types == "all")))
181
+					} else if (! $isdir && (($types == "files") || ($types == "all")))
171 182
 					{
172 183
 						// Add file into file_list array
173
-						if ($loaddate || $sortcriteria == 'date') $filedate=dol_filemtime($path."/".$file);
174
-						if ($loadsize || $sortcriteria == 'size') $filesize=dol_filesize($path."/".$file);
184
+						if ($loaddate || $sortcriteria == 'date') {
185
+						    $filedate=dol_filemtime($path."/".$file);
186
+						}
187
+						if ($loadsize || $sortcriteria == 'size') {
188
+						    $filesize=dol_filesize($path."/".$file);
189
+						}
175 190
 
176
-						if (! $filter || preg_match('/'.$filter.'/i',$file))	// We do not search key $filter into $path, only into $file
191
+						if (! $filter || preg_match('/'.$filter.'/i',$file)) {
192
+						    // We do not search key $filter into $path, only into $file
177 193
 						{
178 194
 							preg_match('/([^\/]+)\/[^\/]+$/',$path.'/'.$file,$reg);
195
+						}
179 196
 							$level1name=(isset($reg[1])?$reg[1]:'');
180 197
 							$file_list[] = array(
181 198
 									"name" => $file,
@@ -202,12 +219,16 @@  discard block
 block discarded – undo
202 219
 					$myarray[$key] = (isset($row[$sortcriteria])?$row[$sortcriteria]:'');
203 220
 				}
204 221
 				// Sort the data
205
-				if ($sortorder) array_multisort($myarray, $sortorder, $file_list);
222
+				if ($sortorder) {
223
+				    array_multisort($myarray, $sortorder, $file_list);
224
+				}
206 225
 			}
207 226
 		}
208 227
 	}
209 228
 
210
-	if (is_object($hookmanager) && is_array($hookmanager->resArray)) $file_list = array_merge($file_list, $hookmanager->resArray);
229
+	if (is_object($hookmanager) && is_array($hookmanager->resArray)) {
230
+	    $file_list = array_merge($file_list, $hookmanager->resArray);
231
+	}
211 232
 
212 233
 	return $file_list;
213 234
 }
@@ -232,7 +253,9 @@  discard block
 block discarded – undo
232 253
 
233 254
 	$sql =" SELECT rowid, label, entity, filename, filepath, fullpath_orig, keywords, cover, gen_or_uploaded, extraparams, date_c, date_m, fk_user_c, fk_user_m,";
234 255
 	$sql.=" acl, position, share";
235
-	if ($mode) $sql.=", description";
256
+	if ($mode) {
257
+	    $sql.=", description";
258
+	}
236 259
 	$sql.=" FROM ".MAIN_DB_PREFIX."ecm_files";
237 260
 	$sql.=" WHERE filepath = '".$db->escape($path)."'";
238 261
 	$sql.=" AND entity = ".$conf->entity;
@@ -280,12 +303,13 @@  discard block
 block discarded – undo
280 303
 				$myarray[$key] = (isset($row[$sortcriteria])?$row[$sortcriteria]:'');
281 304
 			}
282 305
 			// Sort the data
283
-			if ($sortorder) array_multisort($myarray, $sortorder, $file_list);
306
+			if ($sortorder) {
307
+			    array_multisort($myarray, $sortorder, $file_list);
308
+			}
284 309
 		}
285 310
 
286 311
 		return $file_list;
287
-	}
288
-	else
312
+	} else
289 313
 	{
290 314
 		dol_print_error($db);
291 315
 		return array();
@@ -313,8 +337,11 @@  discard block
 block discarded – undo
313 337
 		global $object;
314 338
 		if (! empty($object->id))
315 339
 		{
316
-			if (! empty($conf->product->enabled)) $upload_dirold = $conf->product->multidir_output[$object->entity].'/'.substr(substr("000".$object->id, -2),1,1).'/'.substr(substr("000".$object->id, -2),0,1).'/'.$object->id."/photos";
317
-			else $upload_dirold = $conf->service->multidir_output[$object->entity].'/'.substr(substr("000".$object->id, -2),1,1).'/'.substr(substr("000".$object->id, -2),0,1).'/'.$object->id."/photos";
340
+			if (! empty($conf->product->enabled)) {
341
+			    $upload_dirold = $conf->product->multidir_output[$object->entity].'/'.substr(substr("000".$object->id, -2),1,1).'/'.substr(substr("000".$object->id, -2),0,1).'/'.$object->id."/photos";
342
+			} else {
343
+			    $upload_dirold = $conf->service->multidir_output[$object->entity].'/'.substr(substr("000".$object->id, -2),1,1).'/'.substr(substr("000".$object->id, -2),0,1).'/'.$object->id."/photos";
344
+			}
318 345
 
319 346
 			$relativedirold = preg_replace('/^'.preg_quote(DOL_DATA_ROOT,'/').'/', '', $upload_dirold);
320 347
 			$relativedirold = preg_replace('/^[\\/]/','',$relativedirold);
@@ -347,16 +374,21 @@  discard block
 block discarded – undo
347 374
 			}
348 375
 		}
349 376
 
350
-		if (! $found)    // This happen in transition toward version 6, or if files were added manually into os dir.
377
+		if (! $found) {
378
+		    // This happen in transition toward version 6, or if files were added manually into os dir.
351 379
 		{
352
-			$filearray[$key]['position']='999999';     // File not indexed are at end. So if we add a file, it will not replace an existing position
380
+			$filearray[$key]['position']='999999';
381
+		}
382
+		// File not indexed are at end. So if we add a file, it will not replace an existing position
353 383
 			$filearray[$key]['cover']=0;
354 384
 			$filearray[$key]['acl']='';
355 385
 
356 386
 			$rel_filename = preg_replace('/^'.preg_quote(DOL_DATA_ROOT,'/').'/', '', $filearray[$key]['fullname']);
357
-			if (! preg_match('/([\\/]temp[\\/]|[\\/]thumbs|\.meta$)/', $rel_filetorenameafter))     // If not a tmp file
387
+			if (! preg_match('/([\\/]temp[\\/]|[\\/]thumbs|\.meta$)/', $rel_filetorenameafter)) {
388
+			    // If not a tmp file
358 389
 			{
359 390
 				dol_syslog("list_of_documents We found a file called '".$filearray[$key]['name']."' not indexed into database. We add it");
391
+			}
360 392
 				include_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmfiles.class.php';
361 393
 				$ecmfile=new EcmFiles($db);
362 394
 
@@ -377,13 +409,11 @@  discard block
 block discarded – undo
377 409
 				if ($result < 0)
378 410
 				{
379 411
 					setEventMessages($ecmfile->error, $ecmfile->errors, 'warnings');
380
-				}
381
-				else
412
+				} else
382 413
 				{
383 414
 					$filearray[$key]['rowid']=$result;
384 415
 				}
385
-			}
386
-			else
416
+			} else
387 417
 			{
388 418
 				$filearray[$key]['rowid']=0;     // Should not happened
389 419
 			}
@@ -408,22 +438,27 @@  discard block
 block discarded – undo
408 438
 
409 439
 	$sortorder=strtoupper($sortorder);
410 440
 
411
-	if ($sortorder == 'ASC') { $retup=-1; $retdown=1; }
412
-	else { $retup=1; $retdown=-1; }
441
+	if ($sortorder == 'ASC') { $retup=-1; $retdown=1; } else { $retup=1; $retdown=-1; }
413 442
 
414 443
 	if ($sortfield == 'name')
415 444
 	{
416
-		if ($a->name == $b->name) return 0;
445
+		if ($a->name == $b->name) {
446
+		    return 0;
447
+		}
417 448
 		return ($a->name < $b->name) ? $retup : $retdown;
418 449
 	}
419 450
 	if ($sortfield == 'date')
420 451
 	{
421
-		if ($a->date == $b->date) return 0;
452
+		if ($a->date == $b->date) {
453
+		    return 0;
454
+		}
422 455
 		return ($a->date < $b->date) ? $retup : $retdown;
423 456
 	}
424 457
 	if ($sortfield == 'size')
425 458
 	{
426
-		if ($a->size == $b->size) return 0;
459
+		if ($a->size == $b->size) {
460
+		    return 0;
461
+		}
427 462
 		return ($a->size < $b->size) ? $retup : $retdown;
428 463
 	}
429 464
 }
@@ -438,9 +473,12 @@  discard block
 block discarded – undo
438 473
 function dol_is_dir($folder)
439 474
 {
440 475
 	$newfolder=dol_osencode($folder);
441
-	if (is_dir($newfolder)) return true;
442
-	else return false;
443
-}
476
+	if (is_dir($newfolder)) {
477
+	    return true;
478
+	} else {
479
+	    return false;
480
+	}
481
+	}
444 482
 
445 483
 /**
446 484
  * Return if path is a file
@@ -477,7 +515,9 @@  discard block
 block discarded – undo
477 515
 	$tmpprot=array('file','http','https','ftp','zlib','data','ssh','ssh2','ogg','expect');
478 516
 	foreach($tmpprot as $prot)
479 517
 	{
480
-		if (preg_match('/^'.$prot.':/i',$url)) return true;
518
+		if (preg_match('/^'.$prot.':/i',$url)) {
519
+		    return true;
520
+		}
481 521
 	}
482 522
 	return false;
483 523
 }
@@ -499,15 +539,21 @@  discard block
 block discarded – undo
499 539
 		{
500 540
 			$name_array[] = $name;
501 541
 		}
502
-		foreach($name_array as $temp) $folder_content .= $temp;
542
+		foreach($name_array as $temp) {
543
+		    $folder_content .= $temp;
544
+		}
503 545
 
504 546
 		closedir($handle);
505 547
 
506
-		if ($folder_content == "...") return true;
507
-		else return false;
548
+		if ($folder_content == "...") {
549
+		    return true;
550
+		} else {
551
+		    return false;
552
+		}
553
+	} else {
554
+		return true;
508 555
 	}
509
-	else
510
-	return true; // Dir does not exists
556
+	// Dir does not exists
511 557
 }
512 558
 
513 559
 /**
@@ -530,11 +576,12 @@  discard block
 block discarded – undo
530 576
 		{
531 577
 			$line=fgets($fp);
532 578
 			// We increase count only if read was success. We need test because feof return true only after fgets so we do n+1 fgets for a file with n lines.
533
-			if (! $line === false) $nb++;
579
+			if (! $line === false) {
580
+			    $nb++;
581
+			}
534 582
 		}
535 583
 		fclose($fp);
536
-	}
537
-	else
584
+	} else
538 585
 	{
539 586
 		$nb=-1;
540 587
 	}
@@ -584,11 +631,17 @@  discard block
 block discarded – undo
584 631
 
585 632
 	dol_syslog("files.lib.php::dolReplaceInFile srcfile=".$srcfile." destfile=".$destfile." newmask=".$newmask." indexdatabase=".$indexdatabase);
586 633
 
587
-	if (empty($srcfile)) return -1;
588
-	if (empty($destfile)) $destfile=$srcfile;
634
+	if (empty($srcfile)) {
635
+	    return -1;
636
+	}
637
+	if (empty($destfile)) {
638
+	    $destfile=$srcfile;
639
+	}
589 640
 
590 641
 	$destexists=dol_is_file($destfile);
591
-	if (($destfile != $srcfile) && $destexists) return 0;
642
+	if (($destfile != $srcfile) && $destexists) {
643
+	    return 0;
644
+	}
592 645
 
593 646
 	$tmpdestfile=$destfile.'.tmp';
594 647
 
@@ -625,10 +678,14 @@  discard block
 block discarded – undo
625 678
 		dol_syslog("files.lib.php::dolReplaceInFile failed to move tmp file to final dest", LOG_WARNING);
626 679
 		return -3;
627 680
 	}
628
-	if (empty($newmask) && ! empty($conf->global->MAIN_UMASK)) $newmask=$conf->global->MAIN_UMASK;
629
-	if (empty($newmask))	// This should no happen
681
+	if (empty($newmask) && ! empty($conf->global->MAIN_UMASK)) {
682
+	    $newmask=$conf->global->MAIN_UMASK;
683
+	}
684
+	if (empty($newmask)) {
685
+	    // This should no happen
630 686
 	{
631 687
 		dol_syslog("Warning: dolReplaceInFile called with empty value for newmask and no default value defined", LOG_WARNING);
688
+	}
632 689
 		$newmask='0664';
633 690
 	}
634 691
 
@@ -669,10 +726,14 @@  discard block
 block discarded – undo
669 726
 
670 727
 	dol_syslog("files.lib.php::dol_copy srcfile=".$srcfile." destfile=".$destfile." newmask=".$newmask." overwriteifexists=".$overwriteifexists);
671 728
 
672
-	if (empty($srcfile) || empty($destfile)) return -1;
729
+	if (empty($srcfile) || empty($destfile)) {
730
+	    return -1;
731
+	}
673 732
 
674 733
 	$destexists=dol_is_file($destfile);
675
-	if (! $overwriteifexists && $destexists) return 0;
734
+	if (! $overwriteifexists && $destexists) {
735
+	    return 0;
736
+	}
676 737
 
677 738
 	$newpathofsrcfile=dol_osencode($srcfile);
678 739
 	$newpathofdestfile=dol_osencode($destfile);
@@ -696,10 +757,14 @@  discard block
 block discarded – undo
696 757
 		dol_syslog("files.lib.php::dol_copy failed to copy", LOG_WARNING);
697 758
 		return -3;
698 759
 	}
699
-	if (empty($newmask) && ! empty($conf->global->MAIN_UMASK)) $newmask=$conf->global->MAIN_UMASK;
700
-	if (empty($newmask))	// This should no happen
760
+	if (empty($newmask) && ! empty($conf->global->MAIN_UMASK)) {
761
+	    $newmask=$conf->global->MAIN_UMASK;
762
+	}
763
+	if (empty($newmask)) {
764
+	    // This should no happen
701 765
 	{
702 766
 		dol_syslog("Warning: dol_copy called with empty value for newmask and no default value defined", LOG_WARNING);
767
+	}
703 768
 		$newmask='0664';
704 769
 	}
705 770
 
@@ -727,7 +792,9 @@  discard block
 block discarded – undo
727 792
 
728 793
 	dol_syslog("files.lib.php::dolCopyDir srcfile=".$srcfile." destfile=".$destfile." newmask=".$newmask." overwriteifexists=".$overwriteifexists);
729 794
 
730
-	if (empty($srcfile) || empty($destfile)) return -1;
795
+	if (empty($srcfile) || empty($destfile)) {
796
+	    return -1;
797
+	}
731 798
 
732 799
 	$destexists=dol_is_dir($destfile);
733 800
 	//if (! $overwriteifexists && $destexists) return 0;	// The overwriteifexists is for files only, so propagated to dol_copy only.
@@ -737,7 +804,9 @@  discard block
 block discarded – undo
737 804
 		// We must set mask just before creating dir, becaause it can be set differently by dol_copy
738 805
 		umask(0);
739 806
 		$dirmaskdec=octdec($newmask);
740
-		if (empty($newmask) && ! empty($conf->global->MAIN_UMASK)) $dirmaskdec=octdec($conf->global->MAIN_UMASK);
807
+		if (empty($newmask) && ! empty($conf->global->MAIN_UMASK)) {
808
+		    $dirmaskdec=octdec($conf->global->MAIN_UMASK);
809
+		}
741 810
 		$dirmaskdec |= octdec('0200');  // Set w bit required to be able to create content for recursive subdirs files
742 811
 		dol_mkdir($destfile, '', decoct($dirmaskdec));
743 812
 	}
@@ -757,8 +826,7 @@  discard block
 block discarded – undo
757 826
 				{
758 827
 					//var_dump("xxx dolCopyDir $srcfile/$file, $destfile/$file, $newmask, $overwriteifexists");
759 828
 					$tmpresult=dolCopyDir($srcfile."/".$file, $destfile."/".$file, $newmask, $overwriteifexists, $arrayreplacement);
760
-				}
761
-				else
829
+				} else
762 830
 				{
763 831
 					$newfile = $file;
764 832
 					// Replace destination filename with a new one
@@ -775,17 +843,17 @@  discard block
 block discarded – undo
775 843
 				if ($result > 0 && $tmpresult >= 0)
776 844
 				{
777 845
 					// Do nothing, so we don't set result to 0 if tmpresult is 0 and result was success in a previous pass
778
-				}
779
-				else
846
+				} else
780 847
 				{
781 848
 					$result=$tmpresult;
782 849
 				}
783
-				if ($result < 0) break;
850
+				if ($result < 0) {
851
+				    break;
852
+				}
784 853
 			}
785 854
 		}
786 855
 		closedir($dir_handle);
787
-	}
788
-	else
856
+	} else
789 857
 	{
790 858
 		// Source directory does not exists
791 859
 		$result = -2;
@@ -852,8 +920,9 @@  discard block
 block discarded – undo
852 920
 				// We force delete and try again. Rename function sometimes fails to replace dest file with some windows NTFS partitions.
853 921
 				dol_delete_file($destfile);
854 922
 				$result=@rename($newpathofsrcfile, $newpathofdestfile); // To see errors, remove @
923
+			} else {
924
+			    dol_syslog("files.lib.php::dol_move Failed.", LOG_WARNING);
855 925
 			}
856
-			else dol_syslog("files.lib.php::dol_move Failed.", LOG_WARNING);
857 926
 		}
858 927
 
859 928
 		// Move ok
@@ -862,9 +931,11 @@  discard block
 block discarded – undo
862 931
 			// Rename entry into ecm database
863 932
 			$rel_filetorenamebefore = preg_replace('/^'.preg_quote(DOL_DATA_ROOT,'/').'/', '', $srcfile);
864 933
 			$rel_filetorenameafter = preg_replace('/^'.preg_quote(DOL_DATA_ROOT,'/').'/', '', $destfile);
865
-			if (! preg_match('/([\\/]temp[\\/]|[\\/]thumbs|\.meta$)/', $rel_filetorenameafter))     // If not a tmp file
934
+			if (! preg_match('/([\\/]temp[\\/]|[\\/]thumbs|\.meta$)/', $rel_filetorenameafter)) {
935
+			    // If not a tmp file
866 936
 			{
867 937
 				$rel_filetorenamebefore = preg_replace('/^[\\/]/', '', $rel_filetorenamebefore);
938
+			}
868 939
 				$rel_filetorenameafter = preg_replace('/^[\\/]/', '', $rel_filetorenameafter);
869 940
 				//var_dump($rel_filetorenamebefore.' - '.$rel_filetorenameafter);
870 941
 
@@ -873,16 +944,20 @@  discard block
 block discarded – undo
873 944
 
874 945
 				$ecmfiletarget=new EcmFiles($db);
875 946
 				$resultecmtarget = $ecmfiletarget->fetch(0, '', $rel_filetorenameafter);
876
-				if ($resultecmtarget > 0)   // An entry for target name already exists for target, we delete it, a new one will be created.
947
+				if ($resultecmtarget > 0) {
948
+				    // An entry for target name already exists for target, we delete it, a new one will be created.
877 949
 				{
878 950
 					$ecmfiletarget->delete($user);
879 951
 				}
952
+				}
880 953
 
881 954
 				$ecmfile=new EcmFiles($db);
882 955
 				$resultecm = $ecmfile->fetch(0, '', $rel_filetorenamebefore);
883
-				if ($resultecm > 0)   // If an entry was found for src file, we use it to move entry
956
+				if ($resultecm > 0) {
957
+				    // If an entry was found for src file, we use it to move entry
884 958
 				{
885 959
 					$filename = basename($rel_filetorenameafter);
960
+				}
886 961
 					$rel_dir = dirname($rel_filetorenameafter);
887 962
 					$rel_dir = preg_replace('/[\\/]$/', '', $rel_dir);
888 963
 					$rel_dir = preg_replace('/^[\\/]/', '', $rel_dir);
@@ -890,10 +965,11 @@  discard block
 block discarded – undo
890 965
 					$ecmfile->filepath = $rel_dir;
891 966
 					$ecmfile->filename = $filename;
892 967
 					$resultecm = $ecmfile->update($user);
893
-				}
894
-				elseif ($resultecm == 0)   // If no entry were found for src files, create/update target file
968
+				} elseif ($resultecm == 0) {
969
+				    // If no entry were found for src files, create/update target file
895 970
 				{
896 971
 					$filename = basename($rel_filetorenameafter);
972
+				}
897 973
 					$rel_dir = dirname($rel_filetorenameafter);
898 974
 					$rel_dir = preg_replace('/[\\/]$/', '', $rel_dir);
899 975
 					$rel_dir = preg_replace('/^[\\/]/', '', $rel_dir);
@@ -910,18 +986,22 @@  discard block
 block discarded – undo
910 986
 					{
911 987
 						setEventMessages($ecmfile->error, $ecmfile->errors, 'warnings');
912 988
 					}
913
-				}
914
-				elseif ($resultecm < 0)
989
+				} elseif ($resultecm < 0)
915 990
 				{
916 991
 					setEventMessages($ecmfile->error, $ecmfile->errors, 'warnings');
917 992
 				}
918 993
 
919
-				if ($resultecm > 0) $result=true;
920
-				else $result = false;
994
+				if ($resultecm > 0) {
995
+				    $result=true;
996
+				} else {
997
+				    $result = false;
998
+				}
921 999
 			}
922 1000
 		}
923 1001
 
924
-		if (empty($newmask)) $newmask=empty($conf->global->MAIN_UMASK)?'0755':$conf->global->MAIN_UMASK;
1002
+		if (empty($newmask)) {
1003
+		    $newmask=empty($conf->global->MAIN_UMASK)?'0755':$conf->global->MAIN_UMASK;
1004
+		}
925 1005
 		$newmaskdec=octdec($newmask);
926 1006
 		// Currently method is restricted to files (dol_delete_files previously used is for files, and mask usage if for files too)
927 1007
 		// to allow mask usage for dir, we shoul introduce a new param "isdir" to 1 to complete newmask like this
@@ -965,9 +1045,11 @@  discard block
 block discarded – undo
965 1045
 		}
966 1046
 		$antivir=new AntiVir($db);
967 1047
 		$result = $antivir->dol_avscan_file($src_file);
968
-		if ($result < 0)	// If virus or error, we stop here
1048
+		if ($result < 0) {
1049
+		    // If virus or error, we stop here
969 1050
 		{
970 1051
 			$reterrors=$antivir->errors;
1052
+		}
971 1053
 			return $reterrors;
972 1054
 		}
973 1055
 	}
@@ -1075,13 +1157,17 @@  discard block
 block discarded – undo
1075 1157
 		}
1076 1158
 	}
1077 1159
 
1078
-	if ($reshook < 0)	// At least one blocking error returned by one hook
1160
+	if ($reshook < 0) {
1161
+	    // At least one blocking error returned by one hook
1079 1162
 	{
1080 1163
 		$errmsg = join(',', $hookmanager->errors);
1081
-		if (empty($errmsg)) $errmsg = 'ErrorReturnedBySomeHooks';	// Should not occurs. Added if hook is bugged and does not set ->errors when there is error.
1082
-		return $errmsg;
1083 1164
 	}
1084
-	elseif (empty($reshook))
1165
+		if (empty($errmsg)) {
1166
+		    $errmsg = 'ErrorReturnedBySomeHooks';
1167
+		}
1168
+		// Should not occurs. Added if hook is bugged and does not set ->errors when there is error.
1169
+		return $errmsg;
1170
+	} elseif (empty($reshook))
1085 1171
 	{
1086 1172
 		// The file functions must be in OS filesystem encoding.
1087 1173
 		$src_file_osencoded=dol_osencode($src_file);
@@ -1108,11 +1194,12 @@  discard block
 block discarded – undo
1108 1194
 		$return=move_uploaded_file($src_file_osencoded, $file_name_osencoded);
1109 1195
 		if ($return)
1110 1196
 		{
1111
-			if (! empty($conf->global->MAIN_UMASK)) @chmod($file_name_osencoded, octdec($conf->global->MAIN_UMASK));
1197
+			if (! empty($conf->global->MAIN_UMASK)) {
1198
+			    @chmod($file_name_osencoded, octdec($conf->global->MAIN_UMASK));
1199
+			}
1112 1200
 			dol_syslog("Files.lib::dol_move_uploaded_file Success to move ".$src_file." to ".$file_name." - Umask=".$conf->global->MAIN_UMASK, LOG_DEBUG);
1113 1201
 			return 1;	// Success
1114
-		}
1115
-		else
1202
+		} else
1116 1203
 		{
1117 1204
 			dol_syslog("Files.lib::dol_move_uploaded_file Failed to move ".$src_file." to ".$file_name, LOG_ERR);
1118 1205
 			return -3;	// Unknown error
@@ -1167,12 +1254,13 @@  discard block
 block discarded – undo
1167 1254
 		$reshook=$hookmanager->executeHooks('deleteFile', $parameters, $object);
1168 1255
 	}
1169 1256
 
1170
-	if (empty($nohook) && $reshook != 0) // reshook = 0 to do standard actions, 1 = ok, -1 = ko
1257
+	if (empty($nohook) && $reshook != 0) {
1258
+	    // reshook = 0 to do standard actions, 1 = ok, -1 = ko
1171 1259
 	{
1172 1260
 		if ($reshook < 0) return false;
1173
-		return true;
1174 1261
 	}
1175
-	else
1262
+		return true;
1263
+	} else
1176 1264
 	{
1177 1265
 		$error=0;
1178 1266
 
@@ -1188,21 +1276,28 @@  discard block
 block discarded – undo
1188 1276
 			{
1189 1277
 				foreach ($listofdir as $filename)
1190 1278
 				{
1191
-					if ($nophperrors) $ok=@unlink($filename);
1192
-					else $ok=unlink($filename);
1279
+					if ($nophperrors) {
1280
+					    $ok=@unlink($filename);
1281
+					} else {
1282
+					    $ok=unlink($filename);
1283
+					}
1193 1284
 					if ($ok)
1194 1285
 					{
1195 1286
 						dol_syslog("Removed file ".$filename, LOG_DEBUG);
1196 1287
 
1197 1288
 						// Delete entry into ecm database
1198 1289
 						$rel_filetodelete = preg_replace('/^'.preg_quote(DOL_DATA_ROOT,'/').'/', '', $filename);
1199
-						if (! preg_match('/(\/temp\/|\/thumbs\/|\.meta$)/', $rel_filetodelete))     // If not a tmp file
1290
+						if (! preg_match('/(\/temp\/|\/thumbs\/|\.meta$)/', $rel_filetodelete)) {
1291
+						    // If not a tmp file
1200 1292
 						{
1201 1293
 							$rel_filetodelete = preg_replace('/^[\\/]/', '', $rel_filetodelete);
1294
+						}
1202 1295
 
1203
-							if (is_object($db) && $indexdatabase)		// $db may not be defined when lib is in a context with define('NOREQUIREDB',1)
1296
+							if (is_object($db) && $indexdatabase) {
1297
+							    // $db may not be defined when lib is in a context with define('NOREQUIREDB',1)
1204 1298
 							{
1205 1299
 								dol_syslog("Try to remove also entries in database for full relative path = ".$rel_filetodelete, LOG_DEBUG);
1300
+							}
1206 1301
 								include_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmfiles.class.php';
1207 1302
 								$ecmfile=new EcmFiles($db);
1208 1303
 								$result = $ecmfile->fetch(0, '', $rel_filetodelete);
@@ -1216,21 +1311,28 @@  discard block
 block discarded – undo
1216 1311
 								}
1217 1312
 							}
1218 1313
 						}
1314
+					} else {
1315
+					    dol_syslog("Failed to remove file ".$filename, LOG_WARNING);
1219 1316
 					}
1220
-					else dol_syslog("Failed to remove file ".$filename, LOG_WARNING);
1221 1317
 					// TODO Failure to remove can be because file was already removed or because of permission
1222 1318
 					// If error because it does not exists, we should return true, and we should return false if this is a permission problem
1223 1319
 				}
1320
+			} else {
1321
+			    dol_syslog("No files to delete found", LOG_DEBUG);
1224 1322
 			}
1225
-			else dol_syslog("No files to delete found", LOG_DEBUG);
1226
-		}
1227
-		else
1323
+		} else
1228 1324
 		{
1229 1325
 			$ok=false;
1230
-			if ($nophperrors) $ok=@unlink($file_osencoded);
1231
-			else $ok=unlink($file_osencoded);
1232
-			if ($ok) dol_syslog("Removed file ".$file_osencoded, LOG_DEBUG);
1233
-			else dol_syslog("Failed to remove file ".$file_osencoded, LOG_WARNING);
1326
+			if ($nophperrors) {
1327
+			    $ok=@unlink($file_osencoded);
1328
+			} else {
1329
+			    $ok=unlink($file_osencoded);
1330
+			}
1331
+			if ($ok) {
1332
+			    dol_syslog("Removed file ".$file_osencoded, LOG_DEBUG);
1333
+			} else {
1334
+			    dol_syslog("Failed to remove file ".$file_osencoded, LOG_WARNING);
1335
+			}
1234 1336
 		}
1235 1337
 
1236 1338
 		return $ok;
@@ -1280,19 +1382,23 @@  discard block
 block discarded – undo
1280 1382
 		{
1281 1383
 			while (false !== ($item = readdir($handle)))
1282 1384
 			{
1283
-				if (! utf8_check($item)) $item=utf8_encode($item);  // should be useless
1385
+				if (! utf8_check($item)) {
1386
+				    $item=utf8_encode($item);
1387
+				}
1388
+				// should be useless
1284 1389
 
1285 1390
 				if ($item != "." && $item != "..")
1286 1391
 				{
1287 1392
 					if (is_dir(dol_osencode("$dir/$item")) && ! is_link(dol_osencode("$dir/$item")))
1288 1393
 					{
1289 1394
 						$count=dol_delete_dir_recursive("$dir/$item", $count, $nophperrors, 0, $countdeleted);
1290
-					}
1291
-					else
1395
+					} else
1292 1396
 					{
1293 1397
 						$result=dol_delete_file("$dir/$item", 1, $nophperrors);
1294 1398
 						$count++;
1295
-						if ($result) $countdeleted++;
1399
+						if ($result) {
1400
+						    $countdeleted++;
1401
+						}
1296 1402
 						//else print 'Error on '.$item."\n";
1297 1403
 					}
1298 1404
 				}
@@ -1303,7 +1409,9 @@  discard block
 block discarded – undo
1303 1409
 			{
1304 1410
 				$result=dol_delete_dir($dir, $nophperrors);
1305 1411
 				$count++;
1306
-				if ($result) $countdeleted++;
1412
+				if ($result) {
1413
+				    $countdeleted++;
1414
+				}
1307 1415
 				//else print 'Error on '.$dir."\n";
1308 1416
 			}
1309 1417
 		}
@@ -1328,15 +1436,25 @@  discard block
 block discarded – undo
1328 1436
 	// Define parent dir of elements
1329 1437
 	$element = $object->element;
1330 1438
 
1331
-	if ($object->element == 'order_supplier')		$dir = $conf->fournisseur->commande->dir_output;
1332
-	elseif ($object->element == 'invoice_supplier')	$dir = $conf->fournisseur->facture->dir_output;
1333
-	elseif ($object->element == 'project')			$dir = $conf->projet->dir_output;
1334
-	elseif ($object->element == 'shipping')			$dir = $conf->expedition->dir_output.'/sending';
1335
-	elseif ($object->element == 'delivery')			$dir = $conf->expedition->dir_output.'/receipt';
1336
-	elseif ($object->element == 'fichinter')		$dir = $conf->ficheinter->dir_output;
1337
-	else $dir=empty($conf->$element->dir_output)?'':$conf->$element->dir_output;
1439
+	if ($object->element == 'order_supplier') {
1440
+	    $dir = $conf->fournisseur->commande->dir_output;
1441
+	} elseif ($object->element == 'invoice_supplier') {
1442
+	    $dir = $conf->fournisseur->facture->dir_output;
1443
+	} elseif ($object->element == 'project') {
1444
+	    $dir = $conf->projet->dir_output;
1445
+	} elseif ($object->element == 'shipping') {
1446
+	    $dir = $conf->expedition->dir_output.'/sending';
1447
+	} elseif ($object->element == 'delivery') {
1448
+	    $dir = $conf->expedition->dir_output.'/receipt';
1449
+	} elseif ($object->element == 'fichinter') {
1450
+	    $dir = $conf->ficheinter->dir_output;
1451
+	} else {
1452
+	    $dir=empty($conf->$element->dir_output)?'':$conf->$element->dir_output;
1453
+	}
1338 1454
 
1339
-	if (empty($dir)) return 'ErrorObjectNoSupportedByFunction';
1455
+	if (empty($dir)) {
1456
+	    return 'ErrorObjectNoSupportedByFunction';
1457
+	}
1340 1458
 
1341 1459
 	$refsan = dol_sanitizeFileName($object->ref);
1342 1460
 	$dir = $dir . "/" . $refsan ;
@@ -1369,8 +1487,7 @@  discard block
 block discarded – undo
1369 1487
 			$object->error=$langs->trans("ErrorFailedToDeleteFile",$filepreviewold);
1370 1488
 			return 0;
1371 1489
 		}
1372
-	}
1373
-	else
1490
+	} else
1374 1491
 	{
1375 1492
 		$multiple = $filepreviewold . ".";
1376 1493
 		for ($i = 0; $i < 20; $i++)
@@ -1404,18 +1521,29 @@  discard block
 block discarded – undo
1404 1521
 	global $conf;
1405 1522
 
1406 1523
 	// Create meta file
1407
-	if (empty($conf->global->MAIN_DOC_CREATE_METAFILE)) return 0;	// By default, no metafile.
1524
+	if (empty($conf->global->MAIN_DOC_CREATE_METAFILE)) {
1525
+	    return 0;
1526
+	}
1527
+	// By default, no metafile.
1408 1528
 
1409 1529
 	// Define parent dir of elements
1410 1530
 	$element=$object->element;
1411 1531
 
1412
-	if ($object->element == 'order_supplier')		$dir = $conf->fournisseur->dir_output.'/commande';
1413
-	elseif ($object->element == 'invoice_supplier')	$dir = $conf->fournisseur->dir_output.'/facture';
1414
-	elseif ($object->element == 'project')			$dir = $conf->projet->dir_output;
1415
-	elseif ($object->element == 'shipping')			$dir = $conf->expedition->dir_output.'/sending';
1416
-	elseif ($object->element == 'delivery')			$dir = $conf->expedition->dir_output.'/receipt';
1417
-	elseif ($object->element == 'fichinter')		$dir = $conf->ficheinter->dir_output;
1418
-	else $dir=empty($conf->$element->dir_output)?'':$conf->$element->dir_output;
1532
+	if ($object->element == 'order_supplier') {
1533
+	    $dir = $conf->fournisseur->dir_output.'/commande';
1534
+	} elseif ($object->element == 'invoice_supplier') {
1535
+	    $dir = $conf->fournisseur->dir_output.'/facture';
1536
+	} elseif ($object->element == 'project') {
1537
+	    $dir = $conf->projet->dir_output;
1538
+	} elseif ($object->element == 'shipping') {
1539
+	    $dir = $conf->expedition->dir_output.'/sending';
1540
+	} elseif ($object->element == 'delivery') {
1541
+	    $dir = $conf->expedition->dir_output.'/receipt';
1542
+	} elseif ($object->element == 'fichinter') {
1543
+	    $dir = $conf->ficheinter->dir_output;
1544
+	} else {
1545
+	    $dir=empty($conf->$element->dir_output)?'':$conf->$element->dir_output;
1546
+	}
1419 1547
 
1420 1548
 	if ($dir)
1421 1549
 	{
@@ -1455,12 +1583,12 @@  discard block
 block discarded – undo
1455 1583
 		$fp = fopen($file,"w");
1456 1584
 		fputs($fp,$meta);
1457 1585
 		fclose($fp);
1458
-		if (! empty($conf->global->MAIN_UMASK))
1459
-		@chmod($file, octdec($conf->global->MAIN_UMASK));
1586
+		if (! empty($conf->global->MAIN_UMASK)) {
1587
+				@chmod($file, octdec($conf->global->MAIN_UMASK));
1588
+		}
1460 1589
 
1461 1590
 		return 1;
1462
-	}
1463
-	else
1591
+	} else
1464 1592
 	{
1465 1593
 		dol_syslog('FailedToDetectDirInDolMetaCreateFor'.$object->element, LOG_WARNING);
1466 1594
 	}
@@ -1522,9 +1650,11 @@  discard block
 block discarded – undo
1522 1650
 
1523 1651
 	$res = 0;
1524 1652
 
1525
-	if (! empty($_FILES[$varfiles])) // For view $_FILES[$varfiles]['error']
1653
+	if (! empty($_FILES[$varfiles])) {
1654
+	    // For view $_FILES[$varfiles]['error']
1526 1655
 	{
1527 1656
 		dol_syslog('dol_add_file_process upload_dir='.$upload_dir.' allowoverwrite='.$allowoverwrite.' donotupdatesession='.$donotupdatesession.' savingdocmask='.$savingdocmask, LOG_DEBUG);
1657
+	}
1528 1658
 		if (dol_mkdir($upload_dir) >= 0)
1529 1659
 		{
1530 1660
 			$TFile = $_FILES[$varfiles];
@@ -1558,9 +1688,11 @@  discard block
 block discarded – undo
1558 1688
 
1559 1689
 				$resupload = dol_move_uploaded_file($TFile['tmp_name'][$i], $destfull, $allowoverwrite, 0, $TFile['error'][$i], 0, $varfiles);
1560 1690
 
1561
-				if (is_numeric($resupload) && $resupload > 0)   // $resupload can be 'ErrorFileAlreadyExists'
1691
+				if (is_numeric($resupload) && $resupload > 0) {
1692
+				    // $resupload can be 'ErrorFileAlreadyExists'
1562 1693
 				{
1563 1694
 					global $maxwidthsmall, $maxheightsmall, $maxwidthmini, $maxheightmini;
1695
+				}
1564 1696
 
1565 1697
 					include_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php';
1566 1698
 
@@ -1600,19 +1732,20 @@  discard block
 block discarded – undo
1600 1732
 					}
1601 1733
 
1602 1734
 					$nbok++;
1603
-				}
1604
-				else
1735
+				} else
1605 1736
 				{
1606 1737
 					$langs->load("errors");
1607
-					if ($resupload < 0)	// Unknown error
1738
+					if ($resupload < 0) {
1739
+					    // Unknown error
1608 1740
 					{
1609 1741
 						setEventMessages($langs->trans("ErrorFileNotUploaded"), null, 'errors');
1610 1742
 					}
1611
-					else if (preg_match('/ErrorFileIsInfectedWithAVirus/',$resupload))	// Files infected by a virus
1743
+					} else if (preg_match('/ErrorFileIsInfectedWithAVirus/',$resupload)) {
1744
+					    // Files infected by a virus
1612 1745
 					{
1613 1746
 						setEventMessages($langs->trans("ErrorFileIsInfectedWithAVirus"), null, 'errors');
1614 1747
 					}
1615
-					else	// Known error
1748
+					} else	// Known error
1616 1749
 					{
1617 1750
 						setEventMessages($langs->trans($resupload), null, 'errors');
1618 1751
 					}
@@ -1639,8 +1772,7 @@  discard block
 block discarded – undo
1639 1772
 		} else {
1640 1773
 			setEventMessages($langs->trans("ErrorFileNotLinked"), null, 'errors');
1641 1774
 		}
1642
-	}
1643
-	else
1775
+	} else
1644 1776
 	{
1645 1777
 		$langs->load("errors");
1646 1778
 		setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("File")), null, 'errors');
@@ -1671,16 +1803,27 @@  discard block
 block discarded – undo
1671 1803
 	$listofnames=array();
1672 1804
 	$listofmimes=array();
1673 1805
 	$keytoavoidconflict = empty($trackid)?'':'-'.$trackid;
1674
-	if (! empty($_SESSION["listofpaths".$keytoavoidconflict])) $listofpaths=explode(';',$_SESSION["listofpaths".$keytoavoidconflict]);
1675
-	if (! empty($_SESSION["listofnames".$keytoavoidconflict])) $listofnames=explode(';',$_SESSION["listofnames".$keytoavoidconflict]);
1676
-	if (! empty($_SESSION["listofmimes".$keytoavoidconflict])) $listofmimes=explode(';',$_SESSION["listofmimes".$keytoavoidconflict]);
1806
+	if (! empty($_SESSION["listofpaths".$keytoavoidconflict])) {
1807
+	    $listofpaths=explode(';',$_SESSION["listofpaths".$keytoavoidconflict]);
1808
+	}
1809
+	if (! empty($_SESSION["listofnames".$keytoavoidconflict])) {
1810
+	    $listofnames=explode(';',$_SESSION["listofnames".$keytoavoidconflict]);
1811
+	}
1812
+	if (! empty($_SESSION["listofmimes".$keytoavoidconflict])) {
1813
+	    $listofmimes=explode(';',$_SESSION["listofmimes".$keytoavoidconflict]);
1814
+	}
1677 1815
 
1678 1816
 	if ($keytodelete >= 0)
1679 1817
 	{
1680 1818
 		$pathtodelete=$listofpaths[$keytodelete];
1681 1819
 		$filetodelete=$listofnames[$keytodelete];
1682
-		if (empty($donotdeletefile)) $result = dol_delete_file($pathtodelete,1);  // The delete of ecm database is inside the function dol_delete_file
1683
-		else $result=0;
1820
+		if (empty($donotdeletefile)) {
1821
+		    $result = dol_delete_file($pathtodelete,1);
1822
+		}
1823
+		// The delete of ecm database is inside the function dol_delete_file
1824
+		else {
1825
+		    $result=0;
1826
+		}
1684 1827
 		if ($result >= 0)
1685 1828
 		{
1686 1829
 			if (empty($donotdeletefile))
@@ -1720,9 +1863,11 @@  discard block
 block discarded – undo
1720 1863
 
1721 1864
 	$rel_dir = preg_replace('/^'.preg_quote(DOL_DATA_ROOT,'/').'/', '', $dir);
1722 1865
 
1723
-	if (! preg_match('/[\\/]temp[\\/]|[\\/]thumbs|\.meta$/', $rel_dir))     // If not a tmp dir
1866
+	if (! preg_match('/[\\/]temp[\\/]|[\\/]thumbs|\.meta$/', $rel_dir)) {
1867
+	    // If not a tmp dir
1724 1868
 	{
1725 1869
 		$filename = basename($file);
1870
+	}
1726 1871
 		$rel_dir = preg_replace('/[\\/]$/', '', $rel_dir);
1727 1872
 		$rel_dir = preg_replace('/^[\\/]/', '', $rel_dir);
1728 1873
 
@@ -1785,8 +1930,12 @@  discard block
 block discarded – undo
1785 1930
 		$sql = 'DELETE FROM ' . MAIN_DB_PREFIX . 'ecm_files';
1786 1931
 		$sql.= ' WHERE entity = '.$conf->entity;
1787 1932
 		$sql.= " AND filepath = '" . $db->escape($rel_dir) . "'";
1788
-		if ($file) $sql.= " AND filename = '" . $db->escape($file) . "'";
1789
-		if ($mode) $sql.= " AND gen_or_uploaded = '" . $db->escape($mode) . "'";
1933
+		if ($file) {
1934
+		    $sql.= " AND filename = '" . $db->escape($file) . "'";
1935
+		}
1936
+		if ($mode) {
1937
+		    $sql.= " AND gen_or_uploaded = '" . $db->escape($mode) . "'";
1938
+		}
1790 1939
 
1791 1940
 		$resql = $db->query($sql);
1792 1941
 		if (!$resql)
@@ -1834,32 +1983,33 @@  discard block
 block discarded – undo
1834 1983
 			$ret = $image->setImageFormat($ext);
1835 1984
 			if ($ret)
1836 1985
 			{
1837
-				if (empty($fileoutput)) $fileoutput=$fileinput.".".$ext;
1986
+				if (empty($fileoutput)) {
1987
+				    $fileoutput=$fileinput.".".$ext;
1988
+				}
1838 1989
 
1839 1990
 				$count = $image->getNumberImages();
1840 1991
 
1841 1992
 				if (! dol_is_file($fileoutput) || is_writeable($fileoutput))
1842 1993
 				{
1843 1994
 					$ret = $image->writeImages($fileoutput, true);
1844
-				}
1845
-				else
1995
+				} else
1846 1996
 				{
1847 1997
 					dol_syslog("Warning: Failed to write cache preview file '.$fileoutput.'. Check permission on file/dir", LOG_ERR);
1848 1998
 				}
1849
-				if ($ret) return $count;
1850
-				else return -3;
1851
-			}
1852
-			else
1999
+				if ($ret) {
2000
+				    return $count;
2001
+				} else {
2002
+				    return -3;
2003
+				}
2004
+			} else
1853 2005
 			{
1854 2006
 				return -2;
1855 2007
 			}
1856
-		}
1857
-		else
2008
+		} else
1858 2009
 		{
1859 2010
 			return -1;
1860 2011
 		}
1861
-	}
1862
-	else
2012
+	} else
1863 2013
 	{
1864 2014
 		return 0;
1865 2015
 	}
@@ -1881,9 +2031,7 @@  discard block
 block discarded – undo
1881 2031
 	try
1882 2032
 	{
1883 2033
 		$data = implode("", file(dol_osencode($inputfile)));
1884
-		if ($mode == 'gz')     { $foundhandler=1; $compressdata = gzencode($data, 9); }
1885
-		elseif ($mode == 'bz') { $foundhandler=1; $compressdata = bzcompress($data, 9); }
1886
-		elseif ($mode == 'zip')
2034
+		if ($mode == 'gz')     { $foundhandler=1; $compressdata = gzencode($data, 9); } elseif ($mode == 'bz') { $foundhandler=1; $compressdata = bzcompress($data, 9); } elseif ($mode == 'zip')
1887 2035
 		{
1888 2036
 			if (defined('ODTPHP_PATHTOPCLZIP'))
1889 2037
 			{
@@ -1903,14 +2051,12 @@  discard block
 block discarded – undo
1903 2051
 			fwrite($fp, $compressdata);
1904 2052
 			fclose($fp);
1905 2053
 			return 1;
1906
-		}
1907
-		else
2054
+		} else
1908 2055
 		{
1909 2056
 			dol_syslog("Try to zip with format ".$mode." with no handler for this format",LOG_ERR);
1910 2057
 			return -2;
1911 2058
 		}
1912
-	}
1913
-	catch (Exception $e)
2059
+	} catch (Exception $e)
1914 2060
 	{
1915 2061
 		global $langs, $errormsg;
1916 2062
 		$langs->load("errors");
@@ -1938,8 +2084,9 @@  discard block
 block discarded – undo
1938 2084
 		$archive = new PclZip($inputfile);
1939 2085
 		$result=$archive->extract(PCLZIP_OPT_PATH, $outputdir);
1940 2086
 		//var_dump($result);
1941
-		if (! is_array($result) && $result <= 0) return array('error'=>$archive->errorInfo(true));
1942
-		else
2087
+		if (! is_array($result) && $result <= 0) {
2088
+		    return array('error'=>$archive->errorInfo(true));
2089
+		} else
1943 2090
 		{
1944 2091
 			$ok=1; $errmsg='';
1945 2092
 			// Loop on each file to check result for unzipping file
@@ -1954,8 +2101,11 @@  discard block
 block discarded – undo
1954 2101
 				}
1955 2102
 			}
1956 2103
 
1957
-			if ($ok) return array();
1958
-			else return array('error'=>$errmsg);
2104
+			if ($ok) {
2105
+			    return array();
2106
+			} else {
2107
+			    return array('error'=>$errmsg);
2108
+			}
1959 2109
 		}
1960 2110
 	}
1961 2111
 
@@ -1969,8 +2119,7 @@  discard block
 block discarded – undo
1969 2119
 			$zip->extractTo($outputdir.'/');
1970 2120
 			$zip->close();
1971 2121
 			return array();
1972
-		}
1973
-		else
2122
+		} else
1974 2123
 		{
1975 2124
 			return array('error'=>'ErrUnzipFails');
1976 2125
 		}
@@ -2004,9 +2153,7 @@  discard block
 block discarded – undo
2004 2153
 
2005 2154
 	try
2006 2155
 	{
2007
-		if ($mode == 'gz')     { $foundhandler=0; }
2008
-		elseif ($mode == 'bz') { $foundhandler=0; }
2009
-		elseif ($mode == 'zip')
2156
+		if ($mode == 'gz')     { $foundhandler=0; } elseif ($mode == 'bz') { $foundhandler=0; } elseif ($mode == 'zip')
2010 2157
 		{
2011 2158
 			/*if (defined('ODTPHP_PATHTOPCLZIP'))
2012 2159
             {
@@ -2059,13 +2206,11 @@  discard block
 block discarded – undo
2059 2206
 		{
2060 2207
 			dol_syslog("Try to zip with format ".$mode." with no handler for this format",LOG_ERR);
2061 2208
 			return -2;
2062
-		}
2063
-		else
2209
+		} else
2064 2210
 		{
2065 2211
 			return 0;
2066 2212
 		}
2067
-	}
2068
-	catch (Exception $e)
2213
+	} catch (Exception $e)
2069 2214
 	{
2070 2215
 		global $langs, $errormsg;
2071 2216
 		$langs->load("errors");
@@ -2111,16 +2256,25 @@  discard block
 block discarded – undo
2111 2256
 	global $conf, $db, $user;
2112 2257
 	global $dolibarr_main_data_root, $dolibarr_main_document_root_alt;
2113 2258
 
2114
-	if (! is_object($fuser)) $fuser=$user;
2259
+	if (! is_object($fuser)) {
2260
+	    $fuser=$user;
2261
+	}
2115 2262
 
2116
-	if (empty($modulepart)) return 'ErrorBadParameter';
2263
+	if (empty($modulepart)) {
2264
+	    return 'ErrorBadParameter';
2265
+	}
2117 2266
 	if (empty($entity))
2118 2267
 	{
2119
-		if (empty($conf->multicompany->enabled)) $entity=1;
2120
-		else $entity=0;
2268
+		if (empty($conf->multicompany->enabled)) {
2269
+		    $entity=1;
2270
+		} else {
2271
+		    $entity=0;
2272
+		}
2121 2273
 	}
2122 2274
 	// Fix modulepart
2123
-	if ($modulepart == 'users') $modulepart='user';
2275
+	if ($modulepart == 'users') {
2276
+	    $modulepart='user';
2277
+	}
2124 2278
 
2125 2279
 	dol_syslog('modulepart='.$modulepart.' original_file='.$original_file.' entity='.$entity);
2126 2280
 	// We define $accessallowed and $sqlprotectagainstexternals
@@ -2129,7 +2283,9 @@  discard block
 block discarded – undo
2129 2283
 	$ret=array();
2130 2284
 
2131 2285
 	// Find the subdirectory name as the reference. For exemple original_file='10/myfile.pdf' -> refname='10'
2132
-	if (empty($refname)) $refname=basename(dirname($original_file)."/");
2286
+	if (empty($refname)) {
2287
+	    $refname=basename(dirname($original_file)."/");
2288
+	}
2133 2289
 
2134 2290
 	$relative_original_file = $original_file;
2135 2291
 
@@ -2143,7 +2299,9 @@  discard block
 block discarded – undo
2143 2299
 	// Wrapping for miscellaneous medias files
2144 2300
 	if ($modulepart == 'medias' && !empty($dolibarr_main_data_root))
2145 2301
 	{
2146
-		if (empty($entity) || empty($conf->medias->multidir_output[$entity])) return array('accessallowed'=>0, 'error'=>'Value entity must be provided');
2302
+		if (empty($entity) || empty($conf->medias->multidir_output[$entity])) {
2303
+		    return array('accessallowed'=>0, 'error'=>'Value entity must be provided');
2304
+		}
2147 2305
 		$accessallowed=1;
2148 2306
 		$original_file=$conf->medias->multidir_output[$entity].'/'.$original_file;
2149 2307
 	}
@@ -2184,132 +2342,176 @@  discard block
 block discarded – undo
2184 2342
 	// Wrapping pour les apercu factures
2185 2343
 	elseif ($modulepart == 'apercufacture' && !empty($conf->facture->dir_output))
2186 2344
 	{
2187
-		if ($fuser->rights->facture->{$lire}) $accessallowed=1;
2345
+		if ($fuser->rights->facture->{$lire}) {
2346
+		    $accessallowed=1;
2347
+		}
2188 2348
 		$original_file=$conf->facture->dir_output.'/'.$original_file;
2189 2349
 	}
2190 2350
 	// Wrapping pour les apercu propal
2191 2351
 	elseif ($modulepart == 'apercupropal' && !empty($conf->propal->multidir_output[$entity]))
2192 2352
 	{
2193
-		if ($fuser->rights->propale->{$lire}) $accessallowed=1;
2353
+		if ($fuser->rights->propale->{$lire}) {
2354
+		    $accessallowed=1;
2355
+		}
2194 2356
 		$original_file=$conf->propal->multidir_output[$entity].'/'.$original_file;
2195 2357
 	}
2196 2358
 	// Wrapping pour les apercu commande
2197 2359
 	elseif ($modulepart == 'apercucommande' && !empty($conf->commande->dir_output))
2198 2360
 	{
2199
-		if ($fuser->rights->commande->{$lire}) $accessallowed=1;
2361
+		if ($fuser->rights->commande->{$lire}) {
2362
+		    $accessallowed=1;
2363
+		}
2200 2364
 		$original_file=$conf->commande->dir_output.'/'.$original_file;
2201 2365
 	}
2202 2366
 	// Wrapping pour les apercu intervention
2203 2367
 	elseif (($modulepart == 'apercufichinter' || $modulepart == 'apercuficheinter') && !empty($conf->ficheinter->dir_output))
2204 2368
 	{
2205
-		if ($fuser->rights->ficheinter->{$lire}) $accessallowed=1;
2369
+		if ($fuser->rights->ficheinter->{$lire}) {
2370
+		    $accessallowed=1;
2371
+		}
2206 2372
 		$original_file=$conf->ficheinter->dir_output.'/'.$original_file;
2207 2373
 	}
2208 2374
 	// Wrapping pour les apercu conat
2209 2375
 	elseif (($modulepart == 'apercucontract') && !empty($conf->contrat->dir_output))
2210 2376
 	{
2211
-		if ($fuser->rights->contrat->{$lire}) $accessallowed=1;
2377
+		if ($fuser->rights->contrat->{$lire}) {
2378
+		    $accessallowed=1;
2379
+		}
2212 2380
 		$original_file=$conf->contrat->dir_output.'/'.$original_file;
2213 2381
 	}
2214 2382
 	// Wrapping pour les apercu supplier proposal
2215 2383
 	elseif (($modulepart == 'apercusupplier_proposal' || $modulepart == 'apercusupplier_proposal') && !empty($conf->supplier_proposal->dir_output))
2216 2384
 	{
2217
-		if ($fuser->rights->supplier_proposal->{$lire}) $accessallowed=1;
2385
+		if ($fuser->rights->supplier_proposal->{$lire}) {
2386
+		    $accessallowed=1;
2387
+		}
2218 2388
 		$original_file=$conf->supplier_proposal->dir_output.'/'.$original_file;
2219 2389
 	}
2220 2390
 	// Wrapping pour les apercu supplier order
2221 2391
 	elseif (($modulepart == 'apercusupplier_order' || $modulepart == 'apercusupplier_order') && !empty($conf->fournisseur->commande->dir_output))
2222 2392
 	{
2223
-		if ($fuser->rights->fournisseur->commande->{$lire}) $accessallowed=1;
2393
+		if ($fuser->rights->fournisseur->commande->{$lire}) {
2394
+		    $accessallowed=1;
2395
+		}
2224 2396
 		$original_file=$conf->fournisseur->commande->dir_output.'/'.$original_file;
2225 2397
 	}
2226 2398
 	// Wrapping pour les apercu supplier invoice
2227 2399
 	elseif (($modulepart == 'apercusupplier_invoice' || $modulepart == 'apercusupplier_invoice') && !empty($conf->fournisseur->facture->dir_output))
2228 2400
 	{
2229
-		if ($fuser->rights->fournisseur->facture->{$lire}) $accessallowed=1;
2401
+		if ($fuser->rights->fournisseur->facture->{$lire}) {
2402
+		    $accessallowed=1;
2403
+		}
2230 2404
 		$original_file=$conf->fournisseur->facture->dir_output.'/'.$original_file;
2231 2405
 	}
2232 2406
 	// Wrapping pour les apercu supplier invoice
2233 2407
 	elseif (($modulepart == 'apercuexpensereport') && !empty($conf->expensereport->dir_output))
2234 2408
 	{
2235
-		if ($fuser->rights->expensereport->{$lire}) $accessallowed=1;
2409
+		if ($fuser->rights->expensereport->{$lire}) {
2410
+		    $accessallowed=1;
2411
+		}
2236 2412
 		$original_file=$conf->expensereport->dir_output.'/'.$original_file;
2237 2413
 	}
2238 2414
 	// Wrapping pour les images des stats propales
2239 2415
 	elseif ($modulepart == 'propalstats' && !empty($conf->propal->multidir_temp[$entity]))
2240 2416
 	{
2241
-		if ($fuser->rights->propale->{$lire}) $accessallowed=1;
2417
+		if ($fuser->rights->propale->{$lire}) {
2418
+		    $accessallowed=1;
2419
+		}
2242 2420
 		$original_file=$conf->propal->multidir_temp[$entity].'/'.$original_file;
2243 2421
 	}
2244 2422
 	// Wrapping pour les images des stats commandes
2245 2423
 	elseif ($modulepart == 'orderstats' && !empty($conf->commande->dir_temp))
2246 2424
 	{
2247
-		if ($fuser->rights->commande->{$lire}) $accessallowed=1;
2425
+		if ($fuser->rights->commande->{$lire}) {
2426
+		    $accessallowed=1;
2427
+		}
2248 2428
 		$original_file=$conf->commande->dir_temp.'/'.$original_file;
2249
-	}
2250
-	elseif ($modulepart == 'orderstatssupplier' && !empty($conf->fournisseur->dir_output))
2429
+	} elseif ($modulepart == 'orderstatssupplier' && !empty($conf->fournisseur->dir_output))
2251 2430
 	{
2252
-		if ($fuser->rights->fournisseur->commande->{$lire}) $accessallowed=1;
2431
+		if ($fuser->rights->fournisseur->commande->{$lire}) {
2432
+		    $accessallowed=1;
2433
+		}
2253 2434
 		$original_file=$conf->fournisseur->commande->dir_temp.'/'.$original_file;
2254 2435
 	}
2255 2436
 	// Wrapping pour les images des stats factures
2256 2437
 	elseif ($modulepart == 'billstats' && !empty($conf->facture->dir_temp))
2257 2438
 	{
2258
-		if ($fuser->rights->facture->{$lire}) $accessallowed=1;
2439
+		if ($fuser->rights->facture->{$lire}) {
2440
+		    $accessallowed=1;
2441
+		}
2259 2442
 		$original_file=$conf->facture->dir_temp.'/'.$original_file;
2260
-	}
2261
-	elseif ($modulepart == 'billstatssupplier' && !empty($conf->fournisseur->dir_output))
2443
+	} elseif ($modulepart == 'billstatssupplier' && !empty($conf->fournisseur->dir_output))
2262 2444
 	{
2263
-		if ($fuser->rights->fournisseur->facture->{$lire}) $accessallowed=1;
2445
+		if ($fuser->rights->fournisseur->facture->{$lire}) {
2446
+		    $accessallowed=1;
2447
+		}
2264 2448
 		$original_file=$conf->fournisseur->facture->dir_temp.'/'.$original_file;
2265 2449
 	}
2266 2450
 	// Wrapping pour les images des stats expeditions
2267 2451
 	elseif ($modulepart == 'expeditionstats' && !empty($conf->expedition->dir_temp))
2268 2452
 	{
2269
-		if ($fuser->rights->expedition->{$lire}) $accessallowed=1;
2453
+		if ($fuser->rights->expedition->{$lire}) {
2454
+		    $accessallowed=1;
2455
+		}
2270 2456
 		$original_file=$conf->expedition->dir_temp.'/'.$original_file;
2271 2457
 	}
2272 2458
 	// Wrapping pour les images des stats expeditions
2273 2459
 	elseif ($modulepart == 'tripsexpensesstats' && !empty($conf->deplacement->dir_temp))
2274 2460
 	{
2275
-		if ($fuser->rights->deplacement->{$lire}) $accessallowed=1;
2461
+		if ($fuser->rights->deplacement->{$lire}) {
2462
+		    $accessallowed=1;
2463
+		}
2276 2464
 		$original_file=$conf->deplacement->dir_temp.'/'.$original_file;
2277 2465
 	}
2278 2466
 	// Wrapping pour les images des stats expeditions
2279 2467
 	elseif ($modulepart == 'memberstats' && !empty($conf->adherent->dir_temp))
2280 2468
 	{
2281
-		if ($fuser->rights->adherent->{$lire}) $accessallowed=1;
2469
+		if ($fuser->rights->adherent->{$lire}) {
2470
+		    $accessallowed=1;
2471
+		}
2282 2472
 		$original_file=$conf->adherent->dir_temp.'/'.$original_file;
2283 2473
 	}
2284 2474
 	// Wrapping pour les images des stats produits
2285 2475
 	elseif (preg_match('/^productstats_/i',$modulepart) && !empty($conf->product->dir_temp))
2286 2476
 	{
2287
-		if ($fuser->rights->produit->{$lire} || $fuser->rights->service->{$lire}) $accessallowed=1;
2477
+		if ($fuser->rights->produit->{$lire} || $fuser->rights->service->{$lire}) {
2478
+		    $accessallowed=1;
2479
+		}
2288 2480
 		$original_file=(!empty($conf->product->multidir_temp[$entity])?$conf->product->multidir_temp[$entity]:$conf->service->multidir_temp[$entity]).'/'.$original_file;
2289 2481
 	}
2290 2482
 	// Wrapping for taxes
2291 2483
 	elseif ($modulepart == 'tax' && !empty($conf->tax->dir_output))
2292 2484
 	{
2293
-		if ($fuser->rights->tax->charges->{$lire}) $accessallowed=1;
2485
+		if ($fuser->rights->tax->charges->{$lire}) {
2486
+		    $accessallowed=1;
2487
+		}
2294 2488
 		$original_file=$conf->tax->dir_output.'/'.$original_file;
2295 2489
 	}
2296 2490
 	// Wrapping for events
2297 2491
 	elseif ($modulepart == 'actions' && !empty($conf->agenda->dir_output))
2298 2492
 	{
2299
-		if ($fuser->rights->agenda->myactions->{$read}) $accessallowed=1;
2493
+		if ($fuser->rights->agenda->myactions->{$read}) {
2494
+		    $accessallowed=1;
2495
+		}
2300 2496
 		$original_file=$conf->agenda->dir_output.'/'.$original_file;
2301 2497
 	}
2302 2498
 	// Wrapping for categories
2303 2499
 	elseif ($modulepart == 'category' && !empty($conf->categorie->dir_output))
2304 2500
 	{
2305
-		if (empty($entity) || empty($conf->categorie->multidir_output[$entity])) return array('accessallowed'=>0, 'error'=>'Value entity must be provided');
2306
-		if ($fuser->rights->categorie->{$lire}) $accessallowed=1;
2501
+		if (empty($entity) || empty($conf->categorie->multidir_output[$entity])) {
2502
+		    return array('accessallowed'=>0, 'error'=>'Value entity must be provided');
2503
+		}
2504
+		if ($fuser->rights->categorie->{$lire}) {
2505
+		    $accessallowed=1;
2506
+		}
2307 2507
 		$original_file=$conf->categorie->multidir_output[$entity].'/'.$original_file;
2308 2508
 	}
2309 2509
 	// Wrapping pour les prelevements
2310 2510
 	elseif ($modulepart == 'prelevement' && !empty($conf->prelevement->dir_output))
2311 2511
 	{
2312
-		if ($fuser->rights->prelevement->bons->{$lire} || preg_match('/^specimen/i',$original_file)) $accessallowed=1;
2512
+		if ($fuser->rights->prelevement->bons->{$lire} || preg_match('/^specimen/i',$original_file)) {
2513
+		    $accessallowed=1;
2514
+		}
2313 2515
 		$original_file=$conf->prelevement->dir_output.'/'.$original_file;
2314 2516
 	}
2315 2517
 	// Wrapping pour les graph energie
@@ -2372,7 +2574,9 @@  discard block
 block discarded – undo
2372 2574
 	// Wrapping for third parties
2373 2575
 	else if (($modulepart == 'company' || $modulepart == 'societe') && !empty($conf->societe->dir_output))
2374 2576
 	{
2375
-		if (empty($entity) || empty($conf->societe->multidir_output[$entity])) return array('accessallowed'=>0, 'error'=>'Value entity must be provided');
2577
+		if (empty($entity) || empty($conf->societe->multidir_output[$entity])) {
2578
+		    return array('accessallowed'=>0, 'error'=>'Value entity must be provided');
2579
+		}
2376 2580
 		if ($fuser->rights->societe->{$lire} || preg_match('/^specimen/i',$original_file))
2377 2581
 		{
2378 2582
 			$accessallowed=1;
@@ -2384,7 +2588,9 @@  discard block
 block discarded – undo
2384 2588
 	// Wrapping for contact
2385 2589
 	else if ($modulepart == 'contact' && !empty($conf->societe->dir_output))
2386 2590
 	{
2387
-		if (empty($entity) || empty($conf->societe->multidir_output[$entity])) return array('accessallowed'=>0, 'error'=>'Value entity must be provided');
2591
+		if (empty($entity) || empty($conf->societe->multidir_output[$entity])) {
2592
+		    return array('accessallowed'=>0, 'error'=>'Value entity must be provided');
2593
+		}
2388 2594
 		if ($fuser->rights->societe->{$lire})
2389 2595
 		{
2390 2596
 			$accessallowed=1;
@@ -2410,64 +2616,56 @@  discard block
 block discarded – undo
2410 2616
 			$accessallowed=1;
2411 2617
 		}
2412 2618
 		$original_file=$conf->propal->multidir_output[$entity].'/temp/massgeneration/'.$user->id.'/'.$original_file;
2413
-	}
2414
-	else if ($modulepart == 'massfilesarea_orders')
2619
+	} else if ($modulepart == 'massfilesarea_orders')
2415 2620
 	{
2416 2621
 		if ($fuser->rights->commande->{$lire} || preg_match('/^specimen/i',$original_file))
2417 2622
 		{
2418 2623
 			$accessallowed=1;
2419 2624
 		}
2420 2625
 		$original_file=$conf->commande->dir_output.'/temp/massgeneration/'.$user->id.'/'.$original_file;
2421
-	}
2422
-	else if ($modulepart == 'massfilesarea_invoices')
2626
+	} else if ($modulepart == 'massfilesarea_invoices')
2423 2627
 	{
2424 2628
 		if ($fuser->rights->facture->{$lire} || preg_match('/^specimen/i',$original_file))
2425 2629
 		{
2426 2630
 			$accessallowed=1;
2427 2631
 		}
2428 2632
 		$original_file=$conf->facture->dir_output.'/temp/massgeneration/'.$user->id.'/'.$original_file;
2429
-	}
2430
-	else if ($modulepart == 'massfilesarea_expensereport')
2633
+	} else if ($modulepart == 'massfilesarea_expensereport')
2431 2634
 	{
2432 2635
 		if ($fuser->rights->facture->{$lire} || preg_match('/^specimen/i',$original_file))
2433 2636
 		{
2434 2637
 			$accessallowed=1;
2435 2638
 		}
2436 2639
 		$original_file=$conf->expensereport->dir_output.'/temp/massgeneration/'.$user->id.'/'.$original_file;
2437
-	}
2438
-	else if ($modulepart == 'massfilesarea_interventions')
2640
+	} else if ($modulepart == 'massfilesarea_interventions')
2439 2641
 	{
2440 2642
 		if ($fuser->rights->ficheinter->{$lire} || preg_match('/^specimen/i',$original_file))
2441 2643
 		{
2442 2644
 			$accessallowed=1;
2443 2645
 		}
2444 2646
 		$original_file=$conf->ficheinter->dir_output.'/temp/massgeneration/'.$user->id.'/'.$original_file;
2445
-	}
2446
-	else if ($modulepart == 'massfilesarea_supplier_proposal' && !empty($conf->supplier_proposal->dir_output))
2647
+	} else if ($modulepart == 'massfilesarea_supplier_proposal' && !empty($conf->supplier_proposal->dir_output))
2447 2648
 	{
2448 2649
 		if ($fuser->rights->supplier_proposal->{$lire} || preg_match('/^specimen/i',$original_file))
2449 2650
 		{
2450 2651
 			$accessallowed=1;
2451 2652
 		}
2452 2653
 		$original_file=$conf->supplier_proposal->dir_output.'/temp/massgeneration/'.$user->id.'/'.$original_file;
2453
-	}
2454
-	else if ($modulepart == 'massfilesarea_supplier_order')
2654
+	} else if ($modulepart == 'massfilesarea_supplier_order')
2455 2655
 	{
2456 2656
 		if ($fuser->rights->fournisseur->commande->{$lire} || preg_match('/^specimen/i',$original_file))
2457 2657
 		{
2458 2658
 			$accessallowed=1;
2459 2659
 		}
2460 2660
 		$original_file=$conf->fournisseur->commande->dir_output.'/temp/massgeneration/'.$user->id.'/'.$original_file;
2461
-	}
2462
-	else if ($modulepart == 'massfilesarea_supplier_invoice')
2661
+	} else if ($modulepart == 'massfilesarea_supplier_invoice')
2463 2662
 	{
2464 2663
 		if ($fuser->rights->fournisseur->facture->{$lire} || preg_match('/^specimen/i',$original_file))
2465 2664
 		{
2466 2665
 			$accessallowed=1;
2467 2666
 		}
2468 2667
 		$original_file=$conf->fournisseur->facture->dir_output.'/temp/massgeneration/'.$user->id.'/'.$original_file;
2469
-	}
2470
-	else if ($modulepart == 'massfilesarea_contract' && !empty($conf->contrat->dir_output))
2668
+	} else if ($modulepart == 'massfilesarea_contract' && !empty($conf->contrat->dir_output))
2471 2669
 	{
2472 2670
 		if ($fuser->rights->contrat->{$lire} || preg_match('/^specimen/i',$original_file))
2473 2671
 		{
@@ -2528,8 +2726,7 @@  discard block
 block discarded – undo
2528 2726
 		}
2529 2727
 		$original_file=$conf->projet->dir_output.'/'.$original_file;
2530 2728
 		$sqlprotectagainstexternals = "SELECT fk_soc as fk_soc FROM ".MAIN_DB_PREFIX."projet WHERE ref='".$db->escape($refname)."' AND entity IN (".getEntity('project').")";
2531
-	}
2532
-	else if ($modulepart == 'project_task' && !empty($conf->projet->dir_output))
2729
+	} else if ($modulepart == 'project_task' && !empty($conf->projet->dir_output))
2533 2730
 	{
2534 2731
 		if ($fuser->rights->projet->{$lire} || preg_match('/^specimen/i',$original_file))
2535 2732
 		{
@@ -2578,8 +2775,11 @@  discard block
 block discarded – undo
2578 2775
 		{
2579 2776
 			$accessallowed=1;
2580 2777
 		}
2581
-		if ($fuser->societe_id > 0) $original_file=$conf->facture->dir_output.'/payments/private/'.$fuser->id.'/'.$original_file;
2582
-		else $original_file=$conf->facture->dir_output.'/payments/'.$original_file;
2778
+		if ($fuser->societe_id > 0) {
2779
+		    $original_file=$conf->facture->dir_output.'/payments/private/'.$fuser->id.'/'.$original_file;
2780
+		} else {
2781
+		    $original_file=$conf->facture->dir_output.'/payments/'.$original_file;
2782
+		}
2583 2783
 	}
2584 2784
 
2585 2785
 	// Wrapping for accounting exports
@@ -2634,24 +2834,33 @@  discard block
 block discarded – undo
2634 2834
 	// Wrapping pour les produits et services
2635 2835
 	else if ($modulepart == 'product' || $modulepart == 'produit' || $modulepart == 'service' || $modulepart == 'produit|service')
2636 2836
 	{
2637
-		if (empty($entity) || (empty($conf->product->multidir_output[$entity]) && empty($conf->service->multidir_output[$entity]))) return array('accessallowed'=>0, 'error'=>'Value entity must be provided');
2837
+		if (empty($entity) || (empty($conf->product->multidir_output[$entity]) && empty($conf->service->multidir_output[$entity]))) {
2838
+		    return array('accessallowed'=>0, 'error'=>'Value entity must be provided');
2839
+		}
2638 2840
 		if (($fuser->rights->produit->{$lire} || $fuser->rights->service->{$lire}) || preg_match('/^specimen/i',$original_file))
2639 2841
 		{
2640 2842
 			$accessallowed=1;
2641 2843
 		}
2642
-		if (! empty($conf->product->enabled)) $original_file=$conf->product->multidir_output[$entity].'/'.$original_file;
2643
-		elseif (! empty($conf->service->enabled)) $original_file=$conf->service->multidir_output[$entity].'/'.$original_file;
2844
+		if (! empty($conf->product->enabled)) {
2845
+		    $original_file=$conf->product->multidir_output[$entity].'/'.$original_file;
2846
+		} elseif (! empty($conf->service->enabled)) {
2847
+		    $original_file=$conf->service->multidir_output[$entity].'/'.$original_file;
2848
+		}
2644 2849
 	}
2645 2850
 
2646 2851
 	// Wrapping pour les lots produits
2647 2852
 	else if ($modulepart == 'product_batch' || $modulepart == 'produitlot')
2648 2853
 	{
2649
-		if (empty($entity) || (empty($conf->productbatch->multidir_output[$entity]))) return array('accessallowed'=>0, 'error'=>'Value entity must be provided');
2854
+		if (empty($entity) || (empty($conf->productbatch->multidir_output[$entity]))) {
2855
+		    return array('accessallowed'=>0, 'error'=>'Value entity must be provided');
2856
+		}
2650 2857
 		if (($fuser->rights->produit->{$lire} ) || preg_match('/^specimen/i',$original_file))
2651 2858
 		{
2652 2859
 			$accessallowed=1;
2653 2860
 		}
2654
-		if (! empty($conf->productbatch->enabled)) $original_file=$conf->productbatch->multidir_output[$entity].'/'.$original_file;
2861
+		if (! empty($conf->productbatch->enabled)) {
2862
+		    $original_file=$conf->productbatch->multidir_output[$entity].'/'.$original_file;
2863
+		}
2655 2864
 	}
2656 2865
 
2657 2866
 	// Wrapping pour les contrats
@@ -2732,14 +2941,18 @@  discard block
 block discarded – undo
2732 2941
 	// Wrapping for backups
2733 2942
 	else if ($modulepart == 'systemtools' && !empty($conf->admin->dir_output))
2734 2943
 	{
2735
-		if ($fuser->admin) $accessallowed=1;
2944
+		if ($fuser->admin) {
2945
+		    $accessallowed=1;
2946
+		}
2736 2947
 		$original_file=$conf->admin->dir_output.'/'.$original_file;
2737 2948
 	}
2738 2949
 
2739 2950
 	// Wrapping for upload file test
2740 2951
 	else if ($modulepart == 'admin_temp' && !empty($conf->admin->dir_temp))
2741 2952
 	{
2742
-		if ($fuser->admin) $accessallowed=1;
2953
+		if ($fuser->admin) {
2954
+		    $accessallowed=1;
2955
+		}
2743 2956
 		$original_file=$conf->admin->dir_temp.'/'.$original_file;
2744 2957
 	}
2745 2958
 
@@ -2748,7 +2961,9 @@  discard block
 block discarded – undo
2748 2961
 	{
2749 2962
 		$accessallowed=1;
2750 2963
 		$dir='files';
2751
-		if (dol_mimetype($original_file) == 'application/x-bittorrent') $dir='torrents';
2964
+		if (dol_mimetype($original_file) == 'application/x-bittorrent') {
2965
+		    $dir='torrents';
2966
+		}
2752 2967
 		$original_file=$conf->bittorrent->dir_output.'/'.$dir.'/'.$original_file;
2753 2968
 	}
2754 2969
 
@@ -2776,45 +2991,62 @@  discard block
 block discarded – undo
2776 2991
 	// If modulepart=module				Allows any module to open a file if file is in directory called DOL_DATA_ROOT/modulepart
2777 2992
 	else
2778 2993
 	{
2779
-		if (preg_match('/^specimen/i',$original_file))	$accessallowed=1;    // If link to a file called specimen. Test must be done before changing $original_file int full path.
2780
-		if ($fuser->admin) $accessallowed=1;    // If user is admin
2994
+		if (preg_match('/^specimen/i',$original_file)) {
2995
+		    $accessallowed=1;
2996
+		}
2997
+		// If link to a file called specimen. Test must be done before changing $original_file int full path.
2998
+		if ($fuser->admin) {
2999
+		    $accessallowed=1;
3000
+		}
3001
+		// If user is admin
2781 3002
 
2782 3003
 		// Define $accessallowed
2783 3004
 		if (preg_match('/^([a-z]+)_user_temp$/i',$modulepart,$reg))
2784 3005
 		{
2785
-			if (empty($conf->{$reg[1]}->dir_temp))	// modulepart not supported
3006
+			if (empty($conf->{$reg[1]}->dir_temp)) {
3007
+			    // modulepart not supported
2786 3008
 			{
2787 3009
 				dol_print_error('','Error call dol_check_secure_access_document with not supported value for modulepart parameter ('.$modulepart.')');
3010
+			}
2788 3011
 				exit;
2789 3012
 			}
2790
-			if ($fuser->rights->{$reg[1]}->{$lire} || $fuser->rights->{$reg[1]}->{$read} || ($fuser->rights->{$reg[1]}->{$download})) $accessallowed=1;
3013
+			if ($fuser->rights->{$reg[1]}->{$lire} || $fuser->rights->{$reg[1]}->{$read} || ($fuser->rights->{$reg[1]}->{$download})) {
3014
+			    $accessallowed=1;
3015
+			}
2791 3016
 			$original_file=$conf->{$reg[1]}->dir_temp.'/'.$fuser->id.'/'.$original_file;
2792
-		}
2793
-		else if (preg_match('/^([a-z]+)_temp$/i',$modulepart,$reg))
3017
+		} else if (preg_match('/^([a-z]+)_temp$/i',$modulepart,$reg))
2794 3018
 		{
2795
-			if (empty($conf->{$reg[1]}->dir_temp))	// modulepart not supported
3019
+			if (empty($conf->{$reg[1]}->dir_temp)) {
3020
+			    // modulepart not supported
2796 3021
 			{
2797 3022
 				dol_print_error('','Error call dol_check_secure_access_document with not supported value for modulepart parameter ('.$modulepart.')');
3023
+			}
2798 3024
 				exit;
2799 3025
 			}
2800
-			if ($fuser->rights->{$reg[1]}->{$lire} || $fuser->rights->{$reg[1]}->{$read} || ($fuser->rights->{$reg[1]}->{$download})) $accessallowed=1;
3026
+			if ($fuser->rights->{$reg[1]}->{$lire} || $fuser->rights->{$reg[1]}->{$read} || ($fuser->rights->{$reg[1]}->{$download})) {
3027
+			    $accessallowed=1;
3028
+			}
2801 3029
 			$original_file=$conf->{$reg[1]}->dir_temp.'/'.$original_file;
2802
-		}
2803
-		else if (preg_match('/^([a-z]+)_user$/i',$modulepart,$reg))
3030
+		} else if (preg_match('/^([a-z]+)_user$/i',$modulepart,$reg))
2804 3031
 		{
2805
-			if (empty($conf->{$reg[1]}->dir_output))	// modulepart not supported
3032
+			if (empty($conf->{$reg[1]}->dir_output)) {
3033
+			    // modulepart not supported
2806 3034
 			{
2807 3035
 				dol_print_error('','Error call dol_check_secure_access_document with not supported value for modulepart parameter ('.$modulepart.')');
3036
+			}
2808 3037
 				exit;
2809 3038
 			}
2810
-			if ($fuser->rights->{$reg[1]}->{$lire} || $fuser->rights->{$reg[1]}->{$read} || ($fuser->rights->{$reg[1]}->{$download})) $accessallowed=1;
3039
+			if ($fuser->rights->{$reg[1]}->{$lire} || $fuser->rights->{$reg[1]}->{$read} || ($fuser->rights->{$reg[1]}->{$download})) {
3040
+			    $accessallowed=1;
3041
+			}
2811 3042
 			$original_file=$conf->{$reg[1]}->dir_output.'/'.$fuser->id.'/'.$original_file;
2812
-		}
2813
-		else if (preg_match('/^massfilesarea_([a-z]+)$/i', $modulepart, $reg))
3043
+		} else if (preg_match('/^massfilesarea_([a-z]+)$/i', $modulepart, $reg))
2814 3044
 		{
2815
-			if (empty($conf->{$reg[1]}->dir_output))	// modulepart not supported
3045
+			if (empty($conf->{$reg[1]}->dir_output)) {
3046
+			    // modulepart not supported
2816 3047
 			{
2817 3048
 				dol_print_error('','Error call dol_check_secure_access_document with not supported value for modulepart parameter ('.$modulepart.')');
3049
+			}
2818 3050
 				exit;
2819 3051
 			}
2820 3052
 			if ($fuser->rights->{$reg[1]}->{$lire} || preg_match('/^specimen/i', $original_file))
@@ -2822,12 +3054,13 @@  discard block
 block discarded – undo
2822 3054
 				$accessallowed=1;
2823 3055
 			}
2824 3056
 			$original_file=$conf->{$reg[1]}->dir_output.'/temp/massgeneration/'.$user->id.'/'.$original_file;
2825
-		}
2826
-		else
3057
+		} else
2827 3058
 		{
2828
-			if (empty($conf->$modulepart->dir_output))	// modulepart not supported
3059
+			if (empty($conf->$modulepart->dir_output)) {
3060
+			    // modulepart not supported
2829 3061
 			{
2830 3062
 				dol_print_error('','Error call dol_check_secure_access_document with not supported value for modulepart parameter ('.$modulepart.')');
3063
+			}
2831 3064
 				exit;
2832 3065
 			}
2833 3066
 
@@ -2835,12 +3068,15 @@  discard block
 block discarded – undo
2835 3068
 			$subperm=GETPOST('subperm');
2836 3069
 			if ($perm || $subperm)
2837 3070
 			{
2838
-				if (($perm && ! $subperm && $fuser->rights->$modulepart->$perm) || ($perm && $subperm && $fuser->rights->$modulepart->$perm->$subperm)) $accessallowed=1;
3071
+				if (($perm && ! $subperm && $fuser->rights->$modulepart->$perm) || ($perm && $subperm && $fuser->rights->$modulepart->$perm->$subperm)) {
3072
+				    $accessallowed=1;
3073
+				}
2839 3074
 				$original_file=$conf->$modulepart->dir_output.'/'.$original_file;
2840
-			}
2841
-			else
3075
+			} else
2842 3076
 			{
2843
-				if ($fuser->rights->$modulepart->{$lire} || $fuser->rights->$modulepart->{$read}) $accessallowed=1;
3077
+				if ($fuser->rights->$modulepart->{$lire} || $fuser->rights->$modulepart->{$read}) {
3078
+				    $accessallowed=1;
3079
+				}
2844 3080
 				$original_file=$conf->$modulepart->dir_output.'/'.$original_file;
2845 3081
 			}
2846 3082
 		}
@@ -2858,11 +3094,13 @@  discard block
 block discarded – undo
2858 3094
 
2859 3095
 		// Define $sqlprotectagainstexternals for modules who want to protect access using a SQL query.
2860 3096
 		$sqlProtectConstName = strtoupper($modulepart).'_SQLPROTECTAGAINSTEXTERNALS_FOR_DOCUMENTS';
2861
-		if (! empty($conf->global->$sqlProtectConstName))	// If module want to define its own $sqlprotectagainstexternals
3097
+		if (! empty($conf->global->$sqlProtectConstName)) {
3098
+		    // If module want to define its own $sqlprotectagainstexternals
2862 3099
 		{
2863 3100
 			// Example: mymodule__SQLPROTECTAGAINSTEXTERNALS_FOR_DOCUMENTS = "SELECT fk_soc FROM ".MAIN_DB_PREFIX.$modulepart." WHERE ref='".$db->escape($refname)."' AND entity=".$conf->entity;
2864 3101
 			eval('$sqlprotectagainstexternals = "'.$conf->global->$sqlProtectConstName.'";');
2865 3102
 		}
3103
+		}
2866 3104
 	}
2867 3105
 
2868 3106
 	$ret = array(
@@ -2884,7 +3122,9 @@  discard block
 block discarded – undo
2884 3122
  */
2885 3123
 function dol_filecache($directory, $filename, $object)
2886 3124
 {
2887
-	if (! dol_is_dir($directory)) dol_mkdir($directory);
3125
+	if (! dol_is_dir($directory)) {
3126
+	    dol_mkdir($directory);
3127
+	}
2888 3128
 	$cachefile = $directory . $filename;
2889 3129
 	file_put_contents($cachefile, serialize($object), LOCK_EX);
2890 3130
 	@chmod($cachefile, 0644);
@@ -2938,9 +3178,11 @@  discard block
 block discarded – undo
2938 3178
 
2939 3179
 	$exclude = 'install';
2940 3180
 
2941
-	foreach ($dir->md5file as $file)    // $file is a simpleXMLElement
3181
+	foreach ($dir->md5file as $file) {
3182
+	    // $file is a simpleXMLElement
2942 3183
 	{
2943 3184
 		$filename = $path.$file['name'];
3185
+	}
2944 3186
 		$file_list['insignature'][] = $filename;
2945 3187
 		$expectedmd5 = (string) $file;
2946 3188
 
@@ -2949,27 +3191,31 @@  discard block
 block discarded – undo
2949 3191
 		if (!file_exists($pathref.'/'.$filename))
2950 3192
 		{
2951 3193
 			$file_list['missing'][] = array('filename'=>$filename, 'expectedmd5'=>$expectedmd5);
2952
-		}
2953
-		else
3194
+		} else
2954 3195
 		{
2955 3196
 			$md5_local = md5_file($pathref.'/'.$filename);
2956 3197
 
2957
-			if ($conffile == '/etc/dolibarr/conf.php' && $filename == '/filefunc.inc.php')	// For install with deb or rpm, we ignore test on filefunc.inc.php that was modified by package
3198
+			if ($conffile == '/etc/dolibarr/conf.php' && $filename == '/filefunc.inc.php') {
3199
+			    // For install with deb or rpm, we ignore test on filefunc.inc.php that was modified by package
2958 3200
 			{
2959 3201
 				$checksumconcat[] = $expectedmd5;
2960 3202
 			}
2961
-			else
3203
+			} else
2962 3204
 			{
2963
-				if ($md5_local != $expectedmd5) $file_list['updated'][] = array('filename'=>$filename, 'expectedmd5'=>$expectedmd5, 'md5'=>(string) $md5_local);
3205
+				if ($md5_local != $expectedmd5) {
3206
+				    $file_list['updated'][] = array('filename'=>$filename, 'expectedmd5'=>$expectedmd5, 'md5'=>(string) $md5_local);
3207
+				}
2964 3208
 				$checksumconcat[] = $md5_local;
2965 3209
 			}
2966 3210
 		}
2967 3211
 	}
2968 3212
 
2969
-	foreach ($dir->dir as $subdir)			// $subdir['name'] is  '' or '/accountancy/admin' for example
3213
+	foreach ($dir->dir as $subdir) {
3214
+	    // $subdir['name'] is  '' or '/accountancy/admin' for example
2970 3215
 	{
2971 3216
 		getFilesUpdated($file_list, $subdir, $path.$subdir['name'].'/', $pathref, $checksumconcat);
2972 3217
 	}
3218
+	}
2973 3219
 
2974 3220
 	return $file_list;
2975 3221
 }
Please login to merge, or discard this patch.
dolibarr/htdocs/core/lib/expedition.lib.php 1 patch
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -35,7 +35,9 @@
 block discarded – undo
35 35
 function expedition_prepare_head(Expedition $object)
36 36
 {
37 37
 	global $langs, $conf, $user;
38
-	if (! empty($conf->expedition->enabled)) $langs->load("sendings");
38
+	if (! empty($conf->expedition->enabled)) {
39
+	    $langs->load("sendings");
40
+	}
39 41
 	$langs->load("orders");
40 42
 
41 43
 	$h = 0;
Please login to merge, or discard this patch.
dolibarr/htdocs/core/lib/fourn.lib.php 1 patch
Braces   +30 added lines, -10 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.'/fourn/facture/contact.php?facid='.$object->id;
50 50
 		$head[$h][1] = $langs->trans('ContactsAddresses');
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
 	}
@@ -62,11 +64,17 @@  discard block
 block discarded – undo
62 64
     if (empty($conf->global->MAIN_DISABLE_NOTES_TAB))
63 65
     {
64 66
     	$nbNote = 0;
65
-        if(!empty($object->note_private)) $nbNote++;
66
-		if(!empty($object->note_public)) $nbNote++;
67
+        if(!empty($object->note_private)) {
68
+            $nbNote++;
69
+        }
70
+		if(!empty($object->note_public)) {
71
+		    $nbNote++;
72
+		}
67 73
     	$head[$h][0] = DOL_URL_ROOT.'/fourn/facture/note.php?facid='.$object->id;
68 74
     	$head[$h][1] = $langs->trans('Notes');
69
-		if ($nbNote > 0) $head[$h][1].= ' <span class="badge">'.$nbNote.'</span>';
75
+		if ($nbNote > 0) {
76
+		    $head[$h][1].= ' <span class="badge">'.$nbNote.'</span>';
77
+		}
70 78
     	$head[$h][2] = 'note';
71 79
     	$h++;
72 80
     }
@@ -78,7 +86,9 @@  discard block
 block discarded – undo
78 86
     $nbLinks=Link::count($db, $object->element, $object->id);
79 87
 	$head[$h][0] = DOL_URL_ROOT.'/fourn/facture/document.php?facid='.$object->id;
80 88
 	$head[$h][1] = $langs->trans('Documents');
81
-	if (($nbFiles+$nbLinks) > 0) $head[$h][1].= ' <span class="badge">'.($nbFiles+$nbLinks).'</span>';
89
+	if (($nbFiles+$nbLinks) > 0) {
90
+	    $head[$h][1].= ' <span class="badge">'.($nbFiles+$nbLinks).'</span>';
91
+	}
82 92
 	$head[$h][2] = 'documents';
83 93
 	$h++;
84 94
 
@@ -116,7 +126,9 @@  discard block
 block discarded – undo
116 126
 	    $nbContact = count($object->liste_contact(-1,'internal')) + count($object->liste_contact(-1,'external'));
117 127
 	    $head[$h][0] = DOL_URL_ROOT.'/fourn/commande/contact.php?id='.$object->id;
118 128
 		$head[$h][1] = $langs->trans('ContactsAddresses');
119
-		if ($nbContact > 0) $head[$h][1].= ' <span class="badge">'.$nbContact.'</span>';
129
+		if ($nbContact > 0) {
130
+		    $head[$h][1].= ' <span class="badge">'.$nbContact.'</span>';
131
+		}
120 132
 		$head[$h][2] = 'contact';
121 133
 		$h++;
122 134
 	}
@@ -139,11 +151,17 @@  discard block
 block discarded – undo
139 151
     if (empty($conf->global->MAIN_DISABLE_NOTES_TAB))
140 152
     {
141 153
     	$nbNote = 0;
142
-        if(!empty($object->note_private)) $nbNote++;
143
-		if(!empty($object->note_public)) $nbNote++;
154
+        if(!empty($object->note_private)) {
155
+            $nbNote++;
156
+        }
157
+		if(!empty($object->note_public)) {
158
+		    $nbNote++;
159
+		}
144 160
     	$head[$h][0] = DOL_URL_ROOT.'/fourn/commande/note.php?id='.$object->id;
145 161
     	$head[$h][1] = $langs->trans("Notes");
146
-		if ($nbNote > 0) $head[$h][1].= ' <span class="badge">'.$nbNote.'</span>';
162
+		if ($nbNote > 0) {
163
+		    $head[$h][1].= ' <span class="badge">'.$nbNote.'</span>';
164
+		}
147 165
     	$head[$h][2] = 'note';
148 166
     	$h++;
149 167
     }
@@ -155,7 +173,9 @@  discard block
 block discarded – undo
155 173
     $nbLinks=Link::count($db, $object->element, $object->id);
156 174
 	$head[$h][0] = DOL_URL_ROOT.'/fourn/commande/document.php?id='.$object->id;
157 175
 	$head[$h][1] = $langs->trans('Documents');
158
-	if (($nbFiles+$nbLinks) > 0) $head[$h][1].= ' <span class="badge">'.($nbFiles+$nbLinks).'</span>';
176
+	if (($nbFiles+$nbLinks) > 0) {
177
+	    $head[$h][1].= ' <span class="badge">'.($nbFiles+$nbLinks).'</span>';
178
+	}
159 179
 	$head[$h][2] = 'documents';
160 180
 	$h++;
161 181
 
Please login to merge, or discard this patch.
dolibarr/htdocs/core/lib/parsemd.lib.php 1 patch
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -45,8 +45,7 @@
 block discarded – undo
45 45
         include_once DOL_DOCUMENT_ROOT.'/includes/parsedown/Parsedown.php';
46 46
         $Parsedown = new Parsedown();
47 47
         $content = $Parsedown->text($content);
48
-    }
49
-    else
48
+    } else
50 49
     {
51 50
         $content = nl2br($content);
52 51
     }
Please login to merge, or discard this patch.