1
0

Add berichten page, and authentication checks

This commit is contained in:
Christiaan Goossens 2017-03-30 19:36:22 +02:00
parent 4f47ae6a55
commit 516ced5152
7 changed files with 130 additions and 7 deletions

View File

@ -47,6 +47,7 @@ ul.nv {
color: grey;
margin-top: 50px;
}
/** Table Row **/
.clickable {
cursor: pointer;

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;
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());
}
}

View 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);
}
}

View File

@ -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());
}
}

View File

@ -63,6 +63,6 @@ class Transacties
'rekening' => $rekening,
'transacties' => $returnArray
]);
});
})->add(new Auth\Middleware());
}
}

View File

@ -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);
/**

19
templates/berichten.phtml Normal file
View File

@ -0,0 +1,19 @@
<?php include '__header.phtml'; ?>
<h2 class="page-header">Berichten</h2>
<?php foreach ($berichten as $bericht) {
?>
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title"><?php echo $bericht['datum']; ?></h3>
<small>Afzender: </small><?php echo $bericht['afzender']; ?></div>
<div class="panel-body">
<?php echo $bericht['bericht']; ?>
</div>
</div>
<?php
} ?>
<?php include '__footer.phtml'; ?>