<?php
/**
 * Produkty 
 * 
 *
 */
class ProductAttributeController extends MainController implements ControllerInterface {


	const AVATAR_DEST_DIR = '/upload/Product';
	const AVATAR_TEMP_DIR = '/upload/temp';
	const NO_PHOTO_IMG_BIG = "image/Admin/cropperNoPhotoBig.gif";
	const NO_PHOTO_IMG_SMALL = "image/Admin/przekatne.gif";
	const MAX_AVATAR_FILE_SIZE = 5; //Rozmiar w mb
	const CROPPER_BIG_PHOTO_MAX_WIDTH = 800;
	const CROPPER_BIG_PHOTO_MAX_HEIGHT = 800;
	const PHOTO_WIDTH = 800;
	const PHOTO_HEIGHT = 600;

	const IMAGE_MINI_WIDTH = 240;
	const IMAGE_MINI_HEIGHT = 180;
	const IMAGE_NORMAL_WIDTH = 800;
	const IMAGE_NORMAL_HEIGHT = 600;


	public function IndexAction($param) {


		$dalData = MfProductAttributeDAL::GetDalDataObj();
		$dalData->setJoin(array('MfProductAttributeDescription' => ' LEFT JOIN mf_product_attribute_description ON mf_product_attribute.id_mf_product_attribute=mf_product_attribute_description.id_mf_product_attribute '));
		$dalData->setCondition(array('lang' => $param['lang']));
		$arrayObjProductAttribute = MfProductAttributeDAL::GetResult($dalData);

		//		$param['runSharedVariable'] = 'linkedAttribute';
		//		$this->RunModuleController( 'ProductAttributeController', 'LinkedAttribute', $param, true);
		//
		//		$param['runSharedVariable'] = 'unlinkedAttribute';
		//		$this->RunModuleController( 'ProductAttributeController', 'UnlinkedAttribute', $param, true);

		$this->smarty->assign('arrayObjProductAttribute', $arrayObjProductAttribute);
		//Utils::ArrayDisplay($arrayObjProductAttribute);
	}

	//	public function UpdateLangAttrAction($param) {
	//
	//		$dalData = MfProductAttributeDAL::GetDalDataObj();
	//		$dalData->setJoin(array('MfProductAttributeDescription' => ' LEFT JOIN mf_product_attribute_description ON mf_product_attribute.id_mf_product_attribute=mf_product_attribute_description.id_mf_product_attribute '));
	//		$dalData->setCondition(array('lang' => 'pl'));
	//		$arrayObjProductAttribute = MfProductAttributeDAL::GetResult($dalData);
	//
	//		//Utils::ArrayDisplay($arrayObjProductAttribute);
	//
	//		foreach ($arrayObjProductAttribute as $objProductAttribute) {
	//			//Utils::ArrayDisplay($objProductAttribute->GetDescriptionObj());
	//			$objDesc = $objProductAttribute->GetDescriptionObj();
	//			foreach (Router::$arrayLang as $lang) {
	//				if ($lang  != 'pl') {
	//
	//					$objDesc->setLang($lang);
	//					$objDesc->setId('-1');
	//					Utils::ArrayDisplay($objDesc);
	//					MfProductAttributeDescriptionDAL::Save($objDesc);
	//
	//				}
	//			}
	//		}
	//
	//	}
	//
	//	public function UpdateLangCatAction($param) {
	//
	//		$dalData = MfProductCategoryDAL::GetDalDataObj();
	//		$dalData->setJoin(array('MfProductCategoryDescription' => ' LEFT JOIN mf_product_category_description ON mf_product_category.id_mf_product_category=mf_product_category_description.id_mf_product_category '));
	//		$dalData->setCondition(array('lang' => 'pl'));
	//		$arrayObjProductCategory = MfProductCategoryDAL::GetResult($dalData);
	//
	//		//Utils::ArrayDisplay($arrayObjProductAttribute);
	//
	//		foreach ($arrayObjProductCategory as $objProductCategory) {
	//			//Utils::ArrayDisplay($objProductAttribute->GetDescriptionObj());
	//			$objDesc = $objProductCategory->GetDescriptionObj();
	//			foreach (Router::$arrayLang as $lang) {
	//				if ($lang  != 'pl') {
	//
	//					$objDesc->setLang($lang);
	//					$objDesc->setId('-1');
	//					Utils::ArrayDisplay($objDesc);
	//					MfProductCategoryDescriptionDAL::Save($objDesc);
	//
	//				}
	//			}
	//		}
	//
	//	}

