<?php echo $this->render('admin/header.phtml'); ?>

<style>
.formLabelMarginTopNW{
    white-space: nowrap;
}
</style>

<script type="text/javascript" language="javascript">

	$(document).ready(function () {

		<?php if( isset( $this->addProductElementSuccess ) ){ ?>
			alertify.success("<i class='fa fa-check'></i> <?php echo @Lib_Lang::translate(admin_product_element_add_success); ?>");
		<?php } ?>
		
	});

</script>

<div class="container">		

<?php echo $this->render('admin/menu.phtml'); ?>
<?php echo $this->render('admin/productmenu.phtml'); ?>


<script type="text/javascript" language="javascript">

	$(document).ready(function () {	
		
		var removeFunction = function(){	
			$( "#element"+$(this).attr('cmd') ).remove();
		};
	
		$('#addElement').click(function(){
			var theResponse = null;
			var pageLoad = $.ajax({
				url:"<?php echo @$this->url(array('controller' => 'admin', 'action' => 'producteditelementaddelement', 'id' => $this->ProductInfo['product_id']), 'default', true); ?>",
				type: 'POST',
				dataType:"html",
				async: false,
				success: function(data) {
					theResponse = data;
				}
			});
			$('#elementBox').before(theResponse);
			
			$('.removeElement').unbind('click').bind('click', removeFunction);
			
		});
	
		$('.removeElement').unbind('click').bind('click', removeFunction);
		
	});

</script>

	
	<div class="row">
		<div class="col-xs-3 col-sm-3 col-md-3">
			<h3><?php echo @Lib_Lang::translate(admin_product_edit_top); ?><br /><small><?php echo$this->ProductInfo['product_name']; ?></small></h3>
			
		</div>
		<div class="col-xs-9 col-sm-9 col-md-9 text-right">
		</div>
	</div>

	<?php echo $this->render('admin/producteditmenu.phtml'); ?>


	<?php
	/*
		$zadanie = "(5+5)/3"; 
	
		echo$zadanie.'<br />';
		eval('$wynik = '.$zadanie.';');
		echo$wynik;
	*/
	?>
	

	<div class="row">
		<div class="col-xs-8 col-sm-8 col-md-8">
		
		Zmienne: 
		<code>WYS</code>,
		<code>SZER</code>,
		<code>GLEB</code>,
		<code>PARA</code>,
		<code>PARB</code>,
		<code>PARC</code>,
		<code>PARD</code>,
		<code>PARE</code>,
		<code>WYSP</code>,
		<code>WYSL</code>,
		<code>OPP</code>,
		<code>OPL</code>
		<br />
		Działania: <b>(</b>, <b>)</b>, <b>+</b>, <b>-</b>, <b>* <i>(mnożenie)</i></b>, <b>/ <i>(dzielenie)</i></b>
		<br />
		Funkcje: <b>PIERWIASTEK(<i>liczba_lub_zmienna</i>)</b>
		<br />
		<i>Należy pamiętać o wielkości znaków oraz poprawności równania np. zamykanie nawiasów, unikanie dzielenia przez 0.</i>
		
		</div>
		<div class="col-xs-4 col-sm-4 col-md-4 text-right"><a href="javascript:void(0);" class="btn btn-success" id="addElement"><i class="fa fa-plus"></i> <?php echo @Lib_Lang::translate(admin_product_element_add); ?></a></div>
	</div>
		
</div>
	
	

<div class="row">	
	<form method="post">
	<div class="col-xs-12 col-sm-12 col-md-12 elementBox">




















<?php 
foreach ($this->dataTableProductElement as $keyM => $val): 
$elementName = $val['product_element_id'].'_'.time();
?>

<div id="element<?php echo$elementName; ?>">

