Added base routing + moved rekeningen
This commit is contained in:
parent
ffe56bcf9b
commit
afc472e7d7
32
src/Application/Helper/Header.php
Normal file
32
src/Application/Helper/Header.php
Normal 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
|
||||
);
|
||||
}
|
||||
}
|
@ -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());
|
||||
}
|
||||
}
|
||||
|
@ -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, "/");
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
36
src/Application/Rekeningen.php
Normal file
36
src/Application/Rekeningen.php
Normal 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());
|
||||
}
|
||||
}
|
@ -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
|
||||
]);
|
||||
});
|
||||
}
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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);
|
||||
|
@ -5,6 +5,7 @@
|
||||
<title>Inforbank</title>
|
||||
<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">
|
||||
<base href="<?= $header['base'] ?>">
|
||||
</head>
|
||||
<body>
|
||||
<div class="header">
|
||||
@ -12,11 +13,11 @@
|
||||
<div class="container">
|
||||
<img src="assets/logo.png" alt="Inforbank"></img>
|
||||
<div class="user">
|
||||
Welkom <?= $klant['voornaam'] ?> <?php
|
||||
if ($klant['tussenvoegsel'] !== "") {
|
||||
echo " " . $klant['tussenvoegsel'];
|
||||
Welkom <?= $header['klant']['voornaam'] ?> <?php
|
||||
if ($header['klant']['tussenvoegsel'] !== "") {
|
||||
echo " " . $header['klant']['tussenvoegsel'];
|
||||
}
|
||||
?> <?= $klant['achternaam'] ?><br/>
|
||||
?> <?= $header['klant']['achternaam'] ?><br/>
|
||||
<a href="logout">Uitloggen</a>
|
||||
</div>
|
||||
</div>
|
||||
@ -25,8 +26,7 @@
|
||||
<div class="container">
|
||||
<ul class="nv">
|
||||
<li><a href="rekeningen">Rekeningen</a></li>
|
||||
<li><a href="rekeningen">Transactie Beginnen</a></li>
|
||||
<li><a href="rekeningen">Transacties</a></li>
|
||||
<li><a href="berichten">Berichten</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
Reference in New Issue
Block a user