Completed
Push — feature/graph_stat_flight ( ed413f )
by Laurent
01:27
created
card_tab_damage.php 2 patches
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -49,7 +49,7 @@  discard block
 block discarded – undo
49 49
 
50 50
 $id = GETPOST('id', 'int') ?: GETPOST('idBBC_vols', 'int');
51 51
 $action = GETPOST('action', 'alpha');
52
-$permissiondellink=$user->rights->flightlog->vol->financial;
52
+$permissiondellink = $user->rights->flightlog->vol->financial;
53 53
 
54 54
 $object = new Bbcvols($db);
55 55
 
@@ -57,8 +57,8 @@  discard block
 block discarded – undo
57 57
 $extralabels = $extrafields->fetch_name_optionals_label($object->table_element);
58 58
 
59 59
 // Load object
60
-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
61
-include DOL_DOCUMENT_ROOT.'/core/actions_dellink.inc.php';
60
+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
61
+include DOL_DOCUMENT_ROOT . '/core/actions_dellink.inc.php';
62 62
 
63 63
 // Initialize technical object to manage hooks of modules. Note that conf->hooks_modules contains array array
64 64
 $hookmanager->initHooks(array('bbcvols'));
@@ -85,13 +85,13 @@  discard block
 block discarded – undo
85 85
         FLIGHTLOG_ACTION_HANDLE_ADD_DAMAGE => [AddFlightDamageController::class, 'view'],
86 86
     ];
87 87
 
