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


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

	$(document).ready(function () {

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

		$('#formAdd').validate({
			errorClass: "formError",
			errorElement: "div",
			rules: {
				product_name: {
					required: true
				},
				product_price: {
					required: true
				}
			},
			messages: {
				product_name: {
					required: "<?php echo @Lib_Lang::translate(admin_required); ?>"
				},
				product_price: {
					required: "<?php echo @Lib_Lang::translate(admin_required); ?>"
				}
			}
		});	

		<?php if( isset( $this->removeSuccess ) ){ ?>
			alertify.success("<i class='fa fa-check'></i> <?php echo @Lib_Lang::translate(admin_element_remove_success); ?>");
		<?php } ?>
		
		$(".remove").click(function(){
		
			var link = $(this).attr('link');
			var name = $(this).attr('name');
			alertify.set({ buttonFocus: "none", labels: {ok: "<?php echo @Lib_Lang::translate(admin_confirm_accept); ?>", cancel: "<?php echo @Lib_Lang::translate(admin_confirm_cancel); ?>"}});
			alertify.confirm("<?php echo @Lib_Lang::translate(admin_confirm_remove_element); ?> "+name+"?", function (e) {
				if (e) {
					window.location.href = link;
				} else {
					return false;
				}
			});
		
		});

		
	});

</script>

<div class="container">		

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

	
	<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'); ?>

	

	
	<div class="row">
		<div class="col-xs-3 col-sm-3 col-md-3">
			<h3><?php echo @Lib_Lang::translate(admin_productedittype_top_edit); ?></h3>
		</div>
		<div class="col-xs-9 col-sm-9 col-md-9 text-right">
			<a href="<?php echo @$this->url(array('controller' => 'admin', 'action' => 'productedittype', 'id' => $this->ProductInfo['product_id']), 'default', true); ?>" class="btn btn-default btn-sm"><i class='fa fa-edit'></i> <?php echo @Lib_Lang::translate(admin_producteditelement_menu_list); ?></a>
			<a href="<?php echo @$this->url(array('controller' => 'admin', 'action' => 'productedittypeadd', 'id' => $this->ProductInfo['product_id']), 'default', true); ?>" class="btn btn-default btn-sm"><i class='fa fa-plus'></i> <?php echo @Lib_Lang::translate(admin_producteditelement_menu_add); ?></a>
		</div>
	</div>	
	
	
	
	
	
	
	

		
	<form id="formAdd" method="post" class="form-horizontal">
	
	<div class="row">
		<div class="col-xs-12 col-sm-4 col-md-4 text-right formLabelMarginTop"><?php echo @Lib_Lang::translate(admin_productelement_name); ?></div>
		<div class="col-xs-12 col-sm-8 col-md-8"><input maxlength="100" name="product_name" class="form-control" value="<?php echo$this->rowElement['product_type_name']; ?>" /></div>
	</div>

	
	<div class="row">
		<div class="col-xs-12 col-sm-4 col-md-4 text-right formLabelMarginTop"><?php echo @Lib_Lang::translate(admin_productelement_code); ?></div>
		<div class="col-xs-12 col-sm-8 col-md-8"><input maxlength="100" name="product_code" class="form-control" value="<?php echo$this->rowElement['product_type_code']; ?>" /></div>
	</div>


	
	
	<div class="row">
		<div class="col-xs-12 col-sm-4 col-md-4 text-right formLabelMarginTop"><?php echo @Lib_Lang::translate(admin_productelement_image); ?></div>
		<div class="col-xs-12 col-sm-8 col-md-8"><input type="file" name="image_product" class="form-control fileInput" />
		
		<div id="message" style="padding-top:8px;padding-bottom:8px;display:none;"></div>
		<div class="row" id="finishPhoto"></div>
		</div>
	</div>
	
	

				
<script type="text/javascript" language="javascript">
	
