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


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

	$(document).ready(function () {
		
	});

</script>

<div class="container">		

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


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

	$(document).ready(function () {
	
		$('#genPassButton').click(function(){			
			$('[name="admin_pass"]').focus();
			$('[name="admin_pass"]').val(randString(8));			
		});

		function acceptlogin() {
			var response = 0;
			$.ajax({  
				type: "POST",  
				url: "<?php echo $this->url(array('controller' => 'admin', 'action' => 'checklogin'), 'default', true); ?>", 				
				async: false,
				data: { admin_login: $('[name="admin_login"]').val() },
				success: function(data){   
					response = data;
				}
			});
			if(response == 0)
			{
				return true;
			}
			else
			{
				alertify.error("<i class='fa fa-close'></i> <?php echo @Lib_Lang::translate(admin_users_login_exist); ?>");
				$('[name="admin_login"]').focus();
				return false;
			}
		};
		
		$('#formAddUser').submit(acceptlogin);
	
	
	

		$('#formAddUser').validate({
			errorClass: "formError",
			errorElement: "div",
			rules: {
				admin_login: {
					required: true,
					accept: "^[a-zA-Z0-9]+$"
				},
				admin_pass: {
					required: true
				},
				admin_firstname: {
					required: true
				},
				admin_secondname: {
					required: true
				},
				admin_email: {
					required: true,
					email: true
				}
			},
			messages: {
				admin_login: {
					required: "<?php echo @Lib_Lang::translate(admin_users_login_required); ?>",
					accept: "<?php echo @Lib_Lang::translate(admin_users_login_accept); ?>"
				},
				admin_pass: {
					required: "<?php echo @Lib_Lang::translate(admin_users_pass_required); ?>"
				},
				admin_firstname: {
					required: "<?php echo @Lib_Lang::translate(admin_users_firstname_required); ?>"
				},
				admin_secondname: {
					required: "<?php echo @Lib_Lang::translate(admin_users_secondname_required); ?>"
				},
				admin_email: {
					required: "<?php echo @Lib_Lang::translate(admin_users_email_required); ?>",
					email: "<?php echo @Lib_Lang::translate(admin_users_email_email); ?>"
				}
			}
		});	
	
	
	});

</script>

	
	<div class="row">
		<div class="col-xs-3 col-sm-3 col-md-3">
			<h3><?php echo @Lib_Lang::translate(admin_users_add_top); ?></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' => 'users'), 'default', true); ?>" class="btn btn-default btn-sm"><i class='fa fa-users'></i> <?php echo @Lib_Lang::translate(admin_users_menu_list); ?></a>
		</div>
	</div>


		
	<form id="formAddUser" 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_users_login); ?></div>
		<div class="col-xs-12 col-sm-8 col-md-8"><input maxlength="50" name="admin_login" class="form-control" /></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_users_password); ?></div>
		<div class="col-xs-12 col-sm-8 col-md-8"><input maxlength="50" name="admin_pass" class="form-control" /></div>
	</div>
	
	<div class="row text-right"><div class="col-xs-12 col-sm-12 col-md-12"><a href="javascript:void(0);" id="genPassButton" class="btn btn-primary btn-xs"><i class='fa fa-random'></i> <?php echo @Lib_Lang::translate(admin_users_genpass); ?></a></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_users_firstname); ?></div>
		<div class="col-xs-12 col-sm-8 col-md-8"><input maxlength="100" name="admin_firstname" class="form-control" /></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_users_secondname); ?></div>
		<div class="col-xs-12 col-sm-8 col-md-8"><input maxlength="100" name="admin_secondname" class="form-control" /></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_users_email); ?></div>
		<div class="col-xs-12 col-sm-8 col-md-8"><input maxlength="100" name="admin_email" class="form-control" /></div>
	</div>
	
	<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_adduser" class="btn btn-info form-control" type="submit" value="<?php echo @Lib_Lang::translate(admin_users_add_button); ?>" /></div>
	</div>
	
	</form>	
		
</div>

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