Completed
Push — feature/pilot_information ( 13ff1e )
by Laurent
02:49 queued 53s
created
Damage/Query/Repository/GetDamagesForFlightQueryRepository.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -31,15 +31,15 @@
 block discarded – undo
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
                 }
Please login to merge, or discard this patch.
Infrastructure/Damage/Repository/FlightDamageRepository.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 
Please login to merge, or discard this patch.
Infrastructure/Common/Repository/AbstractDomainRepository.php 1 patch
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 
Please login to merge, or discard this patch.
Application/Damage/ViewModel/Damage.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -72,14 +72,14 @@
 block discarded – undo
72 72
      *
73 73
      * @return Damage
74 74
      */
75
-    public static function fromArray(array $properties){
75
+    public static function fromArray(array $properties) {
76 76
         $authorId = $properties['author_id'];
77 77
         $author = $properties['author_name'];
78 78
         $label = $properties['label'];
79 79
         $amount = $properties['amount'];
80 80
         $id = $properties['id'];
81 81
         $flightId = isset($properties['flight_id']) ? $properties['flight_id'] : null;
82
-        $invoiced = (bool)$properties['invoiced'];
82
+        $invoiced = (bool) $properties['invoiced'];
83 83
 
84 84
         return new self($authorId, $author, $amount, $id, $invoiced, $flightId, $label);
85 85
     }
Please login to merge, or discard this patch.
Application/Damage/Command/CreateDamageCommandHandler.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
     public function __invoke(CreateDamageCommand $command)
43 43
     {
44 44
         $damage = FlightDamage::waiting(new DamageAmount($command->getAmount()), AuthorId::create($command->getAuthorId()), new DamageLabel($command->getLabel()));
45
-        if(null !== $command->getFlightId()){
45
+        if (null !== $command->getFlightId()) {
46 46
             $damage = FlightDamage::damage(FlightId::create($command->getFlightId()), new DamageLabel($command->getLabel()), new DamageAmount($command->getAmount()), AuthorId::create($command->getAuthorId()));
47 47
         }
48 48
 
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
      */
61 61
     private function linkSupplierInvoice($damageId, $invoiceId)
62 62
     {
63
-        if($invoiceId <= 0){
63
+        if ($invoiceId <= 0) {
64 64
             return;
65 65
         }
66 66
 
@@ -81,8 +81,8 @@  discard block
 block discarded – undo
81 81
      * @param int $targetId
82 82
      * @param string $targetType
83 83
      */
84
-    private function insertLinks($damageId, $targetId, $targetType){
85
-        $sql = "INSERT INTO ".MAIN_DB_PREFIX."element_element (";
84
+    private function insertLinks($damageId, $targetId, $targetType) {
85
+        $sql = "INSERT INTO " . MAIN_DB_PREFIX . "element_element (";
86 86
         $sql .= "fk_source";
87 87
         $sql .= ", sourcetype";
88 88
         $sql .= ", fk_target";
@@ -90,8 +90,8 @@  discard block
 block discarded – undo
90 90
         $sql .= ") VALUES (";
91 91
         $sql .= $damageId;
92 92
         $sql .= ", 'flightlog_damage'";
93
-        $sql .= ", ".$targetId;
94
-        $sql .= ", '".$targetType."'";
93
+        $sql .= ", " . $targetId;
94
+        $sql .= ", '" . $targetType . "'";
95 95
         $sql .= ")";
96 96
 
97 97
         if ($this->db->query($sql))
Please login to merge, or discard this patch.
class/Damage/ValueObject/DamageLabel.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -15,7 +15,7 @@
 block discarded – undo
15 15
         $this->label = $label;
16 16
     }
17 17
 
18
-    public function value(){
18
+    public function value() {
19 19
         return $this->label;
20 20
     }
21 21
 
Please login to merge, or discard this patch.
class/flight/Pilot.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -106,11 +106,11 @@  discard block
 block discarded – undo
106 106
         return new Pilot($this->name, $this->id, $types);
107 107
     }
108 108
 
109
-    public function addDamage(FlightDamageCount $damage){
109
+    public function addDamage(FlightDamageCount $damage) {
110 110
         $this->damages[] = $damage;
111 111
     }
112 112
 
113
-    public function addInvoicedDamage(FlightInvoicedDamageCount $damage){
113
+    public function addInvoicedDamage(FlightInvoicedDamageCount $damage) {
114 114
         $this->damages[] = $damage;
115 115
     }
116 116
 
@@ -161,21 +161,21 @@  discard block
 block discarded – undo
161 161
         return $flightsCost;
162 162
     }
163 163
 
164
-    public function totalDamageCost(){
164
+    public function totalDamageCost() {
165 165
         $flightCost = FlightCost::zero();
166 166
 
167
-        foreach($this->damages as $damage){
167
+        foreach ($this->damages as $damage) {
168 168
             $flightCost = $flightCost->addCost($damage->getCost());
169 169
         }
170 170
 
171 171
         return $flightCost;
172 172
     }
173 173
 
174
-    public function damageCost(){
174
+    public function damageCost() {
175 175
         $flightCost = FlightCost::zero();
176 176
 
177
-        foreach($this->damages as $damage){
178
-            if(!$damage instanceof FlightDamageCount){
177
+        foreach ($this->damages as $damage) {
178
+            if (!$damage instanceof FlightDamageCount) {
179 179
                 continue;
180 180
             }
181 181
 
@@ -185,11 +185,11 @@  discard block
 block discarded – undo
185 185
         return $flightCost;
186 186
     }
187 187
 
188
-    public function invoicedDamageCost(){
188
+    public function invoicedDamageCost() {
189 189
         $flightCost = FlightCost::zero();
190 190
 
191
-        foreach($this->damages as $damage){
192
-            if(!$damage instanceof FlightInvoicedDamageCount){
191
+        foreach ($this->damages as $damage) {
192
+            if (!$damage instanceof FlightInvoicedDamageCount) {
193 193
                 continue;
194 194
             }
195 195
 
@@ -199,7 +199,7 @@  discard block
 block discarded – undo
199 199
         return $flightCost;
200 200
     }
201 201
 
202
-    public function damages(){
202
+    public function damages() {
203 203
         return $this->damages;
204 204
     }
205 205
 
Please login to merge, or discard this patch.
query/BillableFlightQueryHandler.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -71,7 +71,7 @@  discard block
 block discarded – undo
71 71
                     $pilots[$obj->pilot] = $pilots[$obj->pilot]->addCount(
72 72
                         new FlightTypeCount(
73 73
                             $obj->type,
74
-                            (int)$obj->nbr,
74
+                            (int) $obj->nbr,
75 75
                             $this->getFactorByType($obj->type)
76 76
                         )
77 77
                     );
@@ -106,7 +106,7 @@  discard block
 block discarded – undo
106 106
                         $pilots[$obj->rowid] = $pilots[$obj->rowid]->addCount(
107 107
                             new FlightTypeCount(
108 108
                                 'orga',
109
-                                (int)$obj->total,
109
+                                (int) $obj->total,
110 110
                                 $this->getFactorByType('orga')
111 111
                             )
112 112
                         );
@@ -136,7 +136,7 @@  discard block
 block discarded – undo
136 136
                         $pilots[$obj->rowid] = $pilots[$obj->rowid]->addCount(
137 137
                             new FlightTypeCount(
138 138
                                 'orga_T6',
139
-                                (int)$obj->total,
139
+                                (int) $obj->total,
140 140
                                 $this->getFactorByType('orga_T6')
141 141
                             )
142 142
                         );
@@ -148,7 +148,7 @@  discard block
 block discarded – undo
148 148
 
149 149
         //Total damages
150 150
         $damages = $this->pilotDamageQueryRepository->query($query->getFiscalYear());
151
-        foreach($damages as $currentDamage){
151
+        foreach ($damages as $currentDamage) {
152 152
 
153 153
             //Pilot doesn't exist
154 154
             if (!isset($pilots[$currentDamage->getAuthorId()])) {
@@ -157,13 +157,13 @@  discard block
 block discarded – undo
157 157
 
158 158
             // Add all damage
159 159
             $pilots[$currentDamage->getAuthorId()]->addDamage(
160
-                new FlightDamageCount('',  $currentDamage->getAmount())
160
+                new FlightDamageCount('', $currentDamage->getAmount())
161 161
             );
162 162
 
163 163
             // The damage is already invoiced. So not take into account.
164
-            if($currentDamage->isInvoiced()){
164
+            if ($currentDamage->isInvoiced()) {
165 165
                 $pilots[$currentDamage->getAuthorId()]->addInvoicedDamage(
166
-                    new FlightInvoicedDamageCount('',  $currentDamage->getAmount())
166
+                    new FlightInvoicedDamageCount('', $currentDamage->getAmount())
167 167
                 );
168 168
             }
169 169
         }
Please login to merge, or discard this patch.
card_tab_financial.php 1 patch
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -43,7 +43,7 @@  discard block
 block discarded – undo
43 43
 
44 44
 $id = GETPOST('id', 'int') ?: GETPOST('idBBC_vols', 'int');
45 45
 $action = GETPOST('action', 'alpha');
46
-$permissiondellink=$user->rights->flightlog->vol->financial;
46
+$permissiondellink = $user->rights->flightlog->vol->financial;
47 47
 
48 48
 $object = new Bbcvols($db);
49 49
 $extrafields = new ExtraFields($db);
@@ -62,8 +62,8 @@  discard block
 block discarded – undo
62 62
 $extralabels = $extrafields->fetch_name_optionals_label($object->table_element);
63 63
 
64 64
 // Load object
65
-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
66
-include DOL_DOCUMENT_ROOT.'/core/actions_dellink.inc.php';
65
+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
66
+include DOL_DOCUMENT_ROOT . '/core/actions_dellink.inc.php';
67 67
 
68 68
 // Initialize technical object to manage hooks of modules. Note that conf->hooks_modules contains array array
69 69
 $hookmanager->initHooks(array('bbcvols'));
@@ -99,20 +99,20 @@  discard block
 block discarded – undo
99 99
 print '<tr><td class="fieldrequired">' . $langs->trans("Fielddate") . '</td><td>' . dol_print_date($object->date) . '</td></tr>';
100 100
 
101 101
 if ($user->rights->flightlog->vol->financial) {
102
-    print '<tr><td class="fieldrequired">' . $langs->trans("Fieldis_facture") . '</td><td>' . $object->getLibStatut(5). '</td></tr>';
102
+    print '<tr><td class="fieldrequired">' . $langs->trans("Fieldis_facture") . '</td><td>' . $object->getLibStatut(5) . '</td></tr>';
103 103
 }
104 104
 
105 105
 print '<tr><td class="fieldrequired">' . $langs->trans("Fieldkilometers") . '</td><td>' . $object->kilometers . ' KM</td></tr>';
106 106
 print '<tr><td class="fieldrequired">' . $langs->trans("Fieldjustif_kilometers") . '</td><td>' . $object->justif_kilometers . '</td></tr>';
107
-if($object->hasReceiver()){
107
+if ($object->hasReceiver()) {
108 108
     print '<tr><td class="fieldrequired">' . $langs->trans("Fieldcost") . '</td><td>' . $object->cost . " " . $langs->getCurrencySymbol($conf->currency) . '</td></tr>';
109 109
     print '<tr><td class="fieldrequired">' . $langs->trans("Fieldfk_receiver") . '</td><td>' . $receiver->getNomUrl(1) . '</td></tr>';
110 110
 }
111 111
 
112
-if($object->isLinkedToOrder()){
112
+if ($object->isLinkedToOrder()) {
113 113
     print '<tr><td class="fieldrequired">' . $langs->trans("Order") . '</td><td><ul>';
114
-    foreach($object->getOrders() as $currentOrder){
115
-        print '<li>'.$currentOrder->getNomUrl(1).'</li>';
114
+    foreach ($object->getOrders() as $currentOrder) {
115
+        print '<li>' . $currentOrder->getNomUrl(1) . '</li>';
116 116
     }
117 117
     print '</ul></td></tr>';
118 118
 }
@@ -124,18 +124,18 @@  discard block
 block discarded – undo
124 124
 print '<div class="tabsAction">' . "\n";
125 125
 
126 126
 // Make invoice
127
-if($user->rights->flightlog->vol->financial && $object->fk_type == 2 && !$object->hasFacture()){
128
-    print '<div class="inline-block divButAction"><a class="butAction" href="' . DOL_URL_ROOT . '/flightlog/facture.php?id=' . $object->id.'">' . $langs->trans("Facturer") . '</a></div>' . "\n";
127
+if ($user->rights->flightlog->vol->financial && $object->fk_type == 2 && !$object->hasFacture()) {
128
+    print '<div class="inline-block divButAction"><a class="butAction" href="' . DOL_URL_ROOT . '/flightlog/facture.php?id=' . $object->id . '">' . $langs->trans("Facturer") . '</a></div>' . "\n";
129 129
 }
130 130
 
131 131
 // Open
132
-if($object->isBilled() && $object->isBillingRequired()){
133
-    print '<div class="inline-block divButAction"><a class="butAction" href="' . DOL_URL_ROOT . '/flightlog/card_tab_financial.php?action=open&id=' . $object->id.'">' . $langs->trans("Ouvrir") . '</a></div>' . "\n";
132
+if ($object->isBilled() && $object->isBillingRequired()) {
133
+    print '<div class="inline-block divButAction"><a class="butAction" href="' . DOL_URL_ROOT . '/flightlog/card_tab_financial.php?action=open&id=' . $object->id . '">' . $langs->trans("Ouvrir") . '</a></div>' . "\n";
134 134
 }
135 135
 
136 136
 print '</div>' . "\n";
137 137
 
138
-if($user->rights->flightlog->vol->financial){
138
+if ($user->rights->flightlog->vol->financial) {
139 139
     print '<div class="fichecenter"><div class="fichehalfleft">';
140 140
     $form->showLinkedObjectBlock($object);
141 141
     print '</div></div>';
Please login to merge, or discard this patch.