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

class MfProductCategory extends DataObject{


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

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

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

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


	protected $id;
	private $weight;
	private $idParent;
	private $publication;
	private $descriptionObj;	
	private $haveChildren;
	public $arrayChildren = array();
	private $checked;


	// -- Konstruktor --


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



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

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

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


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

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


	public function getIdParent(){
		return $this->idParent;
	}

	public function setIdParent($idParent){
		$this->idParent = $idParent;
	}


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

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


	public function GetDescriptionObj() {
		if(!is_object($this->descriptionObj)) {
			$dalData = MfProductCategoryDescriptionDAL::GetDalDataObj();
			$dalData->setCondition(array('publication' => 1, 'lang'=>$this->GetLang(), 'mf_product_category'=>$this->GetId()));

			$descriptionObj = MfProductCategoryDescriptionDAL::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 SetMfProductCategoryDescription($descriptionObj) {
		$this->descriptionObj = $descriptionObj;
	}

	public function GetHaveChildren() {
		return $this->haveChildren;
	}

	public function SetHaveChildren($s) {
		$this->haveChildren = $s;
	}

	public function SetArrayChildren($s) {
		$this->arrayChildren = $s;
	}

	public function AddChildren($obj) {
		$this->arrayChildren = array_merge_recursive($this->arrayChildren, $obj);
	}
	public function GetArrayChildren() {
		return  $this->arrayChildren;
	}	
	
	public function getChecked(){
		return $this->checked;
	}

	public function setChecked($checked){
		$this->checked = $checked;
	}


	public function __call($name, $param) {

		$obj = $this->GetDescriptionObj();

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



	/**
	* 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;
	}



}

?>