1
0
This repository has been archived on 2017-06-06. You can view files and clone it, but cannot push or open issues or pull requests.
informaticaD4P-2017/src/Application/Transacties.php

65 lines
1.5 KiB
PHP
Raw Normal View History

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();
$ibanhelper = new IBAN;
$rekening = false;
$rekeningnr = $args['rekeningnummer'];
foreach($rekeningen as $rek){
if($rek['nr'] === $rekeningnr){
$rekening = $rek;
break;
}
}
$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']
);
}
return $this->renderer->render($response, 'transacties.phtml', [
'klant' => $klant,
'rekening' => $rekening,
'transacties' => $returnArray
]);
});
}
}