Added static object linking & authorization methods
This commit is contained in:
		
							
								
								
									
										64
									
								
								src/Application/Helper/IBAN.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										64
									
								
								src/Application/Helper/IBAN.php
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,64 @@ | ||||
| <?php | ||||
|  | ||||
| /** | ||||
|  *  Informatica Eindproject D4p | ||||
|  *  6in3, Stedelijk Gymnasium Nijmegen | ||||
|  *  Docent: Hans de Wolf | ||||
|  * | ||||
|  *  ================== | ||||
|  * | ||||
|  *  Daniel Boutros, | ||||
|  *  Christiaan Goossens, | ||||
|  *  Jelmer Hinssen | ||||
|  */ | ||||
|  | ||||
| namespace Inforbank\Application\Helper; | ||||
|  | ||||
| class IBAN | ||||
| { | ||||
|     private function wordToNumbers($word) | ||||
|     { | ||||
|         $newword = ""; | ||||
|         $wordarray = str_split($word); | ||||
|         foreach ($wordarray as $v) { | ||||
|             $newword .= ord(strtolower($v)) - 87; | ||||
|         } | ||||
|         return $newword; | ||||
|     } | ||||
|  | ||||
|  | ||||
|     public function getIBAN($rekeningnr) | ||||
|     { | ||||
|         $landcode = "NL"; // NL in vertaling | ||||
|         $landnumber = $this->wordToNumbers($landcode); | ||||
|  | ||||
|  | ||||
|         $bankcode = "INFO"; | ||||
|         $banknumber = $this->wordToNumbers($bankcode); | ||||
|  | ||||
|         $rekeningnr = str_pad($rekeningnr, 10, 0, STR_PAD_LEFT); | ||||
|  | ||||
|         $bignum = $banknumber . $rekeningnr . $landnumber . "00"; | ||||
|  | ||||
|         $modulo97 = ''; | ||||
|         $checkdigits = '00'; | ||||
|  | ||||
|         // begin modulo staartdeling | ||||
|         $modulo97 = (int)substr($bignum, 0, 6); | ||||
|         $modulo97 = $modulo97 % 97; | ||||
|         $modulo97 = (1000000 * $modulo97) + (int)substr($bignum, 6, 6); | ||||
|         $modulo97 = $modulo97 % 97; | ||||
|         $modulo97 = (1000000 * $modulo97) + (int)substr($bignum, 12, 6); | ||||
|         $modulo97 = $modulo97 % 97; | ||||
|         $modulo97 = (1000000 * $modulo97) + (int)substr($bignum, 18, 6); | ||||
|         $modulo97 = $modulo97 % 97; | ||||
|         $checkdigits = 98 - $modulo97; | ||||
|         // einde modulo staartdeling | ||||
|         if (strlen($checkdigits) < 2) { | ||||
|             $checkdigits = '0' . $checkdigits; | ||||
|         } | ||||
|  | ||||
|         $rekeningnrarr = str_split($rekeningnr, 4); | ||||
|         return $landcode.$checkdigits." ".$bankcode." ".$rekeningnrarr[0]." ".$rekeningnrarr[1]." ".$rekeningnrarr[2]; | ||||
|     } | ||||
| } | ||||
							
								
								
									
										42
									
								
								src/Application/Helper/Rekeningen.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										42
									
								
								src/Application/Helper/Rekeningen.php
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,42 @@ | ||||
| <?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 function getCurrentUserRekeningen() | ||||
|     { | ||||
|         $container = Application::getContainer(); | ||||
|         $user = $container->auth->getUser(); | ||||
|  | ||||
|         $db = $container->db; | ||||
|         $ibanhelper = new IBAN; | ||||
|  | ||||
|         $rekeningen = $db->rekeningen->where('klantid', $user['id']); | ||||
|  | ||||
|         $returnArray = array(); | ||||
|  | ||||
|         foreach ($rekeningen as $rekening) { | ||||
|             $returnArray[] = array( | ||||
|                 "rekeningnr" => $ibanhelper->getIBAN($rekening['rekeningnr']), | ||||
|                 "saldo" => (double) $rekening['saldo'] | ||||
|             ); | ||||
|         } | ||||
|  | ||||
|         return $returnArray; | ||||
|     } | ||||
| } | ||||
		Reference in New Issue
	
	Block a user