@@ -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; |
@@ -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 | } |
@@ -24,19 +24,19 @@ |
||
24 | 24 | $this->request = new Request(); |
25 | 25 | } |
26 | 26 | |
27 | - protected function render($template, array $variables = []){ |
|
27 | + protected function render($template, array $variables = []) { |
|
28 | 28 | |
29 | - foreach($variables as $variableName => $variableValue){ |
|
29 | + foreach ($variables as $variableName => $variableValue) { |
|
30 | 30 | $GLOBALS[$variableName] = $variableValue; |
31 | 31 | } |
32 | 32 | |
33 | - return include __DIR__.'/../templates/'.$template; |
|
33 | + return include __DIR__ . '/../templates/' . $template; |
|
34 | 34 | } |
35 | 35 | |
36 | 36 | /** |
37 | 37 | * @param string $html |
38 | 38 | */ |
39 | - protected function renderHtml($html){ |
|
39 | + protected function renderHtml($html) { |
|
40 | 40 | print $html; |
41 | 41 | } |
42 | 42 |
@@ -280,7 +280,7 @@ discard block |
||
280 | 280 | return; |
281 | 281 | } |
282 | 282 | |
283 | - $pointsHt = $command->getAdditionalBonus()/(1+6/100); |
|
283 | + $pointsHt = $command->getAdditionalBonus() / (1 + 6 / 100); |
|
284 | 284 | $desc = sprintf("%s - %s", $command->getYear(), $command->getBonusAdditionalMessage()); |
285 | 285 | |
286 | 286 | $discountid = $this->getCompany($object->socid)->set_remise_except($pointsHt, $this->user, $desc, 6); |
@@ -300,7 +300,7 @@ discard block |
||
300 | 300 | { |
301 | 301 | $price = $damage->getCost()->addCost($invoicedDamage->getCost())->getValue(); |
302 | 302 | |
303 | - if($price <= 0 ){ |
|
303 | + if ($price <= 0) { |
|
304 | 304 | return; |
305 | 305 | } |
306 | 306 |
@@ -53,14 +53,14 @@ |
||
53 | 53 | |
54 | 54 | $routes = require './Infrastructure/Common/Routes/routes.conf.php'; |
55 | 55 | |
56 | -try{ |
|
56 | +try { |
|
57 | 57 | $routeName = GETPOST('r'); |
58 | 58 | |
59 | 59 | $routeManager = new \FlightLog\Infrastructure\Common\Routes\RouteManager($db); |
60 | 60 | $routeManager->load($routes); |
61 | 61 | |
62 | 62 | $routeManager->__invoke($routeName); |
63 | -}catch (\Exception $e){ |
|
63 | +} catch (\Exception $e) { |
|
64 | 64 | dol_syslog($e->getMessage(), LOG_ERR); |
65 | 65 | echo $e->getMessage(); |
66 | 66 | } |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | public function __invoke(CreateDamageCommand $command) |
42 | 42 | { |
43 | 43 | $damage = FlightDamage::waiting(new DamageAmount($command->getAmount()), AuthorId::create($command->getAuthorId())); |
44 | - if(null !== $command->getFlightId()){ |
|
44 | + if (null !== $command->getFlightId()) { |
|
45 | 45 | $damage = FlightDamage::damage(FlightId::create($command->getFlightId()), new DamageAmount($command->getAmount()), AuthorId::create($command->getAuthorId())); |
46 | 46 | } |
47 | 47 | |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | */ |
60 | 60 | private function linkSupplierInvoice($damageId, $invoiceId) |
61 | 61 | { |
62 | - if($invoiceId <= 0){ |
|
62 | + if ($invoiceId <= 0) { |
|
63 | 63 | return; |
64 | 64 | } |
65 | 65 | |
@@ -80,8 +80,8 @@ discard block |
||
80 | 80 | * @param int $targetId |
81 | 81 | * @param string $targetType |
82 | 82 | */ |
83 | - private function insertLinks($damageId, $targetId, $targetType){ |
|
84 | - $sql = "INSERT INTO ".MAIN_DB_PREFIX."element_element ("; |
|
83 | + private function insertLinks($damageId, $targetId, $targetType) { |
|
84 | + $sql = "INSERT INTO " . MAIN_DB_PREFIX . "element_element ("; |
|
85 | 85 | $sql .= "fk_source"; |
86 | 86 | $sql .= ", sourcetype"; |
87 | 87 | $sql .= ", fk_target"; |
@@ -89,8 +89,8 @@ discard block |
||
89 | 89 | $sql .= ") VALUES ("; |
90 | 90 | $sql .= $damageId; |
91 | 91 | $sql .= ", 'flightlog_damage'"; |
92 | - $sql .= ", ".$targetId; |
|
93 | - $sql .= ", '".$targetType."'"; |
|
92 | + $sql .= ", " . $targetId; |
|
93 | + $sql .= ", '" . $targetType . "'"; |
|
94 | 94 | $sql .= ")"; |
95 | 95 | |
96 | 96 | if ($this->db->query($sql)) |