<?php


class Lib_Export
{




	function colorElement($row,$idE) 
	{	
		$db = Zend_Registry::get('db');
		// sprawdzenie koloru elementu
		
		if( $idE == 1 ){
			// plyta korpus
			$idElement = $row['product_body_id'];
			$schema = 'body';	
			$ask = 'SELECT * FROM product_'.$schema.' WHERE product_'.$schema.'_id = '.$idElement.' AND product_'.$schema.'_type'.$schema.' = 0 LIMIT 1';
		//	return$ask;
			$rowReturn = $db->query($ask)->fetch();
			return $rowReturn['product_'.$schema.'_name']; // .'('.$ask.')';
		}
		
		if( $idE == 2 ){
			// plyta front
			$idElement = $row['product_front_id'];
			$schema = 'front';	
			$ask = 'SELECT * FROM product_'.$schema.' WHERE product_'.$schema.'_id = '.$idElement.' LIMIT 1';
		//	return$ask;
			$rowReturn = $db->query($ask)->fetch();
			return $rowReturn['product_'.$schema.'_name']; // .'('.$ask.')';
		}
		
		if( $idE == 3 ){
			// plyta plecy
			$idElement = $row['product_body2_id'];
			$schema = 'body';	
			$ask = 'SELECT * FROM product_'.$schema.' WHERE product_'.$schema.'_id = '.$idElement.' AND product_'.$schema.'_type'.$schema.' = 1 LIMIT 1';
		//	return$ask;
			$rowReturn = $db->query($ask)->fetch();
			return $rowReturn['product_'.$schema.'_name']; // .'('.$ask.')';
		}
		
		if( $idE == 4 ){
			// plyta inna
		}
		
    	return 'INNA';
	} 
	
	
	
	function parametrOption($i) 
	{	
		$i = (int)$i;
		if( $i == 0 ) return'';
		else return$i;
	}
	
	
	function parametr($row,$E) 
	{	
		if( $row['product_wysszer'.$E] == 1 ) return $row['order_product_wysszer'.$E];
		else return'';
	}
	
	
	function parametrShelf($row) 
	{	
		if( $row['product_shelf'] == 1 ) return $row['order_product_shelfamount'];
		else return'';
	}
	
	
	function parametrOptions($row,$field) 
	{	
		if( $row['product_'.$field] == 1 ){
			if( $field == 'options' ) return Lib_Lang::consta(Lib_Lang::consta(admin_product_options_wd.$row['product_'.$field.'_id']).$dataAllOrder['order_id_transport']);
			if( $field == 'options2' ) return Lib_Lang::consta(Lib_Lang::consta(admin_product_options_rp.$row['product_'.$field.'_id']).$dataAllOrder['order_id_transport']);
		}else return'';
	}
	
	
	function parametrType($row) 
	{	
		$db = Zend_Registry::get('db');
		if( $row['product_type2_id'] != 0 ){
			$idElement = $row['product_type2_id'];
			$ask = 'SELECT * FROM product_type2 WHERE product_type2_id = '.$idElement.' LIMIT 1';
			$rowReturn = $db->query($ask)->fetch();	
			return$rowReturn['product_type2_code'];
		}
		if( $row['product_type_id'] != 0 ){
			$idElement = $row['product_type_id'];
			$ask = 'SELECT * FROM product_type WHERE product_type_id = '.$idElement.' LIMIT 1';
			$rowReturn = $db->query($ask)->fetch();	
			return$rowReturn['product_type_code'];		
		}
		return'';
	}
	
	
	function parametrElement($table,$field,$idElement,$returnElement) 
	{	
		$db = Zend_Registry::get('db');
		
		$ask = 'SELECT * FROM '.$table.' WHERE '.$field.' = '.$idElement.' LIMIT 1';
		$rowReturn = $db->query($ask)->fetch();	
		return$rowReturn[$returnElement];	
	
	}
	
	
	
	
	
	
}

