@@ -27,7 +27,7 @@ discard block |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 | { |
@@ -86,16 +86,19 @@ discard block |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 | |
@@ -712,23 +852,58 @@ discard block |
||
| 712 | 852 | $countryfound=1; |
| 713 | 853 | |
| 714 | 854 | // Definition des dates feriees fixes |
| 715 | - if($jour == 1 && $mois == 1) $ferie=true; // Neujahr |
|
| 716 | - if($jour == 6 && $mois == 1) $ferie=true; // Hl. 3 Koenige |
|
| 717 | - if($jour == 1 && $mois == 5) $ferie=true; // 1. Mai |
|
| 718 | - if($jour == 15 && $mois == 8) $ferie=true; // Mariae Himmelfahrt |
|
| 719 | - if($jour == 26 && $mois == 10) $ferie=true; // 26. Oktober |
|
| 720 | - if($jour == 1 && $mois == 11) $ferie=true; // Allerheiligen |
|
| 721 | - if($jour == 8 && $mois == 12) $ferie=true; // Mariae Empfaengnis |
|
| 722 | - if($jour == 24 && $mois == 12) $ferie=true; // Heilig abend |
|
| 723 | - if($jour == 25 && $mois == 12) $ferie=true; // Christtag |
|
| 724 | - if($jour == 26 && $mois == 12) $ferie=true; // Stefanietag |
|
| 725 | - if($jour == 31 && $mois == 12) $ferie=true; // Silvester |
|
| 855 | + if($jour == 1 && $mois == 1) { |
|
| 856 | + $ferie=true; |
|
| 857 | + } |
|
| 858 | + // Neujahr |
|
| 859 | + if($jour == 6 && $mois == 1) { |
|
| 860 | + $ferie=true; |
|
| 861 | + } |
|
| 862 | + // Hl. 3 Koenige |
|
| 863 | + if($jour == 1 && $mois == 5) { |
|
| 864 | + $ferie=true; |
|
| 865 | + } |
|
| 866 | + // 1. Mai |
|
| 867 | + if($jour == 15 && $mois == 8) { |
|
| 868 | + $ferie=true; |
|
| 869 | + } |
|
| 870 | + // Mariae Himmelfahrt |
|
| 871 | + if($jour == 26 && $mois == 10) { |
|
| 872 | + $ferie=true; |
|
| 873 | + } |
|
| 874 | + // 26. Oktober |
|
| 875 | + if($jour == 1 && $mois == 11) { |
|
| 876 | + $ferie=true; |
|
| 877 | + } |
|
| 878 | + // Allerheiligen |
|
| 879 | + if($jour == 8 && $mois == 12) { |
|
| 880 | + $ferie=true; |
|
| 881 | + } |
|
| 882 | + // Mariae Empfaengnis |
|
| 883 | + if($jour == 24 && $mois == 12) { |
|
| 884 | + $ferie=true; |
|
| 885 | + } |
|
| 886 | + // Heilig abend |
|
| 887 | + if($jour == 25 && $mois == 12) { |
|
| 888 | + $ferie=true; |
|
| 889 | + } |
|
| 890 | + // Christtag |
|
| 891 | + if($jour == 26 && $mois == 12) { |
|
| 892 | + $ferie=true; |
|
| 893 | + } |
|
| 894 | + // Stefanietag |
|
| 895 | + if($jour == 31 && $mois == 12) { |
|
| 896 | + $ferie=true; |
|
| 897 | + } |
|
| 898 | + // Silvester |
|
| 726 | 899 | |
| 727 | 900 | // Easter calculation |
| 728 | 901 | $date_paques = easter_date($annee); |
| 729 | 902 | $jour_paques = date("d", $date_paques); |
| 730 | 903 | $mois_paques = date("m", $date_paques); |
| 731 | - if($jour_paques == $jour && $mois_paques == $mois) $ferie=true; |
|
| 904 | + if($jour_paques == $jour && $mois_paques == $mois) { |
|
| 905 | + $ferie=true; |
|
| 906 | + } |
|
| 732 | 907 | // Easter sunday |
| 733 | 908 | |
| 734 | 909 | // Monday after easter |
@@ -742,7 +917,9 @@ discard block |
||
| 742 | 917 | ); |
| 743 | 918 | $jour_eastermonday = date("d", $date_eastermonday); |
| 744 | 919 | $mois_eastermonday = date("m", $date_eastermonday); |
| 745 | - if($jour_eastermonday == $jour && $mois_eastermonday == $mois) $ferie=true; |
|
| 920 | + if($jour_eastermonday == $jour && $mois_eastermonday == $mois) { |
|
| 921 | + $ferie=true; |
|
| 922 | + } |
|
| 746 | 923 | // Easter monday |
| 747 | 924 | |
| 748 | 925 | // Christi Himmelfahrt (39 days after easter sunday) |
@@ -756,7 +933,9 @@ discard block |
||
| 756 | 933 | ); |
| 757 | 934 | $jour_ch = date("d", $date_ch); |
| 758 | 935 | $mois_ch = date("m", $date_ch); |
| 759 | - if($jour_ch == $jour && $mois_ch == $mois) $ferie=true; |
|
| 936 | + if($jour_ch == $jour && $mois_ch == $mois) { |
|
| 937 | + $ferie=true; |
|
| 938 | + } |
|
| 760 | 939 | // Christi Himmelfahrt |
| 761 | 940 | |
| 762 | 941 | // Pfingsten (50 days after easter sunday) |
@@ -770,7 +949,9 @@ discard block |
||
| 770 | 949 | ); |
| 771 | 950 | $jour_pentecote = date("d", $date_pentecote); |
| 772 | 951 | $mois_pentecote = date("m", $date_pentecote); |
| 773 | - if($jour_pentecote == $jour && $mois_pentecote == $mois) $ferie=true; |
|
| 952 | + if($jour_pentecote == $jour && $mois_pentecote == $mois) { |
|
| 953 | + $ferie=true; |
|
| 954 | + } |
|
| 774 | 955 | // Pfingsten |
| 775 | 956 | |
| 776 | 957 | // Fronleichnam (60 days after easter sunday) |
@@ -784,13 +965,17 @@ discard block |
||
| 784 | 965 | ); |
| 785 | 966 | $jour_fronleichnam = date("d", $date_fronleichnam); |
| 786 | 967 | $mois_fronleichnam = date("m", $date_fronleichnam); |
| 787 | - if($jour_fronleichnam == $jour && $mois_fronleichnam == $mois) $ferie=true; |
|
| 968 | + if($jour_fronleichnam == $jour && $mois_fronleichnam == $mois) { |
|
| 969 | + $ferie=true; |
|
| 970 | + } |
|
| 788 | 971 | // Fronleichnam |
| 789 | 972 | |
| 790 | 973 | // Calul des samedis et dimanches |
| 791 | 974 | $jour_julien = unixtojd($timestampStart); |
| 792 | 975 | $jour_semaine = jddayofweek($jour_julien, 0); |
| 793 | - if($jour_semaine == 0 || $jour_semaine == 6) $ferie=true; |
|
| 976 | + if($jour_semaine == 0 || $jour_semaine == 6) { |
|
| 977 | + $ferie=true; |
|
| 978 | + } |
|
| 794 | 979 | //Samedi (6) et dimanche (0) |
| 795 | 980 | } |
| 796 | 981 | |
@@ -800,12 +985,16 @@ discard block |
||
| 800 | 985 | // Calul des samedis et dimanches |
| 801 | 986 | $jour_julien = unixtojd($timestampStart); |
| 802 | 987 | $jour_semaine = jddayofweek($jour_julien, 0); |
| 803 | - if($jour_semaine == 0 || $jour_semaine == 6) $ferie=true; |
|
| 988 | + if($jour_semaine == 0 || $jour_semaine == 6) { |
|
| 989 | + $ferie=true; |
|
| 990 | + } |
|
| 804 | 991 | //Samedi (6) et dimanche (0) |
| 805 | 992 | } |
| 806 | 993 | |
| 807 | 994 | // On incremente compteur |
| 808 | - if ($ferie) $nbFerie++; |
|
| 995 | + if ($ferie) { |
|
| 996 | + $nbFerie++; |
|
| 997 | + } |
|
| 809 | 998 | |
| 810 | 999 | // Increase number of days (on go up into loop) |
| 811 | 1000 | $timestampStart=dol_time_plus_duree($timestampStart, 1, 'd'); |
@@ -834,8 +1023,7 @@ discard block |
||
| 834 | 1023 | if ($lastday == 1) |
| 835 | 1024 | { |
| 836 | 1025 | $bit = 0; |
| 837 | - } |
|
| 838 | - else |
|
| 1026 | + } else |
|
| 839 | 1027 | { |
| 840 | 1028 | $bit = 1; |
| 841 | 1029 | } |
@@ -861,13 +1049,19 @@ discard block |
||
| 861 | 1049 | { |
| 862 | 1050 | global $langs,$mysoc; |
| 863 | 1051 | |
| 864 | - if (empty($country_code)) $country_code=$mysoc->country_code; |
|
| 1052 | + if (empty($country_code)) { |
|
| 1053 | + $country_code=$mysoc->country_code; |
|
| 1054 | + } |
|
| 865 | 1055 | |
| 866 | 1056 | dol_syslog('num_open_day timestampStart='.$timestampStart.' timestampEnd='.$timestampEnd.' bit='.$lastday.' country_code='.$country_code); |
| 867 | 1057 | |
| 868 | 1058 | // Check parameters |
| 869 | - if (! is_int($timestampStart) && ! is_float($timestampStart)) return 'ErrorBadParameter_num_open_day'; |
|
| 870 | - if (! is_int($timestampEnd) && ! is_float($timestampEnd)) return 'ErrorBadParameter_num_open_day'; |
|
| 1059 | + if (! is_int($timestampStart) && ! is_float($timestampStart)) { |
|
| 1060 | + return 'ErrorBadParameter_num_open_day'; |
|
| 1061 | + } |
|
| 1062 | + if (! is_int($timestampEnd) && ! is_float($timestampEnd)) { |
|
| 1063 | + return 'ErrorBadParameter_num_open_day'; |
|
| 1064 | + } |
|
| 871 | 1065 | |
| 872 | 1066 | //print 'num_open_day timestampStart='.$timestampStart.' timestampEnd='.$timestampEnd.' bit='.$lastday; |
| 873 | 1067 | if ($timestampStart < $timestampEnd) |
@@ -876,16 +1070,18 @@ discard block |
||
| 876 | 1070 | $numholidays = num_public_holiday($timestampStart, $timestampEnd, $country_code, $lastday); |
| 877 | 1071 | $nbOpenDay = $numdays - $numholidays; |
| 878 | 1072 | $nbOpenDay.= " " . $langs->trans("Days"); |
| 879 | - if ($inhour == 1 && $nbOpenDay <= 3) $nbOpenDay = $nbOpenDay*24 . $langs->trans("HourShort"); |
|
| 1073 | + if ($inhour == 1 && $nbOpenDay <= 3) { |
|
| 1074 | + $nbOpenDay = $nbOpenDay*24 . $langs->trans("HourShort"); |
|
| 1075 | + } |
|
| 880 | 1076 | return $nbOpenDay - (($inhour == 1 ? 12 : 0.5) * abs($halfday)); |
| 881 | - } |
|
| 882 | - elseif ($timestampStart == $timestampEnd) |
|
| 1077 | + } elseif ($timestampStart == $timestampEnd) |
|
| 883 | 1078 | { |
| 884 | 1079 | $nbOpenDay=$lastday; |
| 885 | - if ($inhour == 1) $nbOpenDay = $nbOpenDay*24 . $langs->trans("HourShort"); |
|
| 1080 | + if ($inhour == 1) { |
|
| 1081 | + $nbOpenDay = $nbOpenDay*24 . $langs->trans("HourShort"); |
|
| 1082 | + } |
|
| 886 | 1083 | return $nbOpenDay - (($inhour == 1 ? 12 : 0.5) * abs($halfday)); |
| 887 | - } |
|
| 888 | - else |
|
| 1084 | + } else |
|
| 889 | 1085 | { |
| 890 | 1086 | return $langs->trans("Error"); |
| 891 | 1087 | } |
@@ -32,34 +32,34 @@ discard block |
||
| 32 | 32 | */ |
| 33 | 33 | function get_tz_array() |
| 34 | 34 | { |
| 35 | - $tzarray=array( |
|
| 36 | - -11=>"Pacific/Midway", |
|
| 37 | - -10=>"Pacific/Fakaofo", |
|
| 38 | - -9=>"America/Anchorage", |
|
| 39 | - -8=>"America/Los_Angeles", |
|
| 40 | - -7=>"America/Dawson_Creek", |
|
| 41 | - -6=>"America/Chicago", |
|
| 42 | - -5=>"America/Bogota", |
|
| 43 | - -4=>"America/Anguilla", |
|
| 44 | - -3=>"America/Araguaina", |
|
| 45 | - -2=>"America/Noronha", |
|
| 46 | - -1=>"Atlantic/Azores", |
|
| 47 | - 0=>"Africa/Abidjan", |
|
| 48 | - 1=>"Europe/Paris", |
|
| 49 | - 2=>"Europe/Helsinki", |
|
| 50 | - 3=>"Europe/Moscow", |
|
| 51 | - 4=>"Asia/Dubai", |
|
| 52 | - 5=>"Asia/Karachi", |
|
| 53 | - 6=>"Indian/Chagos", |
|
| 54 | - 7=>"Asia/Jakarta", |
|
| 55 | - 8=>"Asia/Hong_Kong", |
|
| 56 | - 9=>"Asia/Tokyo", |
|
| 57 | - 10=>"Australia/Sydney", |
|
| 58 | - 11=>"Pacific/Noumea", |
|
| 59 | - 12=>"Pacific/Auckland", |
|
| 60 | - 13=>"Pacific/Enderbury" |
|
| 61 | - ); |
|
| 62 | - return $tzarray; |
|
| 35 | + $tzarray=array( |
|
| 36 | + -11=>"Pacific/Midway", |
|
| 37 | + -10=>"Pacific/Fakaofo", |
|
| 38 | + -9=>"America/Anchorage", |
|
| 39 | + -8=>"America/Los_Angeles", |
|
| 40 | + -7=>"America/Dawson_Creek", |
|
| 41 | + -6=>"America/Chicago", |
|
| 42 | + -5=>"America/Bogota", |
|
| 43 | + -4=>"America/Anguilla", |
|
| 44 | + -3=>"America/Araguaina", |
|
| 45 | + -2=>"America/Noronha", |
|
| 46 | + -1=>"Atlantic/Azores", |
|
| 47 | + 0=>"Africa/Abidjan", |
|
| 48 | + 1=>"Europe/Paris", |
|
| 49 | + 2=>"Europe/Helsinki", |
|
| 50 | + 3=>"Europe/Moscow", |
|
| 51 | + 4=>"Asia/Dubai", |
|
| 52 | + 5=>"Asia/Karachi", |
|
| 53 | + 6=>"Indian/Chagos", |
|
| 54 | + 7=>"Asia/Jakarta", |
|
| 55 | + 8=>"Asia/Hong_Kong", |
|
| 56 | + 9=>"Asia/Tokyo", |
|
| 57 | + 10=>"Australia/Sydney", |
|
| 58 | + 11=>"Pacific/Noumea", |
|
| 59 | + 12=>"Pacific/Auckland", |
|
| 60 | + 13=>"Pacific/Enderbury" |
|
| 61 | + ); |
|
| 62 | + return $tzarray; |
|
| 63 | 63 | } |
| 64 | 64 | |
| 65 | 65 | |
@@ -70,7 +70,7 @@ discard block |
||
| 70 | 70 | */ |
| 71 | 71 | function getServerTimeZoneString() |
| 72 | 72 | { |
| 73 | - return @date_default_timezone_get(); |
|
| 73 | + return @date_default_timezone_get(); |
|
| 74 | 74 | } |
| 75 | 75 | |
| 76 | 76 | /** |
@@ -81,27 +81,27 @@ discard block |
||
| 81 | 81 | */ |
| 82 | 82 | function getServerTimeZoneInt($refgmtdate='now') |
| 83 | 83 | { |
| 84 | - global $conf; |
|
| 85 | - if (method_exists('DateTimeZone','getOffset')) |
|
| 86 | - { |
|
| 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'; |
|
| 93 | - $localtz = new DateTimeZone(getServerTimeZoneString()); |
|
| 94 | - $localdt = new DateTime($newrefgmtdate, $localtz); |
|
| 95 | - $tmp=-1*$localtz->getOffset($localdt); |
|
| 96 | - //print $refgmtdate.'='.$tmp; |
|
| 97 | - } |
|
| 98 | - else |
|
| 99 | - { |
|
| 100 | - $tmp=0; |
|
| 101 | - dol_print_error('','PHP version must be 5.3+'); |
|
| 102 | - } |
|
| 103 | - $tz=round(($tmp<0?1:-1)*abs($tmp/3600)); |
|
| 104 | - return $tz; |
|
| 84 | + global $conf; |
|
| 85 | + if (method_exists('DateTimeZone','getOffset')) |
|
| 86 | + { |
|
| 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'; |
|
| 93 | + $localtz = new DateTimeZone(getServerTimeZoneString()); |
|
| 94 | + $localdt = new DateTime($newrefgmtdate, $localtz); |
|
| 95 | + $tmp=-1*$localtz->getOffset($localdt); |
|
| 96 | + //print $refgmtdate.'='.$tmp; |
|
| 97 | + } |
|
| 98 | + else |
|
| 99 | + { |
|
| 100 | + $tmp=0; |
|
| 101 | + dol_print_error('','PHP version must be 5.3+'); |
|
| 102 | + } |
|
| 103 | + $tz=round(($tmp<0?1:-1)*abs($tmp/3600)); |
|
| 104 | + return $tz; |
|
| 105 | 105 | } |
| 106 | 106 | |
| 107 | 107 | |
@@ -173,15 +173,15 @@ discard block |
||
| 173 | 173 | global $langs; |
| 174 | 174 | |
| 175 | 175 | if (empty($lengthOfDay)) $lengthOfDay = 86400; // 1 day = 24 hours |
| 176 | - if (empty($lengthOfWeek)) $lengthOfWeek = 7; // 1 week = 7 days |
|
| 176 | + if (empty($lengthOfWeek)) $lengthOfWeek = 7; // 1 week = 7 days |
|
| 177 | 177 | |
| 178 | 178 | if ($format == 'all' || $format == 'allwithouthour' || $format == 'allhour' || $format == 'allhourmin') |
| 179 | 179 | { |
| 180 | 180 | if ((int) $iSecond === 0) return '0'; // This is to avoid having 0 return a 12:00 AM for en_US |
| 181 | 181 | |
| 182 | - $sTime=''; |
|
| 183 | - $sDay=0; |
|
| 184 | - $sWeek=0; |
|
| 182 | + $sTime=''; |
|
| 183 | + $sDay=0; |
|
| 184 | + $sWeek=0; |
|
| 185 | 185 | |
| 186 | 186 | if ($iSecond >= $lengthOfDay) |
| 187 | 187 | { |
@@ -196,17 +196,17 @@ discard block |
||
| 196 | 196 | |
| 197 | 197 | if ($lengthOfWeek < 7) |
| 198 | 198 | { |
| 199 | - if ($sDay) |
|
| 200 | - { |
|
| 201 | - if ($sDay >= $lengthOfWeek) |
|
| 202 | - { |
|
| 203 | - $sWeek = (int) (($sDay - $sDay % $lengthOfWeek ) / $lengthOfWeek); |
|
| 204 | - $sDay = $sDay % $lengthOfWeek; |
|
| 205 | - $weekTranslate = $langs->trans("DurationWeek"); |
|
| 206 | - if ($sWeek >= 2) $weekTranslate = $langs->trans("DurationWeeks"); |
|
| 207 | - $sTime.=$sWeek.' '.$weekTranslate.' '; |
|
| 208 | - } |
|
| 209 | - } |
|
| 199 | + if ($sDay) |
|
| 200 | + { |
|
| 201 | + if ($sDay >= $lengthOfWeek) |
|
| 202 | + { |
|
| 203 | + $sWeek = (int) (($sDay - $sDay % $lengthOfWeek ) / $lengthOfWeek); |
|
| 204 | + $sDay = $sDay % $lengthOfWeek; |
|
| 205 | + $weekTranslate = $langs->trans("DurationWeek"); |
|
| 206 | + if ($sWeek >= 2) $weekTranslate = $langs->trans("DurationWeeks"); |
|
| 207 | + $sTime.=$sWeek.' '.$weekTranslate.' '; |
|
| 208 | + } |
|
| 209 | + } |
|
| 210 | 210 | } |
| 211 | 211 | if ($sDay>0) |
| 212 | 212 | { |
@@ -224,7 +224,7 @@ discard block |
||
| 224 | 224 | } |
| 225 | 225 | if ($format == 'allhourmin') |
| 226 | 226 | { |
| 227 | - return sprintf("%02d",($sWeek*$lengthOfWeek*24 + $sDay*24 + (int) floor($iSecond/3600))).':'.sprintf("%02d",((int) floor(($iSecond % 3600)/60))); |
|
| 227 | + return sprintf("%02d",($sWeek*$lengthOfWeek*24 + $sDay*24 + (int) floor($iSecond/3600))).':'.sprintf("%02d",((int) floor(($iSecond % 3600)/60))); |
|
| 228 | 228 | } |
| 229 | 229 | if ($format == 'allhour') |
| 230 | 230 | { |
@@ -249,19 +249,19 @@ discard block |
||
| 249 | 249 | { |
| 250 | 250 | $sTime=dol_print_date($iSecond,'%M',true); |
| 251 | 251 | } |
| 252 | - else if ($format == 'sec') // only sec part |
|
| 253 | - { |
|
| 254 | - $sTime=dol_print_date($iSecond,'%S',true); |
|
| 255 | - } |
|
| 256 | - else if ($format == 'month') // only month part |
|
| 257 | - { |
|
| 258 | - $sTime=dol_print_date($iSecond,'%m',true); |
|
| 259 | - } |
|
| 260 | - else if ($format == 'year') // only year part |
|
| 261 | - { |
|
| 262 | - $sTime=dol_print_date($iSecond,'%Y',true); |
|
| 263 | - } |
|
| 264 | - return trim($sTime); |
|
| 252 | + else if ($format == 'sec') // only sec part |
|
| 253 | + { |
|
| 254 | + $sTime=dol_print_date($iSecond,'%S',true); |
|
| 255 | + } |
|
| 256 | + else if ($format == 'month') // only month part |
|
| 257 | + { |
|
| 258 | + $sTime=dol_print_date($iSecond,'%m',true); |
|
| 259 | + } |
|
| 260 | + else if ($format == 'year') // only year part |
|
| 261 | + { |
|
| 262 | + $sTime=dol_print_date($iSecond,'%Y',true); |
|
| 263 | + } |
|
| 264 | + return trim($sTime); |
|
| 265 | 265 | } |
| 266 | 266 | |
| 267 | 267 | |
@@ -285,41 +285,41 @@ discard block |
||
| 285 | 285 | */ |
| 286 | 286 | function dol_stringtotime($string, $gm=1) |
| 287 | 287 | { |
| 288 | - // Convert date with format DD/MM/YYY HH:MM:SS. This part of code should not be used. |
|
| 289 | - if (preg_match('/^([0-9]+)\/([0-9]+)\/([0-9]+)\s?([0-9]+)?:?([0-9]+)?:?([0-9]+)?/i',$string,$reg)) |
|
| 290 | - { |
|
| 291 | - dol_syslog("dol_stringtotime call to function with deprecated parameter format", LOG_WARNING); |
|
| 292 | - // Date est au format 'DD/MM/YY' ou 'DD/MM/YY HH:MM:SS' |
|
| 293 | - // Date est au format 'DD/MM/YYYY' ou 'DD/MM/YYYY HH:MM:SS' |
|
| 294 | - $sday = $reg[1]; |
|
| 295 | - $smonth = $reg[2]; |
|
| 296 | - $syear = $reg[3]; |
|
| 297 | - $shour = $reg[4]; |
|
| 298 | - $smin = $reg[5]; |
|
| 299 | - $ssec = $reg[6]; |
|
| 300 | - if ($syear < 50) $syear+=1900; |
|
| 301 | - if ($syear >= 50 && $syear < 100) $syear+=2000; |
|
| 302 | - $string=sprintf("%04d%02d%02d%02d%02d%02d",$syear,$smonth,$sday,$shour,$smin,$ssec); |
|
| 303 | - } |
|
| 304 | - else if ( |
|
| 305 | - 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) |
|
| 306 | - || 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 |
|
| 288 | + // Convert date with format DD/MM/YYY HH:MM:SS. This part of code should not be used. |
|
| 289 | + if (preg_match('/^([0-9]+)\/([0-9]+)\/([0-9]+)\s?([0-9]+)?:?([0-9]+)?:?([0-9]+)?/i',$string,$reg)) |
|
| 290 | + { |
|
| 291 | + dol_syslog("dol_stringtotime call to function with deprecated parameter format", LOG_WARNING); |
|
| 292 | + // Date est au format 'DD/MM/YY' ou 'DD/MM/YY HH:MM:SS' |
|
| 293 | + // Date est au format 'DD/MM/YYYY' ou 'DD/MM/YYYY HH:MM:SS' |
|
| 294 | + $sday = $reg[1]; |
|
| 295 | + $smonth = $reg[2]; |
|
| 296 | + $syear = $reg[3]; |
|
| 297 | + $shour = $reg[4]; |
|
| 298 | + $smin = $reg[5]; |
|
| 299 | + $ssec = $reg[6]; |
|
| 300 | + if ($syear < 50) $syear+=1900; |
|
| 301 | + if ($syear >= 50 && $syear < 100) $syear+=2000; |
|
| 302 | + $string=sprintf("%04d%02d%02d%02d%02d%02d",$syear,$smonth,$sday,$shour,$smin,$ssec); |
|
| 303 | + } |
|
| 304 | + else if ( |
|
| 305 | + 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) |
|
| 306 | + || 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 |
|
| 307 | 307 | || 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 |
| 308 | - ) |
|
| 309 | - { |
|
| 310 | - $syear = $reg[1]; |
|
| 311 | - $smonth = $reg[2]; |
|
| 312 | - $sday = $reg[3]; |
|
| 313 | - $shour = $reg[4]; |
|
| 314 | - $smin = $reg[5]; |
|
| 315 | - $ssec = $reg[6]; |
|
| 316 | - $string=sprintf("%04d%02d%02d%02d%02d%02d",$syear,$smonth,$sday,$shour,$smin,$ssec); |
|
| 317 | - } |
|
| 318 | - |
|
| 319 | - $string=preg_replace('/([^0-9])/i','',$string); |
|
| 320 | - $tmp=$string.'000000'; |
|
| 321 | - $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)); |
|
| 322 | - return $date; |
|
| 308 | + ) |
|
| 309 | + { |
|
| 310 | + $syear = $reg[1]; |
|
| 311 | + $smonth = $reg[2]; |
|
| 312 | + $sday = $reg[3]; |
|
| 313 | + $shour = $reg[4]; |
|
| 314 | + $smin = $reg[5]; |
|
| 315 | + $ssec = $reg[6]; |
|
| 316 | + $string=sprintf("%04d%02d%02d%02d%02d%02d",$syear,$smonth,$sday,$shour,$smin,$ssec); |
|
| 317 | + } |
|
| 318 | + |
|
| 319 | + $string=preg_replace('/([^0-9])/i','',$string); |
|
| 320 | + $tmp=$string.'000000'; |
|
| 321 | + $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)); |
|
| 322 | + return $date; |
|
| 323 | 323 | } |
| 324 | 324 | |
| 325 | 325 | |
@@ -500,30 +500,30 @@ discard block |
||
| 500 | 500 | $days = $start_week - $tmparray['wday']; |
| 501 | 501 | if ($days>=1) $days=7-$days; |
| 502 | 502 | $days = abs($days); |
| 503 | - $seconds = $days*24*60*60; |
|
| 503 | + $seconds = $days*24*60*60; |
|
| 504 | 504 | //print 'start_week='.$start_week.' tmparray[wday]='.$tmparray['wday'].' day offset='.$days.' seconds offset='.$seconds.'<br>'; |
| 505 | 505 | |
| 506 | - //Get first day of week |
|
| 507 | - $tmpdaytms = date($tmparray[0])-$seconds; // $tmparray[0] is day of parameters |
|
| 506 | + //Get first day of week |
|
| 507 | + $tmpdaytms = date($tmparray[0])-$seconds; // $tmparray[0] is day of parameters |
|
| 508 | 508 | $tmpday = date("d",$tmpdaytms); |
| 509 | 509 | |
| 510 | 510 | //Check first day of week is in same month than current day or not |
| 511 | 511 | if ($tmpday>$day) |
| 512 | - { |
|
| 513 | - $prev_month = $month-1; |
|
| 512 | + { |
|
| 513 | + $prev_month = $month-1; |
|
| 514 | 514 | $prev_year = $year; |
| 515 | 515 | |
| 516 | - if ($prev_month==0) |
|
| 517 | - { |
|
| 518 | - $prev_month = 12; |
|
| 519 | - $prev_year = $year-1; |
|
| 520 | - } |
|
| 521 | - } |
|
| 522 | - else |
|
| 523 | - { |
|
| 524 | - $prev_month = $month; |
|
| 516 | + if ($prev_month==0) |
|
| 517 | + { |
|
| 518 | + $prev_month = 12; |
|
| 519 | + $prev_year = $year-1; |
|
| 520 | + } |
|
| 521 | + } |
|
| 522 | + else |
|
| 523 | + { |
|
| 524 | + $prev_month = $month; |
|
| 525 | 525 | $prev_year = $year; |
| 526 | - } |
|
| 526 | + } |
|
| 527 | 527 | $tmpmonth = $prev_month; |
| 528 | 528 | $tmpyear = $prev_year; |
| 529 | 529 | |
@@ -531,22 +531,22 @@ discard block |
||
| 531 | 531 | $tmptime=dol_mktime(12,0,0,$month,$tmpday,$year,1,0); |
| 532 | 532 | $tmptime-=24*60*60*7; |
| 533 | 533 | $tmparray=dol_getdate($tmptime,true); |
| 534 | - $prev_day = $tmparray['mday']; |
|
| 534 | + $prev_day = $tmparray['mday']; |
|
| 535 | 535 | |
| 536 | - //Check prev day of week is in same month than first day or not |
|
| 536 | + //Check prev day of week is in same month than first day or not |
|
| 537 | 537 | if ($prev_day > $tmpday) |
| 538 | - { |
|
| 539 | - $prev_month = $month-1; |
|
| 538 | + { |
|
| 539 | + $prev_month = $month-1; |
|
| 540 | 540 | $prev_year = $year; |
| 541 | 541 | |
| 542 | - if ($prev_month==0) |
|
| 543 | - { |
|
| 544 | - $prev_month = 12; |
|
| 545 | - $prev_year = $year-1; |
|
| 546 | - } |
|
| 547 | - } |
|
| 542 | + if ($prev_month==0) |
|
| 543 | + { |
|
| 544 | + $prev_month = 12; |
|
| 545 | + $prev_year = $year-1; |
|
| 546 | + } |
|
| 547 | + } |
|
| 548 | 548 | |
| 549 | - $week = date("W",dol_mktime(0,0,0,$tmpmonth,$tmpday,$tmpyear,$gm)); |
|
| 549 | + $week = date("W",dol_mktime(0,0,0,$tmpmonth,$tmpday,$tmpyear,$gm)); |
|
| 550 | 550 | |
| 551 | 551 | 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); |
| 552 | 552 | } |
@@ -571,7 +571,7 @@ discard block |
||
| 571 | 571 | |
| 572 | 572 | $i=0; |
| 573 | 573 | while (( ($lastday == 0 && $timestampStart < $timestampEnd) || ($lastday && $timestampStart <= $timestampEnd) ) |
| 574 | - && ($i < 50000)) // Loop end when equals (Test on i is a security loop to avoid infinite loop) |
|
| 574 | + && ($i < 50000)) // Loop end when equals (Test on i is a security loop to avoid infinite loop) |
|
| 575 | 575 | { |
| 576 | 576 | $ferie=false; |
| 577 | 577 | $countryfound=0; |
@@ -601,28 +601,28 @@ discard block |
||
| 601 | 601 | // Paques |
| 602 | 602 | |
| 603 | 603 | // Calcul du jour de l ascension (38 jours apres Paques) |
| 604 | - $date_ascension = mktime( |
|
| 605 | - date("H", $date_paques), |
|
| 606 | - date("i", $date_paques), |
|
| 607 | - date("s", $date_paques), |
|
| 608 | - date("m", $date_paques), |
|
| 609 | - date("d", $date_paques) + 38, |
|
| 610 | - date("Y", $date_paques) |
|
| 611 | - ); |
|
| 604 | + $date_ascension = mktime( |
|
| 605 | + date("H", $date_paques), |
|
| 606 | + date("i", $date_paques), |
|
| 607 | + date("s", $date_paques), |
|
| 608 | + date("m", $date_paques), |
|
| 609 | + date("d", $date_paques) + 38, |
|
| 610 | + date("Y", $date_paques) |
|
| 611 | + ); |
|
| 612 | 612 | $jour_ascension = date("d", $date_ascension); |
| 613 | 613 | $mois_ascension = date("m", $date_ascension); |
| 614 | 614 | if($jour_ascension == $jour && $mois_ascension == $mois) $ferie=true; |
| 615 | 615 | //Ascension |
| 616 | 616 | |
| 617 | 617 | // Calcul de Pentecote (11 jours apres Paques) |
| 618 | - $date_pentecote = mktime( |
|
| 619 | - date("H", $date_ascension), |
|
| 620 | - date("i", $date_ascension), |
|
| 621 | - date("s", $date_ascension), |
|
| 622 | - date("m", $date_ascension), |
|
| 623 | - date("d", $date_ascension) + 11, |
|
| 624 | - date("Y", $date_ascension) |
|
| 625 | - ); |
|
| 618 | + $date_pentecote = mktime( |
|
| 619 | + date("H", $date_ascension), |
|
| 620 | + date("i", $date_ascension), |
|
| 621 | + date("s", $date_ascension), |
|
| 622 | + date("m", $date_ascension), |
|
| 623 | + date("d", $date_ascension) + 11, |
|
| 624 | + date("Y", $date_ascension) |
|
| 625 | + ); |
|
| 626 | 626 | $jour_pentecote = date("d", $date_pentecote); |
| 627 | 627 | $mois_pentecote = date("m", $date_pentecote); |
| 628 | 628 | if($jour_pentecote == $jour && $mois_pentecote == $mois) $ferie=true; |
@@ -690,14 +690,14 @@ discard block |
||
| 690 | 690 | // Paques |
| 691 | 691 | |
| 692 | 692 | // Viernes Santo |
| 693 | - $date_viernes = mktime( |
|
| 694 | - date("H", $date_paques), |
|
| 695 | - date("i", $date_paques), |
|
| 696 | - date("s", $date_paques), |
|
| 697 | - date("m", $date_paques), |
|
| 698 | - date("d", $date_paques) -2, |
|
| 699 | - date("Y", $date_paques) |
|
| 700 | - ); |
|
| 693 | + $date_viernes = mktime( |
|
| 694 | + date("H", $date_paques), |
|
| 695 | + date("i", $date_paques), |
|
| 696 | + date("s", $date_paques), |
|
| 697 | + date("m", $date_paques), |
|
| 698 | + date("d", $date_paques) -2, |
|
| 699 | + date("Y", $date_paques) |
|
| 700 | + ); |
|
| 701 | 701 | $jour_viernes = date("d", $date_viernes); |
| 702 | 702 | $mois_viernes = date("m", $date_viernes); |
| 703 | 703 | if($jour_viernes == $jour && $mois_viernes == $mois) $ferie=true; |
@@ -712,89 +712,89 @@ discard block |
||
| 712 | 712 | |
| 713 | 713 | if ($countrycode == 'AT') |
| 714 | 714 | { |
| 715 | - $countryfound=1; |
|
| 716 | - |
|
| 717 | - // Definition des dates feriees fixes |
|
| 718 | - if($jour == 1 && $mois == 1) $ferie=true; // Neujahr |
|
| 719 | - if($jour == 6 && $mois == 1) $ferie=true; // Hl. 3 Koenige |
|
| 720 | - if($jour == 1 && $mois == 5) $ferie=true; // 1. Mai |
|
| 721 | - if($jour == 15 && $mois == 8) $ferie=true; // Mariae Himmelfahrt |
|
| 722 | - if($jour == 26 && $mois == 10) $ferie=true; // 26. Oktober |
|
| 723 | - if($jour == 1 && $mois == 11) $ferie=true; // Allerheiligen |
|
| 724 | - if($jour == 8 && $mois == 12) $ferie=true; // Mariae Empfaengnis |
|
| 725 | - if($jour == 24 && $mois == 12) $ferie=true; // Heilig abend |
|
| 726 | - if($jour == 25 && $mois == 12) $ferie=true; // Christtag |
|
| 727 | - if($jour == 26 && $mois == 12) $ferie=true; // Stefanietag |
|
| 728 | - if($jour == 31 && $mois == 12) $ferie=true; // Silvester |
|
| 729 | - |
|
| 730 | - // Easter calculation |
|
| 731 | - $date_paques = easter_date($annee); |
|
| 732 | - $jour_paques = date("d", $date_paques); |
|
| 733 | - $mois_paques = date("m", $date_paques); |
|
| 734 | - if($jour_paques == $jour && $mois_paques == $mois) $ferie=true; |
|
| 735 | - // Easter sunday |
|
| 736 | - |
|
| 737 | - // Monday after easter |
|
| 738 | - $date_eastermonday = mktime( |
|
| 739 | - date("H", $date_paques), |
|
| 740 | - date("i", $date_paques), |
|
| 741 | - date("s", $date_paques), |
|
| 742 | - date("m", $date_paques), |
|
| 743 | - date("d", $date_paques) + 1, |
|
| 744 | - date("Y", $date_paques) |
|
| 745 | - ); |
|
| 746 | - $jour_eastermonday = date("d", $date_eastermonday); |
|
| 747 | - $mois_eastermonday = date("m", $date_eastermonday); |
|
| 748 | - if($jour_eastermonday == $jour && $mois_eastermonday == $mois) $ferie=true; |
|
| 749 | - // Easter monday |
|
| 750 | - |
|
| 751 | - // Christi Himmelfahrt (39 days after easter sunday) |
|
| 752 | - $date_ch = mktime( |
|
| 753 | - date("H", $date_paques), |
|
| 754 | - date("i", $date_paques), |
|
| 755 | - date("s", $date_paques), |
|
| 756 | - date("m", $date_paques), |
|
| 757 | - date("d", $date_paques) + 39, |
|
| 758 | - date("Y", $date_paques) |
|
| 759 | - ); |
|
| 760 | - $jour_ch = date("d", $date_ch); |
|
| 761 | - $mois_ch = date("m", $date_ch); |
|
| 762 | - if($jour_ch == $jour && $mois_ch == $mois) $ferie=true; |
|
| 763 | - // Christi Himmelfahrt |
|
| 764 | - |
|
| 765 | - // Pfingsten (50 days after easter sunday) |
|
| 766 | - $date_pentecote = mktime( |
|
| 767 | - date("H", $date_paques), |
|
| 768 | - date("i", $date_paques), |
|
| 769 | - date("s", $date_paques), |
|
| 770 | - date("m", $date_paques), |
|
| 771 | - date("d", $date_paques) + 50, |
|
| 772 | - date("Y", $date_paques) |
|
| 773 | - ); |
|
| 774 | - $jour_pentecote = date("d", $date_pentecote); |
|
| 775 | - $mois_pentecote = date("m", $date_pentecote); |
|
| 776 | - if($jour_pentecote == $jour && $mois_pentecote == $mois) $ferie=true; |
|
| 777 | - // Pfingsten |
|
| 778 | - |
|
| 779 | - // Fronleichnam (60 days after easter sunday) |
|
| 780 | - $date_fronleichnam = mktime( |
|
| 781 | - date("H", $date_paques), |
|
| 782 | - date("i", $date_paques), |
|
| 783 | - date("s", $date_paques), |
|
| 784 | - date("m", $date_paques), |
|
| 785 | - date("d", $date_paques) + 60, |
|
| 786 | - date("Y", $date_paques) |
|
| 787 | - ); |
|
| 788 | - $jour_fronleichnam = date("d", $date_fronleichnam); |
|
| 789 | - $mois_fronleichnam = date("m", $date_fronleichnam); |
|
| 790 | - if($jour_fronleichnam == $jour && $mois_fronleichnam == $mois) $ferie=true; |
|
| 791 | - // Fronleichnam |
|
| 792 | - |
|
| 793 | - // Calul des samedis et dimanches |
|
| 794 | - $jour_julien = unixtojd($timestampStart); |
|
| 795 | - $jour_semaine = jddayofweek($jour_julien, 0); |
|
| 796 | - if($jour_semaine == 0 || $jour_semaine == 6) $ferie=true; |
|
| 797 | - //Samedi (6) et dimanche (0) |
|
| 715 | + $countryfound=1; |
|
| 716 | + |
|
| 717 | + // Definition des dates feriees fixes |
|
| 718 | + if($jour == 1 && $mois == 1) $ferie=true; // Neujahr |
|
| 719 | + if($jour == 6 && $mois == 1) $ferie=true; // Hl. 3 Koenige |
|
| 720 | + if($jour == 1 && $mois == 5) $ferie=true; // 1. Mai |
|
| 721 | + if($jour == 15 && $mois == 8) $ferie=true; // Mariae Himmelfahrt |
|
| 722 | + if($jour == 26 && $mois == 10) $ferie=true; // 26. Oktober |
|
| 723 | + if($jour == 1 && $mois == 11) $ferie=true; // Allerheiligen |
|
| 724 | + if($jour == 8 && $mois == 12) $ferie=true; // Mariae Empfaengnis |
|
| 725 | + if($jour == 24 && $mois == 12) $ferie=true; // Heilig abend |
|
| 726 | + if($jour == 25 && $mois == 12) $ferie=true; // Christtag |
|
| 727 | + if($jour == 26 && $mois == 12) $ferie=true; // Stefanietag |
|
| 728 | + if($jour == 31 && $mois == 12) $ferie=true; // Silvester |
|
| 729 | + |
|
| 730 | + // Easter calculation |
|
| 731 | + $date_paques = easter_date($annee); |
|
| 732 | + $jour_paques = date("d", $date_paques); |
|
| 733 | + $mois_paques = date("m", $date_paques); |
|
| 734 | + if($jour_paques == $jour && $mois_paques == $mois) $ferie=true; |
|
| 735 | + // Easter sunday |
|
| 736 | + |
|
| 737 | + // Monday after easter |
|
| 738 | + $date_eastermonday = mktime( |
|
| 739 | + date("H", $date_paques), |
|
| 740 | + date("i", $date_paques), |
|
| 741 | + date("s", $date_paques), |
|
| 742 | + date("m", $date_paques), |
|
| 743 | + date("d", $date_paques) + 1, |
|
| 744 | + date("Y", $date_paques) |
|
| 745 | + ); |
|
| 746 | + $jour_eastermonday = date("d", $date_eastermonday); |
|
| 747 | + $mois_eastermonday = date("m", $date_eastermonday); |
|
| 748 | + if($jour_eastermonday == $jour && $mois_eastermonday == $mois) $ferie=true; |
|
| 749 | + // Easter monday |
|
| 750 | + |
|
| 751 | + // Christi Himmelfahrt (39 days after easter sunday) |
|
| 752 | + $date_ch = mktime( |
|
| 753 | + date("H", $date_paques), |
|
| 754 | + date("i", $date_paques), |
|
| 755 | + date("s", $date_paques), |
|
| 756 | + date("m", $date_paques), |
|
| 757 | + date("d", $date_paques) + 39, |
|
| 758 | + date("Y", $date_paques) |
|
| 759 | + ); |
|
| 760 | + $jour_ch = date("d", $date_ch); |
|
| 761 | + $mois_ch = date("m", $date_ch); |
|
| 762 | + if($jour_ch == $jour && $mois_ch == $mois) $ferie=true; |
|
| 763 | + // Christi Himmelfahrt |
|
| 764 | + |
|
| 765 | + // Pfingsten (50 days after easter sunday) |
|
| 766 | + $date_pentecote = mktime( |
|
| 767 | + date("H", $date_paques), |
|
| 768 | + date("i", $date_paques), |
|
| 769 | + date("s", $date_paques), |
|
| 770 | + date("m", $date_paques), |
|
| 771 | + date("d", $date_paques) + 50, |
|
| 772 | + date("Y", $date_paques) |
|
| 773 | + ); |
|
| 774 | + $jour_pentecote = date("d", $date_pentecote); |
|
| 775 | + $mois_pentecote = date("m", $date_pentecote); |
|
| 776 | + if($jour_pentecote == $jour && $mois_pentecote == $mois) $ferie=true; |
|
| 777 | + // Pfingsten |
|
| 778 | + |
|
| 779 | + // Fronleichnam (60 days after easter sunday) |
|
| 780 | + $date_fronleichnam = mktime( |
|
| 781 | + date("H", $date_paques), |
|
| 782 | + date("i", $date_paques), |
|
| 783 | + date("s", $date_paques), |
|
| 784 | + date("m", $date_paques), |
|
| 785 | + date("d", $date_paques) + 60, |
|
| 786 | + date("Y", $date_paques) |
|
| 787 | + ); |
|
| 788 | + $jour_fronleichnam = date("d", $date_fronleichnam); |
|
| 789 | + $mois_fronleichnam = date("m", $date_fronleichnam); |
|
| 790 | + if($jour_fronleichnam == $jour && $mois_fronleichnam == $mois) $ferie=true; |
|
| 791 | + // Fronleichnam |
|
| 792 | + |
|
| 793 | + // Calul des samedis et dimanches |
|
| 794 | + $jour_julien = unixtojd($timestampStart); |
|
| 795 | + $jour_semaine = jddayofweek($jour_julien, 0); |
|
| 796 | + if($jour_semaine == 0 || $jour_semaine == 6) $ferie=true; |
|
| 797 | + //Samedi (6) et dimanche (0) |
|
| 798 | 798 | } |
| 799 | 799 | |
| 800 | 800 | // Cas pays non defini |
@@ -907,35 +907,35 @@ discard block |
||
| 907 | 907 | function monthArray($outputlangs,$short=0) |
| 908 | 908 | { |
| 909 | 909 | $montharray = array ( |
| 910 | - 1 => $outputlangs->trans("January"), |
|
| 911 | - 2 => $outputlangs->trans("February"), |
|
| 912 | - 3 => $outputlangs->trans("March"), |
|
| 913 | - 4 => $outputlangs->trans("April"), |
|
| 914 | - 5 => $outputlangs->trans("May"), |
|
| 915 | - 6 => $outputlangs->trans("June"), |
|
| 916 | - 7 => $outputlangs->trans("July"), |
|
| 917 | - 8 => $outputlangs->trans("August"), |
|
| 918 | - 9 => $outputlangs->trans("September"), |
|
| 919 | - 10 => $outputlangs->trans("October"), |
|
| 920 | - 11 => $outputlangs->trans("November"), |
|
| 921 | - 12 => $outputlangs->trans("December") |
|
| 922 | - ); |
|
| 910 | + 1 => $outputlangs->trans("January"), |
|
| 911 | + 2 => $outputlangs->trans("February"), |
|
| 912 | + 3 => $outputlangs->trans("March"), |
|
| 913 | + 4 => $outputlangs->trans("April"), |
|
| 914 | + 5 => $outputlangs->trans("May"), |
|
| 915 | + 6 => $outputlangs->trans("June"), |
|
| 916 | + 7 => $outputlangs->trans("July"), |
|
| 917 | + 8 => $outputlangs->trans("August"), |
|
| 918 | + 9 => $outputlangs->trans("September"), |
|
| 919 | + 10 => $outputlangs->trans("October"), |
|
| 920 | + 11 => $outputlangs->trans("November"), |
|
| 921 | + 12 => $outputlangs->trans("December") |
|
| 922 | + ); |
|
| 923 | 923 | |
| 924 | 924 | if (! empty($short)) |
| 925 | 925 | { |
| 926 | 926 | $montharray = array ( |
| 927 | - 1 => $outputlangs->trans("JanuaryMin"), |
|
| 928 | - 2 => $outputlangs->trans("FebruaryMin"), |
|
| 929 | - 3 => $outputlangs->trans("MarchMin"), |
|
| 930 | - 4 => $outputlangs->trans("AprilMin"), |
|
| 931 | - 5 => $outputlangs->trans("MayMin"), |
|
| 932 | - 6 => $outputlangs->trans("JuneMin"), |
|
| 933 | - 7 => $outputlangs->trans("JulyMin"), |
|
| 934 | - 8 => $outputlangs->trans("AugustMin"), |
|
| 935 | - 9 => $outputlangs->trans("SeptemberMin"), |
|
| 936 | - 10 => $outputlangs->trans("OctoberMin"), |
|
| 937 | - 11 => $outputlangs->trans("NovemberMin"), |
|
| 938 | - 12 => $outputlangs->trans("DecemberMin") |
|
| 927 | + 1 => $outputlangs->trans("JanuaryMin"), |
|
| 928 | + 2 => $outputlangs->trans("FebruaryMin"), |
|
| 929 | + 3 => $outputlangs->trans("MarchMin"), |
|
| 930 | + 4 => $outputlangs->trans("AprilMin"), |
|
| 931 | + 5 => $outputlangs->trans("MayMin"), |
|
| 932 | + 6 => $outputlangs->trans("JuneMin"), |
|
| 933 | + 7 => $outputlangs->trans("JulyMin"), |
|
| 934 | + 8 => $outputlangs->trans("AugustMin"), |
|
| 935 | + 9 => $outputlangs->trans("SeptemberMin"), |
|
| 936 | + 10 => $outputlangs->trans("OctoberMin"), |
|
| 937 | + 11 => $outputlangs->trans("NovemberMin"), |
|
| 938 | + 12 => $outputlangs->trans("DecemberMin") |
|
| 939 | 939 | ); |
| 940 | 940 | } |
| 941 | 941 | |
@@ -32,7 +32,7 @@ discard block |
||
| 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 |
||
| 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 |
||
| 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 | } |
@@ -150,9 +150,9 @@ discard block |
||
| 150 | 150 | * @return int Time into seconds |
| 151 | 151 | * @see convertSecondToTime |
| 152 | 152 | */ |
| 153 | -function convertTime2Seconds($iHours=0,$iMinutes=0,$iSeconds=0) |
|
| 153 | +function convertTime2Seconds($iHours = 0, $iMinutes = 0, $iSeconds = 0) |
|
| 154 | 154 | { |
| 155 | - $iResult=($iHours*3600)+($iMinutes*60)+$iSeconds; |
|
| 155 | + $iResult = ($iHours * 3600) + ($iMinutes * 60) + $iSeconds; |
|
| 156 | 156 | return $iResult; |
| 157 | 157 | } |
| 158 | 158 | |
@@ -168,30 +168,30 @@ discard block |
||
| 168 | 168 | * Example: 0 return 00:00, 3600 return 1:00, 86400 return 1d, 90000 return 1 Day 01:00 |
| 169 | 169 | * @see convertTime2Seconds |
| 170 | 170 | */ |
| 171 | -function convertSecondToTime($iSecond, $format='all', $lengthOfDay=86400, $lengthOfWeek=7) |
|
| 171 | +function convertSecondToTime($iSecond, $format = 'all', $lengthOfDay = 86400, $lengthOfWeek = 7) |
|
| 172 | 172 | { |
| 173 | 173 | global $langs; |
| 174 | 174 | |
| 175 | - if (empty($lengthOfDay)) $lengthOfDay = 86400; // 1 day = 24 hours |
|
| 176 | - if (empty($lengthOfWeek)) $lengthOfWeek = 7; // 1 week = 7 days |
|
| 175 | + if (empty($lengthOfDay)) $lengthOfDay = 86400; // 1 day = 24 hours |
|
| 176 | + if (empty($lengthOfWeek)) $lengthOfWeek = 7; // 1 week = 7 days |
|
| 177 | 177 | |
| 178 | 178 | if ($format == 'all' || $format == 'allwithouthour' || $format == 'allhour' || $format == 'allhourmin') |
| 179 | 179 | { |
| 180 | - if ((int) $iSecond === 0) return '0'; // This is to avoid having 0 return a 12:00 AM for en_US |
|
| 180 | + if ((int) $iSecond === 0) return '0'; // This is to avoid having 0 return a 12:00 AM for en_US |
|
| 181 | 181 | |
| 182 | - $sTime=''; |
|
| 183 | - $sDay=0; |
|
| 184 | - $sWeek=0; |
|
| 182 | + $sTime = ''; |
|
| 183 | + $sDay = 0; |
|
| 184 | + $sWeek = 0; |
|
| 185 | 185 | |
| 186 | 186 | if ($iSecond >= $lengthOfDay) |
| 187 | 187 | { |
| 188 | - for($i = $iSecond; $i >= $lengthOfDay; $i -= $lengthOfDay ) |
|
| 188 | + for ($i = $iSecond; $i >= $lengthOfDay; $i -= $lengthOfDay) |
|
| 189 | 189 | { |
| 190 | 190 | $sDay++; |
| 191 | - $iSecond-=$lengthOfDay; |
|
| 191 | + $iSecond -= $lengthOfDay; |
|
| 192 | 192 | } |
| 193 | 193 | $dayTranslate = $langs->trans("Day"); |
| 194 | - if ($iSecond >= ($lengthOfDay*2)) $dayTranslate = $langs->trans("Days"); |
|
| 194 | + if ($iSecond >= ($lengthOfDay * 2)) $dayTranslate = $langs->trans("Days"); |
|
| 195 | 195 | } |
| 196 | 196 | |
| 197 | 197 | if ($lengthOfWeek < 7) |
@@ -200,66 +200,66 @@ discard block |
||
| 200 | 200 | { |
| 201 | 201 | if ($sDay >= $lengthOfWeek) |
| 202 | 202 | { |
| 203 | - $sWeek = (int) (($sDay - $sDay % $lengthOfWeek ) / $lengthOfWeek); |
|
| 203 | + $sWeek = (int) (($sDay - $sDay % $lengthOfWeek) / $lengthOfWeek); |
|
| 204 | 204 | $sDay = $sDay % $lengthOfWeek; |
| 205 | 205 | $weekTranslate = $langs->trans("DurationWeek"); |
| 206 | 206 | if ($sWeek >= 2) $weekTranslate = $langs->trans("DurationWeeks"); |
| 207 | - $sTime.=$sWeek.' '.$weekTranslate.' '; |
|
| 207 | + $sTime .= $sWeek.' '.$weekTranslate.' '; |
|
| 208 | 208 | } |
| 209 | 209 | } |
| 210 | 210 | } |
| 211 | - if ($sDay>0) |
|
| 211 | + if ($sDay > 0) |
|
| 212 | 212 | { |
| 213 | 213 | $dayTranslate = $langs->trans("Day"); |
| 214 | 214 | if ($sDay > 1) $dayTranslate = $langs->trans("Days"); |
| 215 | - $sTime.=$sDay.' '.$dayTranslate.' '; |
|
| 215 | + $sTime .= $sDay.' '.$dayTranslate.' '; |
|
| 216 | 216 | } |
| 217 | 217 | |
| 218 | 218 | if ($format == 'all') |
| 219 | 219 | { |
| 220 | 220 | if ($iSecond || empty($sDay)) |
| 221 | 221 | { |
| 222 | - $sTime.= dol_print_date($iSecond,'hourduration',true); |
|
| 222 | + $sTime .= dol_print_date($iSecond, 'hourduration', true); |
|
| 223 | 223 | } |
| 224 | 224 | } |
| 225 | 225 | if ($format == 'allhourmin') |
| 226 | 226 | { |
| 227 | - return sprintf("%02d",($sWeek*$lengthOfWeek*24 + $sDay*24 + (int) floor($iSecond/3600))).':'.sprintf("%02d",((int) floor(($iSecond % 3600)/60))); |
|
| 227 | + return sprintf("%02d", ($sWeek * $lengthOfWeek * 24 + $sDay * 24 + (int) floor($iSecond / 3600))).':'.sprintf("%02d", ((int) floor(($iSecond % 3600) / 60))); |
|
| 228 | 228 | } |
| 229 | 229 | if ($format == 'allhour') |
| 230 | 230 | { |
| 231 | - return sprintf("%02d",($sWeek*$lengthOfWeek*24 + $sDay*24 + (int) floor($iSecond/3600))); |
|
| 231 | + return sprintf("%02d", ($sWeek * $lengthOfWeek * 24 + $sDay * 24 + (int) floor($iSecond / 3600))); |
|
| 232 | 232 | } |
| 233 | 233 | } |
| 234 | 234 | else if ($format == 'hour') // only hour part |
| 235 | 235 | { |
| 236 | - $sTime=dol_print_date($iSecond,'%H',true); |
|
| 236 | + $sTime = dol_print_date($iSecond, '%H', true); |
|
| 237 | 237 | } |
| 238 | 238 | else if ($format == 'fullhour') |
| 239 | 239 | { |
| 240 | 240 | if (!empty($iSecond)) { |
| 241 | - $iSecond=$iSecond/3600; |
|
| 241 | + $iSecond = $iSecond / 3600; |
|
| 242 | 242 | } |
| 243 | 243 | else { |
| 244 | - $iSecond=0; |
|
| 244 | + $iSecond = 0; |
|
| 245 | 245 | } |
| 246 | - $sTime=$iSecond; |
|
| 246 | + $sTime = $iSecond; |
|
| 247 | 247 | } |
| 248 | 248 | else if ($format == 'min') // only min part |
| 249 | 249 | { |
| 250 | - $sTime=dol_print_date($iSecond,'%M',true); |
|
| 250 | + $sTime = dol_print_date($iSecond, '%M', true); |
|
| 251 | 251 | } |
| 252 | 252 | else if ($format == 'sec') // only sec part |
| 253 | 253 | { |
| 254 | - $sTime=dol_print_date($iSecond,'%S',true); |
|
| 254 | + $sTime = dol_print_date($iSecond, '%S', true); |
|
| 255 | 255 | } |
| 256 | 256 | else if ($format == 'month') // only month part |
| 257 | 257 | { |
| 258 | - $sTime=dol_print_date($iSecond,'%m',true); |
|
| 258 | + $sTime = dol_print_date($iSecond, '%m', true); |
|
| 259 | 259 | } |
| 260 | 260 | else if ($format == 'year') // only year part |
| 261 | 261 | { |
| 262 | - $sTime=dol_print_date($iSecond,'%Y',true); |
|
| 262 | + $sTime = dol_print_date($iSecond, '%Y', true); |
|
| 263 | 263 | } |
| 264 | 264 | return trim($sTime); |
| 265 | 265 | } |
@@ -283,10 +283,10 @@ discard block |
||
| 283 | 283 | * |
| 284 | 284 | * @see dol_print_date, dol_mktime, dol_getdate |
| 285 | 285 | */ |
| 286 | -function dol_stringtotime($string, $gm=1) |
|
| 286 | +function dol_stringtotime($string, $gm = 1) |
|
| 287 | 287 | { |
| 288 | 288 | // Convert date with format DD/MM/YYY HH:MM:SS. This part of code should not be used. |
| 289 | - if (preg_match('/^([0-9]+)\/([0-9]+)\/([0-9]+)\s?([0-9]+)?:?([0-9]+)?:?([0-9]+)?/i',$string,$reg)) |
|
| 289 | + if (preg_match('/^([0-9]+)\/([0-9]+)\/([0-9]+)\s?([0-9]+)?:?([0-9]+)?:?([0-9]+)?/i', $string, $reg)) |
|
| 290 | 290 | { |
| 291 | 291 | dol_syslog("dol_stringtotime call to function with deprecated parameter format", LOG_WARNING); |
| 292 | 292 | // Date est au format 'DD/MM/YY' ou 'DD/MM/YY HH:MM:SS' |
@@ -297,14 +297,14 @@ discard block |
||
| 297 | 297 | $shour = $reg[4]; |
| 298 | 298 | $smin = $reg[5]; |
| 299 | 299 | $ssec = $reg[6]; |
| 300 | - if ($syear < 50) $syear+=1900; |
|
| 301 | - if ($syear >= 50 && $syear < 100) $syear+=2000; |
|
| 302 | - $string=sprintf("%04d%02d%02d%02d%02d%02d",$syear,$smonth,$sday,$shour,$smin,$ssec); |
|
| 300 | + if ($syear < 50) $syear += 1900; |
|
| 301 | + if ($syear >= 50 && $syear < 100) $syear += 2000; |
|
| 302 | + $string = sprintf("%04d%02d%02d%02d%02d%02d", $syear, $smonth, $sday, $shour, $smin, $ssec); |
|
| 303 | 303 | } |
| 304 | 304 | else if ( |
| 305 | - 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) |
|
| 306 | - || 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 |
|
| 307 | - || 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 | + 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) |
|
| 306 | + || 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 |
|
| 307 | + || 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 |
|
| 308 | 308 | ) |
| 309 | 309 | { |
| 310 | 310 | $syear = $reg[1]; |
@@ -313,12 +313,12 @@ discard block |
||
| 313 | 313 | $shour = $reg[4]; |
| 314 | 314 | $smin = $reg[5]; |
| 315 | 315 | $ssec = $reg[6]; |
| 316 | - $string=sprintf("%04d%02d%02d%02d%02d%02d",$syear,$smonth,$sday,$shour,$smin,$ssec); |
|
| 316 | + $string = sprintf("%04d%02d%02d%02d%02d%02d", $syear, $smonth, $sday, $shour, $smin, $ssec); |
|
| 317 | 317 | } |
| 318 | 318 | |
| 319 | - $string=preg_replace('/([^0-9])/i','',$string); |
|
| 320 | - $tmp=$string.'000000'; |
|
| 321 | - $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 | + $string = preg_replace('/([^0-9])/i', '', $string); |
|
| 320 | + $tmp = $string.'000000'; |
|
| 321 | + $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)); |
|
| 322 | 322 | return $date; |
| 323 | 323 | } |
| 324 | 324 | |
@@ -332,9 +332,9 @@ discard block |
||
| 332 | 332 | */ |
| 333 | 333 | function dol_get_prev_day($day, $month, $year) |
| 334 | 334 | { |
| 335 | - $time=dol_mktime(12,0,0,$month,$day,$year,1,0); |
|
| 336 | - $time-=24*60*60; |
|
| 337 | - $tmparray=dol_getdate($time,true); |
|
| 335 | + $time = dol_mktime(12, 0, 0, $month, $day, $year, 1, 0); |
|
| 336 | + $time -= 24 * 60 * 60; |
|
| 337 | + $tmparray = dol_getdate($time, true); |
|
| 338 | 338 | return array('year' => $tmparray['year'], 'month' => $tmparray['mon'], 'day' => $tmparray['mday']); |
| 339 | 339 | } |
| 340 | 340 | |
@@ -347,9 +347,9 @@ discard block |
||
| 347 | 347 | */ |
| 348 | 348 | function dol_get_next_day($day, $month, $year) |
| 349 | 349 | { |
| 350 | - $time=dol_mktime(12,0,0,$month,$day,$year,1,0); |
|
| 351 | - $time+=24*60*60; |
|
| 352 | - $tmparray=dol_getdate($time,true); |
|
| 350 | + $time = dol_mktime(12, 0, 0, $month, $day, $year, 1, 0); |
|
| 351 | + $time += 24 * 60 * 60; |
|
| 352 | + $tmparray = dol_getdate($time, true); |
|
| 353 | 353 | return array('year' => $tmparray['year'], 'month' => $tmparray['mon'], 'day' => $tmparray['mday']); |
| 354 | 354 | } |
| 355 | 355 | |
@@ -368,7 +368,7 @@ discard block |
||
| 368 | 368 | } |
| 369 | 369 | else |
| 370 | 370 | { |
| 371 | - $prev_month = $month-1; |
|
| 371 | + $prev_month = $month - 1; |
|
| 372 | 372 | $prev_year = $year; |
| 373 | 373 | } |
| 374 | 374 | return array('year' => $prev_year, 'month' => $prev_month); |
@@ -407,9 +407,9 @@ discard block |
||
| 407 | 407 | { |
| 408 | 408 | $tmparray = dol_get_first_day_week($day, $month, $year); |
| 409 | 409 | |
| 410 | - $time=dol_mktime(12,0,0,$month,$tmparray['first_day'],$year,1,0); |
|
| 411 | - $time-=24*60*60*7; |
|
| 412 | - $tmparray=dol_getdate($time,true); |
|
| 410 | + $time = dol_mktime(12, 0, 0, $month, $tmparray['first_day'], $year, 1, 0); |
|
| 411 | + $time -= 24 * 60 * 60 * 7; |
|
| 412 | + $tmparray = dol_getdate($time, true); |
|
| 413 | 413 | return array('year' => $tmparray['year'], 'month' => $tmparray['mon'], 'day' => $tmparray['mday']); |
| 414 | 414 | } |
| 415 | 415 | |
@@ -425,9 +425,9 @@ discard block |
||
| 425 | 425 | { |
| 426 | 426 | $tmparray = dol_get_first_day_week($day, $month, $year); |
| 427 | 427 | |
| 428 | - $time=dol_mktime(12,0,0,$tmparray['first_month'],$tmparray['first_day'],$tmparray['first_year'],1,0); |
|
| 429 | - $time+=24*60*60*7; |
|
| 430 | - $tmparray=dol_getdate($time,true); |
|
| 428 | + $time = dol_mktime(12, 0, 0, $tmparray['first_month'], $tmparray['first_day'], $tmparray['first_year'], 1, 0); |
|
| 429 | + $time += 24 * 60 * 60 * 7; |
|
| 430 | + $tmparray = dol_getdate($time, true); |
|
| 431 | 431 | |
| 432 | 432 | return array('year' => $tmparray['year'], 'month' => $tmparray['mon'], 'day' => $tmparray['mday']); |
| 433 | 433 | |
@@ -442,10 +442,10 @@ discard block |
||
| 442 | 442 | * 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 |
| 443 | 443 | * @return int Date for first day, '' if error |
| 444 | 444 | */ |
| 445 | -function dol_get_first_day($year,$month=1,$gm=false) |
|
| 445 | +function dol_get_first_day($year, $month = 1, $gm = false) |
|
| 446 | 446 | { |
| 447 | 447 | if ($year > 9999) return ''; |
| 448 | - return dol_mktime(0,0,0,$month,1,$year,$gm); |
|
| 448 | + return dol_mktime(0, 0, 0, $month, 1, $year, $gm); |
|
| 449 | 449 | } |
| 450 | 450 | |
| 451 | 451 | |
@@ -456,7 +456,7 @@ discard block |
||
| 456 | 456 | * @param boolean $gm False or 0 or 'server' = Return date to compare with server TZ, True or 1 to compare with GM date. |
| 457 | 457 | * @return int Date for first day, '' if error |
| 458 | 458 | */ |
| 459 | -function dol_get_last_day($year,$month=12,$gm=false) |
|
| 459 | +function dol_get_last_day($year, $month = 12, $gm = false) |
|
| 460 | 460 | { |
| 461 | 461 | if ($year > 9999) return ''; |
| 462 | 462 | if ($month == 12) |
@@ -470,7 +470,7 @@ discard block |
||
| 470 | 470 | } |
| 471 | 471 | |
| 472 | 472 | // On se deplace au debut du mois suivant, et on retire un jour |
| 473 | - $datelim=dol_mktime(23,59,59,$month,1,$year,$gm); |
|
| 473 | + $datelim = dol_mktime(23, 59, 59, $month, 1, $year, $gm); |
|
| 474 | 474 | $datelim -= (3600 * 24); |
| 475 | 475 | |
| 476 | 476 | return $datelim; |
@@ -484,69 +484,69 @@ discard block |
||
| 484 | 484 | * @param int $gm False or 0 or 'server' = Return date to compare with server TZ, True or 1 to compare with GM date. |
| 485 | 485 | * @return array year,month,week,first_day,first_month,first_year,prev_day,prev_month,prev_year |
| 486 | 486 | */ |
| 487 | -function dol_get_first_day_week($day,$month,$year,$gm=false) |
|
| 487 | +function dol_get_first_day_week($day, $month, $year, $gm = false) |
|
| 488 | 488 | { |
| 489 | 489 | global $conf; |
| 490 | 490 | |
| 491 | 491 | //$day=2; $month=2; $year=2015; |
| 492 | - $date = dol_mktime(0,0,0,$month,$day,$year,$gm); |
|
| 492 | + $date = dol_mktime(0, 0, 0, $month, $day, $year, $gm); |
|
| 493 | 493 | |
| 494 | 494 | //Checking conf of start week |
| 495 | - $start_week = (isset($conf->global->MAIN_START_WEEK)?$conf->global->MAIN_START_WEEK:1); |
|
| 495 | + $start_week = (isset($conf->global->MAIN_START_WEEK) ? $conf->global->MAIN_START_WEEK : 1); |
|
| 496 | 496 | |
| 497 | - $tmparray = dol_getdate($date,true); // detail of current day |
|
| 497 | + $tmparray = dol_getdate($date, true); // detail of current day |
|
| 498 | 498 | |
| 499 | 499 | //Calculate days = offset from current day |
| 500 | 500 | $days = $start_week - $tmparray['wday']; |
| 501 | - if ($days>=1) $days=7-$days; |
|
| 501 | + if ($days >= 1) $days = 7 - $days; |
|
| 502 | 502 | $days = abs($days); |
| 503 | - $seconds = $days*24*60*60; |
|
| 503 | + $seconds = $days * 24 * 60 * 60; |
|
| 504 | 504 | //print 'start_week='.$start_week.' tmparray[wday]='.$tmparray['wday'].' day offset='.$days.' seconds offset='.$seconds.'<br>'; |
| 505 | 505 | |
| 506 | 506 | //Get first day of week |
| 507 | - $tmpdaytms = date($tmparray[0])-$seconds; // $tmparray[0] is day of parameters |
|
| 508 | - $tmpday = date("d",$tmpdaytms); |
|
| 507 | + $tmpdaytms = date($tmparray[0]) - $seconds; // $tmparray[0] is day of parameters |
|
| 508 | + $tmpday = date("d", $tmpdaytms); |
|
| 509 | 509 | |
| 510 | 510 | //Check first day of week is in same month than current day or not |
| 511 | - if ($tmpday>$day) |
|
| 511 | + if ($tmpday > $day) |
|
| 512 | 512 | { |
| 513 | - $prev_month = $month-1; |
|
| 514 | - $prev_year = $year; |
|
| 513 | + $prev_month = $month - 1; |
|
| 514 | + $prev_year = $year; |
|
| 515 | 515 | |
| 516 | - if ($prev_month==0) |
|
| 516 | + if ($prev_month == 0) |
|
| 517 | 517 | { |
| 518 | 518 | $prev_month = 12; |
| 519 | - $prev_year = $year-1; |
|
| 519 | + $prev_year = $year - 1; |
|
| 520 | 520 | } |
| 521 | 521 | } |
| 522 | 522 | else |
| 523 | 523 | { |
| 524 | 524 | $prev_month = $month; |
| 525 | - $prev_year = $year; |
|
| 525 | + $prev_year = $year; |
|
| 526 | 526 | } |
| 527 | 527 | $tmpmonth = $prev_month; |
| 528 | 528 | $tmpyear = $prev_year; |
| 529 | 529 | |
| 530 | 530 | //Get first day of next week |
| 531 | - $tmptime=dol_mktime(12,0,0,$month,$tmpday,$year,1,0); |
|
| 532 | - $tmptime-=24*60*60*7; |
|
| 533 | - $tmparray=dol_getdate($tmptime,true); |
|
| 534 | - $prev_day = $tmparray['mday']; |
|
| 531 | + $tmptime = dol_mktime(12, 0, 0, $month, $tmpday, $year, 1, 0); |
|
| 532 | + $tmptime -= 24 * 60 * 60 * 7; |
|
| 533 | + $tmparray = dol_getdate($tmptime, true); |
|
| 534 | + $prev_day = $tmparray['mday']; |
|
| 535 | 535 | |
| 536 | 536 | //Check prev day of week is in same month than first day or not |
| 537 | 537 | if ($prev_day > $tmpday) |
| 538 | 538 | { |
| 539 | - $prev_month = $month-1; |
|
| 540 | - $prev_year = $year; |
|
| 539 | + $prev_month = $month - 1; |
|
| 540 | + $prev_year = $year; |
|
| 541 | 541 | |
| 542 | - if ($prev_month==0) |
|
| 542 | + if ($prev_month == 0) |
|
| 543 | 543 | { |
| 544 | 544 | $prev_month = 12; |
| 545 | - $prev_year = $year-1; |
|
| 545 | + $prev_year = $year - 1; |
|
| 546 | 546 | } |
| 547 | 547 | } |
| 548 | 548 | |
| 549 | - $week = date("W",dol_mktime(0,0,0,$tmpmonth,$tmpday,$tmpyear,$gm)); |
|
| 549 | + $week = date("W", dol_mktime(0, 0, 0, $tmpmonth, $tmpday, $tmpyear, $gm)); |
|
| 550 | 550 | |
| 551 | 551 | 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); |
| 552 | 552 | } |
@@ -562,42 +562,42 @@ discard block |
||
| 562 | 562 | * @return int Nombre de jours feries |
| 563 | 563 | * @see num_between_day, num_open_day |
| 564 | 564 | */ |
| 565 | -function num_public_holiday($timestampStart, $timestampEnd, $countrycode='FR', $lastday=0) |
|
| 565 | +function num_public_holiday($timestampStart, $timestampEnd, $countrycode = 'FR', $lastday = 0) |
|
| 566 | 566 | { |
| 567 | 567 | $nbFerie = 0; |
| 568 | 568 | |
| 569 | 569 | // Check to ensure we use correct parameters |
| 570 | 570 | if ((($timestampEnd - $timestampStart) % 86400) != 0) return 'ErrorDates must use same hours and must be GMT dates'; |
| 571 | 571 | |
| 572 | - $i=0; |
|
| 573 | - while (( ($lastday == 0 && $timestampStart < $timestampEnd) || ($lastday && $timestampStart <= $timestampEnd) ) |
|
| 572 | + $i = 0; |
|
| 573 | + while ((($lastday == 0 && $timestampStart < $timestampEnd) || ($lastday && $timestampStart <= $timestampEnd)) |
|
| 574 | 574 | && ($i < 50000)) // Loop end when equals (Test on i is a security loop to avoid infinite loop) |
| 575 | 575 | { |
| 576 | - $ferie=false; |
|
| 577 | - $countryfound=0; |
|
| 576 | + $ferie = false; |
|
| 577 | + $countryfound = 0; |
|
| 578 | 578 | |
| 579 | 579 | $jour = date("d", $timestampStart); |
| 580 | 580 | $mois = date("m", $timestampStart); |
| 581 | 581 | $annee = date("Y", $timestampStart); |
| 582 | 582 | if ($countrycode == 'FR') |
| 583 | 583 | { |
| 584 | - $countryfound=1; |
|
| 584 | + $countryfound = 1; |
|
| 585 | 585 | |
| 586 | 586 | // Definition des dates feriees fixes |
| 587 | - if($jour == 1 && $mois == 1) $ferie=true; // 1er janvier |
|
| 588 | - if($jour == 1 && $mois == 5) $ferie=true; // 1er mai |
|
| 589 | - if($jour == 8 && $mois == 5) $ferie=true; // 5 mai |
|
| 590 | - if($jour == 14 && $mois == 7) $ferie=true; // 14 juillet |
|
| 591 | - if($jour == 15 && $mois == 8) $ferie=true; // 15 aout |
|
| 592 | - if($jour == 1 && $mois == 11) $ferie=true; // 1 novembre |
|
| 593 | - if($jour == 11 && $mois == 11) $ferie=true; // 11 novembre |
|
| 594 | - if($jour == 25 && $mois == 12) $ferie=true; // 25 decembre |
|
| 587 | + if ($jour == 1 && $mois == 1) $ferie = true; // 1er janvier |
|
| 588 | + if ($jour == 1 && $mois == 5) $ferie = true; // 1er mai |
|
| 589 | + if ($jour == 8 && $mois == 5) $ferie = true; // 5 mai |
|
| 590 | + if ($jour == 14 && $mois == 7) $ferie = true; // 14 juillet |
|
| 591 | + if ($jour == 15 && $mois == 8) $ferie = true; // 15 aout |
|
| 592 | + if ($jour == 1 && $mois == 11) $ferie = true; // 1 novembre |
|
| 593 | + if ($jour == 11 && $mois == 11) $ferie = true; // 11 novembre |
|
| 594 | + if ($jour == 25 && $mois == 12) $ferie = true; // 25 decembre |
|
| 595 | 595 | |
| 596 | 596 | // Calcul du jour de paques |
| 597 | 597 | $date_paques = easter_date($annee); |
| 598 | 598 | $jour_paques = date("d", $date_paques); |
| 599 | 599 | $mois_paques = date("m", $date_paques); |
| 600 | - if($jour_paques == $jour && $mois_paques == $mois) $ferie=true; |
|
| 600 | + if ($jour_paques == $jour && $mois_paques == $mois) $ferie = true; |
|
| 601 | 601 | // Paques |
| 602 | 602 | |
| 603 | 603 | // Calcul du jour de l ascension (38 jours apres Paques) |
@@ -611,7 +611,7 @@ discard block |
||
| 611 | 611 | ); |
| 612 | 612 | $jour_ascension = date("d", $date_ascension); |
| 613 | 613 | $mois_ascension = date("m", $date_ascension); |
| 614 | - if($jour_ascension == $jour && $mois_ascension == $mois) $ferie=true; |
|
| 614 | + if ($jour_ascension == $jour && $mois_ascension == $mois) $ferie = true; |
|
| 615 | 615 | //Ascension |
| 616 | 616 | |
| 617 | 617 | // Calcul de Pentecote (11 jours apres Paques) |
@@ -625,13 +625,13 @@ discard block |
||
| 625 | 625 | ); |
| 626 | 626 | $jour_pentecote = date("d", $date_pentecote); |
| 627 | 627 | $mois_pentecote = date("m", $date_pentecote); |
| 628 | - if($jour_pentecote == $jour && $mois_pentecote == $mois) $ferie=true; |
|
| 628 | + if ($jour_pentecote == $jour && $mois_pentecote == $mois) $ferie = true; |
|
| 629 | 629 | //Pentecote |
| 630 | 630 | |
| 631 | 631 | // Calul des samedis et dimanches |
| 632 | 632 | $jour_julien = unixtojd($timestampStart); |
| 633 | 633 | $jour_semaine = jddayofweek($jour_julien, 0); |
| 634 | - if($jour_semaine == 0 || $jour_semaine == 6) $ferie=true; |
|
| 634 | + if ($jour_semaine == 0 || $jour_semaine == 6) $ferie = true; |
|
| 635 | 635 | //Samedi (6) et dimanche (0) |
| 636 | 636 | } |
| 637 | 637 | |
@@ -639,54 +639,54 @@ discard block |
||
| 639 | 639 | // Pentecoste is 50 days after Easter, Ascensione 40 |
| 640 | 640 | if ($countrycode == 'IT') |
| 641 | 641 | { |
| 642 | - $countryfound=1; |
|
| 642 | + $countryfound = 1; |
|
| 643 | 643 | |
| 644 | 644 | // Definition des dates feriees fixes |
| 645 | - if($jour == 1 && $mois == 1) $ferie=true; // Capodanno |
|
| 646 | - if($jour == 6 && $mois == 1) $ferie=true; // Epifania |
|
| 647 | - if($jour == 25 && $mois == 4) $ferie=true; // Anniversario Liberazione |
|
| 648 | - if($jour == 1 && $mois == 5) $ferie=true; // Festa del Lavoro |
|
| 649 | - if($jour == 2 && $mois == 6) $ferie=true; // Festa della Repubblica |
|
| 650 | - if($jour == 15 && $mois == 8) $ferie=true; // Ferragosto |
|
| 651 | - if($jour == 1 && $mois == 11) $ferie=true; // Tutti i Santi |
|
| 652 | - if($jour == 8 && $mois == 12) $ferie=true; // Immacolata Concezione |
|
| 653 | - if($jour == 25 && $mois == 12) $ferie=true; // 25 decembre |
|
| 654 | - if($jour == 26 && $mois == 12) $ferie=true; // Santo Stefano |
|
| 645 | + if ($jour == 1 && $mois == 1) $ferie = true; // Capodanno |
|
| 646 | + if ($jour == 6 && $mois == 1) $ferie = true; // Epifania |
|
| 647 | + if ($jour == 25 && $mois == 4) $ferie = true; // Anniversario Liberazione |
|
| 648 | + if ($jour == 1 && $mois == 5) $ferie = true; // Festa del Lavoro |
|
| 649 | + if ($jour == 2 && $mois == 6) $ferie = true; // Festa della Repubblica |
|
| 650 | + if ($jour == 15 && $mois == 8) $ferie = true; // Ferragosto |
|
| 651 | + if ($jour == 1 && $mois == 11) $ferie = true; // Tutti i Santi |
|
| 652 | + if ($jour == 8 && $mois == 12) $ferie = true; // Immacolata Concezione |
|
| 653 | + if ($jour == 25 && $mois == 12) $ferie = true; // 25 decembre |
|
| 654 | + if ($jour == 26 && $mois == 12) $ferie = true; // Santo Stefano |
|
| 655 | 655 | |
| 656 | 656 | // Calcul du jour de paques |
| 657 | 657 | $date_paques = easter_date($annee); |
| 658 | 658 | $jour_paques = date("d", $date_paques); |
| 659 | 659 | $mois_paques = date("m", $date_paques); |
| 660 | - if($jour_paques == $jour && $mois_paques == $mois) $ferie=true; |
|
| 660 | + if ($jour_paques == $jour && $mois_paques == $mois) $ferie = true; |
|
| 661 | 661 | // Paques |
| 662 | 662 | |
| 663 | 663 | // Calul des samedis et dimanches |
| 664 | 664 | $jour_julien = unixtojd($timestampStart); |
| 665 | 665 | $jour_semaine = jddayofweek($jour_julien, 0); |
| 666 | - if($jour_semaine == 0 || $jour_semaine == 6) $ferie=true; |
|
| 666 | + if ($jour_semaine == 0 || $jour_semaine == 6) $ferie = true; |
|
| 667 | 667 | //Samedi (6) et dimanche (0) |
| 668 | 668 | } |
| 669 | 669 | |
| 670 | 670 | if ($countrycode == 'ES') |
| 671 | 671 | { |
| 672 | - $countryfound=1; |
|
| 672 | + $countryfound = 1; |
|
| 673 | 673 | |
| 674 | 674 | // Definition des dates feriees fixes |
| 675 | - if($jour == 1 && $mois == 1) $ferie=true; // Año nuevo |
|
| 676 | - if($jour == 6 && $mois == 1) $ferie=true; // Día Reyes |
|
| 677 | - if($jour == 1 && $mois == 5) $ferie=true; // 1 Mayo |
|
| 678 | - if($jour == 15 && $mois == 8) $ferie=true; // 15 Agosto |
|
| 679 | - if($jour == 12 && $mois == 10) $ferie=true; // Día Hispanidad |
|
| 680 | - if($jour == 1 && $mois == 11) $ferie=true; // 1 noviembre |
|
| 681 | - if($jour == 6 && $mois == 12) $ferie=true; // Constitución |
|
| 682 | - if($jour == 8 && $mois == 12) $ferie=true; // Inmaculada |
|
| 683 | - if($jour == 25 && $mois == 12) $ferie=true; // 25 diciembre |
|
| 675 | + if ($jour == 1 && $mois == 1) $ferie = true; // Año nuevo |
|
| 676 | + if ($jour == 6 && $mois == 1) $ferie = true; // Día Reyes |
|
| 677 | + if ($jour == 1 && $mois == 5) $ferie = true; // 1 Mayo |
|
| 678 | + if ($jour == 15 && $mois == 8) $ferie = true; // 15 Agosto |
|
| 679 | + if ($jour == 12 && $mois == 10) $ferie = true; // Día Hispanidad |
|
| 680 | + if ($jour == 1 && $mois == 11) $ferie = true; // 1 noviembre |
|
| 681 | + if ($jour == 6 && $mois == 12) $ferie = true; // Constitución |
|
| 682 | + if ($jour == 8 && $mois == 12) $ferie = true; // Inmaculada |
|
| 683 | + if ($jour == 25 && $mois == 12) $ferie = true; // 25 diciembre |
|
| 684 | 684 | |
| 685 | 685 | // Calcul día de Pascua |
| 686 | 686 | $date_paques = easter_date($annee); |
| 687 | 687 | $jour_paques = date("d", $date_paques); |
| 688 | 688 | $mois_paques = date("m", $date_paques); |
| 689 | - if($jour_paques == $jour && $mois_paques == $mois) $ferie=true; |
|
| 689 | + if ($jour_paques == $jour && $mois_paques == $mois) $ferie = true; |
|
| 690 | 690 | // Paques |
| 691 | 691 | |
| 692 | 692 | // Viernes Santo |
@@ -695,43 +695,43 @@ discard block |
||
| 695 | 695 | date("i", $date_paques), |
| 696 | 696 | date("s", $date_paques), |
| 697 | 697 | date("m", $date_paques), |
| 698 | - date("d", $date_paques) -2, |
|
| 698 | + date("d", $date_paques) - 2, |
|
| 699 | 699 | date("Y", $date_paques) |
| 700 | 700 | ); |
| 701 | 701 | $jour_viernes = date("d", $date_viernes); |
| 702 | 702 | $mois_viernes = date("m", $date_viernes); |
| 703 | - if($jour_viernes == $jour && $mois_viernes == $mois) $ferie=true; |
|
| 703 | + if ($jour_viernes == $jour && $mois_viernes == $mois) $ferie = true; |
|
| 704 | 704 | //Viernes Santo |
| 705 | 705 | |
| 706 | 706 | // Calul des samedis et dimanches |
| 707 | 707 | $jour_julien = unixtojd($timestampStart); |
| 708 | 708 | $jour_semaine = jddayofweek($jour_julien, 0); |
| 709 | - if($jour_semaine == 0 || $jour_semaine == 6) $ferie=true; |
|
| 709 | + if ($jour_semaine == 0 || $jour_semaine == 6) $ferie = true; |
|
| 710 | 710 | //Samedi (6) et dimanche (0) |
| 711 | 711 | } |
| 712 | 712 | |
| 713 | 713 | if ($countrycode == 'AT') |
| 714 | 714 | { |
| 715 | - $countryfound=1; |
|
| 715 | + $countryfound = 1; |
|
| 716 | 716 | |
| 717 | 717 | // Definition des dates feriees fixes |
| 718 | - if($jour == 1 && $mois == 1) $ferie=true; // Neujahr |
|
| 719 | - if($jour == 6 && $mois == 1) $ferie=true; // Hl. 3 Koenige |
|
| 720 | - if($jour == 1 && $mois == 5) $ferie=true; // 1. Mai |
|
| 721 | - if($jour == 15 && $mois == 8) $ferie=true; // Mariae Himmelfahrt |
|
| 722 | - if($jour == 26 && $mois == 10) $ferie=true; // 26. Oktober |
|
| 723 | - if($jour == 1 && $mois == 11) $ferie=true; // Allerheiligen |
|
| 724 | - if($jour == 8 && $mois == 12) $ferie=true; // Mariae Empfaengnis |
|
| 725 | - if($jour == 24 && $mois == 12) $ferie=true; // Heilig abend |
|
| 726 | - if($jour == 25 && $mois == 12) $ferie=true; // Christtag |
|
| 727 | - if($jour == 26 && $mois == 12) $ferie=true; // Stefanietag |
|
| 728 | - if($jour == 31 && $mois == 12) $ferie=true; // Silvester |
|
| 718 | + if ($jour == 1 && $mois == 1) $ferie = true; // Neujahr |
|
| 719 | + if ($jour == 6 && $mois == 1) $ferie = true; // Hl. 3 Koenige |
|
| 720 | + if ($jour == 1 && $mois == 5) $ferie = true; // 1. Mai |
|
| 721 | + if ($jour == 15 && $mois == 8) $ferie = true; // Mariae Himmelfahrt |
|
| 722 | + if ($jour == 26 && $mois == 10) $ferie = true; // 26. Oktober |
|
| 723 | + if ($jour == 1 && $mois == 11) $ferie = true; // Allerheiligen |
|
| 724 | + if ($jour == 8 && $mois == 12) $ferie = true; // Mariae Empfaengnis |
|
| 725 | + if ($jour == 24 && $mois == 12) $ferie = true; // Heilig abend |
|
| 726 | + if ($jour == 25 && $mois == 12) $ferie = true; // Christtag |
|
| 727 | + if ($jour == 26 && $mois == 12) $ferie = true; // Stefanietag |
|
| 728 | + if ($jour == 31 && $mois == 12) $ferie = true; // Silvester |
|
| 729 | 729 | |
| 730 | 730 | // Easter calculation |
| 731 | 731 | $date_paques = easter_date($annee); |
| 732 | 732 | $jour_paques = date("d", $date_paques); |
| 733 | 733 | $mois_paques = date("m", $date_paques); |
| 734 | - if($jour_paques == $jour && $mois_paques == $mois) $ferie=true; |
|
| 734 | + if ($jour_paques == $jour && $mois_paques == $mois) $ferie = true; |
|
| 735 | 735 | // Easter sunday |
| 736 | 736 | |
| 737 | 737 | // Monday after easter |
@@ -745,7 +745,7 @@ discard block |
||
| 745 | 745 | ); |
| 746 | 746 | $jour_eastermonday = date("d", $date_eastermonday); |
| 747 | 747 | $mois_eastermonday = date("m", $date_eastermonday); |
| 748 | - if($jour_eastermonday == $jour && $mois_eastermonday == $mois) $ferie=true; |
|
| 748 | + if ($jour_eastermonday == $jour && $mois_eastermonday == $mois) $ferie = true; |
|
| 749 | 749 | // Easter monday |
| 750 | 750 | |
| 751 | 751 | // Christi Himmelfahrt (39 days after easter sunday) |
@@ -759,7 +759,7 @@ discard block |
||
| 759 | 759 | ); |
| 760 | 760 | $jour_ch = date("d", $date_ch); |
| 761 | 761 | $mois_ch = date("m", $date_ch); |
| 762 | - if($jour_ch == $jour && $mois_ch == $mois) $ferie=true; |
|
| 762 | + if ($jour_ch == $jour && $mois_ch == $mois) $ferie = true; |
|
| 763 | 763 | // Christi Himmelfahrt |
| 764 | 764 | |
| 765 | 765 | // Pfingsten (50 days after easter sunday) |
@@ -773,7 +773,7 @@ discard block |
||
| 773 | 773 | ); |
| 774 | 774 | $jour_pentecote = date("d", $date_pentecote); |
| 775 | 775 | $mois_pentecote = date("m", $date_pentecote); |
| 776 | - if($jour_pentecote == $jour && $mois_pentecote == $mois) $ferie=true; |
|
| 776 | + if ($jour_pentecote == $jour && $mois_pentecote == $mois) $ferie = true; |
|
| 777 | 777 | // Pfingsten |
| 778 | 778 | |
| 779 | 779 | // Fronleichnam (60 days after easter sunday) |
@@ -787,23 +787,23 @@ discard block |
||
| 787 | 787 | ); |
| 788 | 788 | $jour_fronleichnam = date("d", $date_fronleichnam); |
| 789 | 789 | $mois_fronleichnam = date("m", $date_fronleichnam); |
| 790 | - if($jour_fronleichnam == $jour && $mois_fronleichnam == $mois) $ferie=true; |
|
| 790 | + if ($jour_fronleichnam == $jour && $mois_fronleichnam == $mois) $ferie = true; |
|
| 791 | 791 | // Fronleichnam |
| 792 | 792 | |
| 793 | 793 | // Calul des samedis et dimanches |
| 794 | 794 | $jour_julien = unixtojd($timestampStart); |
| 795 | 795 | $jour_semaine = jddayofweek($jour_julien, 0); |
| 796 | - if($jour_semaine == 0 || $jour_semaine == 6) $ferie=true; |
|
| 796 | + if ($jour_semaine == 0 || $jour_semaine == 6) $ferie = true; |
|
| 797 | 797 | //Samedi (6) et dimanche (0) |
| 798 | 798 | } |
| 799 | 799 | |
| 800 | 800 | // Cas pays non defini |
| 801 | - if (! $countryfound) |
|
| 801 | + if (!$countryfound) |
|
| 802 | 802 | { |
| 803 | 803 | // Calul des samedis et dimanches |
| 804 | 804 | $jour_julien = unixtojd($timestampStart); |
| 805 | 805 | $jour_semaine = jddayofweek($jour_julien, 0); |
| 806 | - if($jour_semaine == 0 || $jour_semaine == 6) $ferie=true; |
|
| 806 | + if ($jour_semaine == 0 || $jour_semaine == 6) $ferie = true; |
|
| 807 | 807 | //Samedi (6) et dimanche (0) |
| 808 | 808 | } |
| 809 | 809 | |
@@ -811,7 +811,7 @@ discard block |
||
| 811 | 811 | if ($ferie) $nbFerie++; |
| 812 | 812 | |
| 813 | 813 | // Increase number of days (on go up into loop) |
| 814 | - $timestampStart=dol_time_plus_duree($timestampStart, 1, 'd'); |
|
| 814 | + $timestampStart = dol_time_plus_duree($timestampStart, 1, 'd'); |
|
| 815 | 815 | //var_dump($jour.' '.$mois.' '.$annee.' '.$timestampStart); |
| 816 | 816 | |
| 817 | 817 | $i++; |
@@ -830,7 +830,7 @@ discard block |
||
| 830 | 830 | * @return int Number of days |
| 831 | 831 | * @see also num_public_holiday, num_open_day |
| 832 | 832 | */ |
| 833 | -function num_between_day($timestampStart, $timestampEnd, $lastday=0) |
|
| 833 | +function num_between_day($timestampStart, $timestampEnd, $lastday = 0) |
|
| 834 | 834 | { |
| 835 | 835 | if ($timestampStart < $timestampEnd) |
| 836 | 836 | { |
@@ -842,7 +842,7 @@ discard block |
||
| 842 | 842 | { |
| 843 | 843 | $bit = 1; |
| 844 | 844 | } |
| 845 | - $nbjours = (int) floor(($timestampEnd - $timestampStart)/(60*60*24)) + 1 - $bit; |
|
| 845 | + $nbjours = (int) floor(($timestampEnd - $timestampStart) / (60 * 60 * 24)) + 1 - $bit; |
|
| 846 | 846 | } |
| 847 | 847 | //print ($timestampEnd - $timestampStart) - $lastday; |
| 848 | 848 | return $nbjours; |
@@ -860,17 +860,17 @@ discard block |
||
| 860 | 860 | * @return int Number of days or hours |
| 861 | 861 | * @see also num_between_day, num_public_holiday |
| 862 | 862 | */ |
| 863 | -function num_open_day($timestampStart, $timestampEnd, $inhour=0, $lastday=0, $halfday=0, $country_code='') |
|
| 863 | +function num_open_day($timestampStart, $timestampEnd, $inhour = 0, $lastday = 0, $halfday = 0, $country_code = '') |
|
| 864 | 864 | { |
| 865 | - global $langs,$mysoc; |
|
| 865 | + global $langs, $mysoc; |
|
| 866 | 866 | |
| 867 | - if (empty($country_code)) $country_code=$mysoc->country_code; |
|
| 867 | + if (empty($country_code)) $country_code = $mysoc->country_code; |
|
| 868 | 868 | |
| 869 | 869 | dol_syslog('num_open_day timestampStart='.$timestampStart.' timestampEnd='.$timestampEnd.' bit='.$lastday.' country_code='.$country_code); |
| 870 | 870 | |
| 871 | 871 | // Check parameters |
| 872 | - if (! is_int($timestampStart) && ! is_float($timestampStart)) return 'ErrorBadParameter_num_open_day'; |
|
| 873 | - if (! is_int($timestampEnd) && ! is_float($timestampEnd)) return 'ErrorBadParameter_num_open_day'; |
|
| 872 | + if (!is_int($timestampStart) && !is_float($timestampStart)) return 'ErrorBadParameter_num_open_day'; |
|
| 873 | + if (!is_int($timestampEnd) && !is_float($timestampEnd)) return 'ErrorBadParameter_num_open_day'; |
|
| 874 | 874 | |
| 875 | 875 | //print 'num_open_day timestampStart='.$timestampStart.' timestampEnd='.$timestampEnd.' bit='.$lastday; |
| 876 | 876 | if ($timestampStart < $timestampEnd) |
@@ -878,14 +878,14 @@ discard block |
||
| 878 | 878 | $numdays = num_between_day($timestampStart, $timestampEnd, $lastday); |
| 879 | 879 | $numholidays = num_public_holiday($timestampStart, $timestampEnd, $country_code, $lastday); |
| 880 | 880 | $nbOpenDay = $numdays - $numholidays; |
| 881 | - $nbOpenDay.= " " . $langs->trans("Days"); |
|
| 882 | - if ($inhour == 1 && $nbOpenDay <= 3) $nbOpenDay = $nbOpenDay*24 . $langs->trans("HourShort"); |
|
| 881 | + $nbOpenDay .= " ".$langs->trans("Days"); |
|
| 882 | + if ($inhour == 1 && $nbOpenDay <= 3) $nbOpenDay = $nbOpenDay * 24.$langs->trans("HourShort"); |
|
| 883 | 883 | return $nbOpenDay - (($inhour == 1 ? 12 : 0.5) * abs($halfday)); |
| 884 | 884 | } |
| 885 | 885 | elseif ($timestampStart == $timestampEnd) |
| 886 | 886 | { |
| 887 | - $nbOpenDay=$lastday; |
|
| 888 | - if ($inhour == 1) $nbOpenDay = $nbOpenDay*24 . $langs->trans("HourShort"); |
|
| 887 | + $nbOpenDay = $lastday; |
|
| 888 | + if ($inhour == 1) $nbOpenDay = $nbOpenDay * 24.$langs->trans("HourShort"); |
|
| 889 | 889 | return $nbOpenDay - (($inhour == 1 ? 12 : 0.5) * abs($halfday)); |
| 890 | 890 | } |
| 891 | 891 | else |
@@ -904,9 +904,9 @@ discard block |
||
| 904 | 904 | * @param int $short 1=Return short label |
| 905 | 905 | * @return array Month string or array if selected < 0 |
| 906 | 906 | */ |
| 907 | -function monthArray($outputlangs,$short=0) |
|
| 907 | +function monthArray($outputlangs, $short = 0) |
|
| 908 | 908 | { |
| 909 | - $montharray = array ( |
|
| 909 | + $montharray = array( |
|
| 910 | 910 | 1 => $outputlangs->trans("January"), |
| 911 | 911 | 2 => $outputlangs->trans("February"), |
| 912 | 912 | 3 => $outputlangs->trans("March"), |
@@ -921,9 +921,9 @@ discard block |
||
| 921 | 921 | 12 => $outputlangs->trans("December") |
| 922 | 922 | ); |
| 923 | 923 | |
| 924 | - if (! empty($short)) |
|
| 924 | + if (!empty($short)) |
|
| 925 | 925 | { |
| 926 | - $montharray = array ( |
|
| 926 | + $montharray = array( |
|
| 927 | 927 | 1 => $outputlangs->trans("JanuaryMin"), |
| 928 | 928 | 2 => $outputlangs->trans("FebruaryMin"), |
| 929 | 929 | 3 => $outputlangs->trans("MarchMin"), |
@@ -269,7 +269,7 @@ discard block |
||
| 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 |
||
| 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 | { |
@@ -44,16 +44,16 @@ discard block |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 " "; |
| 456 | 456 | } |
@@ -461,7 +461,7 @@ discard block |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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>'; |
@@ -592,48 +592,48 @@ discard block |
||
| 592 | 592 | * @param int $oldprojectforbreak Old project id of last project break |
| 593 | 593 | * @return array Array with time spent for $fuser for each day of week on tasks in $lines and substasks |
| 594 | 594 | */ |
| 595 | -function projectLinesPerAction(&$inc, $parent, $fuser, $lines, &$level, &$projectsrole, &$tasksrole, $mine, $restricteditformytask, $preselectedday, &$isavailable, $oldprojectforbreak=0) |
|
| 595 | +function projectLinesPerAction(&$inc, $parent, $fuser, $lines, &$level, &$projectsrole, &$tasksrole, $mine, $restricteditformytask, $preselectedday, &$isavailable, $oldprojectforbreak = 0) |
|
| 596 | 596 | { |
| 597 | 597 | global $conf, $db, $user, $bc, $langs; |
| 598 | 598 | global $form, $formother, $projectstatic, $taskstatic, $thirdpartystatic; |
| 599 | 599 | |
| 600 | - $lastprojectid=0; |
|
| 601 | - $totalforeachline=array(); |
|
| 602 | - $workloadforid=array(); |
|
| 603 | - $lineswithoutlevel0=array(); |
|
| 600 | + $lastprojectid = 0; |
|
| 601 | + $totalforeachline = array(); |
|
| 602 | + $workloadforid = array(); |
|
| 603 | + $lineswithoutlevel0 = array(); |
|
| 604 | 604 | |
| 605 | - $numlines=count($lines); |
|
| 605 | + $numlines = count($lines); |
|
| 606 | 606 | |
| 607 | 607 | // Create a smaller array with sublevels only to be used later. This increase dramatically performances. |
| 608 | 608 | if ($parent == 0) // Always and only if at first level |
| 609 | 609 | { |
| 610 | - for ($i = 0 ; $i < $numlines ; $i++) |
|
| 610 | + for ($i = 0; $i < $numlines; $i++) |
|
| 611 | 611 | { |
| 612 | - if ($lines[$i]->fk_task_parent) $lineswithoutlevel0[]=$lines[$i]; |
|
| 612 | + if ($lines[$i]->fk_task_parent) $lineswithoutlevel0[] = $lines[$i]; |
|
| 613 | 613 | } |
| 614 | 614 | } |
| 615 | 615 | |
| 616 | 616 | if (empty($oldprojectforbreak)) |
| 617 | 617 | { |
| 618 | - $oldprojectforbreak = (empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT)?0:-1); // 0 to start break , -1 no break |
|
| 618 | + $oldprojectforbreak = (empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT) ? 0 : -1); // 0 to start break , -1 no break |
|
| 619 | 619 | } |
| 620 | 620 | |
| 621 | 621 | //dol_syslog('projectLinesPerDay inc='.$inc.' preselectedday='.$preselectedday.' task parent id='.$parent.' level='.$level." count(lines)=".$numlines." count(lineswithoutlevel0)=".count($lineswithoutlevel0)); |
| 622 | - for ($i = 0 ; $i < $numlines ; $i++) |
|
| 622 | + for ($i = 0; $i < $numlines; $i++) |
|
| 623 | 623 | { |
| 624 | 624 | if ($parent == 0) $level = 0; |
| 625 | 625 | |
| 626 | 626 | //if ($lines[$i]->fk_task_parent == $parent) |
| 627 | 627 | //{ |
| 628 | 628 | // If we want all or we have a role on task, we show it |
| 629 | - if (empty($mine) || ! empty($tasksrole[$lines[$i]->id])) |
|
| 629 | + if (empty($mine) || !empty($tasksrole[$lines[$i]->id])) |
|
| 630 | 630 | { |
| 631 | 631 | //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); |
| 632 | 632 | |
| 633 | 633 | // Break on a new project |
| 634 | 634 | if ($parent == 0 && $lines[$i]->fk_project != $lastprojectid) |
| 635 | 635 | { |
| 636 | - $lastprojectid=$lines[$i]->fk_project; |
|
| 636 | + $lastprojectid = $lines[$i]->fk_project; |
|
| 637 | 637 | if ($preselectedday) |
| 638 | 638 | { |
| 639 | 639 | $projectstatic->id = $lines[$i]->fk_project; |
@@ -644,31 +644,31 @@ discard block |
||
| 644 | 644 | { |
| 645 | 645 | if ($preselectedday) |
| 646 | 646 | { |
| 647 | - $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 |
|
| 648 | - $workloadforid[$projectstatic->id]=1; |
|
| 647 | + $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 |
|
| 648 | + $workloadforid[$projectstatic->id] = 1; |
|
| 649 | 649 | } |
| 650 | 650 | } |
| 651 | 651 | |
| 652 | - $projectstatic->id=$lines[$i]->fk_project; |
|
| 653 | - $projectstatic->ref=$lines[$i]->project_ref; |
|
| 654 | - $projectstatic->title=$lines[$i]->project_label; |
|
| 655 | - $projectstatic->public=$lines[$i]->public; |
|
| 652 | + $projectstatic->id = $lines[$i]->fk_project; |
|
| 653 | + $projectstatic->ref = $lines[$i]->project_ref; |
|
| 654 | + $projectstatic->title = $lines[$i]->project_label; |
|
| 655 | + $projectstatic->public = $lines[$i]->public; |
|
| 656 | 656 | |
| 657 | - $taskstatic->id=$lines[$i]->task_id; |
|
| 658 | - $taskstatic->ref=($lines[$i]->task_ref?$lines[$i]->task_ref:$lines[$i]->task_id); |
|
| 659 | - $taskstatic->label=$lines[$i]->task_label; |
|
| 660 | - $taskstatic->date_start=$lines[$i]->date_start; |
|
| 661 | - $taskstatic->date_end=$lines[$i]->date_end; |
|
| 657 | + $taskstatic->id = $lines[$i]->task_id; |
|
| 658 | + $taskstatic->ref = ($lines[$i]->task_ref ? $lines[$i]->task_ref : $lines[$i]->task_id); |
|
| 659 | + $taskstatic->label = $lines[$i]->task_label; |
|
| 660 | + $taskstatic->date_start = $lines[$i]->date_start; |
|
| 661 | + $taskstatic->date_end = $lines[$i]->date_end; |
|
| 662 | 662 | |
| 663 | - $thirdpartystatic->id=$lines[$i]->socid; |
|
| 664 | - $thirdpartystatic->name=$lines[$i]->thirdparty_name; |
|
| 665 | - $thirdpartystatic->email=$lines[$i]->thirdparty_email; |
|
| 663 | + $thirdpartystatic->id = $lines[$i]->socid; |
|
| 664 | + $thirdpartystatic->name = $lines[$i]->thirdparty_name; |
|
| 665 | + $thirdpartystatic->email = $lines[$i]->thirdparty_email; |
|
| 666 | 666 | |
| 667 | 667 | if (empty($oldprojectforbreak) || ($oldprojectforbreak != -1 && $oldprojectforbreak != $projectstatic->id)) |
| 668 | 668 | { |
| 669 | 669 | print '<tr class="oddeven trforbreak">'."\n"; |
| 670 | 670 | print '<td colspan="11">'; |
| 671 | - print $projectstatic->getNomUrl(1,'',0,$langs->transnoentitiesnoconv("YourRole").': '.$projectsrole[$lines[$i]->fk_project]); |
|
| 671 | + print $projectstatic->getNomUrl(1, '', 0, $langs->transnoentitiesnoconv("YourRole").': '.$projectsrole[$lines[$i]->fk_project]); |
|
| 672 | 672 | if ($projectstatic->title) |
| 673 | 673 | { |
| 674 | 674 | print ' - '; |
@@ -693,7 +693,7 @@ discard block |
||
| 693 | 693 | print "<td>"; |
| 694 | 694 | if ($oldprojectforbreak == -1) |
| 695 | 695 | { |
| 696 | - print $projectstatic->getNomUrl(1,'',0,$langs->transnoentitiesnoconv("YourRole").': '.$projectsrole[$lines[$i]->fk_project]); |
|
| 696 | + print $projectstatic->getNomUrl(1, '', 0, $langs->transnoentitiesnoconv("YourRole").': '.$projectsrole[$lines[$i]->fk_project]); |
|
| 697 | 697 | print '<br>'.$projectstatic->title; |
| 698 | 698 | } |
| 699 | 699 | print "</td>"; |
@@ -706,11 +706,11 @@ discard block |
||
| 706 | 706 | // Ref |
| 707 | 707 | print '<td>'; |
| 708 | 708 | print '<!-- Task id = '.$lines[$i]->id.' -->'; |
| 709 | - for ($k = 0 ; $k < $level ; $k++) print " "; |
|
| 709 | + for ($k = 0; $k < $level; $k++) print " "; |
|
| 710 | 710 | print $taskstatic->getNomUrl(1, 'withproject', 'time'); |
| 711 | 711 | // Label task |
| 712 | 712 | print '<br>'; |
| 713 | - for ($k = 0 ; $k < $level ; $k++) print " "; |
|
| 713 | + for ($k = 0; $k < $level; $k++) print " "; |
|
| 714 | 714 | print $taskstatic->label; |
| 715 | 715 | //print "<br>"; |
| 716 | 716 | //for ($k = 0 ; $k < $level ; $k++) print " "; |
@@ -719,47 +719,47 @@ discard block |
||
| 719 | 719 | |
| 720 | 720 | // Date |
| 721 | 721 | print '<td align="center">'; |
| 722 | - print dol_print_date($lines[$i]->timespent_datehour,'day'); |
|
| 722 | + print dol_print_date($lines[$i]->timespent_datehour, 'day'); |
|
| 723 | 723 | print '</td>'; |
| 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 | // Hour |
| 742 | 742 | print '<td class="nowrap" align="center">'; |
| 743 | - print dol_print_date($lines[$i]->timespent_datehour,'hour'); |
|
| 743 | + print dol_print_date($lines[$i]->timespent_datehour, 'hour'); |
|
| 744 | 744 | print '</td>'; |
| 745 | 745 | |
| 746 | - $cssonholiday=''; |
|
| 747 | - if (! $isavailable[$preselectedday]['morning'] && ! $isavailable[$preselectedday]['afternoon']) $cssonholiday.='onholidayallday '; |
|
| 748 | - elseif (! $isavailable[$preselectedday]['morning']) $cssonholiday.='onholidaymorning '; |
|
| 749 | - elseif (! $isavailable[$preselectedday]['afternoon']) $cssonholiday.='onholidayafternoon '; |
|
| 746 | + $cssonholiday = ''; |
|
| 747 | + if (!$isavailable[$preselectedday]['morning'] && !$isavailable[$preselectedday]['afternoon']) $cssonholiday .= 'onholidayallday '; |
|
| 748 | + elseif (!$isavailable[$preselectedday]['morning']) $cssonholiday .= 'onholidaymorning '; |
|
| 749 | + elseif (!$isavailable[$preselectedday]['afternoon']) $cssonholiday .= 'onholidayafternoon '; |
|
| 750 | 750 | |
| 751 | 751 | // Duration |
| 752 | - print '<td align="center" class="duration'.($cssonholiday?' '.$cssonholiday:'').'">'; |
|
| 752 | + print '<td align="center" class="duration'.($cssonholiday ? ' '.$cssonholiday : '').'">'; |
|
| 753 | 753 | |
| 754 | 754 | $dayWorkLoad = $lines[$i]->timespent_duration; |
| 755 | - $totalforeachline[$preselectedday]+=$lines[$i]->timespent_duration; |
|
| 755 | + $totalforeachline[$preselectedday] += $lines[$i]->timespent_duration; |
|
| 756 | 756 | |
| 757 | - $alreadyspent=''; |
|
| 758 | - if ($dayWorkLoad > 0) $alreadyspent=convertSecondToTime($lines[$i]->timespent_duration,'allhourmin'); |
|
| 757 | + $alreadyspent = ''; |
|
| 758 | + if ($dayWorkLoad > 0) $alreadyspent = convertSecondToTime($lines[$i]->timespent_duration, 'allhourmin'); |
|
| 759 | 759 | |
| 760 | - print convertSecondToTime($lines[$i]->timespent_duration,'allhourmin'); |
|
| 760 | + print convertSecondToTime($lines[$i]->timespent_duration, 'allhourmin'); |
|
| 761 | 761 | |
| 762 | - $modeinput='hours'; |
|
| 762 | + $modeinput = 'hours'; |
|
| 763 | 763 | |
| 764 | 764 | print '<script type="text/javascript">'; |
| 765 | 765 | print "jQuery(document).ready(function () {\n"; |
@@ -771,7 +771,7 @@ discard block |
||
| 771 | 771 | |
| 772 | 772 | // Note |
| 773 | 773 | print '<td align="center">'; |
| 774 | - print '<textarea name="'.$lines[$i]->id.'note" rows="'.ROWS_2.'" id="'.$lines[$i]->id.'note"'.($disabledtask?' disabled="disabled"':'').'>'; |
|
| 774 | + print '<textarea name="'.$lines[$i]->id.'note" rows="'.ROWS_2.'" id="'.$lines[$i]->id.'note"'.($disabledtask ? ' disabled="disabled"' : '').'>'; |
|
| 775 | 775 | print $lines[$i]->timespent_note; |
| 776 | 776 | print '</textarea>'; |
| 777 | 777 | print '</td>'; |
@@ -818,48 +818,48 @@ discard block |
||
| 818 | 818 | * @param int $oldprojectforbreak Old project id of last project break |
| 819 | 819 | * @return array Array with time spent for $fuser for each day of week on tasks in $lines and substasks |
| 820 | 820 | */ |
| 821 | -function projectLinesPerDay(&$inc, $parent, $fuser, $lines, &$level, &$projectsrole, &$tasksrole, $mine, $restricteditformytask, $preselectedday, &$isavailable, $oldprojectforbreak=0) |
|
| 821 | +function projectLinesPerDay(&$inc, $parent, $fuser, $lines, &$level, &$projectsrole, &$tasksrole, $mine, $restricteditformytask, $preselectedday, &$isavailable, $oldprojectforbreak = 0) |
|
| 822 | 822 | { |
| 823 | 823 | global $conf, $db, $user, $bc, $langs; |
| 824 | 824 | global $form, $formother, $projectstatic, $taskstatic, $thirdpartystatic; |
| 825 | 825 | |
| 826 | - $lastprojectid=0; |
|
| 827 | - $totalforeachday=array(); |
|
| 828 | - $workloadforid=array(); |
|
| 829 | - $lineswithoutlevel0=array(); |
|
| 826 | + $lastprojectid = 0; |
|
| 827 | + $totalforeachday = array(); |
|
| 828 | + $workloadforid = array(); |
|
| 829 | + $lineswithoutlevel0 = array(); |
|
| 830 | 830 | |
| 831 | - $numlines=count($lines); |
|
| 831 | + $numlines = count($lines); |
|
| 832 | 832 | |
| 833 | 833 | // Create a smaller array with sublevels only to be used later. This increase dramatically performances. |
| 834 | 834 | if ($parent == 0) // Always and only if at first level |
| 835 | 835 | { |
| 836 | - for ($i = 0 ; $i < $numlines ; $i++) |
|
| 836 | + for ($i = 0; $i < $numlines; $i++) |
|
| 837 | 837 | { |
| 838 | - if ($lines[$i]->fk_task_parent) $lineswithoutlevel0[]=$lines[$i]; |
|
| 838 | + if ($lines[$i]->fk_task_parent) $lineswithoutlevel0[] = $lines[$i]; |
|
| 839 | 839 | } |
| 840 | 840 | } |
| 841 | 841 | |
| 842 | 842 | if (empty($oldprojectforbreak)) |
| 843 | 843 | { |
| 844 | - $oldprojectforbreak = (empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT)?0:-1); // 0 to start break , -1 no break |
|
| 844 | + $oldprojectforbreak = (empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT) ? 0 : -1); // 0 to start break , -1 no break |
|
| 845 | 845 | } |
| 846 | 846 | |
| 847 | 847 | //dol_syslog('projectLinesPerDay inc='.$inc.' preselectedday='.$preselectedday.' task parent id='.$parent.' level='.$level." count(lines)=".$numlines." count(lineswithoutlevel0)=".count($lineswithoutlevel0)); |
| 848 | - for ($i = 0 ; $i < $numlines ; $i++) |
|
| 848 | + for ($i = 0; $i < $numlines; $i++) |
|
| 849 | 849 | { |
| 850 | 850 | if ($parent == 0) $level = 0; |
| 851 | 851 | |
| 852 | 852 | if ($lines[$i]->fk_task_parent == $parent) |
| 853 | 853 | { |
| 854 | 854 | // If we want all or we have a role on task, we show it |
| 855 | - if (empty($mine) || ! empty($tasksrole[$lines[$i]->id])) |
|
| 855 | + if (empty($mine) || !empty($tasksrole[$lines[$i]->id])) |
|
| 856 | 856 | { |
| 857 | 857 | //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); |
| 858 | 858 | |
| 859 | 859 | // Break on a new project |
| 860 | 860 | if ($parent == 0 && $lines[$i]->fk_project != $lastprojectid) |
| 861 | 861 | { |
| 862 | - $lastprojectid=$lines[$i]->fk_project; |
|
| 862 | + $lastprojectid = $lines[$i]->fk_project; |
|
| 863 | 863 | if ($preselectedday) |
| 864 | 864 | { |
| 865 | 865 | $projectstatic->id = $lines[$i]->fk_project; |
@@ -870,31 +870,31 @@ discard block |
||
| 870 | 870 | { |
| 871 | 871 | if ($preselectedday) |
| 872 | 872 | { |
| 873 | - $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 |
|
| 874 | - $workloadforid[$projectstatic->id]=1; |
|
| 873 | + $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 |
|
| 874 | + $workloadforid[$projectstatic->id] = 1; |
|
| 875 | 875 | } |
| 876 | 876 | } |
| 877 | 877 | |
| 878 | - $projectstatic->id=$lines[$i]->fk_project; |
|
| 879 | - $projectstatic->ref=$lines[$i]->projectref; |
|
| 880 | - $projectstatic->title=$lines[$i]->projectlabel; |
|
| 881 | - $projectstatic->public=$lines[$i]->public; |
|
| 878 | + $projectstatic->id = $lines[$i]->fk_project; |
|
| 879 | + $projectstatic->ref = $lines[$i]->projectref; |
|
| 880 | + $projectstatic->title = $lines[$i]->projectlabel; |
|
| 881 | + $projectstatic->public = $lines[$i]->public; |
|
| 882 | 882 | |
| 883 | - $taskstatic->id=$lines[$i]->id; |
|
| 884 | - $taskstatic->ref=($lines[$i]->ref?$lines[$i]->ref:$lines[$i]->id); |
|
| 885 | - $taskstatic->label=$lines[$i]->label; |
|
| 886 | - $taskstatic->date_start=$lines[$i]->date_start; |
|
| 887 | - $taskstatic->date_end=$lines[$i]->date_end; |
|
| 883 | + $taskstatic->id = $lines[$i]->id; |
|
| 884 | + $taskstatic->ref = ($lines[$i]->ref ? $lines[$i]->ref : $lines[$i]->id); |
|
| 885 | + $taskstatic->label = $lines[$i]->label; |
|
| 886 | + $taskstatic->date_start = $lines[$i]->date_start; |
|
| 887 | + $taskstatic->date_end = $lines[$i]->date_end; |
|
| 888 | 888 | |
| 889 | - $thirdpartystatic->id=$lines[$i]->socid; |
|
| 890 | - $thirdpartystatic->name=$lines[$i]->thirdparty_name; |
|
| 891 | - $thirdpartystatic->email=$lines[$i]->thirdparty_email; |
|
| 889 | + $thirdpartystatic->id = $lines[$i]->socid; |
|
| 890 | + $thirdpartystatic->name = $lines[$i]->thirdparty_name; |
|
| 891 | + $thirdpartystatic->email = $lines[$i]->thirdparty_email; |
|
| 892 | 892 | |
| 893 | 893 | if (empty($oldprojectforbreak) || ($oldprojectforbreak != -1 && $oldprojectforbreak != $projectstatic->id)) |
| 894 | 894 | { |
| 895 | 895 | print '<tr class="oddeven trforbreak">'."\n"; |
| 896 | 896 | print '<td colspan="11">'; |
| 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 | if ($projectstatic->title) |
| 899 | 899 | { |
| 900 | 900 | print ' - '; |
@@ -917,7 +917,7 @@ discard block |
||
| 917 | 917 | |
| 918 | 918 | // Project |
| 919 | 919 | print "<td>"; |
| 920 | - if ($oldprojectforbreak == -1) print $projectstatic->getNomUrl(1,'',0,$langs->transnoentitiesnoconv("YourRole").': '.$projectsrole[$lines[$i]->fk_project]); |
|
| 920 | + if ($oldprojectforbreak == -1) print $projectstatic->getNomUrl(1, '', 0, $langs->transnoentitiesnoconv("YourRole").': '.$projectsrole[$lines[$i]->fk_project]); |
|
| 921 | 921 | print "</td>"; |
| 922 | 922 | |
| 923 | 923 | // Thirdparty |
@@ -928,11 +928,11 @@ discard block |
||
| 928 | 928 | // Ref |
| 929 | 929 | print '<td>'; |
| 930 | 930 | print '<!-- Task id = '.$lines[$i]->id.' -->'; |
| 931 | - for ($k = 0 ; $k < $level ; $k++) print " "; |
|
| 931 | + for ($k = 0; $k < $level; $k++) print " "; |
|
| 932 | 932 | print $taskstatic->getNomUrl(1, 'withproject', 'time'); |
| 933 | 933 | // Label task |
| 934 | 934 | print '<br>'; |
| 935 | - for ($k = 0 ; $k < $level ; $k++) print " "; |
|
| 935 | + for ($k = 0; $k < $level; $k++) print " "; |
|
| 936 | 936 | print $taskstatic->label; |
| 937 | 937 | //print "<br>"; |
| 938 | 938 | //for ($k = 0 ; $k < $level ; $k++) print " "; |
@@ -941,13 +941,13 @@ discard block |
||
| 941 | 941 | |
| 942 | 942 | // Planned Workload |
| 943 | 943 | print '<td align="right" class="leftborder plannedworkload">'; |
| 944 | - if ($lines[$i]->planned_workload) print convertSecondToTime($lines[$i]->planned_workload,'allhourmin'); |
|
| 944 | + if ($lines[$i]->planned_workload) print convertSecondToTime($lines[$i]->planned_workload, 'allhourmin'); |
|
| 945 | 945 | else print '--:--'; |
| 946 | 946 | print '</td>'; |
| 947 | 947 | |
| 948 | 948 | // Progress declared % |
| 949 | 949 | print '<td align="right">'; |
| 950 | - print $formother->select_percent($lines[$i]->progress, $lines[$i]->id . 'progress'); |
|
| 950 | + print $formother->select_percent($lines[$i]->progress, $lines[$i]->id.'progress'); |
|
| 951 | 951 | print '</td>'; |
| 952 | 952 | |
| 953 | 953 | // Time spent by everybody |
@@ -956,7 +956,7 @@ discard block |
||
| 956 | 956 | if ($lines[$i]->duration) |
| 957 | 957 | { |
| 958 | 958 | print '<a href="'.DOL_URL_ROOT.'/projet/tasks/time.php?id='.$lines[$i]->id.'">'; |
| 959 | - print convertSecondToTime($lines[$i]->duration,'allhourmin'); |
|
| 959 | + print convertSecondToTime($lines[$i]->duration, 'allhourmin'); |
|
| 960 | 960 | print '</a>'; |
| 961 | 961 | } |
| 962 | 962 | else print '--:--'; |
@@ -964,68 +964,68 @@ discard block |
||
| 964 | 964 | |
| 965 | 965 | // Time spent by user |
| 966 | 966 | print '<td align="right">'; |
| 967 | - $tmptimespent=$taskstatic->getSummaryOfTimeSpent($fuser->id); |
|
| 968 | - if ($tmptimespent['total_duration']) print convertSecondToTime($tmptimespent['total_duration'],'allhourmin'); |
|
| 967 | + $tmptimespent = $taskstatic->getSummaryOfTimeSpent($fuser->id); |
|
| 968 | + if ($tmptimespent['total_duration']) print convertSecondToTime($tmptimespent['total_duration'], 'allhourmin'); |
|
| 969 | 969 | else print '--:--'; |
| 970 | 970 | print "</td>\n"; |
| 971 | 971 | |
| 972 | - $disabledproject=1;$disabledtask=1; |
|
| 972 | + $disabledproject = 1; $disabledtask = 1; |
|
| 973 | 973 | //print "x".$lines[$i]->fk_project; |
| 974 | 974 | //var_dump($lines[$i]); |
| 975 | 975 | //var_dump($projectsrole[$lines[$i]->fk_project]); |
| 976 | 976 | // If at least one role for project |
| 977 | - if ($lines[$i]->public || ! empty($projectsrole[$lines[$i]->fk_project]) || $user->rights->projet->all->creer) |
|
| 977 | + if ($lines[$i]->public || !empty($projectsrole[$lines[$i]->fk_project]) || $user->rights->projet->all->creer) |
|
| 978 | 978 | { |
| 979 | - $disabledproject=0; |
|
| 980 | - $disabledtask=0; |
|
| 979 | + $disabledproject = 0; |
|
| 980 | + $disabledtask = 0; |
|
| 981 | 981 | } |
| 982 | 982 | // If $restricteditformytask is on and I have no role on task, i disable edit |
| 983 | 983 | if ($restricteditformytask && empty($tasksrole[$lines[$i]->id])) |
| 984 | 984 | { |
| 985 | - $disabledtask=1; |
|
| 985 | + $disabledtask = 1; |
|
| 986 | 986 | } |
| 987 | 987 | |
| 988 | 988 | // Form to add new time |
| 989 | 989 | print '<td class="nowrap leftborder" align="center">'; |
| 990 | - $tableCell=$form->select_date($preselectedday,$lines[$i]->id,1,1,2,"addtime",0,0,1,$disabledtask); |
|
| 990 | + $tableCell = $form->select_date($preselectedday, $lines[$i]->id, 1, 1, 2, "addtime", 0, 0, 1, $disabledtask); |
|
| 991 | 991 | print $tableCell; |
| 992 | 992 | print '</td>'; |
| 993 | 993 | |
| 994 | - $cssonholiday=''; |
|
| 995 | - if (! $isavailable[$preselectedday]['morning'] && ! $isavailable[$preselectedday]['afternoon']) $cssonholiday.='onholidayallday '; |
|
| 996 | - elseif (! $isavailable[$preselectedday]['morning']) $cssonholiday.='onholidaymorning '; |
|
| 997 | - elseif (! $isavailable[$preselectedday]['afternoon']) $cssonholiday.='onholidayafternoon '; |
|
| 994 | + $cssonholiday = ''; |
|
| 995 | + if (!$isavailable[$preselectedday]['morning'] && !$isavailable[$preselectedday]['afternoon']) $cssonholiday .= 'onholidayallday '; |
|
| 996 | + elseif (!$isavailable[$preselectedday]['morning']) $cssonholiday .= 'onholidaymorning '; |
|
| 997 | + elseif (!$isavailable[$preselectedday]['afternoon']) $cssonholiday .= 'onholidayafternoon '; |
|
| 998 | 998 | |
| 999 | 999 | global $daytoparse; |
| 1000 | - $tmparray = dol_getdate($daytoparse,true); // detail of current day |
|
| 1000 | + $tmparray = dol_getdate($daytoparse, true); // detail of current day |
|
| 1001 | 1001 | $idw = $tmparray['wday']; |
| 1002 | 1002 | |
| 1003 | 1003 | global $numstartworkingday, $numendworkingday; |
| 1004 | - $cssweekend=''; |
|
| 1004 | + $cssweekend = ''; |
|
| 1005 | 1005 | if (($idw + 1) < $numstartworkingday || ($idw + 1) > $numendworkingday) // This is a day is not inside the setup of working days, so we use a week-end css. |
| 1006 | 1006 | { |
| 1007 | - $cssweekend='weekend'; |
|
| 1007 | + $cssweekend = 'weekend'; |
|
| 1008 | 1008 | } |
| 1009 | 1009 | |
| 1010 | 1010 | // Duration |
| 1011 | - print '<td class="center duration'.($cssonholiday?' '.$cssonholiday:'').($cssweekend?' '.$cssweekend:'').'">'; |
|
| 1011 | + print '<td class="center duration'.($cssonholiday ? ' '.$cssonholiday : '').($cssweekend ? ' '.$cssweekend : '').'">'; |
|
| 1012 | 1012 | $dayWorkLoad = $projectstatic->weekWorkLoadPerTask[$preselectedday][$lines[$i]->id]; |
| 1013 | - $totalforeachday[$preselectedday]+=$dayWorkLoad; |
|
| 1013 | + $totalforeachday[$preselectedday] += $dayWorkLoad; |
|
| 1014 | 1014 | |
| 1015 | - $alreadyspent=''; |
|
| 1016 | - if ($dayWorkLoad > 0) $alreadyspent=convertSecondToTime($dayWorkLoad,'allhourmin'); |
|
| 1015 | + $alreadyspent = ''; |
|
| 1016 | + if ($dayWorkLoad > 0) $alreadyspent = convertSecondToTime($dayWorkLoad, 'allhourmin'); |
|
| 1017 | 1017 | |
| 1018 | 1018 | $idw = 0; |
| 1019 | 1019 | |
| 1020 | - $tableCell=''; |
|
| 1021 | - $tableCell.='<span class="timesheetalreadyrecorded" title="texttoreplace"><input type="text" class="center" size="2" disabled id="timespent['.$inc.']['.$idw.']" name="task['.$lines[$i]->id.']['.$idw.']" value="'.$alreadyspent.'"></span>'; |
|
| 1022 | - $tableCell.='<span class="hideonsmartphone"> + </span>'; |
|
| 1020 | + $tableCell = ''; |
|
| 1021 | + $tableCell .= '<span class="timesheetalreadyrecorded" title="texttoreplace"><input type="text" class="center" size="2" disabled id="timespent['.$inc.']['.$idw.']" name="task['.$lines[$i]->id.']['.$idw.']" value="'.$alreadyspent.'"></span>'; |
|
| 1022 | + $tableCell .= '<span class="hideonsmartphone"> + </span>'; |
|
| 1023 | 1023 | //$tableCell.=' '; |
| 1024 | - $tableCell.=$form->select_duration($lines[$i]->id.'duration','',$disabledtask,'text',0,1); |
|
| 1024 | + $tableCell .= $form->select_duration($lines[$i]->id.'duration', '', $disabledtask, 'text', 0, 1); |
|
| 1025 | 1025 | //$tableCell.=' <input type="submit" class="button"'.($disabledtask?' disabled':'').' value="'.$langs->trans("Add").'">'; |
| 1026 | 1026 | print $tableCell; |
| 1027 | 1027 | |
| 1028 | - $modeinput='hours'; |
|
| 1028 | + $modeinput = 'hours'; |
|
| 1029 | 1029 | |
| 1030 | 1030 | print '<script type="text/javascript">'; |
| 1031 | 1031 | print "jQuery(document).ready(function () {\n"; |
@@ -1037,19 +1037,19 @@ discard block |
||
| 1037 | 1037 | |
| 1038 | 1038 | // Note |
| 1039 | 1039 | print '<td align="center">'; |
| 1040 | - print '<textarea name="'.$lines[$i]->id.'note" rows="'.ROWS_2.'" id="'.$lines[$i]->id.'note"'.($disabledtask?' disabled="disabled"':'').'>'; |
|
| 1040 | + print '<textarea name="'.$lines[$i]->id.'note" rows="'.ROWS_2.'" id="'.$lines[$i]->id.'note"'.($disabledtask ? ' disabled="disabled"' : '').'>'; |
|
| 1041 | 1041 | print '</textarea>'; |
| 1042 | 1042 | print '</td>'; |
| 1043 | 1043 | |
| 1044 | 1044 | // Warning |
| 1045 | 1045 | print '<td align="right">'; |
| 1046 | - if ((! $lines[$i]->public) && $disabledproject) print $form->textwithpicto('',$langs->trans("UserIsNotContactOfProject")); |
|
| 1046 | + if ((!$lines[$i]->public) && $disabledproject) print $form->textwithpicto('', $langs->trans("UserIsNotContactOfProject")); |
|
| 1047 | 1047 | else if ($disabledtask) |
| 1048 | 1048 | { |
| 1049 | 1049 | $titleassigntask = $langs->trans("AssignTaskToMe"); |
| 1050 | 1050 | if ($fuser->id != $user->id) $titleassigntask = $langs->trans("AssignTaskToUser", '...'); |
| 1051 | 1051 | |
| 1052 | - print $form->textwithpicto('',$langs->trans("TaskIsNotAssignedToUser", $titleassigntask)); |
|
| 1052 | + print $form->textwithpicto('', $langs->trans("TaskIsNotAssignedToUser", $titleassigntask)); |
|
| 1053 | 1053 | } |
| 1054 | 1054 | print '</td>'; |
| 1055 | 1055 | |
@@ -1065,9 +1065,9 @@ discard block |
||
| 1065 | 1065 | $ret = projectLinesPerDay($inc, $lines[$i]->id, $fuser, ($parent == 0 ? $lineswithoutlevel0 : $lines), $level, $projectsrole, $tasksrole, $mine, $restricteditformytask, $preselectedday, $isavailable, $oldprojectforbreak); |
| 1066 | 1066 | //var_dump('ret with parent='.$lines[$i]->id.' level='.$level); |
| 1067 | 1067 | //var_dump($ret); |
| 1068 | - foreach($ret as $key => $val) |
|
| 1068 | + foreach ($ret as $key => $val) |
|
| 1069 | 1069 | { |
| 1070 | - $totalforeachday[$key]+=$val; |
|
| 1070 | + $totalforeachday[$key] += $val; |
|
| 1071 | 1071 | } |
| 1072 | 1072 | //var_dump('totalforeachday after taskid='.$lines[$i]->id.' and previous one on level '.$level.' + subtasks'); |
| 1073 | 1073 | //var_dump($totalforeachday); |
@@ -1101,24 +1101,24 @@ discard block |
||
| 1101 | 1101 | * @param int $oldprojectforbreak Old project id of last project break |
| 1102 | 1102 | * @return array Array with time spent for $fuser for each day of week on tasks in $lines and substasks |
| 1103 | 1103 | */ |
| 1104 | -function projectLinesPerWeek(&$inc, $firstdaytoshow, $fuser, $parent, $lines, &$level, &$projectsrole, &$tasksrole, $mine, $restricteditformytask, &$isavailable, $oldprojectforbreak=0) |
|
| 1104 | +function projectLinesPerWeek(&$inc, $firstdaytoshow, $fuser, $parent, $lines, &$level, &$projectsrole, &$tasksrole, $mine, $restricteditformytask, &$isavailable, $oldprojectforbreak = 0) |
|
| 1105 | 1105 | { |
| 1106 | 1106 | global $conf, $db, $user, $bc, $langs; |
| 1107 | 1107 | global $form, $formother, $projectstatic, $taskstatic, $thirdpartystatic; |
| 1108 | 1108 | |
| 1109 | - $numlines=count($lines); |
|
| 1109 | + $numlines = count($lines); |
|
| 1110 | 1110 | |
| 1111 | - $lastprojectid=0; |
|
| 1112 | - $workloadforid=array(); |
|
| 1113 | - $totalforeachday=array(); |
|
| 1114 | - $lineswithoutlevel0=array(); |
|
| 1111 | + $lastprojectid = 0; |
|
| 1112 | + $workloadforid = array(); |
|
| 1113 | + $totalforeachday = array(); |
|
| 1114 | + $lineswithoutlevel0 = array(); |
|
| 1115 | 1115 | |
| 1116 | 1116 | // Create a smaller array with sublevels only to be used later. This increase dramatically performances. |
| 1117 | 1117 | if ($parent == 0) // Always and only if at first level |
| 1118 | 1118 | { |
| 1119 | - for ($i = 0 ; $i < $numlines ; $i++) |
|
| 1119 | + for ($i = 0; $i < $numlines; $i++) |
|
| 1120 | 1120 | { |
| 1121 | - if ($lines[$i]->fk_task_parent) $lineswithoutlevel0[]=$lines[$i]; |
|
| 1121 | + if ($lines[$i]->fk_task_parent) $lineswithoutlevel0[] = $lines[$i]; |
|
| 1122 | 1122 | } |
| 1123 | 1123 | } |
| 1124 | 1124 | |
@@ -1126,24 +1126,24 @@ discard block |
||
| 1126 | 1126 | |
| 1127 | 1127 | if (empty($oldprojectforbreak)) |
| 1128 | 1128 | { |
| 1129 | - $oldprojectforbreak = (empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT)?0:-1); // 0 = start break, -1 = never break |
|
| 1129 | + $oldprojectforbreak = (empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT) ? 0 : -1); // 0 = start break, -1 = never break |
|
| 1130 | 1130 | } |
| 1131 | 1131 | |
| 1132 | - for ($i = 0 ; $i < $numlines ; $i++) |
|
| 1132 | + for ($i = 0; $i < $numlines; $i++) |
|
| 1133 | 1133 | { |
| 1134 | 1134 | if ($parent == 0) $level = 0; |
| 1135 | 1135 | |
| 1136 | 1136 | if ($lines[$i]->fk_task_parent == $parent) |
| 1137 | 1137 | { |
| 1138 | 1138 | // If we want all or we have a role on task, we show it |
| 1139 | - if (empty($mine) || ! empty($tasksrole[$lines[$i]->id])) |
|
| 1139 | + if (empty($mine) || !empty($tasksrole[$lines[$i]->id])) |
|
| 1140 | 1140 | { |
| 1141 | 1141 | //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); |
| 1142 | 1142 | |
| 1143 | 1143 | // Break on a new project |
| 1144 | 1144 | if ($parent == 0 && $lines[$i]->fk_project != $lastprojectid) |
| 1145 | 1145 | { |
| 1146 | - $lastprojectid=$lines[$i]->fk_project; |
|
| 1146 | + $lastprojectid = $lines[$i]->fk_project; |
|
| 1147 | 1147 | $projectstatic->id = $lines[$i]->fk_project; |
| 1148 | 1148 | } |
| 1149 | 1149 | |
@@ -1151,33 +1151,33 @@ discard block |
||
| 1151 | 1151 | //var_dump($projectstatic->weekWorkLoadPerTask); |
| 1152 | 1152 | if (empty($workloadforid[$projectstatic->id])) |
| 1153 | 1153 | { |
| 1154 | - $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 |
|
| 1155 | - $workloadforid[$projectstatic->id]=1; |
|
| 1154 | + $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 |
|
| 1155 | + $workloadforid[$projectstatic->id] = 1; |
|
| 1156 | 1156 | } |
| 1157 | 1157 | //var_dump($projectstatic->weekWorkLoadPerTask); |
| 1158 | 1158 | //var_dump('--- '.$projectstatic->id.' '.$workloadforid[$projectstatic->id]); |
| 1159 | 1159 | |
| 1160 | - $projectstatic->id=$lines[$i]->fk_project; |
|
| 1161 | - $projectstatic->ref=$lines[$i]->projectref; |
|
| 1162 | - $projectstatic->title=$lines[$i]->projectlabel; |
|
| 1163 | - $projectstatic->public=$lines[$i]->public; |
|
| 1164 | - $projectstatic->thirdparty_name=$lines[$i]->thirdparty_name; |
|
| 1160 | + $projectstatic->id = $lines[$i]->fk_project; |
|
| 1161 | + $projectstatic->ref = $lines[$i]->projectref; |
|
| 1162 | + $projectstatic->title = $lines[$i]->projectlabel; |
|
| 1163 | + $projectstatic->public = $lines[$i]->public; |
|
| 1164 | + $projectstatic->thirdparty_name = $lines[$i]->thirdparty_name; |
|
| 1165 | 1165 | |
| 1166 | - $taskstatic->id=$lines[$i]->id; |
|
| 1167 | - $taskstatic->ref=($lines[$i]->ref?$lines[$i]->ref:$lines[$i]->id); |
|
| 1168 | - $taskstatic->label=$lines[$i]->label; |
|
| 1169 | - $taskstatic->date_start=$lines[$i]->date_start; |
|
| 1170 | - $taskstatic->date_end=$lines[$i]->date_end; |
|
| 1166 | + $taskstatic->id = $lines[$i]->id; |
|
| 1167 | + $taskstatic->ref = ($lines[$i]->ref ? $lines[$i]->ref : $lines[$i]->id); |
|
| 1168 | + $taskstatic->label = $lines[$i]->label; |
|
| 1169 | + $taskstatic->date_start = $lines[$i]->date_start; |
|
| 1170 | + $taskstatic->date_end = $lines[$i]->date_end; |
|
| 1171 | 1171 | |
| 1172 | - $thirdpartystatic->id=$lines[$i]->thirdparty_id; |
|
| 1173 | - $thirdpartystatic->name=$lines[$i]->thirdparty_name; |
|
| 1174 | - $thirdpartystatic->email=$lines[$i]->thirdparty_email; |
|
| 1172 | + $thirdpartystatic->id = $lines[$i]->thirdparty_id; |
|
| 1173 | + $thirdpartystatic->name = $lines[$i]->thirdparty_name; |
|
| 1174 | + $thirdpartystatic->email = $lines[$i]->thirdparty_email; |
|
| 1175 | 1175 | |
| 1176 | 1176 | if (empty($oldprojectforbreak) || ($oldprojectforbreak != -1 && $oldprojectforbreak != $projectstatic->id)) |
| 1177 | 1177 | { |
| 1178 | 1178 | print '<tr class="oddeven trforbreak">'."\n"; |
| 1179 | 1179 | print '<td colspan="15">'; |
| 1180 | - print $projectstatic->getNomUrl(1,'',0,$langs->transnoentitiesnoconv("YourRole").': '.$projectsrole[$lines[$i]->fk_project]); |
|
| 1180 | + print $projectstatic->getNomUrl(1, '', 0, $langs->transnoentitiesnoconv("YourRole").': '.$projectsrole[$lines[$i]->fk_project]); |
|
| 1181 | 1181 | if ($projectstatic->title) |
| 1182 | 1182 | { |
| 1183 | 1183 | print ' - '; |
@@ -1200,7 +1200,7 @@ discard block |
||
| 1200 | 1200 | |
| 1201 | 1201 | // Project |
| 1202 | 1202 | print '<td class="nowrap">'; |
| 1203 | - if ($oldprojectforbreak == -1) print $projectstatic->getNomUrl(1,'',0,$langs->transnoentitiesnoconv("YourRole").': '.$projectsrole[$lines[$i]->fk_project]); |
|
| 1203 | + if ($oldprojectforbreak == -1) print $projectstatic->getNomUrl(1, '', 0, $langs->transnoentitiesnoconv("YourRole").': '.$projectsrole[$lines[$i]->fk_project]); |
|
| 1204 | 1204 | print "</td>"; |
| 1205 | 1205 | |
| 1206 | 1206 | // Thirdparty |
@@ -1211,11 +1211,11 @@ discard block |
||
| 1211 | 1211 | // Ref |
| 1212 | 1212 | print '<td class="nowrap">'; |
| 1213 | 1213 | print '<!-- Task id = '.$lines[$i]->id.' -->'; |
| 1214 | - for ($k = 0 ; $k < $level ; $k++) print " "; |
|
| 1214 | + for ($k = 0; $k < $level; $k++) print " "; |
|
| 1215 | 1215 | print $taskstatic->getNomUrl(1, 'withproject', 'time'); |
| 1216 | 1216 | // Label task |
| 1217 | 1217 | print '<br>'; |
| 1218 | - for ($k = 0 ; $k < $level ; $k++) print " "; |
|
| 1218 | + for ($k = 0; $k < $level; $k++) print " "; |
|
| 1219 | 1219 | //print $taskstatic->getNomUrl(0, 'withproject', 'time'); |
| 1220 | 1220 | print $taskstatic->label; |
| 1221 | 1221 | //print "<br>"; |
@@ -1225,13 +1225,13 @@ discard block |
||
| 1225 | 1225 | |
| 1226 | 1226 | // Planned Workload |
| 1227 | 1227 | print '<td align="right" class="leftborder plannedworkload">'; |
| 1228 | - if ($lines[$i]->planned_workload) print convertSecondToTime($lines[$i]->planned_workload,'allhourmin'); |
|
| 1228 | + if ($lines[$i]->planned_workload) print convertSecondToTime($lines[$i]->planned_workload, 'allhourmin'); |
|
| 1229 | 1229 | else print '--:--'; |
| 1230 | 1230 | print '</td>'; |
| 1231 | 1231 | |
| 1232 | 1232 | // Progress declared % |
| 1233 | 1233 | print '<td align="right">'; |
| 1234 | - print $formother->select_percent($lines[$i]->progress, $lines[$i]->id . 'progress'); |
|
| 1234 | + print $formother->select_percent($lines[$i]->progress, $lines[$i]->id.'progress'); |
|
| 1235 | 1235 | print '</td>'; |
| 1236 | 1236 | |
| 1237 | 1237 | // Time spent by everybody |
@@ -1240,7 +1240,7 @@ discard block |
||
| 1240 | 1240 | if ($lines[$i]->duration) |
| 1241 | 1241 | { |
| 1242 | 1242 | print '<a href="'.DOL_URL_ROOT.'/projet/tasks/time.php?id='.$lines[$i]->id.'">'; |
| 1243 | - print convertSecondToTime($lines[$i]->duration,'allhourmin'); |
|
| 1243 | + print convertSecondToTime($lines[$i]->duration, 'allhourmin'); |
|
| 1244 | 1244 | print '</a>'; |
| 1245 | 1245 | } |
| 1246 | 1246 | else print '--:--'; |
@@ -1248,80 +1248,80 @@ discard block |
||
| 1248 | 1248 | |
| 1249 | 1249 | // Time spent by user |
| 1250 | 1250 | print '<td align="right">'; |
| 1251 | - $tmptimespent=$taskstatic->getSummaryOfTimeSpent($fuser->id); |
|
| 1252 | - if ($tmptimespent['total_duration']) print convertSecondToTime($tmptimespent['total_duration'],'allhourmin'); |
|
| 1251 | + $tmptimespent = $taskstatic->getSummaryOfTimeSpent($fuser->id); |
|
| 1252 | + if ($tmptimespent['total_duration']) print convertSecondToTime($tmptimespent['total_duration'], 'allhourmin'); |
|
| 1253 | 1253 | else print '--:--'; |
| 1254 | 1254 | print "</td>\n"; |
| 1255 | 1255 | |
| 1256 | - $disabledproject=1;$disabledtask=1; |
|
| 1256 | + $disabledproject = 1; $disabledtask = 1; |
|
| 1257 | 1257 | //print "x".$lines[$i]->fk_project; |
| 1258 | 1258 | //var_dump($lines[$i]); |
| 1259 | 1259 | //var_dump($projectsrole[$lines[$i]->fk_project]); |
| 1260 | 1260 | // If at least one role for project |
| 1261 | - if ($lines[$i]->public || ! empty($projectsrole[$lines[$i]->fk_project]) || $user->rights->projet->all->creer) |
|
| 1261 | + if ($lines[$i]->public || !empty($projectsrole[$lines[$i]->fk_project]) || $user->rights->projet->all->creer) |
|
| 1262 | 1262 | { |
| 1263 | - $disabledproject=0; |
|
| 1264 | - $disabledtask=0; |
|
| 1263 | + $disabledproject = 0; |
|
| 1264 | + $disabledtask = 0; |
|
| 1265 | 1265 | } |
| 1266 | 1266 | // If $restricteditformytask is on and I have no role on task, i disable edit |
| 1267 | 1267 | if ($restricteditformytask && empty($tasksrole[$lines[$i]->id])) |
| 1268 | 1268 | { |
| 1269 | - $disabledtask=1; |
|
| 1269 | + $disabledtask = 1; |
|
| 1270 | 1270 | } |
| 1271 | 1271 | |
| 1272 | 1272 | //var_dump($projectstatic->weekWorkLoadPerTask); |
| 1273 | 1273 | |
| 1274 | 1274 | // Fields to show current time |
| 1275 | - $tableCell=''; $modeinput='hours'; |
|
| 1275 | + $tableCell = ''; $modeinput = 'hours'; |
|
| 1276 | 1276 | for ($idw = 0; $idw < 7; $idw++) |
| 1277 | 1277 | { |
| 1278 | - $tmpday=dol_time_plus_duree($firstdaytoshow, $idw, 'd'); |
|
| 1278 | + $tmpday = dol_time_plus_duree($firstdaytoshow, $idw, 'd'); |
|
| 1279 | 1279 | |
| 1280 | - $cssonholiday=''; |
|
| 1281 | - if (! $isavailable[$tmpday]['morning'] && ! $isavailable[$tmpday]['afternoon']) $cssonholiday.='onholidayallday '; |
|
| 1282 | - elseif (! $isavailable[$tmpday]['morning']) $cssonholiday.='onholidaymorning '; |
|
| 1283 | - elseif (! $isavailable[$tmpday]['afternoon']) $cssonholiday.='onholidayafternoon '; |
|
| 1280 | + $cssonholiday = ''; |
|
| 1281 | + if (!$isavailable[$tmpday]['morning'] && !$isavailable[$tmpday]['afternoon']) $cssonholiday .= 'onholidayallday '; |
|
| 1282 | + elseif (!$isavailable[$tmpday]['morning']) $cssonholiday .= 'onholidaymorning '; |
|
| 1283 | + elseif (!$isavailable[$tmpday]['afternoon']) $cssonholiday .= 'onholidayafternoon '; |
|
| 1284 | 1284 | |
| 1285 | - $tmparray=dol_getdate($tmpday); |
|
| 1285 | + $tmparray = dol_getdate($tmpday); |
|
| 1286 | 1286 | $dayWorkLoad = $projectstatic->weekWorkLoadPerTask[$tmpday][$lines[$i]->id]; |
| 1287 | - $totalforeachday[$tmpday]+=$dayWorkLoad; |
|
| 1287 | + $totalforeachday[$tmpday] += $dayWorkLoad; |
|
| 1288 | 1288 | |
| 1289 | - $alreadyspent=''; |
|
| 1290 | - if ($dayWorkLoad > 0) $alreadyspent=convertSecondToTime($dayWorkLoad,'allhourmin'); |
|
| 1291 | - $alttitle=$langs->trans("AddHereTimeSpentForDay",$tmparray['day'],$tmparray['mon']); |
|
| 1289 | + $alreadyspent = ''; |
|
| 1290 | + if ($dayWorkLoad > 0) $alreadyspent = convertSecondToTime($dayWorkLoad, 'allhourmin'); |
|
| 1291 | + $alttitle = $langs->trans("AddHereTimeSpentForDay", $tmparray['day'], $tmparray['mon']); |
|
| 1292 | 1292 | |
| 1293 | 1293 | global $numstartworkingday, $numendworkingday; |
| 1294 | - $cssweekend=''; |
|
| 1294 | + $cssweekend = ''; |
|
| 1295 | 1295 | if (($idw + 1) < $numstartworkingday || ($idw + 1) > $numendworkingday) // This is a day is not inside the setup of working days, so we use a week-end css. |
| 1296 | 1296 | { |
| 1297 | - $cssweekend='weekend'; |
|
| 1297 | + $cssweekend = 'weekend'; |
|
| 1298 | 1298 | } |
| 1299 | 1299 | |
| 1300 | - $tableCell ='<td align="center" class="hide'.$idw.($cssonholiday?' '.$cssonholiday:'').($cssweekend?' '.$cssweekend:'').'">'; |
|
| 1300 | + $tableCell = '<td align="center" class="hide'.$idw.($cssonholiday ? ' '.$cssonholiday : '').($cssweekend ? ' '.$cssweekend : '').'">'; |
|
| 1301 | 1301 | if ($alreadyspent) |
| 1302 | 1302 | { |
| 1303 | - $tableCell.='<span class="timesheetalreadyrecorded" title="texttoreplace"><input type="text" class="center smallpadd" size="2" disabled id="timespent['.$inc.']['.$idw.']" name="task['.$lines[$i]->id.']['.$idw.']" value="'.$alreadyspent.'"></span>'; |
|
| 1303 | + $tableCell .= '<span class="timesheetalreadyrecorded" title="texttoreplace"><input type="text" class="center smallpadd" size="2" disabled id="timespent['.$inc.']['.$idw.']" name="task['.$lines[$i]->id.']['.$idw.']" value="'.$alreadyspent.'"></span>'; |
|
| 1304 | 1304 | //$placeholder=' placeholder="00:00"'; |
| 1305 | - $placeholder=''; |
|
| 1305 | + $placeholder = ''; |
|
| 1306 | 1306 | //$tableCell.='+'; |
| 1307 | 1307 | } |
| 1308 | - $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"'; |
|
| 1309 | - $tableCell.=' onkeypress="return regexEvent(this,event,\'timeChar\')"'; |
|
| 1310 | - $tableCell.=' onkeyup="updateTotal('.$idw.',\''.$modeinput.'\')"'; |
|
| 1311 | - $tableCell.=' onblur="regexEvent(this,event,\''.$modeinput.'\'); updateTotal('.$idw.',\''.$modeinput.'\')" />'; |
|
| 1312 | - $tableCell.='</td>'; |
|
| 1308 | + $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"'; |
|
| 1309 | + $tableCell .= ' onkeypress="return regexEvent(this,event,\'timeChar\')"'; |
|
| 1310 | + $tableCell .= ' onkeyup="updateTotal('.$idw.',\''.$modeinput.'\')"'; |
|
| 1311 | + $tableCell .= ' onblur="regexEvent(this,event,\''.$modeinput.'\'); updateTotal('.$idw.',\''.$modeinput.'\')" />'; |
|
| 1312 | + $tableCell .= '</td>'; |
|
| 1313 | 1313 | print $tableCell; |
| 1314 | 1314 | } |
| 1315 | 1315 | |
| 1316 | 1316 | // Warning |
| 1317 | 1317 | print '<td align="right">'; |
| 1318 | - if ((! $lines[$i]->public) && $disabledproject) print $form->textwithpicto('',$langs->trans("UserIsNotContactOfProject")); |
|
| 1318 | + if ((!$lines[$i]->public) && $disabledproject) print $form->textwithpicto('', $langs->trans("UserIsNotContactOfProject")); |
|
| 1319 | 1319 | else if ($disabledtask) |
| 1320 | 1320 | { |
| 1321 | 1321 | $titleassigntask = $langs->trans("AssignTaskToMe"); |
| 1322 | 1322 | if ($fuser->id != $user->id) $titleassigntask = $langs->trans("AssignTaskToUser", '...'); |
| 1323 | 1323 | |
| 1324 | - print $form->textwithpicto('',$langs->trans("TaskIsNotAssignedToUser", $titleassigntask)); |
|
| 1324 | + print $form->textwithpicto('', $langs->trans("TaskIsNotAssignedToUser", $titleassigntask)); |
|
| 1325 | 1325 | } |
| 1326 | 1326 | print '</td>'; |
| 1327 | 1327 | |
@@ -1338,9 +1338,9 @@ discard block |
||
| 1338 | 1338 | $ret = projectLinesPerWeek($inc, $firstdaytoshow, $fuser, $lines[$i]->id, ($parent == 0 ? $lineswithoutlevel0 : $lines), $level, $projectsrole, $tasksrole, $mine, $restricteditformytask, $isavailable, $oldprojectforbreak); |
| 1339 | 1339 | //var_dump('ret with parent='.$lines[$i]->id.' level='.$level); |
| 1340 | 1340 | //var_dump($ret); |
| 1341 | - foreach($ret as $key => $val) |
|
| 1341 | + foreach ($ret as $key => $val) |
|
| 1342 | 1342 | { |
| 1343 | - $totalforeachday[$key]+=$val; |
|
| 1343 | + $totalforeachday[$key] += $val; |
|
| 1344 | 1344 | } |
| 1345 | 1345 | //var_dump('totalforeachday after taskid='.$lines[$i]->id.' and previous one on level '.$level.' + subtasks'); |
| 1346 | 1346 | //var_dump($totalforeachday); |
@@ -1369,8 +1369,8 @@ discard block |
||
| 1369 | 1369 | function searchTaskInChild(&$inc, $parent, &$lines, &$taskrole) |
| 1370 | 1370 | { |
| 1371 | 1371 | //print 'Search in line with parent id = '.$parent.'<br>'; |
| 1372 | - $numlines=count($lines); |
|
| 1373 | - for ($i = 0 ; $i < $numlines ; $i++) |
|
| 1372 | + $numlines = count($lines); |
|
| 1373 | + for ($i = 0; $i < $numlines; $i++) |
|
| 1374 | 1374 | { |
| 1375 | 1375 | // Process line $lines[$i] |
| 1376 | 1376 | if ($lines[$i]->fk_parent == $parent && $lines[$i]->id != $lines[$i]->fk_parent) |
@@ -1406,52 +1406,52 @@ discard block |
||
| 1406 | 1406 | * @param array $hiddenfields List of info to not show ('projectlabel', 'declaredprogress', '...', ) |
| 1407 | 1407 | * @return void |
| 1408 | 1408 | */ |
| 1409 | -function print_projecttasks_array($db, $form, $socid, $projectsListId, $mytasks=0, $statut=-1, $listofoppstatus=array(),$hiddenfields=array()) |
|
| 1409 | +function print_projecttasks_array($db, $form, $socid, $projectsListId, $mytasks = 0, $statut = -1, $listofoppstatus = array(), $hiddenfields = array()) |
|
| 1410 | 1410 | { |
| 1411 | - global $langs,$conf,$user,$bc; |
|
| 1411 | + global $langs, $conf, $user, $bc; |
|
| 1412 | 1412 | |
| 1413 | 1413 | require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; |
| 1414 | 1414 | |
| 1415 | - $projectstatic=new Project($db); |
|
| 1416 | - $thirdpartystatic=new Societe($db); |
|
| 1415 | + $projectstatic = new Project($db); |
|
| 1416 | + $thirdpartystatic = new Societe($db); |
|
| 1417 | 1417 | |
| 1418 | - $sortfield=''; |
|
| 1419 | - $sortorder=''; |
|
| 1420 | - $project_year_filter=0; |
|
| 1418 | + $sortfield = ''; |
|
| 1419 | + $sortorder = ''; |
|
| 1420 | + $project_year_filter = 0; |
|
| 1421 | 1421 | |
| 1422 | - $title=$langs->trans("Projects"); |
|
| 1423 | - if (strcmp($statut, '') && $statut >= 0) $title=$langs->trans("Projects").' '.$langs->trans($projectstatic->statuts_long[$statut]); |
|
| 1422 | + $title = $langs->trans("Projects"); |
|
| 1423 | + if (strcmp($statut, '') && $statut >= 0) $title = $langs->trans("Projects").' '.$langs->trans($projectstatic->statuts_long[$statut]); |
|
| 1424 | 1424 | |
| 1425 | - $arrayidtypeofcontact=array(); |
|
| 1425 | + $arrayidtypeofcontact = array(); |
|
| 1426 | 1426 | |
| 1427 | 1427 | print '<div class="div-table-responsive-no-min">'; |
| 1428 | 1428 | print '<table class="noborder" width="100%">'; |
| 1429 | 1429 | |
| 1430 | - $sql.= " FROM ".MAIN_DB_PREFIX."projet as p"; |
|
| 1430 | + $sql .= " FROM ".MAIN_DB_PREFIX."projet as p"; |
|
| 1431 | 1431 | if ($mytasks) |
| 1432 | 1432 | { |
| 1433 | - $sql.= ", ".MAIN_DB_PREFIX."projet_task as t"; |
|
| 1434 | - $sql.= ", ".MAIN_DB_PREFIX."element_contact as ec"; |
|
| 1435 | - $sql.= ", ".MAIN_DB_PREFIX."c_type_contact as ctc"; |
|
| 1433 | + $sql .= ", ".MAIN_DB_PREFIX."projet_task as t"; |
|
| 1434 | + $sql .= ", ".MAIN_DB_PREFIX."element_contact as ec"; |
|
| 1435 | + $sql .= ", ".MAIN_DB_PREFIX."c_type_contact as ctc"; |
|
| 1436 | 1436 | } |
| 1437 | 1437 | else |
| 1438 | 1438 | { |
| 1439 | - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."projet_task as t ON p.rowid = t.fk_projet"; |
|
| 1439 | + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."projet_task as t ON p.rowid = t.fk_projet"; |
|
| 1440 | 1440 | } |
| 1441 | - $sql.= " WHERE p.entity IN (".getEntity('project').")"; |
|
| 1442 | - $sql.= " AND p.rowid IN (".$projectsListId.")"; |
|
| 1443 | - if ($socid) $sql.= " AND (p.fk_soc IS NULL OR p.fk_soc = 0 OR p.fk_soc = ".$socid.")"; |
|
| 1441 | + $sql .= " WHERE p.entity IN (".getEntity('project').")"; |
|
| 1442 | + $sql .= " AND p.rowid IN (".$projectsListId.")"; |
|
| 1443 | + if ($socid) $sql .= " AND (p.fk_soc IS NULL OR p.fk_soc = 0 OR p.fk_soc = ".$socid.")"; |
|
| 1444 | 1444 | if ($mytasks) |
| 1445 | 1445 | { |
| 1446 | - $sql.= " AND p.rowid = t.fk_projet"; |
|
| 1447 | - $sql.= " AND ec.element_id = t.rowid"; |
|
| 1448 | - $sql.= " AND ec.fk_socpeople = ".$user->id; |
|
| 1449 | - $sql.= " AND ec.fk_c_type_contact = ctc.rowid"; // Replace the 2 lines with ec.fk_c_type_contact in $arrayidtypeofcontact |
|
| 1450 | - $sql.= " AND ctc.element = 'project_task'"; |
|
| 1446 | + $sql .= " AND p.rowid = t.fk_projet"; |
|
| 1447 | + $sql .= " AND ec.element_id = t.rowid"; |
|
| 1448 | + $sql .= " AND ec.fk_socpeople = ".$user->id; |
|
| 1449 | + $sql .= " AND ec.fk_c_type_contact = ctc.rowid"; // Replace the 2 lines with ec.fk_c_type_contact in $arrayidtypeofcontact |
|
| 1450 | + $sql .= " AND ctc.element = 'project_task'"; |
|
| 1451 | 1451 | } |
| 1452 | 1452 | if ($statut >= 0) |
| 1453 | 1453 | { |
| 1454 | - $sql.= " AND p.fk_statut = ".$statut; |
|
| 1454 | + $sql .= " AND p.fk_statut = ".$statut; |
|
| 1455 | 1455 | } |
| 1456 | 1456 | if (!empty($conf->global->PROJECT_LIMIT_YEAR_RANGE)) |
| 1457 | 1457 | { |
@@ -1463,40 +1463,40 @@ discard block |
||
| 1463 | 1463 | { |
| 1464 | 1464 | $project_year_filter = date("Y"); |
| 1465 | 1465 | } |
| 1466 | - $sql.= " AND (p.dateo IS NULL OR p.dateo <= ".$db->idate(dol_get_last_day($project_year_filter,12,false)).")"; |
|
| 1467 | - $sql.= " AND (p.datee IS NULL OR p.datee >= ".$db->idate(dol_get_first_day($project_year_filter,1,false)).")"; |
|
| 1466 | + $sql .= " AND (p.dateo IS NULL OR p.dateo <= ".$db->idate(dol_get_last_day($project_year_filter, 12, false)).")"; |
|
| 1467 | + $sql .= " AND (p.datee IS NULL OR p.datee >= ".$db->idate(dol_get_first_day($project_year_filter, 1, false)).")"; |
|
| 1468 | 1468 | } |
| 1469 | 1469 | } |
| 1470 | 1470 | |
| 1471 | 1471 | // Get id of project we must show tasks |
| 1472 | - $arrayidofprojects=array(); |
|
| 1472 | + $arrayidofprojects = array(); |
|
| 1473 | 1473 | $sql1 = "SELECT p.rowid as projectid"; |
| 1474 | - $sql1.= $sql; |
|
| 1474 | + $sql1 .= $sql; |
|
| 1475 | 1475 | $resql = $db->query($sql1); |
| 1476 | 1476 | if ($resql) |
| 1477 | 1477 | { |
| 1478 | - $i=0; |
|
| 1478 | + $i = 0; |
|
| 1479 | 1479 | $num = $db->num_rows($resql); |
| 1480 | 1480 | while ($i < $num) |
| 1481 | 1481 | { |
| 1482 | 1482 | $objp = $db->fetch_object($resql); |
| 1483 | - $arrayidofprojects[$objp->projectid]=$objp->projectid; |
|
| 1483 | + $arrayidofprojects[$objp->projectid] = $objp->projectid; |
|
| 1484 | 1484 | $i++; |
| 1485 | 1485 | } |
| 1486 | 1486 | } |
| 1487 | 1487 | else dol_print_error($db); |
| 1488 | - if (empty($arrayidofprojects)) $arrayidofprojects[0]=-1; |
|
| 1488 | + if (empty($arrayidofprojects)) $arrayidofprojects[0] = -1; |
|
| 1489 | 1489 | |
| 1490 | 1490 | // Get list of project with calculation on tasks |
| 1491 | 1491 | $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,"; |
| 1492 | - $sql2.= " p.dateo, p.datee,"; |
|
| 1493 | - $sql2.= " COUNT(t.rowid) as nb, SUM(t.planned_workload) as planned_workload, SUM(t.planned_workload * t.progress / 100) as declared_progess_workload"; |
|
| 1494 | - $sql2.= " FROM ".MAIN_DB_PREFIX."projet as p"; |
|
| 1495 | - $sql2.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = p.fk_soc"; |
|
| 1496 | - $sql2.= " LEFT JOIN ".MAIN_DB_PREFIX."projet_task as t ON p.rowid = t.fk_projet"; |
|
| 1497 | - $sql2.= " WHERE p.rowid IN (".join(',',$arrayidofprojects).")"; |
|
| 1498 | - $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"; |
|
| 1499 | - $sql2.= " ORDER BY p.title, p.ref"; |
|
| 1492 | + $sql2 .= " p.dateo, p.datee,"; |
|
| 1493 | + $sql2 .= " COUNT(t.rowid) as nb, SUM(t.planned_workload) as planned_workload, SUM(t.planned_workload * t.progress / 100) as declared_progess_workload"; |
|
| 1494 | + $sql2 .= " FROM ".MAIN_DB_PREFIX."projet as p"; |
|
| 1495 | + $sql2 .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = p.fk_soc"; |
|
| 1496 | + $sql2 .= " LEFT JOIN ".MAIN_DB_PREFIX."projet_task as t ON p.rowid = t.fk_projet"; |
|
| 1497 | + $sql2 .= " WHERE p.rowid IN (".join(',', $arrayidofprojects).")"; |
|
| 1498 | + $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"; |
|
| 1499 | + $sql2 .= " ORDER BY p.title, p.ref"; |
|
| 1500 | 1500 | |
| 1501 | 1501 | $resql = $db->query($sql2); |
| 1502 | 1502 | if ($resql) |
@@ -1509,20 +1509,20 @@ discard block |
||
| 1509 | 1509 | $i = 0; |
| 1510 | 1510 | |
| 1511 | 1511 | print '<tr class="liste_titre">'; |
| 1512 | - print_liste_field_titre($title.' <span class="badge">'.$num.'</span>',$_SERVER["PHP_SELF"],"","","","",$sortfield,$sortorder); |
|
| 1513 | - print_liste_field_titre("ThirdParty",$_SERVER["PHP_SELF"],"","","","",$sortfield,$sortorder); |
|
| 1514 | - if (! empty($conf->global->PROJECT_USE_OPPORTUNITIES)) |
|
| 1512 | + print_liste_field_titre($title.' <span class="badge">'.$num.'</span>', $_SERVER["PHP_SELF"], "", "", "", "", $sortfield, $sortorder); |
|
| 1513 | + print_liste_field_titre("ThirdParty", $_SERVER["PHP_SELF"], "", "", "", "", $sortfield, $sortorder); |
|
| 1514 | + if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) |
|
| 1515 | 1515 | { |
| 1516 | - print_liste_field_titre("OpportunityAmount","","","","",'align="right"',$sortfield,$sortorder); |
|
| 1517 | - print_liste_field_titre("OpportunityStatus","","","","",'align="right"',$sortfield,$sortorder); |
|
| 1516 | + print_liste_field_titre("OpportunityAmount", "", "", "", "", 'align="right"', $sortfield, $sortorder); |
|
| 1517 | + print_liste_field_titre("OpportunityStatus", "", "", "", "", 'align="right"', $sortfield, $sortorder); |
|
| 1518 | 1518 | } |
| 1519 | 1519 | if (empty($conf->global->PROJECT_HIDE_TASKS)) |
| 1520 | 1520 | { |
| 1521 | - print_liste_field_titre("Tasks","","","","",'align="right"',$sortfield,$sortorder); |
|
| 1522 | - if (! in_array('plannedworkload', $hiddenfields)) print_liste_field_titre("PlannedWorkload","","","","",'align="right"',$sortfield,$sortorder); |
|
| 1523 | - if (! in_array('declaredprogress', $hiddenfields)) print_liste_field_titre("ProgressDeclared","","","","",'align="right"',$sortfield,$sortorder); |
|
| 1521 | + print_liste_field_titre("Tasks", "", "", "", "", 'align="right"', $sortfield, $sortorder); |
|
| 1522 | + if (!in_array('plannedworkload', $hiddenfields)) print_liste_field_titre("PlannedWorkload", "", "", "", "", 'align="right"', $sortfield, $sortorder); |
|
| 1523 | + if (!in_array('declaredprogress', $hiddenfields)) print_liste_field_titre("ProgressDeclared", "", "", "", "", 'align="right"', $sortfield, $sortorder); |
|
| 1524 | 1524 | } |
| 1525 | - print_liste_field_titre("Status","","","","",'align="right"',$sortfield,$sortorder); |
|
| 1525 | + print_liste_field_titre("Status", "", "", "", "", 'align="right"', $sortfield, $sortorder); |
|
| 1526 | 1526 | print "</tr>\n"; |
| 1527 | 1527 | |
| 1528 | 1528 | while ($i < $num) |
@@ -1537,7 +1537,7 @@ discard block |
||
| 1537 | 1537 | $userAccess = $projectstatic->restrictedProjectArea($user); |
| 1538 | 1538 | if ($userAccess >= 0) |
| 1539 | 1539 | { |
| 1540 | - $projectstatic->ref=$objp->ref; |
|
| 1540 | + $projectstatic->ref = $objp->ref; |
|
| 1541 | 1541 | $projectstatic->statut = $objp->status; |
| 1542 | 1542 | $projectstatic->title = $objp->title; |
| 1543 | 1543 | $projectstatic->datee = $db->jdate($objp->datee); |
@@ -1547,18 +1547,18 @@ discard block |
||
| 1547 | 1547 | print '<tr class="oddeven">'; |
| 1548 | 1548 | print '<td>'; |
| 1549 | 1549 | print $projectstatic->getNomUrl(1); |
| 1550 | - if (! in_array('projectlabel', $hiddenfields)) print '<br>'.dol_trunc($objp->title,24); |
|
| 1550 | + if (!in_array('projectlabel', $hiddenfields)) print '<br>'.dol_trunc($objp->title, 24); |
|
| 1551 | 1551 | print '</td>'; |
| 1552 | 1552 | print '<td>'; |
| 1553 | 1553 | if ($objp->fk_soc > 0) |
| 1554 | 1554 | { |
| 1555 | - $thirdpartystatic->id=$objp->fk_soc; |
|
| 1556 | - $thirdpartystatic->ref=$objp->socname; |
|
| 1557 | - $thirdpartystatic->name=$objp->socname; |
|
| 1555 | + $thirdpartystatic->id = $objp->fk_soc; |
|
| 1556 | + $thirdpartystatic->ref = $objp->socname; |
|
| 1557 | + $thirdpartystatic->name = $objp->socname; |
|
| 1558 | 1558 | print $thirdpartystatic->getNomUrl(1); |
| 1559 | 1559 | } |
| 1560 | 1560 | print '</td>'; |
| 1561 | - if (! empty($conf->global->PROJECT_USE_OPPORTUNITIES)) |
|
| 1561 | + if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) |
|
| 1562 | 1562 | { |
| 1563 | 1563 | print '<td align="right">'; |
| 1564 | 1564 | if ($objp->opp_amount) print price($objp->opp_amount, 0, '', 1, -1, -1, $conf->currency); |
@@ -1572,19 +1572,19 @@ discard block |
||
| 1572 | 1572 | { |
| 1573 | 1573 | print '<td align="right">'.$objp->nb.'</td>'; |
| 1574 | 1574 | |
| 1575 | - $plannedworkload=$objp->planned_workload; |
|
| 1576 | - $total_plannedworkload+=$plannedworkload; |
|
| 1577 | - if (! in_array('plannedworkload', $hiddenfields)) |
|
| 1575 | + $plannedworkload = $objp->planned_workload; |
|
| 1576 | + $total_plannedworkload += $plannedworkload; |
|
| 1577 | + if (!in_array('plannedworkload', $hiddenfields)) |
|
| 1578 | 1578 | { |
| 1579 | - print '<td align="right">'.($plannedworkload?convertSecondToTime($plannedworkload):'').'</td>'; |
|
| 1579 | + print '<td align="right">'.($plannedworkload ?convertSecondToTime($plannedworkload) : '').'</td>'; |
|
| 1580 | 1580 | } |
| 1581 | - if (! in_array('declaredprogress', $hiddenfields)) |
|
| 1581 | + if (!in_array('declaredprogress', $hiddenfields)) |
|
| 1582 | 1582 | { |
| 1583 | - $declaredprogressworkload=$objp->declared_progess_workload; |
|
| 1584 | - $total_declaredprogressworkload+=$declaredprogressworkload; |
|
| 1583 | + $declaredprogressworkload = $objp->declared_progess_workload; |
|
| 1584 | + $total_declaredprogressworkload += $declaredprogressworkload; |
|
| 1585 | 1585 | print '<td align="right">'; |
| 1586 | 1586 | //print $objp->planned_workload.'-'.$objp->declared_progess_workload."<br>"; |
| 1587 | - print ($plannedworkload?round(100*$declaredprogressworkload/$plannedworkload,0).'%':''); |
|
| 1587 | + print ($plannedworkload ?round(100 * $declaredprogressworkload / $plannedworkload, 0).'%' : ''); |
|
| 1588 | 1588 | print '</td>'; |
| 1589 | 1589 | } |
| 1590 | 1590 | } |
@@ -1602,7 +1602,7 @@ discard block |
||
| 1602 | 1602 | |
| 1603 | 1603 | print '<tr class="liste_total">'; |
| 1604 | 1604 | print '<td colspan="2">'.$langs->trans("Total")."</td>"; |
| 1605 | - if (! empty($conf->global->PROJECT_USE_OPPORTUNITIES)) |
|
| 1605 | + if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) |
|
| 1606 | 1606 | { |
| 1607 | 1607 | print '<td class="liste_total" align="right">'.price($total_opp_amount, 0, '', 1, -1, -1, $conf->currency).'</td>'; |
| 1608 | 1608 | print '<td class="liste_total" align="right">'.$form->textwithpicto(price($ponderated_opp_amount, 0, '', 1, -1, -1, $conf->currency), $langs->trans("OpportunityPonderatedAmountDesc"), 1).'</td>'; |
@@ -1610,8 +1610,8 @@ discard block |
||
| 1610 | 1610 | if (empty($conf->global->PROJECT_HIDE_TASKS)) |
| 1611 | 1611 | { |
| 1612 | 1612 | print '<td class="liste_total" align="right">'.$total_task.'</td>'; |
| 1613 | - if (! in_array('plannedworkload', $hiddenfields)) print '<td class="liste_total" align="right">'.($total_plannedworkload?convertSecondToTime($total_plannedworkload):'').'</td>'; |
|
| 1614 | - if (! in_array('declaredprogress', $hiddenfields)) print '<td class="liste_total" align="right">'.($total_plannedworkload?round(100*$total_declaredprogressworkload/$total_plannedworkload,0).'%':'').'</td>'; |
|
| 1613 | + if (!in_array('plannedworkload', $hiddenfields)) print '<td class="liste_total" align="right">'.($total_plannedworkload ?convertSecondToTime($total_plannedworkload) : '').'</td>'; |
|
| 1614 | + if (!in_array('declaredprogress', $hiddenfields)) print '<td class="liste_total" align="right">'.($total_plannedworkload ?round(100 * $total_declaredprogressworkload / $total_plannedworkload, 0).'%' : '').'</td>'; |
|
| 1615 | 1615 | } |
| 1616 | 1616 | print '<td class="liste_total"></td>'; |
| 1617 | 1617 | print '</tr>'; |
@@ -47,7 +47,9 @@ discard block |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 " "; |
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 | |
@@ -605,11 +684,16 @@ discard block |
||
| 605 | 684 | $numlines=count($lines); |
| 606 | 685 | |
| 607 | 686 | // Create a smaller array with sublevels only to be used later. This increase dramatically performances. |
| 608 | - if ($parent == 0) // Always and only if at first level |
|
| 687 | + if ($parent == 0) { |
|
| 688 | + // Always and only if at first level |
|
| 609 | 689 | { |
| 610 | - for ($i = 0 ; $i < $numlines ; $i++) |
|
| 690 | + for ($i = 0 ; |
|
| 691 | + } |
|
| 692 | + $i < $numlines ; $i++) |
|
| 611 | 693 | { |
| 612 | - if ($lines[$i]->fk_task_parent) $lineswithoutlevel0[]=$lines[$i]; |
|
| 694 | + if ($lines[$i]->fk_task_parent) { |
|
| 695 | + $lineswithoutlevel0[]=$lines[$i]; |
|
| 696 | + } |
|
| 613 | 697 | } |
| 614 | 698 | } |
| 615 | 699 | |
@@ -621,7 +705,9 @@ discard block |
||
| 621 | 705 | //dol_syslog('projectLinesPerDay inc='.$inc.' preselectedday='.$preselectedday.' task parent id='.$parent.' level='.$level." count(lines)=".$numlines." count(lineswithoutlevel0)=".count($lineswithoutlevel0)); |
| 622 | 706 | for ($i = 0 ; $i < $numlines ; $i++) |
| 623 | 707 | { |
| 624 | - if ($parent == 0) $level = 0; |
|
| 708 | + if ($parent == 0) { |
|
| 709 | + $level = 0; |
|
| 710 | + } |
|
| 625 | 711 | |
| 626 | 712 | //if ($lines[$i]->fk_task_parent == $parent) |
| 627 | 713 | //{ |
@@ -678,7 +764,9 @@ discard block |
||
| 678 | 764 | print '</tr>'; |
| 679 | 765 | } |
| 680 | 766 | |
| 681 | - if ($oldprojectforbreak != -1) $oldprojectforbreak = $projectstatic->id; |
|
| 767 | + if ($oldprojectforbreak != -1) { |
|
| 768 | + $oldprojectforbreak = $projectstatic->id; |
|
| 769 | + } |
|
| 682 | 770 | |
| 683 | 771 | print '<tr class="oddeven">'."\n"; |
| 684 | 772 | |
@@ -700,17 +788,23 @@ discard block |
||
| 700 | 788 | |
| 701 | 789 | // Thirdparty |
| 702 | 790 | print '<td class="tdoverflowmax100">'; |
| 703 | - if ($thirdpartystatic->id > 0) print $thirdpartystatic->getNomUrl(1, 'project', 10); |
|
| 791 | + if ($thirdpartystatic->id > 0) { |
|
| 792 | + print $thirdpartystatic->getNomUrl(1, 'project', 10); |
|
| 793 | + } |
|
| 704 | 794 | print '</td>'; |
| 705 | 795 | |
| 706 | 796 | // Ref |
| 707 | 797 | print '<td>'; |
| 708 | 798 | print '<!-- Task id = '.$lines[$i]->id.' -->'; |
| 709 | - for ($k = 0 ; $k < $level ; $k++) print " "; |
|
| 799 | + for ($k = 0 ; $k < $level ; $k++) { |
|
| 800 | + print " "; |
|
| 801 | + } |
|
| 710 | 802 | print $taskstatic->getNomUrl(1, 'withproject', 'time'); |
| 711 | 803 | // Label task |
| 712 | 804 | print '<br>'; |
| 713 | - for ($k = 0 ; $k < $level ; $k++) print " "; |
|
| 805 | + for ($k = 0 ; $k < $level ; $k++) { |
|
| 806 | + print " "; |
|
| 807 | + } |
|
| 714 | 808 | print $taskstatic->label; |
| 715 | 809 | //print "<br>"; |
| 716 | 810 | //for ($k = 0 ; $k < $level ; $k++) print " "; |
@@ -744,9 +838,13 @@ discard block |
||
| 744 | 838 | print '</td>'; |
| 745 | 839 | |
| 746 | 840 | $cssonholiday=''; |
| 747 | - if (! $isavailable[$preselectedday]['morning'] && ! $isavailable[$preselectedday]['afternoon']) $cssonholiday.='onholidayallday '; |
|
| 748 | - elseif (! $isavailable[$preselectedday]['morning']) $cssonholiday.='onholidaymorning '; |
|
| 749 | - elseif (! $isavailable[$preselectedday]['afternoon']) $cssonholiday.='onholidayafternoon '; |
|
| 841 | + if (! $isavailable[$preselectedday]['morning'] && ! $isavailable[$preselectedday]['afternoon']) { |
|
| 842 | + $cssonholiday.='onholidayallday '; |
|
| 843 | + } elseif (! $isavailable[$preselectedday]['morning']) { |
|
| 844 | + $cssonholiday.='onholidaymorning '; |
|
| 845 | + } elseif (! $isavailable[$preselectedday]['afternoon']) { |
|
| 846 | + $cssonholiday.='onholidayafternoon '; |
|
| 847 | + } |
|
| 750 | 848 | |
| 751 | 849 | // Duration |
| 752 | 850 | print '<td align="center" class="duration'.($cssonholiday?' '.$cssonholiday:'').'">'; |
@@ -755,7 +853,9 @@ discard block |
||
| 755 | 853 | $totalforeachline[$preselectedday]+=$lines[$i]->timespent_duration; |
| 756 | 854 | |
| 757 | 855 | $alreadyspent=''; |
| 758 | - if ($dayWorkLoad > 0) $alreadyspent=convertSecondToTime($lines[$i]->timespent_duration,'allhourmin'); |
|
| 856 | + if ($dayWorkLoad > 0) { |
|
| 857 | + $alreadyspent=convertSecondToTime($lines[$i]->timespent_duration,'allhourmin'); |
|
| 858 | + } |
|
| 759 | 859 | |
| 760 | 860 | print convertSecondToTime($lines[$i]->timespent_duration,'allhourmin'); |
| 761 | 861 | |
@@ -831,11 +931,16 @@ discard block |
||
| 831 | 931 | $numlines=count($lines); |
| 832 | 932 | |
| 833 | 933 | // Create a smaller array with sublevels only to be used later. This increase dramatically performances. |
| 834 | - if ($parent == 0) // Always and only if at first level |
|
| 934 | + if ($parent == 0) { |
|
| 935 | + // Always and only if at first level |
|
| 835 | 936 | { |
| 836 | - for ($i = 0 ; $i < $numlines ; $i++) |
|
| 937 | + for ($i = 0 ; |
|
| 938 | + } |
|
| 939 | + $i < $numlines ; $i++) |
|
| 837 | 940 | { |
| 838 | - if ($lines[$i]->fk_task_parent) $lineswithoutlevel0[]=$lines[$i]; |
|
| 941 | + if ($lines[$i]->fk_task_parent) { |
|
| 942 | + $lineswithoutlevel0[]=$lines[$i]; |
|
| 943 | + } |
|
| 839 | 944 | } |
| 840 | 945 | } |
| 841 | 946 | |
@@ -847,7 +952,9 @@ discard block |
||
| 847 | 952 | //dol_syslog('projectLinesPerDay inc='.$inc.' preselectedday='.$preselectedday.' task parent id='.$parent.' level='.$level." count(lines)=".$numlines." count(lineswithoutlevel0)=".count($lineswithoutlevel0)); |
| 848 | 953 | for ($i = 0 ; $i < $numlines ; $i++) |
| 849 | 954 | { |
| 850 | - if ($parent == 0) $level = 0; |
|
| 955 | + if ($parent == 0) { |
|
| 956 | + $level = 0; |
|
| 957 | + } |
|
| 851 | 958 | |
| 852 | 959 | if ($lines[$i]->fk_task_parent == $parent) |
| 853 | 960 | { |
@@ -904,7 +1011,9 @@ discard block |
||
| 904 | 1011 | print '</tr>'; |
| 905 | 1012 | } |
| 906 | 1013 | |
| 907 | - if ($oldprojectforbreak != -1) $oldprojectforbreak = $projectstatic->id; |
|
| 1014 | + if ($oldprojectforbreak != -1) { |
|
| 1015 | + $oldprojectforbreak = $projectstatic->id; |
|
| 1016 | + } |
|
| 908 | 1017 | |
| 909 | 1018 | print '<tr class="oddeven">'."\n"; |
| 910 | 1019 | |
@@ -917,22 +1026,30 @@ discard block |
||
| 917 | 1026 | |
| 918 | 1027 | // Project |
| 919 | 1028 | print "<td>"; |
| 920 | - if ($oldprojectforbreak == -1) print $projectstatic->getNomUrl(1,'',0,$langs->transnoentitiesnoconv("YourRole").': '.$projectsrole[$lines[$i]->fk_project]); |
|
| 1029 | + if ($oldprojectforbreak == -1) { |
|
| 1030 | + print $projectstatic->getNomUrl(1,'',0,$langs->transnoentitiesnoconv("YourRole").': '.$projectsrole[$lines[$i]->fk_project]); |
|
| 1031 | + } |
|
| 921 | 1032 | print "</td>"; |
| 922 | 1033 | |
| 923 | 1034 | // Thirdparty |
| 924 | 1035 | print '<td class="tdoverflowmax100">'; |
| 925 | - if ($thirdpartystatic->id > 0) print $thirdpartystatic->getNomUrl(1, 'project', 10); |
|
| 1036 | + if ($thirdpartystatic->id > 0) { |
|
| 1037 | + print $thirdpartystatic->getNomUrl(1, 'project', 10); |
|
| 1038 | + } |
|
| 926 | 1039 | print '</td>'; |
| 927 | 1040 | |
| 928 | 1041 | // Ref |
| 929 | 1042 | print '<td>'; |
| 930 | 1043 | print '<!-- Task id = '.$lines[$i]->id.' -->'; |
| 931 | - for ($k = 0 ; $k < $level ; $k++) print " "; |
|
| 1044 | + for ($k = 0 ; $k < $level ; $k++) { |
|
| 1045 | + print " "; |
|
| 1046 | + } |
|
| 932 | 1047 | print $taskstatic->getNomUrl(1, 'withproject', 'time'); |
| 933 | 1048 | // Label task |
| 934 | 1049 | print '<br>'; |
| 935 | - for ($k = 0 ; $k < $level ; $k++) print " "; |
|
| 1050 | + for ($k = 0 ; $k < $level ; $k++) { |
|
| 1051 | + print " "; |
|
| 1052 | + } |
|
| 936 | 1053 | print $taskstatic->label; |
| 937 | 1054 | //print "<br>"; |
| 938 | 1055 | //for ($k = 0 ; $k < $level ; $k++) print " "; |
@@ -941,8 +1058,11 @@ discard block |
||
| 941 | 1058 | |
| 942 | 1059 | // Planned Workload |
| 943 | 1060 | print '<td align="right" class="leftborder plannedworkload">'; |
| 944 | - if ($lines[$i]->planned_workload) print convertSecondToTime($lines[$i]->planned_workload,'allhourmin'); |
|
| 945 | - else print '--:--'; |
|
| 1061 | + if ($lines[$i]->planned_workload) { |
|
| 1062 | + print convertSecondToTime($lines[$i]->planned_workload,'allhourmin'); |
|
| 1063 | + } else { |
|
| 1064 | + print '--:--'; |
|
| 1065 | + } |
|
| 946 | 1066 | print '</td>'; |
| 947 | 1067 | |
| 948 | 1068 | // Progress declared % |
@@ -958,15 +1078,19 @@ discard block |
||
| 958 | 1078 | print '<a href="'.DOL_URL_ROOT.'/projet/tasks/time.php?id='.$lines[$i]->id.'">'; |
| 959 | 1079 | print convertSecondToTime($lines[$i]->duration,'allhourmin'); |
| 960 | 1080 | print '</a>'; |
| 1081 | + } else { |
|
| 1082 | + print '--:--'; |
|
| 961 | 1083 | } |
| 962 | - else print '--:--'; |
|
| 963 | 1084 | print "</td>\n"; |
| 964 | 1085 | |
| 965 | 1086 | // Time spent by user |
| 966 | 1087 | print '<td align="right">'; |
| 967 | 1088 | $tmptimespent=$taskstatic->getSummaryOfTimeSpent($fuser->id); |
| 968 | - if ($tmptimespent['total_duration']) print convertSecondToTime($tmptimespent['total_duration'],'allhourmin'); |
|
| 969 | - else print '--:--'; |
|
| 1089 | + if ($tmptimespent['total_duration']) { |
|
| 1090 | + print convertSecondToTime($tmptimespent['total_duration'],'allhourmin'); |
|
| 1091 | + } else { |
|
| 1092 | + print '--:--'; |
|
| 1093 | + } |
|
| 970 | 1094 | print "</td>\n"; |
| 971 | 1095 | |
| 972 | 1096 | $disabledproject=1;$disabledtask=1; |
@@ -992,9 +1116,13 @@ discard block |
||
| 992 | 1116 | print '</td>'; |
| 993 | 1117 | |
| 994 | 1118 | $cssonholiday=''; |
| 995 | - if (! $isavailable[$preselectedday]['morning'] && ! $isavailable[$preselectedday]['afternoon']) $cssonholiday.='onholidayallday '; |
|
| 996 | - elseif (! $isavailable[$preselectedday]['morning']) $cssonholiday.='onholidaymorning '; |
|
| 997 | - elseif (! $isavailable[$preselectedday]['afternoon']) $cssonholiday.='onholidayafternoon '; |
|
| 1119 | + if (! $isavailable[$preselectedday]['morning'] && ! $isavailable[$preselectedday]['afternoon']) { |
|
| 1120 | + $cssonholiday.='onholidayallday '; |
|
| 1121 | + } elseif (! $isavailable[$preselectedday]['morning']) { |
|
| 1122 | + $cssonholiday.='onholidaymorning '; |
|
| 1123 | + } elseif (! $isavailable[$preselectedday]['afternoon']) { |
|
| 1124 | + $cssonholiday.='onholidayafternoon '; |
|
| 1125 | + } |
|
| 998 | 1126 | |
| 999 | 1127 | global $daytoparse; |
| 1000 | 1128 | $tmparray = dol_getdate($daytoparse,true); // detail of current day |
@@ -1002,10 +1130,12 @@ discard block |
||
| 1002 | 1130 | |
| 1003 | 1131 | global $numstartworkingday, $numendworkingday; |
| 1004 | 1132 | $cssweekend=''; |
| 1005 | - if (($idw + 1) < $numstartworkingday || ($idw + 1) > $numendworkingday) // This is a day is not inside the setup of working days, so we use a week-end css. |
|
| 1133 | + if (($idw + 1) < $numstartworkingday || ($idw + 1) > $numendworkingday) { |
|
| 1134 | + // This is a day is not inside the setup of working days, so we use a week-end css. |
|
| 1006 | 1135 | { |
| 1007 | 1136 | $cssweekend='weekend'; |
| 1008 | 1137 | } |
| 1138 | + } |
|
| 1009 | 1139 | |
| 1010 | 1140 | // Duration |
| 1011 | 1141 | print '<td class="center duration'.($cssonholiday?' '.$cssonholiday:'').($cssweekend?' '.$cssweekend:'').'">'; |
@@ -1013,7 +1143,9 @@ discard block |
||
| 1013 | 1143 | $totalforeachday[$preselectedday]+=$dayWorkLoad; |
| 1014 | 1144 | |
| 1015 | 1145 | $alreadyspent=''; |
| 1016 | - if ($dayWorkLoad > 0) $alreadyspent=convertSecondToTime($dayWorkLoad,'allhourmin'); |
|
| 1146 | + if ($dayWorkLoad > 0) { |
|
| 1147 | + $alreadyspent=convertSecondToTime($dayWorkLoad,'allhourmin'); |
|
| 1148 | + } |
|
| 1017 | 1149 | |
| 1018 | 1150 | $idw = 0; |
| 1019 | 1151 | |
@@ -1043,11 +1175,14 @@ discard block |
||
| 1043 | 1175 | |
| 1044 | 1176 | // Warning |
| 1045 | 1177 | print '<td align="right">'; |
| 1046 | - if ((! $lines[$i]->public) && $disabledproject) print $form->textwithpicto('',$langs->trans("UserIsNotContactOfProject")); |
|
| 1047 | - else if ($disabledtask) |
|
| 1178 | + if ((! $lines[$i]->public) && $disabledproject) { |
|
| 1179 | + print $form->textwithpicto('',$langs->trans("UserIsNotContactOfProject")); |
|
| 1180 | + } else if ($disabledtask) |
|
| 1048 | 1181 | { |
| 1049 | 1182 | $titleassigntask = $langs->trans("AssignTaskToMe"); |
| 1050 | - if ($fuser->id != $user->id) $titleassigntask = $langs->trans("AssignTaskToUser", '...'); |
|
| 1183 | + if ($fuser->id != $user->id) { |
|
| 1184 | + $titleassigntask = $langs->trans("AssignTaskToUser", '...'); |
|
| 1185 | + } |
|
| 1051 | 1186 | |
| 1052 | 1187 | print $form->textwithpicto('',$langs->trans("TaskIsNotAssignedToUser", $titleassigntask)); |
| 1053 | 1188 | } |
@@ -1073,8 +1208,7 @@ discard block |
||
| 1073 | 1208 | //var_dump($totalforeachday); |
| 1074 | 1209 | } |
| 1075 | 1210 | $level--; |
| 1076 | - } |
|
| 1077 | - else |
|
| 1211 | + } else |
|
| 1078 | 1212 | { |
| 1079 | 1213 | //$level--; |
| 1080 | 1214 | } |
@@ -1114,11 +1248,16 @@ discard block |
||
| 1114 | 1248 | $lineswithoutlevel0=array(); |
| 1115 | 1249 | |
| 1116 | 1250 | // Create a smaller array with sublevels only to be used later. This increase dramatically performances. |
| 1117 | - if ($parent == 0) // Always and only if at first level |
|
| 1251 | + if ($parent == 0) { |
|
| 1252 | + // Always and only if at first level |
|
| 1118 | 1253 | { |
| 1119 | - for ($i = 0 ; $i < $numlines ; $i++) |
|
| 1254 | + for ($i = 0 ; |
|
| 1255 | + } |
|
| 1256 | + $i < $numlines ; $i++) |
|
| 1120 | 1257 | { |
| 1121 | - if ($lines[$i]->fk_task_parent) $lineswithoutlevel0[]=$lines[$i]; |
|
| 1258 | + if ($lines[$i]->fk_task_parent) { |
|
| 1259 | + $lineswithoutlevel0[]=$lines[$i]; |
|
| 1260 | + } |
|
| 1122 | 1261 | } |
| 1123 | 1262 | } |
| 1124 | 1263 | |
@@ -1131,7 +1270,9 @@ discard block |
||
| 1131 | 1270 | |
| 1132 | 1271 | for ($i = 0 ; $i < $numlines ; $i++) |
| 1133 | 1272 | { |
| 1134 | - if ($parent == 0) $level = 0; |
|
| 1273 | + if ($parent == 0) { |
|
| 1274 | + $level = 0; |
|
| 1275 | + } |
|
| 1135 | 1276 | |
| 1136 | 1277 | if ($lines[$i]->fk_task_parent == $parent) |
| 1137 | 1278 | { |
@@ -1187,7 +1328,9 @@ discard block |
||
| 1187 | 1328 | print '</tr>'; |
| 1188 | 1329 | } |
| 1189 | 1330 | |
| 1190 | - if ($oldprojectforbreak != -1) $oldprojectforbreak = $projectstatic->id; |
|
| 1331 | + if ($oldprojectforbreak != -1) { |
|
| 1332 | + $oldprojectforbreak = $projectstatic->id; |
|
| 1333 | + } |
|
| 1191 | 1334 | |
| 1192 | 1335 | print '<tr class="oddeven">'."\n"; |
| 1193 | 1336 | |
@@ -1200,22 +1343,30 @@ discard block |
||
| 1200 | 1343 | |
| 1201 | 1344 | // Project |
| 1202 | 1345 | print '<td class="nowrap">'; |
| 1203 | - if ($oldprojectforbreak == -1) print $projectstatic->getNomUrl(1,'',0,$langs->transnoentitiesnoconv("YourRole").': '.$projectsrole[$lines[$i]->fk_project]); |
|
| 1346 | + if ($oldprojectforbreak == -1) { |
|
| 1347 | + print $projectstatic->getNomUrl(1,'',0,$langs->transnoentitiesnoconv("YourRole").': '.$projectsrole[$lines[$i]->fk_project]); |
|
| 1348 | + } |
|
| 1204 | 1349 | print "</td>"; |
| 1205 | 1350 | |
| 1206 | 1351 | // Thirdparty |
| 1207 | 1352 | print '<td class="tdoverflowmax100">'; |
| 1208 | - if ($thirdpartystatic->id > 0) print $thirdpartystatic->getNomUrl(1, 'project'); |
|
| 1353 | + if ($thirdpartystatic->id > 0) { |
|
| 1354 | + print $thirdpartystatic->getNomUrl(1, 'project'); |
|
| 1355 | + } |
|
| 1209 | 1356 | print '</td>'; |
| 1210 | 1357 | |
| 1211 | 1358 | // Ref |
| 1212 | 1359 | print '<td class="nowrap">'; |
| 1213 | 1360 | print '<!-- Task id = '.$lines[$i]->id.' -->'; |
| 1214 | - for ($k = 0 ; $k < $level ; $k++) print " "; |
|
| 1361 | + for ($k = 0 ; $k < $level ; $k++) { |
|
| 1362 | + print " "; |
|
| 1363 | + } |
|
| 1215 | 1364 | print $taskstatic->getNomUrl(1, 'withproject', 'time'); |
| 1216 | 1365 | // Label task |
| 1217 | 1366 | print '<br>'; |
| 1218 | - for ($k = 0 ; $k < $level ; $k++) print " "; |
|
| 1367 | + for ($k = 0 ; $k < $level ; $k++) { |
|
| 1368 | + print " "; |
|
| 1369 | + } |
|
| 1219 | 1370 | //print $taskstatic->getNomUrl(0, 'withproject', 'time'); |
| 1220 | 1371 | print $taskstatic->label; |
| 1221 | 1372 | //print "<br>"; |
@@ -1225,8 +1376,11 @@ discard block |
||
| 1225 | 1376 | |
| 1226 | 1377 | // Planned Workload |
| 1227 | 1378 | print '<td align="right" class="leftborder plannedworkload">'; |
| 1228 | - if ($lines[$i]->planned_workload) print convertSecondToTime($lines[$i]->planned_workload,'allhourmin'); |
|
| 1229 | - else print '--:--'; |
|
| 1379 | + if ($lines[$i]->planned_workload) { |
|
| 1380 | + print convertSecondToTime($lines[$i]->planned_workload,'allhourmin'); |
|
| 1381 | + } else { |
|
| 1382 | + print '--:--'; |
|
| 1383 | + } |
|
| 1230 | 1384 | print '</td>'; |
| 1231 | 1385 | |
| 1232 | 1386 | // Progress declared % |
@@ -1242,15 +1396,19 @@ discard block |
||
| 1242 | 1396 | print '<a href="'.DOL_URL_ROOT.'/projet/tasks/time.php?id='.$lines[$i]->id.'">'; |
| 1243 | 1397 | print convertSecondToTime($lines[$i]->duration,'allhourmin'); |
| 1244 | 1398 | print '</a>'; |
| 1399 | + } else { |
|
| 1400 | + print '--:--'; |
|
| 1245 | 1401 | } |
| 1246 | - else print '--:--'; |
|
| 1247 | 1402 | print "</td>\n"; |
| 1248 | 1403 | |
| 1249 | 1404 | // Time spent by user |
| 1250 | 1405 | print '<td align="right">'; |
| 1251 | 1406 | $tmptimespent=$taskstatic->getSummaryOfTimeSpent($fuser->id); |
| 1252 | - if ($tmptimespent['total_duration']) print convertSecondToTime($tmptimespent['total_duration'],'allhourmin'); |
|
| 1253 | - else print '--:--'; |
|
| 1407 | + if ($tmptimespent['total_duration']) { |
|
| 1408 | + print convertSecondToTime($tmptimespent['total_duration'],'allhourmin'); |
|
| 1409 | + } else { |
|
| 1410 | + print '--:--'; |
|
| 1411 | + } |
|
| 1254 | 1412 | print "</td>\n"; |
| 1255 | 1413 | |
| 1256 | 1414 | $disabledproject=1;$disabledtask=1; |
@@ -1278,24 +1436,32 @@ discard block |
||
| 1278 | 1436 | $tmpday=dol_time_plus_duree($firstdaytoshow, $idw, 'd'); |
| 1279 | 1437 | |
| 1280 | 1438 | $cssonholiday=''; |
| 1281 | - if (! $isavailable[$tmpday]['morning'] && ! $isavailable[$tmpday]['afternoon']) $cssonholiday.='onholidayallday '; |
|
| 1282 | - elseif (! $isavailable[$tmpday]['morning']) $cssonholiday.='onholidaymorning '; |
|
| 1283 | - elseif (! $isavailable[$tmpday]['afternoon']) $cssonholiday.='onholidayafternoon '; |
|
| 1439 | + if (! $isavailable[$tmpday]['morning'] && ! $isavailable[$tmpday]['afternoon']) { |
|
| 1440 | + $cssonholiday.='onholidayallday '; |
|
| 1441 | + } elseif (! $isavailable[$tmpday]['morning']) { |
|
| 1442 | + $cssonholiday.='onholidaymorning '; |
|
| 1443 | + } elseif (! $isavailable[$tmpday]['afternoon']) { |
|
| 1444 | + $cssonholiday.='onholidayafternoon '; |
|
| 1445 | + } |
|
| 1284 | 1446 | |
| 1285 | 1447 | $tmparray=dol_getdate($tmpday); |
| 1286 | 1448 | $dayWorkLoad = $projectstatic->weekWorkLoadPerTask[$tmpday][$lines[$i]->id]; |
| 1287 | 1449 | $totalforeachday[$tmpday]+=$dayWorkLoad; |
| 1288 | 1450 | |
| 1289 | 1451 | $alreadyspent=''; |
| 1290 | - if ($dayWorkLoad > 0) $alreadyspent=convertSecondToTime($dayWorkLoad,'allhourmin'); |
|
| 1452 | + if ($dayWorkLoad > 0) { |
|
| 1453 | + $alreadyspent=convertSecondToTime($dayWorkLoad,'allhourmin'); |
|
| 1454 | + } |
|
| 1291 | 1455 | $alttitle=$langs->trans("AddHereTimeSpentForDay",$tmparray['day'],$tmparray['mon']); |
| 1292 | 1456 | |
| 1293 | 1457 | global $numstartworkingday, $numendworkingday; |
| 1294 | 1458 | $cssweekend=''; |
| 1295 | - if (($idw + 1) < $numstartworkingday || ($idw + 1) > $numendworkingday) // This is a day is not inside the setup of working days, so we use a week-end css. |
|
| 1459 | + if (($idw + 1) < $numstartworkingday || ($idw + 1) > $numendworkingday) { |
|
| 1460 | + // This is a day is not inside the setup of working days, so we use a week-end css. |
|
| 1296 | 1461 | { |
| 1297 | 1462 | $cssweekend='weekend'; |
| 1298 | 1463 | } |
| 1464 | + } |
|
| 1299 | 1465 | |
| 1300 | 1466 | $tableCell ='<td align="center" class="hide'.$idw.($cssonholiday?' '.$cssonholiday:'').($cssweekend?' '.$cssweekend:'').'">'; |
| 1301 | 1467 | if ($alreadyspent) |
@@ -1315,11 +1481,14 @@ discard block |
||
| 1315 | 1481 | |
| 1316 | 1482 | // Warning |
| 1317 | 1483 | print '<td align="right">'; |
| 1318 | - if ((! $lines[$i]->public) && $disabledproject) print $form->textwithpicto('',$langs->trans("UserIsNotContactOfProject")); |
|
| 1319 | - else if ($disabledtask) |
|
| 1484 | + if ((! $lines[$i]->public) && $disabledproject) { |
|
| 1485 | + print $form->textwithpicto('',$langs->trans("UserIsNotContactOfProject")); |
|
| 1486 | + } else if ($disabledtask) |
|
| 1320 | 1487 | { |
| 1321 | 1488 | $titleassigntask = $langs->trans("AssignTaskToMe"); |
| 1322 | - if ($fuser->id != $user->id) $titleassigntask = $langs->trans("AssignTaskToUser", '...'); |
|
| 1489 | + if ($fuser->id != $user->id) { |
|
| 1490 | + $titleassigntask = $langs->trans("AssignTaskToUser", '...'); |
|
| 1491 | + } |
|
| 1323 | 1492 | |
| 1324 | 1493 | print $form->textwithpicto('',$langs->trans("TaskIsNotAssignedToUser", $titleassigntask)); |
| 1325 | 1494 | } |
@@ -1346,8 +1515,7 @@ discard block |
||
| 1346 | 1515 | //var_dump($totalforeachday); |
| 1347 | 1516 | } |
| 1348 | 1517 | $level--; |
| 1349 | - } |
|
| 1350 | - else |
|
| 1518 | + } else |
|
| 1351 | 1519 | { |
| 1352 | 1520 | //$level--; |
| 1353 | 1521 | } |
@@ -1386,7 +1554,9 @@ discard block |
||
| 1386 | 1554 | searchTaskInChild($inc, $lines[$i]->id, $lines, $taskrole); |
| 1387 | 1555 | //print 'Found inc='.$inc.'<br>'; |
| 1388 | 1556 | |
| 1389 | - if ($inc > 0) return $inc; |
|
| 1557 | + if ($inc > 0) { |
|
| 1558 | + return $inc; |
|
| 1559 | + } |
|
| 1390 | 1560 | } |
| 1391 | 1561 | } |
| 1392 | 1562 | |
@@ -1420,7 +1590,9 @@ discard block |
||
| 1420 | 1590 | $project_year_filter=0; |
| 1421 | 1591 | |
| 1422 | 1592 | $title=$langs->trans("Projects"); |
| 1423 | - if (strcmp($statut, '') && $statut >= 0) $title=$langs->trans("Projects").' '.$langs->trans($projectstatic->statuts_long[$statut]); |
|
| 1593 | + if (strcmp($statut, '') && $statut >= 0) { |
|
| 1594 | + $title=$langs->trans("Projects").' '.$langs->trans($projectstatic->statuts_long[$statut]); |
|
| 1595 | + } |
|
| 1424 | 1596 | |
| 1425 | 1597 | $arrayidtypeofcontact=array(); |
| 1426 | 1598 | |
@@ -1433,14 +1605,15 @@ discard block |
||
| 1433 | 1605 | $sql.= ", ".MAIN_DB_PREFIX."projet_task as t"; |
| 1434 | 1606 | $sql.= ", ".MAIN_DB_PREFIX."element_contact as ec"; |
| 1435 | 1607 | $sql.= ", ".MAIN_DB_PREFIX."c_type_contact as ctc"; |
| 1436 | - } |
|
| 1437 | - else |
|
| 1608 | + } else |
|
| 1438 | 1609 | { |
| 1439 | 1610 | $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."projet_task as t ON p.rowid = t.fk_projet"; |
| 1440 | 1611 | } |
| 1441 | 1612 | $sql.= " WHERE p.entity IN (".getEntity('project').")"; |
| 1442 | 1613 | $sql.= " AND p.rowid IN (".$projectsListId.")"; |
| 1443 | - if ($socid) $sql.= " AND (p.fk_soc IS NULL OR p.fk_soc = 0 OR p.fk_soc = ".$socid.")"; |
|
| 1614 | + if ($socid) { |
|
| 1615 | + $sql.= " AND (p.fk_soc IS NULL OR p.fk_soc = 0 OR p.fk_soc = ".$socid.")"; |
|
| 1616 | + } |
|
| 1444 | 1617 | if ($mytasks) |
| 1445 | 1618 | { |
| 1446 | 1619 | $sql.= " AND p.rowid = t.fk_projet"; |
@@ -1483,9 +1656,12 @@ discard block |
||
| 1483 | 1656 | $arrayidofprojects[$objp->projectid]=$objp->projectid; |
| 1484 | 1657 | $i++; |
| 1485 | 1658 | } |
| 1659 | + } else { |
|
| 1660 | + dol_print_error($db); |
|
| 1661 | + } |
|
| 1662 | + if (empty($arrayidofprojects)) { |
|
| 1663 | + $arrayidofprojects[0]=-1; |
|
| 1486 | 1664 | } |
| 1487 | - else dol_print_error($db); |
|
| 1488 | - if (empty($arrayidofprojects)) $arrayidofprojects[0]=-1; |
|
| 1489 | 1665 | |
| 1490 | 1666 | // Get list of project with calculation on tasks |
| 1491 | 1667 | $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,"; |
@@ -1519,8 +1695,12 @@ discard block |
||
| 1519 | 1695 | if (empty($conf->global->PROJECT_HIDE_TASKS)) |
| 1520 | 1696 | { |
| 1521 | 1697 | print_liste_field_titre("Tasks","","","","",'align="right"',$sortfield,$sortorder); |
| 1522 | - if (! in_array('plannedworkload', $hiddenfields)) print_liste_field_titre("PlannedWorkload","","","","",'align="right"',$sortfield,$sortorder); |
|
| 1523 | - if (! in_array('declaredprogress', $hiddenfields)) print_liste_field_titre("ProgressDeclared","","","","",'align="right"',$sortfield,$sortorder); |
|
| 1698 | + if (! in_array('plannedworkload', $hiddenfields)) { |
|
| 1699 | + print_liste_field_titre("PlannedWorkload","","","","",'align="right"',$sortfield,$sortorder); |
|
| 1700 | + } |
|
| 1701 | + if (! in_array('declaredprogress', $hiddenfields)) { |
|
| 1702 | + print_liste_field_titre("ProgressDeclared","","","","",'align="right"',$sortfield,$sortorder); |
|
| 1703 | + } |
|
| 1524 | 1704 | } |
| 1525 | 1705 | print_liste_field_titre("Status","","","","",'align="right"',$sortfield,$sortorder); |
| 1526 | 1706 | print "</tr>\n"; |
@@ -1547,7 +1727,9 @@ discard block |
||
| 1547 | 1727 | print '<tr class="oddeven">'; |
| 1548 | 1728 | print '<td>'; |
| 1549 | 1729 | print $projectstatic->getNomUrl(1); |
| 1550 | - if (! in_array('projectlabel', $hiddenfields)) print '<br>'.dol_trunc($objp->title,24); |
|
| 1730 | + if (! in_array('projectlabel', $hiddenfields)) { |
|
| 1731 | + print '<br>'.dol_trunc($objp->title,24); |
|
| 1732 | + } |
|
| 1551 | 1733 | print '</td>'; |
| 1552 | 1734 | print '<td>'; |
| 1553 | 1735 | if ($objp->fk_soc > 0) |
@@ -1561,11 +1743,15 @@ discard block |
||
| 1561 | 1743 | if (! empty($conf->global->PROJECT_USE_OPPORTUNITIES)) |
| 1562 | 1744 | { |
| 1563 | 1745 | print '<td align="right">'; |
| 1564 | - if ($objp->opp_amount) print price($objp->opp_amount, 0, '', 1, -1, -1, $conf->currency); |
|
| 1746 | + if ($objp->opp_amount) { |
|
| 1747 | + print price($objp->opp_amount, 0, '', 1, -1, -1, $conf->currency); |
|
| 1748 | + } |
|
| 1565 | 1749 | print '</td>'; |
| 1566 | 1750 | print '<td align="right">'; |
| 1567 | 1751 | $code = dol_getIdFromCode($db, $objp->opp_status, 'c_lead_status', 'rowid', 'code'); |
| 1568 | - if ($code) print $langs->trans("OppStatus".$code); |
|
| 1752 | + if ($code) { |
|
| 1753 | + print $langs->trans("OppStatus".$code); |
|
| 1754 | + } |
|
| 1569 | 1755 | print '</td>'; |
| 1570 | 1756 | } |
| 1571 | 1757 | if (empty($conf->global->PROJECT_HIDE_TASKS)) |
@@ -1610,15 +1796,18 @@ discard block |
||
| 1610 | 1796 | if (empty($conf->global->PROJECT_HIDE_TASKS)) |
| 1611 | 1797 | { |
| 1612 | 1798 | print '<td class="liste_total" align="right">'.$total_task.'</td>'; |
| 1613 | - if (! in_array('plannedworkload', $hiddenfields)) print '<td class="liste_total" align="right">'.($total_plannedworkload?convertSecondToTime($total_plannedworkload):'').'</td>'; |
|
| 1614 | - if (! in_array('declaredprogress', $hiddenfields)) print '<td class="liste_total" align="right">'.($total_plannedworkload?round(100*$total_declaredprogressworkload/$total_plannedworkload,0).'%':'').'</td>'; |
|
| 1799 | + if (! in_array('plannedworkload', $hiddenfields)) { |
|
| 1800 | + print '<td class="liste_total" align="right">'.($total_plannedworkload?convertSecondToTime($total_plannedworkload):'').'</td>'; |
|
| 1801 | + } |
|
| 1802 | + if (! in_array('declaredprogress', $hiddenfields)) { |
|
| 1803 | + print '<td class="liste_total" align="right">'.($total_plannedworkload?round(100*$total_declaredprogressworkload/$total_plannedworkload,0).'%':'').'</td>'; |
|
| 1804 | + } |
|
| 1615 | 1805 | } |
| 1616 | 1806 | print '<td class="liste_total"></td>'; |
| 1617 | 1807 | print '</tr>'; |
| 1618 | 1808 | |
| 1619 | 1809 | $db->free($resql); |
| 1620 | - } |
|
| 1621 | - else |
|
| 1810 | + } else |
|
| 1622 | 1811 | { |
| 1623 | 1812 | dol_print_error($db); |
| 1624 | 1813 | } |
@@ -104,7 +104,7 @@ |
||
| 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) |
@@ -260,7 +260,7 @@ discard block |
||
| 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 |
||
| 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); |
@@ -140,7 +140,9 @@ discard block |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 | } |
@@ -33,13 +33,13 @@ discard block |
||
| 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 |
||
| 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"> <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"> <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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 270 | 270 | $result = 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 -1; |
| 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 | if (is_string($result)) |
| 296 | 296 | { |
| 297 | 297 | $this->error = $result; |
@@ -96,7 +96,7 @@ |
||
| 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) |
@@ -35,16 +35,16 @@ discard block |
||
| 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 |
||
| 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; |
@@ -114,10 +114,12 @@ discard block |
||
| 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 |
||
| 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; |
@@ -22,17 +22,17 @@ discard block |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 | } |
@@ -100,7 +100,7 @@ |
||
| 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) |
@@ -35,14 +35,14 @@ discard block |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 | |
@@ -22,7 +22,7 @@ discard block |
||
| 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 |
||
| 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 |
||
| 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"> <input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button"></td>'; |
|
| 68 | + $texte .= '<td align="left" rowspan="2"> <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 |
||
| 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 |
||
| 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 |
||
| 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 | } |
@@ -43,7 +43,7 @@ |
||
| 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 | { |
@@ -76,11 +76,11 @@ discard block |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 | { |
@@ -37,7 +37,7 @@ discard block |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 | } |
@@ -67,7 +67,10 @@ discard block |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 | } |
@@ -41,7 +41,7 @@ |
||
| 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 | { |
@@ -87,17 +87,17 @@ discard block |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
@@ -36,7 +36,7 @@ discard block |
||
| 36 | 36 | */ |
| 37 | 37 | class pdf_rouget extends ModelePdfExpedition |
| 38 | 38 | { |
| 39 | - var $emetteur; // Objet societe qui emet |
|
| 39 | + var $emetteur; // Objet societe qui emet |
|
| 40 | 40 | |
| 41 | 41 | |
| 42 | 42 | /** |
@@ -44,57 +44,57 @@ discard block |
||
| 44 | 44 | * |
| 45 | 45 | * @param DoliDB $db Database handler |
| 46 | 46 | */ |
| 47 | - function __construct($db=0) |
|
| 47 | + function __construct($db = 0) |
|
| 48 | 48 | { |
| 49 | - global $conf,$langs,$mysoc; |
|
| 49 | + global $conf, $langs, $mysoc; |
|
| 50 | 50 | |
| 51 | 51 | $this->db = $db; |
| 52 | 52 | $this->name = "rouget"; |
| 53 | 53 | $this->description = $langs->trans("DocumentModelStandardPDF"); |
| 54 | 54 | |
| 55 | 55 | $this->type = 'pdf'; |
| 56 | - $formatarray=pdf_getFormat(); |
|
| 56 | + $formatarray = pdf_getFormat(); |
|
| 57 | 57 | $this->page_largeur = $formatarray['width']; |
| 58 | 58 | $this->page_hauteur = $formatarray['height']; |
| 59 | - $this->format = array($this->page_largeur,$this->page_hauteur); |
|
| 60 | - $this->marge_gauche=isset($conf->global->MAIN_PDF_MARGIN_LEFT)?$conf->global->MAIN_PDF_MARGIN_LEFT:10; |
|
| 61 | - $this->marge_droite=isset($conf->global->MAIN_PDF_MARGIN_RIGHT)?$conf->global->MAIN_PDF_MARGIN_RIGHT:10; |
|
| 62 | - $this->marge_haute =isset($conf->global->MAIN_PDF_MARGIN_TOP)?$conf->global->MAIN_PDF_MARGIN_TOP:10; |
|
| 63 | - $this->marge_basse =isset($conf->global->MAIN_PDF_MARGIN_BOTTOM)?$conf->global->MAIN_PDF_MARGIN_BOTTOM:10; |
|
| 59 | + $this->format = array($this->page_largeur, $this->page_hauteur); |
|
| 60 | + $this->marge_gauche = isset($conf->global->MAIN_PDF_MARGIN_LEFT) ? $conf->global->MAIN_PDF_MARGIN_LEFT : 10; |
|
| 61 | + $this->marge_droite = isset($conf->global->MAIN_PDF_MARGIN_RIGHT) ? $conf->global->MAIN_PDF_MARGIN_RIGHT : 10; |
|
| 62 | + $this->marge_haute = isset($conf->global->MAIN_PDF_MARGIN_TOP) ? $conf->global->MAIN_PDF_MARGIN_TOP : 10; |
|
| 63 | + $this->marge_basse = isset($conf->global->MAIN_PDF_MARGIN_BOTTOM) ? $conf->global->MAIN_PDF_MARGIN_BOTTOM : 10; |
|
| 64 | 64 | |
| 65 | 65 | $this->option_logo = 1; |
| 66 | 66 | |
| 67 | 67 | // Get source company |
| 68 | - $this->emetteur=$mysoc; |
|
| 69 | - if (! $this->emetteur->country_code) $this->emetteur->country_code=substr($langs->defaultlang,-2); // By default if not defined |
|
| 68 | + $this->emetteur = $mysoc; |
|
| 69 | + if (!$this->emetteur->country_code) $this->emetteur->country_code = substr($langs->defaultlang, -2); // By default if not defined |
|
| 70 | 70 | |
| 71 | 71 | // Define position of columns |
| 72 | - $this->posxdesc=$this->marge_gauche+1; |
|
| 73 | - $this->posxweightvol=$this->page_largeur - $this->marge_droite - 78; |
|
| 74 | - $this->posxqtyordered=$this->page_largeur - $this->marge_droite - 56; |
|
| 75 | - $this->posxqtytoship=$this->page_largeur - $this->marge_droite - 28; |
|
| 76 | - $this->posxpuht=$this->page_largeur - $this->marge_droite; |
|
| 72 | + $this->posxdesc = $this->marge_gauche + 1; |
|
| 73 | + $this->posxweightvol = $this->page_largeur - $this->marge_droite - 78; |
|
| 74 | + $this->posxqtyordered = $this->page_largeur - $this->marge_droite - 56; |
|
| 75 | + $this->posxqtytoship = $this->page_largeur - $this->marge_droite - 28; |
|
| 76 | + $this->posxpuht = $this->page_largeur - $this->marge_droite; |
|
| 77 | 77 | |
| 78 | 78 | if (!empty($conf->global->MAIN_PDF_SHIPPING_DISPLAY_AMOUNT_HT)) { |
| 79 | 79 | |
| 80 | - $this->posxweightvol=$this->page_largeur - $this->marge_droite - 118; |
|
| 81 | - $this->posxqtyordered=$this->page_largeur - $this->marge_droite - 96; |
|
| 82 | - $this->posxqtytoship=$this->page_largeur - $this->marge_droite - 68; |
|
| 83 | - $this->posxpuht=$this->page_largeur - $this->marge_droite - 40; |
|
| 84 | - $this->posxtotalht=$this->page_largeur - $this->marge_droite - 20; |
|
| 80 | + $this->posxweightvol = $this->page_largeur - $this->marge_droite - 118; |
|
| 81 | + $this->posxqtyordered = $this->page_largeur - $this->marge_droite - 96; |
|
| 82 | + $this->posxqtytoship = $this->page_largeur - $this->marge_droite - 68; |
|
| 83 | + $this->posxpuht = $this->page_largeur - $this->marge_droite - 40; |
|
| 84 | + $this->posxtotalht = $this->page_largeur - $this->marge_droite - 20; |
|
| 85 | 85 | } |
| 86 | 86 | |
| 87 | - $this->posxpicture=$this->posxweightvol - (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH)?20:$conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH); // width of images |
|
| 87 | + $this->posxpicture = $this->posxweightvol - (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH) ? 20 : $conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH); // width of images |
|
| 88 | 88 | |
| 89 | 89 | if ($this->page_largeur < 210) // To work with US executive format |
| 90 | 90 | { |
| 91 | - $this->posxweightvol-=20; |
|
| 92 | - $this->posxpicture-=20; |
|
| 93 | - $this->posxqtyordered-=20; |
|
| 94 | - $this->posxqtytoship-=20; |
|
| 91 | + $this->posxweightvol -= 20; |
|
| 92 | + $this->posxpicture -= 20; |
|
| 93 | + $this->posxqtyordered -= 20; |
|
| 94 | + $this->posxqtytoship -= 20; |
|
| 95 | 95 | } |
| 96 | 96 | |
| 97 | - if (! empty($conf->global->SHIPPING_PDF_HIDE_ORDERED)) |
|
| 97 | + if (!empty($conf->global->SHIPPING_PDF_HIDE_ORDERED)) |
|
| 98 | 98 | { |
| 99 | 99 | $this->posxweightvol += ($this->posxqtytoship - $this->posxqtyordered); |
| 100 | 100 | $this->posxpicture += ($this->posxqtytoship - $this->posxqtyordered); |
@@ -113,15 +113,15 @@ discard block |
||
| 113 | 113 | * @param int $hideref Do not show ref |
| 114 | 114 | * @return int 1=OK, 0=KO |
| 115 | 115 | */ |
| 116 | - function write_file($object,$outputlangs,$srctemplatepath='',$hidedetails=0,$hidedesc=0,$hideref=0) |
|
| 116 | + function write_file($object, $outputlangs, $srctemplatepath = '', $hidedetails = 0, $hidedesc = 0, $hideref = 0) |
|
| 117 | 117 | { |
| 118 | - global $user,$conf,$langs,$hookmanager; |
|
| 118 | + global $user, $conf, $langs, $hookmanager; |
|
| 119 | 119 | |
| 120 | 120 | $object->fetch_thirdparty(); |
| 121 | 121 | |
| 122 | - if (! is_object($outputlangs)) $outputlangs=$langs; |
|
| 122 | + if (!is_object($outputlangs)) $outputlangs = $langs; |
|
| 123 | 123 | // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO |
| 124 | - if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1'; |
|
| 124 | + if (!empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output = 'ISO-8859-1'; |
|
| 125 | 125 | |
| 126 | 126 | $outputlangs->load("main"); |
| 127 | 127 | $outputlangs->load("dict"); |
@@ -136,50 +136,50 @@ discard block |
||
| 136 | 136 | $nblignes = count($object->lines); |
| 137 | 137 | |
| 138 | 138 | // Loop on each lines to detect if there is at least one image to show |
| 139 | - $realpatharray=array(); |
|
| 140 | - if (! empty($conf->global->MAIN_GENERATE_SHIPMENT_WITH_PICTURE)) |
|
| 139 | + $realpatharray = array(); |
|
| 140 | + if (!empty($conf->global->MAIN_GENERATE_SHIPMENT_WITH_PICTURE)) |
|
| 141 | 141 | { |
| 142 | 142 | $objphoto = new Product($this->db); |
| 143 | 143 | |
| 144 | - for ($i = 0 ; $i < $nblignes ; $i++) |
|
| 144 | + for ($i = 0; $i < $nblignes; $i++) |
|
| 145 | 145 | { |
| 146 | 146 | if (empty($object->lines[$i]->fk_product)) continue; |
| 147 | 147 | |
| 148 | 148 | $objphoto = new Product($this->db); |
| 149 | 149 | $objphoto->fetch($object->lines[$i]->fk_product); |
| 150 | 150 | |
| 151 | - $pdir = get_exdir($object->lines[$i]->fk_product,2,0,0,$objphoto,'product') . $object->lines[$i]->fk_product ."/photos/"; |
|
| 151 | + $pdir = get_exdir($object->lines[$i]->fk_product, 2, 0, 0, $objphoto, 'product').$object->lines[$i]->fk_product."/photos/"; |
|
| 152 | 152 | $dir = $conf->product->dir_output.'/'.$pdir; |
| 153 | 153 | |
| 154 | - $realpath=''; |
|
| 154 | + $realpath = ''; |
|
| 155 | 155 | |
| 156 | - foreach ($objphoto->liste_photos($dir,1) as $key => $obj) |
|
| 156 | + foreach ($objphoto->liste_photos($dir, 1) as $key => $obj) |
|
| 157 | 157 | { |
| 158 | 158 | if (empty($conf->global->CAT_HIGH_QUALITY_IMAGES)) // If CAT_HIGH_QUALITY_IMAGES not defined, we use thumb if defined and then original photo |
| 159 | 159 | { |
| 160 | 160 | if ($obj['photo_vignette']) |
| 161 | 161 | { |
| 162 | - $filename= $obj['photo_vignette']; |
|
| 162 | + $filename = $obj['photo_vignette']; |
|
| 163 | 163 | } |
| 164 | 164 | else |
| 165 | 165 | { |
| 166 | - $filename=$obj['photo']; |
|
| 166 | + $filename = $obj['photo']; |
|
| 167 | 167 | } |
| 168 | 168 | } |
| 169 | 169 | else |
| 170 | 170 | { |
| 171 | - $filename=$obj['photo']; |
|
| 171 | + $filename = $obj['photo']; |
|
| 172 | 172 | } |
| 173 | 173 | |
| 174 | 174 | $realpath = $dir.$filename; |
| 175 | 175 | break; |
| 176 | 176 | } |
| 177 | 177 | |
| 178 | - if ($realpath) $realpatharray[$i]=$realpath; |
|
| 178 | + if ($realpath) $realpatharray[$i] = $realpath; |
|
| 179 | 179 | } |
| 180 | 180 | } |
| 181 | 181 | |
| 182 | - if (count($realpatharray) == 0) $this->posxpicture=$this->posxweightvol; |
|
| 182 | + if (count($realpatharray) == 0) $this->posxpicture = $this->posxweightvol; |
|
| 183 | 183 | |
| 184 | 184 | if ($conf->expedition->dir_output) |
| 185 | 185 | { |
@@ -187,20 +187,20 @@ discard block |
||
| 187 | 187 | if ($object->specimen) |
| 188 | 188 | { |
| 189 | 189 | $dir = $conf->expedition->dir_output."/sending"; |
| 190 | - $file = $dir . "/SPECIMEN.pdf"; |
|
| 190 | + $file = $dir."/SPECIMEN.pdf"; |
|
| 191 | 191 | } |
| 192 | 192 | else |
| 193 | 193 | { |
| 194 | 194 | $expref = dol_sanitizeFileName($object->ref); |
| 195 | - $dir = $conf->expedition->dir_output."/sending/" . $expref; |
|
| 196 | - $file = $dir . "/" . $expref . ".pdf"; |
|
| 195 | + $dir = $conf->expedition->dir_output."/sending/".$expref; |
|
| 196 | + $file = $dir."/".$expref.".pdf"; |
|
| 197 | 197 | } |
| 198 | 198 | |
| 199 | - if (! file_exists($dir)) |
|
| 199 | + if (!file_exists($dir)) |
|
| 200 | 200 | { |
| 201 | 201 | if (dol_mkdir($dir) < 0) |
| 202 | 202 | { |
| 203 | - $this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir); |
|
| 203 | + $this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir); |
|
| 204 | 204 | return 0; |
| 205 | 205 | } |
| 206 | 206 | } |
@@ -208,25 +208,25 @@ discard block |
||
| 208 | 208 | if (file_exists($dir)) |
| 209 | 209 | { |
| 210 | 210 | // Add pdfgeneration hook |
| 211 | - if (! is_object($hookmanager)) |
|
| 211 | + if (!is_object($hookmanager)) |
|
| 212 | 212 | { |
| 213 | 213 | include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; |
| 214 | - $hookmanager=new HookManager($this->db); |
|
| 214 | + $hookmanager = new HookManager($this->db); |
|
| 215 | 215 | } |
| 216 | 216 | $hookmanager->initHooks(array('pdfgeneration')); |
| 217 | - $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs); |
|
| 217 | + $parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs); |
|
| 218 | 218 | global $action; |
| 219 | - $reshook=$hookmanager->executeHooks('beforePDFCreation',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks |
|
| 219 | + $reshook = $hookmanager->executeHooks('beforePDFCreation', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks |
|
| 220 | 220 | |
| 221 | 221 | // Set nblignes with the new facture lines content after hook |
| 222 | 222 | $nblignes = count($object->lines); |
| 223 | 223 | |
| 224 | - $pdf=pdf_getInstance($this->format); |
|
| 224 | + $pdf = pdf_getInstance($this->format); |
|
| 225 | 225 | $default_font_size = pdf_getPDFFontSize($outputlangs); |
| 226 | - $heightforinfotot = 8; // Height reserved to output the info and total part |
|
| 227 | - $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 |
|
| 228 | - $heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin) |
|
| 229 | - $pdf->SetAutoPageBreak(1,0); |
|
| 226 | + $heightforinfotot = 8; // Height reserved to output the info and total part |
|
| 227 | + $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 |
|
| 228 | + $heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin) |
|
| 229 | + $pdf->SetAutoPageBreak(1, 0); |
|
| 230 | 230 | |
| 231 | 231 | if (class_exists('TCPDF')) |
| 232 | 232 | { |
@@ -235,38 +235,38 @@ discard block |
||
| 235 | 235 | } |
| 236 | 236 | $pdf->SetFont(pdf_getPDFFont($outputlangs)); |
| 237 | 237 | // Set path to the background PDF File |
| 238 | - if (empty($conf->global->MAIN_DISABLE_FPDI) && ! empty($conf->global->MAIN_ADD_PDF_BACKGROUND)) |
|
| 238 | + if (empty($conf->global->MAIN_DISABLE_FPDI) && !empty($conf->global->MAIN_ADD_PDF_BACKGROUND)) |
|
| 239 | 239 | { |
| 240 | 240 | $pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND); |
| 241 | 241 | $tplidx = $pdf->importPage(1); |
| 242 | 242 | } |
| 243 | 243 | |
| 244 | 244 | $pdf->Open(); |
| 245 | - $pagenb=0; |
|
| 246 | - $pdf->SetDrawColor(128,128,128); |
|
| 245 | + $pagenb = 0; |
|
| 246 | + $pdf->SetDrawColor(128, 128, 128); |
|
| 247 | 247 | |
| 248 | - if (method_exists($pdf,'AliasNbPages')) $pdf->AliasNbPages(); |
|
| 248 | + if (method_exists($pdf, 'AliasNbPages')) $pdf->AliasNbPages(); |
|
| 249 | 249 | |
| 250 | 250 | $pdf->SetTitle($outputlangs->convToOutputCharset($object->ref)); |
| 251 | 251 | $pdf->SetSubject($outputlangs->transnoentities("Shipment")); |
| 252 | 252 | $pdf->SetCreator("Dolibarr ".DOL_VERSION); |
| 253 | 253 | $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs))); |
| 254 | 254 | $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("Shipment")); |
| 255 | - if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false); |
|
| 255 | + if (!empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false); |
|
| 256 | 256 | |
| 257 | - $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right |
|
| 257 | + $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right |
|
| 258 | 258 | |
| 259 | 259 | // New page |
| 260 | 260 | $pdf->AddPage(); |
| 261 | - if (! empty($tplidx)) $pdf->useTemplate($tplidx); |
|
| 261 | + if (!empty($tplidx)) $pdf->useTemplate($tplidx); |
|
| 262 | 262 | $pagenb++; |
| 263 | 263 | $this->_pagehead($pdf, $object, 1, $outputlangs); |
| 264 | - $pdf->SetFont('','', $default_font_size - 1); |
|
| 265 | - $pdf->MultiCell(0, 3, ''); // Set interline to 3 |
|
| 266 | - $pdf->SetTextColor(0,0,0); |
|
| 264 | + $pdf->SetFont('', '', $default_font_size - 1); |
|
| 265 | + $pdf->MultiCell(0, 3, ''); // Set interline to 3 |
|
| 266 | + $pdf->SetTextColor(0, 0, 0); |
|
| 267 | 267 | |
| 268 | 268 | $tab_top = 90; |
| 269 | - $tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)?42:10); |
|
| 269 | + $tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD) ? 42 : 10); |
|
| 270 | 270 | $tab_height = 130; |
| 271 | 271 | $tab_height_newpage = 150; |
| 272 | 272 | |
@@ -279,52 +279,52 @@ discard block |
||
| 279 | 279 | { |
| 280 | 280 | $tab_top = 88; |
| 281 | 281 | |
| 282 | - $pdf->SetFont('','', $default_font_size - 1); |
|
| 283 | - $pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top-1, dol_htmlentitiesbr($desc_incoterms), 0, 1); |
|
| 282 | + $pdf->SetFont('', '', $default_font_size - 1); |
|
| 283 | + $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top - 1, dol_htmlentitiesbr($desc_incoterms), 0, 1); |
|
| 284 | 284 | $nexY = $pdf->GetY(); |
| 285 | - $height_incoterms=$nexY-$tab_top; |
|
| 285 | + $height_incoterms = $nexY - $tab_top; |
|
| 286 | 286 | |
| 287 | 287 | // Rect prend une longueur en 3eme param |
| 288 | - $pdf->SetDrawColor(192,192,192); |
|
| 289 | - $pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_incoterms+1); |
|
| 288 | + $pdf->SetDrawColor(192, 192, 192); |
|
| 289 | + $pdf->Rect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_incoterms + 1); |
|
| 290 | 290 | |
| 291 | - $tab_top = $nexY+6; |
|
| 291 | + $tab_top = $nexY + 6; |
|
| 292 | 292 | $height_incoterms += 4; |
| 293 | 293 | } |
| 294 | 294 | } |
| 295 | 295 | |
| 296 | - if (! empty($object->note_public) || ! empty($object->tracking_number)) |
|
| 296 | + if (!empty($object->note_public) || !empty($object->tracking_number)) |
|
| 297 | 297 | { |
| 298 | 298 | $tab_top = 88 + $height_incoterms; |
| 299 | 299 | $tab_top_alt = $tab_top; |
| 300 | 300 | |
| 301 | - $pdf->SetFont('','B', $default_font_size - 2); |
|
| 302 | - $pdf->writeHTMLCell(60, 4, $this->posxdesc-1, $tab_top-1, $outputlangs->transnoentities("TrackingNumber")." : " . $object->tracking_number, 0, 1, false, true, 'L'); |
|
| 301 | + $pdf->SetFont('', 'B', $default_font_size - 2); |
|
| 302 | + $pdf->writeHTMLCell(60, 4, $this->posxdesc - 1, $tab_top - 1, $outputlangs->transnoentities("TrackingNumber")." : ".$object->tracking_number, 0, 1, false, true, 'L'); |
|
| 303 | 303 | |
| 304 | 304 | $tab_top_alt = $pdf->GetY(); |
| 305 | 305 | //$tab_top_alt += 1; |
| 306 | 306 | |
| 307 | 307 | // Tracking number |
| 308 | - if (! empty($object->tracking_number)) |
|
| 308 | + if (!empty($object->tracking_number)) |
|
| 309 | 309 | { |
| 310 | 310 | $object->GetUrlTrackingStatus($object->tracking_number); |
| 311 | - if (! empty($object->tracking_url)) |
|
| 311 | + if (!empty($object->tracking_url)) |
|
| 312 | 312 | { |
| 313 | 313 | if ($object->shipping_method_id > 0) |
| 314 | 314 | { |
| 315 | 315 | // Get code using getLabelFromKey |
| 316 | - $code=$outputlangs->getLabelFromKey($this->db,$object->shipping_method_id,'c_shipment_mode','rowid','code'); |
|
| 317 | - $label=''; |
|
| 318 | - if ($object->tracking_url != $object->tracking_number) $label.=$outputlangs->trans("LinkToTrackYourPackage")."<br>"; |
|
| 319 | - $label.=$outputlangs->trans("SendingMethod").": ".$outputlangs->trans("SendingMethod".strtoupper($code)); |
|
| 316 | + $code = $outputlangs->getLabelFromKey($this->db, $object->shipping_method_id, 'c_shipment_mode', 'rowid', 'code'); |
|
| 317 | + $label = ''; |
|
| 318 | + if ($object->tracking_url != $object->tracking_number) $label .= $outputlangs->trans("LinkToTrackYourPackage")."<br>"; |
|
| 319 | + $label .= $outputlangs->trans("SendingMethod").": ".$outputlangs->trans("SendingMethod".strtoupper($code)); |
|
| 320 | 320 | //var_dump($object->tracking_url != $object->tracking_number);exit; |
| 321 | 321 | if ($object->tracking_url != $object->tracking_number) |
| 322 | 322 | { |
| 323 | - $label.=" : "; |
|
| 324 | - $label.=$object->tracking_url; |
|
| 323 | + $label .= " : "; |
|
| 324 | + $label .= $object->tracking_url; |
|
| 325 | 325 | } |
| 326 | - $pdf->SetFont('','B', $default_font_size - 2); |
|
| 327 | - $pdf->writeHTMLCell(60, 4, $this->posxdesc-1, $tab_top_alt, $label, 0, 1, false, true, 'L'); |
|
| 326 | + $pdf->SetFont('', 'B', $default_font_size - 2); |
|
| 327 | + $pdf->writeHTMLCell(60, 4, $this->posxdesc - 1, $tab_top_alt, $label, 0, 1, false, true, 'L'); |
|
| 328 | 328 | |
| 329 | 329 | $tab_top_alt = $pdf->GetY(); |
| 330 | 330 | } |
@@ -332,25 +332,25 @@ discard block |
||
| 332 | 332 | } |
| 333 | 333 | |
| 334 | 334 | // Notes |
| 335 | - if (! empty($object->note_public)) |
|
| 335 | + if (!empty($object->note_public)) |
|
| 336 | 336 | { |
| 337 | - $pdf->SetFont('','', $default_font_size - 1); // Dans boucle pour gerer multi-page |
|
| 338 | - $pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top_alt, dol_htmlentitiesbr($object->note_public), 0, 1); |
|
| 337 | + $pdf->SetFont('', '', $default_font_size - 1); // Dans boucle pour gerer multi-page |
|
| 338 | + $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top_alt, dol_htmlentitiesbr($object->note_public), 0, 1); |
|
| 339 | 339 | } |
| 340 | 340 | |
| 341 | 341 | $nexY = $pdf->GetY(); |
| 342 | - $height_note=$nexY-$tab_top; |
|
| 342 | + $height_note = $nexY - $tab_top; |
|
| 343 | 343 | |
| 344 | 344 | // Rect prend une longueur en 3eme param |
| 345 | - $pdf->SetDrawColor(192,192,192); |
|
| 346 | - $pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_note+1); |
|
| 345 | + $pdf->SetDrawColor(192, 192, 192); |
|
| 346 | + $pdf->Rect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_note + 1); |
|
| 347 | 347 | |
| 348 | 348 | $tab_height = $tab_height - $height_note; |
| 349 | - $tab_top = $nexY+6; |
|
| 349 | + $tab_top = $nexY + 6; |
|
| 350 | 350 | } |
| 351 | 351 | else |
| 352 | 352 | { |
| 353 | - $height_note=0; |
|
| 353 | + $height_note = 0; |
|
| 354 | 354 | } |
| 355 | 355 | |
| 356 | 356 | $iniY = $tab_top + 7; |
@@ -361,87 +361,87 @@ discard block |
||
| 361 | 361 | for ($i = 0; $i < $nblignes; $i++) |
| 362 | 362 | { |
| 363 | 363 | $curY = $nexY; |
| 364 | - $pdf->SetFont('','', $default_font_size - 1); // Into loop to work with multipage |
|
| 365 | - $pdf->SetTextColor(0,0,0); |
|
| 364 | + $pdf->SetFont('', '', $default_font_size - 1); // Into loop to work with multipage |
|
| 365 | + $pdf->SetTextColor(0, 0, 0); |
|
| 366 | 366 | |
| 367 | 367 | // Define size of image if we need it |
| 368 | - $imglinesize=array(); |
|
| 369 | - if (! empty($realpatharray[$i])) $imglinesize=pdf_getSizeForImage($realpatharray[$i]); |
|
| 368 | + $imglinesize = array(); |
|
| 369 | + if (!empty($realpatharray[$i])) $imglinesize = pdf_getSizeForImage($realpatharray[$i]); |
|
| 370 | 370 | |
| 371 | 371 | $pdf->setTopMargin($tab_top_newpage); |
| 372 | - $pdf->setPageOrientation('', 1, $heightforfooter+$heightforfreetext+$heightforinfotot); // The only function to edit the bottom margin of current page to set it. |
|
| 373 | - $pageposbefore=$pdf->getPage(); |
|
| 372 | + $pdf->setPageOrientation('', 1, $heightforfooter + $heightforfreetext + $heightforinfotot); // The only function to edit the bottom margin of current page to set it. |
|
| 373 | + $pageposbefore = $pdf->getPage(); |
|
| 374 | 374 | |
| 375 | - $showpricebeforepagebreak=1; |
|
| 376 | - $posYAfterImage=0; |
|
| 377 | - $posYAfterDescription=0; |
|
| 375 | + $showpricebeforepagebreak = 1; |
|
| 376 | + $posYAfterImage = 0; |
|
| 377 | + $posYAfterDescription = 0; |
|
| 378 | 378 | |
| 379 | 379 | // We start with Photo of product line |
| 380 | - 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 | + 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 |
|
| 381 | 381 | { |
| 382 | - $pdf->AddPage('','',true); |
|
| 383 | - if (! empty($tplidx)) $pdf->useTemplate($tplidx); |
|
| 382 | + $pdf->AddPage('', '', true); |
|
| 383 | + if (!empty($tplidx)) $pdf->useTemplate($tplidx); |
|
| 384 | 384 | if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); |
| 385 | - $pdf->setPage($pageposbefore+1); |
|
| 385 | + $pdf->setPage($pageposbefore + 1); |
|
| 386 | 386 | |
| 387 | 387 | $curY = $tab_top_newpage; |
| 388 | - $showpricebeforepagebreak=0; |
|
| 388 | + $showpricebeforepagebreak = 0; |
|
| 389 | 389 | } |
| 390 | 390 | |
| 391 | 391 | if (isset($imglinesize['width']) && isset($imglinesize['height'])) |
| 392 | 392 | { |
| 393 | - $curX = $this->posxpicture-1; |
|
| 394 | - $pdf->Image($realpatharray[$i], $curX + (($this->posxweightvol-$this->posxpicture-$imglinesize['width'])/2), $curY, $imglinesize['width'], $imglinesize['height'], '', '', '', 2, 300); // Use 300 dpi |
|
| 393 | + $curX = $this->posxpicture - 1; |
|
| 394 | + $pdf->Image($realpatharray[$i], $curX + (($this->posxweightvol - $this->posxpicture - $imglinesize['width']) / 2), $curY, $imglinesize['width'], $imglinesize['height'], '', '', '', 2, 300); // Use 300 dpi |
|
| 395 | 395 | // $pdf->Image does not increase value return by getY, so we save it manually |
| 396 | - $posYAfterImage=$curY+$imglinesize['height']; |
|
| 396 | + $posYAfterImage = $curY + $imglinesize['height']; |
|
| 397 | 397 | } |
| 398 | 398 | |
| 399 | 399 | // Description of product line |
| 400 | - $curX = $this->posxdesc-1; |
|
| 400 | + $curX = $this->posxdesc - 1; |
|
| 401 | 401 | |
| 402 | 402 | $pdf->startTransaction(); |
| 403 | - pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->posxpicture-$curX,3,$curX,$curY,$hideref,$hidedesc); |
|
| 403 | + pdf_writelinedesc($pdf, $object, $i, $outputlangs, $this->posxpicture - $curX, 3, $curX, $curY, $hideref, $hidedesc); |
|
| 404 | 404 | |
| 405 | - $pageposafter=$pdf->getPage(); |
|
| 405 | + $pageposafter = $pdf->getPage(); |
|
| 406 | 406 | if ($pageposafter > $pageposbefore) // There is a pagebreak |
| 407 | 407 | { |
| 408 | 408 | $pdf->rollbackTransaction(true); |
| 409 | - $pageposafter=$pageposbefore; |
|
| 409 | + $pageposafter = $pageposbefore; |
|
| 410 | 410 | //print $pageposafter.'-'.$pageposbefore;exit; |
| 411 | - $pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it. |
|
| 412 | - pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->posxpicture-$curX,3,$curX,$curY,$hideref,$hidedesc); |
|
| 411 | + $pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it. |
|
| 412 | + pdf_writelinedesc($pdf, $object, $i, $outputlangs, $this->posxpicture - $curX, 3, $curX, $curY, $hideref, $hidedesc); |
|
| 413 | 413 | |
| 414 | - $pageposafter=$pdf->getPage(); |
|
| 415 | - $posyafter=$pdf->GetY(); |
|
| 414 | + $pageposafter = $pdf->getPage(); |
|
| 415 | + $posyafter = $pdf->GetY(); |
|
| 416 | 416 | //var_dump($posyafter); var_dump(($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))); exit; |
| 417 | - if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))) // There is no space left for total+free text |
|
| 417 | + if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) // There is no space left for total+free text |
|
| 418 | 418 | { |
| 419 | - if ($i == ($nblignes-1)) // No more lines, and no space left to show total, so we create a new page |
|
| 419 | + if ($i == ($nblignes - 1)) // No more lines, and no space left to show total, so we create a new page |
|
| 420 | 420 | { |
| 421 | - $pdf->AddPage('','',true); |
|
| 422 | - if (! empty($tplidx)) $pdf->useTemplate($tplidx); |
|
| 421 | + $pdf->AddPage('', '', true); |
|
| 422 | + if (!empty($tplidx)) $pdf->useTemplate($tplidx); |
|
| 423 | 423 | if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); |
| 424 | - $pdf->setPage($pageposafter+1); |
|
| 424 | + $pdf->setPage($pageposafter + 1); |
|
| 425 | 425 | } |
| 426 | 426 | } |
| 427 | 427 | else |
| 428 | 428 | { |
| 429 | 429 | // We found a page break |
| 430 | - $showpricebeforepagebreak=0; |
|
| 430 | + $showpricebeforepagebreak = 0; |
|
| 431 | 431 | } |
| 432 | 432 | } |
| 433 | 433 | else // No pagebreak |
| 434 | 434 | { |
| 435 | 435 | $pdf->commitTransaction(); |
| 436 | 436 | } |
| 437 | - $posYAfterDescription=$pdf->GetY(); |
|
| 437 | + $posYAfterDescription = $pdf->GetY(); |
|
| 438 | 438 | |
| 439 | 439 | $nexY = $pdf->GetY(); |
| 440 | - $pageposafter=$pdf->getPage(); |
|
| 440 | + $pageposafter = $pdf->getPage(); |
|
| 441 | 441 | |
| 442 | 442 | $pdf->setPage($pageposbefore); |
| 443 | 443 | $pdf->setTopMargin($this->marge_haute); |
| 444 | - $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. |
|
| 444 | + $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. |
|
| 445 | 445 | |
| 446 | 446 | // We suppose that a too long description or photo were moved completely on next page |
| 447 | 447 | if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) { |
@@ -453,51 +453,51 @@ discard block |
||
| 453 | 453 | $pdf->setPage($pageposafter); $curY = $tab_top_newpage; |
| 454 | 454 | } |
| 455 | 455 | |
| 456 | - $pdf->SetFont('','', $default_font_size - 1); // On repositionne la police par defaut |
|
| 456 | + $pdf->SetFont('', '', $default_font_size - 1); // On repositionne la police par defaut |
|
| 457 | 457 | |
| 458 | 458 | $pdf->SetXY($this->posxweightvol, $curY); |
| 459 | - $weighttxt=''; |
|
| 459 | + $weighttxt = ''; |
|
| 460 | 460 | if ($object->lines[$i]->fk_product_type == 0 && $object->lines[$i]->weight) |
| 461 | 461 | { |
| 462 | - $weighttxt=round($object->lines[$i]->weight * $object->lines[$i]->qty_shipped, 5).' '.measuring_units_string($object->lines[$i]->weight_units,"weight"); |
|
| 462 | + $weighttxt = round($object->lines[$i]->weight * $object->lines[$i]->qty_shipped, 5).' '.measuring_units_string($object->lines[$i]->weight_units, "weight"); |
|
| 463 | 463 | } |
| 464 | - $voltxt=''; |
|
| 464 | + $voltxt = ''; |
|
| 465 | 465 | if ($object->lines[$i]->fk_product_type == 0 && $object->lines[$i]->volume) |
| 466 | 466 | { |
| 467 | - $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 | + $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"); |
|
| 468 | 468 | } |
| 469 | 469 | |
| 470 | - $pdf->writeHTMLCell($this->posxqtyordered - $this->posxweightvol + 2, 3, $this->posxweightvol - 1, $curY, $weighttxt.(($weighttxt && $voltxt)?'<br>':'').$voltxt, 0, 0, false, true, 'C'); |
|
| 470 | + $pdf->writeHTMLCell($this->posxqtyordered - $this->posxweightvol + 2, 3, $this->posxweightvol - 1, $curY, $weighttxt.(($weighttxt && $voltxt) ? '<br>' : '').$voltxt, 0, 0, false, true, 'C'); |
|
| 471 | 471 | //$pdf->MultiCell(($this->posxqtyordered - $this->posxweightvol), 3, $weighttxt.(($weighttxt && $voltxt)?'<br>':'').$voltxt,'','C'); |
| 472 | 472 | |
| 473 | 473 | if (empty($conf->global->SHIPPING_PDF_HIDE_ORDERED)) |
| 474 | 474 | { |
| 475 | 475 | $pdf->SetXY($this->posxqtyordered, $curY); |
| 476 | - $pdf->MultiCell(($this->posxqtytoship - $this->posxqtyordered), 3, $object->lines[$i]->qty_asked,'','C'); |
|
| 476 | + $pdf->MultiCell(($this->posxqtytoship - $this->posxqtyordered), 3, $object->lines[$i]->qty_asked, '', 'C'); |
|
| 477 | 477 | } |
| 478 | 478 | |
| 479 | 479 | $pdf->SetXY($this->posxqtytoship, $curY); |
| 480 | - $pdf->MultiCell(($this->posxpuht - $this->posxqtytoship), 3, $object->lines[$i]->qty_shipped,'','C'); |
|
| 480 | + $pdf->MultiCell(($this->posxpuht - $this->posxqtytoship), 3, $object->lines[$i]->qty_shipped, '', 'C'); |
|
| 481 | 481 | |
| 482 | - if(!empty($conf->global->MAIN_PDF_SHIPPING_DISPLAY_AMOUNT_HT)) |
|
| 482 | + if (!empty($conf->global->MAIN_PDF_SHIPPING_DISPLAY_AMOUNT_HT)) |
|
| 483 | 483 | { |
| 484 | 484 | $pdf->SetXY($this->posxpuht, $curY); |
| 485 | - $pdf->MultiCell(($this->posxtotalht - $this->posxpuht-1), 3, price($object->lines[$i]->subprice, 0, $outputlangs),'','R'); |
|
| 485 | + $pdf->MultiCell(($this->posxtotalht - $this->posxpuht - 1), 3, price($object->lines[$i]->subprice, 0, $outputlangs), '', 'R'); |
|
| 486 | 486 | |
| 487 | 487 | $pdf->SetXY($this->posxtotalht, $curY); |
| 488 | - $pdf->MultiCell(($this->page_largeur - $this->marge_droite - $this->posxtotalht), 3, price($object->lines[$i]->total_ht, 0, $outputlangs),'','R'); |
|
| 488 | + $pdf->MultiCell(($this->page_largeur - $this->marge_droite - $this->posxtotalht), 3, price($object->lines[$i]->total_ht, 0, $outputlangs), '', 'R'); |
|
| 489 | 489 | } |
| 490 | 490 | |
| 491 | - $nexY+=3; |
|
| 492 | - if ($weighttxt && $voltxt) $nexY+=2; |
|
| 491 | + $nexY += 3; |
|
| 492 | + if ($weighttxt && $voltxt) $nexY += 2; |
|
| 493 | 493 | |
| 494 | 494 | // Add line |
| 495 | - if (! empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblignes - 1)) |
|
| 495 | + if (!empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblignes - 1)) |
|
| 496 | 496 | { |
| 497 | 497 | $pdf->setPage($pageposafter); |
| 498 | - $pdf->SetLineStyle(array('dash'=>'1,1','color'=>array(80,80,80))); |
|
| 498 | + $pdf->SetLineStyle(array('dash'=>'1,1', 'color'=>array(80, 80, 80))); |
|
| 499 | 499 | //$pdf->SetDrawColor(190,190,200); |
| 500 | - $pdf->line($this->marge_gauche, $nexY-1, $this->page_largeur - $this->marge_droite, $nexY-1); |
|
| 500 | + $pdf->line($this->marge_gauche, $nexY - 1, $this->page_largeur - $this->marge_droite, $nexY - 1); |
|
| 501 | 501 | $pdf->SetLineStyle(array('dash'=>0)); |
| 502 | 502 | } |
| 503 | 503 | |
@@ -513,13 +513,13 @@ discard block |
||
| 513 | 513 | { |
| 514 | 514 | $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1); |
| 515 | 515 | } |
| 516 | - $this->_pagefoot($pdf,$object,$outputlangs,1); |
|
| 516 | + $this->_pagefoot($pdf, $object, $outputlangs, 1); |
|
| 517 | 517 | $pagenb++; |
| 518 | 518 | $pdf->setPage($pagenb); |
| 519 | - $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. |
|
| 519 | + $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. |
|
| 520 | 520 | if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); |
| 521 | 521 | } |
| 522 | - if (isset($object->lines[$i+1]->pagebreak) && $object->lines[$i+1]->pagebreak) |
|
| 522 | + if (isset($object->lines[$i + 1]->pagebreak) && $object->lines[$i + 1]->pagebreak) |
|
| 523 | 523 | { |
| 524 | 524 | if ($pagenb == 1) |
| 525 | 525 | { |
@@ -529,10 +529,10 @@ discard block |
||
| 529 | 529 | { |
| 530 | 530 | $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1); |
| 531 | 531 | } |
| 532 | - $this->_pagefoot($pdf,$object,$outputlangs,1); |
|
| 532 | + $this->_pagefoot($pdf, $object, $outputlangs, 1); |
|
| 533 | 533 | // New page |
| 534 | 534 | $pdf->AddPage(); |
| 535 | - if (! empty($tplidx)) $pdf->useTemplate($tplidx); |
|
| 535 | + if (!empty($tplidx)) $pdf->useTemplate($tplidx); |
|
| 536 | 536 | $pagenb++; |
| 537 | 537 | if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); |
| 538 | 538 | } |
@@ -542,47 +542,47 @@ discard block |
||
| 542 | 542 | if ($pagenb == 1) |
| 543 | 543 | { |
| 544 | 544 | $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0); |
| 545 | - $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; |
|
| 545 | + $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; |
|
| 546 | 546 | } |
| 547 | 547 | else |
| 548 | 548 | { |
| 549 | 549 | $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0); |
| 550 | - $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; |
|
| 550 | + $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; |
|
| 551 | 551 | } |
| 552 | 552 | |
| 553 | 553 | // Affiche zone totaux |
| 554 | - $posy=$this->_tableau_tot($pdf, $object, 0, $bottomlasttab, $outputlangs); |
|
| 554 | + $posy = $this->_tableau_tot($pdf, $object, 0, $bottomlasttab, $outputlangs); |
|
| 555 | 555 | |
| 556 | 556 | // Pied de page |
| 557 | - $this->_pagefoot($pdf,$object,$outputlangs); |
|
| 558 | - if (method_exists($pdf,'AliasNbPages')) $pdf->AliasNbPages(); |
|
| 557 | + $this->_pagefoot($pdf, $object, $outputlangs); |
|
| 558 | + if (method_exists($pdf, 'AliasNbPages')) $pdf->AliasNbPages(); |
|
| 559 | 559 | |
| 560 | 560 | $pdf->Close(); |
| 561 | 561 | |
| 562 | - $pdf->Output($file,'F'); |
|
| 562 | + $pdf->Output($file, 'F'); |
|
| 563 | 563 | |
| 564 | 564 | // Add pdfgeneration hook |
| 565 | 565 | $hookmanager->initHooks(array('pdfgeneration')); |
| 566 | - $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs); |
|
| 566 | + $parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs); |
|
| 567 | 567 | global $action; |
| 568 | - $reshook=$hookmanager->executeHooks('afterPDFCreation',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks |
|
| 568 | + $reshook = $hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks |
|
| 569 | 569 | |
| 570 | - if (! empty($conf->global->MAIN_UMASK)) |
|
| 570 | + if (!empty($conf->global->MAIN_UMASK)) |
|
| 571 | 571 | @chmod($file, octdec($conf->global->MAIN_UMASK)); |
| 572 | 572 | |
| 573 | 573 | $this->result = array('fullpath'=>$file); |
| 574 | 574 | |
| 575 | - return 1; // No error |
|
| 575 | + return 1; // No error |
|
| 576 | 576 | } |
| 577 | 577 | else |
| 578 | 578 | { |
| 579 | - $this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir); |
|
| 579 | + $this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir); |
|
| 580 | 580 | return 0; |
| 581 | 581 | } |
| 582 | 582 | } |
| 583 | 583 | else |
| 584 | 584 | { |
| 585 | - $this->error=$langs->transnoentities("ErrorConstantNotDefined","EXP_OUTPUTDIR"); |
|
| 585 | + $this->error = $langs->transnoentities("ErrorConstantNotDefined", "EXP_OUTPUTDIR"); |
|
| 586 | 586 | return 0; |
| 587 | 587 | } |
| 588 | 588 | } |
@@ -599,18 +599,18 @@ discard block |
||
| 599 | 599 | */ |
| 600 | 600 | function _tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs) |
| 601 | 601 | { |
| 602 | - global $conf,$mysoc; |
|
| 602 | + global $conf, $mysoc; |
|
| 603 | 603 | |
| 604 | - $sign=1; |
|
| 604 | + $sign = 1; |
|
| 605 | 605 | |
| 606 | 606 | $default_font_size = pdf_getPDFFontSize($outputlangs); |
| 607 | 607 | |
| 608 | 608 | $tab2_top = $posy; |
| 609 | 609 | $tab2_hl = 4; |
| 610 | - $pdf->SetFont('','B', $default_font_size - 1); |
|
| 610 | + $pdf->SetFont('', 'B', $default_font_size - 1); |
|
| 611 | 611 | |
| 612 | 612 | // Tableau total |
| 613 | - $col1x = $this->posxweightvol-50; $col2x = $this->posxweightvol; |
|
| 613 | + $col1x = $this->posxweightvol - 50; $col2x = $this->posxweightvol; |
|
| 614 | 614 | /*if ($this->page_largeur < 210) // To work with US executive format |
| 615 | 615 | { |
| 616 | 616 | $col2x-=20; |
@@ -618,33 +618,33 @@ discard block |
||
| 618 | 618 | if (empty($conf->global->SHIPPING_PDF_HIDE_ORDERED)) $largcol2 = ($this->posxqtyordered - $this->posxweightvol); |
| 619 | 619 | else $largcol2 = ($this->posxqtytoship - $this->posxweightvol); |
| 620 | 620 | |
| 621 | - $useborder=0; |
|
| 621 | + $useborder = 0; |
|
| 622 | 622 | $index = 0; |
| 623 | 623 | |
| 624 | - $totalWeighttoshow=''; |
|
| 625 | - $totalVolumetoshow=''; |
|
| 624 | + $totalWeighttoshow = ''; |
|
| 625 | + $totalVolumetoshow = ''; |
|
| 626 | 626 | |
| 627 | 627 | // Load dim data |
| 628 | - $tmparray=$object->getTotalWeightVolume(); |
|
| 629 | - $totalWeight=$tmparray['weight']; |
|
| 630 | - $totalVolume=$tmparray['volume']; |
|
| 631 | - $totalOrdered=$tmparray['ordered']; |
|
| 632 | - $totalToShip=$tmparray['toship']; |
|
| 628 | + $tmparray = $object->getTotalWeightVolume(); |
|
| 629 | + $totalWeight = $tmparray['weight']; |
|
| 630 | + $totalVolume = $tmparray['volume']; |
|
| 631 | + $totalOrdered = $tmparray['ordered']; |
|
| 632 | + $totalToShip = $tmparray['toship']; |
|
| 633 | 633 | // Set trueVolume and volume_units not currently stored into database |
| 634 | 634 | if ($object->trueWidth && $object->trueHeight && $object->trueDepth) |
| 635 | 635 | { |
| 636 | - $object->trueVolume=price(($object->trueWidth * $object->trueHeight * $object->trueDepth), 0, $outputlangs, 0, 0); |
|
| 637 | - $object->volume_units=$object->size_units * 3; |
|
| 636 | + $object->trueVolume = price(($object->trueWidth * $object->trueHeight * $object->trueDepth), 0, $outputlangs, 0, 0); |
|
| 637 | + $object->volume_units = $object->size_units * 3; |
|
| 638 | 638 | } |
| 639 | 639 | |
| 640 | - if ($totalWeight!='') $totalWeighttoshow=showDimensionInBestUnit($totalWeight, 0, "weight", $outputlangs); |
|
| 641 | - if ($totalVolume!='') $totalVolumetoshow=showDimensionInBestUnit($totalVolume, 0, "volume", $outputlangs); |
|
| 642 | - if ($object->trueWeight) $totalWeighttoshow=showDimensionInBestUnit($object->trueWeight, $object->weight_units, "weight", $outputlangs); |
|
| 643 | - if ($object->trueVolume) $totalVolumetoshow=showDimensionInBestUnit($object->trueVolume, $object->volume_units, "volume", $outputlangs); |
|
| 640 | + if ($totalWeight != '') $totalWeighttoshow = showDimensionInBestUnit($totalWeight, 0, "weight", $outputlangs); |
|
| 641 | + if ($totalVolume != '') $totalVolumetoshow = showDimensionInBestUnit($totalVolume, 0, "volume", $outputlangs); |
|
| 642 | + if ($object->trueWeight) $totalWeighttoshow = showDimensionInBestUnit($object->trueWeight, $object->weight_units, "weight", $outputlangs); |
|
| 643 | + if ($object->trueVolume) $totalVolumetoshow = showDimensionInBestUnit($object->trueVolume, $object->volume_units, "volume", $outputlangs); |
|
| 644 | 644 | |
| 645 | - $pdf->SetFillColor(255,255,255); |
|
| 645 | + $pdf->SetFillColor(255, 255, 255); |
|
| 646 | 646 | $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); |
| 647 | - $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("Total"), 0, 'L', 1); |
|
| 647 | + $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("Total"), 0, 'L', 1); |
|
| 648 | 648 | |
| 649 | 649 | if (empty($conf->global->SHIPPING_PDF_HIDE_ORDERED)) |
| 650 | 650 | { |
@@ -655,7 +655,7 @@ discard block |
||
| 655 | 655 | $pdf->SetXY($this->posxqtytoship, $tab2_top + $tab2_hl * $index); |
| 656 | 656 | $pdf->MultiCell($this->posxpuht - $this->posxqtytoship, $tab2_hl, $totalToShip, 0, 'C', 1); |
| 657 | 657 | |
| 658 | - if(!empty($conf->global->MAIN_PDF_SHIPPING_DISPLAY_AMOUNT_HT)) { |
|
| 658 | + if (!empty($conf->global->MAIN_PDF_SHIPPING_DISPLAY_AMOUNT_HT)) { |
|
| 659 | 659 | |
| 660 | 660 | $pdf->SetXY($this->posxpuht, $tab2_top + $tab2_hl * $index); |
| 661 | 661 | $pdf->MultiCell($this->posxtotalht - $this->posxpuht, $tab2_hl, '', 0, 'C', 1); |
@@ -680,9 +680,9 @@ discard block |
||
| 680 | 680 | |
| 681 | 681 | $index++; |
| 682 | 682 | } |
| 683 | - if (! $totalWeighttoshow && ! $totalVolumetoshow) $index++; |
|
| 683 | + if (!$totalWeighttoshow && !$totalVolumetoshow) $index++; |
|
| 684 | 684 | |
| 685 | - $pdf->SetTextColor(0,0,0); |
|
| 685 | + $pdf->SetTextColor(0, 0, 0); |
|
| 686 | 686 | |
| 687 | 687 | return ($tab2_top + ($tab2_hl * $index)); |
| 688 | 688 | } |
@@ -699,72 +699,72 @@ discard block |
||
| 699 | 699 | * @param int $hidebottom Hide bottom bar of array |
| 700 | 700 | * @return void |
| 701 | 701 | */ |
| 702 | - function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop=0, $hidebottom=0) |
|
| 702 | + function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0) |
|
| 703 | 703 | { |
| 704 | 704 | global $conf; |
| 705 | 705 | |
| 706 | 706 | // Force to disable hidetop and hidebottom |
| 707 | - $hidebottom=0; |
|
| 708 | - if ($hidetop) $hidetop=-1; |
|
| 707 | + $hidebottom = 0; |
|
| 708 | + if ($hidetop) $hidetop = -1; |
|
| 709 | 709 | |
| 710 | 710 | $default_font_size = pdf_getPDFFontSize($outputlangs); |
| 711 | 711 | |
| 712 | 712 | // Amount in (at tab_top - 1) |
| 713 | - $pdf->SetTextColor(0,0,0); |
|
| 714 | - $pdf->SetFont('','',$default_font_size - 2); |
|
| 713 | + $pdf->SetTextColor(0, 0, 0); |
|
| 714 | + $pdf->SetFont('', '', $default_font_size - 2); |
|
| 715 | 715 | |
| 716 | 716 | // Output Rect |
| 717 | - $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 |
|
| 717 | + $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 |
|
| 718 | 718 | |
| 719 | - $pdf->SetDrawColor(128,128,128); |
|
| 720 | - $pdf->SetFont('','', $default_font_size - 1); |
|
| 719 | + $pdf->SetDrawColor(128, 128, 128); |
|
| 720 | + $pdf->SetFont('', '', $default_font_size - 1); |
|
| 721 | 721 | |
| 722 | 722 | if (empty($hidetop)) |
| 723 | 723 | { |
| 724 | - $pdf->line($this->marge_gauche, $tab_top+5, $this->page_largeur-$this->marge_droite, $tab_top+5); |
|
| 724 | + $pdf->line($this->marge_gauche, $tab_top + 5, $this->page_largeur - $this->marge_droite, $tab_top + 5); |
|
| 725 | 725 | |
| 726 | - $pdf->SetXY($this->posxdesc-1, $tab_top+1); |
|
| 726 | + $pdf->SetXY($this->posxdesc - 1, $tab_top + 1); |
|
| 727 | 727 | $pdf->MultiCell($this->posxqtyordered - $this->posxdesc, 2, $outputlangs->transnoentities("Description"), '', 'L'); |
| 728 | 728 | } |
| 729 | 729 | |
| 730 | - $pdf->line($this->posxweightvol-1, $tab_top, $this->posxweightvol-1, $tab_top + $tab_height); |
|
| 730 | + $pdf->line($this->posxweightvol - 1, $tab_top, $this->posxweightvol - 1, $tab_top + $tab_height); |
|
| 731 | 731 | if (empty($hidetop)) |
| 732 | 732 | { |
| 733 | - $pdf->SetXY($this->posxweightvol-1, $tab_top+1); |
|
| 734 | - $pdf->MultiCell(($this->posxqtyordered - $this->posxweightvol), 2, $outputlangs->transnoentities("WeightVolShort"),'','C'); |
|
| 733 | + $pdf->SetXY($this->posxweightvol - 1, $tab_top + 1); |
|
| 734 | + $pdf->MultiCell(($this->posxqtyordered - $this->posxweightvol), 2, $outputlangs->transnoentities("WeightVolShort"), '', 'C'); |
|
| 735 | 735 | } |
| 736 | 736 | |
| 737 | 737 | if (empty($conf->global->SHIPPING_PDF_HIDE_ORDERED)) |
| 738 | 738 | { |
| 739 | - $pdf->line($this->posxqtyordered-1, $tab_top, $this->posxqtyordered-1, $tab_top + $tab_height); |
|
| 739 | + $pdf->line($this->posxqtyordered - 1, $tab_top, $this->posxqtyordered - 1, $tab_top + $tab_height); |
|
| 740 | 740 | if (empty($hidetop)) |
| 741 | 741 | { |
| 742 | - $pdf->SetXY($this->posxqtyordered-1, $tab_top+1); |
|
| 743 | - $pdf->MultiCell(($this->posxqtytoship - $this->posxqtyordered), 2, $outputlangs->transnoentities("QtyOrdered"),'','C'); |
|
| 742 | + $pdf->SetXY($this->posxqtyordered - 1, $tab_top + 1); |
|
| 743 | + $pdf->MultiCell(($this->posxqtytoship - $this->posxqtyordered), 2, $outputlangs->transnoentities("QtyOrdered"), '', 'C'); |
|
| 744 | 744 | } |
| 745 | 745 | } |
| 746 | 746 | |
| 747 | - $pdf->line($this->posxqtytoship-1, $tab_top, $this->posxqtytoship-1, $tab_top + $tab_height); |
|
| 747 | + $pdf->line($this->posxqtytoship - 1, $tab_top, $this->posxqtytoship - 1, $tab_top + $tab_height); |
|
| 748 | 748 | if (empty($hidetop)) |
| 749 | 749 | { |
| 750 | - $pdf->SetXY($this->posxqtytoship, $tab_top+1); |
|
| 751 | - $pdf->MultiCell(($this->posxpuht - $this->posxqtytoship), 2, $outputlangs->transnoentities("QtyToShip"),'','C'); |
|
| 750 | + $pdf->SetXY($this->posxqtytoship, $tab_top + 1); |
|
| 751 | + $pdf->MultiCell(($this->posxpuht - $this->posxqtytoship), 2, $outputlangs->transnoentities("QtyToShip"), '', 'C'); |
|
| 752 | 752 | } |
| 753 | 753 | |
| 754 | - if(!empty($conf->global->MAIN_PDF_SHIPPING_DISPLAY_AMOUNT_HT)) { |
|
| 754 | + if (!empty($conf->global->MAIN_PDF_SHIPPING_DISPLAY_AMOUNT_HT)) { |
|
| 755 | 755 | |
| 756 | - $pdf->line($this->posxpuht-1, $tab_top, $this->posxpuht-1, $tab_top + $tab_height); |
|
| 756 | + $pdf->line($this->posxpuht - 1, $tab_top, $this->posxpuht - 1, $tab_top + $tab_height); |
|
| 757 | 757 | if (empty($hidetop)) |
| 758 | 758 | { |
| 759 | - $pdf->SetXY($this->posxpuht-1, $tab_top+1); |
|
| 760 | - $pdf->MultiCell(($this->posxtotalht - $this->posxpuht), 2, $outputlangs->transnoentities("PriceUHT"),'','C'); |
|
| 759 | + $pdf->SetXY($this->posxpuht - 1, $tab_top + 1); |
|
| 760 | + $pdf->MultiCell(($this->posxtotalht - $this->posxpuht), 2, $outputlangs->transnoentities("PriceUHT"), '', 'C'); |
|
| 761 | 761 | } |
| 762 | 762 | |
| 763 | - $pdf->line($this->posxtotalht-1, $tab_top, $this->posxtotalht-1, $tab_top + $tab_height); |
|
| 763 | + $pdf->line($this->posxtotalht - 1, $tab_top, $this->posxtotalht - 1, $tab_top + $tab_height); |
|
| 764 | 764 | if (empty($hidetop)) |
| 765 | 765 | { |
| 766 | - $pdf->SetXY($this->posxtotalht-1, $tab_top+1); |
|
| 767 | - $pdf->MultiCell(($this->page_largeur - $this->marge_droite - $this->posxtotalht), 2, $outputlangs->transnoentities("TotalHT"),'','C'); |
|
| 766 | + $pdf->SetXY($this->posxtotalht - 1, $tab_top + 1); |
|
| 767 | + $pdf->MultiCell(($this->page_largeur - $this->marge_droite - $this->posxtotalht), 2, $outputlangs->transnoentities("TotalHT"), '', 'C'); |
|
| 768 | 768 | } |
| 769 | 769 | |
| 770 | 770 | } |
@@ -782,73 +782,73 @@ discard block |
||
| 782 | 782 | */ |
| 783 | 783 | function _pagehead(&$pdf, $object, $showaddress, $outputlangs) |
| 784 | 784 | { |
| 785 | - global $conf,$langs,$mysoc; |
|
| 785 | + global $conf, $langs, $mysoc; |
|
| 786 | 786 | |
| 787 | 787 | $langs->load("orders"); |
| 788 | 788 | |
| 789 | 789 | $default_font_size = pdf_getPDFFontSize($outputlangs); |
| 790 | 790 | |
| 791 | - pdf_pagehead($pdf,$outputlangs,$this->page_hauteur); |
|
| 791 | + pdf_pagehead($pdf, $outputlangs, $this->page_hauteur); |
|
| 792 | 792 | |
| 793 | 793 | // Show Draft Watermark |
| 794 | - if($object->statut==0 && (! empty($conf->global->SHIPPING_DRAFT_WATERMARK)) ) |
|
| 794 | + if ($object->statut == 0 && (!empty($conf->global->SHIPPING_DRAFT_WATERMARK))) |
|
| 795 | 795 | { |
| 796 | - pdf_watermark($pdf,$outputlangs,$this->page_hauteur,$this->page_largeur,'mm',$conf->global->SHIPPING_DRAFT_WATERMARK); |
|
| 796 | + pdf_watermark($pdf, $outputlangs, $this->page_hauteur, $this->page_largeur, 'mm', $conf->global->SHIPPING_DRAFT_WATERMARK); |
|
| 797 | 797 | } |
| 798 | 798 | |
| 799 | 799 | //Prepare la suite |
| 800 | - $pdf->SetTextColor(0,0,60); |
|
| 801 | - $pdf->SetFont('','B', $default_font_size + 3); |
|
| 800 | + $pdf->SetTextColor(0, 0, 60); |
|
| 801 | + $pdf->SetFont('', 'B', $default_font_size + 3); |
|
| 802 | 802 | |
| 803 | 803 | $w = 110; |
| 804 | 804 | |
| 805 | - $posy=$this->marge_haute; |
|
| 806 | - $posx=$this->page_largeur-$this->marge_droite-$w; |
|
| 805 | + $posy = $this->marge_haute; |
|
| 806 | + $posx = $this->page_largeur - $this->marge_droite - $w; |
|
| 807 | 807 | |
| 808 | - $pdf->SetXY($this->marge_gauche,$posy); |
|
| 808 | + $pdf->SetXY($this->marge_gauche, $posy); |
|
| 809 | 809 | |
| 810 | 810 | // Logo |
| 811 | - $logo=$conf->mycompany->dir_output.'/logos/'.$this->emetteur->logo; |
|
| 811 | + $logo = $conf->mycompany->dir_output.'/logos/'.$this->emetteur->logo; |
|
| 812 | 812 | if ($this->emetteur->logo) |
| 813 | 813 | { |
| 814 | 814 | if (is_readable($logo)) |
| 815 | 815 | { |
| 816 | - $height=pdf_getHeightForLogo($logo); |
|
| 817 | - $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto) |
|
| 816 | + $height = pdf_getHeightForLogo($logo); |
|
| 817 | + $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto) |
|
| 818 | 818 | } |
| 819 | 819 | else |
| 820 | 820 | { |
| 821 | - $pdf->SetTextColor(200,0,0); |
|
| 822 | - $pdf->SetFont('','B', $default_font_size - 2); |
|
| 823 | - $pdf->MultiCell($w, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound",$logo), 0, 'L'); |
|
| 821 | + $pdf->SetTextColor(200, 0, 0); |
|
| 822 | + $pdf->SetFont('', 'B', $default_font_size - 2); |
|
| 823 | + $pdf->MultiCell($w, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound", $logo), 0, 'L'); |
|
| 824 | 824 | $pdf->MultiCell($w, 3, $outputlangs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L'); |
| 825 | 825 | } |
| 826 | 826 | } |
| 827 | 827 | else |
| 828 | 828 | { |
| 829 | - $text=$this->emetteur->name; |
|
| 829 | + $text = $this->emetteur->name; |
|
| 830 | 830 | $pdf->MultiCell($w, 4, $outputlangs->convToOutputCharset($text), 0, 'L'); |
| 831 | 831 | } |
| 832 | 832 | |
| 833 | 833 | // Show barcode |
| 834 | - if (! empty($conf->barcode->enabled)) |
|
| 834 | + if (!empty($conf->barcode->enabled)) |
|
| 835 | 835 | { |
| 836 | - $posx=105; |
|
| 836 | + $posx = 105; |
|
| 837 | 837 | } |
| 838 | 838 | else |
| 839 | 839 | { |
| 840 | - $posx=$this->marge_gauche+3; |
|
| 840 | + $posx = $this->marge_gauche + 3; |
|
| 841 | 841 | } |
| 842 | 842 | //$pdf->Rect($this->marge_gauche, $this->marge_haute, $this->page_largeur-$this->marge_gauche-$this->marge_droite, 30); |
| 843 | - if (! empty($conf->barcode->enabled)) |
|
| 843 | + if (!empty($conf->barcode->enabled)) |
|
| 844 | 844 | { |
| 845 | 845 | // TODO Build code bar with function writeBarCode of barcode module for sending ref $object->ref |
| 846 | 846 | //$pdf->SetXY($this->marge_gauche+3, $this->marge_haute+3); |
| 847 | 847 | //$pdf->Image($logo,10, 5, 0, 24); |
| 848 | 848 | } |
| 849 | 849 | |
| 850 | - $pdf->SetDrawColor(128,128,128); |
|
| 851 | - if (! empty($conf->barcode->enabled)) |
|
| 850 | + $pdf->SetDrawColor(128, 128, 128); |
|
| 851 | + if (!empty($conf->barcode->enabled)) |
|
| 852 | 852 | { |
| 853 | 853 | // TODO Build code bar with function writeBarCode of barcode module for sending ref $object->ref |
| 854 | 854 | //$pdf->SetXY($this->marge_gauche+3, $this->marge_haute+3); |
@@ -856,125 +856,125 @@ discard block |
||
| 856 | 856 | } |
| 857 | 857 | |
| 858 | 858 | |
| 859 | - $posx=$this->page_largeur - $w - $this->marge_droite; |
|
| 860 | - $posy=$this->marge_haute; |
|
| 859 | + $posx = $this->page_largeur - $w - $this->marge_droite; |
|
| 860 | + $posy = $this->marge_haute; |
|
| 861 | 861 | |
| 862 | - $pdf->SetFont('','B', $default_font_size + 2); |
|
| 863 | - $pdf->SetXY($posx,$posy); |
|
| 864 | - $pdf->SetTextColor(0,0,60); |
|
| 865 | - $title=$outputlangs->transnoentities("SendingSheet"); |
|
| 862 | + $pdf->SetFont('', 'B', $default_font_size + 2); |
|
| 863 | + $pdf->SetXY($posx, $posy); |
|
| 864 | + $pdf->SetTextColor(0, 0, 60); |
|
| 865 | + $title = $outputlangs->transnoentities("SendingSheet"); |
|
| 866 | 866 | $pdf->MultiCell($w, 4, $title, '', 'R'); |
| 867 | 867 | |
| 868 | - $pdf->SetFont('','', $default_font_size + 1); |
|
| 868 | + $pdf->SetFont('', '', $default_font_size + 1); |
|
| 869 | 869 | |
| 870 | - $posy+=5; |
|
| 870 | + $posy += 5; |
|
| 871 | 871 | |
| 872 | - $pdf->SetXY($posx,$posy); |
|
| 873 | - $pdf->SetTextColor(0,0,60); |
|
| 874 | - $pdf->MultiCell($w, 4, $outputlangs->transnoentities("RefSending") ." : ".$object->ref, '', 'R'); |
|
| 872 | + $pdf->SetXY($posx, $posy); |
|
| 873 | + $pdf->SetTextColor(0, 0, 60); |
|
| 874 | + $pdf->MultiCell($w, 4, $outputlangs->transnoentities("RefSending")." : ".$object->ref, '', 'R'); |
|
| 875 | 875 | |
| 876 | 876 | // Date planned delivery |
| 877 | - if (! empty($object->date_delivery)) |
|
| 877 | + if (!empty($object->date_delivery)) |
|
| 878 | 878 | { |
| 879 | - $posy+=4; |
|
| 880 | - $pdf->SetXY($posx,$posy); |
|
| 881 | - $pdf->SetTextColor(0,0,60); |
|
| 882 | - $pdf->MultiCell($w, 4, $outputlangs->transnoentities("DateDeliveryPlanned")." : ".dol_print_date($object->date_delivery,"day",false,$outputlangs,true), '', 'R'); |
|
| 879 | + $posy += 4; |
|
| 880 | + $pdf->SetXY($posx, $posy); |
|
| 881 | + $pdf->SetTextColor(0, 0, 60); |
|
| 882 | + $pdf->MultiCell($w, 4, $outputlangs->transnoentities("DateDeliveryPlanned")." : ".dol_print_date($object->date_delivery, "day", false, $outputlangs, true), '', 'R'); |
|
| 883 | 883 | } |
| 884 | 884 | |
| 885 | - if (! empty($object->thirdparty->code_client)) |
|
| 885 | + if (!empty($object->thirdparty->code_client)) |
|
| 886 | 886 | { |
| 887 | - $posy+=4; |
|
| 888 | - $pdf->SetXY($posx,$posy); |
|
| 889 | - $pdf->SetTextColor(0,0,60); |
|
| 890 | - $pdf->MultiCell($w, 3, $outputlangs->transnoentities("CustomerCode")." : " . $outputlangs->transnoentities($object->thirdparty->code_client), '', 'R'); |
|
| 887 | + $posy += 4; |
|
| 888 | + $pdf->SetXY($posx, $posy); |
|
| 889 | + $pdf->SetTextColor(0, 0, 60); |
|
| 890 | + $pdf->MultiCell($w, 3, $outputlangs->transnoentities("CustomerCode")." : ".$outputlangs->transnoentities($object->thirdparty->code_client), '', 'R'); |
|
| 891 | 891 | } |
| 892 | 892 | |
| 893 | 893 | |
| 894 | - $pdf->SetFont('','', $default_font_size + 3); |
|
| 895 | - $Yoff=25; |
|
| 894 | + $pdf->SetFont('', '', $default_font_size + 3); |
|
| 895 | + $Yoff = 25; |
|
| 896 | 896 | |
| 897 | 897 | // Add list of linked orders |
| 898 | - $origin = $object->origin; |
|
| 899 | - $origin_id = $object->origin_id; |
|
| 898 | + $origin = $object->origin; |
|
| 899 | + $origin_id = $object->origin_id; |
|
| 900 | 900 | |
| 901 | 901 | // TODO move to external function |
| 902 | - if (! empty($conf->$origin->enabled)) // commonly $origin='commande' |
|
| 902 | + if (!empty($conf->$origin->enabled)) // commonly $origin='commande' |
|
| 903 | 903 | { |
| 904 | 904 | $outputlangs->load('orders'); |
| 905 | 905 | |
| 906 | 906 | $classname = ucfirst($origin); |
| 907 | 907 | $linkedobject = new $classname($this->db); |
| 908 | - $result=$linkedobject->fetch($origin_id); |
|
| 908 | + $result = $linkedobject->fetch($origin_id); |
|
| 909 | 909 | if ($result >= 0) |
| 910 | 910 | { |
| 911 | 911 | //$linkedobject->fetchObjectLinked() Get all linked object to the $linkedobject (commonly order) into $linkedobject->linkedObjects |
| 912 | 912 | |
| 913 | - $pdf->SetFont('','', $default_font_size - 2); |
|
| 914 | - $text=$linkedobject->ref; |
|
| 915 | - if ($linkedobject->ref_client) $text.=' ('.$linkedobject->ref_client.')'; |
|
| 916 | - $Yoff = $Yoff+8; |
|
| 917 | - $pdf->SetXY($this->page_largeur - $this->marge_droite - $w,$Yoff); |
|
| 918 | - $pdf->MultiCell($w, 2, $outputlangs->transnoentities("RefOrder") ." : ".$outputlangs->transnoentities($text), 0, 'R'); |
|
| 919 | - $Yoff = $Yoff+3; |
|
| 920 | - $pdf->SetXY($this->page_largeur - $this->marge_droite - $w,$Yoff); |
|
| 921 | - $pdf->MultiCell($w, 2, $outputlangs->transnoentities("OrderDate")." : ".dol_print_date($linkedobject->date,"day",false,$outputlangs,true), 0, 'R'); |
|
| 913 | + $pdf->SetFont('', '', $default_font_size - 2); |
|
| 914 | + $text = $linkedobject->ref; |
|
| 915 | + if ($linkedobject->ref_client) $text .= ' ('.$linkedobject->ref_client.')'; |
|
| 916 | + $Yoff = $Yoff + 8; |
|
| 917 | + $pdf->SetXY($this->page_largeur - $this->marge_droite - $w, $Yoff); |
|
| 918 | + $pdf->MultiCell($w, 2, $outputlangs->transnoentities("RefOrder")." : ".$outputlangs->transnoentities($text), 0, 'R'); |
|
| 919 | + $Yoff = $Yoff + 3; |
|
| 920 | + $pdf->SetXY($this->page_largeur - $this->marge_droite - $w, $Yoff); |
|
| 921 | + $pdf->MultiCell($w, 2, $outputlangs->transnoentities("OrderDate")." : ".dol_print_date($linkedobject->date, "day", false, $outputlangs, true), 0, 'R'); |
|
| 922 | 922 | } |
| 923 | 923 | } |
| 924 | 924 | |
| 925 | 925 | if ($showaddress) |
| 926 | 926 | { |
| 927 | 927 | // Sender properties |
| 928 | - $carac_emetteur=''; |
|
| 928 | + $carac_emetteur = ''; |
|
| 929 | 929 | // Add internal contact of origin element if defined |
| 930 | - $arrayidcontact=array(); |
|
| 931 | - if (! empty($origin) && is_object($object->$origin)) $arrayidcontact=$object->$origin->getIdContact('internal','SALESREPFOLL'); |
|
| 930 | + $arrayidcontact = array(); |
|
| 931 | + if (!empty($origin) && is_object($object->$origin)) $arrayidcontact = $object->$origin->getIdContact('internal', 'SALESREPFOLL'); |
|
| 932 | 932 | if (count($arrayidcontact) > 0) |
| 933 | 933 | { |
| 934 | 934 | $object->fetch_user(reset($arrayidcontact)); |
| 935 | - $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$outputlangs->transnoentities("Name").": ".$outputlangs->convToOutputCharset($object->user->getFullName($outputlangs))."\n"; |
|
| 935 | + $carac_emetteur .= ($carac_emetteur ? "\n" : '').$outputlangs->transnoentities("Name").": ".$outputlangs->convToOutputCharset($object->user->getFullName($outputlangs))."\n"; |
|
| 936 | 936 | } |
| 937 | 937 | |
| 938 | 938 | $carac_emetteur .= pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty); |
| 939 | 939 | |
| 940 | 940 | // Show sender |
| 941 | - $posy=!empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 40 : 42; |
|
| 942 | - $posx=$this->marge_gauche; |
|
| 943 | - if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->page_largeur-$this->marge_droite-80; |
|
| 941 | + $posy = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 40 : 42; |
|
| 942 | + $posx = $this->marge_gauche; |
|
| 943 | + if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx = $this->page_largeur - $this->marge_droite - 80; |
|
| 944 | 944 | |
| 945 | - $hautcadre=!empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 38 : 40; |
|
| 946 | - $widthrecbox=!empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 92 : 82; |
|
| 945 | + $hautcadre = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 38 : 40; |
|
| 946 | + $widthrecbox = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 92 : 82; |
|
| 947 | 947 | |
| 948 | 948 | // Show sender frame |
| 949 | - $pdf->SetTextColor(0,0,0); |
|
| 950 | - $pdf->SetFont('','', $default_font_size - 2); |
|
| 951 | - $pdf->SetXY($posx,$posy-5); |
|
| 952 | - $pdf->MultiCell(66,5, $outputlangs->transnoentities("Sender").":", 0, 'L'); |
|
| 953 | - $pdf->SetXY($posx,$posy); |
|
| 954 | - $pdf->SetFillColor(230,230,230); |
|
| 949 | + $pdf->SetTextColor(0, 0, 0); |
|
| 950 | + $pdf->SetFont('', '', $default_font_size - 2); |
|
| 951 | + $pdf->SetXY($posx, $posy - 5); |
|
| 952 | + $pdf->MultiCell(66, 5, $outputlangs->transnoentities("Sender").":", 0, 'L'); |
|
| 953 | + $pdf->SetXY($posx, $posy); |
|
| 954 | + $pdf->SetFillColor(230, 230, 230); |
|
| 955 | 955 | $pdf->MultiCell($widthrecbox, $hautcadre, "", 0, 'R', 1); |
| 956 | - $pdf->SetTextColor(0,0,60); |
|
| 957 | - $pdf->SetFillColor(255,255,255); |
|
| 956 | + $pdf->SetTextColor(0, 0, 60); |
|
| 957 | + $pdf->SetFillColor(255, 255, 255); |
|
| 958 | 958 | |
| 959 | 959 | // Show sender name |
| 960 | - $pdf->SetXY($posx+2,$posy+3); |
|
| 961 | - $pdf->SetFont('','B',$default_font_size); |
|
| 962 | - $pdf->MultiCell($widthrecbox-2, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, 'L'); |
|
| 963 | - $posy=$pdf->getY(); |
|
| 960 | + $pdf->SetXY($posx + 2, $posy + 3); |
|
| 961 | + $pdf->SetFont('', 'B', $default_font_size); |
|
| 962 | + $pdf->MultiCell($widthrecbox - 2, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, 'L'); |
|
| 963 | + $posy = $pdf->getY(); |
|
| 964 | 964 | |
| 965 | 965 | // Show sender information |
| 966 | - $pdf->SetXY($posx+2,$posy); |
|
| 967 | - $pdf->SetFont('','', $default_font_size - 1); |
|
| 968 | - $pdf->MultiCell($widthrecbox-2, 4, $carac_emetteur, 0, 'L'); |
|
| 966 | + $pdf->SetXY($posx + 2, $posy); |
|
| 967 | + $pdf->SetFont('', '', $default_font_size - 1); |
|
| 968 | + $pdf->MultiCell($widthrecbox - 2, 4, $carac_emetteur, 0, 'L'); |
|
| 969 | 969 | |
| 970 | 970 | |
| 971 | 971 | // If SHIPPING contact defined, we use it |
| 972 | - $usecontact=false; |
|
| 973 | - $arrayidcontact=$object->$origin->getIdContact('external','SHIPPING'); |
|
| 972 | + $usecontact = false; |
|
| 973 | + $arrayidcontact = $object->$origin->getIdContact('external', 'SHIPPING'); |
|
| 974 | 974 | if (count($arrayidcontact) > 0) |
| 975 | 975 | { |
| 976 | - $usecontact=true; |
|
| 977 | - $result=$object->fetch_contact($arrayidcontact[0]); |
|
| 976 | + $usecontact = true; |
|
| 977 | + $result = $object->fetch_contact($arrayidcontact[0]); |
|
| 978 | 978 | } |
| 979 | 979 | |
| 980 | 980 | //Recipient name |
@@ -985,38 +985,38 @@ discard block |
||
| 985 | 985 | $thirdparty = $object->thirdparty; |
| 986 | 986 | } |
| 987 | 987 | |
| 988 | - $carac_client_name= pdfBuildThirdpartyName($thirdparty, $outputlangs); |
|
| 988 | + $carac_client_name = pdfBuildThirdpartyName($thirdparty, $outputlangs); |
|
| 989 | 989 | |
| 990 | - $carac_client=pdf_build_address($outputlangs,$this->emetteur,$object->thirdparty,(!empty($object->contact)?$object->contact:null),$usecontact,'targetwithdetails',$object); |
|
| 990 | + $carac_client = pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, (!empty($object->contact) ? $object->contact : null), $usecontact, 'targetwithdetails', $object); |
|
| 991 | 991 | |
| 992 | 992 | // Show recipient |
| 993 | - $widthrecbox=!empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 92 : 100; |
|
| 994 | - if ($this->page_largeur < 210) $widthrecbox=84; // To work with US executive format |
|
| 995 | - $posy=!empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 40 : 42; |
|
| 996 | - $posx=$this->page_largeur - $this->marge_droite - $widthrecbox; |
|
| 997 | - if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->marge_gauche; |
|
| 993 | + $widthrecbox = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 92 : 100; |
|
| 994 | + if ($this->page_largeur < 210) $widthrecbox = 84; // To work with US executive format |
|
| 995 | + $posy = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 40 : 42; |
|
| 996 | + $posx = $this->page_largeur - $this->marge_droite - $widthrecbox; |
|
| 997 | + if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx = $this->marge_gauche; |
|
| 998 | 998 | |
| 999 | 999 | // Show recipient frame |
| 1000 | - $pdf->SetTextColor(0,0,0); |
|
| 1001 | - $pdf->SetFont('','', $default_font_size - 2); |
|
| 1002 | - $pdf->SetXY($posx+2,$posy-5); |
|
| 1000 | + $pdf->SetTextColor(0, 0, 0); |
|
| 1001 | + $pdf->SetFont('', '', $default_font_size - 2); |
|
| 1002 | + $pdf->SetXY($posx + 2, $posy - 5); |
|
| 1003 | 1003 | $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities("Recipient").":", 0, 'L'); |
| 1004 | 1004 | $pdf->Rect($posx, $posy, $widthrecbox, $hautcadre); |
| 1005 | 1005 | |
| 1006 | 1006 | // Show recipient name |
| 1007 | - $pdf->SetXY($posx+2,$posy+3); |
|
| 1008 | - $pdf->SetFont('','B', $default_font_size); |
|
| 1007 | + $pdf->SetXY($posx + 2, $posy + 3); |
|
| 1008 | + $pdf->SetFont('', 'B', $default_font_size); |
|
| 1009 | 1009 | $pdf->MultiCell($widthrecbox, 2, $carac_client_name, 0, 'L'); |
| 1010 | 1010 | |
| 1011 | 1011 | $posy = $pdf->getY(); |
| 1012 | 1012 | |
| 1013 | 1013 | // Show recipient information |
| 1014 | - $pdf->SetFont('','', $default_font_size - 1); |
|
| 1015 | - $pdf->SetXY($posx+2,$posy); |
|
| 1014 | + $pdf->SetFont('', '', $default_font_size - 1); |
|
| 1015 | + $pdf->SetXY($posx + 2, $posy); |
|
| 1016 | 1016 | $pdf->MultiCell($widthrecbox, 4, $carac_client, 0, 'L'); |
| 1017 | 1017 | } |
| 1018 | 1018 | |
| 1019 | - $pdf->SetTextColor(0,0,0); |
|
| 1019 | + $pdf->SetTextColor(0, 0, 0); |
|
| 1020 | 1020 | } |
| 1021 | 1021 | |
| 1022 | 1022 | /** |
@@ -1028,11 +1028,11 @@ discard block |
||
| 1028 | 1028 | * @param int $hidefreetext 1=Hide free text |
| 1029 | 1029 | * @return int Return height of bottom margin including footer text |
| 1030 | 1030 | */ |
| 1031 | - function _pagefoot(&$pdf,$object,$outputlangs,$hidefreetext=0) |
|
| 1031 | + function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0) |
|
| 1032 | 1032 | { |
| 1033 | 1033 | global $conf; |
| 1034 | - $showdetails=$conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS; |
|
| 1035 | - return pdf_pagefoot($pdf,$outputlangs,'SHIPPING_FREE_TEXT',$this->emetteur,$this->marge_basse,$this->marge_gauche,$this->page_hauteur,$object,$showdetails,$hidefreetext); |
|
| 1034 | + $showdetails = $conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS; |
|
| 1035 | + return pdf_pagefoot($pdf, $outputlangs, 'SHIPPING_FREE_TEXT', $this->emetteur, $this->marge_basse, $this->marge_gauche, $this->page_hauteur, $object, $showdetails, $hidefreetext); |
|
| 1036 | 1036 | } |
| 1037 | 1037 | |
| 1038 | 1038 | } |
@@ -66,7 +66,10 @@ discard block |
||
| 66 | 66 | |
| 67 | 67 | // Get source company |
| 68 | 68 | $this->emetteur=$mysoc; |
| 69 | - if (! $this->emetteur->country_code) $this->emetteur->country_code=substr($langs->defaultlang,-2); // By default if not defined |
|
| 69 | + if (! $this->emetteur->country_code) { |
|
| 70 | + $this->emetteur->country_code=substr($langs->defaultlang,-2); |
|
| 71 | + } |
|
| 72 | + // By default if not defined |
|
| 70 | 73 | |
| 71 | 74 | // Define position of columns |
| 72 | 75 | $this->posxdesc=$this->marge_gauche+1; |
@@ -86,9 +89,11 @@ discard block |
||
| 86 | 89 | |
| 87 | 90 | $this->posxpicture=$this->posxweightvol - (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH)?20:$conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH); // width of images |
| 88 | 91 | |
| 89 | - if ($this->page_largeur < 210) // To work with US executive format |
|
| 92 | + if ($this->page_largeur < 210) { |
|
| 93 | + // To work with US executive format |
|
| 90 | 94 | { |
| 91 | 95 | $this->posxweightvol-=20; |
| 96 | + } |
|
| 92 | 97 | $this->posxpicture-=20; |
| 93 | 98 | $this->posxqtyordered-=20; |
| 94 | 99 | $this->posxqtytoship-=20; |
@@ -119,9 +124,13 @@ discard block |
||
| 119 | 124 | |
| 120 | 125 | $object->fetch_thirdparty(); |
| 121 | 126 | |
| 122 | - if (! is_object($outputlangs)) $outputlangs=$langs; |
|
| 127 | + if (! is_object($outputlangs)) { |
|
| 128 | + $outputlangs=$langs; |
|
| 129 | + } |
|
| 123 | 130 | // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO |
| 124 | - if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1'; |
|
| 131 | + if (! empty($conf->global->MAIN_USE_FPDF)) { |
|
| 132 | + $outputlangs->charset_output='ISO-8859-1'; |
|
| 133 | + } |
|
| 125 | 134 | |
| 126 | 135 | $outputlangs->load("main"); |
| 127 | 136 | $outputlangs->load("dict"); |
@@ -143,7 +152,9 @@ discard block |
||
| 143 | 152 | |
| 144 | 153 | for ($i = 0 ; $i < $nblignes ; $i++) |
| 145 | 154 | { |
| 146 | - if (empty($object->lines[$i]->fk_product)) continue; |
|
| 155 | + if (empty($object->lines[$i]->fk_product)) { |
|
| 156 | + continue; |
|
| 157 | + } |
|
| 147 | 158 | |
| 148 | 159 | $objphoto = new Product($this->db); |
| 149 | 160 | $objphoto->fetch($object->lines[$i]->fk_product); |
@@ -155,18 +166,18 @@ discard block |
||
| 155 | 166 | |
| 156 | 167 | foreach ($objphoto->liste_photos($dir,1) as $key => $obj) |
| 157 | 168 | { |
| 158 | - if (empty($conf->global->CAT_HIGH_QUALITY_IMAGES)) // If CAT_HIGH_QUALITY_IMAGES not defined, we use thumb if defined and then original photo |
|
| 169 | + if (empty($conf->global->CAT_HIGH_QUALITY_IMAGES)) { |
|
| 170 | + // If CAT_HIGH_QUALITY_IMAGES not defined, we use thumb if defined and then original photo |
|
| 159 | 171 | { |
| 160 | 172 | if ($obj['photo_vignette']) |
| 161 | 173 | { |
| 162 | 174 | $filename= $obj['photo_vignette']; |
| 163 | - } |
|
| 164 | - else |
|
| 175 | + } |
|
| 176 | + } else |
|
| 165 | 177 | { |
| 166 | 178 | $filename=$obj['photo']; |
| 167 | 179 | } |
| 168 | - } |
|
| 169 | - else |
|
| 180 | + } else |
|
| 170 | 181 | { |
| 171 | 182 | $filename=$obj['photo']; |
| 172 | 183 | } |
@@ -175,11 +186,15 @@ discard block |
||
| 175 | 186 | break; |
| 176 | 187 | } |
| 177 | 188 | |
| 178 | - if ($realpath) $realpatharray[$i]=$realpath; |
|
| 189 | + if ($realpath) { |
|
| 190 | + $realpatharray[$i]=$realpath; |
|
| 191 | + } |
|
| 179 | 192 | } |
| 180 | 193 | } |
| 181 | 194 | |
| 182 | - if (count($realpatharray) == 0) $this->posxpicture=$this->posxweightvol; |
|
| 195 | + if (count($realpatharray) == 0) { |
|
| 196 | + $this->posxpicture=$this->posxweightvol; |
|
| 197 | + } |
|
| 183 | 198 | |
| 184 | 199 | if ($conf->expedition->dir_output) |
| 185 | 200 | { |
@@ -188,8 +203,7 @@ discard block |
||
| 188 | 203 | { |
| 189 | 204 | $dir = $conf->expedition->dir_output."/sending"; |
| 190 | 205 | $file = $dir . "/SPECIMEN.pdf"; |
| 191 | - } |
|
| 192 | - else |
|
| 206 | + } else |
|
| 193 | 207 | { |
| 194 | 208 | $expref = dol_sanitizeFileName($object->ref); |
| 195 | 209 | $dir = $conf->expedition->dir_output."/sending/" . $expref; |
@@ -245,20 +259,26 @@ discard block |
||
| 245 | 259 | $pagenb=0; |
| 246 | 260 | $pdf->SetDrawColor(128,128,128); |
| 247 | 261 | |
| 248 | - if (method_exists($pdf,'AliasNbPages')) $pdf->AliasNbPages(); |
|
| 262 | + if (method_exists($pdf,'AliasNbPages')) { |
|
| 263 | + $pdf->AliasNbPages(); |
|
| 264 | + } |
|
| 249 | 265 | |
| 250 | 266 | $pdf->SetTitle($outputlangs->convToOutputCharset($object->ref)); |
| 251 | 267 | $pdf->SetSubject($outputlangs->transnoentities("Shipment")); |
| 252 | 268 | $pdf->SetCreator("Dolibarr ".DOL_VERSION); |
| 253 | 269 | $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs))); |
| 254 | 270 | $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("Shipment")); |
| 255 | - if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false); |
|
| 271 | + if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) { |
|
| 272 | + $pdf->SetCompression(false); |
|
| 273 | + } |
|
| 256 | 274 | |
| 257 | 275 | $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right |
| 258 | 276 | |
| 259 | 277 | // New page |
| 260 | 278 | $pdf->AddPage(); |
| 261 | - if (! empty($tplidx)) $pdf->useTemplate($tplidx); |
|
| 279 | + if (! empty($tplidx)) { |
|
| 280 | + $pdf->useTemplate($tplidx); |
|
| 281 | + } |
|
| 262 | 282 | $pagenb++; |
| 263 | 283 | $this->_pagehead($pdf, $object, 1, $outputlangs); |
| 264 | 284 | $pdf->SetFont('','', $default_font_size - 1); |
@@ -315,7 +335,9 @@ discard block |
||
| 315 | 335 | // Get code using getLabelFromKey |
| 316 | 336 | $code=$outputlangs->getLabelFromKey($this->db,$object->shipping_method_id,'c_shipment_mode','rowid','code'); |
| 317 | 337 | $label=''; |
| 318 | - if ($object->tracking_url != $object->tracking_number) $label.=$outputlangs->trans("LinkToTrackYourPackage")."<br>"; |
|
| 338 | + if ($object->tracking_url != $object->tracking_number) { |
|
| 339 | + $label.=$outputlangs->trans("LinkToTrackYourPackage")."<br>"; |
|
| 340 | + } |
|
| 319 | 341 | $label.=$outputlangs->trans("SendingMethod").": ".$outputlangs->trans("SendingMethod".strtoupper($code)); |
| 320 | 342 | //var_dump($object->tracking_url != $object->tracking_number);exit; |
| 321 | 343 | if ($object->tracking_url != $object->tracking_number) |
@@ -347,8 +369,7 @@ discard block |
||
| 347 | 369 | |
| 348 | 370 | $tab_height = $tab_height - $height_note; |
| 349 | 371 | $tab_top = $nexY+6; |
| 350 | - } |
|
| 351 | - else |
|
| 372 | + } else |
|
| 352 | 373 | { |
| 353 | 374 | $height_note=0; |
| 354 | 375 | } |
@@ -366,7 +387,9 @@ discard block |
||
| 366 | 387 | |
| 367 | 388 | // Define size of image if we need it |
| 368 | 389 | $imglinesize=array(); |
| 369 | - if (! empty($realpatharray[$i])) $imglinesize=pdf_getSizeForImage($realpatharray[$i]); |
|
| 390 | + if (! empty($realpatharray[$i])) { |
|
| 391 | + $imglinesize=pdf_getSizeForImage($realpatharray[$i]); |
|
| 392 | + } |
|
| 370 | 393 | |
| 371 | 394 | $pdf->setTopMargin($tab_top_newpage); |
| 372 | 395 | $pdf->setPageOrientation('', 1, $heightforfooter+$heightforfreetext+$heightforinfotot); // The only function to edit the bottom margin of current page to set it. |
@@ -377,11 +400,17 @@ discard block |
||
| 377 | 400 | $posYAfterDescription=0; |
| 378 | 401 | |
| 379 | 402 | // We start with Photo of product line |
| 380 | - 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 |
|
| 403 | + if (isset($imglinesize['width']) && isset($imglinesize['height']) && ($curY + $imglinesize['height']) > ($this->page_hauteur-($heightforfooter+$heightforfreetext+$heightforinfotot))) { |
|
| 404 | + // If photo too high, we moved completely on new page |
|
| 381 | 405 | { |
| 382 | 406 | $pdf->AddPage('','',true); |
| 383 | - if (! empty($tplidx)) $pdf->useTemplate($tplidx); |
|
| 384 | - if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); |
|
| 407 | + } |
|
| 408 | + if (! empty($tplidx)) { |
|
| 409 | + $pdf->useTemplate($tplidx); |
|
| 410 | + } |
|
| 411 | + if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) { |
|
| 412 | + $this->_pagehead($pdf, $object, 0, $outputlangs); |
|
| 413 | + } |
|
| 385 | 414 | $pdf->setPage($pageposbefore+1); |
| 386 | 415 | |
| 387 | 416 | $curY = $tab_top_newpage; |
@@ -403,9 +432,11 @@ discard block |
||
| 403 | 432 | pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->posxpicture-$curX,3,$curX,$curY,$hideref,$hidedesc); |
| 404 | 433 | |
| 405 | 434 | $pageposafter=$pdf->getPage(); |
| 406 | - if ($pageposafter > $pageposbefore) // There is a pagebreak |
|
| 435 | + if ($pageposafter > $pageposbefore) { |
|
| 436 | + // There is a pagebreak |
|
| 407 | 437 | { |
| 408 | 438 | $pdf->rollbackTransaction(true); |
| 439 | + } |
|
| 409 | 440 | $pageposafter=$pageposbefore; |
| 410 | 441 | //print $pageposafter.'-'.$pageposbefore;exit; |
| 411 | 442 | $pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it. |
@@ -414,23 +445,27 @@ discard block |
||
| 414 | 445 | $pageposafter=$pdf->getPage(); |
| 415 | 446 | $posyafter=$pdf->GetY(); |
| 416 | 447 | //var_dump($posyafter); var_dump(($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))); exit; |
| 417 | - if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))) // There is no space left for total+free text |
|
| 448 | + if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))) { |
|
| 449 | + // There is no space left for total+free text |
|
| 418 | 450 | { |
| 419 | 451 | if ($i == ($nblignes-1)) // No more lines, and no space left to show total, so we create a new page |
| 420 | 452 | { |
| 421 | 453 | $pdf->AddPage('','',true); |
| 422 | - if (! empty($tplidx)) $pdf->useTemplate($tplidx); |
|
| 423 | - if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); |
|
| 454 | + } |
|
| 455 | + if (! empty($tplidx)) { |
|
| 456 | + $pdf->useTemplate($tplidx); |
|
| 457 | + } |
|
| 458 | + if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) { |
|
| 459 | + $this->_pagehead($pdf, $object, 0, $outputlangs); |
|
| 460 | + } |
|
| 424 | 461 | $pdf->setPage($pageposafter+1); |
| 425 | 462 | } |
| 426 | - } |
|
| 427 | - else |
|
| 463 | + } else |
|
| 428 | 464 | { |
| 429 | 465 | // We found a page break |
| 430 | 466 | $showpricebeforepagebreak=0; |
| 431 | 467 | } |
| 432 | - } |
|
| 433 | - else // No pagebreak |
|
| 468 | + } else // No pagebreak |
|
| 434 | 469 | { |
| 435 | 470 | $pdf->commitTransaction(); |
| 436 | 471 | } |
@@ -489,7 +524,9 @@ discard block |
||
| 489 | 524 | } |
| 490 | 525 | |
| 491 | 526 | $nexY+=3; |
| 492 | - if ($weighttxt && $voltxt) $nexY+=2; |
|
| 527 | + if ($weighttxt && $voltxt) { |
|
| 528 | + $nexY+=2; |
|
| 529 | + } |
|
| 493 | 530 | |
| 494 | 531 | // Add line |
| 495 | 532 | if (! empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblignes - 1)) |
@@ -508,8 +545,7 @@ discard block |
||
| 508 | 545 | if ($pagenb == 1) |
| 509 | 546 | { |
| 510 | 547 | $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1); |
| 511 | - } |
|
| 512 | - else |
|
| 548 | + } else |
|
| 513 | 549 | { |
| 514 | 550 | $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1); |
| 515 | 551 | } |
@@ -517,24 +553,29 @@ discard block |
||
| 517 | 553 | $pagenb++; |
| 518 | 554 | $pdf->setPage($pagenb); |
| 519 | 555 | $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. |
| 520 | - if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); |
|
| 556 | + if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) { |
|
| 557 | + $this->_pagehead($pdf, $object, 0, $outputlangs); |
|
| 558 | + } |
|
| 521 | 559 | } |
| 522 | 560 | if (isset($object->lines[$i+1]->pagebreak) && $object->lines[$i+1]->pagebreak) |
| 523 | 561 | { |
| 524 | 562 | if ($pagenb == 1) |
| 525 | 563 | { |
| 526 | 564 | $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1); |
| 527 | - } |
|
| 528 | - else |
|
| 565 | + } else |
|
| 529 | 566 | { |
| 530 | 567 | $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1); |
| 531 | 568 | } |
| 532 | 569 | $this->_pagefoot($pdf,$object,$outputlangs,1); |
| 533 | 570 | // New page |
| 534 | 571 | $pdf->AddPage(); |
| 535 | - if (! empty($tplidx)) $pdf->useTemplate($tplidx); |
|
| 572 | + if (! empty($tplidx)) { |
|
| 573 | + $pdf->useTemplate($tplidx); |
|
| 574 | + } |
|
| 536 | 575 | $pagenb++; |
| 537 | - if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); |
|
| 576 | + if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) { |
|
| 577 | + $this->_pagehead($pdf, $object, 0, $outputlangs); |
|
| 578 | + } |
|
| 538 | 579 | } |
| 539 | 580 | } |
| 540 | 581 | |
@@ -543,8 +584,7 @@ discard block |
||
| 543 | 584 | { |
| 544 | 585 | $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0); |
| 545 | 586 | $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; |
| 546 | - } |
|
| 547 | - else |
|
| 587 | + } else |
|
| 548 | 588 | { |
| 549 | 589 | $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0); |
| 550 | 590 | $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; |
@@ -555,7 +595,9 @@ discard block |
||
| 555 | 595 | |
| 556 | 596 | // Pied de page |
| 557 | 597 | $this->_pagefoot($pdf,$object,$outputlangs); |
| 558 | - if (method_exists($pdf,'AliasNbPages')) $pdf->AliasNbPages(); |
|
| 598 | + if (method_exists($pdf,'AliasNbPages')) { |
|
| 599 | + $pdf->AliasNbPages(); |
|
| 600 | + } |
|
| 559 | 601 | |
| 560 | 602 | $pdf->Close(); |
| 561 | 603 | |
@@ -567,20 +609,19 @@ discard block |
||
| 567 | 609 | global $action; |
| 568 | 610 | $reshook=$hookmanager->executeHooks('afterPDFCreation',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks |
| 569 | 611 | |
| 570 | - if (! empty($conf->global->MAIN_UMASK)) |
|
| 571 | - @chmod($file, octdec($conf->global->MAIN_UMASK)); |
|
| 612 | + if (! empty($conf->global->MAIN_UMASK)) { |
|
| 613 | + @chmod($file, octdec($conf->global->MAIN_UMASK)); |
|
| 614 | + } |
|
| 572 | 615 | |
| 573 | 616 | $this->result = array('fullpath'=>$file); |
| 574 | 617 | |
| 575 | 618 | return 1; // No error |
| 576 | - } |
|
| 577 | - else |
|
| 619 | + } else |
|
| 578 | 620 | { |
| 579 | 621 | $this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir); |
| 580 | 622 | return 0; |
| 581 | 623 | } |
| 582 | - } |
|
| 583 | - else |
|
| 624 | + } else |
|
| 584 | 625 | { |
| 585 | 626 | $this->error=$langs->transnoentities("ErrorConstantNotDefined","EXP_OUTPUTDIR"); |
| 586 | 627 | return 0; |
@@ -615,8 +656,11 @@ discard block |
||
| 615 | 656 | { |
| 616 | 657 | $col2x-=20; |
| 617 | 658 | }*/ |
| 618 | - if (empty($conf->global->SHIPPING_PDF_HIDE_ORDERED)) $largcol2 = ($this->posxqtyordered - $this->posxweightvol); |
|
| 619 | - else $largcol2 = ($this->posxqtytoship - $this->posxweightvol); |
|
| 659 | + if (empty($conf->global->SHIPPING_PDF_HIDE_ORDERED)) { |
|
| 660 | + $largcol2 = ($this->posxqtyordered - $this->posxweightvol); |
|
| 661 | + } else { |
|
| 662 | + $largcol2 = ($this->posxqtytoship - $this->posxweightvol); |
|
| 663 | + } |
|
| 620 | 664 | |
| 621 | 665 | $useborder=0; |
| 622 | 666 | $index = 0; |
@@ -637,10 +681,18 @@ discard block |
||
| 637 | 681 | $object->volume_units=$object->size_units * 3; |
| 638 | 682 | } |
| 639 | 683 | |
| 640 | - if ($totalWeight!='') $totalWeighttoshow=showDimensionInBestUnit($totalWeight, 0, "weight", $outputlangs); |
|
| 641 | - if ($totalVolume!='') $totalVolumetoshow=showDimensionInBestUnit($totalVolume, 0, "volume", $outputlangs); |
|
| 642 | - if ($object->trueWeight) $totalWeighttoshow=showDimensionInBestUnit($object->trueWeight, $object->weight_units, "weight", $outputlangs); |
|
| 643 | - if ($object->trueVolume) $totalVolumetoshow=showDimensionInBestUnit($object->trueVolume, $object->volume_units, "volume", $outputlangs); |
|
| 684 | + if ($totalWeight!='') { |
|
| 685 | + $totalWeighttoshow=showDimensionInBestUnit($totalWeight, 0, "weight", $outputlangs); |
|
| 686 | + } |
|
| 687 | + if ($totalVolume!='') { |
|
| 688 | + $totalVolumetoshow=showDimensionInBestUnit($totalVolume, 0, "volume", $outputlangs); |
|
| 689 | + } |
|
| 690 | + if ($object->trueWeight) { |
|
| 691 | + $totalWeighttoshow=showDimensionInBestUnit($object->trueWeight, $object->weight_units, "weight", $outputlangs); |
|
| 692 | + } |
|
| 693 | + if ($object->trueVolume) { |
|
| 694 | + $totalVolumetoshow=showDimensionInBestUnit($object->trueVolume, $object->volume_units, "volume", $outputlangs); |
|
| 695 | + } |
|
| 644 | 696 | |
| 645 | 697 | $pdf->SetFillColor(255,255,255); |
| 646 | 698 | $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); |
@@ -680,7 +732,9 @@ discard block |
||
| 680 | 732 | |
| 681 | 733 | $index++; |
| 682 | 734 | } |
| 683 | - if (! $totalWeighttoshow && ! $totalVolumetoshow) $index++; |
|
| 735 | + if (! $totalWeighttoshow && ! $totalVolumetoshow) { |
|
| 736 | + $index++; |
|
| 737 | + } |
|
| 684 | 738 | |
| 685 | 739 | $pdf->SetTextColor(0,0,0); |
| 686 | 740 | |
@@ -705,7 +759,9 @@ discard block |
||
| 705 | 759 | |
| 706 | 760 | // Force to disable hidetop and hidebottom |
| 707 | 761 | $hidebottom=0; |
| 708 | - if ($hidetop) $hidetop=-1; |
|
| 762 | + if ($hidetop) { |
|
| 763 | + $hidetop=-1; |
|
| 764 | + } |
|
| 709 | 765 | |
| 710 | 766 | $default_font_size = pdf_getPDFFontSize($outputlangs); |
| 711 | 767 | |
@@ -815,16 +871,14 @@ discard block |
||
| 815 | 871 | { |
| 816 | 872 | $height=pdf_getHeightForLogo($logo); |
| 817 | 873 | $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto) |
| 818 | - } |
|
| 819 | - else |
|
| 874 | + } else |
|
| 820 | 875 | { |
| 821 | 876 | $pdf->SetTextColor(200,0,0); |
| 822 | 877 | $pdf->SetFont('','B', $default_font_size - 2); |
| 823 | 878 | $pdf->MultiCell($w, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound",$logo), 0, 'L'); |
| 824 | 879 | $pdf->MultiCell($w, 3, $outputlangs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L'); |
| 825 | 880 | } |
| 826 | - } |
|
| 827 | - else |
|
| 881 | + } else |
|
| 828 | 882 | { |
| 829 | 883 | $text=$this->emetteur->name; |
| 830 | 884 | $pdf->MultiCell($w, 4, $outputlangs->convToOutputCharset($text), 0, 'L'); |
@@ -834,8 +888,7 @@ discard block |
||
| 834 | 888 | if (! empty($conf->barcode->enabled)) |
| 835 | 889 | { |
| 836 | 890 | $posx=105; |
| 837 | - } |
|
| 838 | - else |
|
| 891 | + } else |
|
| 839 | 892 | { |
| 840 | 893 | $posx=$this->marge_gauche+3; |
| 841 | 894 | } |
@@ -899,9 +952,11 @@ discard block |
||
| 899 | 952 | $origin_id = $object->origin_id; |
| 900 | 953 | |
| 901 | 954 | // TODO move to external function |
| 902 | - if (! empty($conf->$origin->enabled)) // commonly $origin='commande' |
|
| 955 | + if (! empty($conf->$origin->enabled)) { |
|
| 956 | + // commonly $origin='commande' |
|
| 903 | 957 | { |
| 904 | 958 | $outputlangs->load('orders'); |
| 959 | + } |
|
| 905 | 960 | |
| 906 | 961 | $classname = ucfirst($origin); |
| 907 | 962 | $linkedobject = new $classname($this->db); |
@@ -912,7 +967,9 @@ discard block |
||
| 912 | 967 | |
| 913 | 968 | $pdf->SetFont('','', $default_font_size - 2); |
| 914 | 969 | $text=$linkedobject->ref; |
| 915 | - if ($linkedobject->ref_client) $text.=' ('.$linkedobject->ref_client.')'; |
|
| 970 | + if ($linkedobject->ref_client) { |
|
| 971 | + $text.=' ('.$linkedobject->ref_client.')'; |
|
| 972 | + } |
|
| 916 | 973 | $Yoff = $Yoff+8; |
| 917 | 974 | $pdf->SetXY($this->page_largeur - $this->marge_droite - $w,$Yoff); |
| 918 | 975 | $pdf->MultiCell($w, 2, $outputlangs->transnoentities("RefOrder") ." : ".$outputlangs->transnoentities($text), 0, 'R'); |
@@ -928,7 +985,9 @@ discard block |
||
| 928 | 985 | $carac_emetteur=''; |
| 929 | 986 | // Add internal contact of origin element if defined |
| 930 | 987 | $arrayidcontact=array(); |
| 931 | - if (! empty($origin) && is_object($object->$origin)) $arrayidcontact=$object->$origin->getIdContact('internal','SALESREPFOLL'); |
|
| 988 | + if (! empty($origin) && is_object($object->$origin)) { |
|
| 989 | + $arrayidcontact=$object->$origin->getIdContact('internal','SALESREPFOLL'); |
|
| 990 | + } |
|
| 932 | 991 | if (count($arrayidcontact) > 0) |
| 933 | 992 | { |
| 934 | 993 | $object->fetch_user(reset($arrayidcontact)); |
@@ -940,7 +999,9 @@ discard block |
||
| 940 | 999 | // Show sender |
| 941 | 1000 | $posy=!empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 40 : 42; |
| 942 | 1001 | $posx=$this->marge_gauche; |
| 943 | - if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->page_largeur-$this->marge_droite-80; |
|
| 1002 | + if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) { |
|
| 1003 | + $posx=$this->page_largeur-$this->marge_droite-80; |
|
| 1004 | + } |
|
| 944 | 1005 | |
| 945 | 1006 | $hautcadre=!empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 38 : 40; |
| 946 | 1007 | $widthrecbox=!empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 92 : 82; |
@@ -991,10 +1052,15 @@ discard block |
||
| 991 | 1052 | |
| 992 | 1053 | // Show recipient |
| 993 | 1054 | $widthrecbox=!empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 92 : 100; |
| 994 | - if ($this->page_largeur < 210) $widthrecbox=84; // To work with US executive format |
|
| 1055 | + if ($this->page_largeur < 210) { |
|
| 1056 | + $widthrecbox=84; |
|
| 1057 | + } |
|
| 1058 | + // To work with US executive format |
|
| 995 | 1059 | $posy=!empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 40 : 42; |
| 996 | 1060 | $posx=$this->page_largeur - $this->marge_droite - $widthrecbox; |
| 997 | - if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->marge_gauche; |
|
| 1061 | + if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) { |
|
| 1062 | + $posx=$this->marge_gauche; |
|
| 1063 | + } |
|
| 998 | 1064 | |
| 999 | 1065 | // Show recipient frame |
| 1000 | 1066 | $pdf->SetTextColor(0,0,0); |
@@ -101,7 +101,7 @@ |
||
| 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 | */ |
@@ -38,13 +38,13 @@ discard block |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 | |
@@ -25,14 +25,14 @@ discard block |
||
| 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 |
||
| 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"> <input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button"></td>'; |
|
| 70 | + $texte .= '<td align="left" rowspan="2"> <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 |
||
| 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 |
||
| 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 |
||
| 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 | } |
@@ -145,7 +145,7 @@ |
||
| 145 | 145 | /** |
| 146 | 146 | * Return next free ref |
| 147 | 147 | * |
| 148 | - * @param Societe $objsoc Object thirdparty |
|
| 148 | + * @param integer $objsoc Object thirdparty |
|
| 149 | 149 | * @param Object $object Object livraison |
| 150 | 150 | * @return string Texte descripif |
| 151 | 151 | */ |
@@ -122,20 +122,29 @@ |
||
| 122 | 122 | if ($resql) |
| 123 | 123 | { |
| 124 | 124 | $obj = $db->fetch_object($resql); |
| 125 | - if ($obj) $max = intval($obj->max); |
|
| 126 | - else $max=0; |
|
| 127 | - } |
|
| 128 | - else |
|
| 125 | + if ($obj) { |
|
| 126 | + $max = intval($obj->max); |
|
| 127 | + } else { |
|
| 128 | + $max=0; |
|
| 129 | + } |
|
| 130 | + } else |
|
| 129 | 131 | { |
| 130 | 132 | return -1; |
| 131 | 133 | } |
| 132 | 134 | |
| 133 | 135 | $date=$object->date_delivery; |
| 134 | - if (empty($date)) $date=dol_now(); |
|
| 136 | + if (empty($date)) { |
|
| 137 | + $date=dol_now(); |
|
| 138 | + } |
|
| 135 | 139 | $yymm = strftime("%y%m",$date); |
| 136 | 140 | |
| 137 | - 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 |
|
| 138 | - else $num = sprintf("%04s",$max+1); |
|
| 141 | + if ($max >= (pow(10, 4) - 1)) { |
|
| 142 | + $num=$max+1; |
|
| 143 | + } |
|
| 144 | + // If counter > 9999, we do not format on 4 chars, we take number as it is |
|
| 145 | + else { |
|
| 146 | + $num = sprintf("%04s",$max+1); |
|
| 147 | + } |
|
| 139 | 148 | |
| 140 | 149 | dol_syslog("mod_livraison_jade::getNextValue return ".$this->prefix.$yymm."-".$num); |
| 141 | 150 | return $this->prefix.$yymm."-".$num; |
@@ -38,7 +38,7 @@ discard block |
||
| 38 | 38 | var $error = ''; |
| 39 | 39 | var $nom = "Jade"; |
| 40 | 40 | |
| 41 | - var $prefix='BL'; |
|
| 41 | + var $prefix='BL'; |
|
| 42 | 42 | |
| 43 | 43 | |
| 44 | 44 | /** |
@@ -55,103 +55,103 @@ discard block |
||
| 55 | 55 | /** |
| 56 | 56 | * Renvoi un exemple de numerotation |
| 57 | 57 | * |
| 58 | - * @return string Example |
|
| 59 | - */ |
|
| 60 | - function getExample() |
|
| 61 | - { |
|
| 62 | - return $this->prefix."0501-0001"; |
|
| 63 | - } |
|
| 64 | - |
|
| 65 | - /** |
|
| 66 | - * Test si les numeros deja en vigueur dans la base ne provoquent pas de |
|
| 67 | - * de conflits qui empechera cette numerotation de fonctionner. |
|
| 68 | - * |
|
| 69 | - * @return boolean false si conflit, true si ok |
|
| 70 | - */ |
|
| 71 | - function canBeActivated() |
|
| 72 | - { |
|
| 73 | - global $langs,$conf,$db; |
|
| 74 | - |
|
| 75 | - $langs->load("bills"); |
|
| 76 | - |
|
| 77 | - // Check invoice num |
|
| 78 | - $fayymm=''; $max=''; |
|
| 79 | - |
|
| 80 | - $posindice=8; |
|
| 81 | - $sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; // This is standard SQL |
|
| 82 | - $sql.= " FROM ".MAIN_DB_PREFIX."livraison"; |
|
| 83 | - $sql.= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'"; |
|
| 84 | - $sql.= " AND entity = ".$conf->entity; |
|
| 85 | - |
|
| 86 | - $resql=$db->query($sql); |
|
| 87 | - if ($resql) |
|
| 88 | - { |
|
| 89 | - $row = $db->fetch_row($resql); |
|
| 90 | - if ($row) { $fayymm = substr($row[0],0,6); $max=$row[0]; } |
|
| 91 | - } |
|
| 92 | - if ($fayymm && ! preg_match('/'.$this->prefix.'[0-9][0-9][0-9][0-9]/i',$fayymm)) |
|
| 93 | - { |
|
| 94 | - $langs->load("errors"); |
|
| 95 | - $this->error=$langs->trans('ErrorNumRefModel',$max); |
|
| 96 | - return false; |
|
| 97 | - } |
|
| 98 | - |
|
| 99 | - return true; |
|
| 100 | - } |
|
| 101 | - |
|
| 102 | - /** |
|
| 58 | + * @return string Example |
|
| 59 | + */ |
|
| 60 | + function getExample() |
|
| 61 | + { |
|
| 62 | + return $this->prefix."0501-0001"; |
|
| 63 | + } |
|
| 64 | + |
|
| 65 | + /** |
|
| 66 | + * Test si les numeros deja en vigueur dans la base ne provoquent pas de |
|
| 67 | + * de conflits qui empechera cette numerotation de fonctionner. |
|
| 68 | + * |
|
| 69 | + * @return boolean false si conflit, true si ok |
|
| 70 | + */ |
|
| 71 | + function canBeActivated() |
|
| 72 | + { |
|
| 73 | + global $langs,$conf,$db; |
|
| 74 | + |
|
| 75 | + $langs->load("bills"); |
|
| 76 | + |
|
| 77 | + // Check invoice num |
|
| 78 | + $fayymm=''; $max=''; |
|
| 79 | + |
|
| 80 | + $posindice=8; |
|
| 81 | + $sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; // This is standard SQL |
|
| 82 | + $sql.= " FROM ".MAIN_DB_PREFIX."livraison"; |
|
| 83 | + $sql.= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'"; |
|
| 84 | + $sql.= " AND entity = ".$conf->entity; |
|
| 85 | + |
|
| 86 | + $resql=$db->query($sql); |
|
| 87 | + if ($resql) |
|
| 88 | + { |
|
| 89 | + $row = $db->fetch_row($resql); |
|
| 90 | + if ($row) { $fayymm = substr($row[0],0,6); $max=$row[0]; } |
|
| 91 | + } |
|
| 92 | + if ($fayymm && ! preg_match('/'.$this->prefix.'[0-9][0-9][0-9][0-9]/i',$fayymm)) |
|
| 93 | + { |
|
| 94 | + $langs->load("errors"); |
|
| 95 | + $this->error=$langs->trans('ErrorNumRefModel',$max); |
|
| 96 | + return false; |
|
| 97 | + } |
|
| 98 | + |
|
| 99 | + return true; |
|
| 100 | + } |
|
| 101 | + |
|
| 102 | + /** |
|
| 103 | 103 | * Return next free value |
| 104 | 104 | * |
| 105 | 105 | * @param Societe $objsoc Object thirdparty |
| 106 | 106 | * @param Object $object Object we need next value for |
| 107 | 107 | * @return string Value if KO, <0 if KO |
| 108 | 108 | */ |
| 109 | - function getNextValue($objsoc,$object) |
|
| 110 | - { |
|
| 111 | - global $db,$conf; |
|
| 112 | - |
|
| 113 | - // D'abord on recupere la valeur max |
|
| 114 | - $posindice=8; |
|
| 115 | - $sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; // This is standard SQL |
|
| 116 | - $sql.= " FROM ".MAIN_DB_PREFIX."livraison"; |
|
| 117 | - $sql.= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'"; |
|
| 118 | - $sql.= " AND entity = ".$conf->entity; |
|
| 119 | - |
|
| 120 | - $resql=$db->query($sql); |
|
| 121 | - dol_syslog("mod_livraison_jade::getNextValue", LOG_DEBUG); |
|
| 122 | - if ($resql) |
|
| 123 | - { |
|
| 124 | - $obj = $db->fetch_object($resql); |
|
| 125 | - if ($obj) $max = intval($obj->max); |
|
| 126 | - else $max=0; |
|
| 127 | - } |
|
| 128 | - else |
|
| 129 | - { |
|
| 130 | - return -1; |
|
| 131 | - } |
|
| 132 | - |
|
| 133 | - $date=$object->date_delivery; |
|
| 134 | - if (empty($date)) $date=dol_now(); |
|
| 135 | - $yymm = strftime("%y%m",$date); |
|
| 136 | - |
|
| 137 | - 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 |
|
| 138 | - else $num = sprintf("%04s",$max+1); |
|
| 139 | - |
|
| 140 | - dol_syslog("mod_livraison_jade::getNextValue return ".$this->prefix.$yymm."-".$num); |
|
| 141 | - return $this->prefix.$yymm."-".$num; |
|
| 142 | - } |
|
| 109 | + function getNextValue($objsoc,$object) |
|
| 110 | + { |
|
| 111 | + global $db,$conf; |
|
| 112 | + |
|
| 113 | + // D'abord on recupere la valeur max |
|
| 114 | + $posindice=8; |
|
| 115 | + $sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; // This is standard SQL |
|
| 116 | + $sql.= " FROM ".MAIN_DB_PREFIX."livraison"; |
|
| 117 | + $sql.= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'"; |
|
| 118 | + $sql.= " AND entity = ".$conf->entity; |
|
| 119 | + |
|
| 120 | + $resql=$db->query($sql); |
|
| 121 | + dol_syslog("mod_livraison_jade::getNextValue", LOG_DEBUG); |
|
| 122 | + if ($resql) |
|
| 123 | + { |
|
| 124 | + $obj = $db->fetch_object($resql); |
|
| 125 | + if ($obj) $max = intval($obj->max); |
|
| 126 | + else $max=0; |
|
| 127 | + } |
|
| 128 | + else |
|
| 129 | + { |
|
| 130 | + return -1; |
|
| 131 | + } |
|
| 132 | + |
|
| 133 | + $date=$object->date_delivery; |
|
| 134 | + if (empty($date)) $date=dol_now(); |
|
| 135 | + $yymm = strftime("%y%m",$date); |
|
| 136 | + |
|
| 137 | + 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 |
|
| 138 | + else $num = sprintf("%04s",$max+1); |
|
| 139 | + |
|
| 140 | + dol_syslog("mod_livraison_jade::getNextValue return ".$this->prefix.$yymm."-".$num); |
|
| 141 | + return $this->prefix.$yymm."-".$num; |
|
| 142 | + } |
|
| 143 | 143 | |
| 144 | 144 | |
| 145 | 145 | /** |
| 146 | 146 | * Return next free ref |
| 147 | 147 | * |
| 148 | - * @param Societe $objsoc Object thirdparty |
|
| 149 | - * @param Object $object Object livraison |
|
| 150 | - * @return string Texte descripif |
|
| 151 | - */ |
|
| 152 | - function livraison_get_num($objsoc=0,$object='') |
|
| 153 | - { |
|
| 154 | - return $this->getNextValue($objsoc,$object); |
|
| 155 | - } |
|
| 148 | + * @param Societe $objsoc Object thirdparty |
|
| 149 | + * @param Object $object Object livraison |
|
| 150 | + * @return string Texte descripif |
|
| 151 | + */ |
|
| 152 | + function livraison_get_num($objsoc=0,$object='') |
|
| 153 | + { |
|
| 154 | + return $this->getNextValue($objsoc,$object); |
|
| 155 | + } |
|
| 156 | 156 | |
| 157 | 157 | } |
@@ -24,7 +24,7 @@ discard block |
||
| 24 | 24 | * \brief Fichier contenant la classe du modele de numerotation de reference de bon de livraison Jade |
| 25 | 25 | */ |
| 26 | 26 | |
| 27 | -require_once DOL_DOCUMENT_ROOT .'/core/modules/livraison/modules_livraison.php'; |
|
| 27 | +require_once DOL_DOCUMENT_ROOT.'/core/modules/livraison/modules_livraison.php'; |
|
| 28 | 28 | |
| 29 | 29 | |
| 30 | 30 | /** |
@@ -34,11 +34,11 @@ discard block |
||
| 34 | 34 | |
| 35 | 35 | class mod_livraison_jade extends ModeleNumRefDeliveryOrder |
| 36 | 36 | { |
| 37 | - var $version='dolibarr'; // 'development', 'experimental', 'dolibarr' |
|
| 37 | + var $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' |
|
| 38 | 38 | var $error = ''; |
| 39 | 39 | var $nom = "Jade"; |
| 40 | 40 | |
| 41 | - var $prefix='BL'; |
|
| 41 | + var $prefix = 'BL'; |
|
| 42 | 42 | |
| 43 | 43 | |
| 44 | 44 | /** |
@@ -49,7 +49,7 @@ discard block |
||
| 49 | 49 | function info() |
| 50 | 50 | { |
| 51 | 51 | global $langs; |
| 52 | - return $langs->trans("SimpleNumRefModelDesc",$this->prefix); |
|
| 52 | + return $langs->trans("SimpleNumRefModelDesc", $this->prefix); |
|
| 53 | 53 | } |
| 54 | 54 | |
| 55 | 55 | /** |
@@ -70,29 +70,29 @@ discard block |
||
| 70 | 70 | */ |
| 71 | 71 | function canBeActivated() |
| 72 | 72 | { |
| 73 | - global $langs,$conf,$db; |
|
| 73 | + global $langs, $conf, $db; |
|
| 74 | 74 | |
| 75 | 75 | $langs->load("bills"); |
| 76 | 76 | |
| 77 | 77 | // Check invoice num |
| 78 | - $fayymm=''; $max=''; |
|
| 78 | + $fayymm = ''; $max = ''; |
|
| 79 | 79 | |
| 80 | - $posindice=8; |
|
| 81 | - $sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; // This is standard SQL |
|
| 82 | - $sql.= " FROM ".MAIN_DB_PREFIX."livraison"; |
|
| 83 | - $sql.= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'"; |
|
| 84 | - $sql.= " AND entity = ".$conf->entity; |
|
| 80 | + $posindice = 8; |
|
| 81 | + $sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; // This is standard SQL |
|
| 82 | + $sql .= " FROM ".MAIN_DB_PREFIX."livraison"; |
|
| 83 | + $sql .= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'"; |
|
| 84 | + $sql .= " AND entity = ".$conf->entity; |
|
| 85 | 85 | |
| 86 | - $resql=$db->query($sql); |
|
| 86 | + $resql = $db->query($sql); |
|
| 87 | 87 | if ($resql) |
| 88 | 88 | { |
| 89 | 89 | $row = $db->fetch_row($resql); |
| 90 | - if ($row) { $fayymm = substr($row[0],0,6); $max=$row[0]; } |
|
| 90 | + if ($row) { $fayymm = substr($row[0], 0, 6); $max = $row[0]; } |
|
| 91 | 91 | } |
| 92 | - if ($fayymm && ! preg_match('/'.$this->prefix.'[0-9][0-9][0-9][0-9]/i',$fayymm)) |
|
| 92 | + if ($fayymm && !preg_match('/'.$this->prefix.'[0-9][0-9][0-9][0-9]/i', $fayymm)) |
|
| 93 | 93 | { |
| 94 | 94 | $langs->load("errors"); |
| 95 | - $this->error=$langs->trans('ErrorNumRefModel',$max); |
|
| 95 | + $this->error = $langs->trans('ErrorNumRefModel', $max); |
|
| 96 | 96 | return false; |
| 97 | 97 | } |
| 98 | 98 | |
@@ -106,36 +106,36 @@ discard block |
||
| 106 | 106 | * @param Object $object Object we need next value for |
| 107 | 107 | * @return string Value if KO, <0 if KO |
| 108 | 108 | */ |
| 109 | - function getNextValue($objsoc,$object) |
|
| 109 | + function getNextValue($objsoc, $object) |
|
| 110 | 110 | { |
| 111 | - global $db,$conf; |
|
| 111 | + global $db, $conf; |
|
| 112 | 112 | |
| 113 | 113 | // D'abord on recupere la valeur max |
| 114 | - $posindice=8; |
|
| 115 | - $sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; // This is standard SQL |
|
| 116 | - $sql.= " FROM ".MAIN_DB_PREFIX."livraison"; |
|
| 117 | - $sql.= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'"; |
|
| 118 | - $sql.= " AND entity = ".$conf->entity; |
|
| 114 | + $posindice = 8; |
|
| 115 | + $sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; // This is standard SQL |
|
| 116 | + $sql .= " FROM ".MAIN_DB_PREFIX."livraison"; |
|
| 117 | + $sql .= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'"; |
|
| 118 | + $sql .= " AND entity = ".$conf->entity; |
|
| 119 | 119 | |
| 120 | - $resql=$db->query($sql); |
|
| 120 | + $resql = $db->query($sql); |
|
| 121 | 121 | dol_syslog("mod_livraison_jade::getNextValue", LOG_DEBUG); |
| 122 | 122 | if ($resql) |
| 123 | 123 | { |
| 124 | 124 | $obj = $db->fetch_object($resql); |
| 125 | 125 | if ($obj) $max = intval($obj->max); |
| 126 | - else $max=0; |
|
| 126 | + else $max = 0; |
|
| 127 | 127 | } |
| 128 | 128 | else |
| 129 | 129 | { |
| 130 | 130 | return -1; |
| 131 | 131 | } |
| 132 | 132 | |
| 133 | - $date=$object->date_delivery; |
|
| 134 | - if (empty($date)) $date=dol_now(); |
|
| 135 | - $yymm = strftime("%y%m",$date); |
|
| 133 | + $date = $object->date_delivery; |
|
| 134 | + if (empty($date)) $date = dol_now(); |
|
| 135 | + $yymm = strftime("%y%m", $date); |
|
| 136 | 136 | |
| 137 | - 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 |
|
| 138 | - else $num = sprintf("%04s",$max+1); |
|
| 137 | + 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 |
|
| 138 | + else $num = sprintf("%04s", $max + 1); |
|
| 139 | 139 | |
| 140 | 140 | dol_syslog("mod_livraison_jade::getNextValue return ".$this->prefix.$yymm."-".$num); |
| 141 | 141 | return $this->prefix.$yymm."-".$num; |
@@ -149,9 +149,9 @@ discard block |
||
| 149 | 149 | * @param Object $object Object livraison |
| 150 | 150 | * @return string Texte descripif |
| 151 | 151 | */ |
| 152 | - function livraison_get_num($objsoc=0,$object='') |
|
| 152 | + function livraison_get_num($objsoc = 0, $object = '') |
|
| 153 | 153 | { |
| 154 | - return $this->getNextValue($objsoc,$object); |
|
| 154 | + return $this->getNextValue($objsoc, $object); |
|
| 155 | 155 | } |
| 156 | 156 | |
| 157 | 157 | } |