@@ -16,7 +16,7 @@ discard block |
||
16 | 16 | */ |
17 | 17 | |
18 | 18 | |
19 | -require_once DOL_DOCUMENT_ROOT.'/core/triggers/dolibarrtriggers.class.php'; |
|
19 | +require_once DOL_DOCUMENT_ROOT . '/core/triggers/dolibarrtriggers.class.php'; |
|
20 | 20 | dol_include_once('/flightlog/class/bbcvols.class.php'); |
21 | 21 | dol_include_once('/core/class/CMailFile.class.php'); |
22 | 22 | |
@@ -78,23 +78,23 @@ discard block |
||
78 | 78 | */ |
79 | 79 | public function runTrigger($action, $object, User $user, Translate $langs, Conf $conf) |
80 | 80 | { |
81 | - if (empty($conf->flightlog->enabled) || empty($conf->workflow->enabled)){ |
|
81 | + if (empty($conf->flightlog->enabled) || empty($conf->workflow->enabled)) { |
|
82 | 82 | return 0; |
83 | 83 | } |
84 | 84 | |
85 | - if(empty($conf->global->WORKFLOW_BBC_FLIGHTLOG_SEND_MAIL_ON_INCIDENT)){ |
|
85 | + if (empty($conf->global->WORKFLOW_BBC_FLIGHTLOG_SEND_MAIL_ON_INCIDENT)) { |
|
86 | 86 | return 0; |
87 | 87 | } |
88 | 88 | |
89 | - if($action !== 'BBC_FLIGHT_LOG_ADD_FLIGHT'){ |
|
89 | + if ($action !== 'BBC_FLIGHT_LOG_ADD_FLIGHT') { |
|
90 | 90 | return 0; |
91 | 91 | } |
92 | 92 | |
93 | - if(!$object->hasIncidents() && !$object->hasComment()){ |
|
93 | + if (!$object->hasIncidents() && !$object->hasComment()) { |
|
94 | 94 | return 0; |
95 | 95 | } |
96 | 96 | |
97 | - if(!empty($conf->global->MAIN_DISABLE_ALL_MAILS)){ |
|
97 | + if (!empty($conf->global->MAIN_DISABLE_ALL_MAILS)) { |
|
98 | 98 | return 0; |
99 | 99 | } |
100 | 100 | |
@@ -102,11 +102,11 @@ discard block |
||
102 | 102 | $message .= sprintf("<p>Vous recevez cet e-mail car un vol a été encodé avec un incident/ une remarque sur le ballon : %s dont vous êtes titulaire ou co-titulaire.</p>", $object->getBalloon()->immat); |
103 | 103 | $message .= sprintf("<p><b>Vol id :</b> %d</p>", $object->getId()); |
104 | 104 | $message .= sprintf("<p><b>Réalisé par :</b> %s </p>", $object->getPilot()->getFullName($langs)); |
105 | - if($object->hasComment()){ |
|
105 | + if ($object->hasComment()) { |
|
106 | 106 | $message .= sprintf("<p><b>Commentaire :</b> %s </p>", $object->getComment()); |
107 | 107 | } |
108 | 108 | |
109 | - if($object->hasIncidents()){ |
|
109 | + if ($object->hasIncidents()) { |
|
110 | 110 | $message .= sprintf("<p><b>Incident :</b> %s </p>", $object->getIncident()); |
111 | 111 | } |
112 | 112 | |
@@ -118,18 +118,18 @@ discard block |
||
118 | 118 | |
119 | 119 | $responsable = new User($user->db); |
120 | 120 | $res = $responsable->fetch($object->getBalloon()->fk_responsable); |
121 | - if($res > 0){ |
|
121 | + if ($res > 0) { |
|
122 | 122 | $to[] = $responsable->email; |
123 | 123 | } |
124 | 124 | |
125 | 125 | |
126 | 126 | $backup = new User($user->db); |
127 | 127 | $res = $backup->fetch($object->getBalloon()->fk_co_responsable); |
128 | - if($res > 0){ |
|
128 | + if ($res > 0) { |
|
129 | 129 | $to[] = $backup->email; |
130 | 130 | } |
131 | 131 | |
132 | - if(empty($to)){ |
|
132 | + if (empty($to)) { |
|
133 | 133 | return 0; |
134 | 134 | } |
135 | 135 | |
@@ -149,7 +149,7 @@ discard block |
||
149 | 149 | ); |
150 | 150 | |
151 | 151 | |
152 | - if (! $mailfile->sendfile()) |
|
152 | + if (!$mailfile->sendfile()) |
|
153 | 153 | { |
154 | 154 | dol_syslog("Error while sending mail in flight log module : incident", LOG_ERR); |
155 | 155 | } |
@@ -45,7 +45,7 @@ |
||
45 | 45 | return $obj; |
46 | 46 | } |
47 | 47 | |
48 | - private function addAmount(){ |
|
48 | + private function addAmount() { |
|
49 | 49 | $field = new Number('amount'); |
50 | 50 | $field->required(); |
51 | 51 | $field->setStep(0.01); |
@@ -24,7 +24,7 @@ |
||
24 | 24 | <?php echo $renderer->render($form->getElement('flight_id')); ?> |
25 | 25 | <?php echo $renderer->render($form->getElement('token')); ?> |
26 | 26 | |
27 | - <?php if($form->has('amount')): ?> |
|
27 | + <?php if ($form->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%"> |
@@ -16,21 +16,21 @@ |
||
16 | 16 | <td colspan="2"> </td> |
17 | 17 | </tr> |
18 | 18 | <?php $total = 0; ?> |
19 | - <?php foreach($damages as $currentDamage):?> |
|
19 | + <?php foreach ($damages as $currentDamage):?> |
|
20 | 20 | <?php $total += $currentDamage->getAmount(); ?> |
21 | 21 | <tr> |
22 | - <td><?php echo $currentDamage->getAuthorName();?></td> |
|
23 | - <td><?php echo $currentDamage->getLabel();?></td> |
|
24 | - <td><?php echo $currentDamage->getAmount();?>€</td> |
|
22 | + <td><?php echo $currentDamage->getAuthorName(); ?></td> |
|
23 | + <td><?php echo $currentDamage->getLabel(); ?></td> |
|
24 | + <td><?php echo $currentDamage->getAmount(); ?>€</td> |
|
25 | 25 | <td> |
26 | - <?php if($currentDamage->isInvoiced()): ?> |
|
26 | + <?php if ($currentDamage->isInvoiced()): ?> |
|
27 | 27 | <i class="fas fa-check"></i> |
28 | 28 | <?php else: ?> |
29 | 29 | <i class="fas fa-times"></i> |
30 | 30 | <?php endif; ?> |
31 | 31 | </td> |
32 | 32 | <td> |
33 | - <a href="<?php print sprintf('%s/flightlog/index.php?r=get_one_damage&id=%s', DOL_URL_ROOT, $currentDamage->getId());?>"><i class="fas fa-link"></i></a> |
|
33 | + <a href="<?php print sprintf('%s/flightlog/index.php?r=get_one_damage&id=%s', DOL_URL_ROOT, $currentDamage->getId()); ?>"><i class="fas fa-link"></i></a> |
|
34 | 34 | </td> |
35 | 35 | </tr> |
36 | 36 | <?php endforeach; ?> |
@@ -258,7 +258,7 @@ discard block |
||
258 | 258 | */ |
259 | 259 | private function addOrderDiscount($order, $pilotFlightCount, $service, $year) |
260 | 260 | { |
261 | - $price = $pilotFlightCount->getCost()->getValue()/(1+$service->tva_tx/100); |
|
261 | + $price = $pilotFlightCount->getCost()->getValue() / (1 + $service->tva_tx / 100); |
|
262 | 262 | $pu_ht = price2num($price, 'MU'); |
263 | 263 | $desc = $year . " - " . $service->label . " - (" . $pilotFlightCount->getCount() . " * " . $pilotFlightCount->getFactor() . ")"; |
264 | 264 | |
@@ -289,7 +289,7 @@ discard block |
||
289 | 289 | return; |
290 | 290 | } |
291 | 291 | |
292 | - $pointsHt = $command->getAdditionalBonus()/(1+6/100); |
|
292 | + $pointsHt = $command->getAdditionalBonus() / (1 + 6 / 100); |
|
293 | 293 | $desc = sprintf("%s - %s", $command->getYear(), $command->getBonusAdditionalMessage()); |
294 | 294 | |
295 | 295 | $discountid = $this->getCompany($object->socid)->set_remise_except($pointsHt, $this->user, $desc, 6); |
@@ -309,14 +309,14 @@ discard block |
||
309 | 309 | $totalCost = FlightCost::zero(); |
310 | 310 | $description = ''; |
311 | 311 | |
312 | - foreach ($damages as $damage){ |
|
312 | + foreach ($damages as $damage) { |
|
313 | 313 | $totalCost->addCost($damage->getCost()); |
314 | - $description .= $damage->getLabel().'; '; |
|
314 | + $description .= $damage->getLabel() . '; '; |
|
315 | 315 | } |
316 | 316 | |
317 | 317 | $tDamage = new Product($this->db); |
318 | 318 | $tDamage->label = 'Réparations aux ballons'; |
319 | - $tDamage->description = $description ; |
|
319 | + $tDamage->description = $description; |
|
320 | 320 | $tDamage->tva_tx = 21; |
321 | 321 | $tDamage->price_ttc = $totalCost->getValue(); |
322 | 322 | $tDamage->price = $tDamage->price_ttc / (1 + $tDamage->tva_tx / 100); |
@@ -189,7 +189,7 @@ discard block |
||
189 | 189 | print '<td>' . $pilot->getCountForType('orga_T6')->getCount() . '</td>'; |
190 | 190 | print '<td>' . $pilot->getCountForType('orga_T6')->getCost()->getValue() . '</td>'; |
191 | 191 | |
192 | - print sprintf('<td class="%s">', $pilot->getFlightBonus()->getValue() === 0?'text-muted':'text-bold'). $pilot->getFlightBonus()->getValue() . ' pts</td>'; |
|
192 | + print sprintf('<td class="%s">', $pilot->getFlightBonus()->getValue() === 0 ? 'text-muted' : 'text-bold') . $pilot->getFlightBonus()->getValue() . ' pts</td>'; |
|
193 | 193 | |
194 | 194 | print '<td>' . $pilot->getCountForType('3')->getCount() . '</td>'; |
195 | 195 | print '<td>' . price($pilot->getCountForType('3')->getCost()->getValue()) . '€</td>'; |
@@ -208,8 +208,8 @@ discard block |
||
208 | 208 | print '<td>' . price($pilot->damageCost()->getValue()) . '€</td>'; |
209 | 209 | print '<td>' . price($pilot->invoicedDamageCost()->getValue()) . '€</td>'; |
210 | 210 | |
211 | - print sprintf('<td class="%s">', $pilot->getFlightsCost()->getValue() === 0?'text-muted':'text-bold'). price($pilot->getFlightsCost()->getValue()) . '€ </td>'; |
|
212 | - print sprintf('<td class="%s">', $pilot->isBillable(FlightBonus::zero())?'text-bold':'text-muted'). price($pilot->getTotalBill()->getValue()) . '€</td>'; |
|
211 | + print sprintf('<td class="%s">', $pilot->getFlightsCost()->getValue() === 0 ? 'text-muted' : 'text-bold') . price($pilot->getFlightsCost()->getValue()) . '€ </td>'; |
|
212 | + print sprintf('<td class="%s">', $pilot->isBillable(FlightBonus::zero()) ? 'text-bold' : 'text-muted') . price($pilot->getTotalBill()->getValue()) . '€</td>'; |
|
213 | 213 | print '</tr>'; |
214 | 214 | } |
215 | 215 | |
@@ -234,7 +234,7 @@ discard block |
||
234 | 234 | print '<td>' . $totalT3 . '</td>'; |
235 | 235 | print '<td></td>'; |
236 | 236 | |
237 | -print '<td>' . $totalT4. '</td>'; |
|
237 | +print '<td>' . $totalT4 . '</td>'; |
|
238 | 238 | print '<td></td>'; |
239 | 239 | |
240 | 240 | print '<td>' . $totalT5 . '</td>'; |
@@ -263,7 +263,7 @@ discard block |
||
263 | 263 | //table km |
264 | 264 | $tauxRemb = isset($conf->global->BBC_FLIGHT_LOG_TAUX_REMB_KM) ? $conf->global->BBC_FLIGHT_LOG_TAUX_REMB_KM : 0; |
265 | 265 | $year = GETPOST("year", 'int'); |
266 | -if(empty($year)){ |
|
266 | +if (empty($year)) { |
|
267 | 267 | $year = date('Y'); |
268 | 268 | } |
269 | 269 |
@@ -31,15 +31,15 @@ |
||
31 | 31 | public function __invoke($flightId) |
32 | 32 | { |
33 | 33 | $sql = 'SELECT damage.author_id as author_id, damage.rowid as id, damage.amount, damage.label, CONCAT(author.firstname, " " , author.lastname) 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 | } |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | 'label' => $flightDamage->getLabel()->value(), |
38 | 38 | ]; |
39 | 39 | |
40 | - if($flightDamage->getId()){ |
|
40 | + if ($flightDamage->getId()) { |
|
41 | 41 | $this->update($flightDamage->getId()->getId(), $fields); |
42 | 42 | return $flightDamage->getId()->getId(); |
43 | 43 | } |
@@ -52,10 +52,10 @@ discard block |
||
52 | 52 | * |
53 | 53 | * @throws \Exception |
54 | 54 | */ |
55 | - public function getById(DamageId $id){ |
|
55 | + public function getById(DamageId $id) { |
|
56 | 56 | $damage = $this->get($id->getId()); |
57 | 57 | |
58 | - if(null === $damage){ |
|
58 | + if (null === $damage) { |
|
59 | 59 | throw new \Exception('Damage not found'); |
60 | 60 | } |
61 | 61 |
@@ -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 |