	public function LinkedAttributeAction($param) {
		//Utils::ArrayDisplay($param);
		if (isset($param['idAttribute'])) {
			$idsAttribute = MfProductLinkDAL::GetIdStringDestinaion('mf_product_attribute', 'mf_product_attribute', $param['idAttribute'], $param['lang']);
			$dalData = MfProductAttributeDAL::GetDalDataObj();
			$dalData->setCondition(array('lang' => $param['lang']));
			$dalData->addCondition('   ', 'mf_product_attribute.id_mf_product_attribute IN ('.$idsAttribute.') ', ' ');
			$dalData->setJoin(array('MfProductAttributeDescription' => ' LEFT JOIN mf_product_attribute_description ON mf_product_attribute.id_mf_product_attribute=mf_product_attribute_description.id_mf_product_attribute '));

			$arrayObjAttribute = MfProductAttributeDAL::GetResult($dalData);
			$this->smarty->assign('arrayObjAttribute', $arrayObjAttribute);
		} else {
			$this->smarty->assign('arrayObjAttribute', array());
			$this->smarty->assign('clikAttribute', true);
		}
	}

	public function UnlinkedAttributeAction($param) {
		//Utils::ArrayDisplay($param);
		if (isset($param['idAttribute'])) {
			$idsAttribute = MfProductLinkDAL::GetIdStringDestinaion('mf_product_attribute', 'mf_product_attribute', $param['idAttribute'], $param['lang']);
			$dalData = MfProductAttributeDAL::GetDalDataObj();
			$dalData->setCondition(array('lang' => $param['lang']));
			$dalData->addCondition('   ', 'mf_product_attribute.id_mf_product_attribute NOT IN ('.$idsAttribute.') ', ' ');
			$dalData->setJoin(array('MfProductAttributeDescription' => ' LEFT JOIN mf_product_attribute_description ON mf_product_attribute.id_mf_product_attribute=mf_product_attribute_description.id_mf_product_attribute '));

			$arrayObjAttribute = MfProductAttributeDAL::GetResult($dalData);
			$this->smarty->assign('arrayObjAttribute', $arrayObjAttribute);
		} else {
			$this->smarty->assign('arrayObjAttribute', array());
			$this->smarty->assign('clikAttribute', true);
		}
	}

	public function IndexStructureAction($param) {

		$idAttribute = SessionProxy::GetValue('idAttribute');
		$this->smarty->assign('idAttribute', $idAttribute);

		$idsProduct = MfProductLinkDAL::GetIdStringDestinaion('mf_product_attribute', 'mf_product',$idAttribute, $param['lang']);

		$dalData = MfProductDAL::GetDalDataObj();
		$dalData->setJoin(array('MfProductDescription' => ' LEFT JOIN mf_product_description ON mf_product.id_mf_product=mf_product_description.id_mf_product '));
		$dalData->setCondition(array('lang' => $param['lang']));
		//Utils::ArrayDisplay('ss'.$idsProduct);
		$dalData->addCondition('   ', 'mf_product.id_mf_product IN (' .$idsProduct. ') ', ' ');
		$arrayObj = MfProductDAL::GetResult($dalData);

		$this->smarty->assign('arrayObj', $arrayObj);
		if (isset($param['methodToRun']) && $param['methodToRun'] == 'Add') {
			$this->smarty->assign('add', true);
		}

	}

