| @@ -1,9 +1,6 @@ | ||
| 1 | 1 | <?php | 
| 2 | 2 | |
| 3 | -use FlightLog\Http\Web\Controller\DamageController; | |
| 4 | -use FlightLog\Http\Web\Controller\FlightController; | |
| 5 | 3 | use FlightLog\Infrastructure\Common\Routes\Guard; | 
| 6 | -use FlightLog\Infrastructure\Common\Routes\Route; | |
| 7 | 4 | |
| 8 | 5 | global $db; | 
| 9 | 6 | |
| @@ -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 | ]; | 
| @@ -19,16 +19,16 @@ discard block | ||
| 19 | 19 | /** | 
| 20 | 20 | * Display the form. | 
| 21 | 21 | */ | 
| 22 | -    public function view(){ | |
| 22 | +    public function view() { | |
| 23 | 23 |          $id = $this->request->getParam('id'); | 
| 24 | 24 | |
| 25 | -        if($id === null){ | |
| 25 | +        if ($id === null) { | |
| 26 | 26 | print '<p>Paramètre non fournis.</p>'; | 
| 27 | 27 | return; | 
| 28 | 28 | } | 
| 29 | 29 | |
| 30 | 30 | $flight = new \Bbcvols($this->db); | 
| 31 | -        if($flight->fetch($id) <= 0){ | |
| 31 | +        if ($flight->fetch($id) <= 0) { | |
| 32 | 32 | print '<p>Vol non trouvé</p>'; | 
| 33 | 33 | return; | 
| 34 | 34 | } | 
| @@ -39,24 +39,24 @@ discard block | ||
| 39 | 39 |          $form = new DamageCreationForm('damage_creation', $this->db); | 
| 40 | 40 | $form->bind($command); | 
| 41 | 41 | |
| 42 | -        if($this->request->isPost()){ | |
| 42 | +        if ($this->request->isPost()) { | |
| 43 | 43 | $form->setData($this->request->getPostParameters()); | 
| 44 | 44 | |
| 45 | -            if(!$form->validate()){ | |
| 45 | +            if (!$form->validate()) { | |
| 46 | 46 |                  return $this->render('flight_damage/form.php', [ | 
| 47 | 47 | 'form' => $form, | 
| 48 | 48 | ]); | 
| 49 | 49 | } | 
| 50 | 50 | |
| 51 | -            try{ | |
| 51 | +            try { | |
| 52 | 52 | $this->handle($form->getObject()); | 
| 53 | -            }catch(\Exception $e){ | |
| 53 | +            } catch (\Exception $e) { | |
| 54 | 54 | print $e->getMessage(); | 
| 55 | 55 | dol_syslog($e->getMessage(), LOG_ERR); | 
| 56 | 56 | } | 
| 57 | 57 | |
| 58 | 58 | |
| 59 | - return $this->redirect($_SERVER["PHP_SELF"].'?id='.$id); | |
| 59 | + return $this->redirect($_SERVER["PHP_SELF"] . '?id=' . $id); | |
| 60 | 60 | } | 
| 61 | 61 | |
| 62 | 62 |          return $this->render('flight_damage/form.php', [ | 
| @@ -77,14 +77,14 @@ discard block | ||
| 77 | 77 | /** | 
| 78 | 78 | * @return CreateDamageCommandHandler | 
| 79 | 79 | */ | 
| 80 | -    private function getHandler(){ | |
| 80 | +    private function getHandler() { | |
| 81 | 81 | return new CreateDamageCommandHandler($this->db, $this->getDamageRepository()); | 
| 82 | 82 | } | 
| 83 | 83 | |
| 84 | 84 | /** | 
| 85 | 85 | * @return FlightDamageRepository | 
| 86 | 86 | */ | 
| 87 | -    private function getDamageRepository(){ | |
| 87 | +    private function getDamageRepository() { | |
| 88 | 88 | return new FlightDamageRepository($this->db); | 
| 89 | 89 | } | 
| 90 | 90 | |
| @@ -13,14 +13,14 @@ discard block | ||
| 13 | 13 | /** | 
| 14 | 14 | * @return GetDamageQueryRepository | 
| 15 | 15 | */ | 
| 16 | -    private function getDamageRepository(){ | |
| 16 | +    private function getDamageRepository() { | |
| 17 | 17 | return new GetDamageQueryRepository($this->db); | 
| 18 | 18 | } | 
| 19 | 19 | |
| 20 | -    public function view(){ | |
| 20 | +    public function view() { | |
| 21 | 21 |          $damageId = $this->request->getParam('id'); | 
| 22 | 22 | |
| 23 | -        try{ | |
| 23 | +        try { | |
| 24 | 24 | $damage = $this->getDamageRepository()->query($damageId); | 
| 25 | 25 | |
| 26 | 26 | $flight = new \Bbcvols($this->db); | 
| @@ -31,16 +31,16 @@ discard block | ||
| 31 | 31 | 'form' => new Form($this->db), | 
| 32 | 32 | 'flight' => $flight | 
| 33 | 33 | ]); | 
| 34 | -        }catch (\Exception $e){ | |
| 34 | +        } catch (\Exception $e) { | |
| 35 | 35 | echo $e->getMessage(); | 
| 36 | 36 | } | 
| 37 | 37 | } | 
| 38 | 38 | |
| 39 | -    public function invoice(){ | |
| 39 | +    public function invoice() { | |
| 40 | 40 |          $damageId = $this->request->getParam('id'); | 
| 41 | 41 | |
| 42 | 42 | |
| 43 | 43 | |
| 44 | - return $this->redirect($_SERVER["PHP_SELF"].'?id='.$damageId); | |
| 44 | + return $this->redirect($_SERVER["PHP_SELF"] . '?id=' . $damageId); | |
| 45 | 45 | } | 
| 46 | 46 | } | 
| 47 | 47 | \ No newline at end of file | 
| @@ -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 | |
| @@ -250,7 +250,7 @@ discard block | ||
| 250 | 250 | */ | 
| 251 | 251 | private function addOrderDiscount($order, $pilotFlightCount, $service, $year) | 
| 252 | 252 |      { | 
| 253 | - $price = $pilotFlightCount->getCost()->getValue()/(1+$service->tva_tx/100); | |
| 253 | + $price = $pilotFlightCount->getCost()->getValue() / (1 + $service->tva_tx / 100); | |
| 254 | 254 | $pu_ht = price2num($price, 'MU'); | 
| 255 | 255 |          $desc = $year . " - " . $service->label . " - (" . $pilotFlightCount->getCount() . " * " . $pilotFlightCount->getFactor() . ")"; | 
| 256 | 256 | |
| @@ -281,7 +281,7 @@ discard block | ||
| 281 | 281 | return; | 
| 282 | 282 | } | 
| 283 | 283 | |
| 284 | - $pointsHt = $command->getAdditionalBonus()/(1+6/100); | |
| 284 | + $pointsHt = $command->getAdditionalBonus() / (1 + 6 / 100); | |
| 285 | 285 |          $desc = sprintf("%s - %s", $command->getYear(), $command->getBonusAdditionalMessage()); | 
| 286 | 286 | |
| 287 | 287 | $discountid = $this->getCompany($object->socid)->set_remise_except($pointsHt, $this->user, $desc, 6); | 
| @@ -301,7 +301,7 @@ discard block | ||
| 301 | 301 |      { | 
| 302 | 302 | $price = $damage->getCost()->addCost($invoicedDamage->getCost())->getValue(); | 
| 303 | 303 | |
| 304 | -        if($price <= 0 ){ | |
| 304 | +        if ($price <= 0) { | |
| 305 | 305 | return; | 
| 306 | 306 | } | 
| 307 | 307 | |
| @@ -49,7 +49,7 @@ discard block | ||
| 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 | ||
| 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 | ||
| 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 | ||
| 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 | ||
| 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>'; | 
| @@ -102,7 +102,7 @@ | ||
| 102 | 102 | } | 
| 103 | 103 | |
| 104 | 104 | include $response->getTemplate(); | 
| 105 | -    }else{ | |
| 105 | +    } else{ | |
| 106 | 106 | echo 'Route non trouvée.'; | 
| 107 | 107 | } | 
| 108 | 108 | ?> | 
| @@ -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 | } | 
| @@ -72,7 +72,7 @@ | ||
| 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 | } |