Added base routing + moved rekeningen
This commit is contained in:
		
							
								
								
									
										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); | ||||
|   | ||||
		Reference in New Issue
	
	Block a user