Test Failed
Branch develop (86e751)
by Laurent
34:11
created
htdocs/core/lib/ajax.lib.php 4 patches
Doc Comments   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -314,7 +314,7 @@  discard block
 block discarded – undo
314 314
  *	@param	string	$message	Message of dialog box
315 315
  *	@param	int		$w			Width of dialog box
316 316
  *	@param	int		$h			height of dialog box
317
- *	@return	void
317
+ *	@return	string
318 318
  */
319 319
 function ajax_dialog($title,$message,$w=350,$h=150)
320 320
 {
@@ -441,7 +441,7 @@  discard block
 block discarded – undo
441 441
  * 	@param	array	$input			Array of type->list of CSS element to switch. Example: array('disabled'=>array(0=>'cssid'))
442 442
  * 	@param	int		$entity			Entity to set
443 443
  *  @param	int		$revertonoff	Revert on/off
444
- *  @param	bool	$strict			Use only "disabled" with delConstant and "enabled" with setConstant
444
+ *  @param	integer	$strict			Use only "disabled" with delConstant and "enabled" with setConstant
445 445
  * 	@return	string
446 446
  */
447 447
 function ajax_constantonoff($code, $input=array(), $entity=null, $revertonoff=0, $strict=0)
@@ -510,7 +510,7 @@  discard block
 block discarded – undo
510 510
  *  @param  string  $text_on    Text if on
511 511
  *  @param  string  $text_off   Text if off
512 512
  *  @param  array   $input      Array of type->list of CSS element to switch. Example: array('disabled'=>array(0=>'cssid'))
513
- *  @return void
513
+ *  @return string
514 514
  */
515 515
 function ajax_object_onoff($object, $code, $field, $text_on, $text_off, $input=array())
516 516
 {
Please login to merge, or discard this patch.
Indentation   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -45,16 +45,16 @@  discard block
 block discarded – undo
45 45
  */
46 46
 function ajax_autocompleter($selected, $htmlname, $url, $urloption='', $minLength=2, $autoselect=0, $ajaxoptions=array())
47 47
 {
48
-    if (empty($minLength)) $minLength=1;
48
+	if (empty($minLength)) $minLength=1;
49 49
 
50
-    $dataforrenderITem='ui-autocomplete';
51
-    $dataforitem='ui-autocomplete-item';
52
-    // Allow two constant to use other values for backward compatibility
53
-    if (defined('JS_QUERY_AUTOCOMPLETE_RENDERITEM')) $dataforrenderITem=constant('JS_QUERY_AUTOCOMPLETE_RENDERITEM');
54
-    if (defined('JS_QUERY_AUTOCOMPLETE_ITEM'))       $dataforitem=constant('JS_QUERY_AUTOCOMPLETE_ITEM');
50
+	$dataforrenderITem='ui-autocomplete';
51
+	$dataforitem='ui-autocomplete-item';
52
+	// Allow two constant to use other values for backward compatibility
53
+	if (defined('JS_QUERY_AUTOCOMPLETE_RENDERITEM')) $dataforrenderITem=constant('JS_QUERY_AUTOCOMPLETE_RENDERITEM');
54
+	if (defined('JS_QUERY_AUTOCOMPLETE_ITEM'))       $dataforitem=constant('JS_QUERY_AUTOCOMPLETE_ITEM');
55 55
 
56
-    // Input search_htmlname is original field
57
-    // Input htmlname is a second input field used when using ajax autocomplete.
56
+	// Input search_htmlname is original field
57
+	// Input htmlname is a second input field used when using ajax autocomplete.
58 58
 	$script = '<input type="hidden" name="'.$htmlname.'" id="'.$htmlname.'" value="'.$selected.'" />';
59 59
 
60 60
 	$script.= '<!-- Javascript code for autocomplete of field '.$htmlname.' -->'."\n";
@@ -339,7 +339,7 @@  discard block
 block discarded – undo
339 339
 	$msg= '<div id="dialog-info" title="'.dol_escape_htmltag($newtitle).'">';
340 340
 	$msg.= $message;
341 341
 	$msg.= '</div>'."\n";
342
-    $msg.= '<script type="text/javascript">
342
+	$msg.= '<script type="text/javascript">
343 343
     jQuery(function() {
344 344
         jQuery("#dialog-info").dialog({
345 345
 	        resizable: false,
@@ -355,9 +355,9 @@  discard block
 block discarded – undo
355 355
 	});
356 356
 	</script>';
357 357
 
358
-    $msg.= "\n";
358
+	$msg.= "\n";
359 359
 
360
-    return $msg;
360
+	return $msg;
361 361
 }
362 362
 
363 363
 
@@ -403,8 +403,8 @@  discard block
 block discarded – undo
403 403
 
404 404
 	if (empty($minLengthToAutocomplete)) $minLengthToAutocomplete=0;
405 405
 
406
-    $tmpplugin='select2';
407
-    $msg="\n".'<!-- JS CODE TO ENABLE '.$tmpplugin.' for id = '.$htmlname.' -->
406
+	$tmpplugin='select2';
407
+	$msg="\n".'<!-- JS CODE TO ENABLE '.$tmpplugin.' for id = '.$htmlname.' -->
408 408
           <script type="text/javascript">
409 409
         	$(document).ready(function () {
410 410
         		$(\''.(preg_match('/^\./',$htmlname)?$htmlname:'#'.$htmlname).'\').'.$tmpplugin.'({
@@ -467,9 +467,9 @@  discard block
 block discarded – undo
467 467
 	}
468 468
 
469 469
 	$msg.= '});'."\n";
470
-    $msg.= "</script>\n";
470
+	$msg.= "</script>\n";
471 471
 
472
-    return $msg;
472
+	return $msg;
473 473
 }
474 474
 
475 475
 /**
@@ -552,9 +552,9 @@  discard block
 block discarded – undo
552 552
  */
553 553
 function ajax_object_onoff($object, $code, $field, $text_on, $text_off, $input=array())
554 554
 {
555
-    global $langs;
555
+	global $langs;
556 556
 
557
-    $out= '<script type="text/javascript">
557
+	$out= '<script type="text/javascript">
558 558
         $(function() {
559 559
             var input = '.json_encode($input).';
560 560
 
@@ -619,9 +619,9 @@  discard block
 block discarded – undo
619 619
             });
620 620
         });
621 621
     </script>';
622
-    $out.= '<span id="set_'.$code.'_'.$object->id.'" class="linkobject '.($object->$code==1?'hideobject':'').'">'.img_picto($langs->trans($text_off),'switch_off').'</span>';
623
-    $out.= '<span id="del_'.$code.'_'.$object->id.'" class="linkobject '.($object->$code==1?'':'hideobject').'">'.img_picto($langs->trans($text_on),'switch_on').'</span>';
622
+	$out.= '<span id="set_'.$code.'_'.$object->id.'" class="linkobject '.($object->$code==1?'hideobject':'').'">'.img_picto($langs->trans($text_off),'switch_off').'</span>';
623
+	$out.= '<span id="del_'.$code.'_'.$object->id.'" class="linkobject '.($object->$code==1?'':'hideobject').'">'.img_picto($langs->trans($text_on),'switch_on').'</span>';
624 624
 
625
-    return $out;
625
+	return $out;
626 626
 }
627 627
 
Please login to merge, or discard this patch.
Spacing   +51 added lines, -51 removed lines patch added patch discarded remove patch
@@ -43,23 +43,23 @@  discard block
 block discarded – undo
43 43
  *                                          Ex: array('option_disabled'=> id to disable and warning to show if we select a disabled value (this is possible when using autocomplete ajax)
44 44
  *	@return string              		Script
45 45
  */
46
-function ajax_autocompleter($selected, $htmlname, $url, $urloption='', $minLength=2, $autoselect=0, $ajaxoptions=array())
46
+function ajax_autocompleter($selected, $htmlname, $url, $urloption = '', $minLength = 2, $autoselect = 0, $ajaxoptions = array())
47 47
 {
48
-    if (empty($minLength)) $minLength=1;
48
+    if (empty($minLength)) $minLength = 1;
49 49
 
50
-    $dataforrenderITem='ui-autocomplete';
51
-    $dataforitem='ui-autocomplete-item';
50
+    $dataforrenderITem = 'ui-autocomplete';
51
+    $dataforitem = 'ui-autocomplete-item';
52 52
     // Allow two constant to use other values for backward compatibility
53
-    if (defined('JS_QUERY_AUTOCOMPLETE_RENDERITEM')) $dataforrenderITem=constant('JS_QUERY_AUTOCOMPLETE_RENDERITEM');
54
-    if (defined('JS_QUERY_AUTOCOMPLETE_ITEM'))       $dataforitem=constant('JS_QUERY_AUTOCOMPLETE_ITEM');
53
+    if (defined('JS_QUERY_AUTOCOMPLETE_RENDERITEM')) $dataforrenderITem = constant('JS_QUERY_AUTOCOMPLETE_RENDERITEM');
54
+    if (defined('JS_QUERY_AUTOCOMPLETE_ITEM'))       $dataforitem = constant('JS_QUERY_AUTOCOMPLETE_ITEM');
55 55
 
56 56
     // Input search_htmlname is original field
57 57
     // Input htmlname is a second input field used when using ajax autocomplete.
58 58
 	$script = '<input type="hidden" name="'.$htmlname.'" id="'.$htmlname.'" value="'.$selected.'" />';
59 59
 
60
-	$script.= '<!-- Javascript code for autocomplete of field '.$htmlname.' -->'."\n";
61
-	$script.= '<script type="text/javascript">'."\n";
62
-	$script.= '$(document).ready(function() {
60
+	$script .= '<!-- Javascript code for autocomplete of field '.$htmlname.' -->'."\n";
61
+	$script .= '<script type="text/javascript">'."\n";
62
+	$script .= '$(document).ready(function() {
63 63
 					var autoselect = '.$autoselect.';
64 64
 					var options = '.json_encode($ajaxoptions).';
65 65
 
@@ -112,7 +112,7 @@  discard block
 block discarded – undo
112 112
                     });
113 113
     				$("input#search_'.$htmlname.'").autocomplete({
114 114
     					source: function( request, response ) {
115
-    						$.get("'.$url.($urloption?'?'.$urloption:'').'", { '.$htmlname.': request.term }, function(data){
115
+    						$.get("'.$url.($urloption ? '?'.$urloption : '').'", { '.$htmlname.': request.term }, function(data){
116 116
 								if (data != null)
117 117
 								{
118 118
 									response($.map( data, function(item) {
@@ -136,7 +136,7 @@  discard block
 block discarded – undo
136 136
 										return { label: label, value: item.value, id: item.key, update: update, textarea: textarea, disabled: item.disabled }
137 137
 									}));
138 138
 								}
139
-								else console.error("Error: Ajax url '.$url.($urloption?'?'.$urloption:'').' has returned an empty page. Should be an empty json array.");
139
+								else console.error("Error: Ajax url '.$url.($urloption ? '?'.$urloption : '').' has returned an empty page. Should be an empty json array.");
140 140
 							}, "json");
141 141
 						},
142 142
 						dataType: "json",
@@ -205,7 +205,7 @@  discard block
 block discarded – undo
205 205
 					};
206 206
 
207 207
   				});';
208
-	$script.= '</script>';
208
+	$script .= '</script>';
209 209
 
210 210
 	return $script;
211 211
 }
@@ -224,11 +224,11 @@  discard block
 block discarded – undo
224 224
  *	@param	int		$autoselect			Automatic selection if just one value
225 225
  *	@return string              		Script
226 226
  */
227
-function ajax_multiautocompleter($htmlname, $fields, $url, $option='', $minLength=2, $autoselect=0)
227
+function ajax_multiautocompleter($htmlname, $fields, $url, $option = '', $minLength = 2, $autoselect = 0)
228 228
 {
229 229
 	$script = '<!-- Autocomplete -->'."\n";
230
-	$script.= '<script type="text/javascript">';
231
-	$script.= 'jQuery(document).ready(function() {
230
+	$script .= '<script type="text/javascript">';
231
+	$script .= 'jQuery(document).ready(function() {
232 232
 					var fields = '.json_encode($fields).';
233 233
 					var nboffields = fields.length;
234 234
 					var autoselect = '.$autoselect.';
@@ -238,7 +238,7 @@  discard block
 block discarded – undo
238 238
     					dataType: "json",
239 239
     					minLength: '.$minLength.',
240 240
     					source: function( request, response ) {
241
-    						jQuery.getJSON( "'.$url.($option?'?'.$option:'').'", { '.$htmlname.': request.term }, function(data){
241
+    						jQuery.getJSON( "'.$url.($option ? '?'.$option : '').'", { '.$htmlname.': request.term }, function(data){
242 242
 								response( jQuery.map( data, function( item ) {
243 243
 									if (autoselect == 1 && data.length == 1) {
244 244
 										jQuery("#'.$htmlname.'").val(item.value);
@@ -317,7 +317,7 @@  discard block
 block discarded – undo
317 317
     					}
318 318
 					});
319 319
   				});';
320
-	$script.= '</script>';
320
+	$script .= '</script>';
321 321
 
322 322
 	return $script;
323 323
 }
@@ -331,15 +331,15 @@  discard block
 block discarded – undo
331 331
  *	@param	int		$h			height of dialog box
332 332
  *	@return	void
333 333
  */
334
-function ajax_dialog($title,$message,$w=350,$h=150)
334
+function ajax_dialog($title, $message, $w = 350, $h = 150)
335 335
 {
336 336
 	global $langs;
337 337
 
338
-	$newtitle=dol_textishtml($title)?dol_string_nohtmltag($title,1):$title;
339
-	$msg= '<div id="dialog-info" title="'.dol_escape_htmltag($newtitle).'">';
340
-	$msg.= $message;
341
-	$msg.= '</div>'."\n";
342
-    $msg.= '<script type="text/javascript">
338
+	$newtitle = dol_textishtml($title) ?dol_string_nohtmltag($title, 1) : $title;
339
+	$msg = '<div id="dialog-info" title="'.dol_escape_htmltag($newtitle).'">';
340
+	$msg .= $message;
341
+	$msg .= '</div>'."\n";
342
+    $msg .= '<script type="text/javascript">
343 343
     jQuery(function() {
344 344
         jQuery("#dialog-info").dialog({
345 345
 	        resizable: false,
@@ -355,7 +355,7 @@  discard block
 block discarded – undo
355 355
 	});
356 356
 	</script>';
357 357
 
358
-    $msg.= "\n";
358
+    $msg .= "\n";
359 359
 
360 360
     return $msg;
361 361
 }
@@ -367,7 +367,7 @@  discard block
 block discarded – undo
367 367
  * @param string	$htmlname	Id of html object
368 368
  * @param string	$addlink	Add a 'link to' after
369 369
  */
370
-function ajax_autoselect($htmlname, $addlink='')
370
+function ajax_autoselect($htmlname, $addlink = '')
371 371
 {
372 372
 	global $langs;
373 373
 	$out = '<script type="text/javascript">
@@ -375,7 +375,7 @@  discard block
 block discarded – undo
375 375
 				    jQuery("#'.$htmlname.'").click(function() { jQuery(this).select(); } );
376 376
 				});
377 377
 		    </script>';
378
-	if ($addlink) $out.=' <a href="'.$addlink.'" target="_blank">'.$langs->trans("Link").'</a>';
378
+	if ($addlink) $out .= ' <a href="'.$addlink.'" target="_blank">'.$langs->trans("Link").'</a>';
379 379
 	return $out;
380 380
 }
381 381
 
@@ -391,33 +391,33 @@  discard block
 block discarded – undo
391 391
  * @param	string	$widthTypeOfAutocomplete	'resolve' or 'off'
392 392
  * @return	string								Return html string to convert a select field into a combo, or '' if feature has been disabled for some reason.
393 393
  */
394
-function ajax_combobox($htmlname, $events=array(), $minLengthToAutocomplete=0, $forcefocus=0, $widthTypeOfAutocomplete='resolve')
394
+function ajax_combobox($htmlname, $events = array(), $minLengthToAutocomplete = 0, $forcefocus = 0, $widthTypeOfAutocomplete = 'resolve')
395 395
 {
396 396
 	global $conf;
397 397
 
398
-	if (! empty($conf->browser->phone)) return '';	// select2 disabled for smartphones with standard browser (does not works, popup appears outside screen)
398
+	if (!empty($conf->browser->phone)) return ''; // select2 disabled for smartphones with standard browser (does not works, popup appears outside screen)
399 399
 	//if (! empty($conf->dol_use_jmobile)) return '';	// select2 works with jmobile but it breaks the autosize feature of jmobile.
400
-	if (! empty($conf->global->MAIN_DISABLE_AJAX_COMBOX)) return '';
400
+	if (!empty($conf->global->MAIN_DISABLE_AJAX_COMBOX)) return '';
401 401
 	if (empty($conf->use_javascript_ajax)) return '';
402
-	if (empty($conf->global->MAIN_USE_JQUERY_MULTISELECT) && ! defined('REQUIRE_JQUERY_MULTISELECT')) return '';
402
+	if (empty($conf->global->MAIN_USE_JQUERY_MULTISELECT) && !defined('REQUIRE_JQUERY_MULTISELECT')) return '';
403 403
 
404
-	if (empty($minLengthToAutocomplete)) $minLengthToAutocomplete=0;
404
+	if (empty($minLengthToAutocomplete)) $minLengthToAutocomplete = 0;
405 405
 
406
-    $tmpplugin='select2';
407
-    $msg="\n".'<!-- JS CODE TO ENABLE '.$tmpplugin.' for id = '.$htmlname.' -->
406
+    $tmpplugin = 'select2';
407
+    $msg = "\n".'<!-- JS CODE TO ENABLE '.$tmpplugin.' for id = '.$htmlname.' -->
408 408
           <script type="text/javascript">
409 409
         	$(document).ready(function () {
410
-        		$(\''.(preg_match('/^\./',$htmlname)?$htmlname:'#'.$htmlname).'\').'.$tmpplugin.'({
410
+        		$(\''.(preg_match('/^\./', $htmlname) ? $htmlname : '#'.$htmlname).'\').'.$tmpplugin.'({
411 411
         		    dir: \'ltr\',
412 412
         			width: \''.$widthTypeOfAutocomplete.'\',		/* off or resolve */
413 413
 					minimumInputLength: '.$minLengthToAutocomplete.'
414 414
 				})';
415
-	if ($forcefocus) $msg.= '.select2(\'focus\')';
416
-	$msg.= ';'."\n";
415
+	if ($forcefocus) $msg .= '.select2(\'focus\')';
416
+	$msg .= ';'."\n";
417 417
 
418 418
 	if (count($events))    // If an array of js events to do were provided.
419 419
 	{
420
-		$msg.= '
420
+		$msg .= '
421 421
 			jQuery("#'.$htmlname.'").change(function () {
422 422
 				var obj = '.json_encode($events).';
423 423
 		   		$.each(obj, function(key,values) {
@@ -466,8 +466,8 @@  discard block
 block discarded – undo
466 466
 			}';
467 467
 	}
468 468
 
469
-	$msg.= '});'."\n";
470
-    $msg.= "</script>\n";
469
+	$msg .= '});'."\n";
470
+    $msg .= "</script>\n";
471 471
 
472 472
     return $msg;
473 473
 }
@@ -482,7 +482,7 @@  discard block
 block discarded – undo
482 482
  *  @param	bool	$strict			Use only "disabled" with delConstant and "enabled" with setConstant
483 483
  * 	@return	string
484 484
  */
485
-function ajax_constantonoff($code, $input=array(), $entity=null, $revertonoff=0, $strict=0)
485
+function ajax_constantonoff($code, $input = array(), $entity = null, $revertonoff = 0, $strict = 0)
486 486
 {
487 487
 	global $conf, $langs;
488 488
 
@@ -490,12 +490,12 @@  discard block
 block discarded – undo
490 490
 
491 491
 	if (empty($conf->use_javascript_ajax))
492 492
 	{
493
-		if (empty($conf->global->$code)) print '<a href="'.$_SERVER['PHP_SELF'].'?action=set_'.$code.'&entity='.$entity.'">'.img_picto($langs->trans("Disabled"),'off').'</a>';
494
-		else print '<a href="'.$_SERVER['PHP_SELF'].'?action=del_'.$code.'&entity='.$entity.'">'.img_picto($langs->trans("Enabled"),'on').'</a>';
493
+		if (empty($conf->global->$code)) print '<a href="'.$_SERVER['PHP_SELF'].'?action=set_'.$code.'&entity='.$entity.'">'.img_picto($langs->trans("Disabled"), 'off').'</a>';
494
+		else print '<a href="'.$_SERVER['PHP_SELF'].'?action=del_'.$code.'&entity='.$entity.'">'.img_picto($langs->trans("Enabled"), 'on').'</a>';
495 495
 	}
496 496
 	else
497 497
 	{
498
-		$out= "\n<!-- Ajax code to switch constant ".$code." -->".'
498
+		$out = "\n<!-- Ajax code to switch constant ".$code." -->".'
499 499
 		<script type="text/javascript">
500 500
 			$(document).ready(function() {
501 501
 				var input = '.json_encode($input).';
@@ -530,10 +530,10 @@  discard block
 block discarded – undo
530 530
 			});
531 531
 		</script>'."\n";
532 532
 
533
-		$out.= '<div id="confirm_'.$code.'" title="" style="display: none;"></div>';
534
-		$out.= '<span id="set_'.$code.'" class="linkobject '.(! empty($conf->global->$code)?'hideobject':'').'">'.($revertonoff?img_picto($langs->trans("Enabled"),'switch_on'):img_picto($langs->trans("Disabled"),'switch_off')).'</span>';
535
-		$out.= '<span id="del_'.$code.'" class="linkobject '.(! empty($conf->global->$code)?'':'hideobject').'">'.($revertonoff?img_picto($langs->trans("Disabled"),'switch_off'):img_picto($langs->trans("Enabled"),'switch_on')).'</span>';
536
-		$out.="\n";
533
+		$out .= '<div id="confirm_'.$code.'" title="" style="display: none;"></div>';
534
+		$out .= '<span id="set_'.$code.'" class="linkobject '.(!empty($conf->global->$code) ? 'hideobject' : '').'">'.($revertonoff ?img_picto($langs->trans("Enabled"), 'switch_on') : img_picto($langs->trans("Disabled"), 'switch_off')).'</span>';
535
+		$out .= '<span id="del_'.$code.'" class="linkobject '.(!empty($conf->global->$code) ? '' : 'hideobject').'">'.($revertonoff ?img_picto($langs->trans("Disabled"), 'switch_off') : img_picto($langs->trans("Enabled"), 'switch_on')).'</span>';
536
+		$out .= "\n";
537 537
 	}
538 538
 
539 539
 	return $out;
@@ -550,11 +550,11 @@  discard block
 block discarded – undo
550 550
  *  @param  array   $input      Array of type->list of CSS element to switch. Example: array('disabled'=>array(0=>'cssid'))
551 551
  *  @return void
552 552
  */
553
-function ajax_object_onoff($object, $code, $field, $text_on, $text_off, $input=array())
553
+function ajax_object_onoff($object, $code, $field, $text_on, $text_off, $input = array())
554 554
 {
555 555
     global $langs;
556 556
 
557
-    $out= '<script type="text/javascript">
557
+    $out = '<script type="text/javascript">
558 558
         $(function() {
559 559
             var input = '.json_encode($input).';
560 560
 
@@ -619,8 +619,8 @@  discard block
 block discarded – undo
619 619
             });
620 620
         });
621 621
     </script>';
622
-    $out.= '<span id="set_'.$code.'_'.$object->id.'" class="linkobject '.($object->$code==1?'hideobject':'').'">'.img_picto($langs->trans($text_off),'switch_off').'</span>';
623
-    $out.= '<span id="del_'.$code.'_'.$object->id.'" class="linkobject '.($object->$code==1?'':'hideobject').'">'.img_picto($langs->trans($text_on),'switch_on').'</span>';
622
+    $out .= '<span id="set_'.$code.'_'.$object->id.'" class="linkobject '.($object->$code == 1 ? 'hideobject' : '').'">'.img_picto($langs->trans($text_off), 'switch_off').'</span>';
623
+    $out .= '<span id="del_'.$code.'_'.$object->id.'" class="linkobject '.($object->$code == 1 ? '' : 'hideobject').'">'.img_picto($langs->trans($text_on), 'switch_on').'</span>';
624 624
 
625 625
     return $out;
626 626
 }
Please login to merge, or discard this patch.
Braces   +40 added lines, -15 removed lines patch added patch discarded remove patch
@@ -45,13 +45,19 @@  discard block
 block discarded – undo
45 45
  */
46 46
 function ajax_autocompleter($selected, $htmlname, $url, $urloption='', $minLength=2, $autoselect=0, $ajaxoptions=array())
47 47
 {
48
-    if (empty($minLength)) $minLength=1;
48
+    if (empty($minLength)) {
49
+    	$minLength=1;
50
+    }
49 51
 
50 52
     $dataforrenderITem='ui-autocomplete';
51 53
     $dataforitem='ui-autocomplete-item';
52 54
     // Allow two constant to use other values for backward compatibility
53
-    if (defined('JS_QUERY_AUTOCOMPLETE_RENDERITEM')) $dataforrenderITem=constant('JS_QUERY_AUTOCOMPLETE_RENDERITEM');
54
-    if (defined('JS_QUERY_AUTOCOMPLETE_ITEM'))       $dataforitem=constant('JS_QUERY_AUTOCOMPLETE_ITEM');
55
+    if (defined('JS_QUERY_AUTOCOMPLETE_RENDERITEM')) {
56
+    	$dataforrenderITem=constant('JS_QUERY_AUTOCOMPLETE_RENDERITEM');
57
+    }
58
+    if (defined('JS_QUERY_AUTOCOMPLETE_ITEM')) {
59
+    	$dataforitem=constant('JS_QUERY_AUTOCOMPLETE_ITEM');
60
+    }
55 61
 
56 62
     // Input search_htmlname is original field
57 63
     // Input htmlname is a second input field used when using ajax autocomplete.
@@ -375,7 +381,9 @@  discard block
 block discarded – undo
375 381
 				    jQuery("#'.$htmlname.'").click(function() { jQuery(this).select(); } );
376 382
 				});
377 383
 		    </script>';
378
-	if ($addlink) $out.=' <a href="'.$addlink.'" target="_blank">'.$langs->trans("Link").'</a>';
384
+	if ($addlink) {
385
+		$out.=' <a href="'.$addlink.'" target="_blank">'.$langs->trans("Link").'</a>';
386
+	}
379 387
 	return $out;
380 388
 }
381 389
 
@@ -395,13 +403,24 @@  discard block
 block discarded – undo
395 403
 {
396 404
 	global $conf;
397 405
 
398
-	if (! empty($conf->browser->phone)) return '';	// select2 disabled for smartphones with standard browser (does not works, popup appears outside screen)
406
+	if (! empty($conf->browser->phone)) {
407
+		return '';
408
+	}
409
+	// select2 disabled for smartphones with standard browser (does not works, popup appears outside screen)
399 410
 	//if (! empty($conf->dol_use_jmobile)) return '';	// select2 works with jmobile but it breaks the autosize feature of jmobile.
400
-	if (! empty($conf->global->MAIN_DISABLE_AJAX_COMBOX)) return '';
401
-	if (empty($conf->use_javascript_ajax)) return '';
402
-	if (empty($conf->global->MAIN_USE_JQUERY_MULTISELECT) && ! defined('REQUIRE_JQUERY_MULTISELECT')) return '';
411
+	if (! empty($conf->global->MAIN_DISABLE_AJAX_COMBOX)) {
412
+		return '';
413
+	}
414
+	if (empty($conf->use_javascript_ajax)) {
415
+		return '';
416
+	}
417
+	if (empty($conf->global->MAIN_USE_JQUERY_MULTISELECT) && ! defined('REQUIRE_JQUERY_MULTISELECT')) {
418
+		return '';
419
+	}
403 420
 
404
-	if (empty($minLengthToAutocomplete)) $minLengthToAutocomplete=0;
421
+	if (empty($minLengthToAutocomplete)) {
422
+		$minLengthToAutocomplete=0;
423
+	}
405 424
 
406 425
     $tmpplugin='select2';
407 426
     $msg="\n".'<!-- JS CODE TO ENABLE '.$tmpplugin.' for id = '.$htmlname.' -->
@@ -412,10 +431,13 @@  discard block
 block discarded – undo
412 431
         			width: \''.$widthTypeOfAutocomplete.'\',		/* off or resolve */
413 432
 					minimumInputLength: '.$minLengthToAutocomplete.'
414 433
 				})';
415
-	if ($forcefocus) $msg.= '.select2(\'focus\')';
434
+	if ($forcefocus) {
435
+		$msg.= '.select2(\'focus\')';
436
+	}
416 437
 	$msg.= ';'."\n";
417 438
 
418
-	if (count($events))    // If an array of js events to do were provided.
439
+	if (count($events)) {
440
+		// If an array of js events to do were provided.
419 441
 	{
420 442
 		$msg.= '
421 443
 			jQuery("#'.$htmlname.'").change(function () {
@@ -465,6 +487,7 @@  discard block
 block discarded – undo
465 487
 				);
466 488
 			}';
467 489
 	}
490
+	}
468 491
 
469 492
 	$msg.= '});'."\n";
470 493
     $msg.= "</script>\n";
@@ -490,10 +513,12 @@  discard block
 block discarded – undo
490 513
 
491 514
 	if (empty($conf->use_javascript_ajax))
492 515
 	{
493
-		if (empty($conf->global->$code)) print '<a href="'.$_SERVER['PHP_SELF'].'?action=set_'.$code.'&entity='.$entity.'">'.img_picto($langs->trans("Disabled"),'off').'</a>';
494
-		else print '<a href="'.$_SERVER['PHP_SELF'].'?action=del_'.$code.'&entity='.$entity.'">'.img_picto($langs->trans("Enabled"),'on').'</a>';
495
-	}
496
-	else
516
+		if (empty($conf->global->$code)) {
517
+			print '<a href="'.$_SERVER['PHP_SELF'].'?action=set_'.$code.'&entity='.$entity.'">'.img_picto($langs->trans("Disabled"),'off').'</a>';
518
+		} else {
519
+			print '<a href="'.$_SERVER['PHP_SELF'].'?action=del_'.$code.'&entity='.$entity.'">'.img_picto($langs->trans("Enabled"),'on').'</a>';
520
+		}
521
+	} else
497 522
 	{
498 523
 		$out= "\n<!-- Ajax code to switch constant ".$code." -->".'
499 524
 		<script type="text/javascript">
Please login to merge, or discard this patch.
htdocs/core/lib/date.lib.php 4 patches
Doc Comments   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -27,7 +27,7 @@  discard block
 block discarded – undo
27 27
 /**
28 28
  *  Return an array with timezone values
29 29
  *
30
- *  @return     array   Array with timezone values
30
+ *  @return     string[]   Array with timezone values
31 31
  */
32 32
 function get_tz_array()
33 33
 {
@@ -76,7 +76,7 @@  discard block
 block discarded – undo
76 76
  * Return server timezone int.
77 77
  *
78 78
  * @param	string	$refgmtdate		Reference period for timezone (timezone differs on winter and summer. May be 'now', 'winter' or 'summer')
79
- * @return 	int						An offset in hour (+1 for Europe/Paris on winter and +2 for Europe/Paris on summer)
79
+ * @return 	double						An offset in hour (+1 for Europe/Paris on winter and +2 for Europe/Paris on summer)
80 80
  */
81 81
 function getServerTimeZoneInt($refgmtdate='now')
82 82
 {
@@ -419,7 +419,7 @@  discard block
 block discarded – undo
419 419
  *
420 420
  *	@param		int			$year		Year
421 421
  * 	@param		int			$month		Month
422
- * 	@param		mixed		$gm			False or 0 or 'server' = Return date to compare with server TZ, True or 1 to compare with GM date.
422
+ * 	@param		boolean		$gm			False or 0 or 'server' = Return date to compare with server TZ, True or 1 to compare with GM date.
423 423
  *                          			Exemple: dol_get_first_day(1970,1,false) will return -3600 with TZ+1, after a dol_print_date will return 1970-01-01 00:00:00
424 424
  *                          			Exemple: dol_get_first_day(1970,1,true) will return 0 whatever is TZ, after a dol_print_date will return 1970-01-01 00:00:00
425 425
  *  @return		int						Date for first day, '' if error
@@ -464,7 +464,7 @@  discard block
 block discarded – undo
464 464
  * 	@param		int		$month		Month
465 465
  *  @param		int		$year		Year
466 466
  * 	@param		int		$gm			False or 0 or 'server' = Return date to compare with server TZ, True or 1 to compare with GM date.
467
- *	@return		array				year,month,week,first_day,first_month,first_year,prev_day,prev_month,prev_year
467
+ *	@return		integer				year,month,week,first_day,first_month,first_year,prev_day,prev_month,prev_year
468 468
  */
469 469
 function dol_get_first_day_week($day,$month,$year,$gm=false)
470 470
 {
@@ -797,7 +797,7 @@  discard block
 block discarded – undo
797 797
  *
798 798
  *	@param	Translate	$outputlangs	Object langs
799 799
  *  @param	int			$short			1=Return short label
800
- *	@return array						Month string or array if selected < 0
800
+ *	@return string[]						Month string or array if selected < 0
801 801
  */
802 802
 function monthArray($outputlangs,$short=0)
803 803
 {
Please login to merge, or discard this patch.
Indentation   +189 added lines, -189 removed lines patch added patch discarded remove patch
@@ -31,34 +31,34 @@  discard block
 block discarded – undo
31 31
  */
32 32
 function get_tz_array()
33 33
 {
34
-    $tzarray=array(
35
-        -11=>"Pacific/Midway",
36
-        -10=>"Pacific/Fakaofo",
37
-        -9=>"America/Anchorage",
38
-        -8=>"America/Los_Angeles",
39
-        -7=>"America/Dawson_Creek",
40
-        -6=>"America/Chicago",
41
-        -5=>"America/Bogota",
42
-        -4=>"America/Anguilla",
43
-        -3=>"America/Araguaina",
44
-        -2=>"America/Noronha",
45
-        -1=>"Atlantic/Azores",
46
-        0=>"Africa/Abidjan",
47
-        1=>"Europe/Paris",
48
-        2=>"Europe/Helsinki",
49
-        3=>"Europe/Moscow",
50
-        4=>"Asia/Dubai",
51
-        5=>"Asia/Karachi",
52
-        6=>"Indian/Chagos",
53
-        7=>"Asia/Jakarta",
54
-        8=>"Asia/Hong_Kong",
55
-        9=>"Asia/Tokyo",
56
-        10=>"Australia/Sydney",
57
-        11=>"Pacific/Noumea",
58
-        12=>"Pacific/Auckland",
59
-        13=>"Pacific/Enderbury"
60
-    );
61
-    return $tzarray;
34
+	$tzarray=array(
35
+		-11=>"Pacific/Midway",
36
+		-10=>"Pacific/Fakaofo",
37
+		-9=>"America/Anchorage",
38
+		-8=>"America/Los_Angeles",
39
+		-7=>"America/Dawson_Creek",
40
+		-6=>"America/Chicago",
41
+		-5=>"America/Bogota",
42
+		-4=>"America/Anguilla",
43
+		-3=>"America/Araguaina",
44
+		-2=>"America/Noronha",
45
+		-1=>"Atlantic/Azores",
46
+		0=>"Africa/Abidjan",
47
+		1=>"Europe/Paris",
48
+		2=>"Europe/Helsinki",
49
+		3=>"Europe/Moscow",
50
+		4=>"Asia/Dubai",
51
+		5=>"Asia/Karachi",
52
+		6=>"Indian/Chagos",
53
+		7=>"Asia/Jakarta",
54
+		8=>"Asia/Hong_Kong",
55
+		9=>"Asia/Tokyo",
56
+		10=>"Australia/Sydney",
57
+		11=>"Pacific/Noumea",
58
+		12=>"Pacific/Auckland",
59
+		13=>"Pacific/Enderbury"
60
+	);
61
+	return $tzarray;
62 62
 }
63 63
 
64 64
 
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
  */
70 70
 function getServerTimeZoneString()
71 71
 {
72
-    return @date_default_timezone_get();
72
+	return @date_default_timezone_get();
73 73
 }
74 74
 
75 75
 /**
@@ -80,27 +80,27 @@  discard block
 block discarded – undo
80 80
  */
81 81
 function getServerTimeZoneInt($refgmtdate='now')
82 82
 {
83
-    global $conf;
84
-    if (method_exists('DateTimeZone','getOffset'))
85
-    {
86
-        // Method 1 (include daylight)
87
-        $gmtnow=dol_now('gmt'); $yearref=dol_print_date($gmtnow,'%Y'); $monthref=dol_print_date($gmtnow,'%m'); $dayref=dol_print_date($gmtnow,'%d');
88
-        if ($refgmtdate == 'now') $newrefgmtdate=$yearref.'-'.$monthref.'-'.$dayref;
89
-        elseif ($refgmtdate == 'summer') $newrefgmtdate=$yearref.'-08-01';
90
-        else $newrefgmtdate=$yearref.'-01-01';
91
-        $newrefgmtdate.='T00:00:00+00:00';
92
-        $localtz = new DateTimeZone(getServerTimeZoneString());
93
-        $localdt = new DateTime($newrefgmtdate, $localtz);
94
-        $tmp=-1*$localtz->getOffset($localdt);
95
-        //print $refgmtdate.'='.$tmp;
96
-    }
97
-    else
98
-    {
99
-    	$tmp=0;
100
-    	dol_print_error('','PHP version must be 5.3+');
101
-    }
102
-    $tz=round(($tmp<0?1:-1)*abs($tmp/3600));
103
-    return $tz;
83
+	global $conf;
84
+	if (method_exists('DateTimeZone','getOffset'))
85
+	{
86
+		// Method 1 (include daylight)
87
+		$gmtnow=dol_now('gmt'); $yearref=dol_print_date($gmtnow,'%Y'); $monthref=dol_print_date($gmtnow,'%m'); $dayref=dol_print_date($gmtnow,'%d');
88
+		if ($refgmtdate == 'now') $newrefgmtdate=$yearref.'-'.$monthref.'-'.$dayref;
89
+		elseif ($refgmtdate == 'summer') $newrefgmtdate=$yearref.'-08-01';
90
+		else $newrefgmtdate=$yearref.'-01-01';
91
+		$newrefgmtdate.='T00:00:00+00:00';
92
+		$localtz = new DateTimeZone(getServerTimeZoneString());
93
+		$localdt = new DateTime($newrefgmtdate, $localtz);
94
+		$tmp=-1*$localtz->getOffset($localdt);
95
+		//print $refgmtdate.'='.$tmp;
96
+	}
97
+	else
98
+	{
99
+		$tmp=0;
100
+		dol_print_error('','PHP version must be 5.3+');
101
+	}
102
+	$tz=round(($tmp<0?1:-1)*abs($tmp/3600));
103
+	return $tz;
104 104
 }
105 105
 
106 106
 
@@ -167,15 +167,15 @@  discard block
 block discarded – undo
167 167
 	global $langs;
168 168
 
169 169
 	if (empty($lengthOfDay))  $lengthOfDay = 86400;         // 1 day = 24 hours
170
-    if (empty($lengthOfWeek)) $lengthOfWeek = 7;            // 1 week = 7 days
170
+	if (empty($lengthOfWeek)) $lengthOfWeek = 7;            // 1 week = 7 days
171 171
 
172 172
 	if ($format == 'all' || $format == 'allwithouthour' || $format == 'allhour' || $format == 'allhourmin')
173 173
 	{
174 174
 		if ((int) $iSecond === 0) return '0';	// This is to avoid having 0 return a 12:00 AM for en_US
175 175
 
176
-        $sTime='';
177
-        $sDay=0;
178
-        $sWeek=0;
176
+		$sTime='';
177
+		$sDay=0;
178
+		$sWeek=0;
179 179
 
180 180
 		if ($iSecond >= $lengthOfDay)
181 181
 		{
@@ -190,17 +190,17 @@  discard block
 block discarded – undo
190 190
 
191 191
 		if ($lengthOfWeek < 7)
192 192
 		{
193
-        	if ($sDay)
194
-            {
195
-                if ($sDay >= $lengthOfWeek)
196
-                {
197
-                    $sWeek = (int) (($sDay - $sDay % $lengthOfWeek ) / $lengthOfWeek);
198
-                    $sDay = $sDay % $lengthOfWeek;
199
-                    $weekTranslate = $langs->trans("DurationWeek");
200
-                    if ($sWeek >= 2) $weekTranslate = $langs->trans("DurationWeeks");
201
-                    $sTime.=$sWeek.' '.$weekTranslate.' ';
202
-                }
203
-            }
193
+			if ($sDay)
194
+			{
195
+				if ($sDay >= $lengthOfWeek)
196
+				{
197
+					$sWeek = (int) (($sDay - $sDay % $lengthOfWeek ) / $lengthOfWeek);
198
+					$sDay = $sDay % $lengthOfWeek;
199
+					$weekTranslate = $langs->trans("DurationWeek");
200
+					if ($sWeek >= 2) $weekTranslate = $langs->trans("DurationWeeks");
201
+					$sTime.=$sWeek.' '.$weekTranslate.' ';
202
+				}
203
+			}
204 204
 		}
205 205
 		if ($sDay>0)
206 206
 		{
@@ -218,7 +218,7 @@  discard block
 block discarded – undo
218 218
 		}
219 219
 		if ($format == 'allhourmin')
220 220
 		{
221
-		    return sprintf("%02d",($sWeek*$lengthOfWeek*24 + $sDay*24 + (int) floor($iSecond/3600))).':'.sprintf("%02d",((int) floor(($iSecond % 3600)/60)));
221
+			return sprintf("%02d",($sWeek*$lengthOfWeek*24 + $sDay*24 + (int) floor($iSecond/3600))).':'.sprintf("%02d",((int) floor(($iSecond % 3600)/60)));
222 222
 		}
223 223
 		if ($format == 'allhour')
224 224
 		{
@@ -243,19 +243,19 @@  discard block
 block discarded – undo
243 243
 	{
244 244
 		$sTime=dol_print_date($iSecond,'%M',true);
245 245
 	}
246
-    else if ($format == 'sec')	// only sec part
247
-    {
248
-        $sTime=dol_print_date($iSecond,'%S',true);
249
-    }
250
-    else if ($format == 'month')	// only month part
251
-    {
252
-        $sTime=dol_print_date($iSecond,'%m',true);
253
-    }
254
-    else if ($format == 'year')	// only year part
255
-    {
256
-        $sTime=dol_print_date($iSecond,'%Y',true);
257
-    }
258
-    return trim($sTime);
246
+	else if ($format == 'sec')	// only sec part
247
+	{
248
+		$sTime=dol_print_date($iSecond,'%S',true);
249
+	}
250
+	else if ($format == 'month')	// only month part
251
+	{
252
+		$sTime=dol_print_date($iSecond,'%m',true);
253
+	}
254
+	else if ($format == 'year')	// only year part
255
+	{
256
+		$sTime=dol_print_date($iSecond,'%Y',true);
257
+	}
258
+	return trim($sTime);
259 259
 }
260 260
 
261 261
 
@@ -279,41 +279,41 @@  discard block
 block discarded – undo
279 279
  */
280 280
 function dol_stringtotime($string, $gm=1)
281 281
 {
282
-    // Convert date with format DD/MM/YYY HH:MM:SS. This part of code should not be used.
283
-    if (preg_match('/^([0-9]+)\/([0-9]+)\/([0-9]+)\s?([0-9]+)?:?([0-9]+)?:?([0-9]+)?/i',$string,$reg))
284
-    {
285
-        dol_syslog("dol_stringtotime call to function with deprecated parameter format", LOG_WARNING);
286
-        // Date est au format 'DD/MM/YY' ou 'DD/MM/YY HH:MM:SS'
287
-        // Date est au format 'DD/MM/YYYY' ou 'DD/MM/YYYY HH:MM:SS'
288
-        $sday = $reg[1];
289
-        $smonth = $reg[2];
290
-        $syear = $reg[3];
291
-        $shour = $reg[4];
292
-        $smin = $reg[5];
293
-        $ssec = $reg[6];
294
-        if ($syear < 50) $syear+=1900;
295
-        if ($syear >= 50 && $syear < 100) $syear+=2000;
296
-        $string=sprintf("%04d%02d%02d%02d%02d%02d",$syear,$smonth,$sday,$shour,$smin,$ssec);
297
-    }
298
-    else if (
299
-    	   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)
300
-    	|| 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
282
+	// Convert date with format DD/MM/YYY HH:MM:SS. This part of code should not be used.
283
+	if (preg_match('/^([0-9]+)\/([0-9]+)\/([0-9]+)\s?([0-9]+)?:?([0-9]+)?:?([0-9]+)?/i',$string,$reg))
284
+	{
285
+		dol_syslog("dol_stringtotime call to function with deprecated parameter format", LOG_WARNING);
286
+		// Date est au format 'DD/MM/YY' ou 'DD/MM/YY HH:MM:SS'
287
+		// Date est au format 'DD/MM/YYYY' ou 'DD/MM/YYYY HH:MM:SS'
288
+		$sday = $reg[1];
289
+		$smonth = $reg[2];
290
+		$syear = $reg[3];
291
+		$shour = $reg[4];
292
+		$smin = $reg[5];
293
+		$ssec = $reg[6];
294
+		if ($syear < 50) $syear+=1900;
295
+		if ($syear >= 50 && $syear < 100) $syear+=2000;
296
+		$string=sprintf("%04d%02d%02d%02d%02d%02d",$syear,$smonth,$sday,$shour,$smin,$ssec);
297
+	}
298
+	else if (
299
+		   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)
300
+		|| 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
301 301
    		|| 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
302
-    )
303
-    {
304
-        $syear = $reg[1];
305
-        $smonth = $reg[2];
306
-        $sday = $reg[3];
307
-        $shour = $reg[4];
308
-        $smin = $reg[5];
309
-        $ssec = $reg[6];
310
-        $string=sprintf("%04d%02d%02d%02d%02d%02d",$syear,$smonth,$sday,$shour,$smin,$ssec);
311
-    }
312
-
313
-    $string=preg_replace('/([^0-9])/i','',$string);
314
-    $tmp=$string.'000000';
315
-    $date=dol_mktime(substr($tmp,8,2),substr($tmp,10,2),substr($tmp,12,2),substr($tmp,4,2),substr($tmp,6,2),substr($tmp,0,4),($gm?1:0));
316
-    return $date;
302
+	)
303
+	{
304
+		$syear = $reg[1];
305
+		$smonth = $reg[2];
306
+		$sday = $reg[3];
307
+		$shour = $reg[4];
308
+		$smin = $reg[5];
309
+		$ssec = $reg[6];
310
+		$string=sprintf("%04d%02d%02d%02d%02d%02d",$syear,$smonth,$sday,$shour,$smin,$ssec);
311
+	}
312
+
313
+	$string=preg_replace('/([^0-9])/i','',$string);
314
+	$tmp=$string.'000000';
315
+	$date=dol_mktime(substr($tmp,8,2),substr($tmp,10,2),substr($tmp,12,2),substr($tmp,4,2),substr($tmp,6,2),substr($tmp,0,4),($gm?1:0));
316
+	return $date;
317 317
 }
318 318
 
319 319
 
@@ -494,30 +494,30 @@  discard block
 block discarded – undo
494 494
 	$days = $start_week - $tmparray['wday'];
495 495
  	if ($days>=1) $days=7-$days;
496 496
  	$days = abs($days);
497
-    $seconds = $days*24*60*60;
497
+	$seconds = $days*24*60*60;
498 498
 	//print 'start_week='.$start_week.' tmparray[wday]='.$tmparray['wday'].' day offset='.$days.' seconds offset='.$seconds.'<br>';
499 499
 
500
-    //Get first day of week
501
-    $tmpdaytms = date($tmparray[0])-$seconds; // $tmparray[0] is day of parameters
500
+	//Get first day of week
501
+	$tmpdaytms = date($tmparray[0])-$seconds; // $tmparray[0] is day of parameters
502 502
 	$tmpday = date("d",$tmpdaytms);
503 503
 
504 504
 	//Check first day of week is in same month than current day or not
505 505
 	if ($tmpday>$day)
506
-    {
507
-    	$prev_month = $month-1;
506
+	{
507
+		$prev_month = $month-1;
508 508
 		$prev_year  = $year;
509 509
 
510
-    	if ($prev_month==0)
511
-    	{
512
-    		$prev_month = 12;
513
-    		$prev_year  = $year-1;
514
-    	}
515
-    }
516
-    else
517
-    {
518
-    	$prev_month = $month;
510
+		if ($prev_month==0)
511
+		{
512
+			$prev_month = 12;
513
+			$prev_year  = $year-1;
514
+		}
515
+	}
516
+	else
517
+	{
518
+		$prev_month = $month;
519 519
 		$prev_year  = $year;
520
-    }
520
+	}
521 521
 	$tmpmonth = $prev_month;
522 522
 	$tmpyear = $prev_year;
523 523
 
@@ -525,22 +525,22 @@  discard block
 block discarded – undo
525 525
 	$tmptime=dol_mktime(12,0,0,$month,$tmpday,$year,1,0);
526 526
 	$tmptime-=24*60*60*7;
527 527
 	$tmparray=dol_getdate($tmptime,true);
528
-    $prev_day   = $tmparray['mday'];
528
+	$prev_day   = $tmparray['mday'];
529 529
 
530
-    //Check prev day of week is in same month than first day or not
530
+	//Check prev day of week is in same month than first day or not
531 531
 	if ($prev_day > $tmpday)
532
-    {
533
-    	$prev_month = $month-1;
532
+	{
533
+		$prev_month = $month-1;
534 534
 		$prev_year  = $year;
535 535
 
536
-    	if ($prev_month==0)
537
-    	{
538
-    		$prev_month = 12;
539
-    		$prev_year  = $year-1;
540
-    	}
541
-    }
536
+		if ($prev_month==0)
537
+		{
538
+			$prev_month = 12;
539
+			$prev_year  = $year-1;
540
+		}
541
+	}
542 542
 
543
-    $week = date("W",dol_mktime(0,0,0,$tmpmonth,$tmpday,$tmpyear,$gm));
543
+	$week = date("W",dol_mktime(0,0,0,$tmpmonth,$tmpday,$tmpyear,$gm));
544 544
 
545 545
 	return array('year' => $year, 'month' => $month, 'week' => $week, 'first_day' => $tmpday, 'first_month' => $tmpmonth, 'first_year' => $tmpyear, 'prev_year' => $prev_year, 'prev_month' => $prev_month, 'prev_day' => $prev_day);
546 546
 }
@@ -565,7 +565,7 @@  discard block
 block discarded – undo
565 565
 
566 566
 	$i=0;
567 567
 	while (( ($lastday == 0 && $timestampStart < $timestampEnd) || ($lastday && $timestampStart <= $timestampEnd) )
568
-	    && ($i < 50000))		// Loop end when equals (Test on i is a security loop to avoid infinite loop)
568
+		&& ($i < 50000))		// Loop end when equals (Test on i is a security loop to avoid infinite loop)
569 569
 	{
570 570
 		$ferie=false;
571 571
 		$countryfound=0;
@@ -595,28 +595,28 @@  discard block
 block discarded – undo
595 595
 			// Paques
596 596
 
597 597
 			// Calcul du jour de l ascension (38 jours apres Paques)
598
-            $date_ascension = mktime(
599
-                date("H", $date_paques),
600
-                date("i", $date_paques),
601
-                date("s", $date_paques),
602
-                date("m", $date_paques),
603
-                date("d", $date_paques) + 38,
604
-                date("Y", $date_paques)
605
-            );
598
+			$date_ascension = mktime(
599
+				date("H", $date_paques),
600
+				date("i", $date_paques),
601
+				date("s", $date_paques),
602
+				date("m", $date_paques),
603
+				date("d", $date_paques) + 38,
604
+				date("Y", $date_paques)
605
+			);
606 606
 			$jour_ascension = date("d", $date_ascension);
607 607
 			$mois_ascension = date("m", $date_ascension);
608 608
 			if($jour_ascension == $jour && $mois_ascension == $mois) $ferie=true;
609 609
 			//Ascension
610 610
 
611 611
 			// Calcul de Pentecote (11 jours apres Paques)
612
-            $date_pentecote = mktime(
613
-                date("H", $date_ascension),
614
-                date("i", $date_ascension),
615
-                date("s", $date_ascension),
616
-                date("m", $date_ascension),
617
-                date("d", $date_ascension) + 11,
618
-                date("Y", $date_ascension)
619
-            );
612
+			$date_pentecote = mktime(
613
+				date("H", $date_ascension),
614
+				date("i", $date_ascension),
615
+				date("s", $date_ascension),
616
+				date("m", $date_ascension),
617
+				date("d", $date_ascension) + 11,
618
+				date("Y", $date_ascension)
619
+			);
620 620
 			$jour_pentecote = date("d", $date_pentecote);
621 621
 			$mois_pentecote = date("m", $date_pentecote);
622 622
 			if($jour_pentecote == $jour && $mois_pentecote == $mois) $ferie=true;
@@ -684,14 +684,14 @@  discard block
 block discarded – undo
684 684
 			// Paques
685 685
 
686 686
 			// Viernes Santo
687
-            $date_viernes = mktime(
688
-                date("H", $date_paques),
689
-                date("i", $date_paques),
690
-                date("s", $date_paques),
691
-                date("m", $date_paques),
692
-                date("d", $date_paques) -2,
693
-                date("Y", $date_paques)
694
-            );
687
+			$date_viernes = mktime(
688
+				date("H", $date_paques),
689
+				date("i", $date_paques),
690
+				date("s", $date_paques),
691
+				date("m", $date_paques),
692
+				date("d", $date_paques) -2,
693
+				date("Y", $date_paques)
694
+			);
695 695
 			$jour_viernes = date("d", $date_viernes);
696 696
 			$mois_viernes = date("m", $date_viernes);
697 697
 			if($jour_viernes == $jour && $mois_viernes == $mois) $ferie=true;
@@ -814,35 +814,35 @@  discard block
 block discarded – undo
814 814
 function monthArray($outputlangs,$short=0)
815 815
 {
816 816
 	$montharray = array (
817
-	    1  => $outputlangs->trans("January"),
818
-	    2  => $outputlangs->trans("February"),
819
-	    3  => $outputlangs->trans("March"),
820
-	    4  => $outputlangs->trans("April"),
821
-	    5  => $outputlangs->trans("May"),
822
-	    6  => $outputlangs->trans("June"),
823
-	    7  => $outputlangs->trans("July"),
824
-	    8  => $outputlangs->trans("August"),
825
-	    9  => $outputlangs->trans("September"),
826
-	    10 => $outputlangs->trans("October"),
827
-	    11 => $outputlangs->trans("November"),
828
-	    12 => $outputlangs->trans("December")
829
-    );
817
+		1  => $outputlangs->trans("January"),
818
+		2  => $outputlangs->trans("February"),
819
+		3  => $outputlangs->trans("March"),
820
+		4  => $outputlangs->trans("April"),
821
+		5  => $outputlangs->trans("May"),
822
+		6  => $outputlangs->trans("June"),
823
+		7  => $outputlangs->trans("July"),
824
+		8  => $outputlangs->trans("August"),
825
+		9  => $outputlangs->trans("September"),
826
+		10 => $outputlangs->trans("October"),
827
+		11 => $outputlangs->trans("November"),
828
+		12 => $outputlangs->trans("December")
829
+	);
830 830
 
831 831
 	if (! empty($short))
832 832
 	{
833 833
 		$montharray = array (
834
-		    1  => $outputlangs->trans("JanuaryMin"),
835
-		    2  => $outputlangs->trans("FebruaryMin"),
836
-		    3  => $outputlangs->trans("MarchMin"),
837
-		    4  => $outputlangs->trans("AprilMin"),
838
-		    5  => $outputlangs->trans("MayMin"),
839
-		    6  => $outputlangs->trans("JuneMin"),
840
-		    7  => $outputlangs->trans("JulyMin"),
841
-		    8  => $outputlangs->trans("AugustMin"),
842
-		    9  => $outputlangs->trans("SeptemberMin"),
843
-		    10 => $outputlangs->trans("OctoberMin"),
844
-		    11 => $outputlangs->trans("NovemberMin"),
845
-		    12 => $outputlangs->trans("DecemberMin")
834
+			1  => $outputlangs->trans("JanuaryMin"),
835
+			2  => $outputlangs->trans("FebruaryMin"),
836
+			3  => $outputlangs->trans("MarchMin"),
837
+			4  => $outputlangs->trans("AprilMin"),
838
+			5  => $outputlangs->trans("MayMin"),
839
+			6  => $outputlangs->trans("JuneMin"),
840
+			7  => $outputlangs->trans("JulyMin"),
841
+			8  => $outputlangs->trans("AugustMin"),
842
+			9  => $outputlangs->trans("SeptemberMin"),
843
+			10 => $outputlangs->trans("OctoberMin"),
844
+			11 => $outputlangs->trans("NovemberMin"),
845
+			12 => $outputlangs->trans("DecemberMin")
846 846
 			);
847 847
 	}
848 848
 
Please login to merge, or discard this patch.
Spacing   +165 added lines, -165 removed lines patch added patch discarded remove patch
@@ -32,7 +32,7 @@  discard block
 block discarded – undo
32 32
  */
33 33
 function get_tz_array()
34 34
 {
35
-    $tzarray=array(
35
+    $tzarray = array(
36 36
         -11=>"Pacific/Midway",
37 37
         -10=>"Pacific/Fakaofo",
38 38
         -9=>"America/Anchorage",
@@ -79,28 +79,28 @@  discard block
 block discarded – undo
79 79
  * @param	string	$refgmtdate		Reference period for timezone (timezone differs on winter and summer. May be 'now', 'winter' or 'summer')
80 80
  * @return 	int						An offset in hour (+1 for Europe/Paris on winter and +2 for Europe/Paris on summer)
81 81
  */
82
-function getServerTimeZoneInt($refgmtdate='now')
82
+function getServerTimeZoneInt($refgmtdate = 'now')
83 83
 {
84 84
     global $conf;
85
-    if (method_exists('DateTimeZone','getOffset'))
85
+    if (method_exists('DateTimeZone', 'getOffset'))
86 86
     {
87 87
         // Method 1 (include daylight)
88
-        $gmtnow=dol_now('gmt'); $yearref=dol_print_date($gmtnow,'%Y'); $monthref=dol_print_date($gmtnow,'%m'); $dayref=dol_print_date($gmtnow,'%d');
89
-        if ($refgmtdate == 'now') $newrefgmtdate=$yearref.'-'.$monthref.'-'.$dayref;
90
-        elseif ($refgmtdate == 'summer') $newrefgmtdate=$yearref.'-08-01';
91
-        else $newrefgmtdate=$yearref.'-01-01';
92
-        $newrefgmtdate.='T00:00:00+00:00';
88
+        $gmtnow = dol_now('gmt'); $yearref = dol_print_date($gmtnow, '%Y'); $monthref = dol_print_date($gmtnow, '%m'); $dayref = dol_print_date($gmtnow, '%d');
89
+        if ($refgmtdate == 'now') $newrefgmtdate = $yearref.'-'.$monthref.'-'.$dayref;
90
+        elseif ($refgmtdate == 'summer') $newrefgmtdate = $yearref.'-08-01';
91
+        else $newrefgmtdate = $yearref.'-01-01';
92
+        $newrefgmtdate .= 'T00:00:00+00:00';
93 93
         $localtz = new DateTimeZone(getServerTimeZoneString());
94 94
         $localdt = new DateTime($newrefgmtdate, $localtz);
95
-        $tmp=-1*$localtz->getOffset($localdt);
95
+        $tmp = -1 * $localtz->getOffset($localdt);
96 96
         //print $refgmtdate.'='.$tmp;
97 97
     }
98 98
     else
99 99
     {
100
-    	$tmp=0;
101
-    	dol_print_error('','PHP version must be 5.3+');
100
+    	$tmp = 0;
101
+    	dol_print_error('', 'PHP version must be 5.3+');
102 102
     }
103
-    $tz=round(($tmp<0?1:-1)*abs($tmp/3600));
103
+    $tz = round(($tmp < 0 ? 1 : -1) * abs($tmp / 3600));
104 104
     return $tz;
105 105
 }
106 106
 
@@ -118,24 +118,24 @@  discard block
 block discarded – undo
118 118
 	global $conf;
119 119
 
120 120
 	if ($duration_value == 0)  return $time;
121
-	if ($duration_unit == 'h') return $time + (3600*$duration_value);
122
-	if ($duration_unit == 'w') return $time + (3600*24*7*$duration_value);
121
+	if ($duration_unit == 'h') return $time + (3600 * $duration_value);
122
+	if ($duration_unit == 'w') return $time + (3600 * 24 * 7 * $duration_value);
123 123
 
124
-	$deltastring='P';
124
+	$deltastring = 'P';
125 125
 
126
-	if ($duration_value > 0){ $deltastring.=abs($duration_value); $sub= false; }
127
-	if ($duration_value < 0){ $deltastring.=abs($duration_value); $sub= true; }
128
-	if ($duration_unit == 'd') { $deltastring.="D"; }
129
-	if ($duration_unit == 'm') { $deltastring.="M"; }
130
-	if ($duration_unit == 'y') { $deltastring.="Y"; }
126
+	if ($duration_value > 0) { $deltastring .= abs($duration_value); $sub = false; }
127
+	if ($duration_value < 0) { $deltastring .= abs($duration_value); $sub = true; }
128
+	if ($duration_unit == 'd') { $deltastring .= "D"; }
129
+	if ($duration_unit == 'm') { $deltastring .= "M"; }
130
+	if ($duration_unit == 'y') { $deltastring .= "Y"; }
131 131
 
132 132
 	$date = new DateTime();
133
-	if (! empty($conf->global->MAIN_DATE_IN_MEMORY_ARE_GMT)) $date->setTimezone(new DateTimeZone('UTC'));
133
+	if (!empty($conf->global->MAIN_DATE_IN_MEMORY_ARE_GMT)) $date->setTimezone(new DateTimeZone('UTC'));
134 134
 	$date->setTimestamp($time);
135 135
 	$interval = new DateInterval($deltastring);
136 136
 
137
-	if($sub) $date->sub($interval);
138
-	else $date->add( $interval );
137
+	if ($sub) $date->sub($interval);
138
+	else $date->add($interval);
139 139
 
140 140
 	return $date->getTimestamp();
141 141
 }
@@ -149,9 +149,9 @@  discard block
 block discarded – undo
149 149
  * @param      int		$iSeconds   	Seconds
150 150
  * @return     int						Time into seconds
151 151
  */
152
-function convertTime2Seconds($iHours=0,$iMinutes=0,$iSeconds=0)
152
+function convertTime2Seconds($iHours = 0, $iMinutes = 0, $iSeconds = 0)
153 153
 {
154
-	$iResult=($iHours*3600)+($iMinutes*60)+$iSeconds;
154
+	$iResult = ($iHours * 3600) + ($iMinutes * 60) + $iSeconds;
155 155
 	return $iResult;
156 156
 }
157 157
 
@@ -165,30 +165,30 @@  discard block
 block discarded – undo
165 165
  *    	@return     string		 		 	Formated text of duration
166 166
  * 	                                		Example: 0 return 00:00, 3600 return 1:00, 86400 return 1d, 90000 return 1 Day 01:00
167 167
  */
168
-function convertSecondToTime($iSecond, $format='all', $lengthOfDay=86400, $lengthOfWeek=7)
168
+function convertSecondToTime($iSecond, $format = 'all', $lengthOfDay = 86400, $lengthOfWeek = 7)
169 169
 {
170 170
 	global $langs;
171 171
 
172
-	if (empty($lengthOfDay))  $lengthOfDay = 86400;         // 1 day = 24 hours
173
-    if (empty($lengthOfWeek)) $lengthOfWeek = 7;            // 1 week = 7 days
172
+	if (empty($lengthOfDay))  $lengthOfDay = 86400; // 1 day = 24 hours
173
+    if (empty($lengthOfWeek)) $lengthOfWeek = 7; // 1 week = 7 days
174 174
 
175 175
 	if ($format == 'all' || $format == 'allwithouthour' || $format == 'allhour' || $format == 'allhourmin')
176 176
 	{
177
-		if ((int) $iSecond === 0) return '0';	// This is to avoid having 0 return a 12:00 AM for en_US
177
+		if ((int) $iSecond === 0) return '0'; // This is to avoid having 0 return a 12:00 AM for en_US
178 178
 
179
-        $sTime='';
180
-        $sDay=0;
181
-        $sWeek=0;
179
+        $sTime = '';
180
+        $sDay = 0;
181
+        $sWeek = 0;
182 182
 
183 183
 		if ($iSecond >= $lengthOfDay)
184 184
 		{
185
-			for($i = $iSecond; $i >= $lengthOfDay; $i -= $lengthOfDay )
185
+			for ($i = $iSecond; $i >= $lengthOfDay; $i -= $lengthOfDay)
186 186
 			{
187 187
 				$sDay++;
188
-				$iSecond-=$lengthOfDay;
188
+				$iSecond -= $lengthOfDay;
189 189
 			}
190 190
 			$dayTranslate = $langs->trans("Day");
191
-			if ($iSecond >= ($lengthOfDay*2)) $dayTranslate = $langs->trans("Days");
191
+			if ($iSecond >= ($lengthOfDay * 2)) $dayTranslate = $langs->trans("Days");
192 192
 		}
193 193
 
194 194
 		if ($lengthOfWeek < 7)
@@ -197,66 +197,66 @@  discard block
 block discarded – undo
197 197
             {
198 198
                 if ($sDay >= $lengthOfWeek)
199 199
                 {
200
-                    $sWeek = (int) (($sDay - $sDay % $lengthOfWeek ) / $lengthOfWeek);
200
+                    $sWeek = (int) (($sDay - $sDay % $lengthOfWeek) / $lengthOfWeek);
201 201
                     $sDay = $sDay % $lengthOfWeek;
202 202
                     $weekTranslate = $langs->trans("DurationWeek");
203 203
                     if ($sWeek >= 2) $weekTranslate = $langs->trans("DurationWeeks");
204
-                    $sTime.=$sWeek.' '.$weekTranslate.' ';
204
+                    $sTime .= $sWeek.' '.$weekTranslate.' ';
205 205
                 }
206 206
             }
207 207
 		}
208
-		if ($sDay>0)
208
+		if ($sDay > 0)
209 209
 		{
210 210
 			$dayTranslate = $langs->trans("Day");
211 211
 			if ($sDay > 1) $dayTranslate = $langs->trans("Days");
212
-			$sTime.=$sDay.' '.$dayTranslate.' ';
212
+			$sTime .= $sDay.' '.$dayTranslate.' ';
213 213
 		}
214 214
 
215 215
 		if ($format == 'all')
216 216
 		{
217 217
 			if ($iSecond || empty($sDay))
218 218
 			{
219
-				$sTime.= dol_print_date($iSecond,'hourduration',true);
219
+				$sTime .= dol_print_date($iSecond, 'hourduration', true);
220 220
 			}
221 221
 		}
222 222
 		if ($format == 'allhourmin')
223 223
 		{
224
-		    return sprintf("%02d",($sWeek*$lengthOfWeek*24 + $sDay*24 + (int) floor($iSecond/3600))).':'.sprintf("%02d",((int) floor(($iSecond % 3600)/60)));
224
+		    return sprintf("%02d", ($sWeek * $lengthOfWeek * 24 + $sDay * 24 + (int) floor($iSecond / 3600))).':'.sprintf("%02d", ((int) floor(($iSecond % 3600) / 60)));
225 225
 		}
226 226
 		if ($format == 'allhour')
227 227
 		{
228
-			return sprintf("%02d",($sWeek*$lengthOfWeek*24 + $sDay*24 + (int) floor($iSecond/3600)));
228
+			return sprintf("%02d", ($sWeek * $lengthOfWeek * 24 + $sDay * 24 + (int) floor($iSecond / 3600)));
229 229
 		}
230 230
 	}
231 231
 	else if ($format == 'hour')	// only hour part
232 232
 	{
233
-		$sTime=dol_print_date($iSecond,'%H',true);
233
+		$sTime = dol_print_date($iSecond, '%H', true);
234 234
 	}
235 235
 	else if ($format == 'fullhour')
236 236
 	{
237 237
 		if (!empty($iSecond)) {
238
-			$iSecond=$iSecond/3600;
238
+			$iSecond = $iSecond / 3600;
239 239
 		}
240 240
 		else {
241
-			$iSecond=0;
241
+			$iSecond = 0;
242 242
 		}
243
-		$sTime=$iSecond;
243
+		$sTime = $iSecond;
244 244
 	}
245 245
 	else if ($format == 'min')	// only min part
246 246
 	{
247
-		$sTime=dol_print_date($iSecond,'%M',true);
247
+		$sTime = dol_print_date($iSecond, '%M', true);
248 248
 	}
249 249
     else if ($format == 'sec')	// only sec part
250 250
     {
251
-        $sTime=dol_print_date($iSecond,'%S',true);
251
+        $sTime = dol_print_date($iSecond, '%S', true);
252 252
     }
253 253
     else if ($format == 'month')	// only month part
254 254
     {
255
-        $sTime=dol_print_date($iSecond,'%m',true);
255
+        $sTime = dol_print_date($iSecond, '%m', true);
256 256
     }
257 257
     else if ($format == 'year')	// only year part
258 258
     {
259
-        $sTime=dol_print_date($iSecond,'%Y',true);
259
+        $sTime = dol_print_date($iSecond, '%Y', true);
260 260
     }
261 261
     return trim($sTime);
262 262
 }
@@ -280,10 +280,10 @@  discard block
 block discarded – undo
280 280
  *
281 281
  *  @see    dol_print_date, dol_mktime, dol_getdate
282 282
  */
283
-function dol_stringtotime($string, $gm=1)
283
+function dol_stringtotime($string, $gm = 1)
284 284
 {
285 285
     // Convert date with format DD/MM/YYY HH:MM:SS. This part of code should not be used.
286
-    if (preg_match('/^([0-9]+)\/([0-9]+)\/([0-9]+)\s?([0-9]+)?:?([0-9]+)?:?([0-9]+)?/i',$string,$reg))
286
+    if (preg_match('/^([0-9]+)\/([0-9]+)\/([0-9]+)\s?([0-9]+)?:?([0-9]+)?:?([0-9]+)?/i', $string, $reg))
287 287
     {
288 288
         dol_syslog("dol_stringtotime call to function with deprecated parameter format", LOG_WARNING);
289 289
         // Date est au format 'DD/MM/YY' ou 'DD/MM/YY HH:MM:SS'
@@ -294,14 +294,14 @@  discard block
 block discarded – undo
294 294
         $shour = $reg[4];
295 295
         $smin = $reg[5];
296 296
         $ssec = $reg[6];
297
-        if ($syear < 50) $syear+=1900;
298
-        if ($syear >= 50 && $syear < 100) $syear+=2000;
299
-        $string=sprintf("%04d%02d%02d%02d%02d%02d",$syear,$smonth,$sday,$shour,$smin,$ssec);
297
+        if ($syear < 50) $syear += 1900;
298
+        if ($syear >= 50 && $syear < 100) $syear += 2000;
299
+        $string = sprintf("%04d%02d%02d%02d%02d%02d", $syear, $smonth, $sday, $shour, $smin, $ssec);
300 300
     }
301 301
     else if (
302
-    	   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)
303
-    	|| 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
304
-   		|| 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
302
+    	   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)
303
+    	|| 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
304
+   		|| 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
305 305
     )
306 306
     {
307 307
         $syear = $reg[1];
@@ -310,12 +310,12 @@  discard block
 block discarded – undo
310 310
         $shour = $reg[4];
311 311
         $smin = $reg[5];
312 312
         $ssec = $reg[6];
313
-        $string=sprintf("%04d%02d%02d%02d%02d%02d",$syear,$smonth,$sday,$shour,$smin,$ssec);
313
+        $string = sprintf("%04d%02d%02d%02d%02d%02d", $syear, $smonth, $sday, $shour, $smin, $ssec);
314 314
     }
315 315
 
316
-    $string=preg_replace('/([^0-9])/i','',$string);
317
-    $tmp=$string.'000000';
318
-    $date=dol_mktime(substr($tmp,8,2),substr($tmp,10,2),substr($tmp,12,2),substr($tmp,4,2),substr($tmp,6,2),substr($tmp,0,4),($gm?1:0));
316
+    $string = preg_replace('/([^0-9])/i', '', $string);
317
+    $tmp = $string.'000000';
318
+    $date = dol_mktime(substr($tmp, 8, 2), substr($tmp, 10, 2), substr($tmp, 12, 2), substr($tmp, 4, 2), substr($tmp, 6, 2), substr($tmp, 0, 4), ($gm ? 1 : 0));
319 319
     return $date;
320 320
 }
321 321
 
@@ -329,9 +329,9 @@  discard block
 block discarded – undo
329 329
  */
330 330
 function dol_get_prev_day($day, $month, $year)
331 331
 {
332
-	$time=dol_mktime(12,0,0,$month,$day,$year,1,0);
333
-	$time-=24*60*60;
334
-	$tmparray=dol_getdate($time,true);
332
+	$time = dol_mktime(12, 0, 0, $month, $day, $year, 1, 0);
333
+	$time -= 24 * 60 * 60;
334
+	$tmparray = dol_getdate($time, true);
335 335
 	return array('year' => $tmparray['year'], 'month' => $tmparray['mon'], 'day' => $tmparray['mday']);
336 336
 }
337 337
 
@@ -344,9 +344,9 @@  discard block
 block discarded – undo
344 344
  */
345 345
 function dol_get_next_day($day, $month, $year)
346 346
 {
347
-	$time=dol_mktime(12,0,0,$month,$day,$year,1,0);
348
-	$time+=24*60*60;
349
-	$tmparray=dol_getdate($time,true);
347
+	$time = dol_mktime(12, 0, 0, $month, $day, $year, 1, 0);
348
+	$time += 24 * 60 * 60;
349
+	$tmparray = dol_getdate($time, true);
350 350
 	return array('year' => $tmparray['year'], 'month' => $tmparray['mon'], 'day' => $tmparray['mday']);
351 351
 }
352 352
 
@@ -365,7 +365,7 @@  discard block
 block discarded – undo
365 365
 	}
366 366
 	else
367 367
 	{
368
-		$prev_month = $month-1;
368
+		$prev_month = $month - 1;
369 369
 		$prev_year  = $year;
370 370
 	}
371 371
 	return array('year' => $prev_year, 'month' => $prev_month);
@@ -404,9 +404,9 @@  discard block
 block discarded – undo
404 404
 {
405 405
 	$tmparray = dol_get_first_day_week($day, $month, $year);
406 406
 
407
-	$time=dol_mktime(12,0,0,$month,$tmparray['first_day'],$year,1,0);
408
-	$time-=24*60*60*7;
409
-	$tmparray=dol_getdate($time,true);
407
+	$time = dol_mktime(12, 0, 0, $month, $tmparray['first_day'], $year, 1, 0);
408
+	$time -= 24 * 60 * 60 * 7;
409
+	$tmparray = dol_getdate($time, true);
410 410
 	return array('year' => $tmparray['year'], 'month' => $tmparray['mon'], 'day' => $tmparray['mday']);
411 411
 }
412 412
 
@@ -422,9 +422,9 @@  discard block
 block discarded – undo
422 422
 {
423 423
 	$tmparray = dol_get_first_day_week($day, $month, $year);
424 424
 
425
-	$time=dol_mktime(12,0,0,$tmparray['first_month'],$tmparray['first_day'],$tmparray['first_year'],1,0);
426
-	$time+=24*60*60*7;
427
-	$tmparray=dol_getdate($time,true);
425
+	$time = dol_mktime(12, 0, 0, $tmparray['first_month'], $tmparray['first_day'], $tmparray['first_year'], 1, 0);
426
+	$time += 24 * 60 * 60 * 7;
427
+	$tmparray = dol_getdate($time, true);
428 428
 
429 429
 	return array('year' => $tmparray['year'], 'month' => $tmparray['mon'], 'day' => $tmparray['mday']);
430 430
 
@@ -439,10 +439,10 @@  discard block
 block discarded – undo
439 439
  *                          			Exemple: dol_get_first_day(1970,1,true) will return 0 whatever is TZ, after a dol_print_date will return 1970-01-01 00:00:00
440 440
  *  @return		int						Date for first day, '' if error
441 441
  */
442
-function dol_get_first_day($year,$month=1,$gm=false)
442
+function dol_get_first_day($year, $month = 1, $gm = false)
443 443
 {
444 444
 	if ($year > 9999) return '';
445
-	return dol_mktime(0,0,0,$month,1,$year,$gm);
445
+	return dol_mktime(0, 0, 0, $month, 1, $year, $gm);
446 446
 }
447 447
 
448 448
 
@@ -453,7 +453,7 @@  discard block
 block discarded – undo
453 453
  * 	@param		boolean		$gm			False or 0 or 'server' = Return date to compare with server TZ, True or 1 to compare with GM date.
454 454
  *	@return		int						Date for first day, '' if error
455 455
  */
456
-function dol_get_last_day($year,$month=12,$gm=false)
456
+function dol_get_last_day($year, $month = 12, $gm = false)
457 457
 {
458 458
 	if ($year > 9999) return '';
459 459
 	if ($month == 12)
@@ -467,7 +467,7 @@  discard block
 block discarded – undo
467 467
 	}
468 468
 
469 469
 	// On se deplace au debut du mois suivant, et on retire un jour
470
-	$datelim=dol_mktime(23,59,59,$month,1,$year,$gm);
470
+	$datelim = dol_mktime(23, 59, 59, $month, 1, $year, $gm);
471 471
 	$datelim -= (3600 * 24);
472 472
 
473 473
 	return $datelim;
@@ -481,69 +481,69 @@  discard block
 block discarded – undo
481 481
  * 	@param		int		$gm			False or 0 or 'server' = Return date to compare with server TZ, True or 1 to compare with GM date.
482 482
  *	@return		array				year,month,week,first_day,first_month,first_year,prev_day,prev_month,prev_year
483 483
  */
484
-function dol_get_first_day_week($day,$month,$year,$gm=false)
484
+function dol_get_first_day_week($day, $month, $year, $gm = false)
485 485
 {
486 486
 	global $conf;
487 487
 
488 488
 	//$day=2; $month=2; $year=2015;
489
-	$date = dol_mktime(0,0,0,$month,$day,$year,$gm);
489
+	$date = dol_mktime(0, 0, 0, $month, $day, $year, $gm);
490 490
 
491 491
 	//Checking conf of start week
492
-	$start_week = (isset($conf->global->MAIN_START_WEEK)?$conf->global->MAIN_START_WEEK:1);
492
+	$start_week = (isset($conf->global->MAIN_START_WEEK) ? $conf->global->MAIN_START_WEEK : 1);
493 493
 
494
-	$tmparray = dol_getdate($date,true);	// detail of current day
494
+	$tmparray = dol_getdate($date, true); // detail of current day
495 495
 
496 496
 	//Calculate days = offset from current day
497 497
 	$days = $start_week - $tmparray['wday'];
498
- 	if ($days>=1) $days=7-$days;
498
+ 	if ($days >= 1) $days = 7 - $days;
499 499
  	$days = abs($days);
500
-    $seconds = $days*24*60*60;
500
+    $seconds = $days * 24 * 60 * 60;
501 501
 	//print 'start_week='.$start_week.' tmparray[wday]='.$tmparray['wday'].' day offset='.$days.' seconds offset='.$seconds.'<br>';
502 502
 
503 503
     //Get first day of week
504
-    $tmpdaytms = date($tmparray[0])-$seconds; // $tmparray[0] is day of parameters
505
-	$tmpday = date("d",$tmpdaytms);
504
+    $tmpdaytms = date($tmparray[0]) - $seconds; // $tmparray[0] is day of parameters
505
+	$tmpday = date("d", $tmpdaytms);
506 506
 
507 507
 	//Check first day of week is in same month than current day or not
508
-	if ($tmpday>$day)
508
+	if ($tmpday > $day)
509 509
     {
510
-    	$prev_month = $month-1;
511
-		$prev_year  = $year;
510
+    	$prev_month = $month - 1;
511
+		$prev_year = $year;
512 512
 
513
-    	if ($prev_month==0)
513
+    	if ($prev_month == 0)
514 514
     	{
515 515
     		$prev_month = 12;
516
-    		$prev_year  = $year-1;
516
+    		$prev_year  = $year - 1;
517 517
     	}
518 518
     }
519 519
     else
520 520
     {
521 521
     	$prev_month = $month;
522
-		$prev_year  = $year;
522
+		$prev_year = $year;
523 523
     }
524 524
 	$tmpmonth = $prev_month;
525 525
 	$tmpyear = $prev_year;
526 526
 
527 527
 	//Get first day of next week
528
-	$tmptime=dol_mktime(12,0,0,$month,$tmpday,$year,1,0);
529
-	$tmptime-=24*60*60*7;
530
-	$tmparray=dol_getdate($tmptime,true);
531
-    $prev_day   = $tmparray['mday'];
528
+	$tmptime = dol_mktime(12, 0, 0, $month, $tmpday, $year, 1, 0);
529
+	$tmptime -= 24 * 60 * 60 * 7;
530
+	$tmparray = dol_getdate($tmptime, true);
531
+    $prev_day = $tmparray['mday'];
532 532
 
533 533
     //Check prev day of week is in same month than first day or not
534 534
 	if ($prev_day > $tmpday)
535 535
     {
536
-    	$prev_month = $month-1;
537
-		$prev_year  = $year;
536
+    	$prev_month = $month - 1;
537
+		$prev_year = $year;
538 538
 
539
-    	if ($prev_month==0)
539
+    	if ($prev_month == 0)
540 540
     	{
541 541
     		$prev_month = 12;
542
-    		$prev_year  = $year-1;
542
+    		$prev_year  = $year - 1;
543 543
     	}
544 544
     }
545 545
 
546
-    $week = date("W",dol_mktime(0,0,0,$tmpmonth,$tmpday,$tmpyear,$gm));
546
+    $week = date("W", dol_mktime(0, 0, 0, $tmpmonth, $tmpday, $tmpyear, $gm));
547 547
 
548 548
 	return array('year' => $year, 'month' => $month, 'week' => $week, 'first_day' => $tmpday, 'first_month' => $tmpmonth, 'first_year' => $tmpyear, 'prev_year' => $prev_year, 'prev_month' => $prev_month, 'prev_day' => $prev_day);
549 549
 }
@@ -559,42 +559,42 @@  discard block
 block discarded – undo
559 559
  *	@return   	int								Nombre de jours feries
560 560
  *  @see num_between_day, num_open_day
561 561
  */
562
-function num_public_holiday($timestampStart, $timestampEnd, $countrycode='FR', $lastday=0)
562
+function num_public_holiday($timestampStart, $timestampEnd, $countrycode = 'FR', $lastday = 0)
563 563
 {
564 564
 	$nbFerie = 0;
565 565
 
566 566
 	// Check to ensure we use correct parameters
567 567
 	if ((($timestampEnd - $timestampStart) % 86400) != 0) return 'ErrorDates must use same hours and must be GMT dates';
568 568
 
569
-	$i=0;
570
-	while (( ($lastday == 0 && $timestampStart < $timestampEnd) || ($lastday && $timestampStart <= $timestampEnd) )
569
+	$i = 0;
570
+	while ((($lastday == 0 && $timestampStart < $timestampEnd) || ($lastday && $timestampStart <= $timestampEnd))
571 571
 	    && ($i < 50000))		// Loop end when equals (Test on i is a security loop to avoid infinite loop)
572 572
 	{
573
-		$ferie=false;
574
-		$countryfound=0;
573
+		$ferie = false;
574
+		$countryfound = 0;
575 575
 
576 576
 		$jour  = date("d", $timestampStart);
577 577
 		$mois  = date("m", $timestampStart);
578 578
 		$annee = date("Y", $timestampStart);
579 579
 		if ($countrycode == 'FR')
580 580
 		{
581
-			$countryfound=1;
581
+			$countryfound = 1;
582 582
 
583 583
 			// Definition des dates feriees fixes
584
-			if($jour == 1 && $mois == 1)   $ferie=true; // 1er janvier
585
-			if($jour == 1 && $mois == 5)   $ferie=true; // 1er mai
586
-			if($jour == 8 && $mois == 5)   $ferie=true; // 5 mai
587
-			if($jour == 14 && $mois == 7)  $ferie=true; // 14 juillet
588
-			if($jour == 15 && $mois == 8)  $ferie=true; // 15 aout
589
-			if($jour == 1 && $mois == 11)  $ferie=true; // 1 novembre
590
-			if($jour == 11 && $mois == 11) $ferie=true; // 11 novembre
591
-			if($jour == 25 && $mois == 12) $ferie=true; // 25 decembre
584
+			if ($jour == 1 && $mois == 1)   $ferie = true; // 1er janvier
585
+			if ($jour == 1 && $mois == 5)   $ferie = true; // 1er mai
586
+			if ($jour == 8 && $mois == 5)   $ferie = true; // 5 mai
587
+			if ($jour == 14 && $mois == 7)  $ferie = true; // 14 juillet
588
+			if ($jour == 15 && $mois == 8)  $ferie = true; // 15 aout
589
+			if ($jour == 1 && $mois == 11)  $ferie = true; // 1 novembre
590
+			if ($jour == 11 && $mois == 11) $ferie = true; // 11 novembre
591
+			if ($jour == 25 && $mois == 12) $ferie = true; // 25 decembre
592 592
 
593 593
 			// Calcul du jour de paques
594 594
 			$date_paques = easter_date($annee);
595 595
 			$jour_paques = date("d", $date_paques);
596 596
 			$mois_paques = date("m", $date_paques);
597
-			if($jour_paques == $jour && $mois_paques == $mois) $ferie=true;
597
+			if ($jour_paques == $jour && $mois_paques == $mois) $ferie = true;
598 598
 			// Paques
599 599
 
600 600
 			// Calcul du jour de l ascension (38 jours apres Paques)
@@ -608,7 +608,7 @@  discard block
 block discarded – undo
608 608
             );
609 609
 			$jour_ascension = date("d", $date_ascension);
610 610
 			$mois_ascension = date("m", $date_ascension);
611
-			if($jour_ascension == $jour && $mois_ascension == $mois) $ferie=true;
611
+			if ($jour_ascension == $jour && $mois_ascension == $mois) $ferie = true;
612 612
 			//Ascension
613 613
 
614 614
 			// Calcul de Pentecote (11 jours apres Paques)
@@ -622,13 +622,13 @@  discard block
 block discarded – undo
622 622
             );
623 623
 			$jour_pentecote = date("d", $date_pentecote);
624 624
 			$mois_pentecote = date("m", $date_pentecote);
625
-			if($jour_pentecote == $jour && $mois_pentecote == $mois) $ferie=true;
625
+			if ($jour_pentecote == $jour && $mois_pentecote == $mois) $ferie = true;
626 626
 			//Pentecote
627 627
 
628 628
 			// Calul des samedis et dimanches
629 629
 			$jour_julien = unixtojd($timestampStart);
630 630
 			$jour_semaine = jddayofweek($jour_julien, 0);
631
-			if($jour_semaine == 0 || $jour_semaine == 6) $ferie=true;
631
+			if ($jour_semaine == 0 || $jour_semaine == 6) $ferie = true;
632 632
 			//Samedi (6) et dimanche (0)
633 633
 		}
634 634
 
@@ -636,54 +636,54 @@  discard block
 block discarded – undo
636 636
 		// Pentecoste is 50 days after Easter, Ascensione 40
637 637
 		if ($countrycode == 'IT')
638 638
 		{
639
-			$countryfound=1;
639
+			$countryfound = 1;
640 640
 
641 641
 			// Definition des dates feriees fixes
642
-			if($jour == 1 && $mois == 1) $ferie=true; // Capodanno
643
-			if($jour == 6 && $mois == 1) $ferie=true; // Epifania
644
-			if($jour == 25 && $mois == 4) $ferie=true; // Anniversario Liberazione
645
-			if($jour == 1 && $mois == 5) $ferie=true; // Festa del Lavoro
646
-			if($jour == 2 && $mois == 6) $ferie=true; // Festa della Repubblica
647
-			if($jour == 15 && $mois == 8) $ferie=true; // Ferragosto
648
-			if($jour == 1 && $mois == 11) $ferie=true; // Tutti i Santi
649
-			if($jour == 8 && $mois == 12) $ferie=true; // Immacolata Concezione
650
-			if($jour == 25 && $mois == 12) $ferie=true; // 25 decembre
651
-			if($jour == 26 && $mois == 12) $ferie=true; // Santo Stefano
642
+			if ($jour == 1 && $mois == 1) $ferie = true; // Capodanno
643
+			if ($jour == 6 && $mois == 1) $ferie = true; // Epifania
644
+			if ($jour == 25 && $mois == 4) $ferie = true; // Anniversario Liberazione
645
+			if ($jour == 1 && $mois == 5) $ferie = true; // Festa del Lavoro
646
+			if ($jour == 2 && $mois == 6) $ferie = true; // Festa della Repubblica
647
+			if ($jour == 15 && $mois == 8) $ferie = true; // Ferragosto
648
+			if ($jour == 1 && $mois == 11) $ferie = true; // Tutti i Santi
649
+			if ($jour == 8 && $mois == 12) $ferie = true; // Immacolata Concezione
650
+			if ($jour == 25 && $mois == 12) $ferie = true; // 25 decembre
651
+			if ($jour == 26 && $mois == 12) $ferie = true; // Santo Stefano
652 652
 
653 653
 			// Calcul du jour de paques
654 654
 			$date_paques = easter_date($annee);
655 655
 			$jour_paques = date("d", $date_paques);
656 656
 			$mois_paques = date("m", $date_paques);
657
-			if($jour_paques == $jour && $mois_paques == $mois) $ferie=true;
657
+			if ($jour_paques == $jour && $mois_paques == $mois) $ferie = true;
658 658
 			// Paques
659 659
 
660 660
 			// Calul des samedis et dimanches
661 661
 			$jour_julien = unixtojd($timestampStart);
662 662
 			$jour_semaine = jddayofweek($jour_julien, 0);
663
-			if($jour_semaine == 0 || $jour_semaine == 6) $ferie=true;
663
+			if ($jour_semaine == 0 || $jour_semaine == 6) $ferie = true;
664 664
 			//Samedi (6) et dimanche (0)
665 665
 		}
666 666
 
667 667
 		if ($countrycode == 'ES')
668 668
 		{
669
-			$countryfound=1;
669
+			$countryfound = 1;
670 670
 
671 671
 			// Definition des dates feriees fixes
672
-			if($jour == 1 && $mois == 1)   $ferie=true; // Año nuevo
673
-			if($jour == 6 && $mois == 1)   $ferie=true; // Día Reyes
674
-			if($jour == 1 && $mois == 5)   $ferie=true; // 1 Mayo
675
-			if($jour == 15 && $mois == 8)  $ferie=true; // 15 Agosto
676
-			if($jour == 12 && $mois == 10)  $ferie=true; // Día Hispanidad
677
-			if($jour == 1 && $mois == 11)  $ferie=true; // 1 noviembre
678
-			if($jour == 6 && $mois == 12) $ferie=true; // Constitución
679
-			if($jour == 8 && $mois == 12)  $ferie=true; // Inmaculada
680
-			if($jour == 25 && $mois == 12) $ferie=true; // 25 diciembre
672
+			if ($jour == 1 && $mois == 1)   $ferie = true; // Año nuevo
673
+			if ($jour == 6 && $mois == 1)   $ferie = true; // Día Reyes
674
+			if ($jour == 1 && $mois == 5)   $ferie = true; // 1 Mayo
675
+			if ($jour == 15 && $mois == 8)  $ferie = true; // 15 Agosto
676
+			if ($jour == 12 && $mois == 10)  $ferie = true; // Día Hispanidad
677
+			if ($jour == 1 && $mois == 11)  $ferie = true; // 1 noviembre
678
+			if ($jour == 6 && $mois == 12) $ferie = true; // Constitución
679
+			if ($jour == 8 && $mois == 12)  $ferie = true; // Inmaculada
680
+			if ($jour == 25 && $mois == 12) $ferie = true; // 25 diciembre
681 681
 
682 682
 			// Calcul día de Pascua
683 683
 			$date_paques = easter_date($annee);
684 684
 			$jour_paques = date("d", $date_paques);
685 685
 			$mois_paques = date("m", $date_paques);
686
-			if($jour_paques == $jour && $mois_paques == $mois) $ferie=true;
686
+			if ($jour_paques == $jour && $mois_paques == $mois) $ferie = true;
687 687
 			// Paques
688 688
 
689 689
 			// Viernes Santo
@@ -692,28 +692,28 @@  discard block
 block discarded – undo
692 692
                 date("i", $date_paques),
693 693
                 date("s", $date_paques),
694 694
                 date("m", $date_paques),
695
-                date("d", $date_paques) -2,
695
+                date("d", $date_paques) - 2,
696 696
                 date("Y", $date_paques)
697 697
             );
698 698
 			$jour_viernes = date("d", $date_viernes);
699 699
 			$mois_viernes = date("m", $date_viernes);
700
-			if($jour_viernes == $jour && $mois_viernes == $mois) $ferie=true;
700
+			if ($jour_viernes == $jour && $mois_viernes == $mois) $ferie = true;
701 701
 			//Viernes Santo
702 702
 
703 703
 			// Calul des samedis et dimanches
704 704
 			$jour_julien = unixtojd($timestampStart);
705 705
 			$jour_semaine = jddayofweek($jour_julien, 0);
706
-			if($jour_semaine == 0 || $jour_semaine == 6) $ferie=true;
706
+			if ($jour_semaine == 0 || $jour_semaine == 6) $ferie = true;
707 707
 			//Samedi (6) et dimanche (0)
708 708
 		}
709 709
 
710 710
 		// Cas pays non defini
711
-		if (! $countryfound)
711
+		if (!$countryfound)
712 712
 		{
713 713
 			// Calul des samedis et dimanches
714 714
 			$jour_julien = unixtojd($timestampStart);
715 715
 			$jour_semaine = jddayofweek($jour_julien, 0);
716
-			if($jour_semaine == 0 || $jour_semaine == 6) $ferie=true;
716
+			if ($jour_semaine == 0 || $jour_semaine == 6) $ferie = true;
717 717
 			//Samedi (6) et dimanche (0)
718 718
 		}
719 719
 
@@ -721,7 +721,7 @@  discard block
 block discarded – undo
721 721
 		if ($ferie) $nbFerie++;
722 722
 
723 723
 		// Increase number of days (on go up into loop)
724
-		$timestampStart=dol_time_plus_duree($timestampStart, 1, 'd');
724
+		$timestampStart = dol_time_plus_duree($timestampStart, 1, 'd');
725 725
 		//var_dump($jour.' '.$mois.' '.$annee.' '.$timestampStart);
726 726
 
727 727
 		$i++;
@@ -740,7 +740,7 @@  discard block
 block discarded – undo
740 740
  *	@return    int								Number of days
741 741
  *  @see also num_public_holiday, num_open_day
742 742
  */
743
-function num_between_day($timestampStart, $timestampEnd, $lastday=0)
743
+function num_between_day($timestampStart, $timestampEnd, $lastday = 0)
744 744
 {
745 745
 	if ($timestampStart < $timestampEnd)
746 746
 	{
@@ -752,7 +752,7 @@  discard block
 block discarded – undo
752 752
 		{
753 753
 			$bit = 1;
754 754
 		}
755
-		$nbjours = (int) floor(($timestampEnd - $timestampStart)/(60*60*24)) + 1 - $bit;
755
+		$nbjours = (int) floor(($timestampEnd - $timestampStart) / (60 * 60 * 24)) + 1 - $bit;
756 756
 	}
757 757
 	//print ($timestampEnd - $timestampStart) - $lastday;
758 758
 	return $nbjours;
@@ -770,17 +770,17 @@  discard block
 block discarded – undo
770 770
  *	@return    	int								Number of days or hours
771 771
  *  @see also num_between_day, num_public_holiday
772 772
  */
773
-function num_open_day($timestampStart, $timestampEnd, $inhour=0, $lastday=0, $halfday=0, $country_code='')
773
+function num_open_day($timestampStart, $timestampEnd, $inhour = 0, $lastday = 0, $halfday = 0, $country_code = '')
774 774
 {
775
-	global $langs,$mysoc;
775
+	global $langs, $mysoc;
776 776
 
777
-	if (empty($country_code)) $country_code=$mysoc->country_code;
777
+	if (empty($country_code)) $country_code = $mysoc->country_code;
778 778
 
779 779
 	dol_syslog('num_open_day timestampStart='.$timestampStart.' timestampEnd='.$timestampEnd.' bit='.$lastday.' country_code='.$country_code);
780 780
 
781 781
 	// Check parameters
782
-	if (! is_int($timestampStart) && ! is_float($timestampStart)) return 'ErrorBadParameter_num_open_day';
783
-	if (! is_int($timestampEnd) && ! is_float($timestampEnd)) return 'ErrorBadParameter_num_open_day';
782
+	if (!is_int($timestampStart) && !is_float($timestampStart)) return 'ErrorBadParameter_num_open_day';
783
+	if (!is_int($timestampEnd) && !is_float($timestampEnd)) return 'ErrorBadParameter_num_open_day';
784 784
 
785 785
 	//print 'num_open_day timestampStart='.$timestampStart.' timestampEnd='.$timestampEnd.' bit='.$lastday;
786 786
 	if ($timestampStart < $timestampEnd)
@@ -788,14 +788,14 @@  discard block
 block discarded – undo
788 788
 		$numdays = num_between_day($timestampStart, $timestampEnd, $lastday);
789 789
 		$numholidays = num_public_holiday($timestampStart, $timestampEnd, $country_code, $lastday);
790 790
 		$nbOpenDay = $numdays - $numholidays;
791
-		$nbOpenDay.= " " . $langs->trans("Days");
792
-		if ($inhour == 1 && $nbOpenDay <= 3) $nbOpenDay = $nbOpenDay*24 . $langs->trans("HourShort");
791
+		$nbOpenDay .= " ".$langs->trans("Days");
792
+		if ($inhour == 1 && $nbOpenDay <= 3) $nbOpenDay = $nbOpenDay * 24.$langs->trans("HourShort");
793 793
 		return $nbOpenDay - (($inhour == 1 ? 12 : 0.5) * abs($halfday));
794 794
 	}
795 795
 	elseif ($timestampStart == $timestampEnd)
796 796
 	{
797
-		$nbOpenDay=$lastday;
798
-		if ($inhour == 1) $nbOpenDay = $nbOpenDay*24 . $langs->trans("HourShort");
797
+		$nbOpenDay = $lastday;
798
+		if ($inhour == 1) $nbOpenDay = $nbOpenDay * 24.$langs->trans("HourShort");
799 799
 		return $nbOpenDay - (($inhour == 1 ? 12 : 0.5) * abs($halfday));
800 800
 	}
801 801
 	else
@@ -814,9 +814,9 @@  discard block
 block discarded – undo
814 814
  *  @param	int			$short			1=Return short label
815 815
  *	@return array						Month string or array if selected < 0
816 816
  */
817
-function monthArray($outputlangs,$short=0)
817
+function monthArray($outputlangs, $short = 0)
818 818
 {
819
-	$montharray = array (
819
+	$montharray = array(
820 820
 	    1  => $outputlangs->trans("January"),
821 821
 	    2  => $outputlangs->trans("February"),
822 822
 	    3  => $outputlangs->trans("March"),
@@ -831,9 +831,9 @@  discard block
 block discarded – undo
831 831
 	    12 => $outputlangs->trans("December")
832 832
     );
833 833
 
834
-	if (! empty($short))
834
+	if (!empty($short))
835 835
 	{
836
-		$montharray = array (
836
+		$montharray = array(
837 837
 		    1  => $outputlangs->trans("JanuaryMin"),
838 838
 		    2  => $outputlangs->trans("FebruaryMin"),
839 839
 		    3  => $outputlangs->trans("MarchMin"),
Please login to merge, or discard this patch.
Braces   +244 added lines, -93 removed lines patch added patch discarded remove patch
@@ -86,16 +86,19 @@  discard block
 block discarded – undo
86 86
     {
87 87
         // Method 1 (include daylight)
88 88
         $gmtnow=dol_now('gmt'); $yearref=dol_print_date($gmtnow,'%Y'); $monthref=dol_print_date($gmtnow,'%m'); $dayref=dol_print_date($gmtnow,'%d');
89
-        if ($refgmtdate == 'now') $newrefgmtdate=$yearref.'-'.$monthref.'-'.$dayref;
90
-        elseif ($refgmtdate == 'summer') $newrefgmtdate=$yearref.'-08-01';
91
-        else $newrefgmtdate=$yearref.'-01-01';
89
+        if ($refgmtdate == 'now') {
90
+        	$newrefgmtdate=$yearref.'-'.$monthref.'-'.$dayref;
91
+        } elseif ($refgmtdate == 'summer') {
92
+        	$newrefgmtdate=$yearref.'-08-01';
93
+        } else {
94
+        	$newrefgmtdate=$yearref.'-01-01';
95
+        }
92 96
         $newrefgmtdate.='T00:00:00+00:00';
93 97
         $localtz = new DateTimeZone(getServerTimeZoneString());
94 98
         $localdt = new DateTime($newrefgmtdate, $localtz);
95 99
         $tmp=-1*$localtz->getOffset($localdt);
96 100
         //print $refgmtdate.'='.$tmp;
97
-    }
98
-    else
101
+    } else
99 102
     {
100 103
     	$tmp=0;
101 104
     	dol_print_error('','PHP version must be 5.3+');
@@ -117,9 +120,15 @@  discard block
 block discarded – undo
117 120
 {
118 121
 	global $conf;
119 122
 
120
-	if ($duration_value == 0)  return $time;
121
-	if ($duration_unit == 'h') return $time + (3600*$duration_value);
122
-	if ($duration_unit == 'w') return $time + (3600*24*7*$duration_value);
123
+	if ($duration_value == 0) {
124
+		return $time;
125
+	}
126
+	if ($duration_unit == 'h') {
127
+		return $time + (3600*$duration_value);
128
+	}
129
+	if ($duration_unit == 'w') {
130
+		return $time + (3600*24*7*$duration_value);
131
+	}
123 132
 
124 133
 	$deltastring='P';
125 134
 
@@ -130,12 +139,17 @@  discard block
 block discarded – undo
130 139
 	if ($duration_unit == 'y') { $deltastring.="Y"; }
131 140
 
132 141
 	$date = new DateTime();
133
-	if (! empty($conf->global->MAIN_DATE_IN_MEMORY_ARE_GMT)) $date->setTimezone(new DateTimeZone('UTC'));
142
+	if (! empty($conf->global->MAIN_DATE_IN_MEMORY_ARE_GMT)) {
143
+		$date->setTimezone(new DateTimeZone('UTC'));
144
+	}
134 145
 	$date->setTimestamp($time);
135 146
 	$interval = new DateInterval($deltastring);
136 147
 
137
-	if($sub) $date->sub($interval);
138
-	else $date->add( $interval );
148
+	if($sub) {
149
+		$date->sub($interval);
150
+	} else {
151
+		$date->add( $interval );
152
+	}
139 153
 
140 154
 	return $date->getTimestamp();
141 155
 }
@@ -169,12 +183,21 @@  discard block
 block discarded – undo
169 183
 {
170 184
 	global $langs;
171 185
 
172
-	if (empty($lengthOfDay))  $lengthOfDay = 86400;         // 1 day = 24 hours
173
-    if (empty($lengthOfWeek)) $lengthOfWeek = 7;            // 1 week = 7 days
186
+	if (empty($lengthOfDay)) {
187
+		$lengthOfDay = 86400;
188
+	}
189
+	// 1 day = 24 hours
190
+    if (empty($lengthOfWeek)) {
191
+    	$lengthOfWeek = 7;
192
+    }
193
+    // 1 week = 7 days
174 194
 
175 195
 	if ($format == 'all' || $format == 'allwithouthour' || $format == 'allhour' || $format == 'allhourmin')
176 196
 	{
177
-		if ((int) $iSecond === 0) return '0';	// This is to avoid having 0 return a 12:00 AM for en_US
197
+		if ((int) $iSecond === 0) {
198
+			return '0';
199
+		}
200
+		// This is to avoid having 0 return a 12:00 AM for en_US
178 201
 
179 202
         $sTime='';
180 203
         $sDay=0;
@@ -188,7 +211,9 @@  discard block
 block discarded – undo
188 211
 				$iSecond-=$lengthOfDay;
189 212
 			}
190 213
 			$dayTranslate = $langs->trans("Day");
191
-			if ($iSecond >= ($lengthOfDay*2)) $dayTranslate = $langs->trans("Days");
214
+			if ($iSecond >= ($lengthOfDay*2)) {
215
+				$dayTranslate = $langs->trans("Days");
216
+			}
192 217
 		}
193 218
 
194 219
 		if ($lengthOfWeek < 7)
@@ -200,7 +225,9 @@  discard block
 block discarded – undo
200 225
                     $sWeek = (int) (($sDay - $sDay % $lengthOfWeek ) / $lengthOfWeek);
201 226
                     $sDay = $sDay % $lengthOfWeek;
202 227
                     $weekTranslate = $langs->trans("DurationWeek");
203
-                    if ($sWeek >= 2) $weekTranslate = $langs->trans("DurationWeeks");
228
+                    if ($sWeek >= 2) {
229
+                    	$weekTranslate = $langs->trans("DurationWeeks");
230
+                    }
204 231
                     $sTime.=$sWeek.' '.$weekTranslate.' ';
205 232
                 }
206 233
             }
@@ -208,7 +235,9 @@  discard block
 block discarded – undo
208 235
 		if ($sDay>0)
209 236
 		{
210 237
 			$dayTranslate = $langs->trans("Day");
211
-			if ($sDay > 1) $dayTranslate = $langs->trans("Days");
238
+			if ($sDay > 1) {
239
+				$dayTranslate = $langs->trans("Days");
240
+			}
212 241
 			$sTime.=$sDay.' '.$dayTranslate.' ';
213 242
 		}
214 243
 
@@ -227,37 +256,40 @@  discard block
 block discarded – undo
227 256
 		{
228 257
 			return sprintf("%02d",($sWeek*$lengthOfWeek*24 + $sDay*24 + (int) floor($iSecond/3600)));
229 258
 		}
230
-	}
231
-	else if ($format == 'hour')	// only hour part
259
+	} else if ($format == 'hour') {
260
+		// only hour part
232 261
 	{
233 262
 		$sTime=dol_print_date($iSecond,'%H',true);
234 263
 	}
235
-	else if ($format == 'fullhour')
264
+	} else if ($format == 'fullhour')
236 265
 	{
237 266
 		if (!empty($iSecond)) {
238 267
 			$iSecond=$iSecond/3600;
239
-		}
240
-		else {
268
+		} else {
241 269
 			$iSecond=0;
242 270
 		}
243 271
 		$sTime=$iSecond;
244
-	}
245
-	else if ($format == 'min')	// only min part
272
+	} else if ($format == 'min') {
273
+		// only min part
246 274
 	{
247 275
 		$sTime=dol_print_date($iSecond,'%M',true);
248 276
 	}
249
-    else if ($format == 'sec')	// only sec part
277
+	} else if ($format == 'sec') {
278
+    	// only sec part
250 279
     {
251 280
         $sTime=dol_print_date($iSecond,'%S',true);
252 281
     }
253
-    else if ($format == 'month')	// only month part
282
+    } else if ($format == 'month') {
283
+    	// only month part
254 284
     {
255 285
         $sTime=dol_print_date($iSecond,'%m',true);
256 286
     }
257
-    else if ($format == 'year')	// only year part
287
+    } else if ($format == 'year') {
288
+    	// only year part
258 289
     {
259 290
         $sTime=dol_print_date($iSecond,'%Y',true);
260 291
     }
292
+    }
261 293
     return trim($sTime);
262 294
 }
263 295
 
@@ -294,11 +326,14 @@  discard block
 block discarded – undo
294 326
         $shour = $reg[4];
295 327
         $smin = $reg[5];
296 328
         $ssec = $reg[6];
297
-        if ($syear < 50) $syear+=1900;
298
-        if ($syear >= 50 && $syear < 100) $syear+=2000;
329
+        if ($syear < 50) {
330
+        	$syear+=1900;
331
+        }
332
+        if ($syear >= 50 && $syear < 100) {
333
+        	$syear+=2000;
334
+        }
299 335
         $string=sprintf("%04d%02d%02d%02d%02d%02d",$syear,$smonth,$sday,$shour,$smin,$ssec);
300
-    }
301
-    else if (
336
+    } else if (
302 337
     	   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)
303 338
     	|| 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
304 339
    		|| 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
@@ -362,8 +397,7 @@  discard block
 block discarded – undo
362 397
 	{
363 398
 		$prev_month = 12;
364 399
 		$prev_year  = $year - 1;
365
-	}
366
-	else
400
+	} else
367 401
 	{
368 402
 		$prev_month = $month-1;
369 403
 		$prev_year  = $year;
@@ -383,8 +417,7 @@  discard block
 block discarded – undo
383 417
 	{
384 418
 		$next_month = 1;
385 419
 		$next_year  = $year + 1;
386
-	}
387
-	else
420
+	} else
388 421
 	{
389 422
 		$next_month = $month + 1;
390 423
 		$next_year  = $year;
@@ -441,7 +474,9 @@  discard block
 block discarded – undo
441 474
  */
442 475
 function dol_get_first_day($year,$month=1,$gm=false)
443 476
 {
444
-	if ($year > 9999) return '';
477
+	if ($year > 9999) {
478
+		return '';
479
+	}
445 480
 	return dol_mktime(0,0,0,$month,1,$year,$gm);
446 481
 }
447 482
 
@@ -455,13 +490,14 @@  discard block
 block discarded – undo
455 490
  */
456 491
 function dol_get_last_day($year,$month=12,$gm=false)
457 492
 {
458
-	if ($year > 9999) return '';
493
+	if ($year > 9999) {
494
+		return '';
495
+	}
459 496
 	if ($month == 12)
460 497
 	{
461 498
 		$month = 1;
462 499
 		$year += 1;
463
-	}
464
-	else
500
+	} else
465 501
 	{
466 502
 		$month += 1;
467 503
 	}
@@ -495,7 +531,9 @@  discard block
 block discarded – undo
495 531
 
496 532
 	//Calculate days = offset from current day
497 533
 	$days = $start_week - $tmparray['wday'];
498
- 	if ($days>=1) $days=7-$days;
534
+ 	if ($days>=1) {
535
+ 		$days=7-$days;
536
+ 	}
499 537
  	$days = abs($days);
500 538
     $seconds = $days*24*60*60;
501 539
 	//print 'start_week='.$start_week.' tmparray[wday]='.$tmparray['wday'].' day offset='.$days.' seconds offset='.$seconds.'<br>';
@@ -515,8 +553,7 @@  discard block
 block discarded – undo
515 553
     		$prev_month = 12;
516 554
     		$prev_year  = $year-1;
517 555
     	}
518
-    }
519
-    else
556
+    } else
520 557
     {
521 558
     	$prev_month = $month;
522 559
 		$prev_year  = $year;
@@ -564,13 +601,17 @@  discard block
 block discarded – undo
564 601
 	$nbFerie = 0;
565 602
 
566 603
 	// Check to ensure we use correct parameters
567
-	if ((($timestampEnd - $timestampStart) % 86400) != 0) return 'ErrorDates must use same hours and must be GMT dates';
604
+	if ((($timestampEnd - $timestampStart) % 86400) != 0) {
605
+		return 'ErrorDates must use same hours and must be GMT dates';
606
+	}
568 607
 
569 608
 	$i=0;
570 609
 	while (( ($lastday == 0 && $timestampStart < $timestampEnd) || ($lastday && $timestampStart <= $timestampEnd) )
571
-	    && ($i < 50000))		// Loop end when equals (Test on i is a security loop to avoid infinite loop)
610
+	    && ($i < 50000)) {
611
+		// Loop end when equals (Test on i is a security loop to avoid infinite loop)
572 612
 	{
573 613
 		$ferie=false;
614
+	}
574 615
 		$countryfound=0;
575 616
 
576 617
 		$jour  = date("d", $timestampStart);
@@ -581,20 +622,46 @@  discard block
 block discarded – undo
581 622
 			$countryfound=1;
582 623
 
583 624
 			// Definition des dates feriees fixes
584
-			if($jour == 1 && $mois == 1)   $ferie=true; // 1er janvier
585
-			if($jour == 1 && $mois == 5)   $ferie=true; // 1er mai
586
-			if($jour == 8 && $mois == 5)   $ferie=true; // 5 mai
587
-			if($jour == 14 && $mois == 7)  $ferie=true; // 14 juillet
588
-			if($jour == 15 && $mois == 8)  $ferie=true; // 15 aout
589
-			if($jour == 1 && $mois == 11)  $ferie=true; // 1 novembre
590
-			if($jour == 11 && $mois == 11) $ferie=true; // 11 novembre
591
-			if($jour == 25 && $mois == 12) $ferie=true; // 25 decembre
625
+			if($jour == 1 && $mois == 1) {
626
+				$ferie=true;
627
+			}
628
+			// 1er janvier
629
+			if($jour == 1 && $mois == 5) {
630
+				$ferie=true;
631
+			}
632
+			// 1er mai
633
+			if($jour == 8 && $mois == 5) {
634
+				$ferie=true;
635
+			}
636
+			// 5 mai
637
+			if($jour == 14 && $mois == 7) {
638
+				$ferie=true;
639
+			}
640
+			// 14 juillet
641
+			if($jour == 15 && $mois == 8) {
642
+				$ferie=true;
643
+			}
644
+			// 15 aout
645
+			if($jour == 1 && $mois == 11) {
646
+				$ferie=true;
647
+			}
648
+			// 1 novembre
649
+			if($jour == 11 && $mois == 11) {
650
+				$ferie=true;
651
+			}
652
+			// 11 novembre
653
+			if($jour == 25 && $mois == 12) {
654
+				$ferie=true;
655
+			}
656
+			// 25 decembre
592 657
 
593 658
 			// Calcul du jour de paques
594 659
 			$date_paques = easter_date($annee);
595 660
 			$jour_paques = date("d", $date_paques);
596 661
 			$mois_paques = date("m", $date_paques);
597
-			if($jour_paques == $jour && $mois_paques == $mois) $ferie=true;
662
+			if($jour_paques == $jour && $mois_paques == $mois) {
663
+				$ferie=true;
664
+			}
598 665
 			// Paques
599 666
 
600 667
 			// Calcul du jour de l ascension (38 jours apres Paques)
@@ -608,7 +675,9 @@  discard block
 block discarded – undo
608 675
             );
609 676
 			$jour_ascension = date("d", $date_ascension);
610 677
 			$mois_ascension = date("m", $date_ascension);
611
-			if($jour_ascension == $jour && $mois_ascension == $mois) $ferie=true;
678
+			if($jour_ascension == $jour && $mois_ascension == $mois) {
679
+				$ferie=true;
680
+			}
612 681
 			//Ascension
613 682
 
614 683
 			// Calcul de Pentecote (11 jours apres Paques)
@@ -622,13 +691,17 @@  discard block
 block discarded – undo
622 691
             );
623 692
 			$jour_pentecote = date("d", $date_pentecote);
624 693
 			$mois_pentecote = date("m", $date_pentecote);
625
-			if($jour_pentecote == $jour && $mois_pentecote == $mois) $ferie=true;
694
+			if($jour_pentecote == $jour && $mois_pentecote == $mois) {
695
+				$ferie=true;
696
+			}
626 697
 			//Pentecote
627 698
 
628 699
 			// Calul des samedis et dimanches
629 700
 			$jour_julien = unixtojd($timestampStart);
630 701
 			$jour_semaine = jddayofweek($jour_julien, 0);
631
-			if($jour_semaine == 0 || $jour_semaine == 6) $ferie=true;
702
+			if($jour_semaine == 0 || $jour_semaine == 6) {
703
+				$ferie=true;
704
+			}
632 705
 			//Samedi (6) et dimanche (0)
633 706
 		}
634 707
 
@@ -639,28 +712,62 @@  discard block
 block discarded – undo
639 712
 			$countryfound=1;
640 713
 
641 714
 			// Definition des dates feriees fixes
642
-			if($jour == 1 && $mois == 1) $ferie=true; // Capodanno
643
-			if($jour == 6 && $mois == 1) $ferie=true; // Epifania
644
-			if($jour == 25 && $mois == 4) $ferie=true; // Anniversario Liberazione
645
-			if($jour == 1 && $mois == 5) $ferie=true; // Festa del Lavoro
646
-			if($jour == 2 && $mois == 6) $ferie=true; // Festa della Repubblica
647
-			if($jour == 15 && $mois == 8) $ferie=true; // Ferragosto
648
-			if($jour == 1 && $mois == 11) $ferie=true; // Tutti i Santi
649
-			if($jour == 8 && $mois == 12) $ferie=true; // Immacolata Concezione
650
-			if($jour == 25 && $mois == 12) $ferie=true; // 25 decembre
651
-			if($jour == 26 && $mois == 12) $ferie=true; // Santo Stefano
715
+			if($jour == 1 && $mois == 1) {
716
+				$ferie=true;
717
+			}
718
+			// Capodanno
719
+			if($jour == 6 && $mois == 1) {
720
+				$ferie=true;
721
+			}
722
+			// Epifania
723
+			if($jour == 25 && $mois == 4) {
724
+				$ferie=true;
725
+			}
726
+			// Anniversario Liberazione
727
+			if($jour == 1 && $mois == 5) {
728
+				$ferie=true;
729
+			}
730
+			// Festa del Lavoro
731
+			if($jour == 2 && $mois == 6) {
732
+				$ferie=true;
733
+			}
734
+			// Festa della Repubblica
735
+			if($jour == 15 && $mois == 8) {
736
+				$ferie=true;
737
+			}
738
+			// Ferragosto
739
+			if($jour == 1 && $mois == 11) {
740
+				$ferie=true;
741
+			}
742
+			// Tutti i Santi
743
+			if($jour == 8 && $mois == 12) {
744
+				$ferie=true;
745
+			}
746
+			// Immacolata Concezione
747
+			if($jour == 25 && $mois == 12) {
748
+				$ferie=true;
749
+			}
750
+			// 25 decembre
751
+			if($jour == 26 && $mois == 12) {
752
+				$ferie=true;
753
+			}
754
+			// Santo Stefano
652 755
 
653 756
 			// Calcul du jour de paques
654 757
 			$date_paques = easter_date($annee);
655 758
 			$jour_paques = date("d", $date_paques);
656 759
 			$mois_paques = date("m", $date_paques);
657
-			if($jour_paques == $jour && $mois_paques == $mois) $ferie=true;
760
+			if($jour_paques == $jour && $mois_paques == $mois) {
761
+				$ferie=true;
762
+			}
658 763
 			// Paques
659 764
 
660 765
 			// Calul des samedis et dimanches
661 766
 			$jour_julien = unixtojd($timestampStart);
662 767
 			$jour_semaine = jddayofweek($jour_julien, 0);
663
-			if($jour_semaine == 0 || $jour_semaine == 6) $ferie=true;
768
+			if($jour_semaine == 0 || $jour_semaine == 6) {
769
+				$ferie=true;
770
+			}
664 771
 			//Samedi (6) et dimanche (0)
665 772
 		}
666 773
 
@@ -669,21 +776,50 @@  discard block
 block discarded – undo
669 776
 			$countryfound=1;
670 777
 
671 778
 			// Definition des dates feriees fixes
672
-			if($jour == 1 && $mois == 1)   $ferie=true; // Año nuevo
673
-			if($jour == 6 && $mois == 1)   $ferie=true; // Día Reyes
674
-			if($jour == 1 && $mois == 5)   $ferie=true; // 1 Mayo
675
-			if($jour == 15 && $mois == 8)  $ferie=true; // 15 Agosto
676
-			if($jour == 12 && $mois == 10)  $ferie=true; // Día Hispanidad
677
-			if($jour == 1 && $mois == 11)  $ferie=true; // 1 noviembre
678
-			if($jour == 6 && $mois == 12) $ferie=true; // Constitución
679
-			if($jour == 8 && $mois == 12)  $ferie=true; // Inmaculada
680
-			if($jour == 25 && $mois == 12) $ferie=true; // 25 diciembre
779
+			if($jour == 1 && $mois == 1) {
780
+				$ferie=true;
781
+			}
782
+			// Año nuevo
783
+			if($jour == 6 && $mois == 1) {
784
+				$ferie=true;
785
+			}
786
+			// Día Reyes
787
+			if($jour == 1 && $mois == 5) {
788
+				$ferie=true;
789
+			}
790
+			// 1 Mayo
791
+			if($jour == 15 && $mois == 8) {
792
+				$ferie=true;
793
+			}
794
+			// 15 Agosto
795
+			if($jour == 12 && $mois == 10) {
796
+				$ferie=true;
797
+			}
798
+			// Día Hispanidad
799
+			if($jour == 1 && $mois == 11) {
800
+				$ferie=true;
801
+			}
802
+			// 1 noviembre
803
+			if($jour == 6 && $mois == 12) {
804
+				$ferie=true;
805
+			}
806
+			// Constitución
807
+			if($jour == 8 && $mois == 12) {
808
+				$ferie=true;
809
+			}
810
+			// Inmaculada
811
+			if($jour == 25 && $mois == 12) {
812
+				$ferie=true;
813
+			}
814
+			// 25 diciembre
681 815
 
682 816
 			// Calcul día de Pascua
683 817
 			$date_paques = easter_date($annee);
684 818
 			$jour_paques = date("d", $date_paques);
685 819
 			$mois_paques = date("m", $date_paques);
686
-			if($jour_paques == $jour && $mois_paques == $mois) $ferie=true;
820
+			if($jour_paques == $jour && $mois_paques == $mois) {
821
+				$ferie=true;
822
+			}
687 823
 			// Paques
688 824
 
689 825
 			// Viernes Santo
@@ -697,13 +833,17 @@  discard block
 block discarded – undo
697 833
             );
698 834
 			$jour_viernes = date("d", $date_viernes);
699 835
 			$mois_viernes = date("m", $date_viernes);
700
-			if($jour_viernes == $jour && $mois_viernes == $mois) $ferie=true;
836
+			if($jour_viernes == $jour && $mois_viernes == $mois) {
837
+				$ferie=true;
838
+			}
701 839
 			//Viernes Santo
702 840
 
703 841
 			// Calul des samedis et dimanches
704 842
 			$jour_julien = unixtojd($timestampStart);
705 843
 			$jour_semaine = jddayofweek($jour_julien, 0);
706
-			if($jour_semaine == 0 || $jour_semaine == 6) $ferie=true;
844
+			if($jour_semaine == 0 || $jour_semaine == 6) {
845
+				$ferie=true;
846
+			}
707 847
 			//Samedi (6) et dimanche (0)
708 848
 		}
709 849
 
@@ -713,12 +853,16 @@  discard block
 block discarded – undo
713 853
 			// Calul des samedis et dimanches
714 854
 			$jour_julien = unixtojd($timestampStart);
715 855
 			$jour_semaine = jddayofweek($jour_julien, 0);
716
-			if($jour_semaine == 0 || $jour_semaine == 6) $ferie=true;
856
+			if($jour_semaine == 0 || $jour_semaine == 6) {
857
+				$ferie=true;
858
+			}
717 859
 			//Samedi (6) et dimanche (0)
718 860
 		}
719 861
 
720 862
 		// On incremente compteur
721
-		if ($ferie) $nbFerie++;
863
+		if ($ferie) {
864
+			$nbFerie++;
865
+		}
722 866
 
723 867
 		// Increase number of days (on go up into loop)
724 868
 		$timestampStart=dol_time_plus_duree($timestampStart, 1, 'd');
@@ -747,8 +891,7 @@  discard block
 block discarded – undo
747 891
 		if ($lastday == 1)
748 892
 		{
749 893
 			$bit = 0;
750
-		}
751
-		else
894
+		} else
752 895
 		{
753 896
 			$bit = 1;
754 897
 		}
@@ -774,13 +917,19 @@  discard block
 block discarded – undo
774 917
 {
775 918
 	global $langs,$mysoc;
776 919
 
777
-	if (empty($country_code)) $country_code=$mysoc->country_code;
920
+	if (empty($country_code)) {
921
+		$country_code=$mysoc->country_code;
922
+	}
778 923
 
779 924
 	dol_syslog('num_open_day timestampStart='.$timestampStart.' timestampEnd='.$timestampEnd.' bit='.$lastday.' country_code='.$country_code);
780 925
 
781 926
 	// Check parameters
782
-	if (! is_int($timestampStart) && ! is_float($timestampStart)) return 'ErrorBadParameter_num_open_day';
783
-	if (! is_int($timestampEnd) && ! is_float($timestampEnd)) return 'ErrorBadParameter_num_open_day';
927
+	if (! is_int($timestampStart) && ! is_float($timestampStart)) {
928
+		return 'ErrorBadParameter_num_open_day';
929
+	}
930
+	if (! is_int($timestampEnd) && ! is_float($timestampEnd)) {
931
+		return 'ErrorBadParameter_num_open_day';
932
+	}
784 933
 
785 934
 	//print 'num_open_day timestampStart='.$timestampStart.' timestampEnd='.$timestampEnd.' bit='.$lastday;
786 935
 	if ($timestampStart < $timestampEnd)
@@ -789,16 +938,18 @@  discard block
 block discarded – undo
789 938
 		$numholidays = num_public_holiday($timestampStart, $timestampEnd, $country_code, $lastday);
790 939
 		$nbOpenDay = $numdays - $numholidays;
791 940
 		$nbOpenDay.= " " . $langs->trans("Days");
792
-		if ($inhour == 1 && $nbOpenDay <= 3) $nbOpenDay = $nbOpenDay*24 . $langs->trans("HourShort");
941
+		if ($inhour == 1 && $nbOpenDay <= 3) {
942
+			$nbOpenDay = $nbOpenDay*24 . $langs->trans("HourShort");
943
+		}
793 944
 		return $nbOpenDay - (($inhour == 1 ? 12 : 0.5) * abs($halfday));
794
-	}
795
-	elseif ($timestampStart == $timestampEnd)
945
+	} elseif ($timestampStart == $timestampEnd)
796 946
 	{
797 947
 		$nbOpenDay=$lastday;
798
-		if ($inhour == 1) $nbOpenDay = $nbOpenDay*24 . $langs->trans("HourShort");
948
+		if ($inhour == 1) {
949
+			$nbOpenDay = $nbOpenDay*24 . $langs->trans("HourShort");
950
+		}
799 951
 		return $nbOpenDay - (($inhour == 1 ? 12 : 0.5) * abs($halfday));
800
-	}
801
-	else
952
+	} else
802 953
 	{
803 954
 		return $langs->trans("Error");
804 955
 	}
Please login to merge, or discard this patch.
htdocs/core/lib/project.lib.php 4 patches
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -269,7 +269,7 @@  discard block
 block discarded – undo
269 269
  * @param	int			$projectsListId		List of id of project allowed to user (string separated with comma)
270 270
  * @param	int			$addordertick		Add a tick to move task
271 271
  * @param   int         $projectidfortotallink     0 or Id of project to use on total line (link to see all time consumed for project)
272
- * @return	void
272
+ * @return	string
273 273
  */
274 274
 function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$taskrole, $projectsListId='', $addordertick=0, $projectidfortotallink=0)
275 275
 {
@@ -865,7 +865,7 @@  discard block
 block discarded – undo
865 865
  * @param 	int		$parent				Id of parent task to start
866 866
  * @param 	array	$lines				Array of all tasks
867 867
  * @param	string	$taskrole			Array of task filtered on a particular user
868
- * @return	int							1 if there is
868
+ * @return	string							1 if there is
869 869
  */
870 870
 function searchTaskInChild(&$inc, $parent, &$lines, &$taskrole)
871 871
 {
Please login to merge, or discard this patch.
Indentation   +163 added lines, -163 removed lines patch added patch discarded remove patch
@@ -44,7 +44,7 @@  discard block
 block discarded – undo
44 44
 	$head[$h][2] = 'project';
45 45
 	$h++;
46 46
 
47
-    $nbContact = count($object->liste_contact(-1,'internal')) + count($object->liste_contact(-1,'external'));
47
+	$nbContact = count($object->liste_contact(-1,'internal')) + count($object->liste_contact(-1,'external'));
48 48
 	$head[$h][0] = DOL_URL_ROOT.'/projet/contact.php?id='.$object->id;
49 49
 	$head[$h][1] = $langs->trans("ProjectContact");
50 50
 	if ($nbContact > 0) $head[$h][1].= ' <span class="badge">'.$nbContact.'</span>';
@@ -69,22 +69,22 @@  discard block
 block discarded – undo
69 69
 
70 70
 
71 71
 	if (empty($conf->global->MAIN_DISABLE_NOTES_TAB))
72
-    {
73
-    	$nbNote = 0;
74
-        if(!empty($object->note_private)) $nbNote++;
72
+	{
73
+		$nbNote = 0;
74
+		if(!empty($object->note_private)) $nbNote++;
75 75
 		if(!empty($object->note_public)) $nbNote++;
76 76
 		$head[$h][0] = DOL_URL_ROOT.'/projet/note.php?id='.$object->id;
77 77
 		$head[$h][1] = $langs->trans('Notes');
78 78
 		if ($nbNote > 0) $head[$h][1].= ' <span class="badge">'.$nbNote.'</span>';
79 79
 		$head[$h][2] = 'notes';
80 80
 		$h++;
81
-    }
81
+	}
82 82
 
83 83
 	require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
84
-    require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php';
84
+	require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php';
85 85
 	$upload_dir = $conf->projet->dir_output . "/" . dol_sanitizeFileName($object->ref);
86 86
 	$nbFiles = count(dol_dir_list($upload_dir,'files',0,'','(\.meta|_preview.*\.png)$'));
87
-    $nbLinks=Link::count($db, $object->element, $object->id);
87
+	$nbLinks=Link::count($db, $object->element, $object->id);
88 88
 	$head[$h][0] = DOL_URL_ROOT.'/projet/document.php?id='.$object->id;
89 89
 	$head[$h][1] = $langs->trans('Documents');
90 90
 	if (($nbFiles+$nbLinks) > 0) $head[$h][1].= ' <span class="badge">'.($nbFiles+$nbLinks).'</span>';
@@ -123,12 +123,12 @@  discard block
 block discarded – undo
123 123
 	}
124 124
 
125 125
 	$head[$h][0] = DOL_URL_ROOT.'/projet/info.php?id='.$object->id;
126
-    $head[$h][1].= $langs->trans("Events");
127
-    if (! empty($conf->agenda->enabled) && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read) ))
128
-    {
129
-        $head[$h][1].= '/';
130
-        $head[$h][1].= $langs->trans("Agenda");
131
-    }
126
+	$head[$h][1].= $langs->trans("Events");
127
+	if (! empty($conf->agenda->enabled) && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read) ))
128
+	{
129
+		$head[$h][1].= '/';
130
+		$head[$h][1].= $langs->trans("Agenda");
131
+	}
132 132
 	$head[$h][2] = 'agenda';
133 133
 	$h++;
134 134
 
@@ -171,8 +171,8 @@  discard block
 block discarded – undo
171 171
 	$resql = $db->query($sql);
172 172
 	if ($resql)
173 173
 	{
174
-	    $obj = $db->fetch_object($resql);
175
-	    if ($obj) $nbTimeSpent=1;
174
+		$obj = $db->fetch_object($resql);
175
+		if ($obj) $nbTimeSpent=1;
176 176
 	}
177 177
 	else dol_print_error($db);
178 178
 
@@ -189,23 +189,23 @@  discard block
 block discarded – undo
189 189
 	complete_head_from_modules($conf,$langs,$object,$head,$h,'task');
190 190
 
191 191
 	if (empty($conf->global->MAIN_DISABLE_NOTES_TAB))
192
-    {
193
-    	$nbNote = 0;
194
-        if(!empty($object->note_private)) $nbNote++;
192
+	{
193
+		$nbNote = 0;
194
+		if(!empty($object->note_private)) $nbNote++;
195 195
 		if(!empty($object->note_public)) $nbNote++;
196 196
 		$head[$h][0] = DOL_URL_ROOT.'/projet/tasks/note.php?id='.$object->id.(GETPOST('withproject')?'&withproject=1':'');
197 197
 		$head[$h][1] = $langs->trans('Notes');
198 198
 		if ($nbNote > 0) $head[$h][1].= ' <span class="badge">'.$nbNote.'</span>';
199 199
 		$head[$h][2] = 'task_notes';
200 200
 		$h++;
201
-    }
201
+	}
202 202
 
203 203
 	$head[$h][0] = DOL_URL_ROOT.'/projet/tasks/document.php?id='.$object->id.(GETPOST('withproject')?'&withproject=1':'');
204 204
 	$filesdir = $conf->projet->dir_output . "/" . dol_sanitizeFileName($object->project->ref) . '/' .dol_sanitizeFileName($object->ref);
205 205
 	include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
206 206
 	include_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php';
207 207
 	$nbFiles = count(dol_dir_list($filesdir,'files',0,'','(\.meta|_preview.*\.png)$'));
208
-    $nbLinks=Link::count($db, $object->element, $object->id);
208
+	$nbLinks=Link::count($db, $object->element, $object->id);
209 209
 	$head[$h][1] = $langs->trans('Documents');
210 210
 	if (($nbFiles+$nbLinks) > 0) $head[$h][1].= ' <span class="badge">'.($nbFiles+$nbLinks).'</span>';
211 211
 	$head[$h][2] = 'task_document';
@@ -467,11 +467,11 @@  discard block
 block discarded – undo
467 467
 				// Date end
468 468
 				print '<td align="center">';
469 469
 				$taskstatic->projectstatus = $lines[$i]->projectstatus;
470
-	            $taskstatic->progress = $lines[$i]->progress;
471
-	            $taskstatic->fk_statut = $lines[$i]->status;
472
-	            $taskstatic->datee = $lines[$i]->date_end;
473
-	            print dol_print_date($lines[$i]->date_end,'dayhour');
474
-	            if ($taskstatic->hasDelay()) print img_warning($langs->trans("Late"));
470
+				$taskstatic->progress = $lines[$i]->progress;
471
+				$taskstatic->fk_statut = $lines[$i]->status;
472
+				$taskstatic->datee = $lines[$i]->date_end;
473
+				print dol_print_date($lines[$i]->date_end,'dayhour');
474
+				if ($taskstatic->hasDelay()) print img_warning($langs->trans("Late"));
475 475
 				print '</td>';
476 476
 
477 477
 				$plannedworkloadoutputformat='allhourmin';
@@ -531,9 +531,9 @@  discard block
 block discarded – undo
531 531
 
532 532
 				if ($level >= 0)    // Call sublevels
533 533
 				{
534
-    				$level++;
535
-    				if ($lines[$i]->id) projectLinesa($inc, $lines[$i]->id, $lines, $level, $var, $showproject, $taskrole, $projectsListId, $addordertick);
536
-    				$level--;
534
+					$level++;
535
+					if ($lines[$i]->id) projectLinesa($inc, $lines[$i]->id, $lines, $level, $var, $showproject, $taskrole, $projectsListId, $addordertick);
536
+					$level--;
537 537
 				}
538 538
 
539 539
 				$total_projectlinesa_spent += $lines[$i]->duration;
@@ -605,13 +605,13 @@  discard block
 block discarded – undo
605 605
 	// Create a smaller array with sublevels only to be used later. This increase dramatically performances.
606 606
 	if ($parent == 0) // Always and only if at first level
607 607
 	{
608
-	    for ($i = 0 ; $i < $numlines ; $i++)
609
-	    {
610
-	        if ($lines[$i]->fk_task_parent) $lineswithoutlevel0[]=$lines[$i];
611
-	    }
608
+		for ($i = 0 ; $i < $numlines ; $i++)
609
+		{
610
+			if ($lines[$i]->fk_task_parent) $lineswithoutlevel0[]=$lines[$i];
611
+		}
612 612
 	}
613 613
 
614
-    //dol_syslog('projectLinesPerDay inc='.$inc.' preselectedday='.$preselectedday.' task parent id='.$parent.' level='.$level." count(lines)=".$numlines." count(lineswithoutlevel0)=".count($lineswithoutlevel0));
614
+	//dol_syslog('projectLinesPerDay inc='.$inc.' preselectedday='.$preselectedday.' task parent id='.$parent.' level='.$level." count(lines)=".$numlines." count(lineswithoutlevel0)=".count($lineswithoutlevel0));
615 615
 	for ($i = 0 ; $i < $numlines ; $i++)
616 616
 	{
617 617
 		if ($parent == 0) $level = 0;
@@ -621,26 +621,26 @@  discard block
 block discarded – undo
621 621
 			// If we want all or we have a role on task, we show it
622 622
 			if (empty($mine) || ! empty($tasksrole[$lines[$i]->id]))
623 623
 			{
624
-                //dol_syslog("projectLinesPerWeek Found line ".$i.", a qualified task (i have role or want to show all tasks) with id=".$lines[$i]->id." project id=".$lines[$i]->fk_project);
624
+				//dol_syslog("projectLinesPerWeek Found line ".$i.", a qualified task (i have role or want to show all tasks) with id=".$lines[$i]->id." project id=".$lines[$i]->fk_project);
625 625
 
626 626
 				// Break on a new project
627
-        		if ($parent == 0 && $lines[$i]->fk_project != $lastprojectid)
628
-        		{
629
-        			$lastprojectid=$lines[$i]->fk_project;
630
-        			if ($preselectedday)
631
-        			{
632
-        				$projectstatic->id = $lines[$i]->fk_project;
633
-        			}
634
-        		}
635
-
636
-			    if (empty($workloadforid[$projectstatic->id]))
637
-			    {
638
-    				if ($preselectedday)
639
-    				{
640
-    			        $projectstatic->loadTimeSpent($preselectedday, 0, $fuser->id);	// Load time spent from table projet_task_time for the project into this->weekWorkLoad and this->weekWorkLoadPerTask for all days of a week
641
-	       		        $workloadforid[$projectstatic->id]=1;
642
-    				}
643
-			    }
627
+				if ($parent == 0 && $lines[$i]->fk_project != $lastprojectid)
628
+				{
629
+					$lastprojectid=$lines[$i]->fk_project;
630
+					if ($preselectedday)
631
+					{
632
+						$projectstatic->id = $lines[$i]->fk_project;
633
+					}
634
+				}
635
+
636
+				if (empty($workloadforid[$projectstatic->id]))
637
+				{
638
+					if ($preselectedday)
639
+					{
640
+						$projectstatic->loadTimeSpent($preselectedday, 0, $fuser->id);	// Load time spent from table projet_task_time for the project into this->weekWorkLoad and this->weekWorkLoadPerTask for all days of a week
641
+		   				$workloadforid[$projectstatic->id]=1;
642
+					}
643
+				}
644 644
 
645 645
 				$projectstatic->id=$lines[$i]->fk_project;
646 646
 				$projectstatic->ref=$lines[$i]->projectref;
@@ -671,12 +671,12 @@  discard block
 block discarded – undo
671 671
 
672 672
 				if (! empty($conf->global->PROJECT_LINES_PERDAY_SHOW_THIRDPARTY))
673 673
 				{
674
-				    // Thirdparty
675
-				    print '<td class="tdoverflowmax100">';
676
-				    $thirdpartystatic->id=$lines[$i]->socid;
677
-				    $thirdpartystatic->name=$lines[$i]->thirdparty_name;
678
-				    print $thirdpartystatic->getNomUrl(1, 'project', 10);
679
-				    print '</td>';
674
+					// Thirdparty
675
+					print '<td class="tdoverflowmax100">';
676
+					$thirdpartystatic->id=$lines[$i]->socid;
677
+					$thirdpartystatic->name=$lines[$i]->thirdparty_name;
678
+					print $thirdpartystatic->getNomUrl(1, 'project', 10);
679
+					print '</td>';
680 680
 				}
681 681
 
682 682
 				// Label task
@@ -753,14 +753,14 @@  discard block
 block discarded – undo
753 753
 				print '<td align="center" class="duration'.($cssonholiday?' '.$cssonholiday:'').'">';
754 754
 
755 755
 				$dayWorkLoad = $projectstatic->weekWorkLoadPerTask[$preselectedday][$lines[$i]->id];
756
-		        $alreadyspent='';
757
-		        if ($dayWorkLoad > 0) $alreadyspent=convertSecondToTime($dayWorkLoad,'allhourmin');
756
+				$alreadyspent='';
757
+				if ($dayWorkLoad > 0) $alreadyspent=convertSecondToTime($dayWorkLoad,'allhourmin');
758 758
 
759
-		        $idw = 0;
759
+				$idw = 0;
760 760
 
761 761
 				$tableCell='';
762 762
 				$tableCell.='<span class="timesheetalreadyrecorded"><input type="text" class="center" size="2" disabled id="timespent['.$inc.']['.$idw.']" name="task['.$lines[$i]->id.']['.$idw.']" value="'.$alreadyspent.'"></span>';
763
-                $tableCell.='<span class="hideonsmartphone"> + </span>';
763
+				$tableCell.='<span class="hideonsmartphone"> + </span>';
764 764
 				//$tableCell.='&nbsp;&nbsp;&nbsp;';
765 765
 				$tableCell.=$form->select_duration($lines[$i]->id.'duration','',$disabledtask,'text',0,1);
766 766
 				//$tableCell.='&nbsp;<input type="submit" class="button"'.($disabledtask?' disabled':'').' value="'.$langs->trans("Add").'">';
@@ -800,8 +800,8 @@  discard block
 block discarded – undo
800 800
 			$level++;
801 801
 			if ($lines[$i]->id > 0)
802 802
 			{
803
-			    if ($parent == 0) projectLinesPerDay($inc, $lines[$i]->id, $fuser, $lineswithoutlevel0, $level, $projectsrole, $tasksrole, $mine, $restricteditformytask, $preselectedday, $isavailable);
804
-			    else projectLinesPerDay($inc, $lines[$i]->id, $fuser, $lines, $level, $projectsrole, $tasksrole, $mine, $restricteditformytask, $preselectedday, $isavailable);
803
+				if ($parent == 0) projectLinesPerDay($inc, $lines[$i]->id, $fuser, $lineswithoutlevel0, $level, $projectsrole, $tasksrole, $mine, $restricteditformytask, $preselectedday, $isavailable);
804
+				else projectLinesPerDay($inc, $lines[$i]->id, $fuser, $lines, $level, $projectsrole, $tasksrole, $mine, $restricteditformytask, $preselectedday, $isavailable);
805 805
 			}
806 806
 			$level--;
807 807
 		}
@@ -845,13 +845,13 @@  discard block
 block discarded – undo
845 845
 	// Create a smaller array with sublevels only to be used later. This increase dramatically performances.
846 846
 	if ($parent == 0) // Always and only if at first level
847 847
 	{
848
-	    for ($i = 0 ; $i < $numlines ; $i++)
849
-	    {
850
-	       if ($lines[$i]->fk_task_parent) $lineswithoutlevel0[]=$lines[$i];
851
-	    }
848
+		for ($i = 0 ; $i < $numlines ; $i++)
849
+		{
850
+		   if ($lines[$i]->fk_task_parent) $lineswithoutlevel0[]=$lines[$i];
851
+		}
852 852
 	}
853 853
 
854
-    //dol_syslog('projectLinesPerWeek inc='.$inc.' firstdaytoshow='.$firstdaytoshow.' task parent id='.$parent.' level='.$level." count(lines)=".$numlines." count(lineswithoutlevel0)=".count($lineswithoutlevel0));
854
+	//dol_syslog('projectLinesPerWeek inc='.$inc.' firstdaytoshow='.$firstdaytoshow.' task parent id='.$parent.' level='.$level." count(lines)=".$numlines." count(lineswithoutlevel0)=".count($lineswithoutlevel0));
855 855
 
856 856
 	for ($i = 0 ; $i < $numlines ; $i++)
857 857
 	{
@@ -862,20 +862,20 @@  discard block
 block discarded – undo
862 862
 			// If we want all or we have a role on task, we show it
863 863
 			if (empty($mine) || ! empty($tasksrole[$lines[$i]->id]))
864 864
 			{
865
-			    //dol_syslog("projectLinesPerWeek Found line ".$i.", a qualified task (i have role or want to show all tasks) with id=".$lines[$i]->id." project id=".$lines[$i]->fk_project);
865
+				//dol_syslog("projectLinesPerWeek Found line ".$i.", a qualified task (i have role or want to show all tasks) with id=".$lines[$i]->id." project id=".$lines[$i]->fk_project);
866 866
 
867
-			    // Break on a new project
868
-    			if ($parent == 0 && $lines[$i]->fk_project != $lastprojectid)
869
-    			{
870
-    				$lastprojectid=$lines[$i]->fk_project;
871
-    				$projectstatic->id = $lines[$i]->fk_project;
872
-    			}
867
+				// Break on a new project
868
+				if ($parent == 0 && $lines[$i]->fk_project != $lastprojectid)
869
+				{
870
+					$lastprojectid=$lines[$i]->fk_project;
871
+					$projectstatic->id = $lines[$i]->fk_project;
872
+				}
873 873
 
874
-			    if (empty($workloadforid[$projectstatic->id]))
875
-			    {
876
-				    $projectstatic->loadTimeSpent($firstdaytoshow, 0, $fuser->id);	// Load time spent from table projet_task_time for the project into this->weekWorkLoad and this->weekWorkLoadPerTask for all days of a week
877
-                    $workloadforid[$projectstatic->id]=1;
878
-			    }
874
+				if (empty($workloadforid[$projectstatic->id]))
875
+				{
876
+					$projectstatic->loadTimeSpent($firstdaytoshow, 0, $fuser->id);	// Load time spent from table projet_task_time for the project into this->weekWorkLoad and this->weekWorkLoadPerTask for all days of a week
877
+					$workloadforid[$projectstatic->id]=1;
878
+				}
879 879
 
880 880
 				$projectstatic->id=$lines[$i]->fk_project;
881 881
 				$projectstatic->ref=$lines[$i]->projectref;
@@ -899,12 +899,12 @@  discard block
 block discarded – undo
899 899
 
900 900
 				if (! empty($conf->global->PROJECT_LINES_PERWEEK_SHOW_THIRDPARTY))
901 901
 				{
902
-				    // Thirdparty
903
-				    print '<td class="tdoverflowmax100">';
904
-				    $thirdpartystatic->id=$lines[$i]->thirdparty_id;
905
-				    $thirdpartystatic->name=$lines[$i]->thirdparty_name;
906
-				    print $thirdpartystatic->getNomUrl(1, 'project');
907
-				    print '</td>';
902
+					// Thirdparty
903
+					print '<td class="tdoverflowmax100">';
904
+					$thirdpartystatic->id=$lines[$i]->thirdparty_id;
905
+					$thirdpartystatic->name=$lines[$i]->thirdparty_name;
906
+					print $thirdpartystatic->getNomUrl(1, 'project');
907
+					print '</td>';
908 908
 				}
909 909
 
910 910
 				// Ref
@@ -979,7 +979,7 @@  discard block
 block discarded – undo
979 979
 				// Fields to show current time
980 980
 				$tableCell=''; $modeinput='hours';
981 981
 				for ($idw = 0; $idw < 7; $idw++)
982
-		        {
982
+				{
983 983
 					$tmpday=dol_time_plus_duree($firstdaytoshow, $idw, 'd');
984 984
 
985 985
 					$cssonholiday='';
@@ -988,28 +988,28 @@  discard block
 block discarded – undo
988 988
 					elseif (! $isavailable[$tmpday]['afternoon']) $cssonholiday.='onholidayafternoon ';
989 989
 
990 990
 					$tmparray=dol_getdate($tmpday);
991
-		        	$dayWorkLoad = $projectstatic->weekWorkLoadPerTask[$tmpday][$lines[$i]->id];
992
-		        	$alreadyspent='';
993
-		        	if ($dayWorkLoad > 0) $alreadyspent=convertSecondToTime($dayWorkLoad,'allhourmin');
994
-                    $alttitle=$langs->trans("AddHereTimeSpentForDay",$tmparray['day'],$tmparray['mon']);
995
-
996
-                    $tableCell ='<td align="center" class="hide'.$idw.($cssonholiday?' '.$cssonholiday:'').'">';
997
-                    if ($alreadyspent)
998
-                    {
999
-                        $tableCell.='<span class="timesheetalreadyrecorded"><input type="text" class="center smallpadd" size="2" disabled id="timespent['.$inc.']['.$idw.']" name="task['.$lines[$i]->id.']['.$idw.']" value="'.$alreadyspent.'"></span>';
1000
-                        //$placeholder=' placeholder="00:00"';
1001
-                        $placeholder='';
1002
-                     	//$tableCell.='+';
1003
-                    }
1004
-                  	$tableCell.='<input type="text" alt="'.($disabledtask?'':$alttitle).'" title="'.($disabledtask?'':$alttitle).'" '.($disabledtask?'disabled':$placeholder).' class="center smallpadd" size="2" id="timeadded['.$inc.']['.$idw.']" name="task['.$lines[$i]->id.']['.$idw.']" value="" cols="2"  maxlength="5"';
1005
-	        		$tableCell.=' onkeypress="return regexEvent(this,event,\'timeChar\')"';
1006
-                   	$tableCell.=' onkeyup="updateTotal('.$idw.',\''.$modeinput.'\')"';
1007
-                   	$tableCell.=' onblur="regexEvent(this,event,\''.$modeinput.'\'); updateTotal('.$idw.',\''.$modeinput.'\')" />';
1008
-                   	$tableCell.='</td>';
1009
-                    print $tableCell;
1010
-		        }
1011
-
1012
-		        // Warning
991
+					$dayWorkLoad = $projectstatic->weekWorkLoadPerTask[$tmpday][$lines[$i]->id];
992
+					$alreadyspent='';
993
+					if ($dayWorkLoad > 0) $alreadyspent=convertSecondToTime($dayWorkLoad,'allhourmin');
994
+					$alttitle=$langs->trans("AddHereTimeSpentForDay",$tmparray['day'],$tmparray['mon']);
995
+
996
+					$tableCell ='<td align="center" class="hide'.$idw.($cssonholiday?' '.$cssonholiday:'').'">';
997
+					if ($alreadyspent)
998
+					{
999
+						$tableCell.='<span class="timesheetalreadyrecorded"><input type="text" class="center smallpadd" size="2" disabled id="timespent['.$inc.']['.$idw.']" name="task['.$lines[$i]->id.']['.$idw.']" value="'.$alreadyspent.'"></span>';
1000
+						//$placeholder=' placeholder="00:00"';
1001
+						$placeholder='';
1002
+					 	//$tableCell.='+';
1003
+					}
1004
+				  	$tableCell.='<input type="text" alt="'.($disabledtask?'':$alttitle).'" title="'.($disabledtask?'':$alttitle).'" '.($disabledtask?'disabled':$placeholder).' class="center smallpadd" size="2" id="timeadded['.$inc.']['.$idw.']" name="task['.$lines[$i]->id.']['.$idw.']" value="" cols="2"  maxlength="5"';
1005
+					$tableCell.=' onkeypress="return regexEvent(this,event,\'timeChar\')"';
1006
+				   	$tableCell.=' onkeyup="updateTotal('.$idw.',\''.$modeinput.'\')"';
1007
+				   	$tableCell.=' onblur="regexEvent(this,event,\''.$modeinput.'\'); updateTotal('.$idw.',\''.$modeinput.'\')" />';
1008
+				   	$tableCell.='</td>';
1009
+					print $tableCell;
1010
+				}
1011
+
1012
+				// Warning
1013 1013
 				print '<td align="right">';
1014 1014
    				if ((! $lines[$i]->public) && $disabledproject) print $form->textwithpicto('',$langs->trans("UserIsNotContactOfProject"));
1015 1015
    				else if ($disabledtask)
@@ -1021,7 +1021,7 @@  discard block
 block discarded – undo
1021 1021
    				}
1022 1022
 				print '</td>';
1023 1023
 
1024
-		        print "</tr>\n";
1024
+				print "</tr>\n";
1025 1025
 			}
1026 1026
 
1027 1027
 			// Call to show task with a lower level (task under the current task)
@@ -1029,8 +1029,8 @@  discard block
 block discarded – undo
1029 1029
 			$level++;
1030 1030
 			if ($lines[$i]->id > 0)
1031 1031
 			{
1032
-			    if ($parent == 0) projectLinesPerWeek($inc, $firstdaytoshow, $fuser, $lines[$i]->id, $lineswithoutlevel0, $level, $projectsrole, $tasksrole, $mine, $restricteditformytask, $isavailable);
1033
-			    else projectLinesPerWeek($inc, $firstdaytoshow, $fuser, $lines[$i]->id, $lines, $level, $projectsrole, $tasksrole, $mine, $restricteditformytask, $isavailable);
1032
+				if ($parent == 0) projectLinesPerWeek($inc, $firstdaytoshow, $fuser, $lines[$i]->id, $lineswithoutlevel0, $level, $projectsrole, $tasksrole, $mine, $restricteditformytask, $isavailable);
1033
+				else projectLinesPerWeek($inc, $firstdaytoshow, $fuser, $lines[$i]->id, $lines, $level, $projectsrole, $tasksrole, $mine, $restricteditformytask, $isavailable);
1034 1034
 			}
1035 1035
 			$level--;
1036 1036
 		}
@@ -1100,7 +1100,7 @@  discard block
 block discarded – undo
1100 1100
 	require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
1101 1101
 
1102 1102
 	$projectstatic=new Project($db);
1103
-    $thirdpartystatic=new Societe($db);
1103
+	$thirdpartystatic=new Societe($db);
1104 1104
 
1105 1105
 	$sortfield='';
1106 1106
 	$sortorder='';
@@ -1161,12 +1161,12 @@  discard block
 block discarded – undo
1161 1161
 	$resql = $db->query($sql1);
1162 1162
 	if ($resql)
1163 1163
 	{
1164
-	    $i=0;
1164
+		$i=0;
1165 1165
 		$num = $db->num_rows($resql);
1166 1166
 		while ($i < $num)
1167 1167
 		{
1168 1168
 			$objp = $db->fetch_object($resql);
1169
-            $arrayidofprojects[$objp->projectid]=$objp->projectid;
1169
+			$arrayidofprojects[$objp->projectid]=$objp->projectid;
1170 1170
 			$i++;
1171 1171
 		}
1172 1172
 	}
@@ -1194,22 +1194,22 @@  discard block
 block discarded – undo
1194 1194
 		$num = $db->num_rows($resql);
1195 1195
 		$i = 0;
1196 1196
 
1197
-    	print '<tr class="liste_titre">';
1198
-    	print_liste_field_titre($title.' <span class="badge">'.$num.'</span>',$_SERVER["PHP_SELF"],"","","","",$sortfield,$sortorder);
1199
-    	print_liste_field_titre("ThirdParty",$_SERVER["PHP_SELF"],"","","","",$sortfield,$sortorder);
1200
-    	if (! empty($conf->global->PROJECT_USE_OPPORTUNITIES))
1201
-    	{
1202
-    		print_liste_field_titre("OpportunityAmount","","","","",'align="right"',$sortfield,$sortorder);
1203
-    		print_liste_field_titre("OpportunityStatus","","","","",'align="right"',$sortfield,$sortorder);
1204
-    	}
1205
-    	if (empty($conf->global->PROJECT_HIDE_TASKS))
1206
-    	{
1207
-            print_liste_field_titre("Tasks","","","","",'align="right"',$sortfield,$sortorder);
1208
-            if (! in_array('plannedworkload', $hiddenfields))  print_liste_field_titre("PlannedWorkload","","","","",'align="right"',$sortfield,$sortorder);
1209
-            if (! in_array('declaredprogress', $hiddenfields)) print_liste_field_titre("ProgressDeclared","","","","",'align="right"',$sortfield,$sortorder);
1210
-    	}
1211
-    	print_liste_field_titre("Status","","","","",'align="right"',$sortfield,$sortorder);
1212
-    	print "</tr>\n";
1197
+		print '<tr class="liste_titre">';
1198
+		print_liste_field_titre($title.' <span class="badge">'.$num.'</span>',$_SERVER["PHP_SELF"],"","","","",$sortfield,$sortorder);
1199
+		print_liste_field_titre("ThirdParty",$_SERVER["PHP_SELF"],"","","","",$sortfield,$sortorder);
1200
+		if (! empty($conf->global->PROJECT_USE_OPPORTUNITIES))
1201
+		{
1202
+			print_liste_field_titre("OpportunityAmount","","","","",'align="right"',$sortfield,$sortorder);
1203
+			print_liste_field_titre("OpportunityStatus","","","","",'align="right"',$sortfield,$sortorder);
1204
+		}
1205
+		if (empty($conf->global->PROJECT_HIDE_TASKS))
1206
+		{
1207
+			print_liste_field_titre("Tasks","","","","",'align="right"',$sortfield,$sortorder);
1208
+			if (! in_array('plannedworkload', $hiddenfields))  print_liste_field_titre("PlannedWorkload","","","","",'align="right"',$sortfield,$sortorder);
1209
+			if (! in_array('declaredprogress', $hiddenfields)) print_liste_field_titre("ProgressDeclared","","","","",'align="right"',$sortfield,$sortorder);
1210
+		}
1211
+		print_liste_field_titre("Status","","","","",'align="right"',$sortfield,$sortorder);
1212
+		print "</tr>\n";
1213 1213
 
1214 1214
 		while ($i < $num)
1215 1215
 		{
@@ -1223,11 +1223,11 @@  discard block
 block discarded – undo
1223 1223
 			$userAccess = $projectstatic->restrictedProjectArea($user);
1224 1224
 			if ($userAccess >= 0)
1225 1225
 			{
1226
-			    $projectstatic->ref=$objp->ref;
1227
-			    $projectstatic->statut = $objp->status;
1228
-			    $projectstatic->title = $objp->title;
1229
-			    $projectstatic->datee = $db->jdate($objp->datee);
1230
-			    $projectstatic->dateo = $db->jdate($objp->dateo);
1226
+				$projectstatic->ref=$objp->ref;
1227
+				$projectstatic->statut = $objp->status;
1228
+				$projectstatic->title = $objp->title;
1229
+				$projectstatic->datee = $db->jdate($objp->datee);
1230
+				$projectstatic->dateo = $db->jdate($objp->dateo);
1231 1231
 
1232 1232
 
1233 1233
 				print '<tr class="oddeven">';
@@ -1238,41 +1238,41 @@  discard block
 block discarded – undo
1238 1238
 				print '<td>';
1239 1239
 				if ($objp->fk_soc > 0)
1240 1240
 				{
1241
-    				$thirdpartystatic->id=$objp->fk_soc;
1242
-    				$thirdpartystatic->ref=$objp->socname;
1243
-    				$thirdpartystatic->name=$objp->socname;
1244
-    				print $thirdpartystatic->getNomUrl(1);
1241
+					$thirdpartystatic->id=$objp->fk_soc;
1242
+					$thirdpartystatic->ref=$objp->socname;
1243
+					$thirdpartystatic->name=$objp->socname;
1244
+					print $thirdpartystatic->getNomUrl(1);
1245 1245
 				}
1246 1246
 				print '</td>';
1247 1247
 				if (! empty($conf->global->PROJECT_USE_OPPORTUNITIES))
1248 1248
 				{
1249 1249
 					print '<td align="right">';
1250
-        			if ($objp->opp_amount) print price($objp->opp_amount, 0, '', 1, -1, -1, $conf->currency);
1250
+					if ($objp->opp_amount) print price($objp->opp_amount, 0, '', 1, -1, -1, $conf->currency);
1251 1251
 					print '</td>';
1252 1252
 					print '<td align="right">';
1253 1253
 					$code = dol_getIdFromCode($db, $objp->opp_status, 'c_lead_status', 'rowid', 'code');
1254
-        			if ($code) print $langs->trans("OppStatus".$code);
1254
+					if ($code) print $langs->trans("OppStatus".$code);
1255 1255
 					print '</td>';
1256 1256
 				}
1257 1257
 				if (empty($conf->global->PROJECT_HIDE_TASKS))
1258 1258
 				{
1259
-				    print '<td align="right">'.$objp->nb.'</td>';
1260
-
1261
-    				$plannedworkload=$objp->planned_workload;
1262
-    				$total_plannedworkload+=$plannedworkload;
1263
-    				if (! in_array('plannedworkload', $hiddenfields))
1264
-    				{
1265
-    				    print '<td align="right">'.($plannedworkload?convertSecondToTime($plannedworkload):'').'</td>';
1266
-    				}
1267
-    				if (! in_array('declaredprogress', $hiddenfields))
1268
-    				{
1269
-    				    $declaredprogressworkload=$objp->declared_progess_workload;
1270
-        				$total_declaredprogressworkload+=$declaredprogressworkload;
1271
-        				print '<td align="right">';
1272
-        				//print $objp->planned_workload.'-'.$objp->declared_progess_workload."<br>";
1273
-        				print ($plannedworkload?round(100*$declaredprogressworkload/$plannedworkload,0).'%':'');
1274
-        				print '</td>';
1275
-    				}
1259
+					print '<td align="right">'.$objp->nb.'</td>';
1260
+
1261
+					$plannedworkload=$objp->planned_workload;
1262
+					$total_plannedworkload+=$plannedworkload;
1263
+					if (! in_array('plannedworkload', $hiddenfields))
1264
+					{
1265
+						print '<td align="right">'.($plannedworkload?convertSecondToTime($plannedworkload):'').'</td>';
1266
+					}
1267
+					if (! in_array('declaredprogress', $hiddenfields))
1268
+					{
1269
+						$declaredprogressworkload=$objp->declared_progess_workload;
1270
+						$total_declaredprogressworkload+=$declaredprogressworkload;
1271
+						print '<td align="right">';
1272
+						//print $objp->planned_workload.'-'.$objp->declared_progess_workload."<br>";
1273
+						print ($plannedworkload?round(100*$declaredprogressworkload/$plannedworkload,0).'%':'');
1274
+						print '</td>';
1275
+					}
1276 1276
 				}
1277 1277
 
1278 1278
 				print '<td align="right">'.$projectstatic->getLibStatut(3).'</td>';
@@ -1295,12 +1295,12 @@  discard block
 block discarded – undo
1295 1295
 		}
1296 1296
 		if (empty($conf->global->PROJECT_HIDE_TASKS))
1297 1297
 		{
1298
-            print '<td class="liste_total" align="right">'.$total_task.'</td>';
1299
-            if (! in_array('plannedworkload', $hiddenfields))  print '<td class="liste_total" align="right">'.($total_plannedworkload?convertSecondToTime($total_plannedworkload):'').'</td>';
1300
-            if (! in_array('declaredprogress', $hiddenfields)) print '<td class="liste_total" align="right">'.($total_plannedworkload?round(100*$total_declaredprogressworkload/$total_plannedworkload,0).'%':'').'</td>';
1298
+			print '<td class="liste_total" align="right">'.$total_task.'</td>';
1299
+			if (! in_array('plannedworkload', $hiddenfields))  print '<td class="liste_total" align="right">'.($total_plannedworkload?convertSecondToTime($total_plannedworkload):'').'</td>';
1300
+			if (! in_array('declaredprogress', $hiddenfields)) print '<td class="liste_total" align="right">'.($total_plannedworkload?round(100*$total_declaredprogressworkload/$total_plannedworkload,0).'%':'').'</td>';
1301 1301
 		}
1302 1302
 		print '<td class="liste_total"></td>';
1303
-        print '</tr>';
1303
+		print '</tr>';
1304 1304
 
1305 1305
 		$db->free($resql);
1306 1306
 	}
Please login to merge, or discard this patch.
Spacing   +279 added lines, -279 removed lines patch added patch discarded remove patch
@@ -44,16 +44,16 @@  discard block
 block discarded – undo
44 44
 	$head[$h][2] = 'project';
45 45
 	$h++;
46 46
 
47
-    $nbContact = count($object->liste_contact(-1,'internal')) + count($object->liste_contact(-1,'external'));
47
+    $nbContact = count($object->liste_contact(-1, 'internal')) + count($object->liste_contact(-1, 'external'));
48 48
 	$head[$h][0] = DOL_URL_ROOT.'/projet/contact.php?id='.$object->id;
49 49
 	$head[$h][1] = $langs->trans("ProjectContact");
50
-	if ($nbContact > 0) $head[$h][1].= ' <span class="badge">'.$nbContact.'</span>';
50
+	if ($nbContact > 0) $head[$h][1] .= ' <span class="badge">'.$nbContact.'</span>';
51 51
 	$head[$h][2] = 'contact';
52 52
 	$h++;
53 53
 
54
-	if (! empty($conf->fournisseur->enabled) || ! empty($conf->propal->enabled) || ! empty($conf->commande->enabled)
55
-	|| ! empty($conf->facture->enabled) || ! empty($conf->contrat->enabled)
56
-	|| ! empty($conf->ficheinter->enabled) || ! empty($conf->agenda->enabled) || ! empty($conf->deplacement->enabled))
54
+	if (!empty($conf->fournisseur->enabled) || !empty($conf->propal->enabled) || !empty($conf->commande->enabled)
55
+	|| !empty($conf->facture->enabled) || !empty($conf->contrat->enabled)
56
+	|| !empty($conf->ficheinter->enabled) || !empty($conf->agenda->enabled) || !empty($conf->deplacement->enabled))
57 57
 	{
58 58
 		$head[$h][0] = DOL_URL_ROOT.'/projet/element.php?id='.$object->id;
59 59
 		$head[$h][1] = $langs->trans("ProjectOverview");
@@ -65,29 +65,29 @@  discard block
 block discarded – undo
65 65
 	// Entries must be declared in modules descriptor with line
66 66
 	// $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__');   to add new tab
67 67
 	// $this->tabs = array('entity:-tabname);   												to remove a tab
68
-	complete_head_from_modules($conf,$langs,$object,$head,$h,'project');
68
+	complete_head_from_modules($conf, $langs, $object, $head, $h, 'project');
69 69
 
70 70
 
71 71
 	if (empty($conf->global->MAIN_DISABLE_NOTES_TAB))
72 72
     {
73 73
     	$nbNote = 0;
74
-        if(!empty($object->note_private)) $nbNote++;
75
-		if(!empty($object->note_public)) $nbNote++;
74
+        if (!empty($object->note_private)) $nbNote++;
75
+		if (!empty($object->note_public)) $nbNote++;
76 76
 		$head[$h][0] = DOL_URL_ROOT.'/projet/note.php?id='.$object->id;
77 77
 		$head[$h][1] = $langs->trans('Notes');
78
-		if ($nbNote > 0) $head[$h][1].= ' <span class="badge">'.$nbNote.'</span>';
78
+		if ($nbNote > 0) $head[$h][1] .= ' <span class="badge">'.$nbNote.'</span>';
79 79
 		$head[$h][2] = 'notes';
80 80
 		$h++;
81 81
     }
82 82
 
83 83
 	require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
84 84
     require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php';
85
-	$upload_dir = $conf->projet->dir_output . "/" . dol_sanitizeFileName($object->ref);
86
-	$nbFiles = count(dol_dir_list($upload_dir,'files',0,'','(\.meta|_preview.*\.png)$'));
87
-    $nbLinks=Link::count($db, $object->element, $object->id);
85
+	$upload_dir = $conf->projet->dir_output."/".dol_sanitizeFileName($object->ref);
86
+	$nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$'));
87
+    $nbLinks = Link::count($db, $object->element, $object->id);
88 88
 	$head[$h][0] = DOL_URL_ROOT.'/projet/document.php?id='.$object->id;
89 89
 	$head[$h][1] = $langs->trans('Documents');
90
-	if (($nbFiles+$nbLinks) > 0) $head[$h][1].= ' <span class="badge">'.($nbFiles+$nbLinks).'</span>';
90
+	if (($nbFiles + $nbLinks) > 0) $head[$h][1] .= ' <span class="badge">'.($nbFiles + $nbLinks).'</span>';
91 91
 	$head[$h][2] = 'document';
92 92
 	$h++;
93 93
 
@@ -98,15 +98,15 @@  discard block
 block discarded – undo
98 98
 		$head[$h][1] = $langs->trans("Tasks");
99 99
 
100 100
 		require_once DOL_DOCUMENT_ROOT.'/projet/class/task.class.php';
101
-		$taskstatic=new Task($db);
102
-		$nbTasks=count($taskstatic->getTasksArray(0, 0, $object->id, 0, 0));
103
-		if ($nbTasks > 0) $head[$h][1].= ' <span class="badge">'.($nbTasks).'</span>';
101
+		$taskstatic = new Task($db);
102
+		$nbTasks = count($taskstatic->getTasksArray(0, 0, $object->id, 0, 0));
103
+		if ($nbTasks > 0) $head[$h][1] .= ' <span class="badge">'.($nbTasks).'</span>';
104 104
 		$head[$h][2] = 'tasks';
105 105
 		$h++;
106 106
 
107 107
 		$head[$h][0] = DOL_URL_ROOT.'/projet/ganttview.php?id='.$object->id;
108 108
 		$head[$h][1] = $langs->trans("Gantt");
109
-		if ($nbTasks > 0) $head[$h][1].= ' <span class="badge">'.($nbTasks).'</span>';
109
+		if ($nbTasks > 0) $head[$h][1] .= ' <span class="badge">'.($nbTasks).'</span>';
110 110
 		$head[$h][2] = 'gantt';
111 111
 		$h++;
112 112
 	}
@@ -117,22 +117,22 @@  discard block
 block discarded – undo
117 117
 		$nbComments = $object->getNbComments();
118 118
 		$head[$h][0] = DOL_URL_ROOT.'/projet/comment.php?id='.$object->id;
119 119
 		$head[$h][1] = $langs->trans("CommentLink");
120
-		if ($nbComments > 0) $head[$h][1].= ' <span class="badge">'.$nbComments.'</span>';
120
+		if ($nbComments > 0) $head[$h][1] .= ' <span class="badge">'.$nbComments.'</span>';
121 121
 		$head[$h][2] = 'project_comment';
122 122
 		$h++;
123 123
 	}
124 124
 
125 125
 	$head[$h][0] = DOL_URL_ROOT.'/projet/info.php?id='.$object->id;
126
-    $head[$h][1].= $langs->trans("Events");
127
-    if (! empty($conf->agenda->enabled) && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read) ))
126
+    $head[$h][1] .= $langs->trans("Events");
127
+    if (!empty($conf->agenda->enabled) && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read)))
128 128
     {
129
-        $head[$h][1].= '/';
130
-        $head[$h][1].= $langs->trans("Agenda");
129
+        $head[$h][1] .= '/';
130
+        $head[$h][1] .= $langs->trans("Agenda");
131 131
     }
132 132
 	$head[$h][2] = 'agenda';
133 133
 	$h++;
134 134
 
135
-	complete_head_from_modules($conf,$langs,$object,$head,$h,'project','remove');
135
+	complete_head_from_modules($conf, $langs, $object, $head, $h, 'project', 'remove');
136 136
 
137 137
 	return $head;
138 138
 }
@@ -150,20 +150,20 @@  discard block
 block discarded – undo
150 150
 	$h = 0;
151 151
 	$head = array();
152 152
 
153
-	$head[$h][0] = DOL_URL_ROOT.'/projet/tasks/task.php?id='.$object->id.(GETPOST('withproject')?'&withproject=1':'');
153
+	$head[$h][0] = DOL_URL_ROOT.'/projet/tasks/task.php?id='.$object->id.(GETPOST('withproject') ? '&withproject=1' : '');
154 154
 	$head[$h][1] = $langs->trans("Card");
155 155
 	$head[$h][2] = 'task_task';
156 156
 	$h++;
157 157
 
158
-	$nbContact = count($object->liste_contact(-1,'internal')) + count($object->liste_contact(-1,'external'));
159
-	$head[$h][0] = DOL_URL_ROOT.'/projet/tasks/contact.php?id='.$object->id.(GETPOST('withproject')?'&withproject=1':'');
158
+	$nbContact = count($object->liste_contact(-1, 'internal')) + count($object->liste_contact(-1, 'external'));
159
+	$head[$h][0] = DOL_URL_ROOT.'/projet/tasks/contact.php?id='.$object->id.(GETPOST('withproject') ? '&withproject=1' : '');
160 160
 	$head[$h][1] = $langs->trans("TaskRessourceLinks");
161
-	if ($nbContact > 0) $head[$h][1].= ' <span class="badge">'.$nbContact.'</span>';
161
+	if ($nbContact > 0) $head[$h][1] .= ' <span class="badge">'.$nbContact.'</span>';
162 162
 	$head[$h][2] = 'task_contact';
163 163
 	$h++;
164 164
 
165 165
 	// Is there timespent ?
166
-	$nbTimeSpent=0;
166
+	$nbTimeSpent = 0;
167 167
 	$sql = "SELECT t.rowid";
168 168
 	$sql .= " FROM ".MAIN_DB_PREFIX."projet_task_time as t, ".MAIN_DB_PREFIX."projet_task as pt, ".MAIN_DB_PREFIX."user as u";
169 169
 	$sql .= " WHERE t.fk_user = u.rowid AND t.fk_task = pt.rowid";
@@ -172,13 +172,13 @@  discard block
 block discarded – undo
172 172
 	if ($resql)
173 173
 	{
174 174
 	    $obj = $db->fetch_object($resql);
175
-	    if ($obj) $nbTimeSpent=1;
175
+	    if ($obj) $nbTimeSpent = 1;
176 176
 	}
177 177
 	else dol_print_error($db);
178 178
 
179
-	$head[$h][0] = DOL_URL_ROOT.'/projet/tasks/time.php?id='.$object->id.(GETPOST('withproject')?'&withproject=1':'');
179
+	$head[$h][0] = DOL_URL_ROOT.'/projet/tasks/time.php?id='.$object->id.(GETPOST('withproject') ? '&withproject=1' : '');
180 180
 	$head[$h][1] = $langs->trans("TimeSpent");
181
-	if ($nbTimeSpent > 0) $head[$h][1].= ' <span class="badge">...</span>';
181
+	if ($nbTimeSpent > 0) $head[$h][1] .= ' <span class="badge">...</span>';
182 182
 	$head[$h][2] = 'task_time';
183 183
 	$h++;
184 184
 
@@ -186,28 +186,28 @@  discard block
 block discarded – undo
186 186
 	// Entries must be declared in modules descriptor with line
187 187
 	// $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__');   to add new tab
188 188
 	// $this->tabs = array('entity:-tabname);   												to remove a tab
189
-	complete_head_from_modules($conf,$langs,$object,$head,$h,'task');
189
+	complete_head_from_modules($conf, $langs, $object, $head, $h, 'task');
190 190
 
191 191
 	if (empty($conf->global->MAIN_DISABLE_NOTES_TAB))
192 192
     {
193 193
     	$nbNote = 0;
194
-        if(!empty($object->note_private)) $nbNote++;
195
-		if(!empty($object->note_public)) $nbNote++;
196
-		$head[$h][0] = DOL_URL_ROOT.'/projet/tasks/note.php?id='.$object->id.(GETPOST('withproject')?'&withproject=1':'');
194
+        if (!empty($object->note_private)) $nbNote++;
195
+		if (!empty($object->note_public)) $nbNote++;
196
+		$head[$h][0] = DOL_URL_ROOT.'/projet/tasks/note.php?id='.$object->id.(GETPOST('withproject') ? '&withproject=1' : '');
197 197
 		$head[$h][1] = $langs->trans('Notes');
198
-		if ($nbNote > 0) $head[$h][1].= ' <span class="badge">'.$nbNote.'</span>';
198
+		if ($nbNote > 0) $head[$h][1] .= ' <span class="badge">'.$nbNote.'</span>';
199 199
 		$head[$h][2] = 'task_notes';
200 200
 		$h++;
201 201
     }
202 202
 
203
-	$head[$h][0] = DOL_URL_ROOT.'/projet/tasks/document.php?id='.$object->id.(GETPOST('withproject')?'&withproject=1':'');
204
-	$filesdir = $conf->projet->dir_output . "/" . dol_sanitizeFileName($object->project->ref) . '/' .dol_sanitizeFileName($object->ref);
203
+	$head[$h][0] = DOL_URL_ROOT.'/projet/tasks/document.php?id='.$object->id.(GETPOST('withproject') ? '&withproject=1' : '');
204
+	$filesdir = $conf->projet->dir_output."/".dol_sanitizeFileName($object->project->ref).'/'.dol_sanitizeFileName($object->ref);
205 205
 	include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
206 206
 	include_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php';
207
-	$nbFiles = count(dol_dir_list($filesdir,'files',0,'','(\.meta|_preview.*\.png)$'));
208
-    $nbLinks=Link::count($db, $object->element, $object->id);
207
+	$nbFiles = count(dol_dir_list($filesdir, 'files', 0, '', '(\.meta|_preview.*\.png)$'));
208
+    $nbLinks = Link::count($db, $object->element, $object->id);
209 209
 	$head[$h][1] = $langs->trans('Documents');
210
-	if (($nbFiles+$nbLinks) > 0) $head[$h][1].= ' <span class="badge">'.($nbFiles+$nbLinks).'</span>';
210
+	if (($nbFiles + $nbLinks) > 0) $head[$h][1] .= ' <span class="badge">'.($nbFiles + $nbLinks).'</span>';
211 211
 	$head[$h][2] = 'task_document';
212 212
 	$h++;
213 213
 
@@ -215,14 +215,14 @@  discard block
 block discarded – undo
215 215
 	if (!empty($conf->global->PROJECT_ALLOW_COMMENT_ON_TASK))
216 216
 	{
217 217
 		$nbComments = $object->getNbComments();
218
-		$head[$h][0] = DOL_URL_ROOT.'/projet/tasks/comment.php?id='.$object->id.(GETPOST('withproject')?'&withproject=1':'');
218
+		$head[$h][0] = DOL_URL_ROOT.'/projet/tasks/comment.php?id='.$object->id.(GETPOST('withproject') ? '&withproject=1' : '');
219 219
 		$head[$h][1] = $langs->trans("CommentLink");
220
-		if ($nbComments > 0) $head[$h][1].= ' <span class="badge">'.$nbComments.'</span>';
220
+		if ($nbComments > 0) $head[$h][1] .= ' <span class="badge">'.$nbComments.'</span>';
221 221
 		$head[$h][2] = 'task_comment';
222 222
 		$h++;
223 223
 	}
224 224
 
225
-	complete_head_from_modules($conf,$langs,$object,$head,$h,'task','remove');
225
+	complete_head_from_modules($conf, $langs, $object, $head, $h, 'task', 'remove');
226 226
 
227 227
 	return $head;
228 228
 }
@@ -234,7 +234,7 @@  discard block
 block discarded – undo
234 234
  * @param   string  $fuser      Filter on user
235 235
  * @return  array				Array of tabs to show
236 236
  */
237
-function project_timesheet_prepare_head($mode, $fuser=null)
237
+function project_timesheet_prepare_head($mode, $fuser = null)
238 238
 {
239 239
 	global $langs, $conf, $user;
240 240
 	$h = 0;
@@ -242,13 +242,13 @@  discard block
 block discarded – undo
242 242
 
243 243
 	$h = 0;
244 244
 
245
-	$param='';
246
-	$param.=($mode?'&mode='.$mode:'');
247
-	if (is_object($fuser) && $fuser->id > 0 && $fuser->id != $user->id) $param.='&search_usertoprocessid='.$fuser->id;
245
+	$param = '';
246
+	$param .= ($mode ? '&mode='.$mode : '');
247
+	if (is_object($fuser) && $fuser->id > 0 && $fuser->id != $user->id) $param .= '&search_usertoprocessid='.$fuser->id;
248 248
 
249 249
 	if (empty($conf->global->PROJECT_DISABLE_TIMESHEET_PERWEEK))
250 250
 	{
251
-		$head[$h][0] = DOL_URL_ROOT."/projet/activity/perweek.php".($param?'?'.$param:'');
251
+		$head[$h][0] = DOL_URL_ROOT."/projet/activity/perweek.php".($param ? '?'.$param : '');
252 252
 		$head[$h][1] = $langs->trans("InputPerWeek");
253 253
 		$head[$h][2] = 'inputperweek';
254 254
 		$h++;
@@ -256,7 +256,7 @@  discard block
 block discarded – undo
256 256
 
257 257
 	if (empty($conf->global->PROJECT_DISABLE_TIMESHEET_PERTIME))
258 258
 	{
259
-		$head[$h][0] = DOL_URL_ROOT."/projet/activity/perday.php".($param?'?'.$param:'');
259
+		$head[$h][0] = DOL_URL_ROOT."/projet/activity/perday.php".($param ? '?'.$param : '');
260 260
 		$head[$h][1] = $langs->trans("InputPerDay");
261 261
 		$head[$h][2] = 'inputperday';
262 262
 		$h++;
@@ -270,9 +270,9 @@  discard block
 block discarded – undo
270 270
 		$h++;
271 271
 	}*/
272 272
 
273
-	complete_head_from_modules($conf,$langs,null,$head,$h,'project_timesheet');
273
+	complete_head_from_modules($conf, $langs, null, $head, $h, 'project_timesheet');
274 274
 
275
-	complete_head_from_modules($conf,$langs,null,$head,$h,'project_timesheet','remove');
275
+	complete_head_from_modules($conf, $langs, null, $head, $h, 'project_timesheet', 'remove');
276 276
 
277 277
 	return $head;
278 278
 }
@@ -296,7 +296,7 @@  discard block
 block discarded – undo
296 296
 	$head[$h][2] = 'project';
297 297
 	$h++;
298 298
 
299
-	complete_head_from_modules($conf,$langs,null,$head,$h,'project_admin');
299
+	complete_head_from_modules($conf, $langs, null, $head, $h, 'project_admin');
300 300
 
301 301
 	$head[$h][0] = DOL_URL_ROOT."/projet/admin/project_extrafields.php";
302 302
 	$head[$h][1] = $langs->trans("ExtraFieldsProject");
@@ -308,7 +308,7 @@  discard block
 block discarded – undo
308 308
 	$head[$h][2] = 'attributes_task';
309 309
 	$h++;
310 310
 
311
-	complete_head_from_modules($conf,$langs,null,$head,$h,'project_admin','remove');
311
+	complete_head_from_modules($conf, $langs, null, $head, $h, 'project_admin', 'remove');
312 312
 
313 313
 	return $head;
314 314
 }
@@ -329,29 +329,29 @@  discard block
 block discarded – undo
329 329
  * @param   int         $projectidfortotallink     0 or Id of project to use on total line (link to see all time consumed for project)
330 330
  * @return	void
331 331
  */
332
-function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$taskrole, $projectsListId='', $addordertick=0, $projectidfortotallink=0)
332
+function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$taskrole, $projectsListId = '', $addordertick = 0, $projectidfortotallink = 0)
333 333
 {
334 334
 	global $user, $bc, $langs;
335 335
 	global $projectstatic, $taskstatic;
336 336
 
337
-	$lastprojectid=0;
337
+	$lastprojectid = 0;
338 338
 
339
-	$projectsArrayId=explode(',',$projectsListId);
339
+	$projectsArrayId = explode(',', $projectsListId);
340 340
 
341
-	$numlines=count($lines);
341
+	$numlines = count($lines);
342 342
 
343 343
 	// We declare counter as global because we want to edit them into recursive call
344
-	global $total_projectlinesa_spent,$total_projectlinesa_planned,$total_projectlinesa_spent_if_planned;
344
+	global $total_projectlinesa_spent, $total_projectlinesa_planned, $total_projectlinesa_spent_if_planned;
345 345
 	if ($level == 0)
346 346
 	{
347
-		$total_projectlinesa_spent=0;
348
-		$total_projectlinesa_planned=0;
349
-		$total_projectlinesa_spent_if_planned=0;
347
+		$total_projectlinesa_spent = 0;
348
+		$total_projectlinesa_planned = 0;
349
+		$total_projectlinesa_spent_if_planned = 0;
350 350
 	}
351 351
 
352
-	for ($i = 0 ; $i < $numlines ; $i++)
352
+	for ($i = 0; $i < $numlines; $i++)
353 353
 	{
354
-		if ($parent == 0 && $level >= 0) $level = 0;              // if $level = -1, we dont' use sublevel recursion, we show all lines
354
+		if ($parent == 0 && $level >= 0) $level = 0; // if $level = -1, we dont' use sublevel recursion, we show all lines
355 355
 
356 356
 		// Process line
357 357
 		// print "i:".$i."-".$lines[$i]->fk_project.'<br>';
@@ -359,26 +359,26 @@  discard block
 block discarded – undo
359 359
 		if ($lines[$i]->fk_parent == $parent || $level < 0)       // if $level = -1, we dont' use sublevel recursion, we show all lines
360 360
 		{
361 361
 			// Show task line.
362
-			$showline=1;
363
-			$showlineingray=0;
362
+			$showline = 1;
363
+			$showlineingray = 0;
364 364
 
365 365
 			// If there is filters to use
366 366
 			if (is_array($taskrole))
367 367
 			{
368 368
 				// If task not legitimate to show, search if a legitimate task exists later in tree
369
-				if (! isset($taskrole[$lines[$i]->id]) && $lines[$i]->id != $lines[$i]->fk_parent)
369
+				if (!isset($taskrole[$lines[$i]->id]) && $lines[$i]->id != $lines[$i]->fk_parent)
370 370
 				{
371 371
 					// So search if task has a subtask legitimate to show
372
-					$foundtaskforuserdeeper=0;
373
-					searchTaskInChild($foundtaskforuserdeeper,$lines[$i]->id,$lines,$taskrole);
372
+					$foundtaskforuserdeeper = 0;
373
+					searchTaskInChild($foundtaskforuserdeeper, $lines[$i]->id, $lines, $taskrole);
374 374
 					//print '$foundtaskforuserpeeper='.$foundtaskforuserdeeper.'<br>';
375 375
 					if ($foundtaskforuserdeeper > 0)
376 376
 					{
377
-						$showlineingray=1;		// We will show line but in gray
377
+						$showlineingray = 1; // We will show line but in gray
378 378
 					}
379 379
 					else
380 380
 					{
381
-						$showline=0;			// No reason to show line
381
+						$showline = 0; // No reason to show line
382 382
 					}
383 383
 				}
384 384
 			}
@@ -389,12 +389,12 @@  discard block
 block discarded – undo
389 389
 				if (empty($user->rights->projet->all->lire))
390 390
 				{
391 391
 					// User is not allowed on this project and project is not public, so we hide line
392
-					if (! in_array($lines[$i]->fk_project, $projectsArrayId))
392
+					if (!in_array($lines[$i]->fk_project, $projectsArrayId))
393 393
 					{
394 394
 						// Note that having a user assigned to a task into a project user has no permission on, should not be possible
395 395
 						// because assignement on task can be done only on contact of project.
396 396
 						// If assignement was done and after, was removed from contact of project, then we can hide the line.
397
-						$showline=0;
397
+						$showline = 0;
398 398
 					}
399 399
 				}
400 400
 			}
@@ -405,7 +405,7 @@  discard block
 block discarded – undo
405 405
 				if ($parent == 0 && $lines[$i]->fk_project != $lastprojectid)
406 406
 				{
407 407
 					$var = !$var;
408
-					$lastprojectid=$lines[$i]->fk_project;
408
+					$lastprojectid = $lines[$i]->fk_project;
409 409
 				}
410 410
 
411 411
 				print '<tr '.$bc[$var].' id="row-'.$lines[$i]->id.'">'."\n";
@@ -415,18 +415,18 @@  discard block
 block discarded – undo
415 415
 					// Project ref
416 416
 					print "<td>";
417 417
 					//if ($showlineingray) print '<i>';
418
-					$projectstatic->id=$lines[$i]->fk_project;
419
-					$projectstatic->ref=$lines[$i]->projectref;
420
-					$projectstatic->public=$lines[$i]->public;
421
-					$projectstatic->title=$lines[$i]->projectlabel;
422
-					if ($lines[$i]->public || in_array($lines[$i]->fk_project,$projectsArrayId) || ! empty($user->rights->projet->all->lire)) print $projectstatic->getNomUrl(1);
423
-					else print $projectstatic->getNomUrl(1,'nolink');
418
+					$projectstatic->id = $lines[$i]->fk_project;
419
+					$projectstatic->ref = $lines[$i]->projectref;
420
+					$projectstatic->public = $lines[$i]->public;
421
+					$projectstatic->title = $lines[$i]->projectlabel;
422
+					if ($lines[$i]->public || in_array($lines[$i]->fk_project, $projectsArrayId) || !empty($user->rights->projet->all->lire)) print $projectstatic->getNomUrl(1);
423
+					else print $projectstatic->getNomUrl(1, 'nolink');
424 424
 					//if ($showlineingray) print '</i>';
425 425
 					print "</td>";
426 426
 
427 427
 					// Project status
428 428
 					print '<td>';
429
-					$projectstatic->statut=$lines[$i]->projectstatus;
429
+					$projectstatic->statut = $lines[$i]->projectstatus;
430 430
 					print $projectstatic->getLibStatut(2);
431 431
 					print "</td>";
432 432
 				}
@@ -435,14 +435,14 @@  discard block
 block discarded – undo
435 435
 				print '<td>';
436 436
 				if ($showlineingray)
437 437
 				{
438
-					print '<i>'.img_object('','projecttask').' '.$lines[$i]->ref.'</i>';
438
+					print '<i>'.img_object('', 'projecttask').' '.$lines[$i]->ref.'</i>';
439 439
 				}
440 440
 				else
441 441
 				{
442
-					$taskstatic->id=$lines[$i]->id;
443
-					$taskstatic->ref=$lines[$i]->ref;
444
-					$taskstatic->label=($taskrole[$lines[$i]->id]?$langs->trans("YourRole").': '.$taskrole[$lines[$i]->id]:'');
445
-					print $taskstatic->getNomUrl(1,'withproject');
442
+					$taskstatic->id = $lines[$i]->id;
443
+					$taskstatic->ref = $lines[$i]->ref;
444
+					$taskstatic->label = ($taskrole[$lines[$i]->id] ? $langs->trans("YourRole").': '.$taskrole[$lines[$i]->id] : '');
445
+					print $taskstatic->getNomUrl(1, 'withproject');
446 446
 				}
447 447
 				print '</td>';
448 448
 
@@ -450,7 +450,7 @@  discard block
 block discarded – undo
450 450
 				print "<td>";
451 451
 				if ($showlineingray) print '<i>';
452 452
 				//else print '<a href="'.DOL_URL_ROOT.'/projet/tasks/task.php?id='.$lines[$i]->id.'&withproject=1">';
453
-				for ($k = 0 ; $k < $level ; $k++)
453
+				for ($k = 0; $k < $level; $k++)
454 454
 				{
455 455
 					print "&nbsp; &nbsp; &nbsp;";
456 456
 				}
@@ -461,7 +461,7 @@  discard block
 block discarded – undo
461 461
 
462 462
 				// Date start
463 463
 				print '<td align="center">';
464
-				print dol_print_date($lines[$i]->date_start,'dayhour');
464
+				print dol_print_date($lines[$i]->date_start, 'dayhour');
465 465
 				print '</td>';
466 466
 
467 467
 				// Date end
@@ -470,19 +470,19 @@  discard block
 block discarded – undo
470 470
 	            $taskstatic->progress = $lines[$i]->progress;
471 471
 	            $taskstatic->fk_statut = $lines[$i]->status;
472 472
 	            $taskstatic->datee = $lines[$i]->date_end;
473
-	            print dol_print_date($lines[$i]->date_end,'dayhour');
473
+	            print dol_print_date($lines[$i]->date_end, 'dayhour');
474 474
 	            if ($taskstatic->hasDelay()) print img_warning($langs->trans("Late"));
475 475
 				print '</td>';
476 476
 
477
-				$plannedworkloadoutputformat='allhourmin';
478
-				$timespentoutputformat='allhourmin';
479
-				if (! empty($conf->global->PROJECT_PLANNED_WORKLOAD_FORMAT)) $plannedworkloadoutputformat=$conf->global->PROJECT_PLANNED_WORKLOAD_FORMAT;
480
-				if (! empty($conf->global->PROJECT_TIMES_SPENT_FORMAT)) $timespentoutputformat=$conf->global->PROJECT_TIME_SPENT_FORMAT;
477
+				$plannedworkloadoutputformat = 'allhourmin';
478
+				$timespentoutputformat = 'allhourmin';
479
+				if (!empty($conf->global->PROJECT_PLANNED_WORKLOAD_FORMAT)) $plannedworkloadoutputformat = $conf->global->PROJECT_PLANNED_WORKLOAD_FORMAT;
480
+				if (!empty($conf->global->PROJECT_TIMES_SPENT_FORMAT)) $timespentoutputformat = $conf->global->PROJECT_TIME_SPENT_FORMAT;
481 481
 
482 482
 				// Planned Workload (in working hours)
483 483
 				print '<td align="right">';
484
-				$fullhour=convertSecondToTime($lines[$i]->planned_workload,$plannedworkloadoutputformat);
485
-				$workingdelay=convertSecondToTime($lines[$i]->planned_workload,'all',86400,7);	// TODO Replace 86400 and 7 to take account working hours per day and working day per weeks
484
+				$fullhour = convertSecondToTime($lines[$i]->planned_workload, $plannedworkloadoutputformat);
485
+				$workingdelay = convertSecondToTime($lines[$i]->planned_workload, 'all', 86400, 7); // TODO Replace 86400 and 7 to take account working hours per day and working day per weeks
486 486
 				if ($lines[$i]->planned_workload != '')
487 487
 				{
488 488
 					print $fullhour;
@@ -495,8 +495,8 @@  discard block
 block discarded – undo
495 495
 				// Time spent
496 496
 				print '<td align="right">';
497 497
 				if ($showlineingray) print '<i>';
498
-				else print '<a href="'.DOL_URL_ROOT.'/projet/tasks/time.php?id='.$lines[$i]->id.($showproject?'':'&withproject=1').'">';
499
-				if ($lines[$i]->duration) print convertSecondToTime($lines[$i]->duration,$timespentoutputformat);
498
+				else print '<a href="'.DOL_URL_ROOT.'/projet/tasks/time.php?id='.$lines[$i]->id.($showproject ? '' : '&withproject=1').'">';
499
+				if ($lines[$i]->duration) print convertSecondToTime($lines[$i]->duration, $timespentoutputformat);
500 500
 				else print '--:--';
501 501
 				if ($showlineingray) print '</i>';
502 502
 				else print '</a>';
@@ -506,7 +506,7 @@  discard block
 block discarded – undo
506 506
 				print '<td align="right">';
507 507
 				if ($lines[$i]->planned_workload || $lines[$i]->duration)
508 508
 				{
509
-					if ($lines[$i]->planned_workload) print round(100 * $lines[$i]->duration / $lines[$i]->planned_workload,2).' %';
509
+					if ($lines[$i]->planned_workload) print round(100 * $lines[$i]->duration / $lines[$i]->planned_workload, 2).' %';
510 510
 					else print '<span class="opacitymedium">'.$langs->trans('WorkloadNotDefined').'</span>';
511 511
 				}
512 512
 				print '</td>';
@@ -527,7 +527,7 @@  discard block
 block discarded – undo
527 527
 
528 528
 				print "</tr>\n";
529 529
 
530
-				if (! $showlineingray) $inc++;
530
+				if (!$showlineingray) $inc++;
531 531
 
532 532
 				if ($level >= 0)    // Call sublevels
533 533
 				{
@@ -559,12 +559,12 @@  discard block
 block discarded – undo
559 559
 		print convertSecondToTime($total_projectlinesa_planned, 'allhourmin');
560 560
 		print '</td>';
561 561
 		print '<td align="right" class="nowrap liste_total">';
562
-		if ($projectidfortotallink > 0) print '<a href="'.DOL_URL_ROOT.'/projet/tasks/time.php?projectid='.$projectidfortotallink.($showproject?'':'&withproject=1').'">';
562
+		if ($projectidfortotallink > 0) print '<a href="'.DOL_URL_ROOT.'/projet/tasks/time.php?projectid='.$projectidfortotallink.($showproject ? '' : '&withproject=1').'">';
563 563
 		print convertSecondToTime($total_projectlinesa_spent, 'allhourmin');
564 564
 		if ($projectidfortotallink > 0) print '</a>';
565 565
 		print '</td>';
566 566
 		print '<td align="right" class="nowrap liste_total">';
567
-		if ($total_projectlinesa_planned) print round(100 * $total_projectlinesa_spent / $total_projectlinesa_planned,2).' %';
567
+		if ($total_projectlinesa_planned) print round(100 * $total_projectlinesa_spent / $total_projectlinesa_planned, 2).' %';
568 568
 		print '</td>';
569 569
 		print '<td></td>';
570 570
 		if ($addordertick) print '<td class="hideonsmartphone"></td>';
@@ -596,37 +596,37 @@  discard block
 block discarded – undo
596 596
 	global $conf, $db, $user, $bc, $langs;
597 597
 	global $form, $formother, $projectstatic, $taskstatic, $thirdpartystatic;
598 598
 
599
-	$lastprojectid=0;
600
-	$workloadforid=array();
601
-	$lineswithoutlevel0=array();
599
+	$lastprojectid = 0;
600
+	$workloadforid = array();
601
+	$lineswithoutlevel0 = array();
602 602
 
603
-	$numlines=count($lines);
603
+	$numlines = count($lines);
604 604
 
605 605
 	// Create a smaller array with sublevels only to be used later. This increase dramatically performances.
606 606
 	if ($parent == 0) // Always and only if at first level
607 607
 	{
608
-	    for ($i = 0 ; $i < $numlines ; $i++)
608
+	    for ($i = 0; $i < $numlines; $i++)
609 609
 	    {
610
-	        if ($lines[$i]->fk_task_parent) $lineswithoutlevel0[]=$lines[$i];
610
+	        if ($lines[$i]->fk_task_parent) $lineswithoutlevel0[] = $lines[$i];
611 611
 	    }
612 612
 	}
613 613
 
614 614
     //dol_syslog('projectLinesPerDay inc='.$inc.' preselectedday='.$preselectedday.' task parent id='.$parent.' level='.$level." count(lines)=".$numlines." count(lineswithoutlevel0)=".count($lineswithoutlevel0));
615
-	for ($i = 0 ; $i < $numlines ; $i++)
615
+	for ($i = 0; $i < $numlines; $i++)
616 616
 	{
617 617
 		if ($parent == 0) $level = 0;
618 618
 
619 619
 		if ($lines[$i]->fk_task_parent == $parent)
620 620
 		{
621 621
 			// If we want all or we have a role on task, we show it
622
-			if (empty($mine) || ! empty($tasksrole[$lines[$i]->id]))
622
+			if (empty($mine) || !empty($tasksrole[$lines[$i]->id]))
623 623
 			{
624 624
                 //dol_syslog("projectLinesPerWeek Found line ".$i.", a qualified task (i have role or want to show all tasks) with id=".$lines[$i]->id." project id=".$lines[$i]->fk_project);
625 625
 
626 626
 				// Break on a new project
627 627
         		if ($parent == 0 && $lines[$i]->fk_project != $lastprojectid)
628 628
         		{
629
-        			$lastprojectid=$lines[$i]->fk_project;
629
+        			$lastprojectid = $lines[$i]->fk_project;
630 630
         			if ($preselectedday)
631 631
         			{
632 632
         				$projectstatic->id = $lines[$i]->fk_project;
@@ -637,17 +637,17 @@  discard block
 block discarded – undo
637 637
 			    {
638 638
     				if ($preselectedday)
639 639
     				{
640
-    			        $projectstatic->loadTimeSpent($preselectedday, 0, $fuser->id);	// Load time spent from table projet_task_time for the project into this->weekWorkLoad and this->weekWorkLoadPerTask for all days of a week
641
-	       		        $workloadforid[$projectstatic->id]=1;
640
+    			        $projectstatic->loadTimeSpent($preselectedday, 0, $fuser->id); // Load time spent from table projet_task_time for the project into this->weekWorkLoad and this->weekWorkLoadPerTask for all days of a week
641
+	       		        $workloadforid[$projectstatic->id] = 1;
642 642
     				}
643 643
 			    }
644 644
 
645
-				$projectstatic->id=$lines[$i]->fk_project;
646
-				$projectstatic->ref=$lines[$i]->projectref;
647
-				$projectstatic->title=$lines[$i]->projectlabel;
648
-				$projectstatic->public=$lines[$i]->public;
645
+				$projectstatic->id = $lines[$i]->fk_project;
646
+				$projectstatic->ref = $lines[$i]->projectref;
647
+				$projectstatic->title = $lines[$i]->projectlabel;
648
+				$projectstatic->public = $lines[$i]->public;
649 649
 
650
-				$taskstatic->id=$lines[$i]->id;
650
+				$taskstatic->id = $lines[$i]->id;
651 651
 
652 652
 				print '<tr class="oddeven">'."\n";
653 653
 
@@ -660,33 +660,33 @@  discard block
 block discarded – undo
660 660
 
661 661
 				// Project
662 662
 				print "<td>";
663
-				print $projectstatic->getNomUrl(1,'',0,$langs->transnoentitiesnoconv("YourRole").': '.$projectsrole[$lines[$i]->fk_project]);
663
+				print $projectstatic->getNomUrl(1, '', 0, $langs->transnoentitiesnoconv("YourRole").': '.$projectsrole[$lines[$i]->fk_project]);
664 664
 				print "</td>";
665 665
 
666 666
 				// Ref
667 667
 				print '<td>';
668
-				$taskstatic->ref=($lines[$i]->ref?$lines[$i]->ref:$lines[$i]->id);
669
-				print $taskstatic->getNomUrl(1,'withproject');
668
+				$taskstatic->ref = ($lines[$i]->ref ? $lines[$i]->ref : $lines[$i]->id);
669
+				print $taskstatic->getNomUrl(1, 'withproject');
670 670
 				print '</td>';
671 671
 
672
-				if (! empty($conf->global->PROJECT_LINES_PERDAY_SHOW_THIRDPARTY))
672
+				if (!empty($conf->global->PROJECT_LINES_PERDAY_SHOW_THIRDPARTY))
673 673
 				{
674 674
 				    // Thirdparty
675 675
 				    print '<td class="tdoverflowmax100">';
676
-				    $thirdpartystatic->id=$lines[$i]->socid;
677
-				    $thirdpartystatic->name=$lines[$i]->thirdparty_name;
676
+				    $thirdpartystatic->id = $lines[$i]->socid;
677
+				    $thirdpartystatic->name = $lines[$i]->thirdparty_name;
678 678
 				    print $thirdpartystatic->getNomUrl(1, 'project', 10);
679 679
 				    print '</td>';
680 680
 				}
681 681
 
682 682
 				// Label task
683 683
 				print "<td>";
684
-				for ($k = 0 ; $k < $level ; $k++) print "&nbsp;&nbsp;&nbsp;";
685
-				$taskstatic->id=$lines[$i]->id;
686
-				$taskstatic->ref=$lines[$i]->label;
687
-				$taskstatic->date_start=$lines[$i]->date_start;
688
-				$taskstatic->date_end=$lines[$i]->date_end;
689
-				print $taskstatic->getNomUrl(0,'withproject');
684
+				for ($k = 0; $k < $level; $k++) print "&nbsp;&nbsp;&nbsp;";
685
+				$taskstatic->id = $lines[$i]->id;
686
+				$taskstatic->ref = $lines[$i]->label;
687
+				$taskstatic->date_start = $lines[$i]->date_start;
688
+				$taskstatic->date_end = $lines[$i]->date_end;
689
+				print $taskstatic->getNomUrl(0, 'withproject');
690 690
 				//print "<br>";
691 691
 				//for ($k = 0 ; $k < $level ; $k++) print "&nbsp;&nbsp;&nbsp;";
692 692
 				//print get_date_range($lines[$i]->date_start,$lines[$i]->date_end,'',$langs,0);
@@ -694,13 +694,13 @@  discard block
 block discarded – undo
694 694
 
695 695
 				// Planned Workload
696 696
 				print '<td align="right">';
697
-				if ($lines[$i]->planned_workload) print convertSecondToTime($lines[$i]->planned_workload,'allhourmin');
697
+				if ($lines[$i]->planned_workload) print convertSecondToTime($lines[$i]->planned_workload, 'allhourmin');
698 698
 				else print '--:--';
699 699
 				print '</td>';
700 700
 
701 701
 				// Progress declared %
702 702
 				print '<td align="right">';
703
-				print $formother->select_percent($lines[$i]->progress, $lines[$i]->id . 'progress');
703
+				print $formother->select_percent($lines[$i]->progress, $lines[$i]->id.'progress');
704 704
 				print '</td>';
705 705
 
706 706
 				// Time spent by everybody
@@ -709,7 +709,7 @@  discard block
 block discarded – undo
709 709
 				if ($lines[$i]->duration)
710 710
 				{
711 711
 					print '<a href="'.DOL_URL_ROOT.'/projet/tasks/time.php?id='.$lines[$i]->id.'">';
712
-					print convertSecondToTime($lines[$i]->duration,'allhourmin');
712
+					print convertSecondToTime($lines[$i]->duration, 'allhourmin');
713 713
 					print '</a>';
714 714
 				}
715 715
 				else print '--:--';
@@ -717,56 +717,56 @@  discard block
 block discarded – undo
717 717
 
718 718
 				// Time spent by user
719 719
 				print '<td align="right">';
720
-				$tmptimespent=$taskstatic->getSummaryOfTimeSpent($fuser->id);
721
-				if ($tmptimespent['total_duration']) print convertSecondToTime($tmptimespent['total_duration'],'allhourmin');
720
+				$tmptimespent = $taskstatic->getSummaryOfTimeSpent($fuser->id);
721
+				if ($tmptimespent['total_duration']) print convertSecondToTime($tmptimespent['total_duration'], 'allhourmin');
722 722
 				else print '--:--';
723 723
 				print "</td>\n";
724 724
 
725
-				$disabledproject=1;$disabledtask=1;
725
+				$disabledproject = 1; $disabledtask = 1;
726 726
 				//print "x".$lines[$i]->fk_project;
727 727
 				//var_dump($lines[$i]);
728 728
 				//var_dump($projectsrole[$lines[$i]->fk_project]);
729 729
 				// If at least one role for project
730
-				if ($lines[$i]->public || ! empty($projectsrole[$lines[$i]->fk_project]) || $user->rights->projet->all->creer)
730
+				if ($lines[$i]->public || !empty($projectsrole[$lines[$i]->fk_project]) || $user->rights->projet->all->creer)
731 731
 				{
732
-					$disabledproject=0;
733
-					$disabledtask=0;
732
+					$disabledproject = 0;
733
+					$disabledtask = 0;
734 734
 				}
735 735
 				// If $restricteditformytask is on and I have no role on task, i disable edit
736 736
 				if ($restricteditformytask && empty($tasksrole[$lines[$i]->id]))
737 737
 				{
738
-					$disabledtask=1;
738
+					$disabledtask = 1;
739 739
 				}
740 740
 
741 741
 				// Form to add new time
742 742
 				print '<td class="nowrap" align="center">';
743
-				$tableCell=$form->select_date($preselectedday,$lines[$i]->id,1,1,2,"addtime",0,0,1,$disabledtask);
743
+				$tableCell = $form->select_date($preselectedday, $lines[$i]->id, 1, 1, 2, "addtime", 0, 0, 1, $disabledtask);
744 744
 				print $tableCell;
745 745
 				print '</td>';
746 746
 
747
-				$cssonholiday='';
748
-				if (! $isavailable[$preselectedday]['morning'] && ! $isavailable[$preselectedday]['afternoon'])   $cssonholiday.='onholidayallday ';
749
-				elseif (! $isavailable[$preselectedday]['morning'])   $cssonholiday.='onholidaymorning ';
750
-				elseif (! $isavailable[$preselectedday]['afternoon']) $cssonholiday.='onholidayafternoon ';
747
+				$cssonholiday = '';
748
+				if (!$isavailable[$preselectedday]['morning'] && !$isavailable[$preselectedday]['afternoon'])   $cssonholiday .= 'onholidayallday ';
749
+				elseif (!$isavailable[$preselectedday]['morning'])   $cssonholiday .= 'onholidaymorning ';
750
+				elseif (!$isavailable[$preselectedday]['afternoon']) $cssonholiday .= 'onholidayafternoon ';
751 751
 
752 752
 				// Duration
753
-				print '<td align="center" class="duration'.($cssonholiday?' '.$cssonholiday:'').'">';
753
+				print '<td align="center" class="duration'.($cssonholiday ? ' '.$cssonholiday : '').'">';
754 754
 
755 755
 				$dayWorkLoad = $projectstatic->weekWorkLoadPerTask[$preselectedday][$lines[$i]->id];
756
-		        $alreadyspent='';
757
-		        if ($dayWorkLoad > 0) $alreadyspent=convertSecondToTime($dayWorkLoad,'allhourmin');
756
+		        $alreadyspent = '';
757
+		        if ($dayWorkLoad > 0) $alreadyspent = convertSecondToTime($dayWorkLoad, 'allhourmin');
758 758
 
759 759
 		        $idw = 0;
760 760
 
761
-				$tableCell='';
762
-				$tableCell.='<span class="timesheetalreadyrecorded"><input type="text" class="center" size="2" disabled id="timespent['.$inc.']['.$idw.']" name="task['.$lines[$i]->id.']['.$idw.']" value="'.$alreadyspent.'"></span>';
763
-                $tableCell.='<span class="hideonsmartphone"> + </span>';
761
+				$tableCell = '';
762
+				$tableCell .= '<span class="timesheetalreadyrecorded"><input type="text" class="center" size="2" disabled id="timespent['.$inc.']['.$idw.']" name="task['.$lines[$i]->id.']['.$idw.']" value="'.$alreadyspent.'"></span>';
763
+                $tableCell .= '<span class="hideonsmartphone"> + </span>';
764 764
 				//$tableCell.='&nbsp;&nbsp;&nbsp;';
765
-				$tableCell.=$form->select_duration($lines[$i]->id.'duration','',$disabledtask,'text',0,1);
765
+				$tableCell .= $form->select_duration($lines[$i]->id.'duration', '', $disabledtask, 'text', 0, 1);
766 766
 				//$tableCell.='&nbsp;<input type="submit" class="button"'.($disabledtask?' disabled':'').' value="'.$langs->trans("Add").'">';
767 767
 				print $tableCell;
768 768
 
769
-				$modeinput='hours';
769
+				$modeinput = 'hours';
770 770
 
771 771
 				print '<script type="text/javascript">';
772 772
 				print "jQuery(document).ready(function () {\n";
@@ -777,19 +777,19 @@  discard block
 block discarded – undo
777 777
 				print '</td>';
778 778
 
779 779
 				print '<td align="right">';
780
-				print '<textarea name="'.$lines[$i]->id.'note" rows="'.ROWS_2.'" id="'.$lines[$i]->id.'note"'.($disabledtask?' disabled="disabled"':'').'>';
780
+				print '<textarea name="'.$lines[$i]->id.'note" rows="'.ROWS_2.'" id="'.$lines[$i]->id.'note"'.($disabledtask ? ' disabled="disabled"' : '').'>';
781 781
 				print '</textarea>';
782 782
 				print '</td>';
783 783
 
784 784
 				// Warning
785 785
 				print '<td align="right">';
786
-   				if ((! $lines[$i]->public) && $disabledproject) print $form->textwithpicto('',$langs->trans("UserIsNotContactOfProject"));
786
+   				if ((!$lines[$i]->public) && $disabledproject) print $form->textwithpicto('', $langs->trans("UserIsNotContactOfProject"));
787 787
    				else if ($disabledtask)
788 788
    				{
789 789
    					$titleassigntask = $langs->trans("AssignTaskToMe");
790 790
    					if ($fuser->id != $user->id) $titleassigntask = $langs->trans("AssignTaskToUser", '...');
791 791
 
792
-   					print $form->textwithpicto('',$langs->trans("TaskIsNotAssignedToUser", $titleassigntask));
792
+   					print $form->textwithpicto('', $langs->trans("TaskIsNotAssignedToUser", $titleassigntask));
793 793
    				}
794 794
 				print '</td>';
795 795
 
@@ -836,52 +836,52 @@  discard block
 block discarded – undo
836 836
 	global $conf, $db, $user, $bc, $langs;
837 837
 	global $form, $formother, $projectstatic, $taskstatic, $thirdpartystatic;
838 838
 
839
-	$numlines=count($lines);
839
+	$numlines = count($lines);
840 840
 
841
-	$lastprojectid=0;
842
-	$workloadforid=array();
843
-	$lineswithoutlevel0=array();
841
+	$lastprojectid = 0;
842
+	$workloadforid = array();
843
+	$lineswithoutlevel0 = array();
844 844
 
845 845
 	// Create a smaller array with sublevels only to be used later. This increase dramatically performances.
846 846
 	if ($parent == 0) // Always and only if at first level
847 847
 	{
848
-	    for ($i = 0 ; $i < $numlines ; $i++)
848
+	    for ($i = 0; $i < $numlines; $i++)
849 849
 	    {
850
-	       if ($lines[$i]->fk_task_parent) $lineswithoutlevel0[]=$lines[$i];
850
+	       if ($lines[$i]->fk_task_parent) $lineswithoutlevel0[] = $lines[$i];
851 851
 	    }
852 852
 	}
853 853
 
854 854
     //dol_syslog('projectLinesPerWeek inc='.$inc.' firstdaytoshow='.$firstdaytoshow.' task parent id='.$parent.' level='.$level." count(lines)=".$numlines." count(lineswithoutlevel0)=".count($lineswithoutlevel0));
855 855
 
856
-	for ($i = 0 ; $i < $numlines ; $i++)
856
+	for ($i = 0; $i < $numlines; $i++)
857 857
 	{
858 858
 		if ($parent == 0) $level = 0;
859 859
 
860 860
 		if ($lines[$i]->fk_task_parent == $parent)
861 861
 		{
862 862
 			// If we want all or we have a role on task, we show it
863
-			if (empty($mine) || ! empty($tasksrole[$lines[$i]->id]))
863
+			if (empty($mine) || !empty($tasksrole[$lines[$i]->id]))
864 864
 			{
865 865
 			    //dol_syslog("projectLinesPerWeek Found line ".$i.", a qualified task (i have role or want to show all tasks) with id=".$lines[$i]->id." project id=".$lines[$i]->fk_project);
866 866
 
867 867
 			    // Break on a new project
868 868
     			if ($parent == 0 && $lines[$i]->fk_project != $lastprojectid)
869 869
     			{
870
-    				$lastprojectid=$lines[$i]->fk_project;
870
+    				$lastprojectid = $lines[$i]->fk_project;
871 871
     				$projectstatic->id = $lines[$i]->fk_project;
872 872
     			}
873 873
 
874 874
 			    if (empty($workloadforid[$projectstatic->id]))
875 875
 			    {
876
-				    $projectstatic->loadTimeSpent($firstdaytoshow, 0, $fuser->id);	// Load time spent from table projet_task_time for the project into this->weekWorkLoad and this->weekWorkLoadPerTask for all days of a week
877
-                    $workloadforid[$projectstatic->id]=1;
876
+				    $projectstatic->loadTimeSpent($firstdaytoshow, 0, $fuser->id); // Load time spent from table projet_task_time for the project into this->weekWorkLoad and this->weekWorkLoadPerTask for all days of a week
877
+                    $workloadforid[$projectstatic->id] = 1;
878 878
 			    }
879 879
 
880
-				$projectstatic->id=$lines[$i]->fk_project;
881
-				$projectstatic->ref=$lines[$i]->projectref;
882
-				$projectstatic->title=$lines[$i]->projectlabel;
883
-				$projectstatic->public=$lines[$i]->public;
884
-				$projectstatic->thirdparty_name=$lines[$i]->thirdparty_name;
880
+				$projectstatic->id = $lines[$i]->fk_project;
881
+				$projectstatic->ref = $lines[$i]->projectref;
882
+				$projectstatic->title = $lines[$i]->projectlabel;
883
+				$projectstatic->public = $lines[$i]->public;
884
+				$projectstatic->thirdparty_name = $lines[$i]->thirdparty_name;
885 885
 
886 886
 				print '<tr class="oddeven">'."\n";
887 887
 
@@ -894,34 +894,34 @@  discard block
 block discarded – undo
894 894
 
895 895
 				// Project
896 896
 				print '<td class="nowrap">';
897
-				print $projectstatic->getNomUrl(1,'',0,$langs->transnoentitiesnoconv("YourRole").': '.$projectsrole[$lines[$i]->fk_project]);
897
+				print $projectstatic->getNomUrl(1, '', 0, $langs->transnoentitiesnoconv("YourRole").': '.$projectsrole[$lines[$i]->fk_project]);
898 898
 				print "</td>";
899 899
 
900
-				if (! empty($conf->global->PROJECT_LINES_PERWEEK_SHOW_THIRDPARTY))
900
+				if (!empty($conf->global->PROJECT_LINES_PERWEEK_SHOW_THIRDPARTY))
901 901
 				{
902 902
 				    // Thirdparty
903 903
 				    print '<td class="tdoverflowmax100">';
904
-				    $thirdpartystatic->id=$lines[$i]->thirdparty_id;
905
-				    $thirdpartystatic->name=$lines[$i]->thirdparty_name;
904
+				    $thirdpartystatic->id = $lines[$i]->thirdparty_id;
905
+				    $thirdpartystatic->name = $lines[$i]->thirdparty_name;
906 906
 				    print $thirdpartystatic->getNomUrl(1, 'project');
907 907
 				    print '</td>';
908 908
 				}
909 909
 
910 910
 				// Ref
911 911
 				print '<td class="nowrap">';
912
-				$taskstatic->id=$lines[$i]->id;
913
-				$taskstatic->ref=($lines[$i]->ref?$lines[$i]->ref:$lines[$i]->id);
912
+				$taskstatic->id = $lines[$i]->id;
913
+				$taskstatic->ref = ($lines[$i]->ref ? $lines[$i]->ref : $lines[$i]->id);
914 914
 				print $taskstatic->getNomUrl(1, 'withproject', 'time');
915 915
 				print '</td>';
916 916
 
917 917
 				// Label task
918 918
 				print "<td>";
919 919
 				print '<!-- Task id = '.$lines[$i]->id.' -->';
920
-				for ($k = 0 ; $k < $level ; $k++) print "&nbsp;&nbsp;&nbsp;";
921
-				$taskstatic->id=$lines[$i]->id;
922
-				$taskstatic->ref=$lines[$i]->label;
923
-				$taskstatic->date_start=$lines[$i]->date_start;
924
-				$taskstatic->date_end=$lines[$i]->date_end;
920
+				for ($k = 0; $k < $level; $k++) print "&nbsp;&nbsp;&nbsp;";
921
+				$taskstatic->id = $lines[$i]->id;
922
+				$taskstatic->ref = $lines[$i]->label;
923
+				$taskstatic->date_start = $lines[$i]->date_start;
924
+				$taskstatic->date_end = $lines[$i]->date_end;
925 925
 				print $taskstatic->getNomUrl(0, 'withproject', 'time');
926 926
 				//print "<br>";
927 927
 				//for ($k = 0 ; $k < $level ; $k++) print "&nbsp;&nbsp;&nbsp;";
@@ -930,13 +930,13 @@  discard block
 block discarded – undo
930 930
 
931 931
 				// Planned Workload
932 932
 				print '<td align="right">';
933
-				if ($lines[$i]->planned_workload) print convertSecondToTime($lines[$i]->planned_workload,'allhourmin');
933
+				if ($lines[$i]->planned_workload) print convertSecondToTime($lines[$i]->planned_workload, 'allhourmin');
934 934
 				else print '--:--';
935 935
 				print '</td>';
936 936
 
937 937
 				// Progress declared %
938 938
 				print '<td align="right">';
939
-				print $formother->select_percent($lines[$i]->progress, $lines[$i]->id . 'progress');
939
+				print $formother->select_percent($lines[$i]->progress, $lines[$i]->id.'progress');
940 940
 				print '</td>';
941 941
 
942 942
 				// Time spent by everybody
@@ -945,7 +945,7 @@  discard block
 block discarded – undo
945 945
 				if ($lines[$i]->duration)
946 946
 				{
947 947
 					print '<a href="'.DOL_URL_ROOT.'/projet/tasks/time.php?id='.$lines[$i]->id.'">';
948
-					print convertSecondToTime($lines[$i]->duration,'allhourmin');
948
+					print convertSecondToTime($lines[$i]->duration, 'allhourmin');
949 949
 					print '</a>';
950 950
 				}
951 951
 				else print '--:--';
@@ -953,71 +953,71 @@  discard block
 block discarded – undo
953 953
 
954 954
 				// Time spent by user
955 955
 				print '<td align="right">';
956
-				$tmptimespent=$taskstatic->getSummaryOfTimeSpent($fuser->id);
957
-				if ($tmptimespent['total_duration']) print convertSecondToTime($tmptimespent['total_duration'],'allhourmin');
956
+				$tmptimespent = $taskstatic->getSummaryOfTimeSpent($fuser->id);
957
+				if ($tmptimespent['total_duration']) print convertSecondToTime($tmptimespent['total_duration'], 'allhourmin');
958 958
 				else print '--:--';
959 959
 				print "</td>\n";
960 960
 
961
-				$disabledproject=1;$disabledtask=1;
961
+				$disabledproject = 1; $disabledtask = 1;
962 962
 				//print "x".$lines[$i]->fk_project;
963 963
 				//var_dump($lines[$i]);
964 964
 				//var_dump($projectsrole[$lines[$i]->fk_project]);
965 965
 				// If at least one role for project
966
-				if ($lines[$i]->public || ! empty($projectsrole[$lines[$i]->fk_project]) || $user->rights->projet->all->creer)
966
+				if ($lines[$i]->public || !empty($projectsrole[$lines[$i]->fk_project]) || $user->rights->projet->all->creer)
967 967
 				{
968
-					$disabledproject=0;
969
-					$disabledtask=0;
968
+					$disabledproject = 0;
969
+					$disabledtask = 0;
970 970
 				}
971 971
 				// If $restricteditformytask is on and I have no role on task, i disable edit
972 972
 				if ($restricteditformytask && empty($tasksrole[$lines[$i]->id]))
973 973
 				{
974
-					$disabledtask=1;
974
+					$disabledtask = 1;
975 975
 				}
976 976
 
977 977
 				//var_dump($projectstatic->weekWorkLoadPerTask);
978 978
 
979 979
 				// Fields to show current time
980
-				$tableCell=''; $modeinput='hours';
980
+				$tableCell = ''; $modeinput = 'hours';
981 981
 				for ($idw = 0; $idw < 7; $idw++)
982 982
 		        {
983
-					$tmpday=dol_time_plus_duree($firstdaytoshow, $idw, 'd');
983
+					$tmpday = dol_time_plus_duree($firstdaytoshow, $idw, 'd');
984 984
 
985
-					$cssonholiday='';
986
-					if (! $isavailable[$tmpday]['morning'] && ! $isavailable[$tmpday]['afternoon'])   $cssonholiday.='onholidayallday ';
987
-					elseif (! $isavailable[$tmpday]['morning'])   $cssonholiday.='onholidaymorning ';
988
-					elseif (! $isavailable[$tmpday]['afternoon']) $cssonholiday.='onholidayafternoon ';
985
+					$cssonholiday = '';
986
+					if (!$isavailable[$tmpday]['morning'] && !$isavailable[$tmpday]['afternoon'])   $cssonholiday .= 'onholidayallday ';
987
+					elseif (!$isavailable[$tmpday]['morning'])   $cssonholiday .= 'onholidaymorning ';
988
+					elseif (!$isavailable[$tmpday]['afternoon']) $cssonholiday .= 'onholidayafternoon ';
989 989
 
990
-					$tmparray=dol_getdate($tmpday);
990
+					$tmparray = dol_getdate($tmpday);
991 991
 		        	$dayWorkLoad = $projectstatic->weekWorkLoadPerTask[$tmpday][$lines[$i]->id];
992
-		        	$alreadyspent='';
993
-		        	if ($dayWorkLoad > 0) $alreadyspent=convertSecondToTime($dayWorkLoad,'allhourmin');
994
-                    $alttitle=$langs->trans("AddHereTimeSpentForDay",$tmparray['day'],$tmparray['mon']);
992
+		        	$alreadyspent = '';
993
+		        	if ($dayWorkLoad > 0) $alreadyspent = convertSecondToTime($dayWorkLoad, 'allhourmin');
994
+                    $alttitle = $langs->trans("AddHereTimeSpentForDay", $tmparray['day'], $tmparray['mon']);
995 995
 
996
-                    $tableCell ='<td align="center" class="hide'.$idw.($cssonholiday?' '.$cssonholiday:'').'">';
996
+                    $tableCell = '<td align="center" class="hide'.$idw.($cssonholiday ? ' '.$cssonholiday : '').'">';
997 997
                     if ($alreadyspent)
998 998
                     {
999
-                        $tableCell.='<span class="timesheetalreadyrecorded"><input type="text" class="center smallpadd" size="2" disabled id="timespent['.$inc.']['.$idw.']" name="task['.$lines[$i]->id.']['.$idw.']" value="'.$alreadyspent.'"></span>';
999
+                        $tableCell .= '<span class="timesheetalreadyrecorded"><input type="text" class="center smallpadd" size="2" disabled id="timespent['.$inc.']['.$idw.']" name="task['.$lines[$i]->id.']['.$idw.']" value="'.$alreadyspent.'"></span>';
1000 1000
                         //$placeholder=' placeholder="00:00"';
1001
-                        $placeholder='';
1001
+                        $placeholder = '';
1002 1002
                      	//$tableCell.='+';
1003 1003
                     }
1004
-                  	$tableCell.='<input type="text" alt="'.($disabledtask?'':$alttitle).'" title="'.($disabledtask?'':$alttitle).'" '.($disabledtask?'disabled':$placeholder).' class="center smallpadd" size="2" id="timeadded['.$inc.']['.$idw.']" name="task['.$lines[$i]->id.']['.$idw.']" value="" cols="2"  maxlength="5"';
1005
-	        		$tableCell.=' onkeypress="return regexEvent(this,event,\'timeChar\')"';
1006
-                   	$tableCell.=' onkeyup="updateTotal('.$idw.',\''.$modeinput.'\')"';
1007
-                   	$tableCell.=' onblur="regexEvent(this,event,\''.$modeinput.'\'); updateTotal('.$idw.',\''.$modeinput.'\')" />';
1008
-                   	$tableCell.='</td>';
1004
+                  	$tableCell .= '<input type="text" alt="'.($disabledtask ? '' : $alttitle).'" title="'.($disabledtask ? '' : $alttitle).'" '.($disabledtask ? 'disabled' : $placeholder).' class="center smallpadd" size="2" id="timeadded['.$inc.']['.$idw.']" name="task['.$lines[$i]->id.']['.$idw.']" value="" cols="2"  maxlength="5"';
1005
+	        		$tableCell .= ' onkeypress="return regexEvent(this,event,\'timeChar\')"';
1006
+                   	$tableCell .= ' onkeyup="updateTotal('.$idw.',\''.$modeinput.'\')"';
1007
+                   	$tableCell .= ' onblur="regexEvent(this,event,\''.$modeinput.'\'); updateTotal('.$idw.',\''.$modeinput.'\')" />';
1008
+                   	$tableCell .= '</td>';
1009 1009
                     print $tableCell;
1010 1010
 		        }
1011 1011
 
1012 1012
 		        // Warning
1013 1013
 				print '<td align="right">';
1014
-   				if ((! $lines[$i]->public) && $disabledproject) print $form->textwithpicto('',$langs->trans("UserIsNotContactOfProject"));
1014
+   				if ((!$lines[$i]->public) && $disabledproject) print $form->textwithpicto('', $langs->trans("UserIsNotContactOfProject"));
1015 1015
    				else if ($disabledtask)
1016 1016
    				{
1017 1017
    					$titleassigntask = $langs->trans("AssignTaskToMe");
1018 1018
    					if ($fuser->id != $user->id) $titleassigntask = $langs->trans("AssignTaskToUser", '...');
1019 1019
 
1020
-   					print $form->textwithpicto('',$langs->trans("TaskIsNotAssignedToUser", $titleassigntask));
1020
+   					print $form->textwithpicto('', $langs->trans("TaskIsNotAssignedToUser", $titleassigntask));
1021 1021
    				}
1022 1022
 				print '</td>';
1023 1023
 
@@ -1056,8 +1056,8 @@  discard block
 block discarded – undo
1056 1056
 function searchTaskInChild(&$inc, $parent, &$lines, &$taskrole)
1057 1057
 {
1058 1058
 	//print 'Search in line with parent id = '.$parent.'<br>';
1059
-	$numlines=count($lines);
1060
-	for ($i = 0 ; $i < $numlines ; $i++)
1059
+	$numlines = count($lines);
1060
+	for ($i = 0; $i < $numlines; $i++)
1061 1061
 	{
1062 1062
 		// Process line $lines[$i]
1063 1063
 		if ($lines[$i]->fk_parent == $parent && $lines[$i]->id != $lines[$i]->fk_parent)
@@ -1093,51 +1093,51 @@  discard block
 block discarded – undo
1093 1093
  * @param   array   $hiddenfields       List of info to not show ('projectlabel', 'declaredprogress', '...', )
1094 1094
  * @return	void
1095 1095
  */
1096
-function print_projecttasks_array($db, $form, $socid, $projectsListId, $mytasks=0, $statut=-1, $listofoppstatus=array(),$hiddenfields=array())
1096
+function print_projecttasks_array($db, $form, $socid, $projectsListId, $mytasks = 0, $statut = -1, $listofoppstatus = array(), $hiddenfields = array())
1097 1097
 {
1098
-	global $langs,$conf,$user,$bc;
1098
+	global $langs, $conf, $user, $bc;
1099 1099
 
1100 1100
 	require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
1101 1101
 
1102
-	$projectstatic=new Project($db);
1103
-    $thirdpartystatic=new Societe($db);
1102
+	$projectstatic = new Project($db);
1103
+    $thirdpartystatic = new Societe($db);
1104 1104
 
1105
-	$sortfield='';
1106
-	$sortorder='';
1107
-	$project_year_filter=0;
1105
+	$sortfield = '';
1106
+	$sortorder = '';
1107
+	$project_year_filter = 0;
1108 1108
 
1109
-	$title=$langs->trans("Projects");
1110
-	if (strcmp($statut, '') && $statut >= 0) $title=$langs->trans("Projects").' '.$langs->trans($projectstatic->statuts_long[$statut]);
1109
+	$title = $langs->trans("Projects");
1110
+	if (strcmp($statut, '') && $statut >= 0) $title = $langs->trans("Projects").' '.$langs->trans($projectstatic->statuts_long[$statut]);
1111 1111
 
1112
-	$arrayidtypeofcontact=array();
1112
+	$arrayidtypeofcontact = array();
1113 1113
 
1114 1114
 	print '<table class="noborder" width="100%">';
1115 1115
 
1116
-	$sql.= " FROM ".MAIN_DB_PREFIX."projet as p";
1116
+	$sql .= " FROM ".MAIN_DB_PREFIX."projet as p";
1117 1117
 	if ($mytasks)
1118 1118
 	{
1119
-		$sql.= ", ".MAIN_DB_PREFIX."projet_task as t";
1120
-		$sql.= ", ".MAIN_DB_PREFIX."element_contact as ec";
1121
-		$sql.= ", ".MAIN_DB_PREFIX."c_type_contact as ctc";
1119
+		$sql .= ", ".MAIN_DB_PREFIX."projet_task as t";
1120
+		$sql .= ", ".MAIN_DB_PREFIX."element_contact as ec";
1121
+		$sql .= ", ".MAIN_DB_PREFIX."c_type_contact as ctc";
1122 1122
 	}
1123 1123
 	else
1124 1124
 	{
1125
-		$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."projet_task as t ON p.rowid = t.fk_projet";
1125
+		$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."projet_task as t ON p.rowid = t.fk_projet";
1126 1126
 	}
1127
-	$sql.= " WHERE p.entity = ".$conf->entity;
1128
-	$sql.= " AND p.rowid IN (".$projectsListId.")";
1129
-	if ($socid) $sql.= "  AND (p.fk_soc IS NULL OR p.fk_soc = 0 OR p.fk_soc = ".$socid.")";
1127
+	$sql .= " WHERE p.entity = ".$conf->entity;
1128
+	$sql .= " AND p.rowid IN (".$projectsListId.")";
1129
+	if ($socid) $sql .= "  AND (p.fk_soc IS NULL OR p.fk_soc = 0 OR p.fk_soc = ".$socid.")";
1130 1130
 	if ($mytasks)
1131 1131
 	{
1132
-		$sql.= " AND p.rowid = t.fk_projet";
1133
-		$sql.= " AND ec.element_id = t.rowid";
1134
-		$sql.= " AND ec.fk_socpeople = ".$user->id;
1135
-		$sql.= " AND ec.fk_c_type_contact = ctc.rowid";   // Replace the 2 lines with ec.fk_c_type_contact in $arrayidtypeofcontact
1136
-		$sql.= " AND ctc.element = 'project_task'";
1132
+		$sql .= " AND p.rowid = t.fk_projet";
1133
+		$sql .= " AND ec.element_id = t.rowid";
1134
+		$sql .= " AND ec.fk_socpeople = ".$user->id;
1135
+		$sql .= " AND ec.fk_c_type_contact = ctc.rowid"; // Replace the 2 lines with ec.fk_c_type_contact in $arrayidtypeofcontact
1136
+		$sql .= " AND ctc.element = 'project_task'";
1137 1137
 	}
1138 1138
 	if ($statut >= 0)
1139 1139
 	{
1140
-		$sql.= " AND p.fk_statut = ".$statut;
1140
+		$sql .= " AND p.fk_statut = ".$statut;
1141 1141
 	}
1142 1142
 	if (!empty($conf->global->PROJECT_LIMIT_YEAR_RANGE))
1143 1143
 	{
@@ -1149,40 +1149,40 @@  discard block
 block discarded – undo
1149 1149
 			{
1150 1150
 				$project_year_filter = date("Y");
1151 1151
 			}
1152
-			$sql.= " AND (p.dateo IS NULL OR p.dateo <= ".$db->idate(dol_get_last_day($project_year_filter,12,false)).")";
1153
-			$sql.= " AND (p.datee IS NULL OR p.datee >= ".$db->idate(dol_get_first_day($project_year_filter,1,false)).")";
1152
+			$sql .= " AND (p.dateo IS NULL OR p.dateo <= ".$db->idate(dol_get_last_day($project_year_filter, 12, false)).")";
1153
+			$sql .= " AND (p.datee IS NULL OR p.datee >= ".$db->idate(dol_get_first_day($project_year_filter, 1, false)).")";
1154 1154
 		}
1155 1155
 	}
1156 1156
 
1157 1157
 	// Get id of project we must show tasks
1158
-	$arrayidofprojects=array();
1158
+	$arrayidofprojects = array();
1159 1159
 	$sql1 = "SELECT p.rowid as projectid";
1160
-	$sql1.= $sql;
1160
+	$sql1 .= $sql;
1161 1161
 	$resql = $db->query($sql1);
1162 1162
 	if ($resql)
1163 1163
 	{
1164
-	    $i=0;
1164
+	    $i = 0;
1165 1165
 		$num = $db->num_rows($resql);
1166 1166
 		while ($i < $num)
1167 1167
 		{
1168 1168
 			$objp = $db->fetch_object($resql);
1169
-            $arrayidofprojects[$objp->projectid]=$objp->projectid;
1169
+            $arrayidofprojects[$objp->projectid] = $objp->projectid;
1170 1170
 			$i++;
1171 1171
 		}
1172 1172
 	}
1173 1173
 	else dol_print_error($db);
1174
-	if (empty($arrayidofprojects)) $arrayidofprojects[0]=-1;
1174
+	if (empty($arrayidofprojects)) $arrayidofprojects[0] = -1;
1175 1175
 
1176 1176
 	// Get list of project with calculation on tasks
1177 1177
 	$sql2 = "SELECT p.rowid as projectid, p.ref, p.title, p.fk_soc, s.nom as socname, p.fk_user_creat, p.public, p.fk_statut as status, p.fk_opp_status as opp_status, p.opp_amount,";
1178
-	$sql2.= " p.dateo, p.datee,";
1179
-	$sql2.= " COUNT(t.rowid) as nb, SUM(t.planned_workload) as planned_workload, SUM(t.planned_workload * t.progress / 100) as declared_progess_workload";
1180
-	$sql2.= " FROM ".MAIN_DB_PREFIX."projet as p";
1181
-	$sql2.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = p.fk_soc";
1182
-	$sql2.= " LEFT JOIN ".MAIN_DB_PREFIX."projet_task as t ON p.rowid = t.fk_projet";
1183
-	$sql2.= " WHERE p.rowid IN (".join(',',$arrayidofprojects).")";
1184
-	$sql2.= " GROUP BY p.rowid, p.ref, p.title, p.fk_soc, s.nom, p.fk_user_creat, p.public, p.fk_statut, p.fk_opp_status, p.opp_amount, p.dateo, p.datee";
1185
-	$sql2.= " ORDER BY p.title, p.ref";
1178
+	$sql2 .= " p.dateo, p.datee,";
1179
+	$sql2 .= " COUNT(t.rowid) as nb, SUM(t.planned_workload) as planned_workload, SUM(t.planned_workload * t.progress / 100) as declared_progess_workload";
1180
+	$sql2 .= " FROM ".MAIN_DB_PREFIX."projet as p";
1181
+	$sql2 .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = p.fk_soc";
1182
+	$sql2 .= " LEFT JOIN ".MAIN_DB_PREFIX."projet_task as t ON p.rowid = t.fk_projet";
1183
+	$sql2 .= " WHERE p.rowid IN (".join(',', $arrayidofprojects).")";
1184
+	$sql2 .= " GROUP BY p.rowid, p.ref, p.title, p.fk_soc, s.nom, p.fk_user_creat, p.public, p.fk_statut, p.fk_opp_status, p.opp_amount, p.dateo, p.datee";
1185
+	$sql2 .= " ORDER BY p.title, p.ref";
1186 1186
 
1187 1187
 	$resql = $db->query($sql2);
1188 1188
 	if ($resql)
@@ -1195,20 +1195,20 @@  discard block
 block discarded – undo
1195 1195
 		$i = 0;
1196 1196
 
1197 1197
     	print '<tr class="liste_titre">';
1198
-    	print_liste_field_titre($title.' <span class="badge">'.$num.'</span>',$_SERVER["PHP_SELF"],"","","","",$sortfield,$sortorder);
1199
-    	print_liste_field_titre("ThirdParty",$_SERVER["PHP_SELF"],"","","","",$sortfield,$sortorder);
1200
-    	if (! empty($conf->global->PROJECT_USE_OPPORTUNITIES))
1198
+    	print_liste_field_titre($title.' <span class="badge">'.$num.'</span>', $_SERVER["PHP_SELF"], "", "", "", "", $sortfield, $sortorder);
1199
+    	print_liste_field_titre("ThirdParty", $_SERVER["PHP_SELF"], "", "", "", "", $sortfield, $sortorder);
1200
+    	if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES))
1201 1201
     	{
1202
-    		print_liste_field_titre("OpportunityAmount","","","","",'align="right"',$sortfield,$sortorder);
1203
-    		print_liste_field_titre("OpportunityStatus","","","","",'align="right"',$sortfield,$sortorder);
1202
+    		print_liste_field_titre("OpportunityAmount", "", "", "", "", 'align="right"', $sortfield, $sortorder);
1203
+    		print_liste_field_titre("OpportunityStatus", "", "", "", "", 'align="right"', $sortfield, $sortorder);
1204 1204
     	}
1205 1205
     	if (empty($conf->global->PROJECT_HIDE_TASKS))
1206 1206
     	{
1207
-            print_liste_field_titre("Tasks","","","","",'align="right"',$sortfield,$sortorder);
1208
-            if (! in_array('plannedworkload', $hiddenfields))  print_liste_field_titre("PlannedWorkload","","","","",'align="right"',$sortfield,$sortorder);
1209
-            if (! in_array('declaredprogress', $hiddenfields)) print_liste_field_titre("ProgressDeclared","","","","",'align="right"',$sortfield,$sortorder);
1207
+            print_liste_field_titre("Tasks", "", "", "", "", 'align="right"', $sortfield, $sortorder);
1208
+            if (!in_array('plannedworkload', $hiddenfields))  print_liste_field_titre("PlannedWorkload", "", "", "", "", 'align="right"', $sortfield, $sortorder);
1209
+            if (!in_array('declaredprogress', $hiddenfields)) print_liste_field_titre("ProgressDeclared", "", "", "", "", 'align="right"', $sortfield, $sortorder);
1210 1210
     	}
1211
-    	print_liste_field_titre("Status","","","","",'align="right"',$sortfield,$sortorder);
1211
+    	print_liste_field_titre("Status", "", "", "", "", 'align="right"', $sortfield, $sortorder);
1212 1212
     	print "</tr>\n";
1213 1213
 
1214 1214
 		while ($i < $num)
@@ -1223,7 +1223,7 @@  discard block
 block discarded – undo
1223 1223
 			$userAccess = $projectstatic->restrictedProjectArea($user);
1224 1224
 			if ($userAccess >= 0)
1225 1225
 			{
1226
-			    $projectstatic->ref=$objp->ref;
1226
+			    $projectstatic->ref = $objp->ref;
1227 1227
 			    $projectstatic->statut = $objp->status;
1228 1228
 			    $projectstatic->title = $objp->title;
1229 1229
 			    $projectstatic->datee = $db->jdate($objp->datee);
@@ -1233,18 +1233,18 @@  discard block
 block discarded – undo
1233 1233
 				print '<tr class="oddeven">';
1234 1234
 				print '<td>';
1235 1235
 				print $projectstatic->getNomUrl(1);
1236
-				if (! in_array('projectlabel', $hiddenfields)) print '<br>'.dol_trunc($objp->title,24);
1236
+				if (!in_array('projectlabel', $hiddenfields)) print '<br>'.dol_trunc($objp->title, 24);
1237 1237
 				print '</td>';
1238 1238
 				print '<td>';
1239 1239
 				if ($objp->fk_soc > 0)
1240 1240
 				{
1241
-    				$thirdpartystatic->id=$objp->fk_soc;
1242
-    				$thirdpartystatic->ref=$objp->socname;
1243
-    				$thirdpartystatic->name=$objp->socname;
1241
+    				$thirdpartystatic->id = $objp->fk_soc;
1242
+    				$thirdpartystatic->ref = $objp->socname;
1243
+    				$thirdpartystatic->name = $objp->socname;
1244 1244
     				print $thirdpartystatic->getNomUrl(1);
1245 1245
 				}
1246 1246
 				print '</td>';
1247
-				if (! empty($conf->global->PROJECT_USE_OPPORTUNITIES))
1247
+				if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES))
1248 1248
 				{
1249 1249
 					print '<td align="right">';
1250 1250
         			if ($objp->opp_amount) print price($objp->opp_amount, 0, '', 1, -1, -1, $conf->currency);
@@ -1258,19 +1258,19 @@  discard block
 block discarded – undo
1258 1258
 				{
1259 1259
 				    print '<td align="right">'.$objp->nb.'</td>';
1260 1260
 
1261
-    				$plannedworkload=$objp->planned_workload;
1262
-    				$total_plannedworkload+=$plannedworkload;
1263
-    				if (! in_array('plannedworkload', $hiddenfields))
1261
+    				$plannedworkload = $objp->planned_workload;
1262
+    				$total_plannedworkload += $plannedworkload;
1263
+    				if (!in_array('plannedworkload', $hiddenfields))
1264 1264
     				{
1265
-    				    print '<td align="right">'.($plannedworkload?convertSecondToTime($plannedworkload):'').'</td>';
1265
+    				    print '<td align="right">'.($plannedworkload ?convertSecondToTime($plannedworkload) : '').'</td>';
1266 1266
     				}
1267
-    				if (! in_array('declaredprogress', $hiddenfields))
1267
+    				if (!in_array('declaredprogress', $hiddenfields))
1268 1268
     				{
1269
-    				    $declaredprogressworkload=$objp->declared_progess_workload;
1270
-        				$total_declaredprogressworkload+=$declaredprogressworkload;
1269
+    				    $declaredprogressworkload = $objp->declared_progess_workload;
1270
+        				$total_declaredprogressworkload += $declaredprogressworkload;
1271 1271
         				print '<td align="right">';
1272 1272
         				//print $objp->planned_workload.'-'.$objp->declared_progess_workload."<br>";
1273
-        				print ($plannedworkload?round(100*$declaredprogressworkload/$plannedworkload,0).'%':'');
1273
+        				print ($plannedworkload ?round(100 * $declaredprogressworkload / $plannedworkload, 0).'%' : '');
1274 1274
         				print '</td>';
1275 1275
     				}
1276 1276
 				}
@@ -1288,7 +1288,7 @@  discard block
 block discarded – undo
1288 1288
 
1289 1289
 		print '<tr class="liste_total">';
1290 1290
 		print '<td colspan="2">'.$langs->trans("Total")."</td>";
1291
-		if (! empty($conf->global->PROJECT_USE_OPPORTUNITIES))
1291
+		if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES))
1292 1292
 		{
1293 1293
 			print '<td class="liste_total" align="right">'.price($total_opp_amount, 0, '', 1, -1, -1, $conf->currency).'</td>';
1294 1294
 			print '<td class="liste_total" align="right">'.$form->textwithpicto(price($ponderated_opp_amount, 0, '', 1, -1, -1, $conf->currency), $langs->trans("OpportunityPonderatedAmountDesc"), 1).'</td>';
@@ -1296,8 +1296,8 @@  discard block
 block discarded – undo
1296 1296
 		if (empty($conf->global->PROJECT_HIDE_TASKS))
1297 1297
 		{
1298 1298
             print '<td class="liste_total" align="right">'.$total_task.'</td>';
1299
-            if (! in_array('plannedworkload', $hiddenfields))  print '<td class="liste_total" align="right">'.($total_plannedworkload?convertSecondToTime($total_plannedworkload):'').'</td>';
1300
-            if (! in_array('declaredprogress', $hiddenfields)) print '<td class="liste_total" align="right">'.($total_plannedworkload?round(100*$total_declaredprogressworkload/$total_plannedworkload,0).'%':'').'</td>';
1299
+            if (!in_array('plannedworkload', $hiddenfields))  print '<td class="liste_total" align="right">'.($total_plannedworkload ?convertSecondToTime($total_plannedworkload) : '').'</td>';
1300
+            if (!in_array('declaredprogress', $hiddenfields)) print '<td class="liste_total" align="right">'.($total_plannedworkload ?round(100 * $total_declaredprogressworkload / $total_plannedworkload, 0).'%' : '').'</td>';
1301 1301
 		}
1302 1302
 		print '<td class="liste_total"></td>';
1303 1303
         print '</tr>';
Please login to merge, or discard this patch.
Braces   +264 added lines, -110 removed lines patch added patch discarded remove patch
@@ -47,7 +47,9 @@  discard block
 block discarded – undo
47 47
     $nbContact = count($object->liste_contact(-1,'internal')) + count($object->liste_contact(-1,'external'));
48 48
 	$head[$h][0] = DOL_URL_ROOT.'/projet/contact.php?id='.$object->id;
49 49
 	$head[$h][1] = $langs->trans("ProjectContact");
50
-	if ($nbContact > 0) $head[$h][1].= ' <span class="badge">'.$nbContact.'</span>';
50
+	if ($nbContact > 0) {
51
+		$head[$h][1].= ' <span class="badge">'.$nbContact.'</span>';
52
+	}
51 53
 	$head[$h][2] = 'contact';
52 54
 	$h++;
53 55
 
@@ -71,11 +73,17 @@  discard block
 block discarded – undo
71 73
 	if (empty($conf->global->MAIN_DISABLE_NOTES_TAB))
72 74
     {
73 75
     	$nbNote = 0;
74
-        if(!empty($object->note_private)) $nbNote++;
75
-		if(!empty($object->note_public)) $nbNote++;
76
+        if(!empty($object->note_private)) {
77
+        	$nbNote++;
78
+        }
79
+		if(!empty($object->note_public)) {
80
+			$nbNote++;
81
+		}
76 82
 		$head[$h][0] = DOL_URL_ROOT.'/projet/note.php?id='.$object->id;
77 83
 		$head[$h][1] = $langs->trans('Notes');
78
-		if ($nbNote > 0) $head[$h][1].= ' <span class="badge">'.$nbNote.'</span>';
84
+		if ($nbNote > 0) {
85
+			$head[$h][1].= ' <span class="badge">'.$nbNote.'</span>';
86
+		}
79 87
 		$head[$h][2] = 'notes';
80 88
 		$h++;
81 89
     }
@@ -87,7 +95,9 @@  discard block
 block discarded – undo
87 95
     $nbLinks=Link::count($db, $object->element, $object->id);
88 96
 	$head[$h][0] = DOL_URL_ROOT.'/projet/document.php?id='.$object->id;
89 97
 	$head[$h][1] = $langs->trans('Documents');
90
-	if (($nbFiles+$nbLinks) > 0) $head[$h][1].= ' <span class="badge">'.($nbFiles+$nbLinks).'</span>';
98
+	if (($nbFiles+$nbLinks) > 0) {
99
+		$head[$h][1].= ' <span class="badge">'.($nbFiles+$nbLinks).'</span>';
100
+	}
91 101
 	$head[$h][2] = 'document';
92 102
 	$h++;
93 103
 
@@ -100,13 +110,17 @@  discard block
 block discarded – undo
100 110
 		require_once DOL_DOCUMENT_ROOT.'/projet/class/task.class.php';
101 111
 		$taskstatic=new Task($db);
102 112
 		$nbTasks=count($taskstatic->getTasksArray(0, 0, $object->id, 0, 0));
103
-		if ($nbTasks > 0) $head[$h][1].= ' <span class="badge">'.($nbTasks).'</span>';
113
+		if ($nbTasks > 0) {
114
+			$head[$h][1].= ' <span class="badge">'.($nbTasks).'</span>';
115
+		}
104 116
 		$head[$h][2] = 'tasks';
105 117
 		$h++;
106 118
 
107 119
 		$head[$h][0] = DOL_URL_ROOT.'/projet/ganttview.php?id='.$object->id;
108 120
 		$head[$h][1] = $langs->trans("Gantt");
109
-		if ($nbTasks > 0) $head[$h][1].= ' <span class="badge">'.($nbTasks).'</span>';
121
+		if ($nbTasks > 0) {
122
+			$head[$h][1].= ' <span class="badge">'.($nbTasks).'</span>';
123
+		}
110 124
 		$head[$h][2] = 'gantt';
111 125
 		$h++;
112 126
 	}
@@ -117,7 +131,9 @@  discard block
 block discarded – undo
117 131
 		$nbComments = $object->getNbComments();
118 132
 		$head[$h][0] = DOL_URL_ROOT.'/projet/comment.php?id='.$object->id;
119 133
 		$head[$h][1] = $langs->trans("CommentLink");
120
-		if ($nbComments > 0) $head[$h][1].= ' <span class="badge">'.$nbComments.'</span>';
134
+		if ($nbComments > 0) {
135
+			$head[$h][1].= ' <span class="badge">'.$nbComments.'</span>';
136
+		}
121 137
 		$head[$h][2] = 'project_comment';
122 138
 		$h++;
123 139
 	}
@@ -158,7 +174,9 @@  discard block
 block discarded – undo
158 174
 	$nbContact = count($object->liste_contact(-1,'internal')) + count($object->liste_contact(-1,'external'));
159 175
 	$head[$h][0] = DOL_URL_ROOT.'/projet/tasks/contact.php?id='.$object->id.(GETPOST('withproject')?'&withproject=1':'');
160 176
 	$head[$h][1] = $langs->trans("TaskRessourceLinks");
161
-	if ($nbContact > 0) $head[$h][1].= ' <span class="badge">'.$nbContact.'</span>';
177
+	if ($nbContact > 0) {
178
+		$head[$h][1].= ' <span class="badge">'.$nbContact.'</span>';
179
+	}
162 180
 	$head[$h][2] = 'task_contact';
163 181
 	$h++;
164 182
 
@@ -172,13 +190,18 @@  discard block
 block discarded – undo
172 190
 	if ($resql)
173 191
 	{
174 192
 	    $obj = $db->fetch_object($resql);
175
-	    if ($obj) $nbTimeSpent=1;
193
+	    if ($obj) {
194
+	    	$nbTimeSpent=1;
195
+	    }
196
+	} else {
197
+		dol_print_error($db);
176 198
 	}
177
-	else dol_print_error($db);
178 199
 
179 200
 	$head[$h][0] = DOL_URL_ROOT.'/projet/tasks/time.php?id='.$object->id.(GETPOST('withproject')?'&withproject=1':'');
180 201
 	$head[$h][1] = $langs->trans("TimeSpent");
181
-	if ($nbTimeSpent > 0) $head[$h][1].= ' <span class="badge">...</span>';
202
+	if ($nbTimeSpent > 0) {
203
+		$head[$h][1].= ' <span class="badge">...</span>';
204
+	}
182 205
 	$head[$h][2] = 'task_time';
183 206
 	$h++;
184 207
 
@@ -191,11 +214,17 @@  discard block
 block discarded – undo
191 214
 	if (empty($conf->global->MAIN_DISABLE_NOTES_TAB))
192 215
     {
193 216
     	$nbNote = 0;
194
-        if(!empty($object->note_private)) $nbNote++;
195
-		if(!empty($object->note_public)) $nbNote++;
217
+        if(!empty($object->note_private)) {
218
+        	$nbNote++;
219
+        }
220
+		if(!empty($object->note_public)) {
221
+			$nbNote++;
222
+		}
196 223
 		$head[$h][0] = DOL_URL_ROOT.'/projet/tasks/note.php?id='.$object->id.(GETPOST('withproject')?'&withproject=1':'');
197 224
 		$head[$h][1] = $langs->trans('Notes');
198
-		if ($nbNote > 0) $head[$h][1].= ' <span class="badge">'.$nbNote.'</span>';
225
+		if ($nbNote > 0) {
226
+			$head[$h][1].= ' <span class="badge">'.$nbNote.'</span>';
227
+		}
199 228
 		$head[$h][2] = 'task_notes';
200 229
 		$h++;
201 230
     }
@@ -207,7 +236,9 @@  discard block
 block discarded – undo
207 236
 	$nbFiles = count(dol_dir_list($filesdir,'files',0,'','(\.meta|_preview.*\.png)$'));
208 237
     $nbLinks=Link::count($db, $object->element, $object->id);
209 238
 	$head[$h][1] = $langs->trans('Documents');
210
-	if (($nbFiles+$nbLinks) > 0) $head[$h][1].= ' <span class="badge">'.($nbFiles+$nbLinks).'</span>';
239
+	if (($nbFiles+$nbLinks) > 0) {
240
+		$head[$h][1].= ' <span class="badge">'.($nbFiles+$nbLinks).'</span>';
241
+	}
211 242
 	$head[$h][2] = 'task_document';
212 243
 	$h++;
213 244
 
@@ -217,7 +248,9 @@  discard block
 block discarded – undo
217 248
 		$nbComments = $object->getNbComments();
218 249
 		$head[$h][0] = DOL_URL_ROOT.'/projet/tasks/comment.php?id='.$object->id.(GETPOST('withproject')?'&withproject=1':'');
219 250
 		$head[$h][1] = $langs->trans("CommentLink");
220
-		if ($nbComments > 0) $head[$h][1].= ' <span class="badge">'.$nbComments.'</span>';
251
+		if ($nbComments > 0) {
252
+			$head[$h][1].= ' <span class="badge">'.$nbComments.'</span>';
253
+		}
221 254
 		$head[$h][2] = 'task_comment';
222 255
 		$h++;
223 256
 	}
@@ -244,7 +277,9 @@  discard block
 block discarded – undo
244 277
 
245 278
 	$param='';
246 279
 	$param.=($mode?'&mode='.$mode:'');
247
-	if (is_object($fuser) && $fuser->id > 0 && $fuser->id != $user->id) $param.='&search_usertoprocessid='.$fuser->id;
280
+	if (is_object($fuser) && $fuser->id > 0 && $fuser->id != $user->id) {
281
+		$param.='&search_usertoprocessid='.$fuser->id;
282
+	}
248 283
 
249 284
 	if (empty($conf->global->PROJECT_DISABLE_TIMESHEET_PERWEEK))
250 285
 	{
@@ -351,15 +386,20 @@  discard block
 block discarded – undo
351 386
 
352 387
 	for ($i = 0 ; $i < $numlines ; $i++)
353 388
 	{
354
-		if ($parent == 0 && $level >= 0) $level = 0;              // if $level = -1, we dont' use sublevel recursion, we show all lines
389
+		if ($parent == 0 && $level >= 0) {
390
+			$level = 0;
391
+		}
392
+		// if $level = -1, we dont' use sublevel recursion, we show all lines
355 393
 
356 394
 		// Process line
357 395
 		// print "i:".$i."-".$lines[$i]->fk_project.'<br>';
358 396
 
359
-		if ($lines[$i]->fk_parent == $parent || $level < 0)       // if $level = -1, we dont' use sublevel recursion, we show all lines
397
+		if ($lines[$i]->fk_parent == $parent || $level < 0) {
398
+			// if $level = -1, we dont' use sublevel recursion, we show all lines
360 399
 		{
361 400
 			// Show task line.
362 401
 			$showline=1;
402
+		}
363 403
 			$showlineingray=0;
364 404
 
365 405
 			// If there is filters to use
@@ -375,14 +415,12 @@  discard block
 block discarded – undo
375 415
 					if ($foundtaskforuserdeeper > 0)
376 416
 					{
377 417
 						$showlineingray=1;		// We will show line but in gray
378
-					}
379
-					else
418
+					} else
380 419
 					{
381 420
 						$showline=0;			// No reason to show line
382 421
 					}
383 422
 				}
384
-			}
385
-			else
423
+			} else
386 424
 			{
387 425
 				// Caller did not ask to filter on tasks of a specific user (this probably means he want also tasks of all users, into public project
388 426
 				// or into all other projects if user has permission to).
@@ -419,8 +457,11 @@  discard block
 block discarded – undo
419 457
 					$projectstatic->ref=$lines[$i]->projectref;
420 458
 					$projectstatic->public=$lines[$i]->public;
421 459
 					$projectstatic->title=$lines[$i]->projectlabel;
422
-					if ($lines[$i]->public || in_array($lines[$i]->fk_project,$projectsArrayId) || ! empty($user->rights->projet->all->lire)) print $projectstatic->getNomUrl(1);
423
-					else print $projectstatic->getNomUrl(1,'nolink');
460
+					if ($lines[$i]->public || in_array($lines[$i]->fk_project,$projectsArrayId) || ! empty($user->rights->projet->all->lire)) {
461
+						print $projectstatic->getNomUrl(1);
462
+					} else {
463
+						print $projectstatic->getNomUrl(1,'nolink');
464
+					}
424 465
 					//if ($showlineingray) print '</i>';
425 466
 					print "</td>";
426 467
 
@@ -436,8 +477,7 @@  discard block
 block discarded – undo
436 477
 				if ($showlineingray)
437 478
 				{
438 479
 					print '<i>'.img_object('','projecttask').' '.$lines[$i]->ref.'</i>';
439
-				}
440
-				else
480
+				} else
441 481
 				{
442 482
 					$taskstatic->id=$lines[$i]->id;
443 483
 					$taskstatic->ref=$lines[$i]->ref;
@@ -448,14 +488,18 @@  discard block
 block discarded – undo
448 488
 
449 489
 				// Title of task
450 490
 				print "<td>";
451
-				if ($showlineingray) print '<i>';
491
+				if ($showlineingray) {
492
+					print '<i>';
493
+				}
452 494
 				//else print '<a href="'.DOL_URL_ROOT.'/projet/tasks/task.php?id='.$lines[$i]->id.'&withproject=1">';
453 495
 				for ($k = 0 ; $k < $level ; $k++)
454 496
 				{
455 497
 					print "&nbsp; &nbsp; &nbsp;";
456 498
 				}
457 499
 				print $lines[$i]->label;
458
-				if ($showlineingray) print '</i>';
500
+				if ($showlineingray) {
501
+					print '</i>';
502
+				}
459 503
 				//else print '</a>';
460 504
 				print "</td>\n";
461 505
 
@@ -471,13 +515,19 @@  discard block
 block discarded – undo
471 515
 	            $taskstatic->fk_statut = $lines[$i]->status;
472 516
 	            $taskstatic->datee = $lines[$i]->date_end;
473 517
 	            print dol_print_date($lines[$i]->date_end,'dayhour');
474
-	            if ($taskstatic->hasDelay()) print img_warning($langs->trans("Late"));
518
+	            if ($taskstatic->hasDelay()) {
519
+	            	print img_warning($langs->trans("Late"));
520
+	            }
475 521
 				print '</td>';
476 522
 
477 523
 				$plannedworkloadoutputformat='allhourmin';
478 524
 				$timespentoutputformat='allhourmin';
479
-				if (! empty($conf->global->PROJECT_PLANNED_WORKLOAD_FORMAT)) $plannedworkloadoutputformat=$conf->global->PROJECT_PLANNED_WORKLOAD_FORMAT;
480
-				if (! empty($conf->global->PROJECT_TIMES_SPENT_FORMAT)) $timespentoutputformat=$conf->global->PROJECT_TIME_SPENT_FORMAT;
525
+				if (! empty($conf->global->PROJECT_PLANNED_WORKLOAD_FORMAT)) {
526
+					$plannedworkloadoutputformat=$conf->global->PROJECT_PLANNED_WORKLOAD_FORMAT;
527
+				}
528
+				if (! empty($conf->global->PROJECT_TIMES_SPENT_FORMAT)) {
529
+					$timespentoutputformat=$conf->global->PROJECT_TIME_SPENT_FORMAT;
530
+				}
481 531
 
482 532
 				// Planned Workload (in working hours)
483 533
 				print '<td align="right">';
@@ -494,20 +544,32 @@  discard block
 block discarded – undo
494 544
 
495 545
 				// Time spent
496 546
 				print '<td align="right">';
497
-				if ($showlineingray) print '<i>';
498
-				else print '<a href="'.DOL_URL_ROOT.'/projet/tasks/time.php?id='.$lines[$i]->id.($showproject?'':'&withproject=1').'">';
499
-				if ($lines[$i]->duration) print convertSecondToTime($lines[$i]->duration,$timespentoutputformat);
500
-				else print '--:--';
501
-				if ($showlineingray) print '</i>';
502
-				else print '</a>';
547
+				if ($showlineingray) {
548
+					print '<i>';
549
+				} else {
550
+					print '<a href="'.DOL_URL_ROOT.'/projet/tasks/time.php?id='.$lines[$i]->id.($showproject?'':'&withproject=1').'">';
551
+				}
552
+				if ($lines[$i]->duration) {
553
+					print convertSecondToTime($lines[$i]->duration,$timespentoutputformat);
554
+				} else {
555
+					print '--:--';
556
+				}
557
+				if ($showlineingray) {
558
+					print '</i>';
559
+				} else {
560
+					print '</a>';
561
+				}
503 562
 				print '</td>';
504 563
 
505 564
 				// Progress calculated (Note: ->duration is time spent)
506 565
 				print '<td align="right">';
507 566
 				if ($lines[$i]->planned_workload || $lines[$i]->duration)
508 567
 				{
509
-					if ($lines[$i]->planned_workload) print round(100 * $lines[$i]->duration / $lines[$i]->planned_workload,2).' %';
510
-					else print '<span class="opacitymedium">'.$langs->trans('WorkloadNotDefined').'</span>';
568
+					if ($lines[$i]->planned_workload) {
569
+						print round(100 * $lines[$i]->duration / $lines[$i]->planned_workload,2).' %';
570
+					} else {
571
+						print '<span class="opacitymedium">'.$langs->trans('WorkloadNotDefined').'</span>';
572
+					}
511 573
 				}
512 574
 				print '</td>';
513 575
 
@@ -527,21 +589,28 @@  discard block
 block discarded – undo
527 589
 
528 590
 				print "</tr>\n";
529 591
 
530
-				if (! $showlineingray) $inc++;
592
+				if (! $showlineingray) {
593
+					$inc++;
594
+				}
531 595
 
532
-				if ($level >= 0)    // Call sublevels
596
+				if ($level >= 0) {
597
+					// Call sublevels
533 598
 				{
534 599
     				$level++;
535
-    				if ($lines[$i]->id) projectLinesa($inc, $lines[$i]->id, $lines, $level, $var, $showproject, $taskrole, $projectsListId, $addordertick);
600
+				}
601
+    				if ($lines[$i]->id) {
602
+    					projectLinesa($inc, $lines[$i]->id, $lines, $level, $var, $showproject, $taskrole, $projectsListId, $addordertick);
603
+    				}
536 604
     				$level--;
537 605
 				}
538 606
 
539 607
 				$total_projectlinesa_spent += $lines[$i]->duration;
540 608
 				$total_projectlinesa_planned += $lines[$i]->planned_workload;
541
-				if ($lines[$i]->planned_workload) $total_projectlinesa_spent_if_planned += $lines[$i]->duration;
609
+				if ($lines[$i]->planned_workload) {
610
+					$total_projectlinesa_spent_if_planned += $lines[$i]->duration;
611
+				}
542 612
 			}
543
-		}
544
-		else
613
+		} else
545 614
 		{
546 615
 			//$level--;
547 616
 		}
@@ -551,7 +620,9 @@  discard block
 block discarded – undo
551 620
 	{
552 621
 		print '<tr class="liste_total nodrag nodrop">';
553 622
 		print '<td class="liste_total">'.$langs->trans("Total").'</td>';
554
-		if ($showproject) print '<td></td><td></td>';
623
+		if ($showproject) {
624
+			print '<td></td><td></td>';
625
+		}
555 626
 		print '<td></td>';
556 627
 		print '<td></td>';
557 628
 		print '<td></td>';
@@ -559,15 +630,23 @@  discard block
 block discarded – undo
559 630
 		print convertSecondToTime($total_projectlinesa_planned, 'allhourmin');
560 631
 		print '</td>';
561 632
 		print '<td align="right" class="nowrap liste_total">';
562
-		if ($projectidfortotallink > 0) print '<a href="'.DOL_URL_ROOT.'/projet/tasks/time.php?projectid='.$projectidfortotallink.($showproject?'':'&withproject=1').'">';
633
+		if ($projectidfortotallink > 0) {
634
+			print '<a href="'.DOL_URL_ROOT.'/projet/tasks/time.php?projectid='.$projectidfortotallink.($showproject?'':'&withproject=1').'">';
635
+		}
563 636
 		print convertSecondToTime($total_projectlinesa_spent, 'allhourmin');
564
-		if ($projectidfortotallink > 0) print '</a>';
637
+		if ($projectidfortotallink > 0) {
638
+			print '</a>';
639
+		}
565 640
 		print '</td>';
566 641
 		print '<td align="right" class="nowrap liste_total">';
567
-		if ($total_projectlinesa_planned) print round(100 * $total_projectlinesa_spent / $total_projectlinesa_planned,2).' %';
642
+		if ($total_projectlinesa_planned) {
643
+			print round(100 * $total_projectlinesa_spent / $total_projectlinesa_planned,2).' %';
644
+		}
568 645
 		print '</td>';
569 646
 		print '<td></td>';
570
-		if ($addordertick) print '<td class="hideonsmartphone"></td>';
647
+		if ($addordertick) {
648
+			print '<td class="hideonsmartphone"></td>';
649
+		}
571 650
 		print '</tr>';
572 651
 	}
573 652
 
@@ -603,18 +682,25 @@  discard block
 block discarded – undo
603 682
 	$numlines=count($lines);
604 683
 
605 684
 	// Create a smaller array with sublevels only to be used later. This increase dramatically performances.
606
-	if ($parent == 0) // Always and only if at first level
685
+	if ($parent == 0) {
686
+		// Always and only if at first level
607 687
 	{
608
-	    for ($i = 0 ; $i < $numlines ; $i++)
688
+	    for ($i = 0 ;
689
+	}
690
+	$i < $numlines ; $i++)
609 691
 	    {
610
-	        if ($lines[$i]->fk_task_parent) $lineswithoutlevel0[]=$lines[$i];
692
+	        if ($lines[$i]->fk_task_parent) {
693
+	        	$lineswithoutlevel0[]=$lines[$i];
694
+	        }
611 695
 	    }
612 696
 	}
613 697
 
614 698
     //dol_syslog('projectLinesPerDay inc='.$inc.' preselectedday='.$preselectedday.' task parent id='.$parent.' level='.$level." count(lines)=".$numlines." count(lineswithoutlevel0)=".count($lineswithoutlevel0));
615 699
 	for ($i = 0 ; $i < $numlines ; $i++)
616 700
 	{
617
-		if ($parent == 0) $level = 0;
701
+		if ($parent == 0) {
702
+			$level = 0;
703
+		}
618 704
 
619 705
 		if ($lines[$i]->fk_task_parent == $parent)
620 706
 		{
@@ -681,7 +767,9 @@  discard block
 block discarded – undo
681 767
 
682 768
 				// Label task
683 769
 				print "<td>";
684
-				for ($k = 0 ; $k < $level ; $k++) print "&nbsp;&nbsp;&nbsp;";
770
+				for ($k = 0 ; $k < $level ; $k++) {
771
+					print "&nbsp;&nbsp;&nbsp;";
772
+				}
685 773
 				$taskstatic->id=$lines[$i]->id;
686 774
 				$taskstatic->ref=$lines[$i]->label;
687 775
 				$taskstatic->date_start=$lines[$i]->date_start;
@@ -694,8 +782,11 @@  discard block
 block discarded – undo
694 782
 
695 783
 				// Planned Workload
696 784
 				print '<td align="right">';
697
-				if ($lines[$i]->planned_workload) print convertSecondToTime($lines[$i]->planned_workload,'allhourmin');
698
-				else print '--:--';
785
+				if ($lines[$i]->planned_workload) {
786
+					print convertSecondToTime($lines[$i]->planned_workload,'allhourmin');
787
+				} else {
788
+					print '--:--';
789
+				}
699 790
 				print '</td>';
700 791
 
701 792
 				// Progress declared %
@@ -711,15 +802,19 @@  discard block
 block discarded – undo
711 802
 					print '<a href="'.DOL_URL_ROOT.'/projet/tasks/time.php?id='.$lines[$i]->id.'">';
712 803
 					print convertSecondToTime($lines[$i]->duration,'allhourmin');
713 804
 					print '</a>';
805
+				} else {
806
+					print '--:--';
714 807
 				}
715
-				else print '--:--';
716 808
 				print "</td>\n";
717 809
 
718 810
 				// Time spent by user
719 811
 				print '<td align="right">';
720 812
 				$tmptimespent=$taskstatic->getSummaryOfTimeSpent($fuser->id);
721
-				if ($tmptimespent['total_duration']) print convertSecondToTime($tmptimespent['total_duration'],'allhourmin');
722
-				else print '--:--';
813
+				if ($tmptimespent['total_duration']) {
814
+					print convertSecondToTime($tmptimespent['total_duration'],'allhourmin');
815
+				} else {
816
+					print '--:--';
817
+				}
723 818
 				print "</td>\n";
724 819
 
725 820
 				$disabledproject=1;$disabledtask=1;
@@ -745,16 +840,22 @@  discard block
 block discarded – undo
745 840
 				print '</td>';
746 841
 
747 842
 				$cssonholiday='';
748
-				if (! $isavailable[$preselectedday]['morning'] && ! $isavailable[$preselectedday]['afternoon'])   $cssonholiday.='onholidayallday ';
749
-				elseif (! $isavailable[$preselectedday]['morning'])   $cssonholiday.='onholidaymorning ';
750
-				elseif (! $isavailable[$preselectedday]['afternoon']) $cssonholiday.='onholidayafternoon ';
843
+				if (! $isavailable[$preselectedday]['morning'] && ! $isavailable[$preselectedday]['afternoon']) {
844
+					$cssonholiday.='onholidayallday ';
845
+				} elseif (! $isavailable[$preselectedday]['morning']) {
846
+					$cssonholiday.='onholidaymorning ';
847
+				} elseif (! $isavailable[$preselectedday]['afternoon']) {
848
+					$cssonholiday.='onholidayafternoon ';
849
+				}
751 850
 
752 851
 				// Duration
753 852
 				print '<td align="center" class="duration'.($cssonholiday?' '.$cssonholiday:'').'">';
754 853
 
755 854
 				$dayWorkLoad = $projectstatic->weekWorkLoadPerTask[$preselectedday][$lines[$i]->id];
756 855
 		        $alreadyspent='';
757
-		        if ($dayWorkLoad > 0) $alreadyspent=convertSecondToTime($dayWorkLoad,'allhourmin');
856
+		        if ($dayWorkLoad > 0) {
857
+		        	$alreadyspent=convertSecondToTime($dayWorkLoad,'allhourmin');
858
+		        }
758 859
 
759 860
 		        $idw = 0;
760 861
 
@@ -783,11 +884,14 @@  discard block
 block discarded – undo
783 884
 
784 885
 				// Warning
785 886
 				print '<td align="right">';
786
-   				if ((! $lines[$i]->public) && $disabledproject) print $form->textwithpicto('',$langs->trans("UserIsNotContactOfProject"));
787
-   				else if ($disabledtask)
887
+   				if ((! $lines[$i]->public) && $disabledproject) {
888
+   					print $form->textwithpicto('',$langs->trans("UserIsNotContactOfProject"));
889
+   				} else if ($disabledtask)
788 890
    				{
789 891
    					$titleassigntask = $langs->trans("AssignTaskToMe");
790
-   					if ($fuser->id != $user->id) $titleassigntask = $langs->trans("AssignTaskToUser", '...');
892
+   					if ($fuser->id != $user->id) {
893
+   						$titleassigntask = $langs->trans("AssignTaskToUser", '...');
894
+   					}
791 895
 
792 896
    					print $form->textwithpicto('',$langs->trans("TaskIsNotAssignedToUser", $titleassigntask));
793 897
    				}
@@ -800,12 +904,14 @@  discard block
 block discarded – undo
800 904
 			$level++;
801 905
 			if ($lines[$i]->id > 0)
802 906
 			{
803
-			    if ($parent == 0) projectLinesPerDay($inc, $lines[$i]->id, $fuser, $lineswithoutlevel0, $level, $projectsrole, $tasksrole, $mine, $restricteditformytask, $preselectedday, $isavailable);
804
-			    else projectLinesPerDay($inc, $lines[$i]->id, $fuser, $lines, $level, $projectsrole, $tasksrole, $mine, $restricteditformytask, $preselectedday, $isavailable);
907
+			    if ($parent == 0) {
908
+			    	projectLinesPerDay($inc, $lines[$i]->id, $fuser, $lineswithoutlevel0, $level, $projectsrole, $tasksrole, $mine, $restricteditformytask, $preselectedday, $isavailable);
909
+			    } else {
910
+			    	projectLinesPerDay($inc, $lines[$i]->id, $fuser, $lines, $level, $projectsrole, $tasksrole, $mine, $restricteditformytask, $preselectedday, $isavailable);
911
+			    }
805 912
 			}
806 913
 			$level--;
807
-		}
808
-		else
914
+		} else
809 915
 		{
810 916
 			//$level--;
811 917
 		}
@@ -843,11 +949,16 @@  discard block
 block discarded – undo
843 949
 	$lineswithoutlevel0=array();
844 950
 
845 951
 	// Create a smaller array with sublevels only to be used later. This increase dramatically performances.
846
-	if ($parent == 0) // Always and only if at first level
952
+	if ($parent == 0) {
953
+		// Always and only if at first level
847 954
 	{
848
-	    for ($i = 0 ; $i < $numlines ; $i++)
955
+	    for ($i = 0 ;
956
+	}
957
+	$i < $numlines ; $i++)
849 958
 	    {
850
-	       if ($lines[$i]->fk_task_parent) $lineswithoutlevel0[]=$lines[$i];
959
+	       if ($lines[$i]->fk_task_parent) {
960
+	       	$lineswithoutlevel0[]=$lines[$i];
961
+	       }
851 962
 	    }
852 963
 	}
853 964
 
@@ -855,7 +966,9 @@  discard block
 block discarded – undo
855 966
 
856 967
 	for ($i = 0 ; $i < $numlines ; $i++)
857 968
 	{
858
-		if ($parent == 0) $level = 0;
969
+		if ($parent == 0) {
970
+			$level = 0;
971
+		}
859 972
 
860 973
 		if ($lines[$i]->fk_task_parent == $parent)
861 974
 		{
@@ -917,7 +1030,9 @@  discard block
 block discarded – undo
917 1030
 				// Label task
918 1031
 				print "<td>";
919 1032
 				print '<!-- Task id = '.$lines[$i]->id.' -->';
920
-				for ($k = 0 ; $k < $level ; $k++) print "&nbsp;&nbsp;&nbsp;";
1033
+				for ($k = 0 ; $k < $level ; $k++) {
1034
+					print "&nbsp;&nbsp;&nbsp;";
1035
+				}
921 1036
 				$taskstatic->id=$lines[$i]->id;
922 1037
 				$taskstatic->ref=$lines[$i]->label;
923 1038
 				$taskstatic->date_start=$lines[$i]->date_start;
@@ -930,8 +1045,11 @@  discard block
 block discarded – undo
930 1045
 
931 1046
 				// Planned Workload
932 1047
 				print '<td align="right">';
933
-				if ($lines[$i]->planned_workload) print convertSecondToTime($lines[$i]->planned_workload,'allhourmin');
934
-				else print '--:--';
1048
+				if ($lines[$i]->planned_workload) {
1049
+					print convertSecondToTime($lines[$i]->planned_workload,'allhourmin');
1050
+				} else {
1051
+					print '--:--';
1052
+				}
935 1053
 				print '</td>';
936 1054
 
937 1055
 				// Progress declared %
@@ -947,15 +1065,19 @@  discard block
 block discarded – undo
947 1065
 					print '<a href="'.DOL_URL_ROOT.'/projet/tasks/time.php?id='.$lines[$i]->id.'">';
948 1066
 					print convertSecondToTime($lines[$i]->duration,'allhourmin');
949 1067
 					print '</a>';
1068
+				} else {
1069
+					print '--:--';
950 1070
 				}
951
-				else print '--:--';
952 1071
 				print "</td>\n";
953 1072
 
954 1073
 				// Time spent by user
955 1074
 				print '<td align="right">';
956 1075
 				$tmptimespent=$taskstatic->getSummaryOfTimeSpent($fuser->id);
957
-				if ($tmptimespent['total_duration']) print convertSecondToTime($tmptimespent['total_duration'],'allhourmin');
958
-				else print '--:--';
1076
+				if ($tmptimespent['total_duration']) {
1077
+					print convertSecondToTime($tmptimespent['total_duration'],'allhourmin');
1078
+				} else {
1079
+					print '--:--';
1080
+				}
959 1081
 				print "</td>\n";
960 1082
 
961 1083
 				$disabledproject=1;$disabledtask=1;
@@ -983,14 +1105,20 @@  discard block
 block discarded – undo
983 1105
 					$tmpday=dol_time_plus_duree($firstdaytoshow, $idw, 'd');
984 1106
 
985 1107
 					$cssonholiday='';
986
-					if (! $isavailable[$tmpday]['morning'] && ! $isavailable[$tmpday]['afternoon'])   $cssonholiday.='onholidayallday ';
987
-					elseif (! $isavailable[$tmpday]['morning'])   $cssonholiday.='onholidaymorning ';
988
-					elseif (! $isavailable[$tmpday]['afternoon']) $cssonholiday.='onholidayafternoon ';
1108
+					if (! $isavailable[$tmpday]['morning'] && ! $isavailable[$tmpday]['afternoon']) {
1109
+						$cssonholiday.='onholidayallday ';
1110
+					} elseif (! $isavailable[$tmpday]['morning']) {
1111
+						$cssonholiday.='onholidaymorning ';
1112
+					} elseif (! $isavailable[$tmpday]['afternoon']) {
1113
+						$cssonholiday.='onholidayafternoon ';
1114
+					}
989 1115
 
990 1116
 					$tmparray=dol_getdate($tmpday);
991 1117
 		        	$dayWorkLoad = $projectstatic->weekWorkLoadPerTask[$tmpday][$lines[$i]->id];
992 1118
 		        	$alreadyspent='';
993
-		        	if ($dayWorkLoad > 0) $alreadyspent=convertSecondToTime($dayWorkLoad,'allhourmin');
1119
+		        	if ($dayWorkLoad > 0) {
1120
+		        		$alreadyspent=convertSecondToTime($dayWorkLoad,'allhourmin');
1121
+		        	}
994 1122
                     $alttitle=$langs->trans("AddHereTimeSpentForDay",$tmparray['day'],$tmparray['mon']);
995 1123
 
996 1124
                     $tableCell ='<td align="center" class="hide'.$idw.($cssonholiday?' '.$cssonholiday:'').'">';
@@ -1011,11 +1139,14 @@  discard block
 block discarded – undo
1011 1139
 
1012 1140
 		        // Warning
1013 1141
 				print '<td align="right">';
1014
-   				if ((! $lines[$i]->public) && $disabledproject) print $form->textwithpicto('',$langs->trans("UserIsNotContactOfProject"));
1015
-   				else if ($disabledtask)
1142
+   				if ((! $lines[$i]->public) && $disabledproject) {
1143
+   					print $form->textwithpicto('',$langs->trans("UserIsNotContactOfProject"));
1144
+   				} else if ($disabledtask)
1016 1145
    				{
1017 1146
    					$titleassigntask = $langs->trans("AssignTaskToMe");
1018
-   					if ($fuser->id != $user->id) $titleassigntask = $langs->trans("AssignTaskToUser", '...');
1147
+   					if ($fuser->id != $user->id) {
1148
+   						$titleassigntask = $langs->trans("AssignTaskToUser", '...');
1149
+   					}
1019 1150
 
1020 1151
    					print $form->textwithpicto('',$langs->trans("TaskIsNotAssignedToUser", $titleassigntask));
1021 1152
    				}
@@ -1029,12 +1160,14 @@  discard block
 block discarded – undo
1029 1160
 			$level++;
1030 1161
 			if ($lines[$i]->id > 0)
1031 1162
 			{
1032
-			    if ($parent == 0) projectLinesPerWeek($inc, $firstdaytoshow, $fuser, $lines[$i]->id, $lineswithoutlevel0, $level, $projectsrole, $tasksrole, $mine, $restricteditformytask, $isavailable);
1033
-			    else projectLinesPerWeek($inc, $firstdaytoshow, $fuser, $lines[$i]->id, $lines, $level, $projectsrole, $tasksrole, $mine, $restricteditformytask, $isavailable);
1163
+			    if ($parent == 0) {
1164
+			    	projectLinesPerWeek($inc, $firstdaytoshow, $fuser, $lines[$i]->id, $lineswithoutlevel0, $level, $projectsrole, $tasksrole, $mine, $restricteditformytask, $isavailable);
1165
+			    } else {
1166
+			    	projectLinesPerWeek($inc, $firstdaytoshow, $fuser, $lines[$i]->id, $lines, $level, $projectsrole, $tasksrole, $mine, $restricteditformytask, $isavailable);
1167
+			    }
1034 1168
 			}
1035 1169
 			$level--;
1036
-		}
1037
-		else
1170
+		} else
1038 1171
 		{
1039 1172
 			//$level--;
1040 1173
 		}
@@ -1073,7 +1206,9 @@  discard block
 block discarded – undo
1073 1206
 			searchTaskInChild($inc, $lines[$i]->id, $lines, $taskrole);
1074 1207
 			//print 'Found inc='.$inc.'<br>';
1075 1208
 
1076
-			if ($inc > 0) return $inc;
1209
+			if ($inc > 0) {
1210
+				return $inc;
1211
+			}
1077 1212
 		}
1078 1213
 	}
1079 1214
 
@@ -1107,7 +1242,9 @@  discard block
 block discarded – undo
1107 1242
 	$project_year_filter=0;
1108 1243
 
1109 1244
 	$title=$langs->trans("Projects");
1110
-	if (strcmp($statut, '') && $statut >= 0) $title=$langs->trans("Projects").' '.$langs->trans($projectstatic->statuts_long[$statut]);
1245
+	if (strcmp($statut, '') && $statut >= 0) {
1246
+		$title=$langs->trans("Projects").' '.$langs->trans($projectstatic->statuts_long[$statut]);
1247
+	}
1111 1248
 
1112 1249
 	$arrayidtypeofcontact=array();
1113 1250
 
@@ -1119,14 +1256,15 @@  discard block
 block discarded – undo
1119 1256
 		$sql.= ", ".MAIN_DB_PREFIX."projet_task as t";
1120 1257
 		$sql.= ", ".MAIN_DB_PREFIX."element_contact as ec";
1121 1258
 		$sql.= ", ".MAIN_DB_PREFIX."c_type_contact as ctc";
1122
-	}
1123
-	else
1259
+	} else
1124 1260
 	{
1125 1261
 		$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."projet_task as t ON p.rowid = t.fk_projet";
1126 1262
 	}
1127 1263
 	$sql.= " WHERE p.entity = ".$conf->entity;
1128 1264
 	$sql.= " AND p.rowid IN (".$projectsListId.")";
1129
-	if ($socid) $sql.= "  AND (p.fk_soc IS NULL OR p.fk_soc = 0 OR p.fk_soc = ".$socid.")";
1265
+	if ($socid) {
1266
+		$sql.= "  AND (p.fk_soc IS NULL OR p.fk_soc = 0 OR p.fk_soc = ".$socid.")";
1267
+	}
1130 1268
 	if ($mytasks)
1131 1269
 	{
1132 1270
 		$sql.= " AND p.rowid = t.fk_projet";
@@ -1169,9 +1307,12 @@  discard block
 block discarded – undo
1169 1307
             $arrayidofprojects[$objp->projectid]=$objp->projectid;
1170 1308
 			$i++;
1171 1309
 		}
1310
+	} else {
1311
+		dol_print_error($db);
1312
+	}
1313
+	if (empty($arrayidofprojects)) {
1314
+		$arrayidofprojects[0]=-1;
1172 1315
 	}
1173
-	else dol_print_error($db);
1174
-	if (empty($arrayidofprojects)) $arrayidofprojects[0]=-1;
1175 1316
 
1176 1317
 	// Get list of project with calculation on tasks
1177 1318
 	$sql2 = "SELECT p.rowid as projectid, p.ref, p.title, p.fk_soc, s.nom as socname, p.fk_user_creat, p.public, p.fk_statut as status, p.fk_opp_status as opp_status, p.opp_amount,";
@@ -1205,8 +1346,12 @@  discard block
 block discarded – undo
1205 1346
     	if (empty($conf->global->PROJECT_HIDE_TASKS))
1206 1347
     	{
1207 1348
             print_liste_field_titre("Tasks","","","","",'align="right"',$sortfield,$sortorder);
1208
-            if (! in_array('plannedworkload', $hiddenfields))  print_liste_field_titre("PlannedWorkload","","","","",'align="right"',$sortfield,$sortorder);
1209
-            if (! in_array('declaredprogress', $hiddenfields)) print_liste_field_titre("ProgressDeclared","","","","",'align="right"',$sortfield,$sortorder);
1349
+            if (! in_array('plannedworkload', $hiddenfields)) {
1350
+            	print_liste_field_titre("PlannedWorkload","","","","",'align="right"',$sortfield,$sortorder);
1351
+            }
1352
+            if (! in_array('declaredprogress', $hiddenfields)) {
1353
+            	print_liste_field_titre("ProgressDeclared","","","","",'align="right"',$sortfield,$sortorder);
1354
+            }
1210 1355
     	}
1211 1356
     	print_liste_field_titre("Status","","","","",'align="right"',$sortfield,$sortorder);
1212 1357
     	print "</tr>\n";
@@ -1233,7 +1378,9 @@  discard block
 block discarded – undo
1233 1378
 				print '<tr class="oddeven">';
1234 1379
 				print '<td>';
1235 1380
 				print $projectstatic->getNomUrl(1);
1236
-				if (! in_array('projectlabel', $hiddenfields)) print '<br>'.dol_trunc($objp->title,24);
1381
+				if (! in_array('projectlabel', $hiddenfields)) {
1382
+					print '<br>'.dol_trunc($objp->title,24);
1383
+				}
1237 1384
 				print '</td>';
1238 1385
 				print '<td>';
1239 1386
 				if ($objp->fk_soc > 0)
@@ -1247,11 +1394,15 @@  discard block
 block discarded – undo
1247 1394
 				if (! empty($conf->global->PROJECT_USE_OPPORTUNITIES))
1248 1395
 				{
1249 1396
 					print '<td align="right">';
1250
-        			if ($objp->opp_amount) print price($objp->opp_amount, 0, '', 1, -1, -1, $conf->currency);
1397
+        			if ($objp->opp_amount) {
1398
+        				print price($objp->opp_amount, 0, '', 1, -1, -1, $conf->currency);
1399
+        			}
1251 1400
 					print '</td>';
1252 1401
 					print '<td align="right">';
1253 1402
 					$code = dol_getIdFromCode($db, $objp->opp_status, 'c_lead_status', 'rowid', 'code');
1254
-        			if ($code) print $langs->trans("OppStatus".$code);
1403
+        			if ($code) {
1404
+        				print $langs->trans("OppStatus".$code);
1405
+        			}
1255 1406
 					print '</td>';
1256 1407
 				}
1257 1408
 				if (empty($conf->global->PROJECT_HIDE_TASKS))
@@ -1296,15 +1447,18 @@  discard block
 block discarded – undo
1296 1447
 		if (empty($conf->global->PROJECT_HIDE_TASKS))
1297 1448
 		{
1298 1449
             print '<td class="liste_total" align="right">'.$total_task.'</td>';
1299
-            if (! in_array('plannedworkload', $hiddenfields))  print '<td class="liste_total" align="right">'.($total_plannedworkload?convertSecondToTime($total_plannedworkload):'').'</td>';
1300
-            if (! in_array('declaredprogress', $hiddenfields)) print '<td class="liste_total" align="right">'.($total_plannedworkload?round(100*$total_declaredprogressworkload/$total_plannedworkload,0).'%':'').'</td>';
1450
+            if (! in_array('plannedworkload', $hiddenfields)) {
1451
+            	print '<td class="liste_total" align="right">'.($total_plannedworkload?convertSecondToTime($total_plannedworkload):'').'</td>';
1452
+            }
1453
+            if (! in_array('declaredprogress', $hiddenfields)) {
1454
+            	print '<td class="liste_total" align="right">'.($total_plannedworkload?round(100*$total_declaredprogressworkload/$total_plannedworkload,0).'%':'').'</td>';
1455
+            }
1301 1456
 		}
1302 1457
 		print '<td class="liste_total"></td>';
1303 1458
         print '</tr>';
1304 1459
 
1305 1460
 		$db->free($resql);
1306
-	}
1307
-	else
1461
+	} else
1308 1462
 	{
1309 1463
 		dol_print_error($db);
1310 1464
 	}
Please login to merge, or discard this patch.
htdocs/core/modules/barcode/mod_barcode_product_standard.php 4 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -104,7 +104,7 @@
 block discarded – undo
104 104
 	 * Return an example of result returned by getNextValue
105 105
 	 *
106 106
 	 * @param	Translate	$langs			Object langs
107
-	 * @param	Product		$objproduct		Object product
107
+	 * @param	integer		$objproduct		Object product
108 108
 	 * @return	string						Return string example
109 109
 	 */
110 110
 	function getExample($langs,$objproduct=0)
Please login to merge, or discard this patch.
Indentation   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -260,7 +260,7 @@  discard block
 block discarded – undo
260 260
 	 *	Return if a barcode value match syntax
261 261
 	 *
262 262
 	 *	@param	string	$codefortest	Code to check syntax
263
-     *  @param	string	$typefortest	Type of barcode (ISBN, EAN, ...)
263
+	 *  @param	string	$typefortest	Type of barcode (ISBN, EAN, ...)
264 264
 	 *	@return	int						0 if OK, <0 if KO
265 265
 	 */
266 266
 	function verif_syntax($codefortest, $typefortest)
@@ -284,11 +284,11 @@  discard block
 block discarded – undo
284 284
 		// Special case, if mask is on 12 digits instead of 13, we remove last char into code to test
285 285
 		if (in_array($typefortest,array('EAN13','ISBN')))	// We remove the CRC char not included into mask
286 286
 		{
287
-    		if (preg_match('/\{(0+)([@\+][0-9]+)?([@\+][0-9]+)?\}/i',$mask,$reg))
288
-    	    {
289
-    	        if (strlen($reg[1]) == 12) $newcodefortest=substr($newcodefortest,0,12);
290
-    	        dol_syslog(get_class($this).'::verif_syntax newcodefortest='.$newcodefortest);
291
-    	    }
287
+			if (preg_match('/\{(0+)([@\+][0-9]+)?([@\+][0-9]+)?\}/i',$mask,$reg))
288
+			{
289
+				if (strlen($reg[1]) == 12) $newcodefortest=substr($newcodefortest,0,12);
290
+				dol_syslog(get_class($this).'::verif_syntax newcodefortest='.$newcodefortest);
291
+			}
292 292
 		}
293 293
 
294 294
 		$result=check_value($mask,$newcodefortest);
Please login to merge, or discard this patch.
Spacing   +56 added lines, -56 removed lines patch added patch discarded remove patch
@@ -33,13 +33,13 @@  discard block
 block discarded – undo
33 33
  */
34 34
 class mod_barcode_product_standard extends ModeleNumRefBarCode
35 35
 {
36
-	var $name='Standard';				// Model Name
37
-	var $code_modifiable;				// Editable code
38
-	var $code_modifiable_invalide;		// Modified code if it is invalid
39
-	var $code_modifiable_null;			// Modified code if it is null
40
-	var $code_null;						// Optional code
41
-	var $version='dolibarr';    		// 'development', 'experimental', 'dolibarr'
42
-	var $code_auto;                     // Automatic Numbering
36
+	var $name = 'Standard'; // Model Name
37
+	var $code_modifiable; // Editable code
38
+	var $code_modifiable_invalide; // Modified code if it is invalid
39
+	var $code_modifiable_null; // Modified code if it is null
40
+	var $code_null; // Optional code
41
+	var $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr'
42
+	var $code_auto; // Automatic Numbering
43 43
 
44 44
 	var $searchcode; // Search string
45 45
 	var $numbitcounter; // Number of digits the counter
@@ -72,29 +72,29 @@  discard block
 block discarded – undo
72 72
 
73 73
 		$langs->load("products");
74 74
 
75
-		$disabled = ((! empty($mc->sharings['referent']) && $mc->sharings['referent'] != $conf->entity) ? ' disabled' : '');
75
+		$disabled = ((!empty($mc->sharings['referent']) && $mc->sharings['referent'] != $conf->entity) ? ' disabled' : '');
76 76
 
77 77
 		$texte = $langs->trans('GenericNumRefModelDesc')."<br>\n";
78
-		$texte.= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
79
-		$texte.= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
80
-		$texte.= '<input type="hidden" name="action" value="setModuleOptions">';
81
-		$texte.= '<input type="hidden" name="param1" value="BARCODE_STANDARD_PRODUCT_MASK">';
82
-		$texte.= '<table class="nobordernopadding" width="100%">';
78
+		$texte .= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
79
+		$texte .= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
80
+		$texte .= '<input type="hidden" name="action" value="setModuleOptions">';
81
+		$texte .= '<input type="hidden" name="param1" value="BARCODE_STANDARD_PRODUCT_MASK">';
82
+		$texte .= '<table class="nobordernopadding" width="100%">';
83 83
 
84
-		$tooltip=$langs->trans("GenericMaskCodes",$langs->transnoentities("BarCode"),$langs->transnoentities("BarCode"));
85
-		$tooltip.=$langs->trans("GenericMaskCodes3");
86
-		$tooltip.=$langs->trans("GenericMaskCodes4c");
87
-		$tooltip.=$langs->trans("GenericMaskCodes5");
84
+		$tooltip = $langs->trans("GenericMaskCodes", $langs->transnoentities("BarCode"), $langs->transnoentities("BarCode"));
85
+		$tooltip .= $langs->trans("GenericMaskCodes3");
86
+		$tooltip .= $langs->trans("GenericMaskCodes4c");
87
+		$tooltip .= $langs->trans("GenericMaskCodes5");
88 88
 
89 89
 		// Mask parameter
90 90
 		//$texte.= '<tr><td>'.$langs->trans("Mask").' ('.$langs->trans("BarCodeModel").'):</td>';
91
-		$texte.= '<tr><td>'.$langs->trans("Mask").':</td>';
92
-		$texte.= '<td align="right">'.$form->textwithpicto('<input type="text" class="flat" size="24" name="value1" value="'.(! empty($conf->global->BARCODE_STANDARD_PRODUCT_MASK)?$conf->global->BARCODE_STANDARD_PRODUCT_MASK:'').'"'.$disabled.'>',$tooltip,1,1).'</td>';
93
-		$texte.= '<td align="left" rowspan="2">&nbsp; <input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button"'.$disabled.'></td>';
94
-		$texte.= '</tr>';
91
+		$texte .= '<tr><td>'.$langs->trans("Mask").':</td>';
92
+		$texte .= '<td align="right">'.$form->textwithpicto('<input type="text" class="flat" size="24" name="value1" value="'.(!empty($conf->global->BARCODE_STANDARD_PRODUCT_MASK) ? $conf->global->BARCODE_STANDARD_PRODUCT_MASK : '').'"'.$disabled.'>', $tooltip, 1, 1).'</td>';
93
+		$texte .= '<td align="left" rowspan="2">&nbsp; <input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button"'.$disabled.'></td>';
94
+		$texte .= '</tr>';
95 95
 
96
-		$texte.= '</table>';
97
-		$texte.= '</form>';
96
+		$texte .= '</table>';
97
+		$texte .= '</form>';
98 98
 
99 99
 		return $texte;
100 100
 	}
@@ -107,17 +107,17 @@  discard block
 block discarded – undo
107 107
 	 * @param	Product		$objproduct		Object product
108 108
 	 * @return	string						Return string example
109 109
 	 */
110
-	function getExample($langs,$objproduct=0)
110
+	function getExample($langs, $objproduct = 0)
111 111
 	{
112
-		$examplebarcode = $this->getNextValue($objproduct,'');
113
-		if (! $examplebarcode)
112
+		$examplebarcode = $this->getNextValue($objproduct, '');
113
+		if (!$examplebarcode)
114 114
 		{
115 115
 			$examplebarcode = $langs->trans('NotConfigured');
116 116
 		}
117
-		if($examplebarcode=="ErrorBadMask")
117
+		if ($examplebarcode == "ErrorBadMask")
118 118
 		{
119 119
 			$langs->load("errors");
120
-			$examplebarcode=$langs->trans($examplebarcode);
120
+			$examplebarcode = $langs->trans($examplebarcode);
121 121
 		}
122 122
 
123 123
 		return $examplebarcode;
@@ -130,29 +130,29 @@  discard block
 block discarded – undo
130 130
 	 * @param	string		$type       	Type of barcode (EAN, ISBN, ...)
131 131
 	 * @return 	string      				Value if OK, '' if module not configured, <0 if KO
132 132
 	 */
133
-	function getNextValue($objproduct=null,$type='')
133
+	function getNextValue($objproduct = null, $type = '')
134 134
 	{
135
-		global $db,$conf;
135
+		global $db, $conf;
136 136
 
137
-		require_once DOL_DOCUMENT_ROOT .'/core/lib/functions2.lib.php';
137
+		require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
138 138
 
139 139
 		// TODO
140 140
 
141 141
 		// Get Mask value
142 142
 		$mask = '';
143
-		if (! empty($conf->global->BARCODE_STANDARD_PRODUCT_MASK)) $mask = $conf->global->BARCODE_STANDARD_PRODUCT_MASK;
143
+		if (!empty($conf->global->BARCODE_STANDARD_PRODUCT_MASK)) $mask = $conf->global->BARCODE_STANDARD_PRODUCT_MASK;
144 144
 
145 145
 		if (empty($mask))
146 146
 		{
147
-			$this->error='NotConfigured';
147
+			$this->error = 'NotConfigured';
148 148
 			return '';
149 149
 		}
150 150
 
151
-		$field='barcode';$where='';
151
+		$field = 'barcode'; $where = '';
152 152
 
153
-		$now=dol_now();
153
+		$now = dol_now();
154 154
 
155
-		$numFinal=get_next_value($db,$mask,'product',$field,$where,'',$now);
155
+		$numFinal = get_next_value($db, $mask, 'product', $field, $where, '', $now);
156 156
 
157 157
 		return  $numFinal;
158 158
 	}
@@ -178,18 +178,18 @@  discard block
 block discarded – undo
178 178
 
179 179
 		//var_dump($code.' '.$product->ref.' '.$thirdparty_type);exit;
180 180
 
181
-		require_once DOL_DOCUMENT_ROOT .'/core/lib/functions2.lib.php';
181
+		require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
182 182
 
183
-		$result=0;
183
+		$result = 0;
184 184
 		$code = strtoupper(trim($code));
185 185
 
186 186
 		if (empty($code) && $this->code_null && empty($conf->global->BARCODE_STANDARD_PRODUCT_MASK))
187 187
 		{
188
-			$result=0;
188
+			$result = 0;
189 189
 		}
190
-		else if (empty($code) && (! $this->code_null || ! empty($conf->global->BARCODE_STANDARD_PRODUCT_MASK)) )
190
+		else if (empty($code) && (!$this->code_null || !empty($conf->global->BARCODE_STANDARD_PRODUCT_MASK)))
191 191
 		{
192
-			$result=-2;
192
+			$result = -2;
193 193
 		}
194 194
 		else
195 195
 		{
@@ -198,22 +198,22 @@  discard block
 block discarded – undo
198 198
 				$is_dispo = $this->verif_dispo($db, $code, $product);
199 199
 				if ($is_dispo <> 0)
200 200
 				{
201
-					$result=-3;
201
+					$result = -3;
202 202
 				}
203 203
 				else
204 204
 				{
205
-					$result=0;
205
+					$result = 0;
206 206
 				}
207 207
 			}
208 208
 			else
209 209
 			{
210 210
 				if (dol_strlen($code) == 0)
211 211
 				{
212
-					$result=-2;
212
+					$result = -2;
213 213
 				}
214 214
 				else
215 215
 				{
216
-					$result=-1;
216
+					$result = -1;
217 217
 				}
218 218
 			}
219 219
 		}
@@ -234,10 +234,10 @@  discard block
 block discarded – undo
234 234
 	function verif_dispo($db, $code, $product)
235 235
 	{
236 236
 		$sql = "SELECT barcode FROM ".MAIN_DB_PREFIX."product";
237
-		$sql.= " WHERE barcode = '".$code."'";
238
-		if ($product->id > 0) $sql.= " AND rowid <> ".$product->id;
237
+		$sql .= " WHERE barcode = '".$code."'";
238
+		if ($product->id > 0) $sql .= " AND rowid <> ".$product->id;
239 239
 
240
-		$resql=$db->query($sql);
240
+		$resql = $db->query($sql);
241 241
 		if ($resql)
242 242
 		{
243 243
 			if ($db->num_rows($resql) == 0)
@@ -270,28 +270,28 @@  discard block
 block discarded – undo
270 270
 		$res = 0;
271 271
 
272 272
 		// Get Mask value
273
-		$mask = empty($conf->global->BARCODE_STANDARD_PRODUCT_MASK)?'':$conf->global->BARCODE_STANDARD_PRODUCT_MASK;
274
-		if (! $mask)
273
+		$mask = empty($conf->global->BARCODE_STANDARD_PRODUCT_MASK) ? '' : $conf->global->BARCODE_STANDARD_PRODUCT_MASK;
274
+		if (!$mask)
275 275
 		{
276
-			$this->error='NotConfigured';
276
+			$this->error = 'NotConfigured';
277 277
 			return '';
278 278
 		}
279 279
 
280 280
 		dol_syslog(get_class($this).'::verif_syntax codefortest='.$codefortest." typefortest=".$typefortest);
281 281
 
282
-		$newcodefortest=$codefortest;
282
+		$newcodefortest = $codefortest;
283 283
 
284 284
 		// Special case, if mask is on 12 digits instead of 13, we remove last char into code to test
285
-		if (in_array($typefortest,array('EAN13','ISBN')))	// We remove the CRC char not included into mask
285
+		if (in_array($typefortest, array('EAN13', 'ISBN')))	// We remove the CRC char not included into mask
286 286
 		{
287
-    		if (preg_match('/\{(0+)([@\+][0-9]+)?([@\+][0-9]+)?\}/i',$mask,$reg))
287
+    		if (preg_match('/\{(0+)([@\+][0-9]+)?([@\+][0-9]+)?\}/i', $mask, $reg))
288 288
     	    {
289
-    	        if (strlen($reg[1]) == 12) $newcodefortest=substr($newcodefortest,0,12);
289
+    	        if (strlen($reg[1]) == 12) $newcodefortest = substr($newcodefortest, 0, 12);
290 290
     	        dol_syslog(get_class($this).'::verif_syntax newcodefortest='.$newcodefortest);
291 291
     	    }
292 292
 		}
293 293
 
294
-		$result=check_value($mask,$newcodefortest);
294
+		$result = check_value($mask, $newcodefortest);
295 295
 
296 296
 		return $result;
297 297
 	}
Please login to merge, or discard this patch.
Braces   +16 added lines, -17 removed lines patch added patch discarded remove patch
@@ -140,7 +140,9 @@  discard block
 block discarded – undo
140 140
 
141 141
 		// Get Mask value
142 142
 		$mask = '';
143
-		if (! empty($conf->global->BARCODE_STANDARD_PRODUCT_MASK)) $mask = $conf->global->BARCODE_STANDARD_PRODUCT_MASK;
143
+		if (! empty($conf->global->BARCODE_STANDARD_PRODUCT_MASK)) {
144
+			$mask = $conf->global->BARCODE_STANDARD_PRODUCT_MASK;
145
+		}
144 146
 
145 147
 		if (empty($mask))
146 148
 		{
@@ -186,12 +188,10 @@  discard block
 block discarded – undo
186 188
 		if (empty($code) && $this->code_null && empty($conf->global->BARCODE_STANDARD_PRODUCT_MASK))
187 189
 		{
188 190
 			$result=0;
189
-		}
190
-		else if (empty($code) && (! $this->code_null || ! empty($conf->global->BARCODE_STANDARD_PRODUCT_MASK)) )
191
+		} else if (empty($code) && (! $this->code_null || ! empty($conf->global->BARCODE_STANDARD_PRODUCT_MASK)) )
191 192
 		{
192 193
 			$result=-2;
193
-		}
194
-		else
194
+		} else
195 195
 		{
196 196
 			if ($this->verif_syntax($code, $type) >= 0)
197 197
 			{
@@ -199,19 +199,16 @@  discard block
 block discarded – undo
199 199
 				if ($is_dispo <> 0)
200 200
 				{
201 201
 					$result=-3;
202
-				}
203
-				else
202
+				} else
204 203
 				{
205 204
 					$result=0;
206 205
 				}
207
-			}
208
-			else
206
+			} else
209 207
 			{
210 208
 				if (dol_strlen($code) == 0)
211 209
 				{
212 210
 					$result=-2;
213
-				}
214
-				else
211
+				} else
215 212
 				{
216 213
 					$result=-1;
217 214
 				}
@@ -235,7 +232,9 @@  discard block
 block discarded – undo
235 232
 	{
236 233
 		$sql = "SELECT barcode FROM ".MAIN_DB_PREFIX."product";
237 234
 		$sql.= " WHERE barcode = '".$code."'";
238
-		if ($product->id > 0) $sql.= " AND rowid <> ".$product->id;
235
+		if ($product->id > 0) {
236
+			$sql.= " AND rowid <> ".$product->id;
237
+		}
239 238
 
240 239
 		$resql=$db->query($sql);
241 240
 		if ($resql)
@@ -243,13 +242,11 @@  discard block
 block discarded – undo
243 242
 			if ($db->num_rows($resql) == 0)
244 243
 			{
245 244
 				return 0;
246
-			}
247
-			else
245
+			} else
248 246
 			{
249 247
 				return -1;
250 248
 			}
251
-		}
252
-		else
249
+		} else
253 250
 		{
254 251
 			return -2;
255 252
 		}
@@ -282,11 +279,13 @@  discard block
 block discarded – undo
282 279
 		$newcodefortest=$codefortest;
283 280
 
284 281
 		// Special case, if mask is on 12 digits instead of 13, we remove last char into code to test
285
-		if (in_array($typefortest,array('EAN13','ISBN')))	// We remove the CRC char not included into mask
282
+		if (in_array($typefortest,array('EAN13','ISBN'))) {
283
+			// We remove the CRC char not included into mask
286 284
 		{
287 285
     		if (preg_match('/\{(0+)([@\+][0-9]+)?([@\+][0-9]+)?\}/i',$mask,$reg))
288 286
     	    {
289 287
     	        if (strlen($reg[1]) == 12) $newcodefortest=substr($newcodefortest,0,12);
288
+		}
290 289
     	        dol_syslog(get_class($this).'::verif_syntax newcodefortest='.$newcodefortest);
291 290
     	    }
292 291
 		}
Please login to merge, or discard this patch.
htdocs/core/modules/cheque/mod_chequereceipt_mint.php 4 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -96,7 +96,7 @@
 block discarded – undo
96 96
 	 * 	Return next free value
97 97
 	 *
98 98
 	 *  @param	Societe		$objsoc     Object thirdparty
99
-	 *  @param  Object		$object		Object we need next value for
99
+	 *  @param  string		$object		Object we need next value for
100 100
 	 *  @return string      			Value if KO, <0 if KO
101 101
 	 */
102 102
 	function getNextValue($objsoc,$object)
Please login to merge, or discard this patch.
Indentation   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -35,16 +35,16 @@  discard block
 block discarded – undo
35 35
 	var $name='Mint';
36 36
 
37 37
 
38
-    /**
39
-     *  Return description of numbering module
40
-     *
41
-     *  @return     string      Text with description
42
-     */
43
-    function info()
44
-    {
45
-    	global $langs;
46
-      	return $langs->trans("SimpleNumRefModelDesc",$this->prefix);
47
-    }
38
+	/**
39
+	 *  Return description of numbering module
40
+	 *
41
+	 *  @return     string      Text with description
42
+	 */
43
+	function info()
44
+	{
45
+		global $langs;
46
+	  	return $langs->trans("SimpleNumRefModelDesc",$this->prefix);
47
+	}
48 48
 
49 49
 
50 50
 	/**
@@ -127,8 +127,8 @@  discard block
 block discarded – undo
127 127
 		$date=$object->date_bordereau;
128 128
 		$yymm = strftime("%y%m",$date);
129 129
 
130
-    	if ($max >= (pow(10, 4) - 1)) $num=$max+1;	// If counter > 9999, we do not format on 4 chars, we take number as it is
131
-    	else $num = sprintf("%04s",$max+1);
130
+		if ($max >= (pow(10, 4) - 1)) $num=$max+1;	// If counter > 9999, we do not format on 4 chars, we take number as it is
131
+		else $num = sprintf("%04s",$max+1);
132 132
 
133 133
 		dol_syslog(__METHOD__." return ".$this->prefix.$yymm."-".$num);
134 134
 		return $this->prefix.$yymm."-".$num;
Please login to merge, or discard this patch.
Braces   +13 added lines, -6 removed lines patch added patch discarded remove patch
@@ -114,10 +114,12 @@  discard block
 block discarded – undo
114 114
 		if ($resql)
115 115
 		{
116 116
 			$obj = $db->fetch_object($resql);
117
-			if ($obj) $max = intval($obj->max);
118
-			else $max=0;
119
-		}
120
-		else
117
+			if ($obj) {
118
+				$max = intval($obj->max);
119
+			} else {
120
+				$max=0;
121
+			}
122
+		} else
121 123
 		{
122 124
 			dol_syslog(__METHOD__, LOG_DEBUG);
123 125
 			return -1;
@@ -127,8 +129,13 @@  discard block
 block discarded – undo
127 129
 		$date=$object->date_bordereau;
128 130
 		$yymm = strftime("%y%m",$date);
129 131
 
130
-    	if ($max >= (pow(10, 4) - 1)) $num=$max+1;	// If counter > 9999, we do not format on 4 chars, we take number as it is
131
-    	else $num = sprintf("%04s",$max+1);
132
+    	if ($max >= (pow(10, 4) - 1)) {
133
+    		$num=$max+1;
134
+    	}
135
+    	// If counter > 9999, we do not format on 4 chars, we take number as it is
136
+    	else {
137
+    		$num = sprintf("%04s",$max+1);
138
+    	}
132 139
 
133 140
 		dol_syslog(__METHOD__." return ".$this->prefix.$yymm."-".$num);
134 141
 		return $this->prefix.$yymm."-".$num;
Please login to merge, or discard this patch.
Spacing   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -22,17 +22,17 @@  discard block
 block discarded – undo
22 22
  * \brief      File containing class for numbering module Mint
23 23
  */
24 24
 
25
-require_once DOL_DOCUMENT_ROOT .'/core/modules/cheque/modules_chequereceipts.php';
25
+require_once DOL_DOCUMENT_ROOT.'/core/modules/cheque/modules_chequereceipts.php';
26 26
 
27 27
 /**
28 28
  *	Class to manage cheque receipts numbering rules Mint
29 29
  */
30 30
 class mod_chequereceipt_mint extends ModeleNumRefChequeReceipts
31 31
 {
32
-	var $version='dolibarr';		// 'development', 'experimental', 'dolibarr'
33
-	var $prefix='CHK';
34
-	var $error='';
35
-	var $name='Mint';
32
+	var $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr'
33
+	var $prefix = 'CHK';
34
+	var $error = '';
35
+	var $name = 'Mint';
36 36
 
37 37
 
38 38
     /**
@@ -43,7 +43,7 @@  discard block
 block discarded – undo
43 43
     function info()
44 44
     {
45 45
     	global $langs;
46
-      	return $langs->trans("SimpleNumRefModelDesc",$this->prefix);
46
+      	return $langs->trans("SimpleNumRefModelDesc", $this->prefix);
47 47
     }
48 48
 
49 49
 
@@ -66,26 +66,26 @@  discard block
 block discarded – undo
66 66
 	 */
67 67
 	function canBeActivated()
68 68
 	{
69
-		global $conf,$langs,$db;
69
+		global $conf, $langs, $db;
70 70
 
71
-		$payyymm=''; $max='';
71
+		$payyymm = ''; $max = '';
72 72
 
73
-		$posindice=9;
73
+		$posindice = 9;
74 74
 		$sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max";
75
-		$sql.= " FROM ".MAIN_DB_PREFIX."bordereau_cheque";
76
-		$sql.= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'";
77
-		$sql.= " AND entity = ".$conf->entity;
75
+		$sql .= " FROM ".MAIN_DB_PREFIX."bordereau_cheque";
76
+		$sql .= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'";
77
+		$sql .= " AND entity = ".$conf->entity;
78 78
 
79
-		$resql=$db->query($sql);
79
+		$resql = $db->query($sql);
80 80
 		if ($resql)
81 81
 		{
82 82
 			$row = $db->fetch_row($resql);
83
-			if ($row) { $payyymm = substr($row[0],0,6); $max=$row[0]; }
83
+			if ($row) { $payyymm = substr($row[0], 0, 6); $max = $row[0]; }
84 84
 		}
85
-		if ($payyymm && ! preg_match('/'.$this->prefix.'[0-9][0-9][0-9][0-9]/i',$payyymm))
85
+		if ($payyymm && !preg_match('/'.$this->prefix.'[0-9][0-9][0-9][0-9]/i', $payyymm))
86 86
 		{
87 87
 			$langs->load("errors");
88
-			$this->error=$langs->trans('ErrorNumRefModel', $max);
88
+			$this->error = $langs->trans('ErrorNumRefModel', $max);
89 89
 			return false;
90 90
 		}
91 91
 
@@ -99,23 +99,23 @@  discard block
 block discarded – undo
99 99
 	 *  @param  Object		$object		Object we need next value for
100 100
 	 *  @return string      			Value if KO, <0 if KO
101 101
 	 */
102
-	function getNextValue($objsoc,$object)
102
+	function getNextValue($objsoc, $object)
103 103
 	{
104
-		global $db,$conf;
104
+		global $db, $conf;
105 105
 
106 106
 		// D'abord on recupere la valeur max
107
-		$posindice=9;
107
+		$posindice = 9;
108 108
 		$sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max";
109
-		$sql.= " FROM ".MAIN_DB_PREFIX."bordereau_cheque";
110
-		$sql.= " WHERE ref like '".$db->escape($this->prefix)."____-%'";
111
-		$sql.= " AND entity = ".$conf->entity;
109
+		$sql .= " FROM ".MAIN_DB_PREFIX."bordereau_cheque";
110
+		$sql .= " WHERE ref like '".$db->escape($this->prefix)."____-%'";
111
+		$sql .= " AND entity = ".$conf->entity;
112 112
 
113
-		$resql=$db->query($sql);
113
+		$resql = $db->query($sql);
114 114
 		if ($resql)
115 115
 		{
116 116
 			$obj = $db->fetch_object($resql);
117 117
 			if ($obj) $max = intval($obj->max);
118
-			else $max=0;
118
+			else $max = 0;
119 119
 		}
120 120
 		else
121 121
 		{
@@ -124,11 +124,11 @@  discard block
 block discarded – undo
124 124
 		}
125 125
 
126 126
 		//$date=time();
127
-		$date=$object->date_bordereau;
128
-		$yymm = strftime("%y%m",$date);
127
+		$date = $object->date_bordereau;
128
+		$yymm = strftime("%y%m", $date);
129 129
 
130
-    	if ($max >= (pow(10, 4) - 1)) $num=$max+1;	// If counter > 9999, we do not format on 4 chars, we take number as it is
131
-    	else $num = sprintf("%04s",$max+1);
130
+    	if ($max >= (pow(10, 4) - 1)) $num = $max + 1; // If counter > 9999, we do not format on 4 chars, we take number as it is
131
+    	else $num = sprintf("%04s", $max + 1);
132 132
 
133 133
 		dol_syslog(__METHOD__." return ".$this->prefix.$yymm."-".$num);
134 134
 		return $this->prefix.$yymm."-".$num;
@@ -142,9 +142,9 @@  discard block
 block discarded – undo
142 142
 	 * 	@param	string		$objforref	Object for number to search
143 143
 	 *  @return string      			Next free value
144 144
 	 */
145
-	function chequereceipt_get_num($objsoc,$objforref)
145
+	function chequereceipt_get_num($objsoc, $objforref)
146 146
 	{
147
-		return $this->getNextValue($objsoc,$objforref);
147
+		return $this->getNextValue($objsoc, $objforref);
148 148
 	}
149 149
 
150 150
 }
Please login to merge, or discard this patch.
htdocs/core/modules/cheque/mod_chequereceipt_thyme.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -100,7 +100,7 @@
 block discarded – undo
100 100
 	 * 	Return next free value
101 101
 	 *
102 102
 	 *  @param	Societe		$objsoc     Object thirdparty
103
-	 *  @param  Object		$object		Object we need next value for
103
+	 *  @param  string		$object		Object we need next value for
104 104
 	 *  @return string      			Value if KO, <0 if KO
105 105
 	 */
106 106
     function getNextValue($objsoc,$object)
Please login to merge, or discard this patch.
Indentation   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -35,14 +35,14 @@  discard block
 block discarded – undo
35 35
 	var $name = 'Thyme';
36 36
 
37 37
 
38
-    /**
39
-     *  Renvoi la description du modele de numerotation
40
-     *
41
-     *  @return     string      Texte descripif
42
-     */
38
+	/**
39
+	 *  Renvoi la description du modele de numerotation
40
+	 *
41
+	 *  @return     string      Texte descripif
42
+	 */
43 43
 	function info()
44
-    {
45
-    	global $conf,$langs;
44
+	{
45
+		global $conf,$langs;
46 46
 
47 47
 		$langs->load("bills");
48 48
 
@@ -73,20 +73,20 @@  discard block
 block discarded – undo
73 73
 		$texte.= '</form>';
74 74
 
75 75
 		return $texte;
76
-    }
77
-
78
-    /**
79
-     *  Renvoi un exemple de numerotation
80
-     *
81
-     *  @return     string      Example
82
-     */
83
-    function getExample()
84
-    {
85
-     	global $conf,$langs,$mysoc;
86
-
87
-    	$old_code_client=$mysoc->code_client;
88
-    	$mysoc->code_client='CCCCCCCCCC';
89
-     	$numExample = $this->getNextValue($mysoc,'');
76
+	}
77
+
78
+	/**
79
+	 *  Renvoi un exemple de numerotation
80
+	 *
81
+	 *  @return     string      Example
82
+	 */
83
+	function getExample()
84
+	{
85
+	 	global $conf,$langs,$mysoc;
86
+
87
+		$old_code_client=$mysoc->code_client;
88
+		$mysoc->code_client='CCCCCCCCCC';
89
+	 	$numExample = $this->getNextValue($mysoc,'');
90 90
 		$mysoc->code_client=$old_code_client;
91 91
 
92 92
 		if (! $numExample)
@@ -94,7 +94,7 @@  discard block
 block discarded – undo
94 94
 			$numExample = $langs->trans('NotConfigured');
95 95
 		}
96 96
 		return $numExample;
97
-    }
97
+	}
98 98
 
99 99
 	/**
100 100
 	 * 	Return next free value
@@ -103,8 +103,8 @@  discard block
 block discarded – undo
103 103
 	 *  @param  Object		$object		Object we need next value for
104 104
 	 *  @return string      			Value if KO, <0 if KO
105 105
 	 */
106
-    function getNextValue($objsoc,$object)
107
-    {
106
+	function getNextValue($objsoc,$object)
107
+	{
108 108
 		global $db,$conf;
109 109
 
110 110
 		require_once DOL_DOCUMENT_ROOT .'/core/lib/functions2.lib.php';
@@ -130,11 +130,11 @@  discard block
 block discarded – undo
130 130
 	 *  @param	Societe		$objsoc     Object third party
131 131
 	 * 	@param	string		$objforref	Object for number to search
132 132
 	 *  @return string      			Next free value
133
-     */
134
-    function chequereceipt_get_num($objsoc,$objforref)
135
-    {
136
-        return $this->getNextValue($objsoc,$objforref);
137
-    }
133
+	 */
134
+	function chequereceipt_get_num($objsoc,$objforref)
135
+	{
136
+		return $this->getNextValue($objsoc,$objforref);
137
+	}
138 138
 
139 139
 }
140 140
 
Please login to merge, or discard this patch.
Spacing   +35 added lines, -35 removed lines patch added patch discarded remove patch
@@ -22,7 +22,7 @@  discard block
 block discarded – undo
22 22
  * \brief      File containing class for numbering module Thyme
23 23
  */
24 24
 
25
-require_once DOL_DOCUMENT_ROOT .'/core/modules/cheque/modules_chequereceipts.php';
25
+require_once DOL_DOCUMENT_ROOT.'/core/modules/cheque/modules_chequereceipts.php';
26 26
 
27 27
 
28 28
 /**
@@ -30,7 +30,7 @@  discard block
 block discarded – undo
30 30
  */
31 31
 class mod_chequereceipt_thyme extends ModeleNumRefChequeReceipts
32 32
 {
33
-	var $version='dolibarr';		// 'development', 'experimental', 'dolibarr'
33
+	var $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr'
34 34
 	var $error = '';
35 35
 	var $name = 'Thyme';
36 36
 
@@ -42,35 +42,35 @@  discard block
 block discarded – undo
42 42
      */
43 43
 	function info()
44 44
     {
45
-    	global $conf,$langs;
45
+    	global $conf, $langs;
46 46
 
47 47
 		$langs->load("bills");
48 48
 
49 49
 		$form = new Form($this->db);
50 50
 
51 51
 		$texte = $langs->trans('GenericNumRefModelDesc')."<br>\n";
52
-		$texte.= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
53
-		$texte.= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
54
-		$texte.= '<input type="hidden" name="action" value="updateMask">';
55
-		$texte.= '<input type="hidden" name="maskconstchequereceipts" value="CHEQUERECEIPTS_THYME_MASK">';
56
-		$texte.= '<table class="nobordernopadding" width="100%">';
57
-
58
-		$tooltip=$langs->trans("GenericMaskCodes",$langs->transnoentities("CheckReceiptShort"),$langs->transnoentities("CheckReceiptShort"));
59
-		$tooltip.=$langs->trans("GenericMaskCodes2");
60
-		$tooltip.=$langs->trans("GenericMaskCodes3");
61
-		$tooltip.=$langs->trans("GenericMaskCodes4a",$langs->transnoentities("CheckReceiptShort"),$langs->transnoentities("CheckReceiptShort"));
62
-		$tooltip.=$langs->trans("GenericMaskCodes5");
52
+		$texte .= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
53
+		$texte .= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
54
+		$texte .= '<input type="hidden" name="action" value="updateMask">';
55
+		$texte .= '<input type="hidden" name="maskconstchequereceipts" value="CHEQUERECEIPTS_THYME_MASK">';
56
+		$texte .= '<table class="nobordernopadding" width="100%">';
57
+
58
+		$tooltip = $langs->trans("GenericMaskCodes", $langs->transnoentities("CheckReceiptShort"), $langs->transnoentities("CheckReceiptShort"));
59
+		$tooltip .= $langs->trans("GenericMaskCodes2");
60
+		$tooltip .= $langs->trans("GenericMaskCodes3");
61
+		$tooltip .= $langs->trans("GenericMaskCodes4a", $langs->transnoentities("CheckReceiptShort"), $langs->transnoentities("CheckReceiptShort"));
62
+		$tooltip .= $langs->trans("GenericMaskCodes5");
63 63
 
64 64
 		// Parametrage du prefix
65
-		$texte.= '<tr><td>'.$langs->trans("Mask").':</td>';
66
-		$texte.= '<td align="right">'.$form->textwithpicto('<input type="text" class="flat" size="24" name="maskchequereceipts" value="'.$conf->global->CHEQUERECEIPTS_THYME_MASK.'">',$tooltip,1,1).'</td>';
65
+		$texte .= '<tr><td>'.$langs->trans("Mask").':</td>';
66
+		$texte .= '<td align="right">'.$form->textwithpicto('<input type="text" class="flat" size="24" name="maskchequereceipts" value="'.$conf->global->CHEQUERECEIPTS_THYME_MASK.'">', $tooltip, 1, 1).'</td>';
67 67
 
68
-		$texte.= '<td align="left" rowspan="2">&nbsp; <input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button"></td>';
68
+		$texte .= '<td align="left" rowspan="2">&nbsp; <input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button"></td>';
69 69
 
70
-		$texte.= '</tr>';
70
+		$texte .= '</tr>';
71 71
 
72
-		$texte.= '</table>';
73
-		$texte.= '</form>';
72
+		$texte .= '</table>';
73
+		$texte .= '</form>';
74 74
 
75 75
 		return $texte;
76 76
     }
@@ -82,14 +82,14 @@  discard block
 block discarded – undo
82 82
      */
83 83
     function getExample()
84 84
     {
85
-     	global $conf,$langs,$mysoc;
85
+     	global $conf, $langs, $mysoc;
86 86
 
87
-    	$old_code_client=$mysoc->code_client;
88
-    	$mysoc->code_client='CCCCCCCCCC';
89
-     	$numExample = $this->getNextValue($mysoc,'');
90
-		$mysoc->code_client=$old_code_client;
87
+    	$old_code_client = $mysoc->code_client;
88
+    	$mysoc->code_client = 'CCCCCCCCCC';
89
+     	$numExample = $this->getNextValue($mysoc, '');
90
+		$mysoc->code_client = $old_code_client;
91 91
 
92
-		if (! $numExample)
92
+		if (!$numExample)
93 93
 		{
94 94
 			$numExample = $langs->trans('NotConfigured');
95 95
 		}
@@ -103,22 +103,22 @@  discard block
 block discarded – undo
103 103
 	 *  @param  Object		$object		Object we need next value for
104 104
 	 *  @return string      			Value if KO, <0 if KO
105 105
 	 */
106
-    function getNextValue($objsoc,$object)
106
+    function getNextValue($objsoc, $object)
107 107
     {
108
-		global $db,$conf;
108
+		global $db, $conf;
109 109
 
110
-		require_once DOL_DOCUMENT_ROOT .'/core/lib/functions2.lib.php';
110
+		require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
111 111
 
112 112
 		// We get cursor rule
113
-		$mask=$conf->global->CHEQUERECEIPTS_THYME_MASK;
113
+		$mask = $conf->global->CHEQUERECEIPTS_THYME_MASK;
114 114
 
115
-		if (! $mask)
115
+		if (!$mask)
116 116
 		{
117
-			$this->error='NotConfigured';
117
+			$this->error = 'NotConfigured';
118 118
 			return 0;
119 119
 		}
120 120
 
121
-		$numFinal=get_next_value($db,$mask,'bordereau_cheque','ref','',$objsoc,$object->date_bordereau);
121
+		$numFinal = get_next_value($db, $mask, 'bordereau_cheque', 'ref', '', $objsoc, $object->date_bordereau);
122 122
 
123 123
 		return  $numFinal;
124 124
 	}
@@ -131,9 +131,9 @@  discard block
 block discarded – undo
131 131
 	 * 	@param	string		$objforref	Object for number to search
132 132
 	 *  @return string      			Next free value
133 133
      */
134
-    function chequereceipt_get_num($objsoc,$objforref)
134
+    function chequereceipt_get_num($objsoc, $objforref)
135 135
     {
136
-        return $this->getNextValue($objsoc,$objforref);
136
+        return $this->getNextValue($objsoc, $objforref);
137 137
     }
138 138
 
139 139
 }
Please login to merge, or discard this patch.
htdocs/core/modules/expedition/doc/pdf_merou.modules.php 4 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -43,7 +43,7 @@
 block discarded – undo
43 43
 	/**
44 44
 	 *	Constructor
45 45
 	 *
46
-	 *  @param		DoliDB		$db      Database handler
46
+	 *  @param		integer		$db      Database handler
47 47
 	 */
48 48
 	function __construct($db=0)
49 49
 	{
Please login to merge, or discard this patch.
Indentation   +35 added lines, -35 removed lines patch added patch discarded remove patch
@@ -76,11 +76,11 @@  discard block
 block discarded – undo
76 76
 	 *
77 77
 	 *	@param		Object		$object			Object expedition to generate (or id if old method)
78 78
 	 *	@param		Translate	$outputlangs		Lang output object
79
-     *  @param		string		$srctemplatepath	Full path of source filename for generator using a template file
80
-     *  @param		int			$hidedetails		Do not show line details
81
-     *  @param		int			$hidedesc			Do not show desc
82
-     *  @param		int			$hideref			Do not show ref
83
-     *  @return     int         	    			1=OK, 0=KO
79
+	 *  @param		string		$srctemplatepath	Full path of source filename for generator using a template file
80
+	 *  @param		int			$hidedetails		Do not show line details
81
+	 *  @param		int			$hidedesc			Do not show desc
82
+	 *  @param		int			$hideref			Do not show ref
83
+	 *  @return     int         	    			1=OK, 0=KO
84 84
 	 */
85 85
 	function write_file(&$object,$outputlangs,$srctemplatepath='',$hidedetails=0,$hidedesc=0,$hideref=0)
86 86
 	{
@@ -113,7 +113,7 @@  discard block
 block discarded – undo
113 113
 
114 114
 			//Creation du destinataire
115 115
 			$idcontact = $object->$origin->getIdContact('external','SHIPPING');
116
-            $this->destinataire = new Contact($this->db);
116
+			$this->destinataire = new Contact($this->db);
117 117
 			if (! empty($idcontact[0])) $this->destinataire->fetch($idcontact[0]);
118 118
 
119 119
 			//Creation du livreur
@@ -161,22 +161,22 @@  discard block
 block discarded – undo
161 161
 				$pdf=pdf_getInstance($this->format,'mm','l');
162 162
 				$default_font_size = pdf_getPDFFontSize($outputlangs);
163 163
 				$heightforinfotot = 0;	// Height reserved to output the info and total part
164
-		        $heightforfreetext= (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT)?$conf->global->MAIN_PDF_FREETEXT_HEIGHT:5);	// Height reserved to output the free text on last page
165
-	            $heightforfooter = $this->marge_basse + 8;	// Height reserved to output the footer (value include bottom margin)
166
-                $pdf->SetAutoPageBreak(1,0);
167
-
168
-			    if (class_exists('TCPDF'))
169
-                {
170
-                    $pdf->setPrintHeader(false);
171
-                    $pdf->setPrintFooter(false);
172
-                }
173
-                $pdf->SetFont(pdf_getPDFFont($outputlangs));
174
-                // Set path to the background PDF File
175
-                if (empty($conf->global->MAIN_DISABLE_FPDI) && ! empty($conf->global->MAIN_ADD_PDF_BACKGROUND))
176
-                {
177
-                    $pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND);
178
-                    $tplidx = $pdf->importPage(1);
179
-                }
164
+				$heightforfreetext= (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT)?$conf->global->MAIN_PDF_FREETEXT_HEIGHT:5);	// Height reserved to output the free text on last page
165
+				$heightforfooter = $this->marge_basse + 8;	// Height reserved to output the footer (value include bottom margin)
166
+				$pdf->SetAutoPageBreak(1,0);
167
+
168
+				if (class_exists('TCPDF'))
169
+				{
170
+					$pdf->setPrintHeader(false);
171
+					$pdf->setPrintFooter(false);
172
+				}
173
+				$pdf->SetFont(pdf_getPDFFont($outputlangs));
174
+				// Set path to the background PDF File
175
+				if (empty($conf->global->MAIN_DISABLE_FPDI) && ! empty($conf->global->MAIN_ADD_PDF_BACKGROUND))
176
+				{
177
+					$pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND);
178
+					$tplidx = $pdf->importPage(1);
179
+				}
180 180
 
181 181
 				$pdf->Open();
182 182
 				$pagenb=0;
@@ -356,8 +356,8 @@  discard block
 block discarded – undo
356 356
 				global $action;
357 357
 				$reshook=$hookmanager->executeHooks('afterPDFCreation',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
358 358
 
359
-                if (! empty($conf->global->MAIN_UMASK))
360
-                    @chmod($file, octdec($conf->global->MAIN_UMASK));
359
+				if (! empty($conf->global->MAIN_UMASK))
360
+					@chmod($file, octdec($conf->global->MAIN_UMASK));
361 361
 
362 362
 				$this->result = array('fullpath'=>$file);
363 363
                 
@@ -419,7 +419,7 @@  discard block
 block discarded – undo
419 419
 
420 420
 	/**
421 421
 	 *   	Show footer of page. Need this->emetteur object
422
-     *
422
+	 *
423 423
 	 *   	@param	PDF			$pdf     			PDF
424 424
 	 * 		@param	Object		$object				Object to show
425 425
 	 *      @param	Translate	$outputlangs		Object lang for output
@@ -438,11 +438,11 @@  discard block
 block discarded – undo
438 438
 		$pdf->MultiCell(100, 3, $outputlangs->transnoentities("NameAndSignature"), 0, 'C');
439 439
 
440 440
 		// Show page nb only on iso languages (so default Helvetica font)
441
-        //if (pdf_getPDFFont($outputlangs) == 'Helvetica')
442
-        //{
443
-    	//    $pdf->SetXY(-10,-10);
444
-        //    $pdf->MultiCell(11, 2, $pdf->PageNo().'/'.$pdf->getAliasNbPages(), 0, 'R', 0);
445
-        //}
441
+		//if (pdf_getPDFFont($outputlangs) == 'Helvetica')
442
+		//{
443
+		//    $pdf->SetXY(-10,-10);
444
+		//    $pdf->MultiCell(11, 2, $pdf->PageNo().'/'.$pdf->getAliasNbPages(), 0, 'R', 0);
445
+		//}
446 446
 	}
447 447
 
448 448
 
@@ -466,11 +466,11 @@  discard block
 block discarded – undo
466 466
 			//Affiche le filigrane brouillon - Print Draft Watermark
467 467
 		if($object->statut==0 && (! empty($conf->global->SENDING_DRAFT_WATERMARK)) )
468 468
 		{
469
-            pdf_watermark($pdf,$outputlangs,$this->page_hauteur,$this->page_largeur,'mm',$conf->global->SENDING_DRAFT_WATERMARK);
469
+			pdf_watermark($pdf,$outputlangs,$this->page_hauteur,$this->page_largeur,'mm',$conf->global->SENDING_DRAFT_WATERMARK);
470 470
 		}
471 471
 
472
-        $posy=$this->marge_haute;
473
-        $posx=$this->page_largeur-$this->marge_droite-100;
472
+		$posy=$this->marge_haute;
473
+		$posx=$this->page_largeur-$this->marge_droite-100;
474 474
 
475 475
 		$Xoff = 90;
476 476
 		$Yoff = 0;
@@ -487,8 +487,8 @@  discard block
 block discarded – undo
487 487
 		{
488 488
 			if (is_readable($logo))
489 489
 			{
490
-			    $height=pdf_getHeightForLogo($logo);
491
-			    $pdf->Image($logo,10, 5, 0, $height);	// width=0 (auto)
490
+				$height=pdf_getHeightForLogo($logo);
491
+				$pdf->Image($logo,10, 5, 0, $height);	// width=0 (auto)
492 492
 			}
493 493
 			else
494 494
 			{
Please login to merge, or discard this patch.
Spacing   +181 added lines, -181 removed lines patch added patch discarded remove patch
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
  */
38 38
 class pdf_merou extends ModelePdfExpedition
39 39
 {
40
-	var $emetteur;	// Objet societe qui emet
40
+	var $emetteur; // Objet societe qui emet
41 41
 
42 42
 
43 43
 	/**
@@ -45,29 +45,29 @@  discard block
 block discarded – undo
45 45
 	 *
46 46
 	 *  @param		DoliDB		$db      Database handler
47 47
 	 */
48
-	function __construct($db=0)
48
+	function __construct($db = 0)
49 49
 	{
50
-		global $conf,$langs,$mysoc;
50
+		global $conf, $langs, $mysoc;
51 51
 
52 52
 		$this->db = $db;
53 53
 		$this->name = "merou";
54 54
 		$this->description = $langs->trans("DocumentModelMerou");
55 55
 
56 56
 		$this->type = 'pdf';
57
-		$formatarray=pdf_getFormat();
57
+		$formatarray = pdf_getFormat();
58 58
 		$this->page_largeur = $formatarray['width'];
59
-		$this->page_hauteur = round($formatarray['height']/2);
60
-		$this->format = array($this->page_largeur,$this->page_hauteur);
61
-		$this->marge_gauche=isset($conf->global->MAIN_PDF_MARGIN_LEFT)?$conf->global->MAIN_PDF_MARGIN_LEFT:10;
62
-		$this->marge_droite=isset($conf->global->MAIN_PDF_MARGIN_RIGHT)?$conf->global->MAIN_PDF_MARGIN_RIGHT:10;
63
-		$this->marge_haute =isset($conf->global->MAIN_PDF_MARGIN_TOP)?$conf->global->MAIN_PDF_MARGIN_TOP:10;
64
-		$this->marge_basse =isset($conf->global->MAIN_PDF_MARGIN_BOTTOM)?$conf->global->MAIN_PDF_MARGIN_BOTTOM:10;
59
+		$this->page_hauteur = round($formatarray['height'] / 2);
60
+		$this->format = array($this->page_largeur, $this->page_hauteur);
61
+		$this->marge_gauche = isset($conf->global->MAIN_PDF_MARGIN_LEFT) ? $conf->global->MAIN_PDF_MARGIN_LEFT : 10;
62
+		$this->marge_droite = isset($conf->global->MAIN_PDF_MARGIN_RIGHT) ? $conf->global->MAIN_PDF_MARGIN_RIGHT : 10;
63
+		$this->marge_haute = isset($conf->global->MAIN_PDF_MARGIN_TOP) ? $conf->global->MAIN_PDF_MARGIN_TOP : 10;
64
+		$this->marge_basse = isset($conf->global->MAIN_PDF_MARGIN_BOTTOM) ? $conf->global->MAIN_PDF_MARGIN_BOTTOM : 10;
65 65
 
66 66
 		$this->option_logo = 1;
67 67
 
68 68
 		// Recupere emmetteur
69
-		$this->emetteur=$mysoc;
70
-		if (! $this->emetteur->country_code) $this->emetteur->country_code=substr($langs->defaultlang,-2);    // By default if not defined
69
+		$this->emetteur = $mysoc;
70
+		if (!$this->emetteur->country_code) $this->emetteur->country_code = substr($langs->defaultlang, -2); // By default if not defined
71 71
 	}
72 72
 
73 73
 
@@ -82,15 +82,15 @@  discard block
 block discarded – undo
82 82
      *  @param		int			$hideref			Do not show ref
83 83
      *  @return     int         	    			1=OK, 0=KO
84 84
 	 */
85
-	function write_file(&$object,$outputlangs,$srctemplatepath='',$hidedetails=0,$hidedesc=0,$hideref=0)
85
+	function write_file(&$object, $outputlangs, $srctemplatepath = '', $hidedetails = 0, $hidedesc = 0, $hideref = 0)
86 86
 	{
87
-		global $user,$conf,$langs,$mysoc,$hookmanager;
87
+		global $user, $conf, $langs, $mysoc, $hookmanager;
88 88
 
89 89
 		$object->fetch_thirdparty();
90 90
 
91
-		if (! is_object($outputlangs)) $outputlangs=$langs;
91
+		if (!is_object($outputlangs)) $outputlangs = $langs;
92 92
 		// For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
93
-		if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1';
93
+		if (!empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output = 'ISO-8859-1';
94 94
 
95 95
 		$outputlangs->load("main");
96 96
 		$outputlangs->load("dict");
@@ -112,33 +112,33 @@  discard block
 block discarded – undo
112 112
 			$this->expediteur = $mysoc;
113 113
 
114 114
 			//Creation du destinataire
115
-			$idcontact = $object->$origin->getIdContact('external','SHIPPING');
115
+			$idcontact = $object->$origin->getIdContact('external', 'SHIPPING');
116 116
             $this->destinataire = new Contact($this->db);
117
-			if (! empty($idcontact[0])) $this->destinataire->fetch($idcontact[0]);
117
+			if (!empty($idcontact[0])) $this->destinataire->fetch($idcontact[0]);
118 118
 
119 119
 			//Creation du livreur
120
-			$idcontact = $object->$origin->getIdContact('internal','LIVREUR');
120
+			$idcontact = $object->$origin->getIdContact('internal', 'LIVREUR');
121 121
 			$this->livreur = new User($this->db);
122
-			if (! empty($idcontact[0])) $this->livreur->fetch($idcontact[0]);
122
+			if (!empty($idcontact[0])) $this->livreur->fetch($idcontact[0]);
123 123
 
124 124
 			// Definition de $dir et $file
125 125
 			if ($object->specimen)
126 126
 			{
127 127
 				$dir = $conf->expedition->dir_output."/sending";
128
-				$file = $dir . "/SPECIMEN.pdf";
128
+				$file = $dir."/SPECIMEN.pdf";
129 129
 			}
130 130
 			else
131 131
 			{
132 132
 				$expref = dol_sanitizeFileName($object->ref);
133
-				$dir = $conf->expedition->dir_output . "/sending/" . $expref;
134
-				$file = $dir . "/" . $expref . ".pdf";
133
+				$dir = $conf->expedition->dir_output."/sending/".$expref;
134
+				$file = $dir."/".$expref.".pdf";
135 135
 			}
136 136
 
137
-			if (! file_exists($dir))
137
+			if (!file_exists($dir))
138 138
 			{
139 139
 				if (dol_mkdir($dir) < 0)
140 140
 				{
141
-					$this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
141
+					$this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir);
142 142
 					return 0;
143 143
 				}
144 144
 			}
@@ -146,24 +146,24 @@  discard block
 block discarded – undo
146 146
 			if (file_exists($dir))
147 147
 			{
148 148
 				// Add pdfgeneration hook
149
-				if (! is_object($hookmanager))
149
+				if (!is_object($hookmanager))
150 150
 				{
151 151
 					include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
152
-					$hookmanager=new HookManager($this->db);
152
+					$hookmanager = new HookManager($this->db);
153 153
 				}
154 154
 				$hookmanager->initHooks(array('pdfgeneration'));
155
-				$parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs);
155
+				$parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs);
156 156
 				global $action;
157
-				$reshook=$hookmanager->executeHooks('beforePDFCreation',$parameters,$object,$action);    // Note that $action and $object may have been modified by some hooks
157
+				$reshook = $hookmanager->executeHooks('beforePDFCreation', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
158 158
 
159 159
 				$nblignes = count($object->lines);
160 160
 
161
-				$pdf=pdf_getInstance($this->format,'mm','l');
161
+				$pdf = pdf_getInstance($this->format, 'mm', 'l');
162 162
 				$default_font_size = pdf_getPDFFontSize($outputlangs);
163
-				$heightforinfotot = 0;	// Height reserved to output the info and total part
164
-		        $heightforfreetext= (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT)?$conf->global->MAIN_PDF_FREETEXT_HEIGHT:5);	// Height reserved to output the free text on last page
165
-	            $heightforfooter = $this->marge_basse + 8;	// Height reserved to output the footer (value include bottom margin)
166
-                $pdf->SetAutoPageBreak(1,0);
163
+				$heightforinfotot = 0; // Height reserved to output the info and total part
164
+		        $heightforfreetext = (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT) ? $conf->global->MAIN_PDF_FREETEXT_HEIGHT : 5); // Height reserved to output the free text on last page
165
+	            $heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin)
166
+                $pdf->SetAutoPageBreak(1, 0);
167 167
 
168 168
 			    if (class_exists('TCPDF'))
169 169
                 {
@@ -172,105 +172,105 @@  discard block
 block discarded – undo
172 172
                 }
173 173
                 $pdf->SetFont(pdf_getPDFFont($outputlangs));
174 174
                 // Set path to the background PDF File
175
-                if (empty($conf->global->MAIN_DISABLE_FPDI) && ! empty($conf->global->MAIN_ADD_PDF_BACKGROUND))
175
+                if (empty($conf->global->MAIN_DISABLE_FPDI) && !empty($conf->global->MAIN_ADD_PDF_BACKGROUND))
176 176
                 {
177 177
                     $pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND);
178 178
                     $tplidx = $pdf->importPage(1);
179 179
                 }
180 180
 
181 181
 				$pdf->Open();
182
-				$pagenb=0;
183
-				$pdf->SetDrawColor(128,128,128);
182
+				$pagenb = 0;
183
+				$pdf->SetDrawColor(128, 128, 128);
184 184
 
185
-				if (method_exists($pdf,'AliasNbPages')) $pdf->AliasNbPages();
185
+				if (method_exists($pdf, 'AliasNbPages')) $pdf->AliasNbPages();
186 186
 
187 187
 				$pdf->SetTitle($outputlangs->convToOutputCharset($object->ref));
188 188
 				$pdf->SetSubject($outputlangs->transnoentities("Shipment"));
189 189
 				$pdf->SetCreator("Dolibarr ".DOL_VERSION);
190 190
 				$pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
191 191
 				$pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("Shipment"));
192
-				if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
192
+				if (!empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
193 193
 
194
-				$pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);   // Left, Top, Right
194
+				$pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right
195 195
 
196 196
 				// New page
197 197
 				$pdf->AddPage();
198 198
 				$pagenb++;
199 199
 				$this->_pagehead($pdf, $object, 1, $outputlangs);
200
-				$pdf->SetFont('','', $default_font_size - 3);
201
-				$pdf->MultiCell(0, 3, '');		// Set interline to 3
202
-				$pdf->SetTextColor(0,0,0);
200
+				$pdf->SetFont('', '', $default_font_size - 3);
201
+				$pdf->MultiCell(0, 3, ''); // Set interline to 3
202
+				$pdf->SetTextColor(0, 0, 0);
203 203
 
204 204
 				$tab_top = 52;
205
-				$tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)?42:10);
205
+				$tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD) ? 42 : 10);
206 206
 				$tab_height = $this->page_hauteur - $tab_top - $heightforfooter;
207 207
 				$tab_height_newpage = $this->page_hauteur - $tab_top_newpage - $heightforfooter;
208 208
 
209 209
 				// Affiche notes
210
-				if (! empty($object->note_public))
210
+				if (!empty($object->note_public))
211 211
 				{
212
-					$pdf->SetFont('','', $default_font_size - 1);
212
+					$pdf->SetFont('', '', $default_font_size - 1);
213 213
 					$pdf->writeHTMLCell(190, 3, $this->marge_gauche, $tab_top, dol_htmlentitiesbr($object->note_public), 0, 1);
214 214
 					$nexY = $pdf->GetY();
215
-					$height_note=$nexY-$tab_top;
215
+					$height_note = $nexY - $tab_top;
216 216
 
217 217
 					// Rect prend une longueur en 3eme param
218
-					$pdf->SetDrawColor(192,192,192);
219
-					$pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_note+1);
218
+					$pdf->SetDrawColor(192, 192, 192);
219
+					$pdf->Rect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_note + 1);
220 220
 
221 221
 					$tab_height = $tab_height - $height_note;
222
-					$tab_top = $nexY+6;
222
+					$tab_top = $nexY + 6;
223 223
 				}
224 224
 				else
225 225
 				{
226
-					$height_note=0;
226
+					$height_note = 0;
227 227
 				}
228 228
 
229 229
 
230
-				$pdf->SetFillColor(240,240,240);
231
-				$pdf->SetTextColor(0,0,0);
230
+				$pdf->SetFillColor(240, 240, 240);
231
+				$pdf->SetTextColor(0, 0, 0);
232 232
 				$pdf->SetXY(10, $tab_top + 5);
233 233
 
234 234
 				$iniY = $tab_top + 7;
235 235
 				$curY = $tab_top + 7;
236 236
 				$nexY = $tab_top + 7;
237 237
 
238
-				$num=count($object->lines);
238
+				$num = count($object->lines);
239 239
 				// Loop on each lines
240 240
 				for ($i = 0; $i < $num; $i++)
241 241
 				{
242 242
 					$curY = $nexY;
243
-					$pdf->SetFont('','', $default_font_size - 3);
244
-					$pdf->SetTextColor(0,0,0);
243
+					$pdf->SetFont('', '', $default_font_size - 3);
244
+					$pdf->SetTextColor(0, 0, 0);
245 245
 
246 246
 					$pdf->setTopMargin($tab_top_newpage);
247
-					$pdf->setPageOrientation('', 1, $heightforfooter);	// The only function to edit the bottom margin of current page to set it.
248
-					$pageposbefore=$pdf->getPage();
247
+					$pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it.
248
+					$pageposbefore = $pdf->getPage();
249 249
 
250 250
 					// Description de la ligne produit
251
-					$libelleproduitservice = pdf_writelinedesc($pdf,$object,$i,$outputlangs,90,3,50,$curY,0,1);
251
+					$libelleproduitservice = pdf_writelinedesc($pdf, $object, $i, $outputlangs, 90, 3, 50, $curY, 0, 1);
252 252
 
253 253
 					$nexY = $pdf->GetY();
254
-					$pageposafter=$pdf->getPage();
254
+					$pageposafter = $pdf->getPage();
255 255
 					$pdf->setPage($pageposbefore);
256 256
 					$pdf->setTopMargin($this->marge_haute);
257
-					$pdf->setPageOrientation('', 1, 0);	// The only function to edit the bottom margin of current page to set it.
257
+					$pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
258 258
 
259 259
 					// We suppose that a too long description is moved completely on next page
260 260
 					if ($pageposafter > $pageposbefore) {
261 261
 						$pdf->setPage($pageposafter); $curY = $tab_top_newpage;
262 262
 					}
263 263
 
264
-					$pdf->SetFont('','', $default_font_size - 3);
264
+					$pdf->SetFont('', '', $default_font_size - 3);
265 265
 
266 266
 					// Check boxes
267
-					$pdf->SetDrawColor(120,120,120);
268
-					$pdf->Rect(10+3, $curY, 3, 3);
269
-					$pdf->Rect(20+3, $curY, 3, 3);
267
+					$pdf->SetDrawColor(120, 120, 120);
268
+					$pdf->Rect(10 + 3, $curY, 3, 3);
269
+					$pdf->Rect(20 + 3, $curY, 3, 3);
270 270
 					
271 271
 					//Insertion de la reference du produit
272 272
 					$pdf->SetXY(30, $curY);
273
-					$pdf->SetFont('','B', $default_font_size - 3);
273
+					$pdf->SetFont('', 'B', $default_font_size - 3);
274 274
 					$pdf->MultiCell(24, 3, $outputlangs->convToOutputCharset($object->lines[$i]->ref), 0, 'L', 0);
275 275
 
276 276
 					$pdf->SetXY(140, $curY);
@@ -280,16 +280,16 @@  discard block
 block discarded – undo
280 280
 					$pdf->MultiCell(30, 3, $object->lines[$i]->qty_shipped, 0, 'C', 0);
281 281
 
282 282
 					// Add line
283
-					if (! empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblignes - 1))
283
+					if (!empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblignes - 1))
284 284
 					{
285 285
 						$pdf->setPage($pageposafter);
286
-						$pdf->SetLineStyle(array('dash'=>'1,1','color'=>array(80,80,80)));
286
+						$pdf->SetLineStyle(array('dash'=>'1,1', 'color'=>array(80, 80, 80)));
287 287
 						//$pdf->SetDrawColor(190,190,200);
288
-						$pdf->line($this->marge_gauche, $nexY+1, $this->page_largeur - $this->marge_droite, $nexY+1);
288
+						$pdf->line($this->marge_gauche, $nexY + 1, $this->page_largeur - $this->marge_droite, $nexY + 1);
289 289
 						$pdf->SetLineStyle(array('dash'=>0));
290 290
 					}
291 291
 
292
-					$nexY+=2;    // Passe espace entre les lignes
292
+					$nexY += 2; // Passe espace entre les lignes
293 293
 
294 294
 					// Detect if some page were added automatically and output _tableau for past pages
295 295
 					while ($pagenb < $pageposafter)
@@ -303,12 +303,12 @@  discard block
 block discarded – undo
303 303
 						{
304 304
 							$this->_tableau($pdf, $tab_top_newpage - 1, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
305 305
 						}
306
-						$this->_pagefoot($pdf,$object,$outputlangs,1);
306
+						$this->_pagefoot($pdf, $object, $outputlangs, 1);
307 307
 						$pagenb++;
308 308
 						$pdf->setPage($pagenb);
309
-						$pdf->setPageOrientation('', 1, 0);	// The only function to edit the bottom margin of current page to set it.
309
+						$pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
310 310
 					}
311
-					if (isset($object->lines[$i+1]->pagebreak) && $object->lines[$i+1]->pagebreak)
311
+					if (isset($object->lines[$i + 1]->pagebreak) && $object->lines[$i + 1]->pagebreak)
312 312
 					{
313 313
 						if ($pagenb == 1)
314 314
 						{
@@ -318,7 +318,7 @@  discard block
 block discarded – undo
318 318
 						{
319 319
 							$this->_tableau($pdf, $tab_top_newpage - 1, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
320 320
 						}
321
-						$this->_pagefoot($pdf,$object,$outputlangs,1);
321
+						$this->_pagefoot($pdf, $object, $outputlangs, 1);
322 322
 						// New page
323 323
 						$pdf->AddPage();
324 324
 						$pagenb++;
@@ -329,34 +329,34 @@  discard block
 block discarded – undo
329 329
 				if ($pagenb == 1)
330 330
 				{
331 331
 					$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0);
332
-					$bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
332
+					$bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
333 333
 				}
334 334
 				else
335 335
 				{
336 336
 					$this->_tableau($pdf, $tab_top_newpage - 1, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0);
337
-					$bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
337
+					$bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
338 338
 				}
339 339
 
340 340
 				// Pied de page
341 341
 				$this->_pagefoot($pdf, $object, $outputlangs);
342
-				if (method_exists($pdf,'AliasNbPages')) $pdf->AliasNbPages();
342
+				if (method_exists($pdf, 'AliasNbPages')) $pdf->AliasNbPages();
343 343
 
344 344
 				$pdf->Close();
345 345
 
346
-				$pdf->Output($file,'F');
346
+				$pdf->Output($file, 'F');
347 347
 
348 348
 				// Add pdfgeneration hook
349
-				if (! is_object($hookmanager))
349
+				if (!is_object($hookmanager))
350 350
 				{
351 351
 					include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
352
-					$hookmanager=new HookManager($this->db);
352
+					$hookmanager = new HookManager($this->db);
353 353
 				}
354 354
 				$hookmanager->initHooks(array('pdfgeneration'));
355
-				$parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs);
355
+				$parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs);
356 356
 				global $action;
357
-				$reshook=$hookmanager->executeHooks('afterPDFCreation',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
357
+				$reshook = $hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
358 358
 
359
-                if (! empty($conf->global->MAIN_UMASK))
359
+                if (!empty($conf->global->MAIN_UMASK))
360 360
                     @chmod($file, octdec($conf->global->MAIN_UMASK));
361 361
 
362 362
 				$this->result = array('fullpath'=>$file);
@@ -365,13 +365,13 @@  discard block
 block discarded – undo
365 365
 			}
366 366
 			else
367 367
 			{
368
-				$this->error=$outputlangs->transnoentities("ErrorCanNotCreateDir",$dir);
368
+				$this->error = $outputlangs->transnoentities("ErrorCanNotCreateDir", $dir);
369 369
 				return 0;
370 370
 			}
371 371
 		}
372 372
 		else
373 373
 		{
374
-			$this->error=$outputlangs->transnoentities("ErrorConstantNotDefined","EXP_OUTPUTDIR");
374
+			$this->error = $outputlangs->transnoentities("ErrorConstantNotDefined", "EXP_OUTPUTDIR");
375 375
 			return 0;
376 376
 		}
377 377
 	}
@@ -388,7 +388,7 @@  discard block
 block discarded – undo
388 388
 	 *   @param		int			$hidebottom		Hide bottom bar of array
389 389
 	 *   @return	void
390 390
 	 */
391
-	function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop=0, $hidebottom=0)
391
+	function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0)
392 392
 	{
393 393
 		global $langs;
394 394
 		$default_font_size = pdf_getPDFFontSize($outputlangs);
@@ -398,21 +398,21 @@  discard block
 block discarded – undo
398 398
 
399 399
 		if (empty($hidetop))
400 400
 		{
401
-			$pdf->SetFont('','B', $default_font_size - 2);
402
-			$pdf->SetXY(10,$tab_top);
403
-			$pdf->MultiCell(10,5,"LS",0,'C',1);
401
+			$pdf->SetFont('', 'B', $default_font_size - 2);
402
+			$pdf->SetXY(10, $tab_top);
403
+			$pdf->MultiCell(10, 5, "LS", 0, 'C', 1);
404 404
 			$pdf->line(20, $tab_top, 20, $tab_top + $tab_height);
405
-			$pdf->SetXY(20,$tab_top);
406
-			$pdf->MultiCell(10,5,"LR",0,'C',1);
405
+			$pdf->SetXY(20, $tab_top);
406
+			$pdf->MultiCell(10, 5, "LR", 0, 'C', 1);
407 407
 			$pdf->line(30, $tab_top, 30, $tab_top + $tab_height);
408
-			$pdf->SetXY(30,$tab_top);
409
-			$pdf->MultiCell(20,5,$outputlangs->transnoentities("Ref"),0,'C',1);
410
-			$pdf->SetXY(50,$tab_top);
411
-			$pdf->MultiCell(90,5,$outputlangs->transnoentities("Description"),0,'L',1);
412
-			$pdf->SetXY(140,$tab_top);
413
-			$pdf->MultiCell(30,5,$outputlangs->transnoentities("QtyOrdered"),0,'C',1);
414
-			$pdf->SetXY(170,$tab_top);
415
-			$pdf->MultiCell(30,5,$outputlangs->transnoentities("QtyToShip"),0,'C',1);
408
+			$pdf->SetXY(30, $tab_top);
409
+			$pdf->MultiCell(20, 5, $outputlangs->transnoentities("Ref"), 0, 'C', 1);
410
+			$pdf->SetXY(50, $tab_top);
411
+			$pdf->MultiCell(90, 5, $outputlangs->transnoentities("Description"), 0, 'L', 1);
412
+			$pdf->SetXY(140, $tab_top);
413
+			$pdf->MultiCell(30, 5, $outputlangs->transnoentities("QtyOrdered"), 0, 'C', 1);
414
+			$pdf->SetXY(170, $tab_top);
415
+			$pdf->MultiCell(30, 5, $outputlangs->transnoentities("QtyToShip"), 0, 'C', 1);
416 416
 		}
417 417
 		$pdf->Rect(10, $tab_top, 190, $tab_height);
418 418
 	}
@@ -426,15 +426,15 @@  discard block
 block discarded – undo
426 426
 	 *      @param	int			$hidefreetext		1=Hide free text
427 427
 	 *      @return	void
428 428
 	 */
429
-	function _pagefoot(&$pdf, $object, $outputlangs,$hidefreetext=0)
429
+	function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0)
430 430
 	{
431 431
 		$default_font_size = pdf_getPDFFontSize($outputlangs);
432
-		$pdf->SetFont('','', $default_font_size - 2);
432
+		$pdf->SetFont('', '', $default_font_size - 2);
433 433
 		$pdf->SetY(-23);
434 434
 		$pdf->MultiCell(100, 3, $outputlangs->transnoentities("GoodStatusDeclaration"), 0, 'L');
435 435
 		$pdf->SetY(-13);
436 436
 		$pdf->MultiCell(100, 3, $outputlangs->transnoentities("ToAndDate"), 0, 'C');
437
-		$pdf->SetXY(120,-23);
437
+		$pdf->SetXY(120, -23);
438 438
 		$pdf->MultiCell(100, 3, $outputlangs->transnoentities("NameAndSignature"), 0, 'C');
439 439
 
440 440
 		// Show page nb only on iso languages (so default Helvetica font)
@@ -457,20 +457,20 @@  discard block
 block discarded – undo
457 457
 	 */
458 458
 	function _pagehead(&$pdf, $object, $showaddress, $outputlangs)
459 459
 	{
460
-		global $conf, $langs,$hookmanager;
460
+		global $conf, $langs, $hookmanager;
461 461
 
462 462
 		$default_font_size = pdf_getPDFFontSize($outputlangs);
463 463
 
464
-		pdf_pagehead($pdf,$outputlangs,$this->page_hauteur);
464
+		pdf_pagehead($pdf, $outputlangs, $this->page_hauteur);
465 465
 
466 466
 			//Affiche le filigrane brouillon - Print Draft Watermark
467
-		if($object->statut==0 && (! empty($conf->global->SENDING_DRAFT_WATERMARK)) )
467
+		if ($object->statut == 0 && (!empty($conf->global->SENDING_DRAFT_WATERMARK)))
468 468
 		{
469
-            pdf_watermark($pdf,$outputlangs,$this->page_hauteur,$this->page_largeur,'mm',$conf->global->SENDING_DRAFT_WATERMARK);
469
+            pdf_watermark($pdf, $outputlangs, $this->page_hauteur, $this->page_largeur, 'mm', $conf->global->SENDING_DRAFT_WATERMARK);
470 470
 		}
471 471
 
472
-        $posy=$this->marge_haute;
473
-        $posx=$this->page_largeur-$this->marge_droite-100;
472
+        $posy = $this->marge_haute;
473
+        $posx = $this->page_largeur - $this->marge_droite - 100;
474 474
 
475 475
 		$Xoff = 90;
476 476
 		$Yoff = 0;
@@ -481,47 +481,47 @@  discard block
 block discarded – undo
481 481
 		$line = 2;
482 482
 
483 483
 		//*********************LOGO****************************
484
-		$pdf->SetXY(11,7);
485
-		$logo=$conf->mycompany->dir_output.'/logos/'.$this->emetteur->logo;
484
+		$pdf->SetXY(11, 7);
485
+		$logo = $conf->mycompany->dir_output.'/logos/'.$this->emetteur->logo;
486 486
 		if ($this->emetteur->logo)
487 487
 		{
488 488
 			if (is_readable($logo))
489 489
 			{
490
-			    $height=pdf_getHeightForLogo($logo);
491
-			    $pdf->Image($logo,10, 5, 0, $height);	// width=0 (auto)
490
+			    $height = pdf_getHeightForLogo($logo);
491
+			    $pdf->Image($logo, 10, 5, 0, $height); // width=0 (auto)
492 492
 			}
493 493
 			else
494 494
 			{
495
-				$pdf->SetTextColor(200,0,0);
496
-				$pdf->SetFont('','B', $default_font_size - 2);
497
-				$pdf->MultiCell(100, 3, $langs->transnoentities("ErrorLogoFileNotFound",$logo), 0, 'L');
495
+				$pdf->SetTextColor(200, 0, 0);
496
+				$pdf->SetFont('', 'B', $default_font_size - 2);
497
+				$pdf->MultiCell(100, 3, $langs->transnoentities("ErrorLogoFileNotFound", $logo), 0, 'L');
498 498
 				$pdf->MultiCell(100, 3, $langs->transnoentities("ErrorGoToModuleSetup"), 0, 'L');
499 499
 			}
500 500
 		}
501 501
 		else
502 502
 		{
503
-			$text=$this->emetteur->name;
503
+			$text = $this->emetteur->name;
504 504
 			$pdf->MultiCell(70, 3, $outputlangs->convToOutputCharset($text), 0, 'L');
505 505
 		}
506 506
 
507 507
 		//*********************Entete****************************
508 508
 		//Nom du Document
509
-		$pdf->SetXY($Xoff,7);
510
-		$pdf->SetFont('','B', $default_font_size + 2);
511
-		$pdf->SetTextColor(0,0,0);
512
-		$pdf->MultiCell(0, 3, $outputlangs->transnoentities("SendingSheet"), '', 'L');	// Bordereau expedition
509
+		$pdf->SetXY($Xoff, 7);
510
+		$pdf->SetFont('', 'B', $default_font_size + 2);
511
+		$pdf->SetTextColor(0, 0, 0);
512
+		$pdf->MultiCell(0, 3, $outputlangs->transnoentities("SendingSheet"), '', 'L'); // Bordereau expedition
513 513
 		//Num Expedition
514
-		$Yoff = $Yoff+7;
514
+		$Yoff = $Yoff + 7;
515 515
 		$Xoff = 142;
516 516
 		//$pdf->Rect($Xoff, $Yoff, 85, 8);
517
-		$pdf->SetXY($Xoff,$Yoff);
518
-		$pdf->SetFont('','', $default_font_size - 2);
519
-		$pdf->SetTextColor(0,0,0);
517
+		$pdf->SetXY($Xoff, $Yoff);
518
+		$pdf->SetFont('', '', $default_font_size - 2);
519
+		$pdf->SetTextColor(0, 0, 0);
520 520
 		$pdf->MultiCell(0, 3, $outputlangs->transnoentities("RefSending").': '.$outputlangs->convToOutputCharset($object->ref), '', 'R');
521 521
 		//$this->Code39($Xoff+43, $Yoff+1, $object->ref,$ext = true, $cks = false, $w = 0.4, $h = 4, $wide = true);
522 522
 
523
-		$origin 	= $object->origin;
524
-		$origin_id 	= $object->origin_id;
523
+		$origin = $object->origin;
524
+		$origin_id = $object->origin_id;
525 525
 
526 526
 		// Add list of linked elements
527 527
 		$posy = pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, 100, 3, 'R', $default_font_size - 1, $hookmanager);
@@ -529,72 +529,72 @@  discard block
 block discarded – undo
529 529
 		//$this->Code39($Xoff+43, $Yoff+1, $object->commande->ref,$ext = true, $cks = false, $w = 0.4, $h = 4, $wide = true);
530 530
 		//Definition Emplacement du bloc Societe
531 531
 		$Xoff = 110;
532
-		$blSocX=90;
533
-		$blSocY=24;
534
-		$blSocW=50;
535
-		$blSocX2=$blSocW+$blSocX;
532
+		$blSocX = 90;
533
+		$blSocY = 24;
534
+		$blSocW = 50;
535
+		$blSocX2 = $blSocW + $blSocX;
536 536
 
537 537
 		// Sender name
538
-		$pdf->SetTextColor(0,0,0);
539
-		$pdf->SetFont('','B', $default_font_size - 3);
540
-		$pdf->SetXY($blSocX,$blSocY+1);
538
+		$pdf->SetTextColor(0, 0, 0);
539
+		$pdf->SetFont('', 'B', $default_font_size - 3);
540
+		$pdf->SetXY($blSocX, $blSocY + 1);
541 541
 		$pdf->MultiCell(80, 3, $outputlangs->convToOutputCharset($this->emetteur->name), 0, 'L');
542
-		$pdf->SetTextColor(0,0,0);
542
+		$pdf->SetTextColor(0, 0, 0);
543 543
 
544 544
 		// Sender properties
545 545
 		$carac_emetteur = pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty);
546 546
 
547
-		$pdf->SetFont('','', $default_font_size - 3);
548
-		$pdf->SetXY($blSocX,$blSocY+4);
547
+		$pdf->SetFont('', '', $default_font_size - 3);
548
+		$pdf->SetXY($blSocX, $blSocY + 4);
549 549
 		$pdf->MultiCell(80, 2, $carac_emetteur, 0, 'L');
550 550
 
551 551
 
552 552
 		if ($object->thirdparty->code_client)
553 553
 		{
554
-			$Yoff+=3;
555
-			$posy=$Yoff;
556
-			$pdf->SetXY(100,$posy);
557
-			$pdf->SetTextColor(0,0,0);
558
-			$pdf->MultiCell(100, 3, $outputlangs->transnoentities("CustomerCode")." : " . $outputlangs->transnoentities($object->thirdparty->code_client), '', 'R');
554
+			$Yoff += 3;
555
+			$posy = $Yoff;
556
+			$pdf->SetXY(100, $posy);
557
+			$pdf->SetTextColor(0, 0, 0);
558
+			$pdf->MultiCell(100, 3, $outputlangs->transnoentities("CustomerCode")." : ".$outputlangs->transnoentities($object->thirdparty->code_client), '', 'R');
559 559
 		}
560 560
 
561 561
 		// Date Expedition
562
-		$Yoff = $Yoff+7;
563
-		$pdf->SetXY($blSocX-80,$blSocY+17);
562
+		$Yoff = $Yoff + 7;
563
+		$pdf->SetXY($blSocX - 80, $blSocY + 17);
564 564
 
565
-		$pdf->SetFont('','B', $default_font_size - 3);
566
-		$pdf->SetTextColor(0,0,0);
567
-		$pdf->MultiCell(50, 8, $outputlangs->transnoentities("DateDeliveryPlanned")." : " . dol_print_date($object->date_delivery,'day',false,$outputlangs,true), '', 'L');
565
+		$pdf->SetFont('', 'B', $default_font_size - 3);
566
+		$pdf->SetTextColor(0, 0, 0);
567
+		$pdf->MultiCell(50, 8, $outputlangs->transnoentities("DateDeliveryPlanned")." : ".dol_print_date($object->date_delivery, 'day', false, $outputlangs, true), '', 'L');
568 568
 
569
-		$pdf->SetXY($blSocX-80,$blSocY+20);
570
-		$pdf->SetFont('','B', $default_font_size - 3);
571
-		$pdf->SetTextColor(0,0,0);
572
-		$pdf->MultiCell(50, 8, $outputlangs->transnoentities("TrackingNumber")." : " . $object->tracking_number, '', 'L');
569
+		$pdf->SetXY($blSocX - 80, $blSocY + 20);
570
+		$pdf->SetFont('', 'B', $default_font_size - 3);
571
+		$pdf->SetTextColor(0, 0, 0);
572
+		$pdf->MultiCell(50, 8, $outputlangs->transnoentities("TrackingNumber")." : ".$object->tracking_number, '', 'L');
573 573
 
574 574
 		// Deliverer
575
-		$pdf->SetXY($blSocX-80,$blSocY+23);
576
-		$pdf->SetFont('','', $default_font_size - 3);
577
-		$pdf->SetTextColor(0,0,0);
575
+		$pdf->SetXY($blSocX - 80, $blSocY + 23);
576
+		$pdf->SetFont('', '', $default_font_size - 3);
577
+		$pdf->SetTextColor(0, 0, 0);
578 578
 
579
-		if (! empty($object->tracking_number))
579
+		if (!empty($object->tracking_number))
580 580
 		{
581 581
 			$object->GetUrlTrackingStatus($object->tracking_number);
582
-			if (! empty($object->tracking_url))
582
+			if (!empty($object->tracking_url))
583 583
 			{
584 584
 				if ($object->shipping_method_id > 0)
585 585
 				{
586 586
 					// Get code using getLabelFromKey
587
-					$code=$outputlangs->getLabelFromKey($this->db,$object->shipping_method_id,'c_shipment_mode','rowid','code');
587
+					$code = $outputlangs->getLabelFromKey($this->db, $object->shipping_method_id, 'c_shipment_mode', 'rowid', 'code');
588 588
 
589
-					$label='';
590
-					$label.=$outputlangs->trans("SendingMethod").": ".$outputlangs->trans("SendingMethod".strtoupper($code));
589
+					$label = '';
590
+					$label .= $outputlangs->trans("SendingMethod").": ".$outputlangs->trans("SendingMethod".strtoupper($code));
591 591
 					//var_dump($object->tracking_url != $object->tracking_number);exit;
592 592
 					if ($object->tracking_url != $object->tracking_number)
593 593
 					{
594
-						$label.=" : ";
595
-						$label.=$object->tracking_url;
594
+						$label .= " : ";
595
+						$label .= $object->tracking_url;
596 596
 					}
597
-					$pdf->SetFont('','B', $default_font_size - 3);
597
+					$pdf->SetFont('', 'B', $default_font_size - 3);
598 598
 					$pdf->writeHTMLCell(50, 8, '', '', $label, '', 'L');
599 599
 				}
600 600
 			}
@@ -607,20 +607,20 @@  discard block
 block discarded – undo
607 607
 
608 608
 		// Shipping company (My Company)
609 609
 		$Yoff = $blSocY;
610
-		$blExpX=$Xoff-20;
611
-		$blW=52;
610
+		$blExpX = $Xoff - 20;
611
+		$blW = 52;
612 612
 		$Ydef = $Yoff;
613 613
 		$pdf->Rect($blExpX, $Yoff, $blW, 26);
614 614
 
615 615
 		$object->fetch_thirdparty();
616 616
 
617 617
 		// If SHIPPING contact defined on order, we use it
618
-		$usecontact=false;
619
-		$arrayidcontact=$object->$origin->getIdContact('external','SHIPPING');
618
+		$usecontact = false;
619
+		$arrayidcontact = $object->$origin->getIdContact('external', 'SHIPPING');
620 620
 		if (count($arrayidcontact) > 0)
621 621
 		{
622
-			$usecontact=true;
623
-			$result=$object->fetch_contact($arrayidcontact[0]);
622
+			$usecontact = true;
623
+			$result = $object->fetch_contact($arrayidcontact[0]);
624 624
 		}
625 625
 
626 626
 		// Recipient name
@@ -631,30 +631,30 @@  discard block
 block discarded – undo
631 631
 			$thirdparty = $object->thirdparty;
632 632
 		}
633 633
 
634
-		$carac_client_name=pdfBuildThirdpartyName($thirdparty, $outputlangs);
634
+		$carac_client_name = pdfBuildThirdpartyName($thirdparty, $outputlangs);
635 635
 
636
-		$carac_client=pdf_build_address($outputlangs,$this->emetteur,$object->thirdparty,((!empty($object->contact))?$object->contact:null),$usecontact,'targetwithdetails',$object);
636
+		$carac_client = pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, ((!empty($object->contact)) ? $object->contact : null), $usecontact, 'targetwithdetails', $object);
637 637
 
638
-		$blDestX=$blExpX+55;
639
-		$blW=54;
640
-		$Yoff = $Ydef +1;
638
+		$blDestX = $blExpX + 55;
639
+		$blW = 54;
640
+		$Yoff = $Ydef + 1;
641 641
 
642 642
 		// Show Recipient frame
643
-		$pdf->SetFont('','B', $default_font_size - 3);
644
-		$pdf->SetXY($blDestX,$Yoff-4);
645
-		$pdf->MultiCell($blW,3, $outputlangs->transnoentities("Recipient"), 0, 'L');
646
-		$pdf->Rect($blDestX, $Yoff-1, $blW, 26);
643
+		$pdf->SetFont('', 'B', $default_font_size - 3);
644
+		$pdf->SetXY($blDestX, $Yoff - 4);
645
+		$pdf->MultiCell($blW, 3, $outputlangs->transnoentities("Recipient"), 0, 'L');
646
+		$pdf->Rect($blDestX, $Yoff - 1, $blW, 26);
647 647
 
648 648
 		// Show recipient name
649
-		$pdf->SetFont('','B', $default_font_size - 3);
650
-		$pdf->SetXY($blDestX,$Yoff);
651
-		$pdf->MultiCell($blW,3, $carac_client_name, 0, 'L');
649
+		$pdf->SetFont('', 'B', $default_font_size - 3);
650
+		$pdf->SetXY($blDestX, $Yoff);
651
+		$pdf->MultiCell($blW, 3, $carac_client_name, 0, 'L');
652 652
 
653 653
 		$posy = $pdf->getY();
654 654
 
655 655
 		// Show recipient information
656
-		$pdf->SetFont('','', $default_font_size - 3);
657
-		$pdf->SetXY($blDestX,$posy);
656
+		$pdf->SetFont('', '', $default_font_size - 3);
657
+		$pdf->SetXY($blDestX, $posy);
658 658
 		$pdf->MultiCell($widthrecbox, 4, $carac_client, 0, 'L');
659 659
 	}
660 660
 }
Please login to merge, or discard this patch.
Braces   +38 added lines, -30 removed lines patch added patch discarded remove patch
@@ -67,7 +67,10 @@  discard block
 block discarded – undo
67 67
 
68 68
 		// Recupere emmetteur
69 69
 		$this->emetteur=$mysoc;
70
-		if (! $this->emetteur->country_code) $this->emetteur->country_code=substr($langs->defaultlang,-2);    // By default if not defined
70
+		if (! $this->emetteur->country_code) {
71
+			$this->emetteur->country_code=substr($langs->defaultlang,-2);
72
+		}
73
+		// By default if not defined
71 74
 	}
72 75
 
73 76
 
@@ -88,9 +91,13 @@  discard block
 block discarded – undo
88 91
 
89 92
 		$object->fetch_thirdparty();
90 93
 
91
-		if (! is_object($outputlangs)) $outputlangs=$langs;
94
+		if (! is_object($outputlangs)) {
95
+			$outputlangs=$langs;
96
+		}
92 97
 		// For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
93
-		if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1';
98
+		if (! empty($conf->global->MAIN_USE_FPDF)) {
99
+			$outputlangs->charset_output='ISO-8859-1';
100
+		}
94 101
 
95 102
 		$outputlangs->load("main");
96 103
 		$outputlangs->load("dict");
@@ -114,20 +121,23 @@  discard block
 block discarded – undo
114 121
 			//Creation du destinataire
115 122
 			$idcontact = $object->$origin->getIdContact('external','SHIPPING');
116 123
             $this->destinataire = new Contact($this->db);
117
-			if (! empty($idcontact[0])) $this->destinataire->fetch($idcontact[0]);
124
+			if (! empty($idcontact[0])) {
125
+				$this->destinataire->fetch($idcontact[0]);
126
+			}
118 127
 
119 128
 			//Creation du livreur
120 129
 			$idcontact = $object->$origin->getIdContact('internal','LIVREUR');
121 130
 			$this->livreur = new User($this->db);
122
-			if (! empty($idcontact[0])) $this->livreur->fetch($idcontact[0]);
131
+			if (! empty($idcontact[0])) {
132
+				$this->livreur->fetch($idcontact[0]);
133
+			}
123 134
 
124 135
 			// Definition de $dir et $file
125 136
 			if ($object->specimen)
126 137
 			{
127 138
 				$dir = $conf->expedition->dir_output."/sending";
128 139
 				$file = $dir . "/SPECIMEN.pdf";
129
-			}
130
-			else
140
+			} else
131 141
 			{
132 142
 				$expref = dol_sanitizeFileName($object->ref);
133 143
 				$dir = $conf->expedition->dir_output . "/sending/" . $expref;
@@ -182,14 +192,18 @@  discard block
 block discarded – undo
182 192
 				$pagenb=0;
183 193
 				$pdf->SetDrawColor(128,128,128);
184 194
 
185
-				if (method_exists($pdf,'AliasNbPages')) $pdf->AliasNbPages();
195
+				if (method_exists($pdf,'AliasNbPages')) {
196
+					$pdf->AliasNbPages();
197
+				}
186 198
 
187 199
 				$pdf->SetTitle($outputlangs->convToOutputCharset($object->ref));
188 200
 				$pdf->SetSubject($outputlangs->transnoentities("Shipment"));
189 201
 				$pdf->SetCreator("Dolibarr ".DOL_VERSION);
190 202
 				$pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
191 203
 				$pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("Shipment"));
192
-				if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
204
+				if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) {
205
+					$pdf->SetCompression(false);
206
+				}
193 207
 
194 208
 				$pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);   // Left, Top, Right
195 209
 
@@ -220,8 +234,7 @@  discard block
 block discarded – undo
220 234
 
221 235
 					$tab_height = $tab_height - $height_note;
222 236
 					$tab_top = $nexY+6;
223
-				}
224
-				else
237
+				} else
225 238
 				{
226 239
 					$height_note=0;
227 240
 				}
@@ -298,8 +311,7 @@  discard block
 block discarded – undo
298 311
 						if ($pagenb == 1)
299 312
 						{
300 313
 							$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1);
301
-						}
302
-						else
314
+						} else
303 315
 						{
304 316
 							$this->_tableau($pdf, $tab_top_newpage - 1, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
305 317
 						}
@@ -313,8 +325,7 @@  discard block
 block discarded – undo
313 325
 						if ($pagenb == 1)
314 326
 						{
315 327
 							$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1);
316
-						}
317
-						else
328
+						} else
318 329
 						{
319 330
 							$this->_tableau($pdf, $tab_top_newpage - 1, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
320 331
 						}
@@ -330,8 +341,7 @@  discard block
 block discarded – undo
330 341
 				{
331 342
 					$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0);
332 343
 					$bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
333
-				}
334
-				else
344
+				} else
335 345
 				{
336 346
 					$this->_tableau($pdf, $tab_top_newpage - 1, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0);
337 347
 					$bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
@@ -339,7 +349,9 @@  discard block
 block discarded – undo
339 349
 
340 350
 				// Pied de page
341 351
 				$this->_pagefoot($pdf, $object, $outputlangs);
342
-				if (method_exists($pdf,'AliasNbPages')) $pdf->AliasNbPages();
352
+				if (method_exists($pdf,'AliasNbPages')) {
353
+					$pdf->AliasNbPages();
354
+				}
343 355
 
344 356
 				$pdf->Close();
345 357
 
@@ -356,20 +368,19 @@  discard block
 block discarded – undo
356 368
 				global $action;
357 369
 				$reshook=$hookmanager->executeHooks('afterPDFCreation',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
358 370
 
359
-                if (! empty($conf->global->MAIN_UMASK))
360
-                    @chmod($file, octdec($conf->global->MAIN_UMASK));
371
+                if (! empty($conf->global->MAIN_UMASK)) {
372
+                                    @chmod($file, octdec($conf->global->MAIN_UMASK));
373
+                }
361 374
 
362 375
 				$this->result = array('fullpath'=>$file);
363 376
                 
364 377
 				return 1;
365
-			}
366
-			else
378
+			} else
367 379
 			{
368 380
 				$this->error=$outputlangs->transnoentities("ErrorCanNotCreateDir",$dir);
369 381
 				return 0;
370 382
 			}
371
-		}
372
-		else
383
+		} else
373 384
 		{
374 385
 			$this->error=$outputlangs->transnoentities("ErrorConstantNotDefined","EXP_OUTPUTDIR");
375 386
 			return 0;
@@ -489,16 +500,14 @@  discard block
 block discarded – undo
489 500
 			{
490 501
 			    $height=pdf_getHeightForLogo($logo);
491 502
 			    $pdf->Image($logo,10, 5, 0, $height);	// width=0 (auto)
492
-			}
493
-			else
503
+			} else
494 504
 			{
495 505
 				$pdf->SetTextColor(200,0,0);
496 506
 				$pdf->SetFont('','B', $default_font_size - 2);
497 507
 				$pdf->MultiCell(100, 3, $langs->transnoentities("ErrorLogoFileNotFound",$logo), 0, 'L');
498 508
 				$pdf->MultiCell(100, 3, $langs->transnoentities("ErrorGoToModuleSetup"), 0, 'L');
499 509
 			}
500
-		}
501
-		else
510
+		} else
502 511
 		{
503 512
 			$text=$this->emetteur->name;
504 513
 			$pdf->MultiCell(70, 3, $outputlangs->convToOutputCharset($text), 0, 'L');
@@ -598,8 +607,7 @@  discard block
 block discarded – undo
598 607
 					$pdf->writeHTMLCell(50, 8, '', '', $label, '', 'L');
599 608
 				}
600 609
 			}
601
-		}
602
-		else
610
+		} else
603 611
 		{
604 612
 			$pdf->MultiCell(50, 8, $outputlangs->transnoentities("Deliverer")." ".$outputlangs->convToOutputCharset($this->livreur->getFullName($outputlangs)), '', 'L');
605 613
 		}
Please login to merge, or discard this patch.
htdocs/core/modules/expedition/doc/pdf_rouget.modules.php 4 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -41,7 +41,7 @@
 block discarded – undo
41 41
 	/**
42 42
 	 *	Constructor
43 43
 	 *
44
-	 *	@param	DoliDB	$db		Database handler
44
+	 *	@param	integer	$db		Database handler
45 45
 	 */
46 46
 	function __construct($db=0)
47 47
 	{
Please login to merge, or discard this patch.
Indentation   +109 added lines, -109 removed lines patch added patch discarded remove patch
@@ -87,17 +87,17 @@  discard block
 block discarded – undo
87 87
 
88 88
 		if ($this->page_largeur < 210) // To work with US executive format
89 89
 		{
90
-		    $this->posxweightvol-=20;
91
-		    $this->posxpicture-=20;
92
-		    $this->posxqtyordered-=20;
93
-		    $this->posxqtytoship-=20;
90
+			$this->posxweightvol-=20;
91
+			$this->posxpicture-=20;
92
+			$this->posxqtyordered-=20;
93
+			$this->posxqtytoship-=20;
94 94
 		}
95 95
 
96 96
 		if (! empty($conf->global->SHIPPING_PDF_HIDE_ORDERED))
97 97
 		{
98
-		    $this->posxweightvol += ($this->posxqtytoship - $this->posxqtyordered);
99
-		    $this->posxpicture += ($this->posxqtytoship - $this->posxqtyordered);
100
-		    $this->posxqtyordered = $this->posxqtytoship;
98
+			$this->posxweightvol += ($this->posxqtytoship - $this->posxqtyordered);
99
+			$this->posxpicture += ($this->posxqtytoship - $this->posxqtyordered);
100
+			$this->posxqtyordered = $this->posxqtytoship;
101 101
 		}
102 102
 	}
103 103
 
@@ -106,11 +106,11 @@  discard block
 block discarded – undo
106 106
 	 *
107 107
 	 *	@param		Object		$object			Object expedition to generate (or id if old method)
108 108
 	 *	@param		Translate	$outputlangs		Lang output object
109
-     *  @param		string		$srctemplatepath	Full path of source filename for generator using a template file
110
-     *  @param		int			$hidedetails		Do not show line details
111
-     *  @param		int			$hidedesc			Do not show desc
112
-     *  @param		int			$hideref			Do not show ref
113
-     *  @return     int         	    			1=OK, 0=KO
109
+	 *  @param		string		$srctemplatepath	Full path of source filename for generator using a template file
110
+	 *  @param		int			$hidedetails		Do not show line details
111
+	 *  @param		int			$hidedesc			Do not show desc
112
+	 *  @param		int			$hideref			Do not show ref
113
+	 *  @return     int         	    			1=OK, 0=KO
114 114
 	 */
115 115
 	function write_file($object,$outputlangs,$srctemplatepath='',$hidedetails=0,$hidedesc=0,$hideref=0)
116 116
 	{
@@ -129,20 +129,20 @@  discard block
 block discarded – undo
129 129
 		$outputlangs->load("products");
130 130
 		$outputlangs->load("propal");
131 131
 		$outputlangs->load("deliveries");
132
-        $outputlangs->load("sendings");
132
+		$outputlangs->load("sendings");
133 133
 		$outputlangs->load("productbatch");
134 134
 
135 135
 		$nblignes = count($object->lines);
136 136
 
137
-        // Loop on each lines to detect if there is at least one image to show
138
-        $realpatharray=array();
139
-        if (! empty($conf->global->MAIN_GENERATE_SHIPMENT_WITH_PICTURE))
140
-        {
141
-            $objphoto = new Product($this->db);
137
+		// Loop on each lines to detect if there is at least one image to show
138
+		$realpatharray=array();
139
+		if (! empty($conf->global->MAIN_GENERATE_SHIPMENT_WITH_PICTURE))
140
+		{
141
+			$objphoto = new Product($this->db);
142 142
 
143
-            for ($i = 0 ; $i < $nblignes ; $i++)
144
-            {
145
-                if (empty($object->lines[$i]->fk_product)) continue;
143
+			for ($i = 0 ; $i < $nblignes ; $i++)
144
+			{
145
+				if (empty($object->lines[$i]->fk_product)) continue;
146 146
 
147 147
 				$objphoto = new Product($this->db);
148 148
 				$objphoto->fetch($object->lines[$i]->fk_product);
@@ -152,33 +152,33 @@  discard block
 block discarded – undo
152 152
 
153 153
 				$realpath='';
154 154
 
155
-                foreach ($objphoto->liste_photos($dir,1) as $key => $obj)
156
-                        {
157
-                            if (empty($conf->global->CAT_HIGH_QUALITY_IMAGES))		// If CAT_HIGH_QUALITY_IMAGES not defined, we use thumb if defined and then original photo
158
-                            {
159
-                                if ($obj['photo_vignette'])
160
-                                {
161
-                                    $filename= $obj['photo_vignette'];
162
-                                }
163
-                                else
164
-                                {
165
-                                    $filename=$obj['photo'];
166
-                                }
167
-                            }
168
-                            else
169
-                            {
170
-                                $filename=$obj['photo'];
171
-                            }
172
-
173
-                            $realpath = $dir.$filename;
174
-                            break;
175
-                }
176
-
177
-                if ($realpath) $realpatharray[$i]=$realpath;
178
-            }
179
-        }
180
-
181
-        if (count($realpatharray) == 0) $this->posxpicture=$this->posxweightvol;
155
+				foreach ($objphoto->liste_photos($dir,1) as $key => $obj)
156
+						{
157
+							if (empty($conf->global->CAT_HIGH_QUALITY_IMAGES))		// If CAT_HIGH_QUALITY_IMAGES not defined, we use thumb if defined and then original photo
158
+							{
159
+								if ($obj['photo_vignette'])
160
+								{
161
+									$filename= $obj['photo_vignette'];
162
+								}
163
+								else
164
+								{
165
+									$filename=$obj['photo'];
166
+								}
167
+							}
168
+							else
169
+							{
170
+								$filename=$obj['photo'];
171
+							}
172
+
173
+							$realpath = $dir.$filename;
174
+							break;
175
+				}
176
+
177
+				if ($realpath) $realpatharray[$i]=$realpath;
178
+			}
179
+		}
180
+
181
+		if (count($realpatharray) == 0) $this->posxpicture=$this->posxweightvol;
182 182
 
183 183
 		if ($conf->expedition->dir_output)
184 184
 		{
@@ -223,22 +223,22 @@  discard block
 block discarded – undo
223 223
 				$pdf=pdf_getInstance($this->format);
224 224
 				$default_font_size = pdf_getPDFFontSize($outputlangs);
225 225
 				$heightforinfotot = 8;	// Height reserved to output the info and total part
226
-		        $heightforfreetext= (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT)?$conf->global->MAIN_PDF_FREETEXT_HEIGHT:5);	// Height reserved to output the free text on last page
227
-	            $heightforfooter = $this->marge_basse + 8;	// Height reserved to output the footer (value include bottom margin)
228
-                $pdf->SetAutoPageBreak(1,0);
229
-
230
-                if (class_exists('TCPDF'))
231
-                {
232
-                    $pdf->setPrintHeader(false);
233
-                    $pdf->setPrintFooter(false);
234
-                }
235
-                $pdf->SetFont(pdf_getPDFFont($outputlangs));
236
-                // Set path to the background PDF File
237
-                if (empty($conf->global->MAIN_DISABLE_FPDI) && ! empty($conf->global->MAIN_ADD_PDF_BACKGROUND))
238
-                {
239
-                    $pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND);
240
-                    $tplidx = $pdf->importPage(1);
241
-                }
226
+				$heightforfreetext= (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT)?$conf->global->MAIN_PDF_FREETEXT_HEIGHT:5);	// Height reserved to output the free text on last page
227
+				$heightforfooter = $this->marge_basse + 8;	// Height reserved to output the footer (value include bottom margin)
228
+				$pdf->SetAutoPageBreak(1,0);
229
+
230
+				if (class_exists('TCPDF'))
231
+				{
232
+					$pdf->setPrintHeader(false);
233
+					$pdf->setPrintFooter(false);
234
+				}
235
+				$pdf->SetFont(pdf_getPDFFont($outputlangs));
236
+				// Set path to the background PDF File
237
+				if (empty($conf->global->MAIN_DISABLE_FPDI) && ! empty($conf->global->MAIN_ADD_PDF_BACKGROUND))
238
+				{
239
+					$pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND);
240
+					$tplidx = $pdf->importPage(1);
241
+				}
242 242
 
243 243
 				$pdf->Open();
244 244
 				$pagenb=0;
@@ -458,12 +458,12 @@  discard block
 block discarded – undo
458 458
 					$weighttxt='';
459 459
 					if ($object->lines[$i]->fk_product_type == 0 && $object->lines[$i]->weight)
460 460
 					{
461
-					    $weighttxt=round($object->lines[$i]->weight * $object->lines[$i]->qty_shipped, 5).' '.measuring_units_string($object->lines[$i]->weight_units,"weight");
461
+						$weighttxt=round($object->lines[$i]->weight * $object->lines[$i]->qty_shipped, 5).' '.measuring_units_string($object->lines[$i]->weight_units,"weight");
462 462
 					}
463 463
 					$voltxt='';
464 464
 					if ($object->lines[$i]->fk_product_type == 0 && $object->lines[$i]->volume)
465 465
 					{
466
-					    $voltxt=round($object->lines[$i]->volume * $object->lines[$i]->qty_shipped, 5).' '.measuring_units_string($object->lines[$i]->volume_units?$object->lines[$i]->volume_units:0,"volume");
466
+						$voltxt=round($object->lines[$i]->volume * $object->lines[$i]->qty_shipped, 5).' '.measuring_units_string($object->lines[$i]->volume_units?$object->lines[$i]->volume_units:0,"volume");
467 467
 					}
468 468
 
469 469
 					$pdf->writeHTMLCell($this->posxqtyordered - $this->posxweightvol + 2, 3, $this->posxweightvol - 1, $curY, $weighttxt.(($weighttxt && $voltxt)?'<br>':'').$voltxt, 0, 0, false, true, 'C');
@@ -598,9 +598,9 @@  discard block
 block discarded – undo
598 598
 	{
599 599
 		global $conf,$mysoc;
600 600
 
601
-        $sign=1;
601
+		$sign=1;
602 602
 
603
-        $default_font_size = pdf_getPDFFontSize($outputlangs);
603
+		$default_font_size = pdf_getPDFFontSize($outputlangs);
604 604
 
605 605
 		$tab2_top = $posy;
606 606
 		$tab2_hl = 4;
@@ -630,8 +630,8 @@  discard block
 block discarded – undo
630 630
 		// Set trueVolume and volume_units not currently stored into database
631 631
 		if ($object->trueWidth && $object->trueHeight && $object->trueDepth)
632 632
 		{
633
-		    $object->trueVolume=price(($object->trueWidth * $object->trueHeight * $object->trueDepth), 0, $outputlangs, 0, 0);
634
-		    $object->volume_units=$object->size_units * 3;
633
+			$object->trueVolume=price(($object->trueWidth * $object->trueHeight * $object->trueDepth), 0, $outputlangs, 0, 0);
634
+			$object->volume_units=$object->size_units * 3;
635 635
 		}
636 636
 
637 637
 		if ($totalWeight!='') $totalWeighttoshow=showDimensionInBestUnit($totalWeight, 0, "weight", $outputlangs);
@@ -639,43 +639,43 @@  discard block
 block discarded – undo
639 639
 		if ($object->trueWeight) $totalWeighttoshow=showDimensionInBestUnit($object->trueWeight, $object->weight_units, "weight", $outputlangs);
640 640
 		if ($object->trueVolume) $totalVolumetoshow=showDimensionInBestUnit($object->trueVolume, $object->volume_units, "volume", $outputlangs);
641 641
 
642
-    	$pdf->SetFillColor(255,255,255);
643
-    	$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
644
-    	$pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("Total"), 0, 'L', 1);
642
+		$pdf->SetFillColor(255,255,255);
643
+		$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
644
+		$pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("Total"), 0, 'L', 1);
645 645
 
646
-        if (empty($conf->global->SHIPPING_PDF_HIDE_ORDERED))
647
-        {
648
-            $pdf->SetXY($this->posxqtyordered, $tab2_top + $tab2_hl * $index);
649
-        	$pdf->MultiCell($this->posxqtytoship - $this->posxqtyordered, $tab2_hl, $totalOrdered, 0, 'C', 1);
650
-        }
646
+		if (empty($conf->global->SHIPPING_PDF_HIDE_ORDERED))
647
+		{
648
+			$pdf->SetXY($this->posxqtyordered, $tab2_top + $tab2_hl * $index);
649
+			$pdf->MultiCell($this->posxqtytoship - $this->posxqtyordered, $tab2_hl, $totalOrdered, 0, 'C', 1);
650
+		}
651 651
 
652
-    	$pdf->SetXY($this->posxqtytoship, $tab2_top + $tab2_hl * $index);
653
-    	$pdf->MultiCell($this->posxpuht - $this->posxqtytoship, $tab2_hl, $totalToShip, 0, 'C', 1);
652
+		$pdf->SetXY($this->posxqtytoship, $tab2_top + $tab2_hl * $index);
653
+		$pdf->MultiCell($this->posxpuht - $this->posxqtytoship, $tab2_hl, $totalToShip, 0, 'C', 1);
654 654
 
655 655
 		if(!empty($conf->global->MAIN_PDF_SHIPPING_DISPLAY_AMOUNT_HT)) {
656 656
 
657
-	    	$pdf->SetXY($this->posxpuht, $tab2_top + $tab2_hl * $index);
658
-	    	$pdf->MultiCell($this->posxtotalht - $this->posxpuht, $tab2_hl, '', 0, 'C', 1);
657
+			$pdf->SetXY($this->posxpuht, $tab2_top + $tab2_hl * $index);
658
+			$pdf->MultiCell($this->posxtotalht - $this->posxpuht, $tab2_hl, '', 0, 'C', 1);
659 659
 
660
-	    	$pdf->SetXY($this->posxtotalht, $tab2_top + $tab2_hl * $index);
661
-	    	$pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->posxtotalht, $tab2_hl, price($object->total_ht, 0, $outputlangs), 0, 'C', 1);
660
+			$pdf->SetXY($this->posxtotalht, $tab2_top + $tab2_hl * $index);
661
+			$pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->posxtotalht, $tab2_hl, price($object->total_ht, 0, $outputlangs), 0, 'C', 1);
662 662
 
663 663
 		}
664 664
 
665 665
 		// Total Weight
666 666
 		if ($totalWeighttoshow)
667 667
 		{
668
-    		$pdf->SetXY($this->posxweightvol, $tab2_top + $tab2_hl * $index);
669
-    		$pdf->MultiCell(($this->posxqtyordered - $this->posxweightvol), $tab2_hl, $totalWeighttoshow, 0, 'C', 1);
668
+			$pdf->SetXY($this->posxweightvol, $tab2_top + $tab2_hl * $index);
669
+			$pdf->MultiCell(($this->posxqtyordered - $this->posxweightvol), $tab2_hl, $totalWeighttoshow, 0, 'C', 1);
670 670
 
671
-    		$index++;
671
+			$index++;
672 672
 		}
673 673
 		if ($totalVolumetoshow)
674 674
 		{
675
-    		$pdf->SetXY($this->posxweightvol, $tab2_top + $tab2_hl * $index);
676
-    		$pdf->MultiCell(($this->posxqtyordered - $this->posxweightvol), $tab2_hl, $totalVolumetoshow, 0, 'C', 1);
675
+			$pdf->SetXY($this->posxweightvol, $tab2_top + $tab2_hl * $index);
676
+			$pdf->MultiCell(($this->posxqtyordered - $this->posxweightvol), $tab2_hl, $totalVolumetoshow, 0, 'C', 1);
677 677
 
678
-		    $index++;
678
+			$index++;
679 679
 		}
680 680
 		if (! $totalWeighttoshow && ! $totalVolumetoshow) $index++;
681 681
 
@@ -731,15 +731,15 @@  discard block
 block discarded – undo
731 731
 			$pdf->MultiCell(($this->posxqtyordered - $this->posxweightvol), 2, $outputlangs->transnoentities("WeightVolShort"),'','C');
732 732
 		}
733 733
 
734
-        if (empty($conf->global->SHIPPING_PDF_HIDE_ORDERED))
735
-        {
736
-            $pdf->line($this->posxqtyordered-1, $tab_top, $this->posxqtyordered-1, $tab_top + $tab_height);
737
-    		if (empty($hidetop))
738
-    		{
739
-    			$pdf->SetXY($this->posxqtyordered-1, $tab_top+1);
740
-    			$pdf->MultiCell(($this->posxqtytoship - $this->posxqtyordered), 2, $outputlangs->transnoentities("QtyOrdered"),'','C');
741
-    		}
742
-        }
734
+		if (empty($conf->global->SHIPPING_PDF_HIDE_ORDERED))
735
+		{
736
+			$pdf->line($this->posxqtyordered-1, $tab_top, $this->posxqtyordered-1, $tab_top + $tab_height);
737
+			if (empty($hidetop))
738
+			{
739
+				$pdf->SetXY($this->posxqtyordered-1, $tab_top+1);
740
+				$pdf->MultiCell(($this->posxqtytoship - $this->posxqtyordered), 2, $outputlangs->transnoentities("QtyOrdered"),'','C');
741
+			}
742
+		}
743 743
 
744 744
 		$pdf->line($this->posxqtytoship-1, $tab_top, $this->posxqtytoship-1, $tab_top + $tab_height);
745 745
 		if (empty($hidetop))
@@ -790,7 +790,7 @@  discard block
 block discarded – undo
790 790
 		// Show Draft Watermark
791 791
 		if($object->statut==0 && (! empty($conf->global->SHIPPING_DRAFT_WATERMARK)) )
792 792
 		{
793
-            		pdf_watermark($pdf,$outputlangs,$this->page_hauteur,$this->page_largeur,'mm',$conf->global->SHIPPING_DRAFT_WATERMARK);
793
+					pdf_watermark($pdf,$outputlangs,$this->page_hauteur,$this->page_largeur,'mm',$conf->global->SHIPPING_DRAFT_WATERMARK);
794 794
 		}
795 795
 
796 796
 		//Prepare la suite
@@ -810,8 +810,8 @@  discard block
 block discarded – undo
810 810
 		{
811 811
 			if (is_readable($logo))
812 812
 			{
813
-			    $height=pdf_getHeightForLogo($logo);
814
-			    $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);	// width=0 (auto)
813
+				$height=pdf_getHeightForLogo($logo);
814
+				$pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);	// width=0 (auto)
815 815
 			}
816 816
 			else
817 817
 			{
@@ -873,10 +873,10 @@  discard block
 block discarded – undo
873 873
 		// Date planned delivery
874 874
 		if (! empty($object->date_delivery))
875 875
 		{
876
-    			$posy+=4;
877
-    			$pdf->SetXY($posx,$posy);
878
-    			$pdf->SetTextColor(0,0,60);
879
-    			$pdf->MultiCell($w, 4, $outputlangs->transnoentities("DateDeliveryPlanned")." : ".dol_print_date($object->date_delivery,"day",false,$outputlangs,true), '', 'R');
876
+				$posy+=4;
877
+				$pdf->SetXY($posx,$posy);
878
+				$pdf->SetTextColor(0,0,60);
879
+				$pdf->MultiCell($w, 4, $outputlangs->transnoentities("DateDeliveryPlanned")." : ".dol_print_date($object->date_delivery,"day",false,$outputlangs,true), '', 'R');
880 880
 		}
881 881
 
882 882
 		if (! empty($object->thirdparty->code_client))
@@ -895,7 +895,7 @@  discard block
 block discarded – undo
895 895
 		$origin 	= $object->origin;
896 896
 		$origin_id 	= $object->origin_id;
897 897
 
898
-	    // TODO move to external function
898
+		// TODO move to external function
899 899
 		if (! empty($conf->$origin->enabled))     // commonly $origin='commande'
900 900
 		{
901 901
 			$outputlangs->load('orders');
@@ -905,7 +905,7 @@  discard block
 block discarded – undo
905 905
 			$result=$linkedobject->fetch($origin_id);
906 906
 			if ($result >= 0)
907 907
 			{
908
-			    //$linkedobject->fetchObjectLinked()   Get all linked object to the $linkedobject (commonly order) into $linkedobject->linkedObjects
908
+				//$linkedobject->fetchObjectLinked()   Get all linked object to the $linkedobject (commonly order) into $linkedobject->linkedObjects
909 909
 
910 910
 				$pdf->SetFont('','', $default_font_size - 2);
911 911
 				$text=$linkedobject->ref;
@@ -1018,7 +1018,7 @@  discard block
 block discarded – undo
1018 1018
 
1019 1019
 	/**
1020 1020
 	 *   	Show footer of page. Need this->emetteur object
1021
-     *
1021
+	 *
1022 1022
 	 *   	@param	PDF			$pdf     			PDF
1023 1023
 	 * 		@param	Object		$object				Object to show
1024 1024
 	 *      @param	Translate	$outputlangs		Object lang for output
Please login to merge, or discard this patch.
Spacing   +314 added lines, -314 removed lines patch added patch discarded remove patch
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
  */
36 36
 class pdf_rouget extends ModelePdfExpedition
37 37
 {
38
-	var $emetteur;	// Objet societe qui emet
38
+	var $emetteur; // Objet societe qui emet
39 39
 
40 40
 
41 41
 	/**
@@ -43,57 +43,57 @@  discard block
 block discarded – undo
43 43
 	 *
44 44
 	 *	@param	DoliDB	$db		Database handler
45 45
 	 */
46
-	function __construct($db=0)
46
+	function __construct($db = 0)
47 47
 	{
48
-		global $conf,$langs,$mysoc;
48
+		global $conf, $langs, $mysoc;
49 49
 
50 50
 		$this->db = $db;
51 51
 		$this->name = "rouget";
52 52
 		$this->description = $langs->trans("DocumentModelStandardPDF");
53 53
 
54 54
 		$this->type = 'pdf';
55
-		$formatarray=pdf_getFormat();
55
+		$formatarray = pdf_getFormat();
56 56
 		$this->page_largeur = $formatarray['width'];
57 57
 		$this->page_hauteur = $formatarray['height'];
58
-		$this->format = array($this->page_largeur,$this->page_hauteur);
59
-		$this->marge_gauche=isset($conf->global->MAIN_PDF_MARGIN_LEFT)?$conf->global->MAIN_PDF_MARGIN_LEFT:10;
60
-		$this->marge_droite=isset($conf->global->MAIN_PDF_MARGIN_RIGHT)?$conf->global->MAIN_PDF_MARGIN_RIGHT:10;
61
-		$this->marge_haute =isset($conf->global->MAIN_PDF_MARGIN_TOP)?$conf->global->MAIN_PDF_MARGIN_TOP:10;
62
-		$this->marge_basse =isset($conf->global->MAIN_PDF_MARGIN_BOTTOM)?$conf->global->MAIN_PDF_MARGIN_BOTTOM:10;
58
+		$this->format = array($this->page_largeur, $this->page_hauteur);
59
+		$this->marge_gauche = isset($conf->global->MAIN_PDF_MARGIN_LEFT) ? $conf->global->MAIN_PDF_MARGIN_LEFT : 10;
60
+		$this->marge_droite = isset($conf->global->MAIN_PDF_MARGIN_RIGHT) ? $conf->global->MAIN_PDF_MARGIN_RIGHT : 10;
61
+		$this->marge_haute = isset($conf->global->MAIN_PDF_MARGIN_TOP) ? $conf->global->MAIN_PDF_MARGIN_TOP : 10;
62
+		$this->marge_basse = isset($conf->global->MAIN_PDF_MARGIN_BOTTOM) ? $conf->global->MAIN_PDF_MARGIN_BOTTOM : 10;
63 63
 
64 64
 		$this->option_logo = 1;
65 65
 
66 66
 		// Get source company
67
-		$this->emetteur=$mysoc;
68
-		if (! $this->emetteur->country_code) $this->emetteur->country_code=substr($langs->defaultlang,-2);    // By default if not defined
67
+		$this->emetteur = $mysoc;
68
+		if (!$this->emetteur->country_code) $this->emetteur->country_code = substr($langs->defaultlang, -2); // By default if not defined
69 69
 
70 70
 		// Define position of columns
71
-		$this->posxdesc=$this->marge_gauche+1;
72
-		$this->posxweightvol=$this->page_largeur - $this->marge_droite - 78;
73
-		$this->posxqtyordered=$this->page_largeur - $this->marge_droite - 56;
74
-		$this->posxqtytoship=$this->page_largeur - $this->marge_droite - 28;
75
-		$this->posxpuht=$this->page_largeur - $this->marge_droite;
71
+		$this->posxdesc = $this->marge_gauche + 1;
72
+		$this->posxweightvol = $this->page_largeur - $this->marge_droite - 78;
73
+		$this->posxqtyordered = $this->page_largeur - $this->marge_droite - 56;
74
+		$this->posxqtytoship = $this->page_largeur - $this->marge_droite - 28;
75
+		$this->posxpuht = $this->page_largeur - $this->marge_droite;
76 76
 
77 77
 		if (!empty($conf->global->MAIN_PDF_SHIPPING_DISPLAY_AMOUNT_HT)) {
78 78
 
79
-			$this->posxweightvol=$this->page_largeur - $this->marge_droite - 118;
80
-			$this->posxqtyordered=$this->page_largeur - $this->marge_droite - 96;
81
-			$this->posxqtytoship=$this->page_largeur - $this->marge_droite - 68;
82
-			$this->posxpuht=$this->page_largeur - $this->marge_droite - 40;
83
-			$this->posxtotalht=$this->page_largeur - $this->marge_droite - 20;
79
+			$this->posxweightvol = $this->page_largeur - $this->marge_droite - 118;
80
+			$this->posxqtyordered = $this->page_largeur - $this->marge_droite - 96;
81
+			$this->posxqtytoship = $this->page_largeur - $this->marge_droite - 68;
82
+			$this->posxpuht = $this->page_largeur - $this->marge_droite - 40;
83
+			$this->posxtotalht = $this->page_largeur - $this->marge_droite - 20;
84 84
 		}
85 85
 
86
-		$this->posxpicture=$this->posxweightvol - (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH)?20:$conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH);	// width of images
86
+		$this->posxpicture = $this->posxweightvol - (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH) ? 20 : $conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH); // width of images
87 87
 
88 88
 		if ($this->page_largeur < 210) // To work with US executive format
89 89
 		{
90
-		    $this->posxweightvol-=20;
91
-		    $this->posxpicture-=20;
92
-		    $this->posxqtyordered-=20;
93
-		    $this->posxqtytoship-=20;
90
+		    $this->posxweightvol -= 20;
91
+		    $this->posxpicture -= 20;
92
+		    $this->posxqtyordered -= 20;
93
+		    $this->posxqtytoship -= 20;
94 94
 		}
95 95
 
96
-		if (! empty($conf->global->SHIPPING_PDF_HIDE_ORDERED))
96
+		if (!empty($conf->global->SHIPPING_PDF_HIDE_ORDERED))
97 97
 		{
98 98
 		    $this->posxweightvol += ($this->posxqtytoship - $this->posxqtyordered);
99 99
 		    $this->posxpicture += ($this->posxqtytoship - $this->posxqtyordered);
@@ -112,15 +112,15 @@  discard block
 block discarded – undo
112 112
      *  @param		int			$hideref			Do not show ref
113 113
      *  @return     int         	    			1=OK, 0=KO
114 114
 	 */
115
-	function write_file($object,$outputlangs,$srctemplatepath='',$hidedetails=0,$hidedesc=0,$hideref=0)
115
+	function write_file($object, $outputlangs, $srctemplatepath = '', $hidedetails = 0, $hidedesc = 0, $hideref = 0)
116 116
 	{
117
-		global $user,$conf,$langs,$hookmanager;
117
+		global $user, $conf, $langs, $hookmanager;
118 118
 
119 119
 		$object->fetch_thirdparty();
120 120
 
121
-		if (! is_object($outputlangs)) $outputlangs=$langs;
121
+		if (!is_object($outputlangs)) $outputlangs = $langs;
122 122
 		// For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
123
-		if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1';
123
+		if (!empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output = 'ISO-8859-1';
124 124
 
125 125
 		$outputlangs->load("main");
126 126
 		$outputlangs->load("dict");
@@ -135,50 +135,50 @@  discard block
 block discarded – undo
135 135
 		$nblignes = count($object->lines);
136 136
 
137 137
         // Loop on each lines to detect if there is at least one image to show
138
-        $realpatharray=array();
139
-        if (! empty($conf->global->MAIN_GENERATE_SHIPMENT_WITH_PICTURE))
138
+        $realpatharray = array();
139
+        if (!empty($conf->global->MAIN_GENERATE_SHIPMENT_WITH_PICTURE))
140 140
         {
141 141
             $objphoto = new Product($this->db);
142 142
 
143
-            for ($i = 0 ; $i < $nblignes ; $i++)
143
+            for ($i = 0; $i < $nblignes; $i++)
144 144
             {
145 145
                 if (empty($object->lines[$i]->fk_product)) continue;
146 146
 
147 147
 				$objphoto = new Product($this->db);
148 148
 				$objphoto->fetch($object->lines[$i]->fk_product);
149 149
 
150
-				$pdir = get_exdir($object->lines[$i]->fk_product,2,0,0,$objphoto,'product') . $object->lines[$i]->fk_product ."/photos/";
150
+				$pdir = get_exdir($object->lines[$i]->fk_product, 2, 0, 0, $objphoto, 'product').$object->lines[$i]->fk_product."/photos/";
151 151
 				$dir = $conf->product->dir_output.'/'.$pdir;
152 152
 
153
-				$realpath='';
153
+				$realpath = '';
154 154
 
155
-                foreach ($objphoto->liste_photos($dir,1) as $key => $obj)
155
+                foreach ($objphoto->liste_photos($dir, 1) as $key => $obj)
156 156
                         {
157 157
                             if (empty($conf->global->CAT_HIGH_QUALITY_IMAGES))		// If CAT_HIGH_QUALITY_IMAGES not defined, we use thumb if defined and then original photo
158 158
                             {
159 159
                                 if ($obj['photo_vignette'])
160 160
                                 {
161
-                                    $filename= $obj['photo_vignette'];
161
+                                    $filename = $obj['photo_vignette'];
162 162
                                 }
163 163
                                 else
164 164
                                 {
165
-                                    $filename=$obj['photo'];
165
+                                    $filename = $obj['photo'];
166 166
                                 }
167 167
                             }
168 168
                             else
169 169
                             {
170
-                                $filename=$obj['photo'];
170
+                                $filename = $obj['photo'];
171 171
                             }
172 172
 
173 173
                             $realpath = $dir.$filename;
174 174
                             break;
175 175
                 }
176 176
 
177
-                if ($realpath) $realpatharray[$i]=$realpath;
177
+                if ($realpath) $realpatharray[$i] = $realpath;
178 178
             }
179 179
         }
180 180
 
181
-        if (count($realpatharray) == 0) $this->posxpicture=$this->posxweightvol;
181
+        if (count($realpatharray) == 0) $this->posxpicture = $this->posxweightvol;
182 182
 
183 183
 		if ($conf->expedition->dir_output)
184 184
 		{
@@ -186,20 +186,20 @@  discard block
 block discarded – undo
186 186
 			if ($object->specimen)
187 187
 			{
188 188
 				$dir = $conf->expedition->dir_output."/sending";
189
-				$file = $dir . "/SPECIMEN.pdf";
189
+				$file = $dir."/SPECIMEN.pdf";
190 190
 			}
191 191
 			else
192 192
 			{
193 193
 				$expref = dol_sanitizeFileName($object->ref);
194
-				$dir = $conf->expedition->dir_output."/sending/" . $expref;
195
-				$file = $dir . "/" . $expref . ".pdf";
194
+				$dir = $conf->expedition->dir_output."/sending/".$expref;
195
+				$file = $dir."/".$expref.".pdf";
196 196
 			}
197 197
 
198
-			if (! file_exists($dir))
198
+			if (!file_exists($dir))
199 199
 			{
200 200
 				if (dol_mkdir($dir) < 0)
201 201
 				{
202
-					$this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
202
+					$this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir);
203 203
 					return 0;
204 204
 				}
205 205
 			}
@@ -207,25 +207,25 @@  discard block
 block discarded – undo
207 207
 			if (file_exists($dir))
208 208
 			{
209 209
 				// Add pdfgeneration hook
210
-				if (! is_object($hookmanager))
210
+				if (!is_object($hookmanager))
211 211
 				{
212 212
 					include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
213
-					$hookmanager=new HookManager($this->db);
213
+					$hookmanager = new HookManager($this->db);
214 214
 				}
215 215
 				$hookmanager->initHooks(array('pdfgeneration'));
216
-				$parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs);
216
+				$parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs);
217 217
 				global $action;
218
-				$reshook=$hookmanager->executeHooks('beforePDFCreation',$parameters,$object,$action);    // Note that $action and $object may have been modified by some hooks
218
+				$reshook = $hookmanager->executeHooks('beforePDFCreation', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
219 219
 
220 220
 				// Set nblignes with the new facture lines content after hook
221 221
 				$nblignes = count($object->lines);
222 222
 
223
-				$pdf=pdf_getInstance($this->format);
223
+				$pdf = pdf_getInstance($this->format);
224 224
 				$default_font_size = pdf_getPDFFontSize($outputlangs);
225
-				$heightforinfotot = 8;	// Height reserved to output the info and total part
226
-		        $heightforfreetext= (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT)?$conf->global->MAIN_PDF_FREETEXT_HEIGHT:5);	// Height reserved to output the free text on last page
227
-	            $heightforfooter = $this->marge_basse + 8;	// Height reserved to output the footer (value include bottom margin)
228
-                $pdf->SetAutoPageBreak(1,0);
225
+				$heightforinfotot = 8; // Height reserved to output the info and total part
226
+		        $heightforfreetext = (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT) ? $conf->global->MAIN_PDF_FREETEXT_HEIGHT : 5); // Height reserved to output the free text on last page
227
+	            $heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin)
228
+                $pdf->SetAutoPageBreak(1, 0);
229 229
 
230 230
                 if (class_exists('TCPDF'))
231 231
                 {
@@ -234,38 +234,38 @@  discard block
 block discarded – undo
234 234
                 }
235 235
                 $pdf->SetFont(pdf_getPDFFont($outputlangs));
236 236
                 // Set path to the background PDF File
237
-                if (empty($conf->global->MAIN_DISABLE_FPDI) && ! empty($conf->global->MAIN_ADD_PDF_BACKGROUND))
237
+                if (empty($conf->global->MAIN_DISABLE_FPDI) && !empty($conf->global->MAIN_ADD_PDF_BACKGROUND))
238 238
                 {
239 239
                     $pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND);
240 240
                     $tplidx = $pdf->importPage(1);
241 241
                 }
242 242
 
243 243
 				$pdf->Open();
244
-				$pagenb=0;
245
-				$pdf->SetDrawColor(128,128,128);
244
+				$pagenb = 0;
245
+				$pdf->SetDrawColor(128, 128, 128);
246 246
 
247
-				if (method_exists($pdf,'AliasNbPages')) $pdf->AliasNbPages();
247
+				if (method_exists($pdf, 'AliasNbPages')) $pdf->AliasNbPages();
248 248
 
249 249
 				$pdf->SetTitle($outputlangs->convToOutputCharset($object->ref));
250 250
 				$pdf->SetSubject($outputlangs->transnoentities("Shipment"));
251 251
 				$pdf->SetCreator("Dolibarr ".DOL_VERSION);
252 252
 				$pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
253 253
 				$pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("Shipment"));
254
-				if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
254
+				if (!empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
255 255
 
256
-				$pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);   // Left, Top, Right
256
+				$pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right
257 257
 
258 258
 				// New page
259 259
 				$pdf->AddPage();
260
-				if (! empty($tplidx)) $pdf->useTemplate($tplidx);
260
+				if (!empty($tplidx)) $pdf->useTemplate($tplidx);
261 261
 				$pagenb++;
262 262
 				$this->_pagehead($pdf, $object, 1, $outputlangs);
263
-				$pdf->SetFont('','', $default_font_size - 1);
264
-				$pdf->MultiCell(0, 3, '');		// Set interline to 3
265
-				$pdf->SetTextColor(0,0,0);
263
+				$pdf->SetFont('', '', $default_font_size - 1);
264
+				$pdf->MultiCell(0, 3, ''); // Set interline to 3
265
+				$pdf->SetTextColor(0, 0, 0);
266 266
 
267 267
 				$tab_top = 90;
268
-				$tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)?42:10);
268
+				$tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD) ? 42 : 10);
269 269
 				$tab_height = 130;
270 270
 				$tab_height_newpage = 150;
271 271
 
@@ -278,52 +278,52 @@  discard block
 block discarded – undo
278 278
 					{
279 279
 						$tab_top = 88;
280 280
 
281
-						$pdf->SetFont('','', $default_font_size - 1);
282
-						$pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top-1, dol_htmlentitiesbr($desc_incoterms), 0, 1);
281
+						$pdf->SetFont('', '', $default_font_size - 1);
282
+						$pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top - 1, dol_htmlentitiesbr($desc_incoterms), 0, 1);
283 283
 						$nexY = $pdf->GetY();
284
-						$height_incoterms=$nexY-$tab_top;
284
+						$height_incoterms = $nexY - $tab_top;
285 285
 
286 286
 						// Rect prend une longueur en 3eme param
287
-						$pdf->SetDrawColor(192,192,192);
288
-						$pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_incoterms+1);
287
+						$pdf->SetDrawColor(192, 192, 192);
288
+						$pdf->Rect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_incoterms + 1);
289 289
 
290
-						$tab_top = $nexY+6;
290
+						$tab_top = $nexY + 6;
291 291
 						$height_incoterms += 4;
292 292
 					}
293 293
 				}
294 294
 
295
-				if (! empty($object->note_public) || ! empty($object->tracking_number))
295
+				if (!empty($object->note_public) || !empty($object->tracking_number))
296 296
 				{
297 297
 					$tab_top = 88 + $height_incoterms;
298 298
 					$tab_top_alt = $tab_top;
299 299
 
300
-					$pdf->SetFont('','B', $default_font_size - 2);
301
-					$pdf->writeHTMLCell(60, 4, $this->posxdesc-1, $tab_top-1, $outputlangs->transnoentities("TrackingNumber")." : " . $object->tracking_number, 0, 1, false, true, 'L');
300
+					$pdf->SetFont('', 'B', $default_font_size - 2);
301
+					$pdf->writeHTMLCell(60, 4, $this->posxdesc - 1, $tab_top - 1, $outputlangs->transnoentities("TrackingNumber")." : ".$object->tracking_number, 0, 1, false, true, 'L');
302 302
 
303 303
 					$tab_top_alt = $pdf->GetY();
304 304
 					//$tab_top_alt += 1;
305 305
 
306 306
 					// Tracking number
307
-					if (! empty($object->tracking_number))
307
+					if (!empty($object->tracking_number))
308 308
 					{
309 309
 						$object->GetUrlTrackingStatus($object->tracking_number);
310
-						if (! empty($object->tracking_url))
310
+						if (!empty($object->tracking_url))
311 311
 						{
312 312
 							if ($object->shipping_method_id > 0)
313 313
 							{
314 314
 								// Get code using getLabelFromKey
315
-								$code=$outputlangs->getLabelFromKey($this->db,$object->shipping_method_id,'c_shipment_mode','rowid','code');
316
-								$label='';
317
-								if ($object->tracking_url != $object->tracking_number) $label.=$outputlangs->trans("LinkToTrackYourPackage")."<br>";
318
-								$label.=$outputlangs->trans("SendingMethod").": ".$outputlangs->trans("SendingMethod".strtoupper($code));
315
+								$code = $outputlangs->getLabelFromKey($this->db, $object->shipping_method_id, 'c_shipment_mode', 'rowid', 'code');
316
+								$label = '';
317
+								if ($object->tracking_url != $object->tracking_number) $label .= $outputlangs->trans("LinkToTrackYourPackage")."<br>";
318
+								$label .= $outputlangs->trans("SendingMethod").": ".$outputlangs->trans("SendingMethod".strtoupper($code));
319 319
 								//var_dump($object->tracking_url != $object->tracking_number);exit;
320 320
 								if ($object->tracking_url != $object->tracking_number)
321 321
 								{
322
-									$label.=" : ";
323
-									$label.=$object->tracking_url;
322
+									$label .= " : ";
323
+									$label .= $object->tracking_url;
324 324
 								}
325
-								$pdf->SetFont('','B', $default_font_size - 2);
326
-								$pdf->writeHTMLCell(60, 4, $this->posxdesc-1, $tab_top_alt, $label, 0, 1, false, true, 'L');
325
+								$pdf->SetFont('', 'B', $default_font_size - 2);
326
+								$pdf->writeHTMLCell(60, 4, $this->posxdesc - 1, $tab_top_alt, $label, 0, 1, false, true, 'L');
327 327
 
328 328
 								$tab_top_alt = $pdf->GetY();
329 329
 							}
@@ -331,25 +331,25 @@  discard block
 block discarded – undo
331 331
 					}
332 332
 
333 333
 					// Notes
334
-					if (! empty($object->note_public))
334
+					if (!empty($object->note_public))
335 335
 					{
336
-						$pdf->SetFont('','', $default_font_size - 1);   // Dans boucle pour gerer multi-page
337
-						$pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top_alt, dol_htmlentitiesbr($object->note_public), 0, 1);
336
+						$pdf->SetFont('', '', $default_font_size - 1); // Dans boucle pour gerer multi-page
337
+						$pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top_alt, dol_htmlentitiesbr($object->note_public), 0, 1);
338 338
 					}
339 339
 
340 340
 					$nexY = $pdf->GetY();
341
-					$height_note=$nexY-$tab_top;
341
+					$height_note = $nexY - $tab_top;
342 342
 
343 343
 					// Rect prend une longueur en 3eme param
344
-					$pdf->SetDrawColor(192,192,192);
345
-					$pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_note+1);
344
+					$pdf->SetDrawColor(192, 192, 192);
345
+					$pdf->Rect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_note + 1);
346 346
 
347 347
 					$tab_height = $tab_height - $height_note;
348
-					$tab_top = $nexY+6;
348
+					$tab_top = $nexY + 6;
349 349
 				}
350 350
 				else
351 351
 				{
352
-					$height_note=0;
352
+					$height_note = 0;
353 353
 				}
354 354
 
355 355
 				$iniY = $tab_top + 7;
@@ -360,87 +360,87 @@  discard block
 block discarded – undo
360 360
 				for ($i = 0; $i < $nblignes; $i++)
361 361
 				{
362 362
 					$curY = $nexY;
363
-					$pdf->SetFont('','', $default_font_size - 1);   // Into loop to work with multipage
364
-					$pdf->SetTextColor(0,0,0);
363
+					$pdf->SetFont('', '', $default_font_size - 1); // Into loop to work with multipage
364
+					$pdf->SetTextColor(0, 0, 0);
365 365
 
366 366
 					// Define size of image if we need it
367
-					$imglinesize=array();
368
-					if (! empty($realpatharray[$i])) $imglinesize=pdf_getSizeForImage($realpatharray[$i]);
367
+					$imglinesize = array();
368
+					if (!empty($realpatharray[$i])) $imglinesize = pdf_getSizeForImage($realpatharray[$i]);
369 369
 
370 370
 					$pdf->setTopMargin($tab_top_newpage);
371
-					$pdf->setPageOrientation('', 1, $heightforfooter+$heightforfreetext+$heightforinfotot);	// The only function to edit the bottom margin of current page to set it.
372
-					$pageposbefore=$pdf->getPage();
371
+					$pdf->setPageOrientation('', 1, $heightforfooter + $heightforfreetext + $heightforinfotot); // The only function to edit the bottom margin of current page to set it.
372
+					$pageposbefore = $pdf->getPage();
373 373
 
374
-					$showpricebeforepagebreak=1;
375
-					$posYAfterImage=0;
376
-					$posYAfterDescription=0;
374
+					$showpricebeforepagebreak = 1;
375
+					$posYAfterImage = 0;
376
+					$posYAfterDescription = 0;
377 377
 
378 378
 					// We start with Photo of product line
379
-					if (isset($imglinesize['width']) && isset($imglinesize['height']) && ($curY + $imglinesize['height']) > ($this->page_hauteur-($heightforfooter+$heightforfreetext+$heightforinfotot)))	// If photo too high, we moved completely on new page
379
+					if (isset($imglinesize['width']) && isset($imglinesize['height']) && ($curY + $imglinesize['height']) > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot)))	// If photo too high, we moved completely on new page
380 380
 					{
381
-						$pdf->AddPage('','',true);
382
-						if (! empty($tplidx)) $pdf->useTemplate($tplidx);
381
+						$pdf->AddPage('', '', true);
382
+						if (!empty($tplidx)) $pdf->useTemplate($tplidx);
383 383
 						if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
384
-						$pdf->setPage($pageposbefore+1);
384
+						$pdf->setPage($pageposbefore + 1);
385 385
 
386 386
 						$curY = $tab_top_newpage;
387
-						$showpricebeforepagebreak=0;
387
+						$showpricebeforepagebreak = 0;
388 388
 					}
389 389
 
390 390
 					if (isset($imglinesize['width']) && isset($imglinesize['height']))
391 391
 					{
392
-						$curX = $this->posxpicture-1;
393
-						$pdf->Image($realpatharray[$i], $curX + (($this->posxweightvol-$this->posxpicture-$imglinesize['width'])/2), $curY, $imglinesize['width'], $imglinesize['height'], '', '', '', 2, 300);	// Use 300 dpi
392
+						$curX = $this->posxpicture - 1;
393
+						$pdf->Image($realpatharray[$i], $curX + (($this->posxweightvol - $this->posxpicture - $imglinesize['width']) / 2), $curY, $imglinesize['width'], $imglinesize['height'], '', '', '', 2, 300); // Use 300 dpi
394 394
 						// $pdf->Image does not increase value return by getY, so we save it manually
395
-						$posYAfterImage=$curY+$imglinesize['height'];
395
+						$posYAfterImage = $curY + $imglinesize['height'];
396 396
 					}
397 397
 
398 398
 					// Description of product line
399
-					$curX = $this->posxdesc-1;
399
+					$curX = $this->posxdesc - 1;
400 400
 
401 401
 					$pdf->startTransaction();
402
-					pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->posxpicture-$curX,3,$curX,$curY,$hideref,$hidedesc);
402
+					pdf_writelinedesc($pdf, $object, $i, $outputlangs, $this->posxpicture - $curX, 3, $curX, $curY, $hideref, $hidedesc);
403 403
 
404
-					$pageposafter=$pdf->getPage();
404
+					$pageposafter = $pdf->getPage();
405 405
 					if ($pageposafter > $pageposbefore)	// There is a pagebreak
406 406
 					{
407 407
 						$pdf->rollbackTransaction(true);
408
-						$pageposafter=$pageposbefore;
408
+						$pageposafter = $pageposbefore;
409 409
 						//print $pageposafter.'-'.$pageposbefore;exit;
410
-						$pdf->setPageOrientation('', 1, $heightforfooter);	// The only function to edit the bottom margin of current page to set it.
411
-						pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->posxpicture-$curX,3,$curX,$curY,$hideref,$hidedesc);
410
+						$pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it.
411
+						pdf_writelinedesc($pdf, $object, $i, $outputlangs, $this->posxpicture - $curX, 3, $curX, $curY, $hideref, $hidedesc);
412 412
 
413
-						$pageposafter=$pdf->getPage();
414
-						$posyafter=$pdf->GetY();
413
+						$pageposafter = $pdf->getPage();
414
+						$posyafter = $pdf->GetY();
415 415
 						//var_dump($posyafter); var_dump(($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))); exit;
416
-						if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot)))	// There is no space left for total+free text
416
+						if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot)))	// There is no space left for total+free text
417 417
 						{
418
-							if ($i == ($nblignes-1))	// No more lines, and no space left to show total, so we create a new page
418
+							if ($i == ($nblignes - 1))	// No more lines, and no space left to show total, so we create a new page
419 419
 							{
420
-								$pdf->AddPage('','',true);
421
-								if (! empty($tplidx)) $pdf->useTemplate($tplidx);
420
+								$pdf->AddPage('', '', true);
421
+								if (!empty($tplidx)) $pdf->useTemplate($tplidx);
422 422
 								if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
423
-								$pdf->setPage($pageposafter+1);
423
+								$pdf->setPage($pageposafter + 1);
424 424
 							}
425 425
 						}
426 426
 						else
427 427
 						{
428 428
 							// We found a page break
429
-							$showpricebeforepagebreak=0;
429
+							$showpricebeforepagebreak = 0;
430 430
 						}
431 431
 					}
432 432
 					else	// No pagebreak
433 433
 					{
434 434
 						$pdf->commitTransaction();
435 435
 					}
436
-					$posYAfterDescription=$pdf->GetY();
436
+					$posYAfterDescription = $pdf->GetY();
437 437
 
438 438
 					$nexY = $pdf->GetY();
439
-					$pageposafter=$pdf->getPage();
439
+					$pageposafter = $pdf->getPage();
440 440
 
441 441
 					$pdf->setPage($pageposbefore);
442 442
 					$pdf->setTopMargin($this->marge_haute);
443
-					$pdf->setPageOrientation('', 1, 0);	// The only function to edit the bottom margin of current page to set it.
443
+					$pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
444 444
 
445 445
 					// We suppose that a too long description or photo were moved completely on next page
446 446
 					if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) {
@@ -452,51 +452,51 @@  discard block
 block discarded – undo
452 452
 						$pdf->setPage($pageposafter); $curY = $tab_top_newpage;
453 453
 					}
454 454
 
455
-					$pdf->SetFont('','', $default_font_size - 1);   // On repositionne la police par defaut
455
+					$pdf->SetFont('', '', $default_font_size - 1); // On repositionne la police par defaut
456 456
 
457 457
 					$pdf->SetXY($this->posxweightvol, $curY);
458
-					$weighttxt='';
458
+					$weighttxt = '';
459 459
 					if ($object->lines[$i]->fk_product_type == 0 && $object->lines[$i]->weight)
460 460
 					{
461
-					    $weighttxt=round($object->lines[$i]->weight * $object->lines[$i]->qty_shipped, 5).' '.measuring_units_string($object->lines[$i]->weight_units,"weight");
461
+					    $weighttxt = round($object->lines[$i]->weight * $object->lines[$i]->qty_shipped, 5).' '.measuring_units_string($object->lines[$i]->weight_units, "weight");
462 462
 					}
463
-					$voltxt='';
463
+					$voltxt = '';
464 464
 					if ($object->lines[$i]->fk_product_type == 0 && $object->lines[$i]->volume)
465 465
 					{
466
-					    $voltxt=round($object->lines[$i]->volume * $object->lines[$i]->qty_shipped, 5).' '.measuring_units_string($object->lines[$i]->volume_units?$object->lines[$i]->volume_units:0,"volume");
466
+					    $voltxt = round($object->lines[$i]->volume * $object->lines[$i]->qty_shipped, 5).' '.measuring_units_string($object->lines[$i]->volume_units ? $object->lines[$i]->volume_units : 0, "volume");
467 467
 					}
468 468
 
469
-					$pdf->writeHTMLCell($this->posxqtyordered - $this->posxweightvol + 2, 3, $this->posxweightvol - 1, $curY, $weighttxt.(($weighttxt && $voltxt)?'<br>':'').$voltxt, 0, 0, false, true, 'C');
469
+					$pdf->writeHTMLCell($this->posxqtyordered - $this->posxweightvol + 2, 3, $this->posxweightvol - 1, $curY, $weighttxt.(($weighttxt && $voltxt) ? '<br>' : '').$voltxt, 0, 0, false, true, 'C');
470 470
 					//$pdf->MultiCell(($this->posxqtyordered - $this->posxweightvol), 3, $weighttxt.(($weighttxt && $voltxt)?'<br>':'').$voltxt,'','C');
471 471
 
472 472
 					if (empty($conf->global->SHIPPING_PDF_HIDE_ORDERED))
473 473
 					{
474 474
 					   $pdf->SetXY($this->posxqtyordered, $curY);
475
-					   $pdf->MultiCell(($this->posxqtytoship - $this->posxqtyordered), 3, $object->lines[$i]->qty_asked,'','C');
475
+					   $pdf->MultiCell(($this->posxqtytoship - $this->posxqtyordered), 3, $object->lines[$i]->qty_asked, '', 'C');
476 476
 					}
477 477
 
478 478
 					$pdf->SetXY($this->posxqtytoship, $curY);
479
-					$pdf->MultiCell(($this->posxpuht - $this->posxqtytoship), 3, $object->lines[$i]->qty_shipped,'','C');
479
+					$pdf->MultiCell(($this->posxpuht - $this->posxqtytoship), 3, $object->lines[$i]->qty_shipped, '', 'C');
480 480
 
481
-					if(!empty($conf->global->MAIN_PDF_SHIPPING_DISPLAY_AMOUNT_HT))
481
+					if (!empty($conf->global->MAIN_PDF_SHIPPING_DISPLAY_AMOUNT_HT))
482 482
 					{
483 483
 						$pdf->SetXY($this->posxpuht, $curY);
484
-						$pdf->MultiCell(($this->posxtotalht - $this->posxpuht-1), 3, price($object->lines[$i]->subprice, 0, $outputlangs),'','R');
484
+						$pdf->MultiCell(($this->posxtotalht - $this->posxpuht - 1), 3, price($object->lines[$i]->subprice, 0, $outputlangs), '', 'R');
485 485
 
486 486
 						$pdf->SetXY($this->posxtotalht, $curY);
487
-						$pdf->MultiCell(($this->page_largeur - $this->marge_droite - $this->posxtotalht), 3, price($object->lines[$i]->total_ht, 0, $outputlangs),'','R');
487
+						$pdf->MultiCell(($this->page_largeur - $this->marge_droite - $this->posxtotalht), 3, price($object->lines[$i]->total_ht, 0, $outputlangs), '', 'R');
488 488
 					}
489 489
 
490
-					$nexY+=3;
491
-					if ($weighttxt && $voltxt) $nexY+=2;
490
+					$nexY += 3;
491
+					if ($weighttxt && $voltxt) $nexY += 2;
492 492
 
493 493
 					// Add line
494
-					if (! empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblignes - 1))
494
+					if (!empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblignes - 1))
495 495
 					{
496 496
 						$pdf->setPage($pageposafter);
497
-						$pdf->SetLineStyle(array('dash'=>'1,1','color'=>array(80,80,80)));
497
+						$pdf->SetLineStyle(array('dash'=>'1,1', 'color'=>array(80, 80, 80)));
498 498
 						//$pdf->SetDrawColor(190,190,200);
499
-						$pdf->line($this->marge_gauche, $nexY-1, $this->page_largeur - $this->marge_droite, $nexY-1);
499
+						$pdf->line($this->marge_gauche, $nexY - 1, $this->page_largeur - $this->marge_droite, $nexY - 1);
500 500
 						$pdf->SetLineStyle(array('dash'=>0));
501 501
 					}
502 502
 
@@ -512,12 +512,12 @@  discard block
 block discarded – undo
512 512
 						{
513 513
 							$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
514 514
 						}
515
-						$this->_pagefoot($pdf,$object,$outputlangs,1);
515
+						$this->_pagefoot($pdf, $object, $outputlangs, 1);
516 516
 						$pagenb++;
517 517
 						$pdf->setPage($pagenb);
518
-						$pdf->setPageOrientation('', 1, 0);	// The only function to edit the bottom margin of current page to set it.
518
+						$pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
519 519
 					}
520
-					if (isset($object->lines[$i+1]->pagebreak) && $object->lines[$i+1]->pagebreak)
520
+					if (isset($object->lines[$i + 1]->pagebreak) && $object->lines[$i + 1]->pagebreak)
521 521
 					{
522 522
 						if ($pagenb == 1)
523 523
 						{
@@ -527,10 +527,10 @@  discard block
 block discarded – undo
527 527
 						{
528 528
 							$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
529 529
 						}
530
-						$this->_pagefoot($pdf,$object,$outputlangs,1);
530
+						$this->_pagefoot($pdf, $object, $outputlangs, 1);
531 531
 						// New page
532 532
 						$pdf->AddPage();
533
-						if (! empty($tplidx)) $pdf->useTemplate($tplidx);
533
+						if (!empty($tplidx)) $pdf->useTemplate($tplidx);
534 534
 						$pagenb++;
535 535
 					}
536 536
 				}
@@ -539,47 +539,47 @@  discard block
 block discarded – undo
539 539
 				if ($pagenb == 1)
540 540
 				{
541 541
 					$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0);
542
-					$bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
542
+					$bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
543 543
 				}
544 544
 				else
545 545
 				{
546 546
 					$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0);
547
-					$bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
547
+					$bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
548 548
 				}
549 549
 
550 550
 				// Affiche zone totaux
551
-				$posy=$this->_tableau_tot($pdf, $object, 0, $bottomlasttab, $outputlangs);
551
+				$posy = $this->_tableau_tot($pdf, $object, 0, $bottomlasttab, $outputlangs);
552 552
 
553 553
 				// Pied de page
554
-				$this->_pagefoot($pdf,$object,$outputlangs);
555
-				if (method_exists($pdf,'AliasNbPages')) $pdf->AliasNbPages();
554
+				$this->_pagefoot($pdf, $object, $outputlangs);
555
+				if (method_exists($pdf, 'AliasNbPages')) $pdf->AliasNbPages();
556 556
 
557 557
 				$pdf->Close();
558 558
 
559
-				$pdf->Output($file,'F');
559
+				$pdf->Output($file, 'F');
560 560
 
561 561
 				// Add pdfgeneration hook
562 562
 				$hookmanager->initHooks(array('pdfgeneration'));
563
-				$parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs);
563
+				$parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs);
564 564
 				global $action;
565
-				$reshook=$hookmanager->executeHooks('afterPDFCreation',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
565
+				$reshook = $hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
566 566
 
567
-				if (! empty($conf->global->MAIN_UMASK))
567
+				if (!empty($conf->global->MAIN_UMASK))
568 568
 				@chmod($file, octdec($conf->global->MAIN_UMASK));
569 569
 
570 570
 				$this->result = array('fullpath'=>$file);
571 571
 
572
-				return 1;	// No error
572
+				return 1; // No error
573 573
 			}
574 574
 			else
575 575
 			{
576
-				$this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
576
+				$this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir);
577 577
 				return 0;
578 578
 			}
579 579
 		}
580 580
 		else
581 581
 		{
582
-			$this->error=$langs->transnoentities("ErrorConstantNotDefined","EXP_OUTPUTDIR");
582
+			$this->error = $langs->transnoentities("ErrorConstantNotDefined", "EXP_OUTPUTDIR");
583 583
 			return 0;
584 584
 		}
585 585
 	}
@@ -596,18 +596,18 @@  discard block
 block discarded – undo
596 596
 	 */
597 597
 	function _tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs)
598 598
 	{
599
-		global $conf,$mysoc;
599
+		global $conf, $mysoc;
600 600
 
601
-        $sign=1;
601
+        $sign = 1;
602 602
 
603 603
         $default_font_size = pdf_getPDFFontSize($outputlangs);
604 604
 
605 605
 		$tab2_top = $posy;
606 606
 		$tab2_hl = 4;
607
-		$pdf->SetFont('','B', $default_font_size - 1);
607
+		$pdf->SetFont('', 'B', $default_font_size - 1);
608 608
 
609 609
 		// Tableau total
610
-		$col1x = $this->posxweightvol-50; $col2x = $this->posxweightvol;
610
+		$col1x = $this->posxweightvol - 50; $col2x = $this->posxweightvol;
611 611
 		/*if ($this->page_largeur < 210) // To work with US executive format
612 612
 		{
613 613
 			$col2x-=20;
@@ -615,33 +615,33 @@  discard block
 block discarded – undo
615 615
 		if (empty($conf->global->SHIPPING_PDF_HIDE_ORDERED)) $largcol2 = ($this->posxqtyordered - $this->posxweightvol);
616 616
 		else $largcol2 = ($this->posxqtytoship - $this->posxweightvol);
617 617
 
618
-		$useborder=0;
618
+		$useborder = 0;
619 619
 		$index = 0;
620 620
 
621
-		$totalWeighttoshow='';
622
-		$totalVolumetoshow='';
621
+		$totalWeighttoshow = '';
622
+		$totalVolumetoshow = '';
623 623
 
624 624
 		// Load dim data
625
-		$tmparray=$object->getTotalWeightVolume();
626
-		$totalWeight=$tmparray['weight'];
627
-		$totalVolume=$tmparray['volume'];
628
-		$totalOrdered=$tmparray['ordered'];
629
-		$totalToShip=$tmparray['toship'];
625
+		$tmparray = $object->getTotalWeightVolume();
626
+		$totalWeight = $tmparray['weight'];
627
+		$totalVolume = $tmparray['volume'];
628
+		$totalOrdered = $tmparray['ordered'];
629
+		$totalToShip = $tmparray['toship'];
630 630
 		// Set trueVolume and volume_units not currently stored into database
631 631
 		if ($object->trueWidth && $object->trueHeight && $object->trueDepth)
632 632
 		{
633
-		    $object->trueVolume=price(($object->trueWidth * $object->trueHeight * $object->trueDepth), 0, $outputlangs, 0, 0);
634
-		    $object->volume_units=$object->size_units * 3;
633
+		    $object->trueVolume = price(($object->trueWidth * $object->trueHeight * $object->trueDepth), 0, $outputlangs, 0, 0);
634
+		    $object->volume_units = $object->size_units * 3;
635 635
 		}
636 636
 
637
-		if ($totalWeight!='') $totalWeighttoshow=showDimensionInBestUnit($totalWeight, 0, "weight", $outputlangs);
638
-		if ($totalVolume!='') $totalVolumetoshow=showDimensionInBestUnit($totalVolume, 0, "volume", $outputlangs);
639
-		if ($object->trueWeight) $totalWeighttoshow=showDimensionInBestUnit($object->trueWeight, $object->weight_units, "weight", $outputlangs);
640
-		if ($object->trueVolume) $totalVolumetoshow=showDimensionInBestUnit($object->trueVolume, $object->volume_units, "volume", $outputlangs);
637
+		if ($totalWeight != '') $totalWeighttoshow = showDimensionInBestUnit($totalWeight, 0, "weight", $outputlangs);
638
+		if ($totalVolume != '') $totalVolumetoshow = showDimensionInBestUnit($totalVolume, 0, "volume", $outputlangs);
639
+		if ($object->trueWeight) $totalWeighttoshow = showDimensionInBestUnit($object->trueWeight, $object->weight_units, "weight", $outputlangs);
640
+		if ($object->trueVolume) $totalVolumetoshow = showDimensionInBestUnit($object->trueVolume, $object->volume_units, "volume", $outputlangs);
641 641
 
642
-    	$pdf->SetFillColor(255,255,255);
642
+    	$pdf->SetFillColor(255, 255, 255);
643 643
     	$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
644
-    	$pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("Total"), 0, 'L', 1);
644
+    	$pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("Total"), 0, 'L', 1);
645 645
 
646 646
         if (empty($conf->global->SHIPPING_PDF_HIDE_ORDERED))
647 647
         {
@@ -652,7 +652,7 @@  discard block
 block discarded – undo
652 652
     	$pdf->SetXY($this->posxqtytoship, $tab2_top + $tab2_hl * $index);
653 653
     	$pdf->MultiCell($this->posxpuht - $this->posxqtytoship, $tab2_hl, $totalToShip, 0, 'C', 1);
654 654
 
655
-		if(!empty($conf->global->MAIN_PDF_SHIPPING_DISPLAY_AMOUNT_HT)) {
655
+		if (!empty($conf->global->MAIN_PDF_SHIPPING_DISPLAY_AMOUNT_HT)) {
656 656
 
657 657
 	    	$pdf->SetXY($this->posxpuht, $tab2_top + $tab2_hl * $index);
658 658
 	    	$pdf->MultiCell($this->posxtotalht - $this->posxpuht, $tab2_hl, '', 0, 'C', 1);
@@ -677,9 +677,9 @@  discard block
 block discarded – undo
677 677
 
678 678
 		    $index++;
679 679
 		}
680
-		if (! $totalWeighttoshow && ! $totalVolumetoshow) $index++;
680
+		if (!$totalWeighttoshow && !$totalVolumetoshow) $index++;
681 681
 
682
-		$pdf->SetTextColor(0,0,0);
682
+		$pdf->SetTextColor(0, 0, 0);
683 683
 
684 684
 		return ($tab2_top + ($tab2_hl * $index));
685 685
 	}
@@ -696,72 +696,72 @@  discard block
 block discarded – undo
696 696
 	 *   @param		int			$hidebottom		Hide bottom bar of array
697 697
 	 *   @return	void
698 698
 	 */
699
-	function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop=0, $hidebottom=0)
699
+	function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0)
700 700
 	{
701 701
 		global $conf;
702 702
 
703 703
 		// Force to disable hidetop and hidebottom
704
-		$hidebottom=0;
705
-		if ($hidetop) $hidetop=-1;
704
+		$hidebottom = 0;
705
+		if ($hidetop) $hidetop = -1;
706 706
 
707 707
 		$default_font_size = pdf_getPDFFontSize($outputlangs);
708 708
 
709 709
 		// Amount in (at tab_top - 1)
710
-		$pdf->SetTextColor(0,0,0);
711
-		$pdf->SetFont('','',$default_font_size - 2);
710
+		$pdf->SetTextColor(0, 0, 0);
711
+		$pdf->SetFont('', '', $default_font_size - 2);
712 712
 
713 713
 		// Output Rect
714
-		$this->printRect($pdf,$this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $tab_height, $hidetop, $hidebottom);	// Rect prend une longueur en 3eme param et 4eme param
714
+		$this->printRect($pdf, $this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $tab_height, $hidetop, $hidebottom); // Rect prend une longueur en 3eme param et 4eme param
715 715
 
716
-		$pdf->SetDrawColor(128,128,128);
717
-		$pdf->SetFont('','', $default_font_size - 1);
716
+		$pdf->SetDrawColor(128, 128, 128);
717
+		$pdf->SetFont('', '', $default_font_size - 1);
718 718
 
719 719
 		if (empty($hidetop))
720 720
 		{
721
-			$pdf->line($this->marge_gauche, $tab_top+5, $this->page_largeur-$this->marge_droite, $tab_top+5);
721
+			$pdf->line($this->marge_gauche, $tab_top + 5, $this->page_largeur - $this->marge_droite, $tab_top + 5);
722 722
 
723
-			$pdf->SetXY($this->posxdesc-1, $tab_top+1);
723
+			$pdf->SetXY($this->posxdesc - 1, $tab_top + 1);
724 724
 			$pdf->MultiCell($this->posxqtyordered - $this->posxdesc, 2, $outputlangs->transnoentities("Description"), '', 'L');
725 725
 		}
726 726
 
727
-		$pdf->line($this->posxweightvol-1, $tab_top, $this->posxweightvol-1, $tab_top + $tab_height);
727
+		$pdf->line($this->posxweightvol - 1, $tab_top, $this->posxweightvol - 1, $tab_top + $tab_height);
728 728
 		if (empty($hidetop))
729 729
 		{
730
-			$pdf->SetXY($this->posxweightvol-1, $tab_top+1);
731
-			$pdf->MultiCell(($this->posxqtyordered - $this->posxweightvol), 2, $outputlangs->transnoentities("WeightVolShort"),'','C');
730
+			$pdf->SetXY($this->posxweightvol - 1, $tab_top + 1);
731
+			$pdf->MultiCell(($this->posxqtyordered - $this->posxweightvol), 2, $outputlangs->transnoentities("WeightVolShort"), '', 'C');
732 732
 		}
733 733
 
734 734
         if (empty($conf->global->SHIPPING_PDF_HIDE_ORDERED))
735 735
         {
736
-            $pdf->line($this->posxqtyordered-1, $tab_top, $this->posxqtyordered-1, $tab_top + $tab_height);
736
+            $pdf->line($this->posxqtyordered - 1, $tab_top, $this->posxqtyordered - 1, $tab_top + $tab_height);
737 737
     		if (empty($hidetop))
738 738
     		{
739
-    			$pdf->SetXY($this->posxqtyordered-1, $tab_top+1);
740
-    			$pdf->MultiCell(($this->posxqtytoship - $this->posxqtyordered), 2, $outputlangs->transnoentities("QtyOrdered"),'','C');
739
+    			$pdf->SetXY($this->posxqtyordered - 1, $tab_top + 1);
740
+    			$pdf->MultiCell(($this->posxqtytoship - $this->posxqtyordered), 2, $outputlangs->transnoentities("QtyOrdered"), '', 'C');
741 741
     		}
742 742
         }
743 743
 
744
-		$pdf->line($this->posxqtytoship-1, $tab_top, $this->posxqtytoship-1, $tab_top + $tab_height);
744
+		$pdf->line($this->posxqtytoship - 1, $tab_top, $this->posxqtytoship - 1, $tab_top + $tab_height);
745 745
 		if (empty($hidetop))
746 746
 		{
747
-			$pdf->SetXY($this->posxqtytoship, $tab_top+1);
748
-			$pdf->MultiCell(($this->posxpuht - $this->posxqtytoship), 2, $outputlangs->transnoentities("QtyToShip"),'','C');
747
+			$pdf->SetXY($this->posxqtytoship, $tab_top + 1);
748
+			$pdf->MultiCell(($this->posxpuht - $this->posxqtytoship), 2, $outputlangs->transnoentities("QtyToShip"), '', 'C');
749 749
 		}
750 750
 
751
-		if(!empty($conf->global->MAIN_PDF_SHIPPING_DISPLAY_AMOUNT_HT)) {
751
+		if (!empty($conf->global->MAIN_PDF_SHIPPING_DISPLAY_AMOUNT_HT)) {
752 752
 
753
-			$pdf->line($this->posxpuht-1, $tab_top, $this->posxpuht-1, $tab_top + $tab_height);
753
+			$pdf->line($this->posxpuht - 1, $tab_top, $this->posxpuht - 1, $tab_top + $tab_height);
754 754
 			if (empty($hidetop))
755 755
 			{
756
-				$pdf->SetXY($this->posxpuht-1, $tab_top+1);
757
-				$pdf->MultiCell(($this->posxtotalht - $this->posxpuht), 2, $outputlangs->transnoentities("PriceUHT"),'','C');
756
+				$pdf->SetXY($this->posxpuht - 1, $tab_top + 1);
757
+				$pdf->MultiCell(($this->posxtotalht - $this->posxpuht), 2, $outputlangs->transnoentities("PriceUHT"), '', 'C');
758 758
 			}
759 759
 
760
-			$pdf->line($this->posxtotalht-1, $tab_top, $this->posxtotalht-1, $tab_top + $tab_height);
760
+			$pdf->line($this->posxtotalht - 1, $tab_top, $this->posxtotalht - 1, $tab_top + $tab_height);
761 761
 			if (empty($hidetop))
762 762
 			{
763
-				$pdf->SetXY($this->posxtotalht-1, $tab_top+1);
764
-				$pdf->MultiCell(($this->page_largeur - $this->marge_droite - $this->posxtotalht), 2, $outputlangs->transnoentities("TotalHT"),'','C');
763
+				$pdf->SetXY($this->posxtotalht - 1, $tab_top + 1);
764
+				$pdf->MultiCell(($this->page_largeur - $this->marge_droite - $this->posxtotalht), 2, $outputlangs->transnoentities("TotalHT"), '', 'C');
765 765
 			}
766 766
 
767 767
 		}
@@ -779,73 +779,73 @@  discard block
 block discarded – undo
779 779
 	 */
780 780
 	function _pagehead(&$pdf, $object, $showaddress, $outputlangs)
781 781
 	{
782
-		global $conf,$langs,$mysoc;
782
+		global $conf, $langs, $mysoc;
783 783
 
784 784
 		$langs->load("orders");
785 785
 
786 786
 		$default_font_size = pdf_getPDFFontSize($outputlangs);
787 787
 
788
-		pdf_pagehead($pdf,$outputlangs,$this->page_hauteur);
788
+		pdf_pagehead($pdf, $outputlangs, $this->page_hauteur);
789 789
 
790 790
 		// Show Draft Watermark
791
-		if($object->statut==0 && (! empty($conf->global->SHIPPING_DRAFT_WATERMARK)) )
791
+		if ($object->statut == 0 && (!empty($conf->global->SHIPPING_DRAFT_WATERMARK)))
792 792
 		{
793
-            		pdf_watermark($pdf,$outputlangs,$this->page_hauteur,$this->page_largeur,'mm',$conf->global->SHIPPING_DRAFT_WATERMARK);
793
+            		pdf_watermark($pdf, $outputlangs, $this->page_hauteur, $this->page_largeur, 'mm', $conf->global->SHIPPING_DRAFT_WATERMARK);
794 794
 		}
795 795
 
796 796
 		//Prepare la suite
797
-		$pdf->SetTextColor(0,0,60);
798
-		$pdf->SetFont('','B', $default_font_size + 3);
797
+		$pdf->SetTextColor(0, 0, 60);
798
+		$pdf->SetFont('', 'B', $default_font_size + 3);
799 799
 
800 800
 		$w = 110;
801 801
 
802
-		$posy=$this->marge_haute;
803
-		$posx=$this->page_largeur-$this->marge_droite-$w;
802
+		$posy = $this->marge_haute;
803
+		$posx = $this->page_largeur - $this->marge_droite - $w;
804 804
 
805
-		$pdf->SetXY($this->marge_gauche,$posy);
805
+		$pdf->SetXY($this->marge_gauche, $posy);
806 806
 
807 807
 		// Logo
808
-		$logo=$conf->mycompany->dir_output.'/logos/'.$this->emetteur->logo;
808
+		$logo = $conf->mycompany->dir_output.'/logos/'.$this->emetteur->logo;
809 809
 		if ($this->emetteur->logo)
810 810
 		{
811 811
 			if (is_readable($logo))
812 812
 			{
813
-			    $height=pdf_getHeightForLogo($logo);
814
-			    $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);	// width=0 (auto)
813
+			    $height = pdf_getHeightForLogo($logo);
814
+			    $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto)
815 815
 			}
816 816
 			else
817 817
 			{
818
-				$pdf->SetTextColor(200,0,0);
819
-				$pdf->SetFont('','B', $default_font_size - 2);
820
-				$pdf->MultiCell($w, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound",$logo), 0, 'L');
818
+				$pdf->SetTextColor(200, 0, 0);
819
+				$pdf->SetFont('', 'B', $default_font_size - 2);
820
+				$pdf->MultiCell($w, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound", $logo), 0, 'L');
821 821
 				$pdf->MultiCell($w, 3, $outputlangs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L');
822 822
 			}
823 823
 		}
824 824
 		else
825 825
 		{
826
-			$text=$this->emetteur->name;
826
+			$text = $this->emetteur->name;
827 827
 			$pdf->MultiCell($w, 4, $outputlangs->convToOutputCharset($text), 0, 'L');
828 828
 		}
829 829
 
830 830
 		// Show barcode
831
-		if (! empty($conf->barcode->enabled))
831
+		if (!empty($conf->barcode->enabled))
832 832
 		{
833
-			$posx=105;
833
+			$posx = 105;
834 834
 		}
835 835
 		else
836 836
 		{
837
-			$posx=$this->marge_gauche+3;
837
+			$posx = $this->marge_gauche + 3;
838 838
 		}
839 839
 		//$pdf->Rect($this->marge_gauche, $this->marge_haute, $this->page_largeur-$this->marge_gauche-$this->marge_droite, 30);
840
-		if (! empty($conf->barcode->enabled))
840
+		if (!empty($conf->barcode->enabled))
841 841
 		{
842 842
 			// TODO Build code bar with function writeBarCode of barcode module for sending ref $object->ref
843 843
 			//$pdf->SetXY($this->marge_gauche+3, $this->marge_haute+3);
844 844
 			//$pdf->Image($logo,10, 5, 0, 24);
845 845
 		}
846 846
 
847
-		$pdf->SetDrawColor(128,128,128);
848
-		if (! empty($conf->barcode->enabled))
847
+		$pdf->SetDrawColor(128, 128, 128);
848
+		if (!empty($conf->barcode->enabled))
849 849
 		{
850 850
 			// TODO Build code bar with function writeBarCode of barcode module for sending ref $object->ref
851 851
 			//$pdf->SetXY($this->marge_gauche+3, $this->marge_haute+3);
@@ -853,125 +853,125 @@  discard block
 block discarded – undo
853 853
 		}
854 854
 
855 855
 
856
-		$posx=$this->page_largeur - $w - $this->marge_droite;
857
-		$posy=$this->marge_haute;
856
+		$posx = $this->page_largeur - $w - $this->marge_droite;
857
+		$posy = $this->marge_haute;
858 858
 
859
-		$pdf->SetFont('','B', $default_font_size + 2);
860
-		$pdf->SetXY($posx,$posy);
861
-		$pdf->SetTextColor(0,0,60);
862
-		$title=$outputlangs->transnoentities("SendingSheet");
859
+		$pdf->SetFont('', 'B', $default_font_size + 2);
860
+		$pdf->SetXY($posx, $posy);
861
+		$pdf->SetTextColor(0, 0, 60);
862
+		$title = $outputlangs->transnoentities("SendingSheet");
863 863
 		$pdf->MultiCell($w, 4, $title, '', 'R');
864 864
 
865
-		$pdf->SetFont('','', $default_font_size + 1);
865
+		$pdf->SetFont('', '', $default_font_size + 1);
866 866
 
867
-		$posy+=5;
867
+		$posy += 5;
868 868
 
869
-		$pdf->SetXY($posx,$posy);
870
-		$pdf->SetTextColor(0,0,60);
871
-		$pdf->MultiCell($w, 4, $outputlangs->transnoentities("RefSending") ." : ".$object->ref, '', 'R');
869
+		$pdf->SetXY($posx, $posy);
870
+		$pdf->SetTextColor(0, 0, 60);
871
+		$pdf->MultiCell($w, 4, $outputlangs->transnoentities("RefSending")." : ".$object->ref, '', 'R');
872 872
 
873 873
 		// Date planned delivery
874
-		if (! empty($object->date_delivery))
874
+		if (!empty($object->date_delivery))
875 875
 		{
876
-    			$posy+=4;
877
-    			$pdf->SetXY($posx,$posy);
878
-    			$pdf->SetTextColor(0,0,60);
879
-    			$pdf->MultiCell($w, 4, $outputlangs->transnoentities("DateDeliveryPlanned")." : ".dol_print_date($object->date_delivery,"day",false,$outputlangs,true), '', 'R');
876
+    			$posy += 4;
877
+    			$pdf->SetXY($posx, $posy);
878
+    			$pdf->SetTextColor(0, 0, 60);
879
+    			$pdf->MultiCell($w, 4, $outputlangs->transnoentities("DateDeliveryPlanned")." : ".dol_print_date($object->date_delivery, "day", false, $outputlangs, true), '', 'R');
880 880
 		}
881 881
 
882
-		if (! empty($object->thirdparty->code_client))
882
+		if (!empty($object->thirdparty->code_client))
883 883
 		{
884
-			$posy+=4;
885
-			$pdf->SetXY($posx,$posy);
886
-			$pdf->SetTextColor(0,0,60);
887
-			$pdf->MultiCell($w, 3, $outputlangs->transnoentities("CustomerCode")." : " . $outputlangs->transnoentities($object->thirdparty->code_client), '', 'R');
884
+			$posy += 4;
885
+			$pdf->SetXY($posx, $posy);
886
+			$pdf->SetTextColor(0, 0, 60);
887
+			$pdf->MultiCell($w, 3, $outputlangs->transnoentities("CustomerCode")." : ".$outputlangs->transnoentities($object->thirdparty->code_client), '', 'R');
888 888
 		}
889 889
 
890 890
 
891
-		$pdf->SetFont('','', $default_font_size + 3);
892
-		$Yoff=25;
891
+		$pdf->SetFont('', '', $default_font_size + 3);
892
+		$Yoff = 25;
893 893
 
894 894
 		// Add list of linked orders
895
-		$origin 	= $object->origin;
896
-		$origin_id 	= $object->origin_id;
895
+		$origin = $object->origin;
896
+		$origin_id = $object->origin_id;
897 897
 
898 898
 	    // TODO move to external function
899
-		if (! empty($conf->$origin->enabled))     // commonly $origin='commande'
899
+		if (!empty($conf->$origin->enabled))     // commonly $origin='commande'
900 900
 		{
901 901
 			$outputlangs->load('orders');
902 902
 
903 903
 			$classname = ucfirst($origin);
904 904
 			$linkedobject = new $classname($this->db);
905
-			$result=$linkedobject->fetch($origin_id);
905
+			$result = $linkedobject->fetch($origin_id);
906 906
 			if ($result >= 0)
907 907
 			{
908 908
 			    //$linkedobject->fetchObjectLinked()   Get all linked object to the $linkedobject (commonly order) into $linkedobject->linkedObjects
909 909
 
910
-				$pdf->SetFont('','', $default_font_size - 2);
911
-				$text=$linkedobject->ref;
912
-				if ($linkedobject->ref_client) $text.=' ('.$linkedobject->ref_client.')';
913
-				$Yoff = $Yoff+8;
914
-				$pdf->SetXY($this->page_largeur - $this->marge_droite - $w,$Yoff);
915
-				$pdf->MultiCell($w, 2, $outputlangs->transnoentities("RefOrder") ." : ".$outputlangs->transnoentities($text), 0, 'R');
916
-				$Yoff = $Yoff+3;
917
-				$pdf->SetXY($this->page_largeur - $this->marge_droite - $w,$Yoff);
918
-				$pdf->MultiCell($w, 2, $outputlangs->transnoentities("OrderDate")." : ".dol_print_date($linkedobject->date,"day",false,$outputlangs,true), 0, 'R');
910
+				$pdf->SetFont('', '', $default_font_size - 2);
911
+				$text = $linkedobject->ref;
912
+				if ($linkedobject->ref_client) $text .= ' ('.$linkedobject->ref_client.')';
913
+				$Yoff = $Yoff + 8;
914
+				$pdf->SetXY($this->page_largeur - $this->marge_droite - $w, $Yoff);
915
+				$pdf->MultiCell($w, 2, $outputlangs->transnoentities("RefOrder")." : ".$outputlangs->transnoentities($text), 0, 'R');
916
+				$Yoff = $Yoff + 3;
917
+				$pdf->SetXY($this->page_largeur - $this->marge_droite - $w, $Yoff);
918
+				$pdf->MultiCell($w, 2, $outputlangs->transnoentities("OrderDate")." : ".dol_print_date($linkedobject->date, "day", false, $outputlangs, true), 0, 'R');
919 919
 			}
920 920
 		}
921 921
 
922 922
 		if ($showaddress)
923 923
 		{
924 924
 			// Sender properties
925
-			$carac_emetteur='';
925
+			$carac_emetteur = '';
926 926
 		 	// Add internal contact of origin element if defined
927
-			$arrayidcontact=array();
928
-			if (! empty($origin) && is_object($object->$origin)) $arrayidcontact=$object->$origin->getIdContact('internal','SALESREPFOLL');
927
+			$arrayidcontact = array();
928
+			if (!empty($origin) && is_object($object->$origin)) $arrayidcontact = $object->$origin->getIdContact('internal', 'SALESREPFOLL');
929 929
 		 	if (count($arrayidcontact) > 0)
930 930
 		 	{
931 931
 		 		$object->fetch_user(reset($arrayidcontact));
932
-		 		$carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$outputlangs->transnoentities("Name").": ".$outputlangs->convToOutputCharset($object->user->getFullName($outputlangs))."\n";
932
+		 		$carac_emetteur .= ($carac_emetteur ? "\n" : '').$outputlangs->transnoentities("Name").": ".$outputlangs->convToOutputCharset($object->user->getFullName($outputlangs))."\n";
933 933
 		 	}
934 934
 
935 935
 		 	$carac_emetteur .= pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty);
936 936
 
937 937
 			// Show sender
938
-			$posy=!empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 40 : 42;
939
-			$posx=$this->marge_gauche;
940
-			if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->page_largeur-$this->marge_droite-80;
938
+			$posy = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 40 : 42;
939
+			$posx = $this->marge_gauche;
940
+			if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx = $this->page_largeur - $this->marge_droite - 80;
941 941
 
942
-			$hautcadre=!empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 38 : 40;
943
-			$widthrecbox=!empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 92 : 82;
942
+			$hautcadre = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 38 : 40;
943
+			$widthrecbox = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 92 : 82;
944 944
 
945 945
 			// Show sender frame
946
-			$pdf->SetTextColor(0,0,0);
947
-			$pdf->SetFont('','', $default_font_size - 2);
948
-			$pdf->SetXY($posx,$posy-5);
949
-			$pdf->MultiCell(66,5, $outputlangs->transnoentities("Sender").":", 0, 'L');
950
-			$pdf->SetXY($posx,$posy);
951
-			$pdf->SetFillColor(230,230,230);
946
+			$pdf->SetTextColor(0, 0, 0);
947
+			$pdf->SetFont('', '', $default_font_size - 2);
948
+			$pdf->SetXY($posx, $posy - 5);
949
+			$pdf->MultiCell(66, 5, $outputlangs->transnoentities("Sender").":", 0, 'L');
950
+			$pdf->SetXY($posx, $posy);
951
+			$pdf->SetFillColor(230, 230, 230);
952 952
 			$pdf->MultiCell($widthrecbox, $hautcadre, "", 0, 'R', 1);
953
-			$pdf->SetTextColor(0,0,60);
954
-			$pdf->SetFillColor(255,255,255);
953
+			$pdf->SetTextColor(0, 0, 60);
954
+			$pdf->SetFillColor(255, 255, 255);
955 955
 
956 956
 			// Show sender name
957
-			$pdf->SetXY($posx+2,$posy+3);
958
-			$pdf->SetFont('','B',$default_font_size);
959
-			$pdf->MultiCell($widthrecbox-2, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, 'L');
960
-			$posy=$pdf->getY();
957
+			$pdf->SetXY($posx + 2, $posy + 3);
958
+			$pdf->SetFont('', 'B', $default_font_size);
959
+			$pdf->MultiCell($widthrecbox - 2, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, 'L');
960
+			$posy = $pdf->getY();
961 961
 
962 962
 			// Show sender information
963
-			$pdf->SetXY($posx+2,$posy);
964
-			$pdf->SetFont('','', $default_font_size - 1);
965
-			$pdf->MultiCell($widthrecbox-2, 4, $carac_emetteur, 0, 'L');
963
+			$pdf->SetXY($posx + 2, $posy);
964
+			$pdf->SetFont('', '', $default_font_size - 1);
965
+			$pdf->MultiCell($widthrecbox - 2, 4, $carac_emetteur, 0, 'L');
966 966
 
967 967
 
968 968
 			// If SHIPPING contact defined, we use it
969
-			$usecontact=false;
970
-			$arrayidcontact=$object->$origin->getIdContact('external','SHIPPING');
969
+			$usecontact = false;
970
+			$arrayidcontact = $object->$origin->getIdContact('external', 'SHIPPING');
971 971
 			if (count($arrayidcontact) > 0)
972 972
 			{
973
-				$usecontact=true;
974
-				$result=$object->fetch_contact($arrayidcontact[0]);
973
+				$usecontact = true;
974
+				$result = $object->fetch_contact($arrayidcontact[0]);
975 975
 			}
976 976
 
977 977
 			//Recipient name
@@ -982,38 +982,38 @@  discard block
 block discarded – undo
982 982
 				$thirdparty = $object->thirdparty;
983 983
 			}
984 984
 
985
-			$carac_client_name= pdfBuildThirdpartyName($thirdparty, $outputlangs);
985
+			$carac_client_name = pdfBuildThirdpartyName($thirdparty, $outputlangs);
986 986
 
987
-			$carac_client=pdf_build_address($outputlangs,$this->emetteur,$object->thirdparty,(!empty($object->contact)?$object->contact:null),$usecontact,'targetwithdetails',$object);
987
+			$carac_client = pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, (!empty($object->contact) ? $object->contact : null), $usecontact, 'targetwithdetails', $object);
988 988
 
989 989
 			// Show recipient
990
-			$widthrecbox=!empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 92 : 100;
991
-			if ($this->page_largeur < 210) $widthrecbox=84;	// To work with US executive format
992
-			$posy=!empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 40 : 42;
993
-			$posx=$this->page_largeur - $this->marge_droite - $widthrecbox;
994
-			if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->marge_gauche;
990
+			$widthrecbox = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 92 : 100;
991
+			if ($this->page_largeur < 210) $widthrecbox = 84; // To work with US executive format
992
+			$posy = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 40 : 42;
993
+			$posx = $this->page_largeur - $this->marge_droite - $widthrecbox;
994
+			if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx = $this->marge_gauche;
995 995
 
996 996
 			// Show recipient frame
997
-			$pdf->SetTextColor(0,0,0);
998
-			$pdf->SetFont('','', $default_font_size - 2);
999
-			$pdf->SetXY($posx+2,$posy-5);
997
+			$pdf->SetTextColor(0, 0, 0);
998
+			$pdf->SetFont('', '', $default_font_size - 2);
999
+			$pdf->SetXY($posx + 2, $posy - 5);
1000 1000
 			$pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities("Recipient").":", 0, 'L');
1001 1001
 			$pdf->Rect($posx, $posy, $widthrecbox, $hautcadre);
1002 1002
 
1003 1003
 			// Show recipient name
1004
-			$pdf->SetXY($posx+2,$posy+3);
1005
-			$pdf->SetFont('','B', $default_font_size);
1004
+			$pdf->SetXY($posx + 2, $posy + 3);
1005
+			$pdf->SetFont('', 'B', $default_font_size);
1006 1006
 			$pdf->MultiCell($widthrecbox, 2, $carac_client_name, 0, 'L');
1007 1007
 
1008 1008
 			$posy = $pdf->getY();
1009 1009
 
1010 1010
 			// Show recipient information
1011
-			$pdf->SetFont('','', $default_font_size - 1);
1012
-			$pdf->SetXY($posx+2,$posy);
1011
+			$pdf->SetFont('', '', $default_font_size - 1);
1012
+			$pdf->SetXY($posx + 2, $posy);
1013 1013
 			$pdf->MultiCell($widthrecbox, 4, $carac_client, 0, 'L');
1014 1014
 		}
1015 1015
 
1016
-		$pdf->SetTextColor(0,0,0);
1016
+		$pdf->SetTextColor(0, 0, 0);
1017 1017
 	}
1018 1018
 
1019 1019
 	/**
@@ -1025,11 +1025,11 @@  discard block
 block discarded – undo
1025 1025
 	 *      @param	int			$hidefreetext		1=Hide free text
1026 1026
 	 *      @return	int								Return height of bottom margin including footer text
1027 1027
 	 */
1028
-	function _pagefoot(&$pdf,$object,$outputlangs,$hidefreetext=0)
1028
+	function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0)
1029 1029
 	{
1030 1030
 		global $conf;
1031
-		$showdetails=$conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS;
1032
-		return pdf_pagefoot($pdf,$outputlangs,'SHIPPING_FREE_TEXT',$this->emetteur,$this->marge_basse,$this->marge_gauche,$this->page_hauteur,$object,$showdetails,$hidefreetext);
1031
+		$showdetails = $conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS;
1032
+		return pdf_pagefoot($pdf, $outputlangs, 'SHIPPING_FREE_TEXT', $this->emetteur, $this->marge_basse, $this->marge_gauche, $this->page_hauteur, $object, $showdetails, $hidefreetext);
1033 1033
 	}
1034 1034
 
1035 1035
 }
Please login to merge, or discard this patch.
Braces   +129 added lines, -67 removed lines patch added patch discarded remove patch
@@ -65,7 +65,10 @@  discard block
 block discarded – undo
65 65
 
66 66
 		// Get source company
67 67
 		$this->emetteur=$mysoc;
68
-		if (! $this->emetteur->country_code) $this->emetteur->country_code=substr($langs->defaultlang,-2);    // By default if not defined
68
+		if (! $this->emetteur->country_code) {
69
+			$this->emetteur->country_code=substr($langs->defaultlang,-2);
70
+		}
71
+		// By default if not defined
69 72
 
70 73
 		// Define position of columns
71 74
 		$this->posxdesc=$this->marge_gauche+1;
@@ -85,9 +88,11 @@  discard block
 block discarded – undo
85 88
 
86 89
 		$this->posxpicture=$this->posxweightvol - (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH)?20:$conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH);	// width of images
87 90
 
88
-		if ($this->page_largeur < 210) // To work with US executive format
91
+		if ($this->page_largeur < 210) {
92
+			// To work with US executive format
89 93
 		{
90 94
 		    $this->posxweightvol-=20;
95
+		}
91 96
 		    $this->posxpicture-=20;
92 97
 		    $this->posxqtyordered-=20;
93 98
 		    $this->posxqtytoship-=20;
@@ -118,9 +123,13 @@  discard block
 block discarded – undo
118 123
 
119 124
 		$object->fetch_thirdparty();
120 125
 
121
-		if (! is_object($outputlangs)) $outputlangs=$langs;
126
+		if (! is_object($outputlangs)) {
127
+			$outputlangs=$langs;
128
+		}
122 129
 		// For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
123
-		if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1';
130
+		if (! empty($conf->global->MAIN_USE_FPDF)) {
131
+			$outputlangs->charset_output='ISO-8859-1';
132
+		}
124 133
 
125 134
 		$outputlangs->load("main");
126 135
 		$outputlangs->load("dict");
@@ -142,7 +151,9 @@  discard block
 block discarded – undo
142 151
 
143 152
             for ($i = 0 ; $i < $nblignes ; $i++)
144 153
             {
145
-                if (empty($object->lines[$i]->fk_product)) continue;
154
+                if (empty($object->lines[$i]->fk_product)) {
155
+                	continue;
156
+                }
146 157
 
147 158
 				$objphoto = new Product($this->db);
148 159
 				$objphoto->fetch($object->lines[$i]->fk_product);
@@ -154,18 +165,18 @@  discard block
 block discarded – undo
154 165
 
155 166
                 foreach ($objphoto->liste_photos($dir,1) as $key => $obj)
156 167
                         {
157
-                            if (empty($conf->global->CAT_HIGH_QUALITY_IMAGES))		// If CAT_HIGH_QUALITY_IMAGES not defined, we use thumb if defined and then original photo
168
+                            if (empty($conf->global->CAT_HIGH_QUALITY_IMAGES)) {
169
+                            	// If CAT_HIGH_QUALITY_IMAGES not defined, we use thumb if defined and then original photo
158 170
                             {
159 171
                                 if ($obj['photo_vignette'])
160 172
                                 {
161 173
                                     $filename= $obj['photo_vignette'];
162
-                                }
163
-                                else
174
+                            }
175
+                                } else
164 176
                                 {
165 177
                                     $filename=$obj['photo'];
166 178
                                 }
167
-                            }
168
-                            else
179
+                            } else
169 180
                             {
170 181
                                 $filename=$obj['photo'];
171 182
                             }
@@ -174,11 +185,15 @@  discard block
 block discarded – undo
174 185
                             break;
175 186
                 }
176 187
 
177
-                if ($realpath) $realpatharray[$i]=$realpath;
188
+                if ($realpath) {
189
+                	$realpatharray[$i]=$realpath;
190
+                }
178 191
             }
179 192
         }
180 193
 
181
-        if (count($realpatharray) == 0) $this->posxpicture=$this->posxweightvol;
194
+        if (count($realpatharray) == 0) {
195
+        	$this->posxpicture=$this->posxweightvol;
196
+        }
182 197
 
183 198
 		if ($conf->expedition->dir_output)
184 199
 		{
@@ -187,8 +202,7 @@  discard block
 block discarded – undo
187 202
 			{
188 203
 				$dir = $conf->expedition->dir_output."/sending";
189 204
 				$file = $dir . "/SPECIMEN.pdf";
190
-			}
191
-			else
205
+			} else
192 206
 			{
193 207
 				$expref = dol_sanitizeFileName($object->ref);
194 208
 				$dir = $conf->expedition->dir_output."/sending/" . $expref;
@@ -244,20 +258,26 @@  discard block
 block discarded – undo
244 258
 				$pagenb=0;
245 259
 				$pdf->SetDrawColor(128,128,128);
246 260
 
247
-				if (method_exists($pdf,'AliasNbPages')) $pdf->AliasNbPages();
261
+				if (method_exists($pdf,'AliasNbPages')) {
262
+					$pdf->AliasNbPages();
263
+				}
248 264
 
249 265
 				$pdf->SetTitle($outputlangs->convToOutputCharset($object->ref));
250 266
 				$pdf->SetSubject($outputlangs->transnoentities("Shipment"));
251 267
 				$pdf->SetCreator("Dolibarr ".DOL_VERSION);
252 268
 				$pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
253 269
 				$pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("Shipment"));
254
-				if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
270
+				if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) {
271
+					$pdf->SetCompression(false);
272
+				}
255 273
 
256 274
 				$pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);   // Left, Top, Right
257 275
 
258 276
 				// New page
259 277
 				$pdf->AddPage();
260
-				if (! empty($tplidx)) $pdf->useTemplate($tplidx);
278
+				if (! empty($tplidx)) {
279
+					$pdf->useTemplate($tplidx);
280
+				}
261 281
 				$pagenb++;
262 282
 				$this->_pagehead($pdf, $object, 1, $outputlangs);
263 283
 				$pdf->SetFont('','', $default_font_size - 1);
@@ -314,7 +334,9 @@  discard block
 block discarded – undo
314 334
 								// Get code using getLabelFromKey
315 335
 								$code=$outputlangs->getLabelFromKey($this->db,$object->shipping_method_id,'c_shipment_mode','rowid','code');
316 336
 								$label='';
317
-								if ($object->tracking_url != $object->tracking_number) $label.=$outputlangs->trans("LinkToTrackYourPackage")."<br>";
337
+								if ($object->tracking_url != $object->tracking_number) {
338
+									$label.=$outputlangs->trans("LinkToTrackYourPackage")."<br>";
339
+								}
318 340
 								$label.=$outputlangs->trans("SendingMethod").": ".$outputlangs->trans("SendingMethod".strtoupper($code));
319 341
 								//var_dump($object->tracking_url != $object->tracking_number);exit;
320 342
 								if ($object->tracking_url != $object->tracking_number)
@@ -346,8 +368,7 @@  discard block
 block discarded – undo
346 368
 
347 369
 					$tab_height = $tab_height - $height_note;
348 370
 					$tab_top = $nexY+6;
349
-				}
350
-				else
371
+				} else
351 372
 				{
352 373
 					$height_note=0;
353 374
 				}
@@ -365,7 +386,9 @@  discard block
 block discarded – undo
365 386
 
366 387
 					// Define size of image if we need it
367 388
 					$imglinesize=array();
368
-					if (! empty($realpatharray[$i])) $imglinesize=pdf_getSizeForImage($realpatharray[$i]);
389
+					if (! empty($realpatharray[$i])) {
390
+						$imglinesize=pdf_getSizeForImage($realpatharray[$i]);
391
+					}
369 392
 
370 393
 					$pdf->setTopMargin($tab_top_newpage);
371 394
 					$pdf->setPageOrientation('', 1, $heightforfooter+$heightforfreetext+$heightforinfotot);	// The only function to edit the bottom margin of current page to set it.
@@ -376,11 +399,17 @@  discard block
 block discarded – undo
376 399
 					$posYAfterDescription=0;
377 400
 
378 401
 					// We start with Photo of product line
379
-					if (isset($imglinesize['width']) && isset($imglinesize['height']) && ($curY + $imglinesize['height']) > ($this->page_hauteur-($heightforfooter+$heightforfreetext+$heightforinfotot)))	// If photo too high, we moved completely on new page
402
+					if (isset($imglinesize['width']) && isset($imglinesize['height']) && ($curY + $imglinesize['height']) > ($this->page_hauteur-($heightforfooter+$heightforfreetext+$heightforinfotot))) {
403
+						// If photo too high, we moved completely on new page
380 404
 					{
381 405
 						$pdf->AddPage('','',true);
382
-						if (! empty($tplidx)) $pdf->useTemplate($tplidx);
383
-						if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
406
+					}
407
+						if (! empty($tplidx)) {
408
+							$pdf->useTemplate($tplidx);
409
+						}
410
+						if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) {
411
+							$this->_pagehead($pdf, $object, 0, $outputlangs);
412
+						}
384 413
 						$pdf->setPage($pageposbefore+1);
385 414
 
386 415
 						$curY = $tab_top_newpage;
@@ -402,9 +431,11 @@  discard block
 block discarded – undo
402 431
 					pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->posxpicture-$curX,3,$curX,$curY,$hideref,$hidedesc);
403 432
 
404 433
 					$pageposafter=$pdf->getPage();
405
-					if ($pageposafter > $pageposbefore)	// There is a pagebreak
434
+					if ($pageposafter > $pageposbefore) {
435
+						// There is a pagebreak
406 436
 					{
407 437
 						$pdf->rollbackTransaction(true);
438
+					}
408 439
 						$pageposafter=$pageposbefore;
409 440
 						//print $pageposafter.'-'.$pageposbefore;exit;
410 441
 						$pdf->setPageOrientation('', 1, $heightforfooter);	// The only function to edit the bottom margin of current page to set it.
@@ -413,23 +444,27 @@  discard block
 block discarded – undo
413 444
 						$pageposafter=$pdf->getPage();
414 445
 						$posyafter=$pdf->GetY();
415 446
 						//var_dump($posyafter); var_dump(($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))); exit;
416
-						if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot)))	// There is no space left for total+free text
447
+						if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))) {
448
+							// There is no space left for total+free text
417 449
 						{
418 450
 							if ($i == ($nblignes-1))	// No more lines, and no space left to show total, so we create a new page
419 451
 							{
420 452
 								$pdf->AddPage('','',true);
421
-								if (! empty($tplidx)) $pdf->useTemplate($tplidx);
422
-								if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
453
+						}
454
+								if (! empty($tplidx)) {
455
+									$pdf->useTemplate($tplidx);
456
+								}
457
+								if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) {
458
+									$this->_pagehead($pdf, $object, 0, $outputlangs);
459
+								}
423 460
 								$pdf->setPage($pageposafter+1);
424 461
 							}
425
-						}
426
-						else
462
+						} else
427 463
 						{
428 464
 							// We found a page break
429 465
 							$showpricebeforepagebreak=0;
430 466
 						}
431
-					}
432
-					else	// No pagebreak
467
+					} else	// No pagebreak
433 468
 					{
434 469
 						$pdf->commitTransaction();
435 470
 					}
@@ -488,7 +523,9 @@  discard block
 block discarded – undo
488 523
 					}
489 524
 
490 525
 					$nexY+=3;
491
-					if ($weighttxt && $voltxt) $nexY+=2;
526
+					if ($weighttxt && $voltxt) {
527
+						$nexY+=2;
528
+					}
492 529
 
493 530
 					// Add line
494 531
 					if (! empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblignes - 1))
@@ -507,8 +544,7 @@  discard block
 block discarded – undo
507 544
 						if ($pagenb == 1)
508 545
 						{
509 546
 							$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1);
510
-						}
511
-						else
547
+						} else
512 548
 						{
513 549
 							$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
514 550
 						}
@@ -522,15 +558,16 @@  discard block
 block discarded – undo
522 558
 						if ($pagenb == 1)
523 559
 						{
524 560
 							$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1);
525
-						}
526
-						else
561
+						} else
527 562
 						{
528 563
 							$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
529 564
 						}
530 565
 						$this->_pagefoot($pdf,$object,$outputlangs,1);
531 566
 						// New page
532 567
 						$pdf->AddPage();
533
-						if (! empty($tplidx)) $pdf->useTemplate($tplidx);
568
+						if (! empty($tplidx)) {
569
+							$pdf->useTemplate($tplidx);
570
+						}
534 571
 						$pagenb++;
535 572
 					}
536 573
 				}
@@ -540,8 +577,7 @@  discard block
 block discarded – undo
540 577
 				{
541 578
 					$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0);
542 579
 					$bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
543
-				}
544
-				else
580
+				} else
545 581
 				{
546 582
 					$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0);
547 583
 					$bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
@@ -552,7 +588,9 @@  discard block
 block discarded – undo
552 588
 
553 589
 				// Pied de page
554 590
 				$this->_pagefoot($pdf,$object,$outputlangs);
555
-				if (method_exists($pdf,'AliasNbPages')) $pdf->AliasNbPages();
591
+				if (method_exists($pdf,'AliasNbPages')) {
592
+					$pdf->AliasNbPages();
593
+				}
556 594
 
557 595
 				$pdf->Close();
558 596
 
@@ -564,20 +602,19 @@  discard block
 block discarded – undo
564 602
 				global $action;
565 603
 				$reshook=$hookmanager->executeHooks('afterPDFCreation',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
566 604
 
567
-				if (! empty($conf->global->MAIN_UMASK))
568
-				@chmod($file, octdec($conf->global->MAIN_UMASK));
605
+				if (! empty($conf->global->MAIN_UMASK)) {
606
+								@chmod($file, octdec($conf->global->MAIN_UMASK));
607
+				}
569 608
 
570 609
 				$this->result = array('fullpath'=>$file);
571 610
 
572 611
 				return 1;	// No error
573
-			}
574
-			else
612
+			} else
575 613
 			{
576 614
 				$this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
577 615
 				return 0;
578 616
 			}
579
-		}
580
-		else
617
+		} else
581 618
 		{
582 619
 			$this->error=$langs->transnoentities("ErrorConstantNotDefined","EXP_OUTPUTDIR");
583 620
 			return 0;
@@ -612,8 +649,11 @@  discard block
 block discarded – undo
612 649
 		{
613 650
 			$col2x-=20;
614 651
 		}*/
615
-		if (empty($conf->global->SHIPPING_PDF_HIDE_ORDERED)) $largcol2 = ($this->posxqtyordered - $this->posxweightvol);
616
-		else $largcol2 = ($this->posxqtytoship - $this->posxweightvol);
652
+		if (empty($conf->global->SHIPPING_PDF_HIDE_ORDERED)) {
653
+			$largcol2 = ($this->posxqtyordered - $this->posxweightvol);
654
+		} else {
655
+			$largcol2 = ($this->posxqtytoship - $this->posxweightvol);
656
+		}
617 657
 
618 658
 		$useborder=0;
619 659
 		$index = 0;
@@ -634,10 +674,18 @@  discard block
 block discarded – undo
634 674
 		    $object->volume_units=$object->size_units * 3;
635 675
 		}
636 676
 
637
-		if ($totalWeight!='') $totalWeighttoshow=showDimensionInBestUnit($totalWeight, 0, "weight", $outputlangs);
638
-		if ($totalVolume!='') $totalVolumetoshow=showDimensionInBestUnit($totalVolume, 0, "volume", $outputlangs);
639
-		if ($object->trueWeight) $totalWeighttoshow=showDimensionInBestUnit($object->trueWeight, $object->weight_units, "weight", $outputlangs);
640
-		if ($object->trueVolume) $totalVolumetoshow=showDimensionInBestUnit($object->trueVolume, $object->volume_units, "volume", $outputlangs);
677
+		if ($totalWeight!='') {
678
+			$totalWeighttoshow=showDimensionInBestUnit($totalWeight, 0, "weight", $outputlangs);
679
+		}
680
+		if ($totalVolume!='') {
681
+			$totalVolumetoshow=showDimensionInBestUnit($totalVolume, 0, "volume", $outputlangs);
682
+		}
683
+		if ($object->trueWeight) {
684
+			$totalWeighttoshow=showDimensionInBestUnit($object->trueWeight, $object->weight_units, "weight", $outputlangs);
685
+		}
686
+		if ($object->trueVolume) {
687
+			$totalVolumetoshow=showDimensionInBestUnit($object->trueVolume, $object->volume_units, "volume", $outputlangs);
688
+		}
641 689
 
642 690
     	$pdf->SetFillColor(255,255,255);
643 691
     	$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
@@ -677,7 +725,9 @@  discard block
 block discarded – undo
677 725
 
678 726
 		    $index++;
679 727
 		}
680
-		if (! $totalWeighttoshow && ! $totalVolumetoshow) $index++;
728
+		if (! $totalWeighttoshow && ! $totalVolumetoshow) {
729
+			$index++;
730
+		}
681 731
 
682 732
 		$pdf->SetTextColor(0,0,0);
683 733
 
@@ -702,7 +752,9 @@  discard block
 block discarded – undo
702 752
 
703 753
 		// Force to disable hidetop and hidebottom
704 754
 		$hidebottom=0;
705
-		if ($hidetop) $hidetop=-1;
755
+		if ($hidetop) {
756
+			$hidetop=-1;
757
+		}
706 758
 
707 759
 		$default_font_size = pdf_getPDFFontSize($outputlangs);
708 760
 
@@ -812,16 +864,14 @@  discard block
 block discarded – undo
812 864
 			{
813 865
 			    $height=pdf_getHeightForLogo($logo);
814 866
 			    $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);	// width=0 (auto)
815
-			}
816
-			else
867
+			} else
817 868
 			{
818 869
 				$pdf->SetTextColor(200,0,0);
819 870
 				$pdf->SetFont('','B', $default_font_size - 2);
820 871
 				$pdf->MultiCell($w, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound",$logo), 0, 'L');
821 872
 				$pdf->MultiCell($w, 3, $outputlangs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L');
822 873
 			}
823
-		}
824
-		else
874
+		} else
825 875
 		{
826 876
 			$text=$this->emetteur->name;
827 877
 			$pdf->MultiCell($w, 4, $outputlangs->convToOutputCharset($text), 0, 'L');
@@ -831,8 +881,7 @@  discard block
 block discarded – undo
831 881
 		if (! empty($conf->barcode->enabled))
832 882
 		{
833 883
 			$posx=105;
834
-		}
835
-		else
884
+		} else
836 885
 		{
837 886
 			$posx=$this->marge_gauche+3;
838 887
 		}
@@ -896,9 +945,11 @@  discard block
 block discarded – undo
896 945
 		$origin_id 	= $object->origin_id;
897 946
 
898 947
 	    // TODO move to external function
899
-		if (! empty($conf->$origin->enabled))     // commonly $origin='commande'
948
+		if (! empty($conf->$origin->enabled)) {
949
+			// commonly $origin='commande'
900 950
 		{
901 951
 			$outputlangs->load('orders');
952
+		}
902 953
 
903 954
 			$classname = ucfirst($origin);
904 955
 			$linkedobject = new $classname($this->db);
@@ -909,7 +960,9 @@  discard block
 block discarded – undo
909 960
 
910 961
 				$pdf->SetFont('','', $default_font_size - 2);
911 962
 				$text=$linkedobject->ref;
912
-				if ($linkedobject->ref_client) $text.=' ('.$linkedobject->ref_client.')';
963
+				if ($linkedobject->ref_client) {
964
+					$text.=' ('.$linkedobject->ref_client.')';
965
+				}
913 966
 				$Yoff = $Yoff+8;
914 967
 				$pdf->SetXY($this->page_largeur - $this->marge_droite - $w,$Yoff);
915 968
 				$pdf->MultiCell($w, 2, $outputlangs->transnoentities("RefOrder") ." : ".$outputlangs->transnoentities($text), 0, 'R');
@@ -925,7 +978,9 @@  discard block
 block discarded – undo
925 978
 			$carac_emetteur='';
926 979
 		 	// Add internal contact of origin element if defined
927 980
 			$arrayidcontact=array();
928
-			if (! empty($origin) && is_object($object->$origin)) $arrayidcontact=$object->$origin->getIdContact('internal','SALESREPFOLL');
981
+			if (! empty($origin) && is_object($object->$origin)) {
982
+				$arrayidcontact=$object->$origin->getIdContact('internal','SALESREPFOLL');
983
+			}
929 984
 		 	if (count($arrayidcontact) > 0)
930 985
 		 	{
931 986
 		 		$object->fetch_user(reset($arrayidcontact));
@@ -937,7 +992,9 @@  discard block
 block discarded – undo
937 992
 			// Show sender
938 993
 			$posy=!empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 40 : 42;
939 994
 			$posx=$this->marge_gauche;
940
-			if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->page_largeur-$this->marge_droite-80;
995
+			if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) {
996
+				$posx=$this->page_largeur-$this->marge_droite-80;
997
+			}
941 998
 
942 999
 			$hautcadre=!empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 38 : 40;
943 1000
 			$widthrecbox=!empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 92 : 82;
@@ -988,10 +1045,15 @@  discard block
 block discarded – undo
988 1045
 
989 1046
 			// Show recipient
990 1047
 			$widthrecbox=!empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 92 : 100;
991
-			if ($this->page_largeur < 210) $widthrecbox=84;	// To work with US executive format
1048
+			if ($this->page_largeur < 210) {
1049
+				$widthrecbox=84;
1050
+			}
1051
+			// To work with US executive format
992 1052
 			$posy=!empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 40 : 42;
993 1053
 			$posx=$this->page_largeur - $this->marge_droite - $widthrecbox;
994
-			if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->marge_gauche;
1054
+			if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) {
1055
+				$posx=$this->marge_gauche;
1056
+			}
995 1057
 
996 1058
 			// Show recipient frame
997 1059
 			$pdf->SetTextColor(0,0,0);
Please login to merge, or discard this patch.
htdocs/core/modules/fichinter/mod_arctic.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -101,7 +101,7 @@
 block discarded – undo
101 101
 	/**
102 102
 	 * 	Return next free value
103 103
 	 *
104
-	 *  @param	Societe		$objsoc     Object thirdparty
104
+	 *  @param	integer		$objsoc     Object thirdparty
105 105
 	 *  @param  Object		$object		Object we need next value for
106 106
 	 *  @return string      			Value if KO, <0 if KO
107 107
 	 */
Please login to merge, or discard this patch.
Indentation   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -38,13 +38,13 @@  discard block
 block discarded – undo
38 38
 
39 39
 
40 40
 	/**
41
-     *  Renvoi la description du modele de numerotation
42
-     *
43
-     *  @return     string      Texte descripif
44
-     */
41
+	 *  Renvoi la description du modele de numerotation
42
+	 *
43
+	 *  @return     string      Texte descripif
44
+	 */
45 45
 	function info()
46
-    {
47
-    	global $conf,$langs;
46
+	{
47
+		global $conf,$langs;
48 48
 
49 49
 		$langs->load("bills");
50 50
 
@@ -75,20 +75,20 @@  discard block
 block discarded – undo
75 75
 		$texte.= '</form>';
76 76
 
77 77
 		return $texte;
78
-    }
79
-
80
-    /**
81
-     * Renvoi un exemple de numerotation
82
-     *
83
-     * @return     string      Example
84
-     */
85
-    function getExample()
86
-    {
87
-     	global $conf,$langs,$mysoc;
88
-
89
-    	$old_code_client=$mysoc->code_client;
90
-    	$mysoc->code_client='CCCCCCCCCC';
91
-     	$numExample = $this->getNextValue($mysoc,'');
78
+	}
79
+
80
+	/**
81
+	 * Renvoi un exemple de numerotation
82
+	 *
83
+	 * @return     string      Example
84
+	 */
85
+	function getExample()
86
+	{
87
+	 	global $conf,$langs,$mysoc;
88
+
89
+		$old_code_client=$mysoc->code_client;
90
+		$mysoc->code_client='CCCCCCCCCC';
91
+	 	$numExample = $this->getNextValue($mysoc,'');
92 92
 		$mysoc->code_client=$old_code_client;
93 93
 
94 94
 		if (! $numExample)
@@ -96,7 +96,7 @@  discard block
 block discarded – undo
96 96
 			$numExample = $langs->trans('NotConfigured');
97 97
 		}
98 98
 		return $numExample;
99
-    }
99
+	}
100 100
 
101 101
 	/**
102 102
 	 * 	Return next free value
@@ -105,8 +105,8 @@  discard block
 block discarded – undo
105 105
 	 *  @param  Object		$object		Object we need next value for
106 106
 	 *  @return string      			Value if KO, <0 if KO
107 107
 	 */
108
-    function getNextValue($objsoc=0,$object='')
109
-    {
108
+	function getNextValue($objsoc=0,$object='')
109
+	{
110 110
 		global $db,$conf;
111 111
 
112 112
 		require_once DOL_DOCUMENT_ROOT .'/core/lib/functions2.lib.php';
@@ -129,14 +129,14 @@  discard block
 block discarded – undo
129 129
 	/**
130 130
 	 * 	Return next free value
131 131
 	 *
132
-     *  @param	Societe		$objsoc     Object third party
132
+	 *  @param	Societe		$objsoc     Object third party
133 133
 	 * 	@param	Object		$objforref	Object for number to search
134
-     *  @return string      			Next free value
135
-     */
136
-    function getNumRef($objsoc,$objforref)
137
-    {
138
-        return $this->getNextValue($objsoc,$objforref);
139
-    }
134
+	 *  @return string      			Next free value
135
+	 */
136
+	function getNumRef($objsoc,$objforref)
137
+	{
138
+		return $this->getNextValue($objsoc,$objforref);
139
+	}
140 140
 
141 141
 }
142 142
 
Please login to merge, or discard this patch.
Spacing   +35 added lines, -35 removed lines patch added patch discarded remove patch
@@ -25,14 +25,14 @@  discard block
 block discarded – undo
25 25
  *	\ingroup    fiche intervention
26 26
  *	\brief      File with Arctic numbering module for interventions
27 27
  */
28
-require_once DOL_DOCUMENT_ROOT .'/core/modules/fichinter/modules_fichinter.php';
28
+require_once DOL_DOCUMENT_ROOT.'/core/modules/fichinter/modules_fichinter.php';
29 29
 
30 30
 /**
31 31
  *	Class to manage numbering of intervention cards with rule Artic.
32 32
  */
33 33
 class mod_arctic extends ModeleNumRefFicheinter
34 34
 {
35
-	var $version='dolibarr';		// 'development', 'experimental', 'dolibarr'
35
+	var $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr'
36 36
 	var $error = '';
37 37
 	var $nom = 'arctic';
38 38
 
@@ -44,35 +44,35 @@  discard block
 block discarded – undo
44 44
      */
45 45
 	function info()
46 46
     {
47
-    	global $conf,$langs;
47
+    	global $conf, $langs;
48 48
 
49 49
 		$langs->load("bills");
50 50
 
51 51
 		$form = new Form($this->db);
52 52
 
53 53
 		$texte = $langs->trans('GenericNumRefModelDesc')."<br>\n";
54
-		$texte.= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
55
-		$texte.= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
56
-		$texte.= '<input type="hidden" name="action" value="updateMask">';
57
-		$texte.= '<input type="hidden" name="maskconst" value="FICHINTER_ARTIC_MASK">';
58
-		$texte.= '<table class="nobordernopadding" width="100%">';
59
-
60
-		$tooltip=$langs->trans("GenericMaskCodes",$langs->transnoentities("InterventionCard"),$langs->transnoentities("InterventionCard"));
61
-		$tooltip.=$langs->trans("GenericMaskCodes2");
62
-		$tooltip.=$langs->trans("GenericMaskCodes3");
63
-		$tooltip.=$langs->trans("GenericMaskCodes4a",$langs->transnoentities("InterventionCard"),$langs->transnoentities("InterventionCard"));
64
-		$tooltip.=$langs->trans("GenericMaskCodes5");
54
+		$texte .= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
55
+		$texte .= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
56
+		$texte .= '<input type="hidden" name="action" value="updateMask">';
57
+		$texte .= '<input type="hidden" name="maskconst" value="FICHINTER_ARTIC_MASK">';
58
+		$texte .= '<table class="nobordernopadding" width="100%">';
59
+
60
+		$tooltip = $langs->trans("GenericMaskCodes", $langs->transnoentities("InterventionCard"), $langs->transnoentities("InterventionCard"));
61
+		$tooltip .= $langs->trans("GenericMaskCodes2");
62
+		$tooltip .= $langs->trans("GenericMaskCodes3");
63
+		$tooltip .= $langs->trans("GenericMaskCodes4a", $langs->transnoentities("InterventionCard"), $langs->transnoentities("InterventionCard"));
64
+		$tooltip .= $langs->trans("GenericMaskCodes5");
65 65
 
66 66
 		// Parametrage du prefix
67
-		$texte.= '<tr><td>'.$langs->trans("Mask").':</td>';
68
-		$texte.= '<td align="right">'.$form->textwithpicto('<input type="text" class="flat" size="24" name="maskvalue" value="'.$conf->global->FICHINTER_ARTIC_MASK.'">',$tooltip,1,1).'</td>';
67
+		$texte .= '<tr><td>'.$langs->trans("Mask").':</td>';
68
+		$texte .= '<td align="right">'.$form->textwithpicto('<input type="text" class="flat" size="24" name="maskvalue" value="'.$conf->global->FICHINTER_ARTIC_MASK.'">', $tooltip, 1, 1).'</td>';
69 69
 
70
-		$texte.= '<td align="left" rowspan="2">&nbsp; <input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button"></td>';
70
+		$texte .= '<td align="left" rowspan="2">&nbsp; <input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button"></td>';
71 71
 
72
-		$texte.= '</tr>';
72
+		$texte .= '</tr>';
73 73
 
74
-		$texte.= '</table>';
75
-		$texte.= '</form>';
74
+		$texte .= '</table>';
75
+		$texte .= '</form>';
76 76
 
77 77
 		return $texte;
78 78
     }
@@ -84,14 +84,14 @@  discard block
 block discarded – undo
84 84
      */
85 85
     function getExample()
86 86
     {
87
-     	global $conf,$langs,$mysoc;
87
+     	global $conf, $langs, $mysoc;
88 88
 
89
-    	$old_code_client=$mysoc->code_client;
90
-    	$mysoc->code_client='CCCCCCCCCC';
91
-     	$numExample = $this->getNextValue($mysoc,'');
92
-		$mysoc->code_client=$old_code_client;
89
+    	$old_code_client = $mysoc->code_client;
90
+    	$mysoc->code_client = 'CCCCCCCCCC';
91
+     	$numExample = $this->getNextValue($mysoc, '');
92
+		$mysoc->code_client = $old_code_client;
93 93
 
94
-		if (! $numExample)
94
+		if (!$numExample)
95 95
 		{
96 96
 			$numExample = $langs->trans('NotConfigured');
97 97
 		}
@@ -105,22 +105,22 @@  discard block
 block discarded – undo
105 105
 	 *  @param  Object		$object		Object we need next value for
106 106
 	 *  @return string      			Value if KO, <0 if KO
107 107
 	 */
108
-    function getNextValue($objsoc=0,$object='')
108
+    function getNextValue($objsoc = 0, $object = '')
109 109
     {
110
-		global $db,$conf;
110
+		global $db, $conf;
111 111
 
112
-		require_once DOL_DOCUMENT_ROOT .'/core/lib/functions2.lib.php';
112
+		require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
113 113
 
114 114
 		// On d�fini critere recherche compteur
115
-		$mask=$conf->global->FICHINTER_ARTIC_MASK;
115
+		$mask = $conf->global->FICHINTER_ARTIC_MASK;
116 116
 
117
-		if (! $mask)
117
+		if (!$mask)
118 118
 		{
119
-			$this->error='NotConfigured';
119
+			$this->error = 'NotConfigured';
120 120
 			return 0;
121 121
 		}
122 122
 
123
-		$numFinal=get_next_value($db,$mask,'fichinter','ref','',$objsoc,$object->datec);
123
+		$numFinal = get_next_value($db, $mask, 'fichinter', 'ref', '', $objsoc, $object->datec);
124 124
 
125 125
 		return  $numFinal;
126 126
   }
@@ -133,9 +133,9 @@  discard block
 block discarded – undo
133 133
 	 * 	@param	Object		$objforref	Object for number to search
134 134
      *  @return string      			Next free value
135 135
      */
136
-    function getNumRef($objsoc,$objforref)
136
+    function getNumRef($objsoc, $objforref)
137 137
     {
138
-        return $this->getNextValue($objsoc,$objforref);
138
+        return $this->getNextValue($objsoc, $objforref);
139 139
     }
140 140
 
141 141
 }
Please login to merge, or discard this patch.