@@ -19,16 +19,16 @@ discard block |
||
| 19 | 19 | /** |
| 20 | 20 | * Display the form. |
| 21 | 21 | */ |
| 22 | - public function view(){ |
|
| 22 | + public function view() { |
|
| 23 | 23 | $id = $this->request->getParam('id'); |
| 24 | 24 | |
| 25 | - if($id === null){ |
|
| 25 | + if ($id === null) { |
|
| 26 | 26 | print '<p>Paramètre non fournis.</p>'; |
| 27 | 27 | return; |
| 28 | 28 | } |
| 29 | 29 | |
| 30 | 30 | $flight = new \Bbcvols($this->db); |
| 31 | - if($flight->fetch($id) <= 0){ |
|
| 31 | + if ($flight->fetch($id) <= 0) { |
|
| 32 | 32 | print '<p>Vol non trouvé</p>'; |
| 33 | 33 | return; |
| 34 | 34 | } |
@@ -37,24 +37,24 @@ discard block |
||
| 37 | 37 | $form = new DamageCreationForm('damage_creation', $this->db); |
| 38 | 38 | $form->bind($command); |
| 39 | 39 | |
| 40 | - if($this->request->isPost()){ |
|
| 40 | + if ($this->request->isPost()) { |
|
| 41 | 41 | $form->setData($this->request->getPostParameters()); |
| 42 | 42 | |
| 43 | - if(!$form->validate()){ |
|
| 43 | + if (!$form->validate()) { |
|
| 44 | 44 | return $this->render('flight_damage/form.php', [ |
| 45 | 45 | 'form' => $form, |
| 46 | 46 | ]); |
| 47 | 47 | } |
| 48 | 48 | |
| 49 | - try{ |
|
| 49 | + try { |
|
| 50 | 50 | $this->handle($form->getObject()); |
| 51 | - }catch(\Exception $e){ |
|
| 51 | + } catch (\Exception $e) { |
|
| 52 | 52 | print $e->getMessage(); |
| 53 | 53 | dol_syslog($e->getMessage(), LOG_ERR); |
| 54 | 54 | } |
| 55 | 55 | |
| 56 | 56 | |
| 57 | - $this->redirect($_SERVER["PHP_SELF"].'?id='.$id); |
|
| 57 | + $this->redirect($_SERVER["PHP_SELF"] . '?id=' . $id); |
|
| 58 | 58 | exit; |
| 59 | 59 | } |
| 60 | 60 | |
@@ -76,14 +76,14 @@ discard block |
||
| 76 | 76 | /** |
| 77 | 77 | * @return CreateDamageCommandHandler |
| 78 | 78 | */ |
| 79 | - private function getHandler(){ |
|
| 79 | + private function getHandler() { |
|
| 80 | 80 | return new CreateDamageCommandHandler($this->db, $this->getDamageRepository()); |
| 81 | 81 | } |
| 82 | 82 | |
| 83 | 83 | /** |
| 84 | 84 | * @return FlightDamageRepository |
| 85 | 85 | */ |
| 86 | - private function getDamageRepository(){ |
|
| 86 | + private function getDamageRepository() { |
|
| 87 | 87 | return new FlightDamageRepository($this->db); |
| 88 | 88 | } |
| 89 | 89 | |
@@ -48,7 +48,7 @@ |
||
| 48 | 48 | |
| 49 | 49 | try{ |
| 50 | 50 | $this->handle($form->getObject()); |
| 51 | - }catch(\Exception $e){ |
|
| 51 | + } catch(\Exception $e){ |
|
| 52 | 52 | print $e->getMessage(); |
| 53 | 53 | dol_syslog($e->getMessage(), LOG_ERR); |
| 54 | 54 | } |
@@ -24,7 +24,7 @@ |
||
| 24 | 24 | * |
| 25 | 25 | * @return Id |
| 26 | 26 | */ |
| 27 | - public static function create($id){ |
|
| 27 | + public static function create($id) { |
|
| 28 | 28 | return new self($id); |
| 29 | 29 | } |
| 30 | 30 | |
@@ -53,7 +53,7 @@ |
||
| 53 | 53 | * @return array |
| 54 | 54 | */ |
| 55 | 55 | public function toArray() { |
| 56 | - return array_map(function(Tab $tab){ |
|
| 56 | + return array_map(function(Tab $tab) { |
|
| 57 | 57 | return $tab->toArray(); |
| 58 | 58 | }, $this->tabs); |
| 59 | 59 | } |
@@ -55,7 +55,7 @@ |
||
| 55 | 55 | */ |
| 56 | 56 | private function linkSupplierInvoice($flightId, $invoiceId) |
| 57 | 57 | { |
| 58 | - if($invoiceId <= 0){ |
|
| 58 | + if ($invoiceId <= 0) { |
|
| 59 | 59 | return; |
| 60 | 60 | } |
| 61 | 61 | |
@@ -90,7 +90,7 @@ |
||
| 90 | 90 | $actionName = $routes[$action][1]; |
| 91 | 91 | |
| 92 | 92 | call_user_func([new $controllerName($db), $actionName]); |
| 93 | - }else{ |
|
| 93 | + } else{ |
|
| 94 | 94 | echo 'Route non trouvée.'; |
| 95 | 95 | } |
| 96 | 96 | ?> |
@@ -49,7 +49,7 @@ discard block |
||
| 49 | 49 | |
| 50 | 50 | $id = GETPOST('id', 'int') ?: GETPOST('idBBC_vols', 'int'); |
| 51 | 51 | $action = GETPOST('action', 'alpha'); |
| 52 | -$permissiondellink=$user->rights->flightlog->vol->financial; |
|
| 52 | +$permissiondellink = $user->rights->flightlog->vol->financial; |
|
| 53 | 53 | |
| 54 | 54 | $object = new Bbcvols($db); |
| 55 | 55 | |
@@ -57,8 +57,8 @@ discard block |
||
| 57 | 57 | $extralabels = $extrafields->fetch_name_optionals_label($object->table_element); |
| 58 | 58 | |
| 59 | 59 | // Load object |
| 60 | -include DOL_DOCUMENT_ROOT . '/core/actions_fetchobject.inc.php'; // Must be include, not include_once // Must be include, not include_once. Include fetch and fetch_thirdparty but not fetch_optionals |
|
| 61 | -include DOL_DOCUMENT_ROOT.'/core/actions_dellink.inc.php'; |
|
| 60 | +include DOL_DOCUMENT_ROOT . '/core/actions_fetchobject.inc.php'; // Must be include, not include_once // Must be include, not include_once. Include fetch and fetch_thirdparty but not fetch_optionals |
|
| 61 | +include DOL_DOCUMENT_ROOT . '/core/actions_dellink.inc.php'; |
|
| 62 | 62 | |
| 63 | 63 | // Initialize technical object to manage hooks of modules. Note that conf->hooks_modules contains array array |
| 64 | 64 | $hookmanager->initHooks(array('bbcvols')); |
@@ -87,12 +87,12 @@ discard block |
||
| 87 | 87 | FLIGHTLOG_ACTION_CONFIRM_BILL_DAMAGE => [FlightDamageController::class, 'handleInvoice'], |
| 88 | 88 | ]; |
| 89 | 89 | |
| 90 | - if(isset($routes[$action])){ |
|
| 90 | + if (isset($routes[$action])) { |
|
| 91 | 91 | $controllerName = $routes[$action][0]; |
| 92 | 92 | $actionName = $routes[$action][1]; |
| 93 | 93 | |
| 94 | 94 | call_user_func([new $controllerName($db), $actionName]); |
| 95 | - }else{ |
|
| 95 | + } else { |
|
| 96 | 96 | echo 'Route non trouvée.'; |
| 97 | 97 | } |
| 98 | 98 | ?> |
@@ -104,13 +104,13 @@ discard block |
||
| 104 | 104 | // Buttons |
| 105 | 105 | print '<div class="tabsAction">' . "\n"; |
| 106 | 106 | |
| 107 | -if($user->rights->flightlog->vol->financial){ |
|
| 108 | - print '<div class="inline-block divButAction"><a class="butAction" href="' . DOL_URL_ROOT . '/flightlog/card_tab_damage.php?id=' . $object->id.'&action='.FLIGHTLOG_ACTION_ADD_DAMAGE.'">' . $langs->trans("Ajouter") . '</a></div>' . "\n"; |
|
| 107 | +if ($user->rights->flightlog->vol->financial) { |
|
| 108 | + print '<div class="inline-block divButAction"><a class="butAction" href="' . DOL_URL_ROOT . '/flightlog/card_tab_damage.php?id=' . $object->id . '&action=' . FLIGHTLOG_ACTION_ADD_DAMAGE . '">' . $langs->trans("Ajouter") . '</a></div>' . "\n"; |
|
| 109 | 109 | } |
| 110 | 110 | |
| 111 | 111 | print '</div>' . "\n"; |
| 112 | 112 | |
| 113 | -if($user->rights->flightlog->vol->financial){ |
|
| 113 | +if ($user->rights->flightlog->vol->financial) { |
|
| 114 | 114 | print '<div class="fichecenter"><div class="fichehalfleft">'; |
| 115 | 115 | $form->showLinkedObjectBlock($object); |
| 116 | 116 | print '</div></div>'; |
@@ -145,7 +145,7 @@ discard block |
||
| 145 | 145 | |
| 146 | 146 | //Total damages |
| 147 | 147 | $damages = $this->pilotDamageQueryRepository->query($query->getFiscalYear()); |
| 148 | - foreach($damages as $currentDamage){ |
|
| 148 | + foreach ($damages as $currentDamage) { |
|
| 149 | 149 | |
| 150 | 150 | //Pilot doesn't exist |
| 151 | 151 | if (!isset($pilots[$currentDamage->getAuthorId()])) { |
@@ -158,7 +158,7 @@ discard block |
||
| 158 | 158 | ); |
| 159 | 159 | |
| 160 | 160 | // The damage is already invoiced. So not take into account. |
| 161 | - if($currentDamage->isInvoiced()){ |
|
| 161 | + if ($currentDamage->isInvoiced()) { |
|
| 162 | 162 | $pilots[$currentDamage->getAuthorId()] = $pilots[$currentDamage->getAuthorId()]->addCount( |
| 163 | 163 | new FlightTypeCount('invoiced_damage', $currentDamage->getAmount(), -1) |
| 164 | 164 | ); |
@@ -230,7 +230,7 @@ discard block |
||
| 230 | 230 | print '<td>' . $pilot->getCountForType('orga_T6')->getCount() . '</td>'; |
| 231 | 231 | print '<td>' . $pilot->getCountForType('orga_T6')->getCost()->getValue() . '</td>'; |
| 232 | 232 | |
| 233 | - print sprintf('<td class="%s">', $pilot->getFlightBonus()->getValue() === 0?'text-muted':'text-bold'). $pilot->getFlightBonus()->getValue() . ' pts</td>'; |
|
| 233 | + print sprintf('<td class="%s">', $pilot->getFlightBonus()->getValue() === 0 ? 'text-muted' : 'text-bold') . $pilot->getFlightBonus()->getValue() . ' pts</td>'; |
|
| 234 | 234 | |
| 235 | 235 | print '<td>' . $pilot->getCountForType('3')->getCount() . '</td>'; |
| 236 | 236 | print '<td>' . price($pilot->getCountForType('3')->getCost()->getValue()) . '€</td>'; |
@@ -249,8 +249,8 @@ discard block |
||
| 249 | 249 | print '<td>' . price($pilot->getCountForType('damage')->getCost()->getValue()) . '€</td>'; |
| 250 | 250 | print '<td>' . price($pilot->getCountForType('invoiced_damage')->getCost()->getValue()) . '€</td>'; |
| 251 | 251 | |
| 252 | - print sprintf('<td class="%s">', $pilot->getFlightsCost()->getValue() === 0?'text-muted':'text-bold'). price($pilot->getFlightsCost()->getValue()) . '€ </td>'; |
|
| 253 | - print sprintf('<td class="%s">', $pilot->isBillable(FlightBonus::zero())?'text-bold':'text-muted'). price($pilot->getTotalBill()->getValue()) . '€</td>'; |
|
| 252 | + print sprintf('<td class="%s">', $pilot->getFlightsCost()->getValue() === 0 ? 'text-muted' : 'text-bold') . price($pilot->getFlightsCost()->getValue()) . '€ </td>'; |
|
| 253 | + print sprintf('<td class="%s">', $pilot->isBillable(FlightBonus::zero()) ? 'text-bold' : 'text-muted') . price($pilot->getTotalBill()->getValue()) . '€</td>'; |
|
| 254 | 254 | print '</tr>'; |
| 255 | 255 | } |
| 256 | 256 | |
@@ -275,7 +275,7 @@ discard block |
||
| 275 | 275 | print '<td>' . $totalT3 . '</td>'; |
| 276 | 276 | print '<td></td>'; |
| 277 | 277 | |
| 278 | -print '<td>' . $totalT4. '</td>'; |
|
| 278 | +print '<td>' . $totalT4 . '</td>'; |
|
| 279 | 279 | print '<td></td>'; |
| 280 | 280 | |
| 281 | 281 | print '<td>' . $totalT5 . '</td>'; |
@@ -304,7 +304,7 @@ discard block |
||
| 304 | 304 | //table km |
| 305 | 305 | $tauxRemb = isset($conf->global->BBC_FLIGHT_LOG_TAUX_REMB_KM) ? $conf->global->BBC_FLIGHT_LOG_TAUX_REMB_KM : 0; |
| 306 | 306 | $year = GETPOST("year", 'int'); |
| 307 | -if(empty($year)){ |
|
| 307 | +if (empty($year)) { |
|
| 308 | 308 | $year = date('Y'); |
| 309 | 309 | } |
| 310 | 310 | |
@@ -35,16 +35,16 @@ |
||
| 35 | 35 | public function query($year) |
| 36 | 36 | { |
| 37 | 37 | $sql = 'SELECT damage.amount as amount, damage.billed as billed, damage.author_id as author, author.firstname as author_name'; |
| 38 | - $sql.=' FROM '.MAIN_DB_PREFIX.'bbc_flight_damages as damage'; |
|
| 39 | - $sql.=' INNER JOIN '.MAIN_DB_PREFIX.'bbc_vols as flight ON flight.rowid = damage.flight_id'; |
|
| 40 | - $sql.=' INNER JOIN '.MAIN_DB_PREFIX.'user as author ON author.rowid = damage.author_id'; |
|
| 41 | - $sql.=' WHERE YEAR(flight.date) = '.$this->db->escape($year); |
|
| 38 | + $sql .= ' FROM ' . MAIN_DB_PREFIX . 'bbc_flight_damages as damage'; |
|
| 39 | + $sql .= ' INNER JOIN ' . MAIN_DB_PREFIX . 'bbc_vols as flight ON flight.rowid = damage.flight_id'; |
|
| 40 | + $sql .= ' INNER JOIN ' . MAIN_DB_PREFIX . 'user as author ON author.rowid = damage.author_id'; |
|
| 41 | + $sql .= ' WHERE YEAR(flight.date) = ' . $this->db->escape($year); |
|
| 42 | 42 | |
| 43 | 43 | $resql = $this->db->query($sql); |
| 44 | 44 | if ($resql) { |
| 45 | 45 | $num = $this->db->num_rows($resql); |
| 46 | 46 | if ($num) { |
| 47 | - for($i = 0; $i < $num ; $i++) { |
|
| 47 | + for ($i = 0; $i < $num; $i++) { |
|
| 48 | 48 | $properties = $this->db->fetch_array($resql); |
| 49 | 49 | $damage = TotalDamage::fromArray($properties); |
| 50 | 50 | yield $damage; |
@@ -46,11 +46,11 @@ |
||
| 46 | 46 | * |
| 47 | 47 | * @return Damage |
| 48 | 48 | */ |
| 49 | - public static function fromArray(array $properties){ |
|
| 49 | + public static function fromArray(array $properties) { |
|
| 50 | 50 | $author = $properties['author_name']; |
| 51 | 51 | $amount = $properties['amount']; |
| 52 | 52 | $id = $properties['id']; |
| 53 | - $invoiced = (bool)$properties['invoiced']; |
|
| 53 | + $invoiced = (bool) $properties['invoiced']; |
|
| 54 | 54 | |
| 55 | 55 | return new self($author, $amount, $id, $invoiced); |
| 56 | 56 | } |