@@ -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 | |
@@ -6,9 +6,9 @@ |
||
| 6 | 6 | |
| 7 | 7 | final class FlightController extends WebController |
| 8 | 8 | { |
| 9 | - public function view(){ |
|
| 9 | + public function view() { |
|
| 10 | 10 | $id = $this->request->getParam('id'); |
| 11 | - return $this->redirect(DOL_URL_ROOT.'/flightlog/card.php?id='.$id); |
|
| 11 | + return $this->redirect(DOL_URL_ROOT . '/flightlog/card.php?id=' . $id); |
|
| 12 | 12 | } |
| 13 | 13 | |
| 14 | 14 | } |
| 15 | 15 | \ No newline at end of file |
@@ -25,7 +25,7 @@ |
||
| 25 | 25 | * |
| 26 | 26 | * @return Redirect |
| 27 | 27 | */ |
| 28 | - public static function create($url){ |
|
| 28 | + public static function create($url) { |
|
| 29 | 29 | return new self($url); |
| 30 | 30 | } |
| 31 | 31 | |
@@ -53,7 +53,7 @@ discard block |
||
| 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 |
||
| 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 |
||
| 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 | } |
@@ -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 | ]; |
@@ -38,8 +38,8 @@ discard block |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 | |
@@ -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> |
@@ -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 | |