diff --git a/src/Application/Helper/Header.php b/src/Application/Helper/Header.php new file mode 100644 index 0000000..796713a --- /dev/null +++ b/src/Application/Helper/Header.php @@ -0,0 +1,32 @@ +getBaseUrl() . "/"; + return array( + 'klant' => $klant, + 'base' => $base + ); + } +} diff --git a/src/Application/Main.php b/src/Application/Main.php index 02d056c..0646609 100644 --- a/src/Application/Main.php +++ b/src/Application/Main.php @@ -15,8 +15,7 @@ namespace Inforbank\Application; use \Slim\App; -use Inforbank\Application\Helper\Klant; -use Inforbank\Application\Helper\Rekeningen; +use Inforbank\Application\Helper\Redirect; class Main { @@ -34,15 +33,7 @@ class Main public function __construct(App $app) { $app->get('/', function ($request, $response, $args) { - // Ophalen klant - $klant = Klant::getCurrentUser(); - $rekeningen = Rekeningen::getCurrentUserRekeningen(); - - // Render index view - return $this->renderer->render($response, 'index.phtml', [ - 'klant' => $klant, - 'rekeningen' => $rekeningen - ]); + return Redirect::create($request, $response, '/rekeningen'); })->add(new Auth\Middleware()); } } diff --git a/src/Application/Overboeking.php b/src/Application/Overboeking.php index b80a941..a7e55d0 100644 --- a/src/Application/Overboeking.php +++ b/src/Application/Overboeking.php @@ -16,19 +16,19 @@ namespace Inforbank\Application; use Inforbank\Application; use Inforbank\Application\Helper\IBAN; -use Inforbank\Application\Helper\Klant; +use Inforbank\Application\Helper\Header; use Inforbank\Application\Helper\Redirect; use Inforbank\Application\Helper\Rekeningen; use Slim\App; -class Overboeking { - - public function __construct(App $app) { +class Overboeking +{ + public function __construct(App $app) + { $app->get('/overboeking', function ($request, $response, $args) { - $klant = Klant::getCurrentUser(); $rekeningen = Rekeningen::getCurrentUserRekeningen(); return $this->renderer->render($response, 'overboeking.phtml', [ - 'klant' => $klant, + 'header' => Header::getHeaderData(), 'rekeningen' => $rekeningen ]); }); @@ -59,7 +59,7 @@ class Overboeking { if (!$ibanHelper->isValidIBAN($naar)) { //error: ongeldige iban return Redirect::create($request, $response, "/ongeldig"); - } else if (!($ibanHelper->getLand($naar) == "NL" && $ibanHelper->getBank($naar) === "INFO")) { + } elseif (!($ibanHelper->getLand($naar) == "NL" && $ibanHelper->getBank($naar) === "INFO")) { //error: andere bank return Redirect::create($request, $response, "/andere"); } @@ -89,5 +89,4 @@ class Overboeking { return Redirect::create($request, $response, "/"); }); } - } diff --git a/src/Application/Rekeningen.php b/src/Application/Rekeningen.php new file mode 100644 index 0000000..c4c591e --- /dev/null +++ b/src/Application/Rekeningen.php @@ -0,0 +1,36 @@ +get('/rekeningen', function ($request, $response, $args) { + // Ophalen klant + $rekeningen = RekeningHelper::getCurrentUserRekeningen(); + + // Render index view + return $this->renderer->render($response, 'index.phtml', [ + 'header' => Header::getHeaderData(), + 'rekeningen' => $rekeningen + ]); + })->add(new Auth\Middleware()); + } +} diff --git a/src/Application/Transacties.php b/src/Application/Transacties.php index a289b2b..9b40efc 100644 --- a/src/Application/Transacties.php +++ b/src/Application/Transacties.php @@ -15,7 +15,7 @@ namespace Inforbank\Application; use \Slim\App; -use Inforbank\Application\Helper\Klant; +use Inforbank\Application\Helper\Header; use Inforbank\Application\Helper\Rekeningen; use Inforbank\Application\Helper\IBAN; use Inforbank\Application; @@ -25,21 +25,20 @@ class Transacties public function __construct(App $app) { $app->get('/rekeningen/{rekeningnummer}', function ($request, $response, $args) { - $klant = Klant::getCurrentUser(); $rekeningen = Rekeningen::getCurrentUserRekeningen(); - + $ibanhelper = new IBAN; $rekening = false; $rekeningnr = $args['rekeningnummer']; //Controleer of deze rekening wel van de ingelogde klant is - foreach($rekeningen as $rek){ - if($rek['nr'] === $rekeningnr){ - $rekening = $rek; - break; + foreach ($rekeningen as $rek) { + if ($rek['nr'] === $rekeningnr) { + $rekening = $rek; + break; } } - if(!$rekening){ + if (!$rekening) { return $this->renderer->render($response, 'transacties.phtml', [ 'klant' => $klant, 'rekening' => false @@ -52,7 +51,7 @@ class Transacties $returnArray = array(); foreach ($transacties as $transactie) { - $returnArray[] = array( + $returnArray[] = array( "van" => $ibanhelper->getIBAN($transactie['van']), "naar" => $ibanhelper->getIBAN($transactie['naar']), "bedrag" => $transactie['bedrag'], @@ -60,9 +59,9 @@ class Transacties ); } return $this->renderer->render($response, 'transacties.phtml', [ - 'klant' => $klant, + 'header' => Header::getHeaderData(), 'rekening' => $rekening, - 'transacties' => $returnArray + 'transacties' => $returnArray ]); }); } diff --git a/src/Proxy.php b/src/Proxy.php index 03a7266..afcdbe7 100644 --- a/src/Proxy.php +++ b/src/Proxy.php @@ -16,9 +16,14 @@ namespace Inforbank; class Proxy { + public static $route; + public function __invoke($request, $response, $next) { $uri = $request->getUri(); + + self::$route = $uri; + $path = $uri->getPath(); $pa = explode('assets/', $path, 2); diff --git a/src/bootstrap.php b/src/bootstrap.php index f2f6cc3..771d735 100644 --- a/src/bootstrap.php +++ b/src/bootstrap.php @@ -118,6 +118,7 @@ new Inforbank\Application\Daniel($app); new Inforbank\Application\Main($app); new Inforbank\Application\Transacties($app); new Inforbank\Application\Overboeking($app); +new Inforbank\Application\Rekeningen($app); // Added API handler new Inforbank\Application\API\Handler($app); diff --git a/templates/__header.phtml b/templates/__header.phtml index 8fc6256..1638ab8 100644 --- a/templates/__header.phtml +++ b/templates/__header.phtml @@ -5,6 +5,7 @@ Inforbank +
@@ -12,11 +13,11 @@
Inforbank
- Welkom
+ ?>
Uitloggen
@@ -25,8 +26,7 @@