HEX
Server: Apache
System: Linux v38079.2is.nl 3.10.0-1160.119.1.el7.x86_64 #1 SMP Tue Jun 4 14:43:51 UTC 2024 x86_64
User: democfellows (10015)
PHP: 8.1.34
Disabled: opcache_get_status
Upload Files
File: /var/www/vhosts/creativefellows.nl/test.creativefellows.nl/tekenmappen/classes/ClientController.php
<?php
	
	/**
	* Client Controller
	*/
	class ClientController extends BaseController
	{
	
		function __construct($db){
			
			$this->db = $db;
			
		}
			
		
		public function create()
		{
			$sth = $this->db->prepare(
				"INSERT INTO klanten(
						aanhef,
						voornaam,
						achternaam,
						bedrijfsnaam,
						telefoon,
						email,
						straat,
						huisnummer,
						postcode,
						plaats,
						land
					) 
				VALUES(
						:aanhef,
						:voornaam,
						:achternaam,
						:bedrijfsnaam,
						:telefoon,
						:email,
						:straat,
						:huisnummer,
						:postcode,
						:plaats,
						:land
					)
				");
	
			// get user session data
			$this->session = new CartController("user");
				
			$sth->execute([
				"aanhef" => $this->session->getSingle("aanhef"),
				"voornaam" => $this->session->getSingle("voornaam"),
				"achternaam" => $this->session->getSingle("achternaam"),
				"bedrijfsnaam" => $this->session->getSingle("bedrijfsnaam"),
				"telefoon" => $this->session->getSingle("telefoon"),
				"email" => $this->session->getSingle("email"),
				"straat" => $this->session->getSingle("straat"),
				"huisnummer" => $this->session->getSingle("huisnummer"),
				"postcode" => $this->session->getSingle("postcode"),
				"plaats" => $this->session->getSingle("plaats"),
				"land" => $this->session->getSingle("land")
			]);	
			
			$client_id = $this->db->lastInsertId();
						
			$this->setClient( $client_id );	
			
		}	
		
		private function setClient($client_id)
		{
			$this->client_id = $client_id;
			$sth = $this->db->prepare("SELECT * FROM klanten WHERE klant_id = :klant_id");
			$sth->execute([
				"klant_id" => $client_id
			]);

			$user_fields = $sth->fetch();
			
			//$this->client = [];
			foreach($user_fields as $column =>$value)
			{
				$this->$column = $value;
			}	
			
			$this->full_address 	= $this->straat." ". $this->huisnummer ."<br />". $this->postcode ." ". $this->plaats ."<br />". $this->land ."<br /><a href='". $this->email ."'>". $this->email ."</a><br />". $this->telefoon;
			$this->full_name 		= preg_replace('/\s+/', ' ',$this->voornaam ." ". $this->tussenvoegsel ." ". $this->achternaam);
			$this->aanhef			= $this->aanhef == 0 ? "de heer" : "mevrouw";
			
		}
		
		public function setClientById($client_id)
		{
			$this->setClient($client_id);
		}
		
		public function getClientId()
		{
			return $this->client_id;
		}
		
		public function getFullName()
		{
			return $this->full_name;
		}
		
		public function getFirstName()
		{
			return ucfirst($this->voornaam);
		}
		
		public function getAddress()
		{
			return $this->full_address;
		}
		
		public function getEmail(){
			return $this->email;
		}
		
		
	
		
	}
	
?>