Add berichten page, and authentication checks
parent
4f47ae6a55
commit
516ced5152
@ -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());
|
||||
}
|
||||
}
|
@ -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);
|
||||
}
|
||||
}
|
@ -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'; ?>
|
Reference in New Issue