@@ -59,12 +59,12 @@ |
||
59 | 59 | * |
60 | 60 | * @return Damage |
61 | 61 | */ |
62 | - public static function fromArray(array $properties){ |
|
62 | + public static function fromArray(array $properties) { |
|
63 | 63 | $author = $properties['author_name']; |
64 | 64 | $amount = $properties['amount']; |
65 | 65 | $id = $properties['id']; |
66 | 66 | $flightId = isset($properties['flight_id']) ? $properties['flight_id'] : null; |
67 | - $invoiced = (bool)$properties['invoiced']; |
|
67 | + $invoiced = (bool) $properties['invoiced']; |
|
68 | 68 | |
69 | 69 | return new self($author, $amount, $id, $invoiced, $flightId); |
70 | 70 | } |
@@ -14,20 +14,20 @@ |
||
14 | 14 | <td>Montant</td> |
15 | 15 | </tr> |
16 | 16 | <?php $total = 0; ?> |
17 | - <?php foreach($damages as $currentDamage):?> |
|
17 | + <?php foreach ($damages as $currentDamage):?> |
|
18 | 18 | <?php $total += $currentDamage->getAmount(); ?> |
19 | 19 | <tr> |
20 | - <td><?php echo $currentDamage->getAuthorName();?></td> |
|
21 | - <td><?php echo $currentDamage->getAmount();?>€</td> |
|
20 | + <td><?php echo $currentDamage->getAuthorName(); ?></td> |
|
21 | + <td><?php echo $currentDamage->getAmount(); ?>€</td> |
|
22 | 22 | <td> |
23 | - <?php if($currentDamage->isInvoiced()): ?> |
|
23 | + <?php if ($currentDamage->isInvoiced()): ?> |
|
24 | 24 | <i class="fas fa-check"></i> |
25 | 25 | <?php else: ?> |
26 | 26 | <i class="fas fa-times"></i> |
27 | 27 | <?php endif; ?> |
28 | 28 | </td> |
29 | 29 | <td> |
30 | - <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> |
|
30 | + <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> |
|
31 | 31 | </td> |
32 | 32 | </tr> |
33 | 33 | <?php endforeach; ?> |
@@ -22,9 +22,12 @@ |
||
22 | 22 | <td> |
23 | 23 | <?php if($currentDamage->isInvoiced()): ?> |
24 | 24 | <i class="fas fa-check"></i> |
25 | - <?php else: ?> |
|
25 | + <?php else { |
|
26 | + : ?> |
|
26 | 27 | <i class="fas fa-times"></i> |
27 | - <?php endif; ?> |
|
28 | + <?php endif; |
|
29 | +} |
|
30 | +?> |
|
28 | 31 | </td> |
29 | 32 | <td> |
30 | 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> |
@@ -53,9 +53,9 @@ |
||
53 | 53 | ?> |
54 | 54 | |
55 | 55 | <table class="border centpercent"> |
56 | - <tr><td class="fieldrequired">Auteur</td><td><?php echo $damage->getAuthorName();?></td></tr> |
|
57 | - <tr><td class="fieldrequired">Montant</td><td><?php echo $damage->getAmount();?>€</td></tr> |
|
58 | - <tr><td class="fieldrequired">Facturé</td><td><?php echo $damage->isInvoiced()? 'Oui' : 'Non';?></td></tr> |
|
56 | + <tr><td class="fieldrequired">Auteur</td><td><?php echo $damage->getAuthorName(); ?></td></tr> |
|
57 | + <tr><td class="fieldrequired">Montant</td><td><?php echo $damage->getAmount(); ?>€</td></tr> |
|
58 | + <tr><td class="fieldrequired">Facturé</td><td><?php echo $damage->isInvoiced() ? 'Oui' : 'Non'; ?></td></tr> |
|
59 | 59 | <tr> |
60 | 60 | <td class="fieldrequired">Vol</td> |
61 | 61 | <td> |
@@ -31,7 +31,7 @@ |
||
31 | 31 | 'form' => new Form($this->db), |
32 | 32 | 'flight' => $flight |
33 | 33 | ]); |
34 | - }catch (\Exception $e){ |
|
34 | + } catch (\Exception $e){ |
|
35 | 35 | echo $e->getMessage(); |
36 | 36 | } |
37 | 37 | } |
@@ -13,14 +13,14 @@ discard block |
||
13 | 13 | /** |
14 | 14 | * @return GetDamageQueryRepository |
15 | 15 | */ |
16 | - private function getDamageRepository(){ |
|
16 | + private function getDamageRepository() { |
|
17 | 17 | return new GetDamageQueryRepository($this->db); |
18 | 18 | } |
19 | 19 | |
20 | - public function view(){ |
|
20 | + public function view() { |
|
21 | 21 | $damageId = $this->request->getParam('id'); |
22 | 22 | |
23 | - try{ |
|
23 | + try { |
|
24 | 24 | $damage = $this->getDamageRepository()->query($damageId); |
25 | 25 | |
26 | 26 | $flight = new \Bbcvols($this->db); |
@@ -31,16 +31,16 @@ discard block |
||
31 | 31 | 'form' => new Form($this->db), |
32 | 32 | 'flight' => $flight |
33 | 33 | ]); |
34 | - }catch (\Exception $e){ |
|
34 | + } catch (\Exception $e) { |
|
35 | 35 | echo $e->getMessage(); |
36 | 36 | } |
37 | 37 | } |
38 | 38 | |
39 | - public function invoice(){ |
|
39 | + public function invoice() { |
|
40 | 40 | $damageId = $this->request->getParam('id'); |
41 | 41 | |
42 | 42 | |
43 | 43 | |
44 | - return $this->redirect($_SERVER["PHP_SELF"].'?id='.$damageId); |
|
44 | + return $this->redirect($_SERVER["PHP_SELF"] . '?id=' . $damageId); |
|
45 | 45 | } |
46 | 46 | } |
47 | 47 | \ No newline at end of file |
@@ -39,11 +39,11 @@ |
||
39 | 39 | */ |
40 | 40 | private function __construct(DamageAmount $amount, $billed, AuthorId $authorId, FlightId $flightId = null, DamageId $id = null) |
41 | 41 | { |
42 | - $this->flight = $flightId; |
|
43 | - $this->amount = $amount; |
|
44 | - $this->billed = $billed; |
|
45 | - $this->author = $authorId; |
|
46 | - $this->id = $id; |
|
42 | + $this->flight = $flightId; |
|
43 | + $this->amount = $amount; |
|
44 | + $this->billed = $billed; |
|
45 | + $this->author = $authorId; |
|
46 | + $this->id = $id; |
|
47 | 47 | } |
48 | 48 | |
49 | 49 | /** |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | * |
56 | 56 | * @return FlightDamage |
57 | 57 | */ |
58 | - public static function load(FlightId $flightId, DamageAmount $amount, $billed, AuthorId $authorId, DamageId $id = null){ |
|
58 | + public static function load(FlightId $flightId, DamageAmount $amount, $billed, AuthorId $authorId, DamageId $id = null) { |
|
59 | 59 | return new self($amount, $billed, $authorId, $flightId, $id); |
60 | 60 | } |
61 | 61 | |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | * |
67 | 67 | * @return FlightDamage |
68 | 68 | */ |
69 | - public static function damage(FlightId $flightId, DamageAmount $amount, AuthorId $authorId){ |
|
69 | + public static function damage(FlightId $flightId, DamageAmount $amount, AuthorId $authorId) { |
|
70 | 70 | return new self($amount, false, $authorId, $flightId); |
71 | 71 | } |
72 | 72 | |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | * |
77 | 77 | * @return FlightDamage |
78 | 78 | */ |
79 | - public static function waiting(DamageAmount $amount, AuthorId $authorId){ |
|
79 | + public static function waiting(DamageAmount $amount, AuthorId $authorId) { |
|
80 | 80 | return new self($amount, false, $authorId); |
81 | 81 | } |
82 | 82 | |
@@ -91,14 +91,14 @@ discard block |
||
91 | 91 | /** |
92 | 92 | * @return FlightId |
93 | 93 | */ |
94 | - public function getFlightId(){ |
|
94 | + public function getFlightId() { |
|
95 | 95 | return $this->flight; |
96 | 96 | } |
97 | 97 | |
98 | 98 | /** |
99 | 99 | * @return DamageAmount |
100 | 100 | */ |
101 | - public function amount(){ |
|
101 | + public function amount() { |
|
102 | 102 | return $this->amount; |
103 | 103 | } |
104 | 104 | |
@@ -115,7 +115,7 @@ discard block |
||
115 | 115 | * |
116 | 116 | * @return FlightDamage |
117 | 117 | */ |
118 | - public function invoice(){ |
|
118 | + public function invoice() { |
|
119 | 119 | return new self($this->flight, $this->amount, true, $this->author, $this->id); |
120 | 120 | } |
121 | 121 |
@@ -22,7 +22,7 @@ discard block |
||
22 | 22 | $this->db = $db; |
23 | 23 | } |
24 | 24 | |
25 | - private function element($objectType, $rowid){ |
|
25 | + private function element($objectType, $rowid) { |
|
26 | 26 | $element = null; |
27 | 27 | $subelement = null; |
28 | 28 | |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | $subelement = $regs[2]; |
34 | 34 | } |
35 | 35 | |
36 | - $classpath = $element.'/class'; |
|
36 | + $classpath = $element . '/class'; |
|
37 | 37 | |
38 | 38 | if ($objectType == 'facture') { |
39 | 39 | $classpath = 'compta/facture/class'; |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | $classfile = 'subscription'; $classname = 'Subscription'; |
86 | 86 | } |
87 | 87 | |
88 | - dol_include_once('/'.$classpath.'/'.$classfile.'.class.php'); |
|
88 | + dol_include_once('/' . $classpath . '/' . $classfile . '.class.php'); |
|
89 | 89 | if (!class_exists($classname)) |
90 | 90 | { |
91 | 91 | return null; |
@@ -104,14 +104,14 @@ discard block |
||
104 | 104 | * |
105 | 105 | * @throws \Exception |
106 | 106 | */ |
107 | - public function query($damageId){ |
|
107 | + public function query($damageId) { |
|
108 | 108 | |
109 | 109 | $sql = 'SELECT damage.rowid as id, damage.amount, author.login as author_name, damage.billed as invoiced, damage.flight_id as flight_id'; |
110 | - $sql.= ', element.rowid as element_id ,element.fk_target as element_fk_target, element.targettype as element_target_type'; |
|
111 | - $sql.=' FROM '.MAIN_DB_PREFIX.'bbc_flight_damages as damage'; |
|
112 | - $sql.=' INNER JOIN '.MAIN_DB_PREFIX.'user as author ON author.rowid = damage.author_id'; |
|
113 | - $sql.=' LEFT JOIN '.MAIN_DB_PREFIX.'element_element as element ON (element.fk_source = damage.rowid AND element.sourcetype = "flightlog_damage")'; |
|
114 | - $sql.=' WHERE damage.rowid = '.$damageId; |
|
110 | + $sql .= ', element.rowid as element_id ,element.fk_target as element_fk_target, element.targettype as element_target_type'; |
|
111 | + $sql .= ' FROM ' . MAIN_DB_PREFIX . 'bbc_flight_damages as damage'; |
|
112 | + $sql .= ' INNER JOIN ' . MAIN_DB_PREFIX . 'user as author ON author.rowid = damage.author_id'; |
|
113 | + $sql .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'element_element as element ON (element.fk_source = damage.rowid AND element.sourcetype = "flightlog_damage")'; |
|
114 | + $sql .= ' WHERE damage.rowid = ' . $damageId; |
|
115 | 115 | |
116 | 116 | $resql = $this->db->query($sql); |
117 | 117 | if (!$resql) { |
@@ -125,13 +125,13 @@ discard block |
||
125 | 125 | |
126 | 126 | /** @var Damage $damage */ |
127 | 127 | $damage = null; |
128 | - for($i = 0; $i < $num ; $i++) { |
|
128 | + for ($i = 0; $i < $num; $i++) { |
|
129 | 129 | $properties = $this->db->fetch_array($resql); |
130 | - if(!$damage){ |
|
130 | + if (!$damage) { |
|
131 | 131 | $damage = Damage::fromArray($properties); |
132 | 132 | } |
133 | 133 | |
134 | - if(!isset($properties['element_id'])){ |
|
134 | + if (!isset($properties['element_id'])) { |
|
135 | 135 | continue; |
136 | 136 | } |
137 | 137 |
@@ -37,29 +37,21 @@ discard block |
||
37 | 37 | |
38 | 38 | if ($objectType == 'facture') { |
39 | 39 | $classpath = 'compta/facture/class'; |
40 | - } |
|
41 | - elseif ($objectType == 'facturerec') { |
|
40 | + } elseif ($objectType == 'facturerec') { |
|
42 | 41 | $classpath = 'compta/facture/class'; |
43 | - } |
|
44 | - elseif ($objectType == 'propal') { |
|
42 | + } elseif ($objectType == 'propal') { |
|
45 | 43 | $classpath = 'comm/propal/class'; |
46 | - } |
|
47 | - elseif ($objectType == 'supplier_proposal') { |
|
44 | + } elseif ($objectType == 'supplier_proposal') { |
|
48 | 45 | $classpath = 'supplier_proposal/class'; |
49 | - } |
|
50 | - elseif ($objectType == 'shipping') { |
|
46 | + } elseif ($objectType == 'shipping') { |
|
51 | 47 | $classpath = 'expedition/class'; $subelement = 'expedition'; |
52 | - } |
|
53 | - elseif ($objectType == 'delivery') { |
|
48 | + } elseif ($objectType == 'delivery') { |
|
54 | 49 | $classpath = 'livraison/class'; $subelement = 'livraison'; |
55 | - } |
|
56 | - elseif ($objectType == 'invoice_supplier' || $objectType == 'order_supplier') { |
|
50 | + } elseif ($objectType == 'invoice_supplier' || $objectType == 'order_supplier') { |
|
57 | 51 | $classpath = 'fourn/class'; |
58 | - } |
|
59 | - elseif ($objectType == 'fichinter') { |
|
52 | + } elseif ($objectType == 'fichinter') { |
|
60 | 53 | $classpath = 'fichinter/class'; $subelement = 'fichinter'; |
61 | - } |
|
62 | - elseif ($objectType == 'subscription') { |
|
54 | + } elseif ($objectType == 'subscription') { |
|
63 | 55 | $classpath = 'adherents/class'; |
64 | 56 | } |
65 | 57 | |
@@ -68,20 +60,15 @@ discard block |
||
68 | 60 | |
69 | 61 | if ($objectType == 'order') { |
70 | 62 | $classfile = 'commande'; $classname = 'Commande'; |
71 | - } |
|
72 | - elseif ($objectType == 'invoice_supplier') { |
|
63 | + } elseif ($objectType == 'invoice_supplier') { |
|
73 | 64 | $classfile = 'fournisseur.facture'; $classname = 'FactureFournisseur'; |
74 | - } |
|
75 | - elseif ($objectType == 'order_supplier') { |
|
65 | + } elseif ($objectType == 'order_supplier') { |
|
76 | 66 | $classfile = 'fournisseur.commande'; $classname = 'CommandeFournisseur'; |
77 | - } |
|
78 | - elseif ($objectType == 'supplier_proposal') { |
|
67 | + } elseif ($objectType == 'supplier_proposal') { |
|
79 | 68 | $classfile = 'supplier_proposal'; $classname = 'SupplierProposal'; |
80 | - } |
|
81 | - elseif ($objectType == 'facturerec') { |
|
69 | + } elseif ($objectType == 'facturerec') { |
|
82 | 70 | $classfile = 'facture-rec'; $classname = 'FactureRec'; |
83 | - } |
|
84 | - elseif ($objectType == 'subscription') { |
|
71 | + } elseif ($objectType == 'subscription') { |
|
85 | 72 | $classfile = 'subscription'; $classname = 'Subscription'; |
86 | 73 | } |
87 | 74 |
@@ -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 $flightDamage->getId()->getId(); |
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 |
@@ -1,9 +1,6 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | -use FlightLog\Http\Web\Controller\DamageController; |
|
4 | -use FlightLog\Http\Web\Controller\FlightController; |
|
5 | 3 | use FlightLog\Infrastructure\Common\Routes\Guard; |
6 | -use FlightLog\Infrastructure\Common\Routes\Route; |
|
7 | 4 | |
8 | 5 | global $db; |
9 | 6 |
@@ -8,7 +8,7 @@ |
||
8 | 8 | global $db; |
9 | 9 | |
10 | 10 | return [ |
11 | - new Guard('get_one_damage', function(User $user){ |
|
11 | + new Guard('get_one_damage', function(User $user) { |
|
12 | 12 | return $user->rights->flightlog->vol->financial; |
13 | 13 | }), |
14 | 14 | ]; |
@@ -32,19 +32,19 @@ |
||
32 | 32 | * |
33 | 33 | * @return Response |
34 | 34 | */ |
35 | - protected function render($template, array $variables = []){ |
|
35 | + protected function render($template, array $variables = []) { |
|
36 | 36 | |
37 | - foreach($variables as $variableName => $variableValue){ |
|
37 | + foreach ($variables as $variableName => $variableValue) { |
|
38 | 38 | $GLOBALS[$variableName] = $variableValue; |
39 | 39 | } |
40 | 40 | |
41 | - return new Response(__DIR__.'/../templates/'.$template); |
|
41 | + return new Response(__DIR__ . '/../templates/' . $template); |
|
42 | 42 | } |
43 | 43 | |
44 | 44 | /** |
45 | 45 | * @param string $html |
46 | 46 | */ |
47 | - protected function renderHtml($html){ |
|
47 | + protected function renderHtml($html) { |
|
48 | 48 | print $html; |
49 | 49 | } |
50 | 50 |