	public function AddAction($param) {


		$dalData = MfProductAttributeDAL::GetDalDataObj();
		$dalData->setCondition(array('lang' => $param['lang']));
		//	$dalData->addCondition('   ', 'mf_product_attribute.id_mf_product_attribute IN ('.$idsAttribute.') ', ' ');
		$dalData->setJoin(array('MfProductAttributeDescription' => ' LEFT JOIN mf_product_attribute_description ON mf_product_attribute.id_mf_product_attribute=mf_product_attribute_description.id_mf_product_attribute '));

		//Utils::ArrayDisplay($dalData);
		$arrayObjAttribute = MfProductAttributeDAL::GetResult($dalData);
		//$objProductAttribute = MfProductAttributeDAL::GetResultByLink('mf_product_attribute', $idAttribute, 'mf_product_attribute');
		//Utils::ArrayDisplay($arrayObjAttribue);
		$this->smarty->assign('arrayObjAttribute', $arrayObjAttribute);
		$this->smarty->assign('arrayObjAttributeLinked', array());
		$objAttributeProduct = MfProductAttributeDAL::GetEmptyObj();

		if (Request::GetPost('doAttributeAdd')) {
			//Utils::ArrayDisplay(Request::GetAllPost());

			$out = array();
			$validator  = new Validator(Request::GetAllPost());
			$data = Request::GetAllPost();

			$validator->IsEmpty('name_pl', 'Pole nazwa musi zostać wypełnione.');
			//$validator->IsEmpty('name_en', 'Pole nazwa musi zostać wypełnione.');
			//$validator->IsEmpty('name_ru', 'Pole nazwa musi zostać wypełnione.');

			$out = $validator->GetErrorList();

			$publication = Request::Get('publication');
			$publication ? $publication = 1 : $publication = '0';

			//$objProduct = new MfProduct();
			//$objAttributeProduct->setDate($data['datepublication']." ".$data['timepublication'].":00:00");
			$objAttributeProduct->setDate("0000-00-00");
			$objAttributeProduct->setPublication($publication);
			$objAttributeProductDesc = new MfProductAttributeDescription();
			$objAttributeProductDescEn = new MfProductAttributeDescription();
			$objAttributeProductDescRu = new MfProductAttributeDescription();
			$objAttributeProductDesc->setLang('pl');
			$objAttributeProductDesc->setDescription($data['name_pl']);
			$objAttributeProductDescEn->setLang('en');
			$objAttributeProductDescEn->setDescription($data['name_en']);
			$objAttributeProductDescRu->setLang('ru');
			$objAttributeProductDescRu->setDescription($data['name_ru']);

			//$arrayObjAttributeWithValue = array();

			//Utils::ArrayDisplay($arrayObjAttribute);

			if(empty($out)) {


				//Utils::ArrayDisplay($objAttributeProductDesc);
				//Utils::ArrayDisplay($objAttributeProductDescEn);
				//Utils::ArrayDisplay($objAttributeProductDescRu);
				$idAttributeProduct = MfProductAttributeDAL::Save($objAttributeProduct);
				$objAttributeProductDesc->setIdMfProductAttribute($idAttributeProduct);
				$objAttributeProductDescEn->setIdMfProductAttribute($idAttributeProduct);
				$objAttributeProductDescRu->setIdMfProductAttribute($idAttributeProduct);
				MfProductAttributeDescriptionDAL::Save($objAttributeProductDesc);
				MfProductAttributeDescriptionDAL::Save($objAttributeProductDescEn);
				MfProductAttributeDescriptionDAL::Save($objAttributeProductDescRu);

				//				foreach ($data['attr'] as $attrKey => $attrId ) {
				//					$objMfProductLink = new MfProductLink();
				//					$objMfProductLink->setDestinationType('mf_product_attribute');
				//					$objMfProductLink->setSourceType('mf_product_attribute');
				//					$objMfProductLink->setIdDestination($attrId);
				//					$objMfProductLink->setIdSource($idAttributeProduct);
				//					$objMfProductLink->setLang($param['lang']);
				//					$objMfProductLink->setPublication(1);
				//					MfProductLinkDAL::Save($objMfProductLink);
				//				}

				$this->AddRedirectInfo('Zapisano', 'ok', Router::GenerateUrl('editAttribute', array('ProductAttribute' => 'index')));
			} else {

				//				if (isset($data['attr'])) {
				//					$idAttrLinked = implode(', ',$data['attr']);
				//				} else {
				//					$idAttrLinked = '-1';
				//				}
				//				$dalData = MfProductAttributeDAL::GetDalDataObj();
				//				$dalData->setCondition(array('lang' => $param['lang']));
				//				$dalData->addCondition('   ', 'mf_product_attribute.id_mf_product_attribute IN ('.$idAttrLinked.') ', ' ');
				//				$dalData->setJoin(array('MfProductAttributeDescription' => ' LEFT JOIN mf_product_attribute_description ON mf_product_attribute.id_mf_product_attribute=mf_product_attribute_description.id_mf_product_attribute '));
				//
				//				//Utils::ArrayDisplay($dalData);
				//				$arrayObjAttributeLinked = MfProductAttributeDAL::GetResult($dalData);
				//				//$objProductAttribute = MfProductAttributeDAL::GetResultByLink('mf_product_attribute', $idAttribute, 'mf_product_attribute');
				//				//Utils::ArrayDisplay($arrayObjAttributeLinked);
				//
				//				$dalData = MfProductAttributeDAL::GetDalDataObj();
				//				$dalData->setCondition(array('lang' => $param['lang']));
				//				$dalData->addCondition('   ', 'mf_product_attribute.id_mf_product_attribute NOT IN ('.$idAttrLinked.') ', ' ');
				//				$dalData->setJoin(array('MfProductAttributeDescription' => ' LEFT JOIN mf_product_attribute_description ON mf_product_attribute.id_mf_product_attribute=mf_product_attribute_description.id_mf_product_attribute '));
				//
				//				//Utils::ArrayDisplay($dalData);
				//				$arrayObjAttribute = MfProductAttributeDAL::GetResult($dalData);
				//
				//				$this->smarty->assign('arrayObjAttribute', $arrayObjAttribute);
				//				$this->smarty->assign('arrayObjAttributeLinked', $arrayObjAttributeLinked);


				$objAttributeProduct->SetDescriptionObj($objAttributeProductDesc);
				$this->smarty->assign('objAttributeProductDesc',$objAttributeProductDesc);
				$this->smarty->assign('objAttributeProductDescRu',$objAttributeProductDescRu);
				$this->smarty->assign('objAttributeProductDescEn',$objAttributeProductDescEn);
				$this->smarty->assign('objAttributeProduct',$objAttributeProduct);


				$this->smarty->assign('arrayObjAttribute', $arrayObjAttribute);
				$this->smarty->assign('info','Pola obowiązkowe muszą zostać wypełnione.');
				$this->smarty->assign('type','error');

				foreach ($out as $item) {
					$error[$item['field']] = $item['msg'];


				}
				$this->smarty->assign('error',$error);


			}



		}
	}


