@@ -459,7 +459,7 @@ discard block |
||
459 | 459 | || !$this->isTrainingFirstHelpValid(); |
460 | 460 | } |
461 | 461 | |
462 | - public function isWarning(){ |
|
462 | + public function isWarning() { |
|
463 | 463 | return !$this->isHoursAndTakeOffValidGroupA() || !$this->isProValid(); |
464 | 464 | } |
465 | 465 | |
@@ -469,7 +469,7 @@ discard block |
||
469 | 469 | |
470 | 470 | $ok = '<span class="text-success text-italic">OK</span>'; |
471 | 471 | |
472 | - if($this->isPilot()){ |
|
472 | + if ($this->isPilot()) { |
|
473 | 473 | $reasons .= '<br> <span class="text-bold">Médical : </span> ' . ($this->isMedicalValid() ? $ok : 'L\'échéance est atteinte ou dépassée.'); |
474 | 474 | $reasons .= '<br> <span class="text-bold">Training flight : </span> ' . ($this->isTrainingFlightValid() ? $ok : 'Pas de vol avec un FI dans les 48 derniers mois.'); |
475 | 475 | $reasons .= '<br> <span class="text-bold">Exp. récente Gr. A: </span> ' . ($this->isHoursAndTakeOffValidGroupA() ? $ok : 'Pas 6H & 10TO dans les 24 derniers mois'); |
@@ -481,27 +481,27 @@ discard block |
||
481 | 481 | } |
482 | 482 | |
483 | 483 | |
484 | - if($this->isPilot() || $this->isTrainingFire()){ |
|
484 | + if ($this->isPilot() || $this->isTrainingFire()) { |
|
485 | 485 | $reasons .= '<br><span class="text-bold">Feu: </span> ' . ($this->isTrainingFireValid() ? $ok : 'Date expirée'); |
486 | 486 | } |
487 | 487 | |
488 | - if($this->isPilot() || $this->isTrainingFirstHelp()){ |
|
488 | + if ($this->isPilot() || $this->isTrainingFirstHelp()) { |
|
489 | 489 | $reasons .= '<br><span class="text-bold">Premiers secours: </span> ' . ($this->isTrainingFirstHelpValid() ? $ok : 'Date expirée'); |
490 | 490 | } |
491 | 491 | |
492 | 492 | |
493 | 493 | $qualification = $ok; |
494 | - if(!$this->isPilot()){ |
|
494 | + if (!$this->isPilot()) { |
|
495 | 495 | $qualification = '<span class="text-success">CREW</span>'; |
496 | 496 | } |
497 | - if($this->isWarning()){ |
|
497 | + if ($this->isWarning()) { |
|
498 | 498 | $qualification = '<span class="text-warning">Controle du carnet de vol nécessaire</span>'; |
499 | 499 | } |
500 | - if($this->isDanger()){ |
|
500 | + if ($this->isDanger()) { |
|
501 | 501 | $qualification = '<span class="text-danger">Vol non autorisé</span>'; |
502 | 502 | } |
503 | 503 | |
504 | - return '<u><span class="text-bold">Qualification </span> : ' . $qualification .'</u>'. $reasons; |
|
504 | + return '<u><span class="text-bold">Qualification </span> : ' . $qualification . '</u>' . $reasons; |
|
505 | 505 | } |
506 | 506 | |
507 | 507 | private function isMedicalValid(): bool |
@@ -510,7 +510,7 @@ discard block |
||
510 | 510 | return true; |
511 | 511 | } |
512 | 512 | |
513 | - if(null === $this->medicalEndDate){ |
|
513 | + if (null === $this->medicalEndDate) { |
|
514 | 514 | return false; |
515 | 515 | } |
516 | 516 | |
@@ -520,11 +520,11 @@ discard block |
||
520 | 520 | |
521 | 521 | private function isTrainingFlightValid(): bool |
522 | 522 | { |
523 | - if(!$this->isPilot()){ |
|
523 | + if (!$this->isPilot()) { |
|
524 | 524 | return true; |
525 | 525 | } |
526 | 526 | |
527 | - if(null === $this->lastTrainingFlightDate){ |
|
527 | + if (null === $this->lastTrainingFlightDate) { |
|
528 | 528 | return false; |
529 | 529 | } |
530 | 530 | |
@@ -533,7 +533,7 @@ discard block |
||
533 | 533 | |
534 | 534 | private function isHoursAndTakeOffValidGroupA(): bool |
535 | 535 | { |
536 | - if(!$this->isPilot()){ |
|
536 | + if (!$this->isPilot()) { |
|
537 | 537 | return true; |
538 | 538 | } |
539 | 539 | |
@@ -560,7 +560,7 @@ discard block |
||
560 | 560 | |
561 | 561 | private function isProDateValid(): bool |
562 | 562 | { |
563 | - if(!$this->isPilot()){ |
|
563 | + if (!$this->isPilot()) { |
|
564 | 564 | return true; |
565 | 565 | } |
566 | 566 | |
@@ -574,7 +574,7 @@ discard block |
||
574 | 574 | |
575 | 575 | private function isProValid(): bool |
576 | 576 | { |
577 | - if(!$this->isPilot()){ |
|
577 | + if (!$this->isPilot()) { |
|
578 | 578 | return true; |
579 | 579 | } |
580 | 580 | |
@@ -582,7 +582,7 @@ discard block |
||
582 | 582 | return true; |
583 | 583 | } |
584 | 584 | |
585 | - if($this->lastOpcDate && $this->diffDateInMonths($this->lastOpcDate) < 6){ |
|
585 | + if ($this->lastOpcDate && $this->diffDateInMonths($this->lastOpcDate) < 6) { |
|
586 | 586 | return true; |
587 | 587 | } |
588 | 588 | |
@@ -602,7 +602,7 @@ discard block |
||
602 | 602 | } |
603 | 603 | |
604 | 604 | private function diffDateInMonths(\DateTimeImmutable $dateA, \DateTimeImmutable $dateB = null): int{ |
605 | - if(null === $dateB){ |
|
605 | + if (null === $dateB) { |
|
606 | 606 | $dateB = new \DateTimeImmutable(); |
607 | 607 | } |
608 | 608 | |
@@ -612,11 +612,11 @@ discard block |
||
612 | 612 | |
613 | 613 | private function isTrainingFireValid() |
614 | 614 | { |
615 | - if(!$this->isTrainingFire() && !$this->isPilot()){ |
|
615 | + if (!$this->isTrainingFire() && !$this->isPilot()) { |
|
616 | 616 | return true; |
617 | 617 | } |
618 | 618 | |
619 | - if(null === $this->lastTrainingFireDate){ |
|
619 | + if (null === $this->lastTrainingFireDate) { |
|
620 | 620 | return false; |
621 | 621 | } |
622 | 622 | |
@@ -625,11 +625,11 @@ discard block |
||
625 | 625 | |
626 | 626 | private function isTrainingFirstHelpValid() |
627 | 627 | { |
628 | - if(!$this->isTrainingFirstHelp() && !$this->isPilot() ){ |
|
628 | + if (!$this->isTrainingFirstHelp() && !$this->isPilot()) { |
|
629 | 629 | return true; |
630 | 630 | } |
631 | 631 | |
632 | - if(null === $this->lastTrainingFirstHelpDate){ |
|
632 | + if (null === $this->lastTrainingFirstHelpDate) { |
|
633 | 633 | return false; |
634 | 634 | } |
635 | 635 |
@@ -31,7 +31,7 @@ discard block |
||
31 | 31 | * |
32 | 32 | * @return Pilot |
33 | 33 | */ |
34 | - public function byId($id){ |
|
34 | + public function byId($id) { |
|
35 | 35 | $pilots = $this->filter(['id' => $id]); |
36 | 36 | if (empty($pilots)) { |
37 | 37 | return Pilot::fromArray(['id' => $id]); |
@@ -90,8 +90,8 @@ discard block |
||
90 | 90 | )) |
91 | 91 | '; |
92 | 92 | |
93 | - if(isset($filters['id'])){ |
|
94 | - $sql .= ' AND llx_user.rowid = '.$filters['id']; |
|
93 | + if (isset($filters['id'])) { |
|
94 | + $sql .= ' AND llx_user.rowid = ' . $filters['id']; |
|
95 | 95 | } |
96 | 96 | $sql .= ' ORDER BY llx_user.firstname, llx_user.lastname, llx_user.rowid, flight.date'; |
97 | 97 | |
@@ -107,16 +107,16 @@ discard block |
||
107 | 107 | |
108 | 108 | /** @var Pilot[] $pilots */ |
109 | 109 | $pilots = []; |
110 | - for($i = 0; $i < $num ; $i++) { |
|
110 | + for ($i = 0; $i < $num; $i++) { |
|
111 | 111 | $values = $this->db->fetch_array($resql); |
112 | 112 | $pilotId = $values['id']; |
113 | 113 | |
114 | - if(!isset($pilots[$pilotId])){ |
|
114 | + if (!isset($pilots[$pilotId])) { |
|
115 | 115 | $pilots[$pilotId] = Pilot::fromArray($values); |
116 | 116 | } |
117 | 117 | |
118 | 118 | $flight = PilotFlight::fromArray($values, 'flight'); |
119 | - if($flight->isValid()){ |
|
119 | + if ($flight->isValid()) { |
|
120 | 120 | $pilots[$pilotId]->addFlight($flight); |
121 | 121 | } |
122 | 122 |
@@ -129,7 +129,7 @@ discard block |
||
129 | 129 | */ |
130 | 130 | public function getIdBBCVols() |
131 | 131 | { |
132 | - return (int)$this->idBBC_vols; |
|
132 | + return (int) $this->idBBC_vols; |
|
133 | 133 | } |
134 | 134 | |
135 | 135 | /** |
@@ -137,7 +137,7 @@ discard block |
||
137 | 137 | */ |
138 | 138 | public function getId() |
139 | 139 | { |
140 | - return (int)$this->getIdBBCVols(); |
|
140 | + return (int) $this->getIdBBCVols(); |
|
141 | 141 | } |
142 | 142 | |
143 | 143 | /** |
@@ -274,13 +274,13 @@ discard block |
||
274 | 274 | $sql .= ' ' . (!isset($this->nbrPax) ? 'NULL' : "'" . $this->db->escape($this->nbrPax) . "'") . ','; |
275 | 275 | $sql .= ' ' . (!isset($this->remarque) ? 'NULL' : "'" . $this->db->escape($this->remarque) . "'") . ','; |
276 | 276 | $sql .= ' ' . (!isset($this->incidents) ? 'NULL' : "'" . $this->db->escape($this->incidents) . "'") . ','; |
277 | - $sql .= ' ' . (!isset($this->fk_type) || (int)$this->fk_type === -1 ? 'NULL' : $this->fk_type) . ','; |
|
278 | - $sql .= ' ' . (!isset($this->fk_pilot) || (int)$this->fk_pilot === -1 ? 'NULL' : $this->fk_pilot) . ','; |
|
279 | - $sql .= ' ' . (!isset($this->fk_organisateur) || (int)$this->fk_organisateur === -1 ? 'NULL' : $this->fk_organisateur) . ','; |
|
277 | + $sql .= ' ' . (!isset($this->fk_type) || (int) $this->fk_type === -1 ? 'NULL' : $this->fk_type) . ','; |
|
278 | + $sql .= ' ' . (!isset($this->fk_pilot) || (int) $this->fk_pilot === -1 ? 'NULL' : $this->fk_pilot) . ','; |
|
279 | + $sql .= ' ' . (!isset($this->fk_organisateur) || (int) $this->fk_organisateur === -1 ? 'NULL' : $this->fk_organisateur) . ','; |
|
280 | 280 | $sql .= ' ' . (!isset($this->is_facture) ? '0' : $this->is_facture) . ','; |
281 | 281 | $sql .= ' ' . (!isset($this->kilometers) || empty($this->kilometers) ? '0' : $this->kilometers) . ','; |
282 | 282 | $sql .= ' ' . (!isset($this->cost) ? 'NULL' : "'" . $this->db->escape($this->cost) . "'") . ','; |
283 | - $sql .= ' ' . (!isset($this->fk_receiver) || (int)$this->fk_receiver === -1 ? 'NULL' : $this->fk_receiver) . ','; |
|
283 | + $sql .= ' ' . (!isset($this->fk_receiver) || (int) $this->fk_receiver === -1 ? 'NULL' : $this->fk_receiver) . ','; |
|
284 | 284 | $sql .= ' ' . (!isset($this->justif_kilometers) ? 'NULL' : "'" . $this->db->escape($this->justif_kilometers) . "'") . ','; |
285 | 285 | $sql .= ' ' . "'" . date('Y-m-d H:i:s') . "'" . ','; |
286 | 286 | $sql .= ' ' . "'" . date('Y-m-d H:i:s') . "'" . ','; |
@@ -455,23 +455,23 @@ discard block |
||
455 | 455 | |
456 | 456 | $this->id = $obj->idBBC_vols; |
457 | 457 | |
458 | - $this->idBBC_vols = (int)$obj->idBBC_vols; |
|
458 | + $this->idBBC_vols = (int) $obj->idBBC_vols; |
|
459 | 459 | $this->date = $this->db->jdate($obj->date); |
460 | 460 | $this->lieuD = $obj->lieuD; |
461 | 461 | $this->lieuA = $obj->lieuA; |
462 | 462 | $this->heureD = $obj->heureD; |
463 | 463 | $this->heureA = $obj->heureA; |
464 | - $this->BBC_ballons_idBBC_ballons = (int)$obj->BBC_ballons_idBBC_ballons; |
|
464 | + $this->BBC_ballons_idBBC_ballons = (int) $obj->BBC_ballons_idBBC_ballons; |
|
465 | 465 | $this->nbrPax = $obj->nbrPax; |
466 | 466 | $this->remarque = $obj->remarque; |
467 | 467 | $this->incidents = $obj->incidents; |
468 | - $this->fk_type = (int)$obj->fk_type; |
|
469 | - $this->fk_pilot = (int)$obj->fk_pilot; |
|
470 | - $this->fk_organisateur = (int)$obj->fk_organisateur; |
|
471 | - $this->statut = $this->is_facture = (int)$obj->is_facture; |
|
468 | + $this->fk_type = (int) $obj->fk_type; |
|
469 | + $this->fk_pilot = (int) $obj->fk_pilot; |
|
470 | + $this->fk_organisateur = (int) $obj->fk_organisateur; |
|
471 | + $this->statut = $this->is_facture = (int) $obj->is_facture; |
|
472 | 472 | $this->kilometers = $obj->kilometers; |
473 | 473 | $this->total_ttc = $this->cost = $obj->cost; |
474 | - $this->fk_receiver = (int)$obj->fk_receiver; |
|
474 | + $this->fk_receiver = (int) $obj->fk_receiver; |
|
475 | 475 | $this->justif_kilometers = $obj->justif_kilometers; |
476 | 476 | $this->date_creation = $obj->date_creation; |
477 | 477 | $this->date_update = $obj->date_update; |
@@ -587,13 +587,13 @@ discard block |
||
587 | 587 | $sql .= ' nbrPax = ' . (isset($this->nbrPax) ? "'" . $this->db->escape($this->nbrPax) . "'" : "null") . ','; |
588 | 588 | $sql .= ' remarque = ' . (isset($this->remarque) ? "'" . $this->db->escape($this->remarque) . "'" : "null") . ','; |
589 | 589 | $sql .= ' incidents = ' . (isset($this->incidents) ? "'" . $this->db->escape($this->incidents) . "'" : "null") . ','; |
590 | - $sql .= ' fk_type = ' . (isset($this->fk_type) && (int)$this->fk_type > 0 ? $this->fk_type : "null") . ','; |
|
591 | - $sql .= ' fk_pilot = ' . (isset($this->fk_pilot) && (int)$this->fk_pilot > 0 ? $this->fk_pilot : "null") . ','; |
|
592 | - $sql .= ' fk_organisateur = ' . (isset($this->fk_organisateur) && (int)$this->fk_organisateur > 0 ? $this->fk_organisateur : "null") . ','; |
|
590 | + $sql .= ' fk_type = ' . (isset($this->fk_type) && (int) $this->fk_type > 0 ? $this->fk_type : "null") . ','; |
|
591 | + $sql .= ' fk_pilot = ' . (isset($this->fk_pilot) && (int) $this->fk_pilot > 0 ? $this->fk_pilot : "null") . ','; |
|
592 | + $sql .= ' fk_organisateur = ' . (isset($this->fk_organisateur) && (int) $this->fk_organisateur > 0 ? $this->fk_organisateur : "null") . ','; |
|
593 | 593 | $sql .= ' is_facture = ' . (isset($this->is_facture) ? $this->is_facture : "0") . ','; |
594 | 594 | $sql .= ' kilometers = ' . (!empty($this->kilometers) ? $this->kilometers : "0") . ','; |
595 | 595 | $sql .= ' cost = ' . (isset($this->cost) ? "'" . $this->db->escape($this->cost) . "'" : "''") . ','; |
596 | - $sql .= ' fk_receiver = ' . (isset($this->fk_receiver) && (int)$this->fk_receiver > 0 ? $this->fk_receiver : "null") . ','; |
|
596 | + $sql .= ' fk_receiver = ' . (isset($this->fk_receiver) && (int) $this->fk_receiver > 0 ? $this->fk_receiver : "null") . ','; |
|
597 | 597 | $sql .= ' justif_kilometers = ' . (isset($this->justif_kilometers) ? "'" . $this->db->escape($this->justif_kilometers) . "'," : "'',"); |
598 | 598 | $sql .= ' date_update = ' . "'" . date('Y-m-d H:i:s') . "',"; |
599 | 599 | $sql .= ' is_night = ' . ($this->nightFlight ? 1 : 0) . ','; |
@@ -701,9 +701,9 @@ discard block |
||
701 | 701 | |
702 | 702 | $label = '<u>' . $langs->trans("MyModule") . '</u>'; |
703 | 703 | $label .= '<div width="100%">'; |
704 | - $label .= '<b>' . $langs->trans('Ref') . ':</b> ' . $this->idBBC_vols . ' - <b>'.$langs->trans('T') . '</b>' . $this->fk_type . '<br>'; |
|
704 | + $label .= '<b>' . $langs->trans('Ref') . ':</b> ' . $this->idBBC_vols . ' - <b>' . $langs->trans('T') . '</b>' . $this->fk_type . '<br>'; |
|
705 | 705 | $label .= '<b>' . $langs->trans('Date') . ':</b> ' . dol_print_date($this->date, '%d-%m-%Y') . '<br/>'; |
706 | - $label .= '<b>' . $langs->trans('De') . ':</b> ' . $this->lieuD . ' - '. '<b>' . $langs->trans('à') . ':</b> ' . $this->lieuA . '<br/>'; |
|
706 | + $label .= '<b>' . $langs->trans('De') . ':</b> ' . $this->lieuD . ' - ' . '<b>' . $langs->trans('à') . ':</b> ' . $this->lieuA . '<br/>'; |
|
707 | 707 | $label .= '<b>' . $langs->trans('Pilote') . ':</b> ' . $this->getPilot()->getFullName($langs) . '<br/>'; |
708 | 708 | $label .= '<b>' . $langs->trans('Organisateur') . ':</b> ' . $this->getOrganisator()->getFullName($langs) . '<br/>'; |
709 | 709 | $label .= '</div>'; |
@@ -903,7 +903,7 @@ discard block |
||
903 | 903 | */ |
904 | 904 | public function getPilotId() |
905 | 905 | { |
906 | - return (int)$this->fk_pilot; |
|
906 | + return (int) $this->fk_pilot; |
|
907 | 907 | } |
908 | 908 | |
909 | 909 | /** |
@@ -911,7 +911,7 @@ discard block |
||
911 | 911 | */ |
912 | 912 | public function getOrganisatorId() |
913 | 913 | { |
914 | - return (int)$this->fk_organisateur; |
|
914 | + return (int) $this->fk_organisateur; |
|
915 | 915 | } |
916 | 916 | |
917 | 917 | /** |
@@ -948,7 +948,7 @@ discard block |
||
948 | 948 | */ |
949 | 949 | public function hasPax() |
950 | 950 | { |
951 | - return (int)$this->nbrPax > 0; |
|
951 | + return (int) $this->nbrPax > 0; |
|
952 | 952 | } |
953 | 953 | |
954 | 954 | /** |
@@ -1017,7 +1017,7 @@ discard block |
||
1017 | 1017 | */ |
1018 | 1018 | public function getKilometers() |
1019 | 1019 | { |
1020 | - return (int)$this->kilometers; |
|
1020 | + return (int) $this->kilometers; |
|
1021 | 1021 | } |
1022 | 1022 | |
1023 | 1023 | /** |
@@ -1060,7 +1060,7 @@ discard block |
||
1060 | 1060 | */ |
1061 | 1061 | public function getNumberOfPassengers() |
1062 | 1062 | { |
1063 | - return (int)$this->nbrPax; |
|
1063 | + return (int) $this->nbrPax; |
|
1064 | 1064 | } |
1065 | 1065 | |
1066 | 1066 | /** |
@@ -1263,7 +1263,7 @@ discard block |
||
1263 | 1263 | */ |
1264 | 1264 | public function getBBCBallonsIdBBCBallons() |
1265 | 1265 | { |
1266 | - return (int)$this->BBC_ballons_idBBC_ballons; |
|
1266 | + return (int) $this->BBC_ballons_idBBC_ballons; |
|
1267 | 1267 | } |
1268 | 1268 | |
1269 | 1269 | /** |
@@ -1339,7 +1339,7 @@ discard block |
||
1339 | 1339 | */ |
1340 | 1340 | public function getFkType() |
1341 | 1341 | { |
1342 | - return (int)$this->fk_type; |
|
1342 | + return (int) $this->fk_type; |
|
1343 | 1343 | } |
1344 | 1344 | |
1345 | 1345 | /** |
@@ -1434,7 +1434,7 @@ discard block |
||
1434 | 1434 | */ |
1435 | 1435 | public function getFkReceiver() |
1436 | 1436 | { |
1437 | - return (int)$this->fk_receiver; |
|
1437 | + return (int) $this->fk_receiver; |
|
1438 | 1438 | } |
1439 | 1439 | |
1440 | 1440 | /** |
@@ -220,7 +220,7 @@ |
||
220 | 220 | |
221 | 221 | $orderId = $this->order->create($this->user); |
222 | 222 | if ($orderId <= 0) { |
223 | - throw new Exception('Exception during the order creation ('.$this->order->error.')'); |
|
223 | + throw new Exception('Exception during the order creation (' . $this->order->error . ')'); |
|
224 | 224 | } |
225 | 225 | |
226 | 226 | return $this; |
@@ -153,10 +153,10 @@ discard block |
||
153 | 153 | $tableQueryHandler = new BillableFlightQueryHandler($db, $conf->global); |
154 | 154 | $pilotQueryRepository = new PilotQueryRepository($db); |
155 | 155 | |
156 | -function pilotStatus($id){ |
|
156 | +function pilotStatus($id) { |
|
157 | 157 | global $pilotQueryRepository; |
158 | 158 | $member = $pilotQueryRepository->byId($id); |
159 | - if($member === null){ |
|
159 | + if ($member === null) { |
|
160 | 160 | return ''; |
161 | 161 | } |
162 | 162 | |
@@ -201,7 +201,7 @@ discard block |
||
201 | 201 | print '<td>' . $pilot->getCountForType('orga_T6')->getCount() . '</td>'; |
202 | 202 | print '<td>' . $pilot->getCountForType('orga_T6')->getCost()->getValue() . '</td>'; |
203 | 203 | |
204 | - print sprintf('<td class="%s">', $pilot->getFlightBonus()->getValue() === 0?'text-muted':'text-bold'). $pilot->getFlightBonus()->getValue() . ' pts</td>'; |
|
204 | + print sprintf('<td class="%s">', $pilot->getFlightBonus()->getValue() === 0 ? 'text-muted' : 'text-bold') . $pilot->getFlightBonus()->getValue() . ' pts</td>'; |
|
205 | 205 | |
206 | 206 | print '<td>' . $pilot->getCountForType('3')->getCount() . '</td>'; |
207 | 207 | print '<td>' . price($pilot->getCountForType('3')->getCost()->getValue()) . '€</td>'; |
@@ -220,8 +220,8 @@ discard block |
||
220 | 220 | print '<td>' . price($pilot->damageCost()->getValue()) . '€</td>'; |
221 | 221 | print '<td>' . price($pilot->invoicedDamageCost()->getValue()) . '€</td>'; |
222 | 222 | |
223 | - print sprintf('<td class="%s">', $pilot->getFlightsCost()->getValue() === 0?'text-muted':'text-bold'). price($pilot->getFlightsCost()->getValue()) . '€ </td>'; |
|
224 | - print sprintf('<td class="%s">', $pilot->isBillable(FlightBonus::zero())?'text-bold':'text-muted'). price($pilot->getTotalBill()->getValue()) . '€</td>'; |
|
223 | + print sprintf('<td class="%s">', $pilot->getFlightsCost()->getValue() === 0 ? 'text-muted' : 'text-bold') . price($pilot->getFlightsCost()->getValue()) . '€ </td>'; |
|
224 | + print sprintf('<td class="%s">', $pilot->isBillable(FlightBonus::zero()) ? 'text-bold' : 'text-muted') . price($pilot->getTotalBill()->getValue()) . '€</td>'; |
|
225 | 225 | print '</tr>'; |
226 | 226 | } |
227 | 227 | |
@@ -246,7 +246,7 @@ discard block |
||
246 | 246 | print '<td>' . $totalT3 . '</td>'; |
247 | 247 | print '<td></td>'; |
248 | 248 | |
249 | -print '<td>' . $totalT4. '</td>'; |
|
249 | +print '<td>' . $totalT4 . '</td>'; |
|
250 | 250 | print '<td></td>'; |
251 | 251 | |
252 | 252 | print '<td>' . $totalT5 . '</td>'; |
@@ -275,7 +275,7 @@ discard block |
||
275 | 275 | //table km |
276 | 276 | $tauxRemb = isset($conf->global->BBC_FLIGHT_LOG_TAUX_REMB_KM) ? $conf->global->BBC_FLIGHT_LOG_TAUX_REMB_KM : 0; |
277 | 277 | $year = GETPOST("year", 'int'); |
278 | -if(empty($year)){ |
|
278 | +if (empty($year)) { |
|
279 | 279 | $year = date('Y'); |
280 | 280 | } |
281 | 281 |
@@ -81,7 +81,7 @@ |
||
81 | 81 | $amount = $properties['amount']; |
82 | 82 | $id = $properties['id']; |
83 | 83 | $flightId = isset($properties['flight_id']) ? $properties['flight_id'] : null; |
84 | - $invoiced = (bool)$properties['invoiced']; |
|
84 | + $invoiced = (bool) $properties['invoiced']; |
|
85 | 85 | |
86 | 86 | return new self($authorId, $author, $amount, $id, $invoiced, $flightId, $label); |
87 | 87 | } |
@@ -24,7 +24,7 @@ |
||
24 | 24 | <?php echo $renderer->render($damageCreationForm->getElement('flight_id')); ?> |
25 | 25 | <?php echo $renderer->render($damageCreationForm->getElement('token')); ?> |
26 | 26 | |
27 | - <?php if($damageCreationForm->has('amount')): ?> |
|
27 | + <?php if ($damageCreationForm->has('amount')): ?> |
|
28 | 28 | <section class="form-section"> |
29 | 29 | <h1 class="form-section-title"><?php echo $langs->trans('Ajout de dégâts'); ?></h1> |
30 | 30 | <table class="border" width="50%"> |
@@ -15,28 +15,28 @@ discard block |
||
15 | 15 | /** |
16 | 16 | * Display the form. |
17 | 17 | */ |
18 | - public function view(){ |
|
18 | + public function view() { |
|
19 | 19 | $damageCreationForm = new DamageCreationForm('damage_creation', $this->db); |
20 | 20 | $damageCreationForm->bind(CreateDamageCommand::create()); |
21 | 21 | |
22 | - if($this->request->isPost()){ |
|
22 | + if ($this->request->isPost()) { |
|
23 | 23 | $damageCreationForm->setData($this->request->getPostParameters()); |
24 | 24 | |
25 | - if(!$damageCreationForm->validate()){ |
|
25 | + if (!$damageCreationForm->validate()) { |
|
26 | 26 | return $this->render('damage/form.php', [ |
27 | 27 | 'form' => $damageCreationForm, |
28 | 28 | ]); |
29 | 29 | } |
30 | 30 | $this->handle($damageCreationForm->getObject()); |
31 | - try{ |
|
31 | + try { |
|
32 | 32 | |
33 | - }catch(\Exception $e){ |
|
33 | + } catch (\Exception $e) { |
|
34 | 34 | print $e->getMessage(); |
35 | 35 | dol_syslog($e->getMessage(), LOG_ERR); |
36 | 36 | } |
37 | 37 | |
38 | 38 | |
39 | - return $this->redirect($_SERVER["PHP_SELF"].'?r=get_damages'); |
|
39 | + return $this->redirect($_SERVER["PHP_SELF"] . '?r=get_damages'); |
|
40 | 40 | } |
41 | 41 | |
42 | 42 | return $this->render('damage/form.php', [ |
@@ -57,14 +57,14 @@ discard block |
||
57 | 57 | /** |
58 | 58 | * @return CreateDamageCommandHandler |
59 | 59 | */ |
60 | - private function getHandler(){ |
|
60 | + private function getHandler() { |
|
61 | 61 | return new CreateDamageCommandHandler($this->db, $this->getDamageRepository()); |
62 | 62 | } |
63 | 63 | |
64 | 64 | /** |
65 | 65 | * @return FlightDamageRepository |
66 | 66 | */ |
67 | - private function getDamageRepository(){ |
|
67 | + private function getDamageRepository() { |
|
68 | 68 | return new FlightDamageRepository($this->db); |
69 | 69 | } |
70 | 70 |
@@ -30,7 +30,7 @@ |
||
30 | 30 | $this->handle($damageCreationForm->getObject()); |
31 | 31 | try{ |
32 | 32 | |
33 | - }catch(\Exception $e){ |
|
33 | + } catch(\Exception $e){ |
|
34 | 34 | print $e->getMessage(); |
35 | 35 | dol_syslog($e->getMessage(), LOG_ERR); |
36 | 36 | } |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | public function __construct(\DoliDB $db, $tableName) |
24 | 24 | { |
25 | 25 | $this->db = $db; |
26 | - $this->tableName = strpos($tableName, MAIN_DB_PREFIX) === 0 ? $tableName : MAIN_DB_PREFIX.$tableName; |
|
26 | + $this->tableName = strpos($tableName, MAIN_DB_PREFIX) === 0 ? $tableName : MAIN_DB_PREFIX . $tableName; |
|
27 | 27 | } |
28 | 28 | |
29 | 29 | /** |
@@ -33,10 +33,10 @@ discard block |
||
33 | 33 | * |
34 | 34 | * @throws \Exception |
35 | 35 | */ |
36 | - protected function write(array $elements){ |
|
36 | + protected function write(array $elements) { |
|
37 | 37 | $columns = join(',', array_keys($elements)); |
38 | 38 | $values = []; |
39 | - foreach($elements as $col => $val){ |
|
39 | + foreach ($elements as $col => $val) { |
|
40 | 40 | $values[] = $this->escape($val); |
41 | 41 | } |
42 | 42 | $values = join(',', $values); |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | $lasterror = $this->db->lasterror(); |
50 | 50 | dol_syslog(__METHOD__ . ' ' . $lasterror, LOG_ERR); |
51 | 51 | $this->db->rollback(); |
52 | - throw new \Exception("Repository error - ".$lasterror. ' ('.$sql.')'); |
|
52 | + throw new \Exception("Repository error - " . $lasterror . ' (' . $sql . ')'); |
|
53 | 53 | } |
54 | 54 | |
55 | 55 | $id = $this->db->last_insert_id($this->tableName); |
@@ -62,16 +62,16 @@ discard block |
||
62 | 62 | * |
63 | 63 | * @return int|string|null |
64 | 64 | */ |
65 | - private function escape($value){ |
|
66 | - if((is_null($value) || null == $value) && !is_bool($value)){ |
|
65 | + private function escape($value) { |
|
66 | + if ((is_null($value) || null == $value) && !is_bool($value)) { |
|
67 | 67 | return 'NULL'; |
68 | 68 | } |
69 | 69 | |
70 | - if(is_bool($value)){ |
|
71 | - return (int)$value; |
|
70 | + if (is_bool($value)) { |
|
71 | + return (int) $value; |
|
72 | 72 | } |
73 | 73 | |
74 | - return is_string($value) ? "'".$this->db->escape($value)."'" : $value ; |
|
74 | + return is_string($value) ? "'" . $this->db->escape($value) . "'" : $value; |
|
75 | 75 | } |
76 | 76 | |
77 | 77 | /** |
@@ -84,18 +84,18 @@ discard block |
||
84 | 84 | { |
85 | 85 | $sqlModifications = []; |
86 | 86 | |
87 | - foreach($elements as $field => $value){ |
|
87 | + foreach ($elements as $field => $value) { |
|
88 | 88 | $sqlModifications[] = sprintf('%s=%s', $field, $this->escape($value)); |
89 | 89 | } |
90 | 90 | |
91 | 91 | $this->db->begin(); |
92 | - $resql = $this->db->query(sprintf('UPDATE %s SET %s WHERE '.$idCol.' = %s ', $this->tableName, join(',',$sqlModifications), $id)); |
|
92 | + $resql = $this->db->query(sprintf('UPDATE %s SET %s WHERE ' . $idCol . ' = %s ', $this->tableName, join(',', $sqlModifications), $id)); |
|
93 | 93 | |
94 | 94 | if (!$resql) { |
95 | 95 | $lasterror = $this->db->lasterror(); |
96 | 96 | dol_syslog(__METHOD__ . ' ' . $lasterror, LOG_ERR); |
97 | 97 | $this->db->rollback(); |
98 | - throw new \Exception("Repository error - ".$lasterror); |
|
98 | + throw new \Exception("Repository error - " . $lasterror); |
|
99 | 99 | } |
100 | 100 | |
101 | 101 | $this->db->commit(); |
@@ -109,8 +109,8 @@ discard block |
||
109 | 109 | * |
110 | 110 | * @return array|null |
111 | 111 | */ |
112 | - protected function get($id, $idCol = 'rowid'){ |
|
113 | - $sql = sprintf('SELECT * FROM %s WHERE '.$idCol.' = %s', $this->tableName, $id ); |
|
112 | + protected function get($id, $idCol = 'rowid') { |
|
113 | + $sql = sprintf('SELECT * FROM %s WHERE ' . $idCol . ' = %s', $this->tableName, $id); |
|
114 | 114 | |
115 | 115 | $resql = $this->db->query($sql); |
116 | 116 | if (!$resql) { |
@@ -122,7 +122,7 @@ discard block |
||
122 | 122 | return null; |
123 | 123 | } |
124 | 124 | |
125 | - for($i = 0; $i < $num ; $i++) { |
|
125 | + for ($i = 0; $i < $num; $i++) { |
|
126 | 126 | return $this->db->fetch_array($resql); |
127 | 127 | } |
128 | 128 |