<?php
class Salesman {
	public $Name, $Email, $ID, $LastLogin, $Language;
	public function __construct($SalesmanID) {

		global $con;
		$this->hasQuotes = [];
		$this->PRIVATE_KEY = "ID";
		$this->TABLE_NAME = "SALESMAN";

		$query = "SELECT * FROM `{$this->TABLE_NAME}` WHERE {$this->PRIVATE_KEY} LIKE '$SalesmanID' OR `Username` LIKE '$SalesmanID'";
		$result = mysqli_query($con, $query);
		$row = mysqli_fetch_array($result, MYSQLI_ASSOC);

		foreach($row as $key => $value){
				$this->$key = $value;
		}

		$this->Name = $row['FullName'];
		$this->hasQuotes = [];
		$query = "SHOW COLUMNS FROM `$this->TABLE_NAME`";
		$result = mysqli_query($con,$query);
		while($row = mysqli_fetch_array($result, MYSQLI_ASSOC)){
			if(stripos($row['Type'], "int") === 0 || stripos($row['Type'], "double") === 0 || stripos($row['Type'], "tinyint") === 0 || stripos($row['Type'], "numeric") === 0 || stripos($row['Type'], "double") === 0 || stripos($row['Type'], "decimal") === 0 || stripos($row['Type'], "float") === 0 || stripos($row['Type'], "bigint") === 0 || stripos($row['Type'], "real") === 0 || stripos($row['Type'], "bool") === 0){
				$this->hasQuotes[$row['Field']] = false;
			}else{
				$this->hasQuotes[$row['Field']] = true;
			}

		}
	}
}

?>