88
-    if(isset($routes[$action])){
88
+    if (isset($routes[$action])) {
89 89
         $controllerName = $routes[$action][0];
90 90
         $actionName = $routes[$action][1];
91 91
 
92 92
         $response = call_user_func([new $controllerName($db), $actionName]);
93 93
 
94
-        if($response instanceof \FlightLog\Http\Web\Response\Redirect){
94
+        if ($response instanceof \FlightLog\Http\Web\Response\Redirect) {
95 95
             if (headers_sent()) {
96 96
                 echo(sprintf("<script>location.href='%s'</script>", $response->getUrl()));
97 97
                 exit;
@@ -102,7 +102,7 @@  discard block
 block discarded – undo
102 102
         }
103 103
 
104 104
         include $response->getTemplate();
105
-    }else{
105
+    } else {
106 106
         echo 'Route non trouvée.';
107 107
     }
108 108
 ?>
@@ -114,13 +114,13 @@  discard block
 block discarded – undo
114 114
 // Buttons
115 115
 print '<div class="tabsAction">' . "\n";
116 116
 
117
-if($user->rights->flightlog->vol->financial){
118
-    print '<div class="inline-block divButAction"><a class="butAction" href="' . DOL_URL_ROOT . '/flightlog/card_tab_damage.php?id=' . $object->id.'&action='.FLIGHTLOG_ACTION_ADD_DAMAGE.'">' . $langs->trans("Ajouter") . '</a></div>' . "\n";
117
+if ($user->rights->flightlog->vol->financial) {
118
+    print '<div class="inline-block divButAction"><a class="butAction" href="' . DOL_URL_ROOT . '/flightlog/card_tab_damage.php?id=' . $object->id . '&action=' . FLIGHTLOG_ACTION_ADD_DAMAGE . '">' . $langs->trans("Ajouter") . '</a></div>' . "\n";
119 119
 }
120 120
 
121 121
 print '</div>' . "\n";
122 122
 
123
-if($user->rights->flightlog->vol->financial){
123
+if ($user->rights->flightlog->vol->financial) {
124 124
     print '<div class="fichecenter"><div class="fichehalfleft">';
125 125
     $form->showLinkedObjectBlock($object);
126 126
     print '</div></div>';
Please login to merge, or discard this patch.
Braces   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -102,7 +102,7 @@
 block discarded – undo
102 102
         }
103 103
 
104 104
         include $response->getTemplate();
105
-    }else{
105
+    } else{
106 106
         echo 'Route non trouvée.';
107 107
     }
108 108
 ?>
Please login to merge, or discard this patch.
index.php 2 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
 $routesGuards = require './Infrastructure/Common/Routes/guards.conf.php';
54 54
 
55 55
 $response = null;
56
-try{
56
+try {
57 57
     $routeName = GETPOST('r');
58 58
 
59 59
     $routeManager = new \FlightLog\Infrastructure\Common\Routes\RouteManager($db);
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
 
63 63
     $response = $routeManager->__invoke($routeName, $user);
64 64
 
65
-    if($response instanceof \FlightLog\Http\Web\Response\Redirect){
65
+    if ($response instanceof \FlightLog\Http\Web\Response\Redirect) {
66 66
         if (headers_sent()) {
67 67
             echo(sprintf("<script>location.href='%s'</script>", $response->getUrl()));
68 68
             exit;
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
         exit;
73 73
     }
74 74
 
75
-}catch (\Exception $e){
75
+} catch (\Exception $e) {
76 76
     dol_syslog($e->getMessage(), LOG_ERR);
77 77
     $response = new \FlightLog\Http\Web\Response\Response($e->getMessage());
78 78
 }
Please login to merge, or discard this patch.
Braces   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -72,7 +72,7 @@
 block discarded – undo
72 72
         exit;
73 73
     }
74 74
 
75
-}catch (\Exception $e){
75
+} catch (\Exception $e){
76 76
     dol_syslog($e->getMessage(), LOG_ERR);
77 77
     $response = new \FlightLog\Http\Web\Response\Response($e->getMessage());
78 78
 }
Please login to merge, or discard this patch.
Infrastructure/Common/Routes/RouteManager.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -38,8 +38,8 @@  discard block
 block discarded – undo
38 38
      *
39 39
      * @throws \Exception
40 40
      */
41
-    public function add(Route $route){
42
-        if(isset($this->routes[$route->getName()])){
41
+    public function add(Route $route) {
42
+        if (isset($this->routes[$route->getName()])) {
43 43
             throw new \Exception('Route exists');
44 44
         }
45 45
 
@@ -51,8 +51,8 @@  discard block
 block discarded – undo
51 51
      *
52 52
      * @throws \Exception
53 53
      */
54
-    public function load(array $routes){
55
-        foreach($routes as $currentRoute){
54
+    public function load(array $routes) {
55
+        foreach ($routes as $currentRoute) {
56 56
             $this->add($currentRoute);
57 57
         }
58 58
     }
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
      */
63 63
     public function loadGuards($routesGuards)
64 64
     {
65
-        foreach($routesGuards as $guard){
65
+        foreach ($routesGuards as $guard) {
66 66
             $this->guards[$guard->getRouteName()] = $guard;
67 67
         }
68 68
     }
@@ -73,8 +73,8 @@  discard block
 block discarded – undo
73 73
      * @param $routeName
74 74
      * @return bool
75 75
      */
76
-    public function isAuthorized(User $user, $routeName){
77
-        if(!isset($this->guards[$routeName])){
76
+    public function isAuthorized(User $user, $routeName) {
77
+        if (!isset($this->guards[$routeName])) {
78 78
             return true;
79 79
         }
80 80
 
@@ -92,11 +92,11 @@  discard block
 block discarded – undo
92 92
      */
93 93
     public function __invoke($name, User $user)
94 94
     {
95
-        if(!isset($this->routes[$name])){
95
+        if (!isset($this->routes[$name])) {
96 96
             throw new \Exception('Route not found');
97 97
         }
98 98
 
99
-        if(!$this->isAuthorized($user, $name)){
99
+        if (!$this->isAuthorized($user, $name)) {
100 100
             throw new \Exception('Action not allowed');
101 101
         }
102 102
 
Please login to merge, or discard this patch.
class/actions_flightlog.class.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -58,8 +58,8 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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'] = [
Please login to merge, or discard this patch.
damage/tpl/linkedobjectblock.tpl.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -45,13 +45,13 @@
 block discarded – undo
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>
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.author_id as author_id, damage.rowid as id, damage.amount, 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.
Application/Damage/ViewModel/Damage.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -66,13 +66,13 @@
 block discarded – undo
66 66
      *
67 67
      * @return Damage
68 68
      */
69
-    public static function fromArray(array $properties){
69
+    public static function fromArray(array $properties) {
70 70
         $authorId = $properties['author_id'];
71 71
         $author = $properties['author_name'];
72 72
         $amount = $properties['amount'];
73 73
         $id = $properties['id'];
74 74
         $flightId = isset($properties['flight_id']) ? $properties['flight_id'] : null;
75
-        $invoiced = (bool)$properties['invoiced'];
75
+        $invoiced = (bool) $properties['invoiced'];
76 76
 
77 77
         return new self($authorId, $author, $amount, $id, $invoiced, $flightId);
78 78
     }
Please login to merge, or discard this patch.
Http/Web/Controller/StatisticalGraphController.php 2 patches
Indentation   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -83,19 +83,19 @@
 block discarded – undo
83 83
              * @var int $month
84 84
              * @var Statistic $stat */
85 85
             foreach($months as $month => $stat){
86
-               if(!isset($series[$month-1])){
87
-                   $series[$month-1] = [substr(\DateTime::createFromFormat('!m', $month)->format('F'),0,1)];
88
-               };
89
-               $series[$month-1][$i] = $stat->number();
90
-
91
-               if($year === 2020){
92
-                   continue;
93
-               }
94
-
95
-               if(!isset($average[$month-1])){
96
-                   $average[$month-1] = 0;
97
-               }
98
-               $average[$month-1] += $stat->number();
86
+                if(!isset($series[$month-1])){
87
+                    $series[$month-1] = [substr(\DateTime::createFromFormat('!m', $month)->format('F'),0,1)];
88
+                };
89
+                $series[$month-1][$i] = $stat->number();
90
+
91
+                if($year === 2020){
92
+                    continue;
93
+                }
94
+
95
+                if(!isset($average[$month-1])){
96
+                    $average[$month-1] = 0;
97
+                }
98
+                $average[$month-1] += $stat->number();
99 99
             }
100 100
 
101 101
             $i++;
Please login to merge, or discard this patch.
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -31,19 +31,19 @@  discard block
 block discarded – undo
31 31
 
32 32
         $i = 10;
33 33
         foreach ($series[0] as $key => $year) {
34
-            if($key == 0){
34
+            if ($key == 0) {
35 35
                 continue;
36 36
             }
37 37
 
38 38
             $graphType[] = $key == 5 ? "lines" : 'linesnopoint';
39 39
             $color[] = $graph->datacolor[$key];
40 40
 
41
-            $i+=30;
41
+            $i += 30;
42 42
         }
43
-        $color[count($color)-1] = [255,0,0]; // Average is red
43
+        $color[count($color) - 1] = [255, 0, 0]; // Average is red
44 44
 
45
-        $color[count($color)-2] = [0,100,255]; //Current year
46
-        $graphType[count($color)-2] = 'bars';
45
+        $color[count($color) - 2] = [0, 100, 255]; //Current year
46
+        $graphType[count($color) - 2] = 'bars';
47 47
 
48 48
         $graph->SetDataColor($color);
49 49
 
@@ -82,27 +82,27 @@  discard block
 block discarded – undo
82 82
             /**
83 83
              * @var int $month
84 84
              * @var Statistic $stat */
85
-            foreach($months as $month => $stat){
86
-               if(!isset($series[$month-1])){
87
-                   $series[$month-1] = [substr(\DateTime::createFromFormat('!m', $month)->format('F'),0,1)];
85
+            foreach ($months as $month => $stat) {
86
+               if (!isset($series[$month - 1])) {
87
+                   $series[$month - 1] = [substr(\DateTime::createFromFormat('!m', $month)->format('F'), 0, 1)];
88 88
                };
89
-               $series[$month-1][$i] = $stat->number();
89
+               $series[$month - 1][$i] = $stat->number();
90 90
 
91
-               if($year === 2020){
91
+               if ($year === 2020) {
92 92
                    continue;
93 93
                }
94 94
 
95
-               if(!isset($average[$month-1])){
96
-                   $average[$month-1] = 0;
95
+               if (!isset($average[$month - 1])) {
96
+                   $average[$month - 1] = 0;
97 97
                }
98
-               $average[$month-1] += $stat->number();
98
+               $average[$month - 1] += $stat->number();
99 99
             }
100 100
 
101 101
             $i++;
102 102
         }
103 103
 
104
-        foreach($series as $monthIndex => $seriesValue){
105
-            $series[$monthIndex][] = $average[$monthIndex] / ($numberOfYears-1);
104
+        foreach ($series as $monthIndex => $seriesValue) {
105
+            $series[$monthIndex][] = $average[$monthIndex] / ($numberOfYears - 1);
106 106
         }
107 107
 
108 108
         return $series;
Please login to merge, or discard this patch.
Flight/Query/Repository/GetBillableFlightPerMonthQueryRepository.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -64,13 +64,13 @@
 block discarded – undo
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
     }
Please login to merge, or discard this patch.