@@ -58,8 +58,8 @@ discard block |
||
58 | 58 | * |
59 | 59 | * @return int |
60 | 60 | */ |
61 | - public function showLinkedObjectBlock(array $params = [], $object){ |
|
62 | - if(!isset($object->linkedObjectsIds) || !isset($object->linkedObjectsIds['flightlog_damage'])){ |
|
61 | + public function showLinkedObjectBlock(array $params = [], $object) { |
|
62 | + if (!isset($object->linkedObjectsIds) || !isset($object->linkedObjectsIds['flightlog_damage'])) { |
|
63 | 63 | return 0; |
64 | 64 | } |
65 | 65 | |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | dol_include_once('/flightlog/flightlog.inc.php'); |
70 | 70 | $queryRepository = new \FlightLog\Infrastructure\Damage\Query\Repository\GetDamageQueryRepository($db); |
71 | 71 | |
72 | - foreach($object->linkedObjectsIds['flightlog_damage'] as $damageId){ |
|
72 | + foreach ($object->linkedObjectsIds['flightlog_damage'] as $damageId) { |
|
73 | 73 | try { |
74 | 74 | $object->linkedObjects['flightlog_damage'][$damageId] = $queryRepository->query($damageId); |
75 | 75 | } catch (Exception $e) { |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | return $sql; |
100 | 100 | } |
101 | 101 | |
102 | - public function completeListOfReferent(){ |
|
102 | + public function completeListOfReferent() { |
|
103 | 103 | dol_include_once('/flightlog/class/bbcvols.class.php'); |
104 | 104 | |
105 | 105 | $this->results['flightlog'] = [ |
@@ -45,13 +45,13 @@ |
||
45 | 45 | $var = !$var; |
46 | 46 | $trclass = ($var ? 'pair' : 'impair'); |
47 | 47 | |
48 | - if(!$user->rights->flightlog->vol->financial && $user->rowid != $damage->getAuthorId()){ |
|
48 | + if (!$user->rights->flightlog->vol->financial && $user->rowid != $damage->getAuthorId()) { |
|
49 | 49 | continue; |
50 | 50 | } |
51 | 51 | ?> |
52 | 52 | <tr <?php echo $GLOBALS['bc'][$var]; ?> > |
53 | 53 | <td><?php echo $langs->trans("Dégâts"); ?></td> |
54 | - <td><a href="<?php echo sprintf(DOL_URL_ROOT.'/flightlog/index.php?id=%s&r=%s', $damage->getId(), 'get_one_damage');?>"><?php echo $damage->getId()?></a></td> |
|
54 | + <td><a href="<?php echo sprintf(DOL_URL_ROOT . '/flightlog/index.php?id=%s&r=%s', $damage->getId(), 'get_one_damage'); ?>"><?php echo $damage->getId()?></a></td> |
|
55 | 55 | <td align="center"><?php echo $damage->getAuthorName(); ?></td> |
56 | 56 | <td align="center"></td> |
57 | 57 | <td align="right"><?echo price($damage->getAmount()) ?>€</td> |
@@ -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.author_id as author_id, damage.rowid as id, damage.amount, CONCAT(author.firstname, " " , author.lastname) 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 |
@@ -64,13 +64,13 @@ |
||
64 | 64 | |
65 | 65 | $stats = new BillableFlightByYearMonth(); |
66 | 66 | |
67 | - for($i = 0; $i < $num ; $i++) { |
|
67 | + for ($i = 0; $i < $num; $i++) { |
|
68 | 68 | $properties = $this->db->fetch_array($resql); |
69 | 69 | $stat = Statistic::fromArray($properties); |
70 | 70 | $stats->add($stat); |
71 | 71 | } |
72 | 72 | |
73 | - $stats->add(new Statistic(0,1,(new \DateTime())->format('Y'))); |
|
73 | + $stats->add(new Statistic(0, 1, (new \DateTime())->format('Y'))); |
|
74 | 74 | |
75 | 75 | return $stats; |
76 | 76 | } |
@@ -16,9 +16,9 @@ discard block |
||
16 | 16 | |
17 | 17 | public function add(Statistic $stat) |
18 | 18 | { |
19 | - if(!isset($this->data[$stat->year()])){ |
|
19 | + if (!isset($this->data[$stat->year()])) { |
|
20 | 20 | $this->data[$stat->year()] = []; |
21 | - for($i = 1 ; $i <= 12 ; $i++){ |
|
21 | + for ($i = 1; $i <= 12; $i++) { |
|
22 | 22 | $this->data[$stat->year()][$i] = new Statistic(0, $stat->month(), $stat->year()); |
23 | 23 | } |
24 | 24 | } |
@@ -26,11 +26,11 @@ discard block |
||
26 | 26 | $this->data[$stat->year()][$stat->month()] = $stat; |
27 | 27 | } |
28 | 28 | |
29 | - public function data(){ |
|
29 | + public function data() { |
|
30 | 30 | return $this->data; |
31 | 31 | } |
32 | 32 | |
33 | - public function years(){ |
|
33 | + public function years() { |
|
34 | 34 | return array_keys($this->data); |
35 | 35 | } |
36 | 36 |
@@ -44,11 +44,11 @@ |
||
44 | 44 | return $this->number; |
45 | 45 | } |
46 | 46 | |
47 | - public function year(){ |
|
47 | + public function year() { |
|
48 | 48 | return $this->year; |
49 | 49 | } |
50 | 50 | |
51 | - public function month(){ |
|
51 | + public function month() { |
|
52 | 52 | return $this->month; |
53 | 53 | } |
54 | 54 |
@@ -136,7 +136,7 @@ |
||
136 | 136 | $graphByTypeAndYear->type = []; |
137 | 137 | foreach (fetchBbcFlightTypes() as $flightType) { |
138 | 138 | |
139 | - if (!in_array($flightType->numero, [1, 2, 3,4, 6])) { |
|
139 | + if (!in_array($flightType->numero, [1, 2, 3, 4, 6])) { |
|
140 | 140 | continue; |
141 | 141 | } |
142 | 142 |
@@ -69,7 +69,7 @@ |
||
69 | 69 | $result = [$this->year]; |
70 | 70 | |
71 | 71 | foreach ($this->graphData as $typeId => $data) { |
72 | - if (!in_array($typeId, [1, 2, 3,4, 6])) { |
|
72 | + if (!in_array($typeId, [1, 2, 3, 4, 6])) { |
|
73 | 73 | continue; |
74 | 74 | } |
75 | 75 |
@@ -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 | } |