<?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 Rekeningen
{
    public static function getCurrentUserRekeningen()
    {
        $container = Application::getContainer();
        $user = $container->auth->getUserID();

        $db = $container->db;
        $ibanhelper = new IBAN;

        $rekeningen = $db->rekeningen->where('klantid', $user);

        $returnArray = array();

        foreach ($rekeningen as $rekening) {
            $type = $db->types->where('id', $rekening['typeid'])[$rekening['typeid']];

            $returnArray[] = array(
                "iban" => $ibanhelper->getIBAN($rekening['rekeningnr']),
                "nr" => $rekening['rekeningnr'],
                "saldo" => (double) $rekening['saldo'],
                "naam" => $type['rekeningnaam'],
                "rente" => $type['rente']
            );
        }

        return $returnArray;
    }
}
