Add berichten page, and authentication checks
This commit is contained in:
		
							
								
								
									
										32
									
								
								src/Application/Berichten.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										32
									
								
								src/Application/Berichten.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; | ||||
|  | ||||
| use \Slim\App; | ||||
| use Inforbank\Application\Helper\Header; | ||||
| use Inforbank\Application\Helper\Berichten as BerichtHelper; | ||||
|  | ||||
| class Berichten | ||||
| { | ||||
|     public function __construct(App $app) | ||||
|     { | ||||
|         $app->get('/berichten', function ($request, $response, $args) { | ||||
|             return $this->renderer->render($response, 'berichten.phtml', [ | ||||
|                 'header' => Header::getHeaderData(), | ||||
|                 'berichten' => BerichtHelper::getUserBerichten() | ||||
|             ]); | ||||
|         })->add(new Auth\Middleware()); | ||||
|     } | ||||
| } | ||||
							
								
								
									
										57
									
								
								src/Application/Helper/Berichten.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										57
									
								
								src/Application/Helper/Berichten.php
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,57 @@ | ||||
| <?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; | ||||
|  | ||||
| class Berichten | ||||
| { | ||||
|     public static function getUserBerichten() | ||||
|     { | ||||
|         $container = Application::getContainer(); | ||||
|         $db = $container->db; | ||||
|         $berichten = $db->berichten->where('klantid', $container->auth->getUserID())->order('datum DESC'); | ||||
|  | ||||
|         $berichtArray = array(); | ||||
|  | ||||
|         foreach ($berichten as $bericht) { | ||||
|             $datum = new \DateTime($bericht['datum']); | ||||
|             $datum = $datum->format('d-m-Y'); | ||||
|  | ||||
|             $berichtArray[] = array( | ||||
|                 "afzender" => $bericht['afzender'], | ||||
|                 "bericht" => $bericht['bericht'], | ||||
|                 "datum" => $datum | ||||
|             ); | ||||
|         } | ||||
|  | ||||
|         return $berichtArray; | ||||
|     } | ||||
|  | ||||
|     public static function newBericht($user, $afzender, $bericht) | ||||
|     { | ||||
|         $container = Application::getContainer(); | ||||
|         $db = $container->db; | ||||
|  | ||||
|         $array = array( | ||||
|             'klantid' => (int) $user, | ||||
|             'afzender' => $afzender, | ||||
|             'bericht' => $bericht, | ||||
|             'datum' => date('Y-m-d') | ||||
|         ); | ||||
|  | ||||
|         $row = $db->berichten->insert($array); | ||||
|     } | ||||
| } | ||||
| @@ -31,7 +31,7 @@ class Overboeking | ||||
|                         'header' => Header::getHeaderData(), | ||||
|                         'rekeningen' => $rekeningen | ||||
|             ]); | ||||
|         }); | ||||
|         })->add(new Auth\Middleware()); | ||||
|  | ||||
|         $app->post('/overboeking', function ($request, $response, $args) { | ||||
|             $post = $request->getParsedBody(); | ||||
| @@ -86,7 +86,8 @@ class Overboeking | ||||
|             ]); | ||||
|  | ||||
|             //TODO update saldo | ||||
|             //TODO Checken of het saldo van de rekening onder de 20 euro komt, dan doe je een mededeling via de berichthelper. | ||||
|             return Redirect::create($request, $response, "/"); | ||||
|         }); | ||||
|         })->add(new Auth\Middleware()); | ||||
|     } | ||||
| } | ||||
|   | ||||
| @@ -63,6 +63,6 @@ class Transacties | ||||
|                 'rekening' => $rekening, | ||||
|         'transacties' => $returnArray | ||||
|             ]); | ||||
|         }); | ||||
|         })->add(new Auth\Middleware()); | ||||
|     } | ||||
| } | ||||
|   | ||||
| @@ -113,14 +113,27 @@ Inforbank\Application::set($app); | ||||
|  * | ||||
|  */ | ||||
|  | ||||
| new Inforbank\Application\Login($app); | ||||
| new Inforbank\Application\Daniel($app); | ||||
|  | ||||
| /** | ||||
|  * Basis | ||||
|  */ | ||||
|  | ||||
| new Inforbank\Application\Main($app); | ||||
| new Inforbank\Application\Login($app); | ||||
|  | ||||
| /** | ||||
|  * Pagina's | ||||
|  */ | ||||
|  | ||||
| new Inforbank\Application\Daniel($app); | ||||
| new Inforbank\Application\Transacties($app); | ||||
| new Inforbank\Application\Overboeking($app); | ||||
| new Inforbank\Application\Rekeningen($app); | ||||
| new Inforbank\Application\Berichten($app); | ||||
|  | ||||
| // Added API handler | ||||
| /** | ||||
|  * API | ||||
|  */ | ||||
| new Inforbank\Application\API\Handler($app); | ||||
|  | ||||
| /** | ||||
|   | ||||
		Reference in New Issue
	
	Block a user