	public function EditAction($param) {


		//		$idsAttribute = MfProductLinkDAL::GetIdStringDestinaion('mf_product_attribute', 'mf_product_attribute', $param['id'], $param['lang']);
		//		$dalData = MfProductAttributeDAL::GetDalDataObj();
		//		$dalData->setCondition(array('lang' => $param['lang']));
		//		$dalData->addCondition('   ', 'mf_product_attribute.id_mf_product_attribute NOT IN ('.$idsAttribute.') ', ' ');
		//		$dalData->setJoin(array('MfProductAttributeDescription' => ' LEFT JOIN mf_product_attribute_description ON mf_product_attribute.id_mf_product_attribute=mf_product_attribute_description.id_mf_product_attribute '));
		//
		//		//Utils::ArrayDisplay($dalData);
		//		$arrayObjAttribute = MfProductAttributeDAL::GetResult($dalData);
		//
		//		$dalData = MfProductAttributeDAL::GetDalDataObj();
		//		$dalData->setCondition(array('lang' => $param['lang']));
		//		$dalData->addCondition('   ', 'mf_product_attribute.id_mf_product_attribute IN ('.$idsAttribute.') ', ' ');
		//		$dalData->setJoin(array('MfProductAttributeDescription' => ' LEFT JOIN mf_product_attribute_description ON mf_product_attribute.id_mf_product_attribute=mf_product_attribute_description.id_mf_product_attribute '));
		//
		//		//Utils::ArrayDisplay($dalData);
		//		$arrayObjAttributeLinked = MfProductAttributeDAL::GetResult($dalData);
		//		//$objProductAttribute = MfProductAttributeDAL::GetResultByLink('mf_product_attribute', $idAttribute, 'mf_product_attribute');
		//		//Utils::ArrayDisplay($arrayObjAttribue);
		//		$this->smarty->assign('arrayObjAttribute', $arrayObjAttribute);
		//		$this->smarty->assign('arrayObjAttributeLinked', $arrayObjAttributeLinked);
		$objAttributeProduct = MfProductAttributeDAL::GetById($param['id'], 'pl');
		$objAttributeProductRu = MfProductAttributeDAL::GetById($param['id'], 'ru');
		$objAttributeProductEn = MfProductAttributeDAL::GetById($param['id'], 'en');
		//$objAttributeProduct->setLang('pl');
		$this->smarty->assign('objAttributeProduct', $objAttributeProduct);
		$this->smarty->assign('objAttributeProductDesc',$objAttributeProduct->getDescriptionObj());
		//$objAttributeProduct->setLang('en');
		$this->smarty->assign('objAttributeProductDescRu',$objAttributeProductRu->getDescriptionObj());
		//$objAttributeProduct->setLang('ru');
		$this->smarty->assign('objAttributeProductDescEn',$objAttributeProductEn->getDescriptionObj());

		if (Request::GetPost('doAttributeEdit')) {
			//Utils::ArrayDisplay(Request::GetAllPost());

			$out = array();
			$validator  = new Validator(Request::GetAllPost());
			$data = Request::GetAllPost();

			$validator->IsEmpty('name_pl', 'Pole nazwa musi zostać wypełnione.');
			//$validator->IsEmpty('name_en', 'Pole nazwa musi zostać wypełnione.');
			//$validator->IsEmpty('name_ru', 'Pole nazwa musi zostać wypełnione.');

			$out = $validator->GetErrorList();

			$publication = Request::Get('publication');
			$publication ? $publication = 1 : $publication = '0';

			//$objProduct = new MfProduct();
			//$objAttributeProduct->setDate($data['datepublication']." ".$data['timepublication'].":00:00");
			$objAttributeProduct->setDate("0000-00-00");
			$objAttributeProduct->setPublication($publication);
			$objAttributeProductDesc = $objAttributeProduct->getDescriptionObj();
			$objAttributeProductDescEn = $objAttributeProductEn->getDescriptionObj();
			$objAttributeProductDescRu = $objAttributeProductRu->getDescriptionObj();

			//$objAttributeProductDesc->setDatePublication("0000-00-00 00:00:00");
			$objAttributeProductDesc->setLang('pl');
			$objAttributeProductDesc->setDescription($data['name_pl']);
			$objAttributeProductDescEn->setLang('en');
			$objAttributeProductDescEn->setDescription($data['name_en']);
			$objAttributeProductDescRu->setLang('ru');
			$objAttributeProductDescRu->setDescription($data['name_ru']);
			$objAttributeProduct->setLang('pl');
			//$arrayObjAttributeWithValue = array();

			//Utils::ArrayDisplay($arrayObjAttribute);

			if(empty($out)) {

				//Utils::ArrayDisplay($objAttributeProductDesc);
				//Utils::ArrayDisplay($objAttributeProductDescEn);
				//Utils::ArrayDisplay($objAttributeProductDescRu);
				$idAttributeProduct = MfProductAttributeDAL::Save($objAttributeProduct);
				$objAttributeProductDesc->setIdMfProductAttribute($idAttributeProduct);
				$objAttributeProductDescEn->setIdMfProductAttribute($idAttributeProduct);
				$objAttributeProductDescRu->setIdMfProductAttribute($idAttributeProduct);
				MfProductAttributeDescriptionDAL::Save($objAttributeProductDesc);
				MfProductAttributeDescriptionDAL::Save($objAttributeProductDescEn);
				MfProductAttributeDescriptionDAL::Save($objAttributeProductDescRu);


				//				MfProductLinkDAL::DeleteFromLink($idAttributeProduct, 'mf_product_attribute', null, 'mf_product_attribute');
				//
				//				foreach ($data['attr'] as $attrKey => $attrId ) {
				//					$objMfProductLink = new MfProductLink();
				//					$objMfProductLink->setDestinationType('mf_product_attribute');
				//					$objMfProductLink->setSourceType('mf_product_attribute');
				//					$objMfProductLink->setIdDestination($attrId);
				//					$objMfProductLink->setIdSource($idAttributeProduct);
				//					$objMfProductLink->setLang($param['lang']);
				//					$objMfProductLink->setPublication(1);
				//					//Utils::ArrayDisplay($objMfProductLink);
				//					MfProductLinkDAL::Save($objMfProductLink);
				//				}

				$this->AddRedirectInfo('Zapisano', 'ok', Router::GenerateUrl('editAttribute', array('ProductAttribute' => 'index')));
			} else {

				//				if (isset($data['attr'])) {
				//					$idAttrLinked = implode(', ',$data['attr']);
				//				} else {
				//					$idAttrLinked = '-1';
				//				}
				//				$dalData = MfProductAttributeDAL::GetDalDataObj();
				//				$dalData->setCondition(array('lang' => $param['lang']));
				//				$dalData->addCondition('   ', 'mf_product_attribute.id_mf_product_attribute IN ('.$idAttrLinked.') ', ' ');
				//				$dalData->setJoin(array('MfProductAttributeDescription' => ' LEFT JOIN mf_product_attribute_description ON mf_product_attribute.id_mf_product_attribute=mf_product_attribute_description.id_mf_product_attribute '));
				//
				//				//Utils::ArrayDisplay($dalData);
				//				$arrayObjAttributeLinked = MfProductAttributeDAL::GetResult($dalData);
				//				//$objProductAttribute = MfProductAttributeDAL::GetResultByLink('mf_product_attribute', $idAttribute, 'mf_product_attribute');
				//				//Utils::ArrayDisplay($arrayObjAttributeLinked);
				//
				//				$dalData = MfProductAttributeDAL::GetDalDataObj();
				//				$dalData->setCondition(array('lang' => $param['lang']));
				//				$dalData->addCondition('   ', 'mf_product_attribute.id_mf_product_attribute NOT IN ('.$idAttrLinked.') ', ' ');
				//				$dalData->setJoin(array('MfProductAttributeDescription' => ' LEFT JOIN mf_product_attribute_description ON mf_product_attribute.id_mf_product_attribute=mf_product_attribute_description.id_mf_product_attribute '));
				//
				//				//Utils::ArrayDisplay($dalData);
				//				$arrayObjAttribute = MfProductAttributeDAL::GetResult($dalData);
				//
				//				$this->smarty->assign('arrayObjAttribute', $arrayObjAttribute);
				//				$this->smarty->assign('arrayObjAttributeLinked', $arrayObjAttributeLinked);
				//

				$objAttributeProduct->SetDescriptionObj($objAttributeProductDesc);
				$this->smarty->assign('objAttributeProduct',$objAttributeProduct);

				$this->smarty->assign('objAttributeProductDesc',$objAttributeProductDesc);
				$this->smarty->assign('objAttributeProductDescRu',$objAttributeProductDescRu);
				$this->smarty->assign('objAttributeProductDescEn',$objAttributeProductDescEn);


				$this->smarty->assign('arrayObjAttribute', $arrayObjAttribute);
				$this->smarty->assign('info','Pola obowiązkowe muszą zostać wypełnione.');
				$this->smarty->assign('type','error');

				foreach ($out as $item) {
					$error[$item['field']] = $item['msg'];


				}
				$this->smarty->assign('error',$error);


			}



		}
	}


