1
0

Added base routing + moved rekeningen

This commit is contained in:
Christiaan Goossens 2017-03-30 18:56:01 +02:00
parent ffe56bcf9b
commit afc472e7d7
8 changed files with 99 additions and 36 deletions

View File

@ -0,0 +1,32 @@
<?php
/**
* Informatica Eindproject D4p
* 6in3, Stedelijk Gymnasium Nijmegen
* Docent: Hans de Wolf
*
* ==================
*
* Daniel Boutros,
* Christiaan Goossens,
* Jelmer Hinssen
*/
namespace Inforbank\Application\Helper;
use Inforbank\Application;
use Inforbank\Application\Helper\Klant;
use Inforbank\Proxy;
class Header
{
public static function getHeaderData()
{
$klant = Klant::getCurrentUser();
$base = Proxy::$route->getBaseUrl() . "/";
return array(
'klant' => $klant,
'base' => $base
);
}
}

View File

@ -15,8 +15,7 @@
namespace Inforbank\Application; namespace Inforbank\Application;
use \Slim\App; use \Slim\App;
use Inforbank\Application\Helper\Klant; use Inforbank\Application\Helper\Redirect;
use Inforbank\Application\Helper\Rekeningen;
class Main class Main
{ {
@ -34,15 +33,7 @@ class Main
public function __construct(App $app) public function __construct(App $app)
{ {
$app->get('/', function ($request, $response, $args) { $app->get('/', function ($request, $response, $args) {
// Ophalen klant return Redirect::create($request, $response, '/rekeningen');
$klant = Klant::getCurrentUser();
$rekeningen = Rekeningen::getCurrentUserRekeningen();
// Render index view
return $this->renderer->render($response, 'index.phtml', [
'klant' => $klant,
'rekeningen' => $rekeningen
]);
})->add(new Auth\Middleware()); })->add(new Auth\Middleware());
} }
} }

View File

@ -16,19 +16,19 @@ namespace Inforbank\Application;
use Inforbank\Application; use Inforbank\Application;
use Inforbank\Application\Helper\IBAN; use Inforbank\Application\Helper\IBAN;
use Inforbank\Application\Helper\Klant; use Inforbank\Application\Helper\Header;
use Inforbank\Application\Helper\Redirect; use Inforbank\Application\Helper\Redirect;
use Inforbank\Application\Helper\Rekeningen; use Inforbank\Application\Helper\Rekeningen;
use Slim\App; use Slim\App;
class Overboeking { class Overboeking
{
public function __construct(App $app) { public function __construct(App $app)
{
$app->get('/overboeking', function ($request, $response, $args) { $app->get('/overboeking', function ($request, $response, $args) {
$klant = Klant::getCurrentUser();
$rekeningen = Rekeningen::getCurrentUserRekeningen(); $rekeningen = Rekeningen::getCurrentUserRekeningen();
return $this->renderer->render($response, 'overboeking.phtml', [ return $this->renderer->render($response, 'overboeking.phtml', [
'klant' => $klant, 'header' => Header::getHeaderData(),
'rekeningen' => $rekeningen 'rekeningen' => $rekeningen
]); ]);
}); });
@ -59,7 +59,7 @@ class Overboeking {
if (!$ibanHelper->isValidIBAN($naar)) { if (!$ibanHelper->isValidIBAN($naar)) {
//error: ongeldige iban //error: ongeldige iban
return Redirect::create($request, $response, "/ongeldig"); 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 //error: andere bank
return Redirect::create($request, $response, "/andere"); return Redirect::create($request, $response, "/andere");
} }
@ -89,5 +89,4 @@ class Overboeking {
return Redirect::create($request, $response, "/"); return Redirect::create($request, $response, "/");
}); });
} }
} }

View File

@ -0,0 +1,36 @@
<?php
/**
* Informatica Eindproject D4p
* 6in3, Stedelijk Gymnasium Nijmegen
* Docent: Hans de Wolf
*
* ==================
*
* Daniel Boutros,
* Christiaan Goossens,
* Jelmer Hinssen
*/
namespace Inforbank\Application;
use \Slim\App;
use Inforbank\Application\Helper\Header;
use Inforbank\Application\Helper\Rekeningen as RekeningHelper;
class Rekeningen
{
public function __construct(App $app)
{
$app->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());
}
}

View File

