<?php

/**
 * 
 * @author Peter Csubak (chuby)
 * @copyright Peter Csubak (chuby)
 * 
 * //Annotations:
 * @Table
 */
class Customer extends Entity implements SecurityGroup {
	
	/**
	 * @var string
	 * @Id(hashBy="<<name>><<phone>>")
	 * @Attribute(type="md5")
	 */
	protected $ID;
	
	/**
	 * @var string
	 * @Attribute(type="string", length=25)
	 */
	protected $name;
	
	/**
	 * @var string
	 * @Attribute(type="string", length=50)
	 */
	protected $address;
	
	/**
	 * @var string
	 * @Attribute(type="string", length=12)
	 * @Constraints(regex="[0-9]+")
	 */
	protected $phone;
	
	/**
	 * @var string
	 * @Attribute(type="string", length=10)
	 */
	protected $userName;
	
	/**
	 * @var string
	 * @Attribute(type="md5")
	 */
	protected $passCode;
	
	/**
	 * @var array
	 * @Select(type="Order", where={"CustomerId" = "<<ID>>"}, metaselect=true, onSet="setOrders")
	 * @XmlArray(schemaName="desktop", elementName="e", valueType="Order")
	 * @XmlArray(schemaName="mobile", elementName="e", valueType="Order")
	 */
	protected $orders;
	
	/** @XmlSchema */
	public $desktop;
	
	/** @XmlSchema */
	public $mobile;
	
	
	public function getGroupName(){
		return "customer";
	}
	
	public function setOrders($ord){
		
	}
	
	public function __construct(){
		$this->desktop = "<customer>".
							"<name>name</name>".
							"<address>address</address>".
							"<phone>phone</phone>".
							"<userName>userName</userName>".
							"<passCode>passCode</passCode>".
							"<orders>orders</orders>".
						"</customer>";
		
		$this->mobile = "<cus>".
							"<n>name</n>".
							"<a>address</a>".
							"<p>phone</p>".
						"</cus>";
	}
	
}
?>