	public function AjaxAddLinkAttrAction($param) {
		//$array
	}

	public function DeleteAction($param) {
		$isLinked = MfProductLinkDAL::IsLinked(null, 'mf_product_category', $param['id'], 'mf_product_attribute');
		$delete = true;
		$error = '';
		if ($isLinked > 0 ) {
			$delete = false;
		}

		$arrayLang = (Router::$arrayLang);
		unset($arrayLang[$param['lang']]);
		$langString = implode(',', $arrayLang);

		$isLang = MfProductAttributeDAL::CheakDescLang($param['id'], $param['lang']);

		//		if ($isLang) {
		//			$delete = false;
		//		}

		if ($delete) {

			foreach (Router::$arrayLang as $lang) {
				$objAttribute = MfProductAttributeDAL::GetById($param['id'], $lang);
				$objAttributeDesc = $objAttribute->getDescriptionObj();
				$dalDataDesc = MfProductAttributeDescriptionDAL::GetDalDataObj();
				$dalDataDesc->setObj($objAttributeDesc);
				MfProductAttributeDescriptionDAL::Delete($dalDataDesc);
			}


			$dalData = MfProductAttributeDAL::GetDalDataObj();
			$dalData->setObj($objAttribute);
			MfProductAttributeDAL::Delete($dalData);
			$this->AddRedirectInfo('Element został usunięty', 'ok', Router::GenerateUrl('editAttribute', array('ProductAttribute' => 'Index')));
		} else {
			if ($isLinked) {
				$error .= 'Parametr jest powiązany z kategorią.';
			}
			//			if ($isLang) {
			//				$error .= $error ? '<br/><br/>' : '';
			//				$error .= 'Parametr posiada wersję jezykową';
			//			}
			$this->AddRedirectInfo($error, 'error', Router::GenerateUrl('editAttribute', array('ProductAttribute' => 'Index')));
		}
	}


	/**
     * Wspolna metoda
     *
     */
	public function preDispatch($param) {


		$this->RunShared('Auth', $param);
		$this->Run($param);
		$this->AddScript('structure.js');
		$admin = AuthDAL::GetAdmin();
		$this->user = $admin;

		$this->smarty->assign('titleAdmin', 'Administracja');

		$struct = array(
		//'User' => array('User' => 'Index'),
		'Słowniki' => array('Dictionary' => 'Index'),
		'Zmienne serwisu' => array('Setup' => 'Index'),
		//'Kategorie produktów' => array('ProductCategory' => 'Index'),
		'Parametry produktów' => array('ProductAttribute' => 'Index')


		);

		$this->smarty->assign('structure',$this->renderStruct($struct));

	}

	private function renderStruct($struct){
		$return = '';

		foreach($struct AS $k => $row){
			$return .= '<li><a href="' . Router::GenerateUrl('dictpig',$row).'">'.$k.'</a></li>';
		}

		$html = '<ul>';
		$html .= $return;
		$html .= '</ul>';


		return $html;
	}

	public function PostDispatch($param) {

	}


}

?>