@ -15,7 +15,7 @@
namespace Inforbank\Application; namespace Inforbank\Application;
use \Slim\App; use \Slim\App;
use Inforbank\Application\Helper\Klant; use Inforbank\Application\Helper\Header;
use Inforbank\Application\Helper\Rekeningen; use Inforbank\Application\Helper\Rekeningen;
use Inforbank\Application\Helper\IBAN; use Inforbank\Application\Helper\IBAN;
use Inforbank\Application; use Inforbank\Application;
@ -25,21 +25,20 @@ class Transacties
public function __construct(App $app) public function __construct(App $app)
{ {
$app->get('/rekeningen/{rekeningnummer}', function ($request, $response, $args) { $app->get('/rekeningen/{rekeningnummer}', function ($request, $response, $args) {
$klant = Klant::getCurrentUser();
$rekeningen = Rekeningen::getCurrentUserRekeningen(); $rekeningen = Rekeningen::getCurrentUserRekeningen();
$ibanhelper = new IBAN; $ibanhelper = new IBAN;
$rekening = false; $rekening = false;
$rekeningnr = $args['rekeningnummer']; $rekeningnr = $args['rekeningnummer'];
//Controleer of deze rekening wel van de ingelogde klant is //Controleer of deze rekening wel van de ingelogde klant is
foreach($rekeningen as $rek){ foreach ($rekeningen as $rek) {
if($rek['nr'] === $rekeningnr){ if ($rek['nr'] === $rekeningnr) {
$rekening = $rek; $rekening = $rek;
break; break;
} }
} }
if(!$rekening){ if (!$rekening) {
return $this->renderer->render($response, 'transacties.phtml', [ return $this->renderer->render($response, 'transacties.phtml', [
'klant' => $klant, 'klant' => $klant,
'rekening' => false 'rekening' => false
@ -52,7 +51,7 @@ class Transacties
$returnArray = array(); $returnArray = array();
foreach ($transacties as $transactie) { foreach ($transacties as $transactie) {
$returnArray[] = array( $returnArray[] = array(
"van" => $ibanhelper->getIBAN($transactie['van']), "van" => $ibanhelper->getIBAN($transactie['van']),
"naar" => $ibanhelper->getIBAN($transactie['naar']), "naar" => $ibanhelper->getIBAN($transactie['naar']),
"bedrag" => $transactie['bedrag'], "bedrag" => $transactie['bedrag'],
@ -60,9 +59,9 @@ class Transacties
); );
} }
return $this->renderer->render($response, 'transacties.phtml', [ return $this->renderer->render($response, 'transacties.phtml', [
'klant' => $klant, 'header' => Header::getHeaderData(),
'rekening' => $rekening, 'rekening' => $rekening,
'transacties' => $returnArray 'transacties' => $returnArray
]); ]);
}); });
} }

View File

@ -16,9 +16,14 @@ namespace Inforbank;
class Proxy class Proxy
{ {
public static $route;
public function __invoke($request, $response, $next) public function __invoke($request, $response, $next)
{ {
$uri = $request->getUri(); $uri = $request->getUri();
self::$route = $uri;
$path = $uri->getPath(); $path = $uri->getPath();
$pa = explode('assets/', $path, 2); $pa = explode('assets/', $path, 2);

View File

@ -118,6 +118,7 @@ new Inforbank\Application\Daniel($app);
new Inforbank\Application\Main($app); new Inforbank\Application\Main($app);
new Inforbank\Application\Transacties($app); new Inforbank\Application\Transacties($app);
new Inforbank\Application\Overboeking($app); new Inforbank\Application\Overboeking($app);
new Inforbank\Application\Rekeningen($app);
// Added API handler // Added API handler
new Inforbank\Application\API\Handler($app); new Inforbank\Application\API\Handler($app);

View File

@ -5,6 +5,7 @@
<title>Inforbank</title> <title>Inforbank</title>
<link rel="stylesheet" href="assets/css/main.css"> <link rel="stylesheet" href="assets/css/main.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous"> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<base href="<?= $header['base'] ?>">
</head> </head>
<body> <body>
<div class="header"> <div class="header">
@ -12,11 +13,11 @@
<div class="container"> <div class="container">
<img src="assets/logo.png" alt="Inforbank"></img> <img src="assets/logo.png" alt="Inforbank"></img>
<div class="user"> <div class="user">
Welkom <?= $klant['voornaam'] ?> <?php Welkom <?= $header['klant']['voornaam'] ?> <?php
if ($klant['tussenvoegsel'] !== "") { if ($header['klant']['tussenvoegsel'] !== "") {
echo " " . $klant['tussenvoegsel']; echo " " . $header['klant']['tussenvoegsel'];
} }
?> <?= $klant['achternaam'] ?><br/> ?> <?= $header['klant']['achternaam'] ?><br/>
<a href="logout">Uitloggen</a> <a href="logout">Uitloggen</a>
</div> </div>
</div> </div>
@ -25,8 +26,7 @@
<div class="container"> <div class="container">
<ul class="nv"> <ul class="nv">
<li><a href="rekeningen">Rekeningen</a></li> <li><a href="rekeningen">Rekeningen</a></li>
<li><a href="rekeningen">Transactie Beginnen</a></li> <li><a href="berichten">Berichten</a></li>
<li><a href="rekeningen">Transacties</a></li>
</ul> </ul>
</div> </div>
</div> </div>