Completed
Push — feature/fixing_cost ( 414fbf...99877f )
by Laurent
01:40
created
Infrastructure/Damage/Query/Repository/GetPilotDamagesQueryRepository.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -35,16 +35,16 @@
 block discarded – undo
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;
Please login to merge, or discard this patch.
Application/Damage/Command/InvoiceDamageCommandHandler.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -28,7 +28,7 @@
 block discarded – undo
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);
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.
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.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
                 }
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
@@ -41,7 +41,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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))
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
@@ -59,12 +59,12 @@
 block discarded – undo
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
     }
Please login to merge, or discard this patch.
Http/Web/templates/flight_damage/view.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -14,20 +14,20 @@
 block discarded – undo
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; ?>
Please login to merge, or discard this patch.
Http/Web/templates/damage/view.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -53,9 +53,9 @@
 block discarded – undo
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>
Please login to merge, or discard this patch.
class/Damage/FlightDamage.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 
Please login to merge, or discard this patch.