<table class="tableElement">

	<tr>
	
		<td>Nazwa elementu</td>
		<td><input name="product_element_name[<?php echo$elementName; ?>]" maxlength="50" class="form-control form-control-small" value="<?php echo$val['product_element_name']; ?>" /></td>
		
		<td>Kod</td>
		<td><input name="product_element_code[<?php echo$elementName; ?>]" maxlength="20" class="form-control form-control-small form-control-small-code" value="<?php echo$val['product_element_code']; ?>" /></td>
		
		<td>Wys.</td>
		<td><input name="product_element_equation1[<?php echo$elementName; ?>]" maxlength="100" class="form-control form-control-small form-control-small-equation" value="<?php echo$val['product_element_equation1']; ?>" /></td>
		
		<td>PCV</td>
		<td><input name="product_element_pcv1[<?php echo$elementName; ?>]" type="number" step="1" min="0" max="5" class="form-control form-control-small form-control-small-pvc" value="<?php echo$val['product_element_pcv1']; ?>" /></td>
		
		<td>Szer</td>
		<td><input name="product_element_equation2[<?php echo$elementName; ?>]" maxlength="100" class="form-control form-control-small form-control-small-equation" value="<?php echo$val['product_element_equation2']; ?>" /></td>
		
		<td>PCV</td>
		<td><input name="product_element_pcv2[<?php echo$elementName; ?>]" type="number" step="1" min="0" max="5" class="form-control form-control-small form-control-small-pvc" value="<?php echo$val['product_element_pcv2']; ?>" /></td>
		
		<td>Płyta</td>
		<td>
		
			<?php
			
				$arrayElementPanel = array(
					1 => "Płyta Korpus",
					2 => "Płyta Front",
					3 => "Płyta Plecy",
					4 => "Płyta Inna"
				);
			
			?>
		
			<select name="product_element_panel[<?php echo$elementName; ?>]" class="form-control form-control-small">
				<?php foreach( $arrayElementPanel as $key => $valP ){ ?>
				<option value="<?php echo$key; ?>" <?php if( $key == $val['product_element_panel'] )echo' selected'; ?>><?php echo$valP; ?></option>
				<?php } ?>
			</select>
		</td>
		
		<td>Wart. licz.</td>
		<td><input name="product_element_quantity[<?php echo$elementName; ?>]" type="number" step="1" min="0" max="99" class="form-control form-control-small" value="<?php echo$val['product_element_quantity']; ?>" /></td>
		
		<td>Wart. szuflady</td>
		<td>
		
			<?php
			
				$arrayElementDrawer = array(
					1 => "TAK",
					0 => "NIE"
				);
			
			?>
			
			<select name="product_element_drawer[<?php echo$elementName; ?>]" class="form-control form-control-small">
				<?php foreach( $arrayElementDrawer as $key => $valP ){ ?>
				<option value="<?php echo$key; ?>" <?php if( $key == $val['product_element_drawer'] )echo' selected'; ?>><?php echo$valP; ?></option>
				<?php } ?>
			</select>
		</td>
		
		<td>Ile</td>
		<td><input name="product_element_drawerAmount[<?php echo$elementName; ?>]" type="number" step="1" min="0" max="99" class="form-control form-control-small" value="<?php echo$val['product_element_drawerAmount']; ?>" /></td>
		
		<td>Półka</td>
		<td>
		
			<?php
			
				$arrayElementDrawer = array(
					1 => "TAK",
					0 => "NIE"
				);
			
			?>
			
			<select name="product_element_shelf[<?php echo$elementName; ?>]" class="form-control form-control-small">
				<?php foreach( $arrayElementDrawer as $key => $valP ){ ?>
				<option value="<?php echo$key; ?>" <?php if( $key == $val['product_element_shelf'] )echo' selected'; ?>><?php echo$valP; ?></option>
				<?php } ?>
			</select>
		</td>
		
		<td>
			<a href="javascript:void(0);" class="btn btn-xs btn-danger removeElement" cmd="<?php echo$elementName; ?>"><i class='fa fa-remove'></i></a>
		</td>
	
	</tr>

</table>

</div>

<?php endforeach; ?>


















	
		<p id="elementBox"></p>
	</div>	
	<div class="col-xs-12 col-sm-12 col-md-12 text-center">
		<input type="submit" name="saveElement" id="saveElement" class="btn btn-primary" value="Zapisz elementy">
	</div>	
	</form>
</div>

<?php echo $this->render('admin/footer.phtml'); ?>