<?php
/**
 * Model dla klasy MfProductAttribute
 *
 * @author ModGen
 */

class MfProductAttribute extends DataObject{


	/**
	 * nazwa tabeli
	 */
	static $tableName = 'mf_product_attribute';

	/**
	 * nazwa klucza tabeli
	 */
	static $classTablePK = 'id_mf_product_attribute';

	/**
	 * nazwa klasy
	 */
	static $className = __CLASS__;

	/**
	 * tablica mapująca pola klasy
	 */
	static $fields = array(
		'id_mf_product_attribute' => 'id',
		'publication' => 'publication',
		'weight' => 'weight',
		'date' => 'date'
	);


	protected $id;
	private $publication;
	private $weight;
	private $date;
	private $descriptionObj;
	private $valueObj;
	private $lang;
	private $value;



	// -- Konstruktor --


	function __construct( $id = -1 , $publication = null, $weight = null, $date = null){
		$this->id = $id;
		$this->publication = $publication;
		$this->weight = $weight;
		$this->date = $date;
	}



	// -- Get-y i Set-y --

	public function getId(){
		return $this->id;
	}

	public function setId($id){
		$this->id = $id;
	}

	
	public function getPublication(){
		return $this->publication;
	}

	public function setPublication($publication){
		$this->publication = $publication;
	}

	
	public function getWeight(){
		return $this->weight;
	}

	public function setWeight($weight){
		$this->weight = $weight;
	}

	
	public function getDate(){
		return $this->date;
	}

	public function setDate($date){
		$this->date = $date;
	}

	public function setValue($value){
		$this->value = $value;
	}

	
	public function getValue(){
		return $this->value;
	}




	/**
	* Pobiera nazwę tabeli reprezentującej obiekt w SQL
	* @return string
	*/
	public  function GetTableName(){
	return self::$tableName;
	}

	/**
	* Pobiera nazwę klucza głównego tabeli
	* @return string
	*/
	public function GetClassTablePK() {
		return self::$classTablePK;
	}

	/**
	* Pobiera tablice mapującą pola klasy na pola tabeli
	* @return array
	*/
	public  function GetFields(){
		return self::$fields;
	}

	/**
	* Pobiera nazwę klasy
	* @return string
	*/
	public  function GetClassName(){
		return self::$className;
	}
	
	
	public function SetLang($lang) {
		$this->lang = $lang;
	}

	public function GetLang() {
		return $this->lang;
	}


	
	public function GetDescriptionObj() {
		if(!is_object($this->descriptionObj)) {
			$dalData = MfProductAttributeDescriptionDAL::GetDalDataObj();
			$dalData->setCondition(array('publication' => 1, 'lang'=>$this->GetLang(), 'mf_product_attribute'=>$this->GetId()));
			
			$descriptionObj = MfProductAttributeDescriptionDAL::GetResult($dalData);
			if(isset($descriptionObj[0]) && is_object($descriptionObj[0])) {
				$this->SetDescriptionObj($descriptionObj[0]);
			} else {
				throw new UserException('Brak wersji jezykowej dla tego rekordu! ('.$this->GetId().' '.$this->GetLang().')');
			}
		}
		return $this->descriptionObj;
	}

	public function SetDescriptionObj($descriptionObj) {
		$this->descriptionObj = $descriptionObj;
	}
	public function SetMfProductAttributeDescription($descriptionObj) {
		$this->descriptionObj = $descriptionObj;
	}

//	public function SetMfProductAttributeValue($descriptionObj) {
//		$this->valueObj = $descriptionObj;
//	}
//	
//	public function SetValueObj($valueObj) {
//		$this->valueObj = $valueObj;
//	}
//	
//	public function GetValueObj() {
//		if(!is_object($this->valueObj)) {
//			$dalData = MfProductAttributeValueDAL::GetDalDataObj();
//			$dalData->setCondition(array('publication' => 1, 'lang'=>$this->GetLang(), 'mf_product_attribute'=>$this->GetId()));
//			
//			$descriptionObj = MfProductAttributeDescriptionDAL::GetResult($dalData);
//			if(isset($descriptionObj[0]) && is_object($descriptionObj[0])) {
//				$this->SetDescriptionObj($descriptionObj[0]);
//			} else {
//				throw new UserException('Brak wersji jezykowej dla tego rekordu! ('.$this->GetId().' '.$this->GetLang().')');
//			}
//		}
//		return $this->descriptionObj;
//	}


	public function __call($name, $param) {

		$obj = $this->GetDescriptionObj();

		return $obj->$name($param);
	}
	

}

?>