<?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); ?>"
				}
			}
		});	

		
	});

</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_producteditbody_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' => 'producteditbody', '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' => 'producteditbodyadd', '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_body_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_body_code']; ?>" /></div>
	</div>

	
	
	
	
	
	
	

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

	$(document).ready(function () {
	
		<?php if( $this->rowElement['product_body_typebody'] == 1 ){ ?>
			$('#typebody').hide();
		<?php }else{ ?>
			$('#typebody').show();		
		<?php } ?>
	
		$('[name="product_typebody"]').change(function(){
			if( $(this).val() == 1 ) $('#typebody').hide();
			else $('#typebody').show();		
		});
	
	});

</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_typebody); ?></div>
		<div class="col-xs-12 col-sm-8 col-md-8">
			
			<select name="product_typebody" class="form-control">
				<option value="0" <?php if( $this->rowElement['product_body_typebody'] == 0 )echo'selected'; ?>><?php echo @Lib_Lang::translate(option_body_typebody_0); ?></option>
				<option value="1" <?php if( $this->rowElement['product_body_typebody'] == 1 )echo'selected'; ?>><?php echo @Lib_Lang::translate(option_body_typebody_1); ?></option>
			</select>
		
		</div>
	</div>

	
	
	
	<div id="typebody">
	
	
	

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

	$(document).ready(function () {
	
		<?php if( $this->rowElement['product_body_type'] == 0 ){ ?>
			$('.r2').hide();
			$('.r1').show();
		<?php }else{ ?>
			$('.r1').hide();
			$('.r2').show();
		<?php } ?>
	
		$('[name="product_type"]').change(function(){
			if( $(this).val() == 0 ){
				$('.r2').hide();
				$('.r1').show();
			}
			else{
				$('.r1').hide();
				$('.r2').show();
			}
		});
	
	});

</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_type); ?></div>
			<div class="col-xs-12 col-sm-8 col-md-8">
				
				<select name="product_type" class="form-control">
					<option value="0" <?php if( $this->rowElement['product_body_type'] == 0 )echo'selected'; ?>><?php echo @Lib_Lang::translate(option_body_type_0); ?></option>
					<option value="1" <?php if( $this->rowElement['product_body_type'] == 1 )echo'selected'; ?>><?php echo @Lib_Lang::translate(option_body_type_1); ?></option>
				</select>
			
			</div>
		</div>
	
	
	
	
		<div class="row r1 r2">
			<div class="col-xs-12 col-sm-4 col-md-4 text-right formLabelMarginTop"><?php echo @Lib_Lang::translate(admin_productelement_option1); ?></div>
			<div class="col-xs-12 col-sm-8 col-md-8">
				
				<select name="product_option1" class="form-control">
					<option value="0" <?php if( $this->rowElement['product_body_option1'] == 0 )echo'selected'; ?>><?php echo @Lib_Lang::translate(option_body_option_0); ?></option>
					<option value="1" <?php if( $this->rowElement['product_body_option1'] == 1 )echo'selected'; ?>><?php echo @Lib_Lang::translate(option_body_option_1); ?></option>
				</select>
			
			</div>
		</div>
	
	
	
	
		<div class="row r1 r2">
			<div class="col-xs-12 col-sm-4 col-md-4 text-right formLabelMarginTop"><?php echo @Lib_Lang::translate(admin_productelement_option2); ?></div>
			<div class="col-xs-12 col-sm-8 col-md-8">
				
				<select name="product_option2" class="form-control">
					<option value="0" <?php if( $this->rowElement['product_body_option2'] == 0 )echo'selected'; ?>><?php echo @Lib_Lang::translate(option_body_option_0); ?></option>
					<option value="1" <?php if( $this->rowElement['product_body_option2'] == 1 )echo'selected'; ?>><?php echo @Lib_Lang::translate(option_body_option_1); ?></option>
				</select>
			
			</div>
		</div>
	
	
	
	
		<div class="row r1">
			<div class="col-xs-12 col-sm-4 col-md-4 text-right formLabelMarginTop"><?php echo @Lib_Lang::translate(admin_productelement_option3); ?></div>
			<div class="col-xs-12 col-sm-8 col-md-8">
				
				<select name="product_option3" class="form-control">
					<option value="0" <?php if( $this->rowElement['product_body_option3'] == 0 )echo'selected'; ?>><?php echo @Lib_Lang::translate(option_body_option_0); ?></option>
					<option value="1" <?php if( $this->rowElement['product_body_option3'] == 1 )echo'selected'; ?>><?php echo @Lib_Lang::translate(option_body_option_1); ?></option>
				</select>
			
			</div>
		</div>
	
	
	
	
		<div class="row r1">
			<div class="col-xs-12 col-sm-4 col-md-4 text-right formLabelMarginTop"><?php echo @Lib_Lang::translate(admin_productelement_option4); ?></div>
			<div class="col-xs-12 col-sm-8 col-md-8">
				
				<select name="product_option4" class="form-control">
					<option value="0" <?php if( $this->rowElement['product_body_option4'] == 0 )echo'selected'; ?>><?php echo @Lib_Lang::translate(option_body_option_0); ?></option>
					<option value="1" <?php if( $this->rowElement['product_body_option4'] == 1 )echo'selected'; ?>><?php echo @Lib_Lang::translate(option_body_option_1); ?></option>
				</select>
			
			</div>
		</div>
	
	
	
	
		<div class="row r2">
			<div class="col-xs-12 col-sm-4 col-md-4 text-right formLabelMarginTop"><?php echo @Lib_Lang::translate(admin_productelement_option5); ?></div>
			<div class="col-xs-12 col-sm-8 col-md-8">
				
				<select name="product_option5" class="form-control">
					<option value="0" <?php if( $this->rowElement['product_body_option5'] == 0 )echo'selected'; ?>><?php echo @Lib_Lang::translate(option_body_option_0); ?></option>
					<option value="1" <?php if( $this->rowElement['product_body_option5'] == 1 )echo'selected'; ?>><?php echo @Lib_Lang::translate(option_body_option_1); ?></option>
				</select>
			
			</div>
		</div>
	
	
	
	
		<div class="row r2">
			<div class="col-xs-12 col-sm-4 col-md-4 text-right formLabelMarginTop"><?php echo @Lib_Lang::translate(admin_productelement_option6); ?></div>
			<div class="col-xs-12 col-sm-8 col-md-8">
				
				<select name="product_option6" class="form-control">
					<option value="0" <?php if( $this->rowElement['product_body_option6'] == 0 )echo'selected'; ?>><?php echo @Lib_Lang::translate(option_body_option_0); ?></option>
					<option value="1" <?php if( $this->rowElement['product_body_option6'] == 1 )echo'selected'; ?>><?php echo @Lib_Lang::translate(option_body_option_1); ?></option>
				</select>
			
			</div>
		</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_body_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' => 'producteditbodyphoto'), 'default', true); ?>",{filename: '<?php echo$this->rowElement['product_body_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' => 'producteditbodyaddphoto'), '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_pricem2); ?></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_body_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"><hr /></div>
	
</div>

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