2017-03-29 14:47:24 +00:00
|
|
|
<?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\Klant;
|
|
|
|
use Inforbank\Application\Helper\Rekeningen;
|
|
|
|
use Inforbank\Application\Helper\IBAN;
|
|
|
|
use Inforbank\Application;
|
|
|
|
|
|
|
|
class Transacties
|
|
|
|
{
|
|
|
|
public function __construct(App $app)
|
|
|
|
{
|
|
|
|
$app->get('/rekeningen/{rekeningnummer}', function ($request, $response, $args) {
|
|
|
|
$klant = Klant::getCurrentUser();
|
|
|
|
$rekeningen = Rekeningen::getCurrentUserRekeningen();
|
|
|
|
|
2017-03-30 13:49:27 +00:00
|
|
|
$ibanhelper = new IBAN;
|
|
|
|
$rekening = false;
|
|
|
|
$rekeningnr = $args['rekeningnummer'];
|
2017-03-29 14:47:24 +00:00
|
|
|
|
2017-03-30 13:49:27 +00:00
|
|
|
//Controleer of deze rekening wel van de ingelogde klant is
|
|
|
|
foreach($rekeningen as $rek){
|
|
|
|
if($rek['nr'] === $rekeningnr){
|
|
|
|
$rekening = $rek;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(!$rekening){
|
|
|
|
return $this->renderer->render($response, 'transacties.phtml', [
|
|
|
|
'klant' => $klant,
|
|
|
|
'rekening' => false
|
|
|
|
]);
|
|
|
|
}
|
|
|
|
$container = Application::getContainer();
|
|
|
|
$db = $container->db;
|
|
|
|
$transacties = $db->transacties->where('van', '12345678')->or('naar', $rekeningnr);
|
|
|
|
|
|
|
|
$returnArray = array();
|
|
|
|
|
|
|
|
foreach ($transacties as $transactie) {
|
|
|
|
$returnArray[] = array(
|
|
|
|
"van" => $ibanhelper->getIBAN($transactie['van']),
|
|
|
|
"naar" => $ibanhelper->getIBAN($transactie['naar']),
|
|
|
|
"bedrag" => $transactie['bedrag'],
|
|
|
|
"type" => $transactie['type']
|
|
|
|
);
|
|
|
|
}
|
2017-03-29 14:47:24 +00:00
|
|
|
return $this->renderer->render($response, 'transacties.phtml', [
|
|
|
|
'klant' => $klant,
|
|
|
|
'rekening' => $rekening,
|
2017-03-30 13:49:27 +00:00
|
|
|
'transacties' => $returnArray
|
2017-03-29 14:47:24 +00:00
|
|
|
]);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|