@@ -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; |
@@ -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>'; |
@@ -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 | } |
@@ -28,7 +28,7 @@ |
||
| 28 | 28 | * |
| 29 | 29 | * @throws \Exception |
| 30 | 30 | */ |
| 31 | - public function __invoke(InvoiceDamageCommand $command){ |
|
| 31 | + public function __invoke(InvoiceDamageCommand $command) { |
|
| 32 | 32 | $damage = $this->damageRepository->getById(DamageId::create($command->getDamageId())); |
| 33 | 33 | $damage = $damage->invoice(); |
| 34 | 34 | $this->damageRepository->save($damage); |
@@ -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,7 +33,7 @@ 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 = join(',', array_map([$this, 'escape'], array_values($elements))); |
| 39 | 39 | |
@@ -44,7 +44,7 @@ discard block |
||
| 44 | 44 | $lasterror = $this->db->lasterror(); |
| 45 | 45 | dol_syslog(__METHOD__ . ' ' . $lasterror, LOG_ERR); |
| 46 | 46 | $this->db->rollback(); |
| 47 | - throw new \Exception("Repository error - ".$lasterror); |
|
| 47 | + throw new \Exception("Repository error - " . $lasterror); |
|
| 48 | 48 | } |
| 49 | 49 | |
| 50 | 50 | $id = $this->db->last_insert_id($this->tableName); |
@@ -57,16 +57,16 @@ discard block |
||
| 57 | 57 | * |
| 58 | 58 | * @return int|string|null |
| 59 | 59 | */ |
| 60 | - private function escape($value){ |
|
| 61 | - if(is_null($value)){ |
|
| 60 | + private function escape($value) { |
|
| 61 | + if (is_null($value)) { |
|
| 62 | 62 | return null; |
| 63 | 63 | } |
| 64 | 64 | |
| 65 | - if(is_bool($value)){ |
|
| 66 | - return (int)$value; |
|
| 65 | + if (is_bool($value)) { |
|
| 66 | + return (int) $value; |
|
| 67 | 67 | } |
| 68 | 68 | |
| 69 | - return is_string($value) ? $this->db->escape($value) : $value ; |
|
| 69 | + return is_string($value) ? $this->db->escape($value) : $value; |
|
| 70 | 70 | } |
| 71 | 71 | |
| 72 | 72 | /** |
@@ -79,18 +79,18 @@ discard block |
||
| 79 | 79 | { |
| 80 | 80 | $sqlModifications = []; |
| 81 | 81 | |
| 82 | - foreach($elements as $field => $value){ |
|
| 82 | + foreach ($elements as $field => $value) { |
|
| 83 | 83 | $sqlModifications[] = sprintf('%s=%s', $field, $this->escape($value)); |
| 84 | 84 | } |
| 85 | 85 | |
| 86 | 86 | $this->db->begin(); |
| 87 | - $resql = $this->db->query(sprintf('UPDATE %s SET %s WHERE rowid = %s ', $this->tableName, join(',',$sqlModifications), $id)); |
|
| 87 | + $resql = $this->db->query(sprintf('UPDATE %s SET %s WHERE rowid = %s ', $this->tableName, join(',', $sqlModifications), $id)); |
|
| 88 | 88 | |
| 89 | 89 | if (!$resql) { |
| 90 | 90 | $lasterror = $this->db->lasterror(); |
| 91 | 91 | dol_syslog(__METHOD__ . ' ' . $lasterror, LOG_ERR); |
| 92 | 92 | $this->db->rollback(); |
| 93 | - throw new \Exception("Repository error - ".$lasterror); |
|
| 93 | + throw new \Exception("Repository error - " . $lasterror); |
|
| 94 | 94 | } |
| 95 | 95 | |
| 96 | 96 | $this->db->commit(); |
@@ -103,8 +103,8 @@ discard block |
||
| 103 | 103 | * |
| 104 | 104 | * @return array|null |
| 105 | 105 | */ |
| 106 | - protected function get($id){ |
|
| 107 | - $sql = sprintf('SELECT * FROM %s WHERE rowid = %s', $this->tableName, $id ); |
|
| 106 | + protected function get($id) { |
|
| 107 | + $sql = sprintf('SELECT * FROM %s WHERE rowid = %s', $this->tableName, $id); |
|
| 108 | 108 | |
| 109 | 109 | $resql = $this->db->query($sql); |
| 110 | 110 | if (!$resql) { |
@@ -116,7 +116,7 @@ discard block |
||
| 116 | 116 | return null; |
| 117 | 117 | } |
| 118 | 118 | |
| 119 | - for($i = 0; $i < $num ; $i++) { |
|
| 119 | + for ($i = 0; $i < $num; $i++) { |
|
| 120 | 120 | return $this->db->fetch_array($resql); |
| 121 | 121 | } |
| 122 | 122 | |
@@ -31,15 +31,15 @@ |
||
| 31 | 31 | public function __invoke($flightId) |
| 32 | 32 | { |
| 33 | 33 | $sql = 'SELECT damage.rowid as id, damage.amount, author.login as author_name, damage.billed as invoiced'; |
| 34 | - $sql.=' FROM '.MAIN_DB_PREFIX.'bbc_flight_damages as damage'; |
|
| 35 | - $sql.=' INNER JOIN '.MAIN_DB_PREFIX.'user as author ON author.rowid = damage.author_id'; |
|
| 36 | - $sql.=' WHERE damage.flight_id = '.$this->db->escape($flightId); |
|
| 34 | + $sql .= ' FROM ' . MAIN_DB_PREFIX . 'bbc_flight_damages as damage'; |
|
| 35 | + $sql .= ' INNER JOIN ' . MAIN_DB_PREFIX . 'user as author ON author.rowid = damage.author_id'; |
|
| 36 | + $sql .= ' WHERE damage.flight_id = ' . $this->db->escape($flightId); |
|
| 37 | 37 | |
| 38 | 38 | $resql = $this->db->query($sql); |
| 39 | 39 | if ($resql) { |
| 40 | 40 | $num = $this->db->num_rows($resql); |
| 41 | 41 | if ($num) { |
| 42 | - for($i = 0; $i < $num ; $i++) { |
|
| 42 | + for ($i = 0; $i < $num; $i++) { |
|
| 43 | 43 | $properties = $this->db->fetch_array($resql); |
| 44 | 44 | yield Damage::fromArray($properties); |
| 45 | 45 | } |
@@ -35,7 +35,7 @@ discard block |
||
| 35 | 35 | 'author_id' => $flightDamage->getAuthor()->getId() |
| 36 | 36 | ]; |
| 37 | 37 | |
| 38 | - if($flightDamage->getId()){ |
|
| 38 | + if ($flightDamage->getId()) { |
|
| 39 | 39 | $this->update($flightDamage->getId()->getId(), $fields); |
| 40 | 40 | return; |
| 41 | 41 | } |
@@ -50,10 +50,10 @@ discard block |
||
| 50 | 50 | * |
| 51 | 51 | * @throws \Exception |
| 52 | 52 | */ |
| 53 | - public function getById(DamageId $id){ |
|
| 53 | + public function getById(DamageId $id) { |
|
| 54 | 54 | $damage = $this->get($id->getId()); |
| 55 | 55 | |
| 56 | - if(null === $damage){ |
|
| 56 | + if (null === $damage) { |
|
| 57 | 57 | throw new \Exception('Damage not found'); |
| 58 | 58 | } |
| 59 | 59 | |