$(document).ready(function () {

	<?php if( $this->rowElement['product_type_image'] ){ ?>
	$("#message").html('<?php echo @Lib_Lang::translate(admin_category_image_upload); ?>');
	$("#message").css({'display':'block'});
	$("#finishPhoto").load("<?php echo $this->url(array('controller' => 'admin', 'action' => 'productedittypephoto'), 'default', true); ?>",{filename: '<?php echo$this->rowElement['product_type_image']; ?>'}, function(){$("#message").css({'display':'none'});$("#message").html('');});
	<?php } ?>

	$("[name='image_product']").change(function() {
		var file = this.files[0];
		var imagefile = file.type;
		var imagename = file.name;
		var imagesize = file.size;
		
		if(imagesize > 1024*1024){
			alertify.error("<i class='fa fa-close'></i> <?php echo @Lib_Lang::translate(admin_product_image_maxsize); ?>");
		}else if( imagefile != 'image/jpeg' && imagefile != 'image/jpg' && imagefile != 'image/gif' && imagefile != 'image/png' ){
			alertify.error("<i class='fa fa-close'></i> <?php echo @Lib_Lang::translate(admin_product_image_errorfile); ?>");
		}else{
			$("#finishPhoto").html('');
			$("#message").html('<?php echo @Lib_Lang::translate(admin_product_image_upload); ?>');
			$("#message").css({'display':'block'});
			$("input").attr('disabled','disabled');
			var reader = new FileReader();
			reader.onload = function(){
			  var dataURL = reader.result;
			  
				$.ajax({
					url: "<?php echo $this->url(array('controller' => 'admin', 'action' => 'productedittypeaddphoto'), 'default', true); ?>", 
					type: "POST",  
					data: {'image_product':dataURL.replace(/^data:image\/(gif|png|jpg|jpeg);base64,/, "")},     
					success: function(data)  
					{
						var control = $("[name='image_product']");
						control.replaceWith( control = control.clone( true ) );
						$("input").removeAttr('disabled');
						$("#message").css({'display':'none'});
						$("#message").html('');
						$("#finishPhoto").html(data);
					}
				});
				
			};
			reader.readAsDataURL(this.files[0]);
		}
		
		
	});
	
	
	
});

