<?php $this->include('rs/utils.php')?>
<?= $this->extend('rs/template-admin'); ?>
<?= $this->section('content'); ?>
  
<link rel="stylesheet" href="intlTelInput/css/intlTelInput.css">
	<style>
		.categ{border:1px solid #CCC;border-radius:5px;display:block;padding:10px 20px;margin:10px}
		form{width:100%}
		.form-control{max-width:350px!important}
	</style>
	<script type="text/javascript">document.getElementById("company").classList.add("active");</script>
	<div class="card shadow">
		<a href="#collapsePrimary" class="d-block card-header py-3" data-toggle="collapse" role="button" aria-expanded="true" aria-controls="collapseReception">
			<h6 class="m-0 font-weight-bold text-primary">Company info</h6>
		</a>
		<div class="collapse show" id="collapsePrimary">
			<div class="card-body">
				
				 <form class="" id="frmdata" action="" method="post" >
					  <div class="col-12 col-sm-12">
					   <div class="form-group">
						<label for="realname">Company name</label>
						<input  type="text" class="form-control" name="company_name" id="companyname" value="<?=$company['company_name'] ?>">
					   </div>
					 </div>
					 
					  <div class="col-12 col-sm-12">
					   <div class="form-group">
						<label for="realname">VAT number</label>
						<input  type="text" class="form-control" name="vat_code" id="vatnumber" value="<?=$company['vat_code'] ?>">
					   </div>
					 </div>
					 
					  
					 
					 <div class="col-12 col-sm-12">
					   <div class="form-group">
						<label for="realname">Address 1</label>
						<input type="text" class="form-control" name="address1" id="address1" value="<?=$company['address1'] ?>">
					   </div>
					 </div>
					 
					 
					 <div class="col-12 col-sm-12">
					   <div class="form-group">
						<label for="realname">Address 2</label>
						<input type="text" class="form-control" name="address2" id="address2" value="<?=$company['address2']?>">
					   </div>
					 </div>
					 
					 
					 <div class="col-12 col-sm-6">
						 <div class="form-group">
						   <label for="phone">Phone number </label>
						   <div class="input-group">
								<input type="tel"  class="form-control" name="phone" id="phone" value="<?=$company['phone'] ?>"  required>										
							</div>
					   </div>	
					 </div>
					 
					 <div class="col-12">
					   <div class="form-group">
						<label for="email">Company email address</label>
						<input type="text" class="form-control"  name="email" value="<?=$company['email'] ?>">
					   </div>
					 </div>
					 
					 
					 <div class="col-12">
					   <div class="form-group">
						<label for="website">Company wesite</label>
						<input type="text" class="form-control"  name="website" value="<?=$company['website'] ?>">
					   </div>
					 </div>
					
				   <?php if (isset($validation)): ?>
					 <div class="col-12">
					   <div class="alert alert-danger" role="alert">
						 <?= $validation->listErrors() ?>
					   </div>
					 </div>
				   <?php endif; ?>
				   
				   
				   
				   <div class="row">
						<div class="col-12 col-sm-4">
						<button type="button" onclick="doSubmit()" class="btn btn-primary">Update</button>
						</div>
					</div>
				</form>
			</div>	   
		</div>
		<hr><hr><hr>
	</div>
			
<script src="/intlTelInput/js/intlTelInput.js"></script>
<script>

  var input = document.querySelector("#phone");
 
  var i=window.intlTelInput(input, {
    utilsScript:"/intlTelInput/js/utils.js"
  });
  
  function doSubmit(){
	  phoneInput=$("#phone");
	  phoneInput.val(i.getNumber());
	  document.getElementById('frmdata').submit();
	 
	}
  
 
  
  function generatePassword() { 
        const passwordLength = 18
        const useSymbols = true
        const useNumbers = true
        const useLowerCase = true
        const useUpperCase = true
        
        let charset = ''; 
        let newPassword = ''; 
  
        if (useSymbols) charset += "!@#$%^&*()"; 
        if (useNumbers) charset += "0123456789"; 
        if (useLowerCase) charset += "abcdefghijklmnopqrstuvwxyz"; 
        if (useUpperCase) charset += "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; 
  
        for (let i = 0; i < passwordLength; i++) { 
            newPassword += charset.charAt( 
                Math.floor(Math.random() * charset.length)); 
        } 
  
        password = newPassword;
		
		$('#password').val(password)
		$('#password').prop('type', 'text');
		//alert(password);
    } 
  
</script>
			
		
<?= $this->endsection(); ?>