Cleanup, added docs & RC 2
This commit is contained in:
		| @@ -25,11 +25,19 @@ class Application | |||||||
|         self::$container = $app->getContainer(); |         self::$container = $app->getContainer(); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     /** | ||||||
|  |      * Gets dependency injection container | ||||||
|  |      * @return Slim\Container | ||||||
|  |      */ | ||||||
|     public static function getContainer() |     public static function getContainer() | ||||||
|     { |     { | ||||||
|         return self::$container; |         return self::$container; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     /** | ||||||
|  |      * Get Slim application object | ||||||
|  |      * @return Slim\App; | ||||||
|  |      */ | ||||||
|     public static function getApplication() |     public static function getApplication() | ||||||
|     { |     { | ||||||
|         return self::$app; |         return self::$app; | ||||||
|   | |||||||
| @@ -35,13 +35,12 @@ class Handler | |||||||
|              * - amount |              * - amount | ||||||
|              * - description |              * - description | ||||||
|              * - returnUrl |              * - returnUrl | ||||||
|              * - sha1 |              * - hash | ||||||
|              */ |              */ | ||||||
|             $this->post('/transactionRequest', function ($request, $response, $args) { |             $this->post('/transactionRequest', function ($request, $response, $args) { | ||||||
|                 $parsedBody = $request->getParsedBody(); |                 $parsedBody = $request->getParsedBody(); | ||||||
|  |  | ||||||
|                 if (isset($parsedBody['clientId']) && isset($parsedBody['transactionId']) && isset($parsedBody['amount']) && isset($parsedBody['description']) && isset($parsedBody['returnUrl']) && isset($parsedBody['hash'])) { |                 if (isset($parsedBody['clientId']) && isset($parsedBody['transactionId']) && isset($parsedBody['amount']) && isset($parsedBody['description']) && isset($parsedBody['returnUrl']) && isset($parsedBody['hash'])) { | ||||||
|                     // Correct request |  | ||||||
|                     try { |                     try { | ||||||
|                         $client = new Client($parsedBody['clientId']); |                         $client = new Client($parsedBody['clientId']); | ||||||
|                         $clientSecret = $client->getClientSecret(); |                         $clientSecret = $client->getClientSecret(); | ||||||
| @@ -112,13 +111,12 @@ class Handler | |||||||
|              * Requires the following POST arguments: |              * Requires the following POST arguments: | ||||||
|              * - clientId |              * - clientId | ||||||
|              * - transactionId |              * - transactionId | ||||||
|              * - sha1 |              * - hash | ||||||
|              */ |              */ | ||||||
|             $this->post('/statusRequest', function ($request, $response, $args) { |             $this->post('/statusRequest', function ($request, $response, $args) { | ||||||
|                 $parsedBody = $request->getParsedBody(); |                 $parsedBody = $request->getParsedBody(); | ||||||
|  |  | ||||||
|                 if (isset($parsedBody['clientId']) && isset($parsedBody['transactionId']) && isset($parsedBody['hash'])) { |                 if (isset($parsedBody['clientId']) && isset($parsedBody['transactionId']) && isset($parsedBody['hash'])) { | ||||||
|                     // Correct request |  | ||||||
|                     try { |                     try { | ||||||
|                         $client = new Client($parsedBody['clientId']); |                         $client = new Client($parsedBody['clientId']); | ||||||
|                         $clientSecret = $client->getClientSecret(); |                         $clientSecret = $client->getClientSecret(); | ||||||
|   | |||||||
| @@ -18,6 +18,12 @@ use Inforbank\Application; | |||||||
|  |  | ||||||
| class Authorization | class Authorization | ||||||
| { | { | ||||||
|  |     /** | ||||||
|  |      * Login user | ||||||
|  |      * @param  $rekeningnr | ||||||
|  |      * @param  $passcode | ||||||
|  |      * @return boolean | ||||||
|  |      */ | ||||||
|     public function login($rekeningnr, $passcode) |     public function login($rekeningnr, $passcode) | ||||||
|     { |     { | ||||||
|         $container = Application::getContainer(); |         $container = Application::getContainer(); | ||||||
| @@ -42,16 +48,27 @@ class Authorization | |||||||
|         return false; |         return false; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     /** | ||||||
|  |      * Return current user id | ||||||
|  |      * @return any | ||||||
|  |      */ | ||||||
|     public function getUserID() |     public function getUserID() | ||||||
|     { |     { | ||||||
|         return $_SESSION['userid']; |         return $_SESSION['userid']; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     /** | ||||||
|  |      * Return if the current user is authenticated | ||||||
|  |      * @return boolean | ||||||
|  |      */ | ||||||
|     public function isUserAuthenticated() |     public function isUserAuthenticated() | ||||||
|     { |     { | ||||||
|         return $this->getUserID() !== null; |         return $this->getUserID() !== null; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     /** | ||||||
|  |      * Delete user session data | ||||||
|  |      */ | ||||||
|     public function logout() |     public function logout() | ||||||
|     { |     { | ||||||
|         unset($_SESSION['userid']); |         unset($_SESSION['userid']); | ||||||
|   | |||||||
| @@ -19,6 +19,9 @@ use Inforbank\Application\Helper\Redirect; | |||||||
|  |  | ||||||
| class Middleware | class Middleware | ||||||
| { | { | ||||||
|  |     /** | ||||||
|  |      * Middleware (https://www.slimframework.com/docs/concepts/middleware.html) om te checken of de gebruiker is ingelogd | ||||||
|  |      */ | ||||||
|     public function __invoke($request, $response, $next) |     public function __invoke($request, $response, $next) | ||||||
|     { |     { | ||||||
|         $container = Application::getContainer(); |         $container = Application::getContainer(); | ||||||
|   | |||||||
| @@ -18,6 +18,10 @@ use Inforbank\Application; | |||||||
|  |  | ||||||
| class Berichten | class Berichten | ||||||
| { | { | ||||||
|  |     /** | ||||||
|  |      * Get all messages for a user | ||||||
|  |      * @return array | ||||||
|  |      */ | ||||||
|     public static function getUserBerichten() |     public static function getUserBerichten() | ||||||
|     { |     { | ||||||
|         $container = Application::getContainer(); |         $container = Application::getContainer(); | ||||||
| @@ -36,7 +40,7 @@ class Berichten | |||||||
|                 "datum" => $datum, |                 "datum" => $datum, | ||||||
|                 "gelezen" => $bericht['gelezen'] |                 "gelezen" => $bericht['gelezen'] | ||||||
|             ); |             ); | ||||||
|             if(!$bericht['gelezen']){ |             if (!$bericht['gelezen']) { | ||||||
|                 $bericht->update([ |                 $bericht->update([ | ||||||
|                     "gelezen" => true |                     "gelezen" => true | ||||||
|                 ]); |                 ]); | ||||||
| @@ -46,6 +50,12 @@ class Berichten | |||||||
|         return $berichtArray; |         return $berichtArray; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     /** | ||||||
|  |      * Send new message | ||||||
|  |      * @param  int $user        Klantid | ||||||
|  |      * @param  string $afzender String name of the sender | ||||||
|  |      * @param  string $bericht  Message | ||||||
|  |      */ | ||||||
|     public static function newBericht($user, $afzender, $bericht) |     public static function newBericht($user, $afzender, $bericht) | ||||||
|     { |     { | ||||||
|         $container = Application::getContainer(); |         $container = Application::getContainer(); | ||||||
|   | |||||||
| @@ -16,7 +16,7 @@ namespace Inforbank\Application\Helper; | |||||||
|  |  | ||||||
| class IBAN | class IBAN | ||||||
| { | { | ||||||
|     private function wordToNumbers($word) |     private static function wordToNumbers($word) | ||||||
|     { |     { | ||||||
|         $newword = ""; |         $newword = ""; | ||||||
|         $wordarray = str_split($word); |         $wordarray = str_split($word); | ||||||
| @@ -30,7 +30,7 @@ class IBAN | |||||||
|         return $newword; |         return $newword; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     private function getCheckDigits($bignum) |     private static function getCheckDigits($bignum) | ||||||
|     { |     { | ||||||
|         //Modulo staartdeling |         //Modulo staartdeling | ||||||
|         $modulo97 = (int)substr($bignum, 0, 6); |         $modulo97 = (int)substr($bignum, 0, 6); | ||||||
| @@ -48,7 +48,7 @@ class IBAN | |||||||
|         return $checkdigits; |         return $checkdigits; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public function isValidIBAN($iban) |     public static function isValidIBAN($iban) | ||||||
|     { |     { | ||||||
|         $iban = str_replace(" ", "", $iban); |         $iban = str_replace(" ", "", $iban); | ||||||
|         $landcode = substr($iban, 0, 2); |         $landcode = substr($iban, 0, 2); | ||||||
| @@ -56,38 +56,38 @@ class IBAN | |||||||
|         $identificatie = substr($iban, 4); |         $identificatie = substr($iban, 4); | ||||||
|         $identificatie .= $landcode; |         $identificatie .= $landcode; | ||||||
|         $identificatie .= "00"; |         $identificatie .= "00"; | ||||||
|         $nummer = $this->wordToNumbers($identificatie); |         $nummer = self::wordToNumbers($identificatie); | ||||||
|         return $controle == $this->getCheckDigits($nummer); |         return $controle == self::getCheckDigits($nummer); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public function getRekeningNummer($iban) |     public static function getRekeningNummer($iban) | ||||||
|     { |     { | ||||||
|         return substr(str_replace(" ", "", $iban), 8); |         return substr(str_replace(" ", "", $iban), 8); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public function getBank($iban) |     public static function getBank($iban) | ||||||
|     { |     { | ||||||
|         return substr(str_replace(" ", "", $iban), 4, 4); |         return substr(str_replace(" ", "", $iban), 4, 4); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public function getLand($iban) |     public static function getLand($iban) | ||||||
|     { |     { | ||||||
|         return substr(str_replace(" ", "", $iban), 0, 2); |         return substr(str_replace(" ", "", $iban), 0, 2); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public function getIBAN($rekeningnr) |     public static function getIBAN($rekeningnr) | ||||||
|     { |     { | ||||||
|         $landcode = "NL"; // NL in vertaling |         $landcode = "NL"; // NL in vertaling | ||||||
|         $landnumber = $this->wordToNumbers($landcode); |         $landnumber = self::wordToNumbers($landcode); | ||||||
|  |  | ||||||
|  |  | ||||||
|         $bankcode = "INFO"; |         $bankcode = "INFO"; | ||||||
|         $banknumber = $this->wordToNumbers($bankcode); |         $banknumber = self::wordToNumbers($bankcode); | ||||||
|  |  | ||||||
|         $rekeningnr = str_pad($rekeningnr, 10, 0, STR_PAD_LEFT); |         $rekeningnr = str_pad($rekeningnr, 10, 0, STR_PAD_LEFT); | ||||||
|  |  | ||||||
|         $bignum = $banknumber . $rekeningnr . $landnumber . "00"; |         $bignum = $banknumber . $rekeningnr . $landnumber . "00"; | ||||||
|         $checkdigits = $this->getCheckDigits($bignum); |         $checkdigits = self::getCheckDigits($bignum); | ||||||
|  |  | ||||||
|         $rekeningnrarr = str_split($rekeningnr, 4); |         $rekeningnrarr = str_split($rekeningnr, 4); | ||||||
|         return $landcode.$checkdigits." ".$bankcode." ".$rekeningnrarr[0]." ".$rekeningnrarr[1]." ".$rekeningnrarr[2]; |         return $landcode.$checkdigits." ".$bankcode." ".$rekeningnrarr[0]." ".$rekeningnrarr[1]." ".$rekeningnrarr[2]; | ||||||
|   | |||||||
| @@ -16,6 +16,9 @@ namespace Inforbank\Application\Helper\Idob; | |||||||
|  |  | ||||||
| use Inforbank\Application; | use Inforbank\Application; | ||||||
|  |  | ||||||
|  | /** | ||||||
|  |  * Used for client authentication in IDOB | ||||||
|  |  */ | ||||||
| class Client | class Client | ||||||
| { | { | ||||||
|     private $client; |     private $client; | ||||||
|   | |||||||
| @@ -18,6 +18,14 @@ use Inforbank\Application; | |||||||
|  |  | ||||||
| class Transactie | class Transactie | ||||||
| { | { | ||||||
|  |     /** | ||||||
|  |      * Create IDOB transaction | ||||||
|  |      * @param  string $reference   Reference passed by the client (webshop) | ||||||
|  |      * @param  string $clientId    Client identifier | ||||||
|  |      * @param  double $amount      Transaction amount | ||||||
|  |      * @param  string $description Description for the user | ||||||
|  |      * @return int                 Transaction identifier | ||||||
|  |      */ | ||||||
|     public static function createTransactie($reference, $clientId, $amount, $description) |     public static function createTransactie($reference, $clientId, $amount, $description) | ||||||
|     { |     { | ||||||
|         $container = Application::getContainer(); |         $container = Application::getContainer(); | ||||||
| @@ -33,6 +41,11 @@ class Transactie | |||||||
|         return $trans['id']; |         return $trans['id']; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     /** | ||||||
|  |      * Get IDOB transaction data | ||||||
|  |      * @param  int $id    Transaction identifier | ||||||
|  |      * @return array | ||||||
|  |      */ | ||||||
|     public static function getTransactie($id) |     public static function getTransactie($id) | ||||||
|     { |     { | ||||||
|         $container = Application::getContainer(); |         $container = Application::getContainer(); | ||||||
| @@ -54,6 +67,11 @@ class Transactie | |||||||
|         ); |         ); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     /** | ||||||
|  |      * Set the IDOB transaction status | ||||||
|  |      * @param int $id        Transaction identifier | ||||||
|  |      * @param int $status    Status: 1 for pending, 2 for paid, 3 for unknown | ||||||
|  |      */ | ||||||
|     public static function setTransactionStatus($id, $status) |     public static function setTransactionStatus($id, $status) | ||||||
|     { |     { | ||||||
|         $container = Application::getContainer(); |         $container = Application::getContainer(); | ||||||
|   | |||||||
| @@ -18,6 +18,10 @@ use Inforbank\Application; | |||||||
|  |  | ||||||
| class Klant | class Klant | ||||||
| { | { | ||||||
|  |     /** | ||||||
|  |      * Get current user data | ||||||
|  |      * @return array | ||||||
|  |      */ | ||||||
|     public static function getCurrentUser() |     public static function getCurrentUser() | ||||||
|     { |     { | ||||||
|         $container = Application::getContainer(); |         $container = Application::getContainer(); | ||||||
|   | |||||||
| @@ -69,20 +69,20 @@ class Overboekingen | |||||||
|             $ascii = ord($char); |             $ascii = ord($char); | ||||||
|             if ($char === "." || $char === ",") { |             if ($char === "." || $char === ",") { | ||||||
|                 $komma++; |                 $komma++; | ||||||
|                 if($komma > 1){ |                 if ($komma > 1) { | ||||||
|                     //Twee komma's |                     //Twee komma's | ||||||
|                     return false; |                     return false; | ||||||
|                 } |                 } | ||||||
|             } elseif (($ascii >= ord("0") && $ascii <= ord("9") || $char === "-")) { |             } elseif (($ascii >= ord("0") && $ascii <= ord("9") || $char === "-")) { | ||||||
|                 if($komma >= 1){ |                 if ($komma >= 1) { | ||||||
|                     $decimalen++; |                     $decimalen++; | ||||||
|                     if ($decimalen > 2) { |                     if ($decimalen > 2) { | ||||||
|                         //Meer dan twee cijfers achter de komma |                         //Meer dan twee cijfers achter de komma | ||||||
|                         return false; |                         return false; | ||||||
|                     } |                     } | ||||||
|                 }else{ |                 } else { | ||||||
|                     $cijfers++; |                     $cijfers++; | ||||||
|                     if($cijfers > 9){ |                     if ($cijfers > 9) { | ||||||
|                         //Te veel cijfers voor de komma |                         //Te veel cijfers voor de komma | ||||||
|                         return false; |                         return false; | ||||||
|                     } |                     } | ||||||
| @@ -101,7 +101,7 @@ class Overboekingen | |||||||
|     } |     } | ||||||
|  |  | ||||||
|     /** |     /** | ||||||
|      * |      * Maak een nieuwe overboeking aan | ||||||
|      * @param IBAN $van De rekening waar het bedrag vanaf wordt gehaald |      * @param IBAN $van De rekening waar het bedrag vanaf wordt gehaald | ||||||
|      * @param IBAN $naar De rekening waar het bedrag bijkomt |      * @param IBAN $naar De rekening waar het bedrag bijkomt | ||||||
|      * @param double $bedrag Het bedrag |      * @param double $bedrag Het bedrag | ||||||
| @@ -115,15 +115,15 @@ class Overboekingen | |||||||
|             //error: rekening is niet van klant |             //error: rekening is niet van klant | ||||||
|             Overboekingen::error(Overboekingen::$EIGENAAR); |             Overboekingen::error(Overboekingen::$EIGENAAR); | ||||||
|         } |         } | ||||||
|         $ibanHelper = new IBAN(); |  | ||||||
|         if (!$ibanHelper->isValidIBAN($naar)) { |         if (!IBAN::isValidIBAN($naar)) { | ||||||
|             //error: ongeldige iban |             //error: ongeldige iban | ||||||
|             throw new Exception("De IBAN van de ontvanger is ongeldig.", Overboekingen::$IBAN); |             throw new Exception("De IBAN van de ontvanger is ongeldig.", Overboekingen::$IBAN); | ||||||
|         } elseif (!($ibanHelper->getLand($naar) == "NL" && $ibanHelper->getBank($naar) === "INFO")) { |         } elseif (!(IBAN::getLand($naar) == "NL" && IBAN::getBank($naar) === "INFO")) { | ||||||
|             //error: andere bank |             //error: andere bank | ||||||
|             Overboekingen::error(Overboekingen::$BANK); |             Overboekingen::error(Overboekingen::$BANK); | ||||||
|         } |         } | ||||||
|         $naarRekeningnr = $ibanHelper->getRekeningNummer($naar); |         $naarRekeningnr = IBAN::getRekeningNummer($naar); | ||||||
|  |  | ||||||
|         //Controleer of de rekening bestaat |         //Controleer of de rekening bestaat | ||||||
|         $db = Application::getContainer()->db; |         $db = Application::getContainer()->db; | ||||||
| @@ -180,7 +180,7 @@ class Overboekingen | |||||||
|         ]); |         ]); | ||||||
|         //Stuur bericht bij laag saldo |         //Stuur bericht bij laag saldo | ||||||
|         if ($vanRekening['saldo'] - $bedragvalue < 20) { |         if ($vanRekening['saldo'] - $bedragvalue < 20) { | ||||||
|             Berichten::newBericht(Application::getContainer()->auth->getUserID(), "Bank", "U heeft een laag saldo op uw rekening: " . $ibanHelper->getIBAN($vanRekening['nr']) . ".<br/>Uw huidige saldo is " . money_format('%(#1n', $vanRekening['saldo'] - $bedragvalue) . "."); |             Berichten::newBericht(Application::getContainer()->auth->getUserID(), "Bank", "U heeft een laag saldo op uw rekening: " . IBAN::getIBAN($vanRekening['nr']) . ".<br/>Uw huidige saldo is " . money_format('%(#1n', $vanRekening['saldo'] - $bedragvalue) . "."); | ||||||
|         } |         } | ||||||
|         //In de database worden de getallen met 10 cijfers voor de komma opgeslagen |         //In de database worden de getallen met 10 cijfers voor de komma opgeslagen | ||||||
|         //Als het saldo te hoog wordt heb je een probleem |         //Als het saldo te hoog wordt heb je een probleem | ||||||
|   | |||||||
| @@ -16,6 +16,13 @@ namespace Inforbank\Application\Helper; | |||||||
|  |  | ||||||
| class Redirect | class Redirect | ||||||
| { | { | ||||||
|  |     /** | ||||||
|  |      * Create a new redirect to the given path | ||||||
|  |      * @param  Request $request | ||||||
|  |      * @param  Response $response | ||||||
|  |      * @param  string $path | ||||||
|  |      * @return Response object | ||||||
|  |      */ | ||||||
|     public static function create($request, $response, $path) |     public static function create($request, $response, $path) | ||||||
|     { |     { | ||||||
|         $basePath = $request->getUri()->getBaseUrl(); |         $basePath = $request->getUri()->getBaseUrl(); | ||||||
|   | |||||||
| @@ -21,13 +21,16 @@ class Rekeningen | |||||||
|     public static $BETAALREKENING = 1; |     public static $BETAALREKENING = 1; | ||||||
|     public static $SPAARREKENING = 2; |     public static $SPAARREKENING = 2; | ||||||
|  |  | ||||||
|  |     /** | ||||||
|  |      * Return the current user bank accounts | ||||||
|  |      * @return array | ||||||
|  |      */ | ||||||
|     public static function getCurrentUserRekeningen() |     public static function getCurrentUserRekeningen() | ||||||
|     { |     { | ||||||
|         $container = Application::getContainer(); |         $container = Application::getContainer(); | ||||||
|         $user = $container->auth->getUserID(); |         $user = $container->auth->getUserID(); | ||||||
|  |  | ||||||
|         $db = $container->db; |         $db = $container->db; | ||||||
|         $ibanhelper = new IBAN; |  | ||||||
|  |  | ||||||
|         $rekeningen = $db->rekeningen->where('klantid', $user); |         $rekeningen = $db->rekeningen->where('klantid', $user); | ||||||
|  |  | ||||||
| @@ -37,7 +40,7 @@ class Rekeningen | |||||||
|             $type = $db->types->where('id', $rekening['typeid'])[$rekening['typeid']]; |             $type = $db->types->where('id', $rekening['typeid'])[$rekening['typeid']]; | ||||||
|  |  | ||||||
|             $returnArray[] = array( |             $returnArray[] = array( | ||||||
|                 "iban" => $ibanhelper->getIBAN($rekening['rekeningnr']), |                 "iban" => IBAN::getIBAN($rekening['rekeningnr']), | ||||||
|                 "nr" => $rekening['rekeningnr'], |                 "nr" => $rekening['rekeningnr'], | ||||||
|                 "saldo" => (double) $rekening['saldo'], |                 "saldo" => (double) $rekening['saldo'], | ||||||
|                 "naam" => $type['rekeningnaam'], |                 "naam" => $type['rekeningnaam'], | ||||||
| @@ -48,6 +51,11 @@ class Rekeningen | |||||||
|         return $returnArray; |         return $returnArray; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     /** | ||||||
|  |      * Check if the current user is the owner of this bank account | ||||||
|  |      * @param  string  $iban | ||||||
|  |      * @return boolean | ||||||
|  |      */ | ||||||
|     public static function isEigenRekeningIBAN($iban) |     public static function isEigenRekeningIBAN($iban) | ||||||
|     { |     { | ||||||
|         $rekeningen = Rekeningen::getCurrentUserRekeningen(); |         $rekeningen = Rekeningen::getCurrentUserRekeningen(); | ||||||
| @@ -62,6 +70,11 @@ class Rekeningen | |||||||
|         return $vanRekening; |         return $vanRekening; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     /** | ||||||
|  |      * Check if the current user is the owner of this bank account | ||||||
|  |      * @param  string  $nr Internal bank account number | ||||||
|  |      * @return boolean | ||||||
|  |      */ | ||||||
|     public static function isEigenRekeningnr($nr) |     public static function isEigenRekeningnr($nr) | ||||||
|     { |     { | ||||||
|         $rekeningen = Rekeningen::getCurrentUserRekeningen(); |         $rekeningen = Rekeningen::getCurrentUserRekeningen(); | ||||||
|   | |||||||
| @@ -5,15 +5,17 @@ namespace Inforbank\Application\Helper; | |||||||
| use Exception; | use Exception; | ||||||
| use Inforbank\Application; | use Inforbank\Application; | ||||||
|  |  | ||||||
| class Statistieken { | class Statistieken | ||||||
|  | { | ||||||
|     public static $EIGENAAR = 1; |     public static $EIGENAAR = 1; | ||||||
|      |  | ||||||
|     public static function getSaldoverloop($dagen, $rekeningNummer){ |     public static function getSaldoverloop($dagen, $rekeningNummer) | ||||||
|         if(!Rekeningen::isEigenRekeningnr($rekeningNummer)){ |     { | ||||||
|  |         if (!Rekeningen::isEigenRekeningnr($rekeningNummer)) { | ||||||
|             throw new Exception("Dit is niet uw eigen rekening", Statistieken::$EIGENAAR); |             throw new Exception("Dit is niet uw eigen rekening", Statistieken::$EIGENAAR); | ||||||
|         } |         } | ||||||
|         $xas = array(); |         $xas = array(); | ||||||
|         for($i = $dagen; $i >= 0; $i--){ |         for ($i = $dagen; $i >= 0; $i--) { | ||||||
|             $xas[] = date("Y-m-d", strtotime("now") - $i * 86400); |             $xas[] = date("Y-m-d", strtotime("now") - $i * 86400); | ||||||
|         } |         } | ||||||
|         $container = Application::getContainer(); |         $container = Application::getContainer(); | ||||||
| @@ -26,27 +28,27 @@ class Statistieken { | |||||||
|         $huidigSaldo = (double)$saldo; |         $huidigSaldo = (double)$saldo; | ||||||
|         $vandaag = strtotime("now"); |         $vandaag = strtotime("now"); | ||||||
|         $yas = array_fill(0, $dagen + 1, 0); |         $yas = array_fill(0, $dagen + 1, 0); | ||||||
|         foreach($eraf as $af){ |         foreach ($eraf as $af) { | ||||||
|                 $dag = strtotime($af['datum']); |             $dag = strtotime($af['datum']); | ||||||
|                 $diff = floor(($vandaag - $dag)/86400); |             $diff = floor(($vandaag - $dag)/86400); | ||||||
|                 if($diff <= $dagen){ |             if ($diff <= $dagen) { | ||||||
|                         $yas[$dagen - $diff] = (double)$af['bedr']; |                 $yas[$dagen - $diff] = (double)$af['bedr']; | ||||||
|                 } |             } | ||||||
|         } |         } | ||||||
|         foreach($erbij as $bij){ |         foreach ($erbij as $bij) { | ||||||
|                 $dag = strtotime($bij['datum']); |             $dag = strtotime($bij['datum']); | ||||||
|                 $diff = floor(($vandaag - $dag)/86400); |             $diff = floor(($vandaag - $dag)/86400); | ||||||
|                 if($diff <= $dagen){ |             if ($diff <= $dagen) { | ||||||
|                         $yas[$dagen - $diff + 1] -= (double)$bij['bedr']; |                 $yas[$dagen - $diff + 1] -= (double)$bij['bedr']; | ||||||
|                 }else{ |             } else { | ||||||
|                         break; |                 break; | ||||||
|                 } |             } | ||||||
|         } |         } | ||||||
|         $verandering = 0; |         $verandering = 0; | ||||||
|         for($i = $dagen; $i >= 0; $i--){ |         for ($i = $dagen; $i >= 0; $i--) { | ||||||
|                 $huidigSaldo += $verandering; |             $huidigSaldo += $verandering; | ||||||
|                 $verandering = $yas[$i]; |             $verandering = $yas[$i]; | ||||||
|                 $yas[$i] = $huidigSaldo; |             $yas[$i] = $huidigSaldo; | ||||||
|         } |         } | ||||||
|         return [ |         return [ | ||||||
|             "x-as" => $xas, |             "x-as" => $xas, | ||||||
|   | |||||||
| @@ -75,10 +75,9 @@ class Idob | |||||||
|                         /** |                         /** | ||||||
|                          * All set to pay! |                          * All set to pay! | ||||||
|                          */ |                          */ | ||||||
|                          $ibanhelper = new IBAN(); |  | ||||||
|  |  | ||||||
|                         // Do overboeking |                         // Do overboeking | ||||||
|                         Overboekingen::createOverboeking($ibanhelper->getIBAN($van), $ibanhelper->getIBAN($rekening), $transactie['amount'], "Betaling aan " . $naam . " voor transactie " . $transactie['reference'], "id"); |                         Overboekingen::createOverboeking(IBAN::getIBAN($van), IBAN::getIBAN($rekening), $transactie['amount'], "Betaling aan " . $naam . " voor transactie " . $transactie['reference'], "id"); | ||||||
|  |  | ||||||
|                         // Do Status update |                         // Do Status update | ||||||
|                         Transactie::setTransactionStatus($transactie['transactieId'], 2); |                         Transactie::setTransactionStatus($transactie['transactieId'], 2); | ||||||
|   | |||||||
| @@ -27,7 +27,7 @@ class Overboeking | |||||||
| { | { | ||||||
|     public function __construct(App $app) |     public function __construct(App $app) | ||||||
|     { |     { | ||||||
|         $app->get('/overboeking', function ($request, $response, $args) use($app) { |         $app->get('/overboeking', function ($request, $response, $args) use ($app) { | ||||||
|             $rekeningen = Rekeningen::getCurrentUserRekeningen(); |             $rekeningen = Rekeningen::getCurrentUserRekeningen(); | ||||||
|             return $this->renderer->render($response, 'overboeking.phtml', [ |             return $this->renderer->render($response, 'overboeking.phtml', [ | ||||||
|                         'header' => Header::getHeaderData(), |                         'header' => Header::getHeaderData(), | ||||||
| @@ -44,8 +44,7 @@ class Overboeking | |||||||
|             $omschrijving = $post['omschrijving']; |             $omschrijving = $post['omschrijving']; | ||||||
|  |  | ||||||
|             try { |             try { | ||||||
|                 $ibanhelper = new IBAN(); |                 Overboekingen::createOverboeking(IBAN::getIBAN($van), $naar, $bedrag, $omschrijving, "bg"); | ||||||
|                 Overboekingen::createOverboeking($ibanhelper->getIBAN($van), $naar, $bedrag, $omschrijving, "bg"); |  | ||||||
|                 return Redirect::create($request, $response, "/rekeningen/$van?geslaagd=1"); |                 return Redirect::create($request, $response, "/rekeningen/$van?geslaagd=1"); | ||||||
|             } catch (Exception $e) { |             } catch (Exception $e) { | ||||||
|                 return Redirect::create($request, $response, "/overboeking?error=" . $e->getCode() . ""); |                 return Redirect::create($request, $response, "/overboeking?error=" . $e->getCode() . ""); | ||||||
|   | |||||||
| @@ -26,8 +26,6 @@ class Transacties | |||||||
|     { |     { | ||||||
|         $app->get('/rekeningen/{rekeningnummer}', function ($request, $response, $args) { |         $app->get('/rekeningen/{rekeningnummer}', function ($request, $response, $args) { | ||||||
|             $rekeningen = Rekeningen::getCurrentUserRekeningen(); |             $rekeningen = Rekeningen::getCurrentUserRekeningen(); | ||||||
|  |  | ||||||
|             $ibanhelper = new IBAN; |  | ||||||
|             $rekening = $rekening = Rekeningen::isEigenRekeningnr($args['rekeningnummer']); |             $rekening = $rekening = Rekeningen::isEigenRekeningnr($args['rekeningnummer']); | ||||||
|             $rekeningnr = $args['rekeningnummer']; |             $rekeningnr = $args['rekeningnummer']; | ||||||
|             if (!$rekening) { |             if (!$rekening) { | ||||||
| @@ -45,8 +43,8 @@ class Transacties | |||||||
|  |  | ||||||
|             foreach ($transacties as $transactie) { |             foreach ($transacties as $transactie) { | ||||||
|                 $returnArray[] = array( |                 $returnArray[] = array( | ||||||
|                 "van" => $ibanhelper->getIBAN($transactie['van']), |                 "van" => IBAN::getIBAN($transactie['van']), | ||||||
|                 "naar" => $ibanhelper->getIBAN($transactie['naar']), |                 "naar" => IBAN::getIBAN($transactie['naar']), | ||||||
|                 "bedrag" => $transactie['bedrag'], |                 "bedrag" => $transactie['bedrag'], | ||||||
|                 "type" => $transactie['type'], |                 "type" => $transactie['type'], | ||||||
|                 "omschrijving" => $transactie['omschrijving'], |                 "omschrijving" => $transactie['omschrijving'], | ||||||
|   | |||||||
| @@ -14,6 +14,9 @@ | |||||||
|  |  | ||||||
| namespace Inforbank; | namespace Inforbank; | ||||||
|  |  | ||||||
|  | /** | ||||||
|  |  * Proxy class om de limitaties van de sgni.nl webserver te omzeilen. Het is mogelijk om de site te bezoeken via zowel /login als /index.php/login op een goed geconfigureerde webserver, maar als de /index.php/login url wordt gebruikt is de onderstaande static file proxy nodig. | ||||||
|  |  */ | ||||||
| class Proxy | class Proxy | ||||||
| { | { | ||||||
|     public static $route; |     public static $route; | ||||||
|   | |||||||
| @@ -1,8 +1,8 @@ | |||||||
| <?php | <?php | ||||||
| return [ | return [ | ||||||
|     'settings' => [ |     'settings' => [ | ||||||
|         'displayErrorDetails' => true, // set to false in production |         'displayErrorDetails' => true, | ||||||
|         'addContentLengthHeader' => false, // Allow the web server to send the content-length header |         'addContentLengthHeader' => false, | ||||||
|  |  | ||||||
|         // Renderer settings |         // Renderer settings | ||||||
|         'renderer' => [ |         'renderer' => [ | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user