</script>

	
	<div class="row">
		<div class="col-xs-12 col-sm-4 col-md-4 text-right formLabelMarginTop"><?php echo @Lib_Lang::translate(admin_productelement_price); ?></div>
		<div class="col-xs-12 col-sm-8 col-md-8"><input type="number" step="0.01" name="product_price" class="form-control" value="<?php echo$this->rowElement['product_type_price']; ?>" /></div>
	</div>
	
	
	
	



	
	<div class="row">
		<div class="col-xs-3 col-sm-3 col-md-3">
			<h3><?php echo @Lib_Lang::translate(admin_category_edit_top_translate); ?></h3>
		</div>
		<div class="col-xs-9 col-sm-9 col-md-9 text-right">
		</div>
	</div>	
	
	
	<?php foreach ($this->dataLang as $key => $val):?>
	<div class="row">
	
		<div class="col-xs-12 col-sm-4 col-md-4 text-right formLabelMarginTop"><u><b><?php echo $val['lang_name']; ?></b></u></div>
		<div class="col-xs-12 col-sm-8 col-md-8"></div>
		
	</div>
	<div class="row">
	
		<div class="col-xs-12 col-sm-4 col-md-4 text-right formLabelMarginTop"><?php echo @Lib_Lang::translate(admin_element_name); ?></div>
		<div class="col-xs-12 col-sm-8 col-md-8"><input maxlength="100" name="product_name_translate[<?php echo $val['lang_suffix']; ?>]" class="form-control" value="<?php echo $val['language_value']; ?>" /></div>
		
	</div>
	<div class="row">
	
		<div class="col-xs-12 col-sm-4 col-md-4 text-right formLabelMarginTop"><?php echo @Lib_Lang::translate(admin_element_description); ?></div>
		<div class="col-xs-12 col-sm-8 col-md-8"><textarea maxlength="500" name="product_description_translate[<?php echo $val['lang_suffix']; ?>]" class="form-control"><?php echo $val['language_value_2']; ?></textarea></div>
		
	</div>
	<div class="row"><hr /></div>
	<?php endforeach; ?>
	
	
	
	
	
	<div class="row">
		<div class="col-xs-12 col-sm-4 col-md-4 text-right"></div>
		<div class="col-xs-12 col-sm-8 col-md-8"><input name="admin_add" class="btn btn-info form-control" type="submit" value="<?php echo @Lib_Lang::translate(admin_product_addelement_button); ?>" /></div>
	</div>
	
	</form>	
		
	
		
	<div class="row"><br /><hr style="height:6px;background:red;" /></div>
	
	
	
	

	
	
	
	
	
	
	
	
	

	
	<div class="row">
		<div class="col-xs-3 col-sm-3 col-md-3">
			<h3><?php echo @Lib_Lang::translate(admin_productedittype2_top_edit); ?></h3>
		</div>
		<div class="col-xs-9 col-sm-9 col-md-9 text-right">
			
			<a href="<?php echo @$this->url(array('controller' => 'admin', 'action' => 'productedittype2add', 'id' => $this->ProductInfo['product_id'], 'idp' => $this->rowElement['product_type_id']), 'default', true); ?>" class="btn btn-default btn-sm"><i class='fa fa-plus'></i> <?php echo @Lib_Lang::translate(admin_producteditelement_menu_add); ?></a>
			
		</div>
	</div>
	
	
	
	
	<div class="row">
	<?php if( count($this->dataTableProductType2) > 0 ){ ?>
	<?php foreach ($this->dataTableProductType2 as $key => $val): ?>
		<div class="col-xs-3 col-sm-3 col-md-3 text-center">
			<div style="margin:5px;padding:5px;border:1px solid #aaa;">
			<?php if( $val['product_type2_image'] ){ ?>
				<img src="<?php echo $this->escape($this->baseUrl); ?>/public/uploads/type/<?php echo$val['product_type2_image']; ?>_h100.jpeg" style="border:1px solid #ccc;" />
			<?php }else{ ?>
			
			<?php } ?>
			<br />
			<?php echo$val['product_type2_name'];?>
			<br />
				<div class="btn-group">
					<a href="<?php echo @$this->url(array('controller' => 'admin', 'action' => 'productedittype2edit', 'id' => $this->ProductInfo['product_id'], 'idp' => $val['product_type_id'], 'idp2' => $val['product_type2_id']), 'default', true); ?>" class="btn btn-primary btn-xs"><i class='fa fa-edit'></i> <?php echo @Lib_Lang::translate(admin_category_list_editbutton); ?></a>
					<a name="<?php echo $this->escape($val['product_type2_name']) ?>" link="<?php echo @$this->url(array('controller' => 'admin', 'action' => 'productedittype2remove', 'id' => $this->ProductInfo['product_id'], 'idp' => $val['product_type_id'], 'idp2' => $val['product_type2_id']), 'default', true); ?>" class="btn btn-danger btn-xs remove"><i class='fa fa-remove'></i> <?php echo @Lib_Lang::translate(admin_category_list_delbutton); ?></a>
				</div>
					<br />
					<?php if( $val['product_type2_default'] == 1 ){ ?><br />
						<?php echo @Lib_Lang::translate(admin_element_default); ?>
					<?php }else{ ?>
						<a href="<?php echo @$this->url(array('controller' => 'admin', 'action' => 'productedittype2default', 'id' => $this->ProductInfo['product_id'], 'idp' => $val['product_type_id'], 'idp2' => $val['product_type2_id']), 'default', true); ?>" class="btn btn-info btn-xs"><i class='fa fa-edit'></i> <?php echo @Lib_Lang::translate(admin_element_defaultset); ?></a>
					<?php } ?>
			</div>
		</div> 
	<?php endforeach; ?>
	<?php }else{ ?>
	<center><?php echo @Lib_Lang::translate(admin_element_list_0); ?></center>
	<?php } ?>
</div>	
	
	
	
	
	
	
	
	
	
	
	
	
	
	

	
		
	<div class="row"><hr /></div>
	
</div>

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