<?php $this->include('rs/utils.php')?>
 <?= $this->extend('rs/template-popup', $data); ?>
 <?= $this->section('content'); ?>
 <style>
 
 select{width:250px!important;}
 .form-inline{padding:5px}
 .form-inline label { min-width:150px;text-align:left!important;justify-content: flex-start!important}
 .control{width:350px!important;}
 .control-sm{width:100px!important;}
 
 </style>
 <div class="card shadow mb-4">
    <div class="card-body">
           <div class="container">
             <?php if (session()->get('success')): ?>
               <div class="alert alert-success" role="alert">
                 <?= session()->get('success') ?>
               </div>
             <?php endif; ?>
             <form action="" method="post">
                  <div class="col-12 col-sm-12 my-2">
					   <div class="form-group form-inline">
						<label for="companyname">Company name</label>
						<input readonly type="text" class="form-control" name="companyname" id="companyname" value="<?= set_value('companyname', $user['companyname']) ?>">
					   </div>
					 </div>
					 
					  <div class="col-12 col-sm-12 my-2">
					   <div class="form-group form-inline">
						<label for="vatnumber">VAT number</label>
						<input readonly type="text" class="form-control" name="vatnumber" id="vatnumber" value="<?= set_value('vatnumber', $user['vatnumber']) ?>">
					   </div>
					 </div>
					 
					   <div class="col-12 col-sm-12 my-2">
					   <div class="form-group form-inline">
						<label for="country">Country</label>
						 <select class="form-control-sm select2" name ="country" id="country"   value="<?= set_value('country', $user['country']) ?>"  readonly required>
								   <option />
								   <option <?php echo ($user['country']=='Bulgaria'?'selected': 'disabled') ?>>Bulgaria</option>
								   <option <?php echo($user['country']=='Romania'?'selected':  'disabled') ?>>Romania</option>
							</select>
					   
					   </div>
					 </div>
				 
				 <div class="col-12 col-sm-12 my-2">
					<div class="form-group form-inline">
                    <label for="realname">District</label>
                    <input type="text" class="form-control" name="district" id="district" value="<?= set_value('district', $user['district']) ?>">
                   </div>
                 </div>
				 
				 <div class="col-12 col-sm-12 my-2">
					   <div class="form-group form-inline">
						<label for="city">City</label>
						<input type="text" class="form-control" name="city" id="city" value="<?= set_value('city', $user['city']) ?>">
					   </div>
					 </div>
					 
					   <div class="col-12 col-sm-12 my-2">
					   <div class="form-group form-inline">
						<label for="address">Address</label>
						<input type="text" class="form-control" name="address" id="address" value="<?= set_value('address', $user['address']) ?>">
					   </div>
					 </div>
					 <div class="col-12 col-sm-12 my-2">
					   <div class="form-group form-inline">
						<label for="email">Email</label>
						<input type="text" class="form-control" id="email" name="email" value="<?= $user['email'] ?>">
					   </div>
					 </div>
					  <div class="col-12 col-sm-12 my-2">
					  <div class="form-group form-inline">
						   <label for="website">Website</label>
						   <input type="text" class="form-control" name="website" id="website" value="<?= set_value('website',$user['website']) ?>">
						  </div>
					</div>
					 <br>
					 <h5>Contact person info</h5>
					 <br>
					 
					 <div class="col-12 col-sm-12 my-2">
					   <div class="form-group form-inline">
						<label for="firstname">First name</label>
						<input type="text" class="form-control" name="firstname" id="firstname" value="<?= set_value('firstname', $user['firstname']) ?>">
					   </div>
					 </div>
					 <div class="col-12 col-sm-12 my-2">
					   <div class="form-group form-inline">
						<label for="lastname">Family name</label>
						<input type="text" class="form-control" name="lastname" id="lastname" value="<?= set_value('lastname', $user['lastname']) ?>">
					   </div>
					 </div>
					 
					 <div class="col-12 col-sm-12 my-2">
						 <div class="form-group form-inline">
						   <label for="phone">Phone number </label>
						   <div class="input-group">
								<input type="text" class="form-control" name="phone" id="phone" value="<?= set_value('phone',$user['phone']) ?>"  required>										
							</div>
					   </div>	
					 </div>
					 
					 <div class="col-12 col-sm-12 my-2">
					   <div class="form-group form-inline">
						<label for="email">Email</label>
						<input type="text" class="form-control"  name="contactemail" id="contactemail" value="<?= $user['contactemail'] ?>">
					   </div>
					 </div>
					 
				 
                  <div class="col-12 col-sm-12 my-2">
					<div class="form-group form-inline">
                    <label for="password">Password</label>
                    <input type="password" class="form-control" name="password" id="password" value="">
                  </div>
                </div>
                <div class="col-12 col-sm-12 my-2">
				   <div class="form-group form-inline">
                   <label for="password_confirm">Confirm Password</label>
                   <input type="password" class="form-control" name="password_confirm" id="password_confirm" value="">
                 </div>
               </div>
			   
			  <?php 
				if($user['access']!="2" && $user['access']!="5" && $user['access']!="6")
					echo "<div style='display:none'>";
			  ?>
				<br><br>
				<hr>				 
				 <div><b>Sale comissions</b></div>
				  <hr>
					<div class="col-12 font-weight-bold mb-1 form-check-inline">
						
						<div class="form-check">
						  <input class="form-check-input" type="radio" name="coms" id="coms1" value="1" <?=($user['commission_type']==1?'checked' :'')?>>
						  <label class="form-check-label" for="coms1">
							Fixed ammount
						  </label>
						</div>
						<div class="form-check">
						  <input class="form-check-input" type="radio" name="coms" id="coms2" value="2" <?=($user['commission_type']==2?'checked' :'')?>>
						  <label class="form-check-label" for="coms2">
							Percent %
						  </label>
						</div>
						<div class="form-check">
						  <input class="form-check-input" type="radio" name="coms" id="coms0" value="0" <?=($user['commission_type']==0?'checked' :'')?>>
						  <label class="form-check-label" for="coms0">
							No comission
						  </label>
						</div>
					</div>
				   <br><br>
				   
				   <div class="col-12 cmsAbs">
					   <div class="form-group form-inline">
							<label for="commission_abs" class="mx-1">Fixed ammount EUR </label>
							<input type="text" class="form-control"  name="commission_abs" id="commission_abs" value="<?= set_value('commission_abs', $user['commission_abs']) ?>" required>
					  </div> 
					  </div>

					<div class="col-12 cmsPerc">
					   <div class="form-group form-inline">
							<label for="commission_percent" class="mx-1">Percent </label>
							<input type="text" class="form-control"   name="commission_percent" id="commission_percent" value="<?= set_value('commission_percent', round(100*$user['commission_percent'],2)) ?>" required>
						</div>
					 </div>	  
					 
					 <div class="col-12 cmsPerc">
					   <div class="form-group form-inline">
							<label for="commission_min" class="mx-1">But no less than EUR </label>
							<input type="text" class="form-control"  name="commission_min" id="commission_min" value="<?= set_value('commission_min', $user['commission_min']) ?>" required>
					   </div>
					 </div>	
					 <br><br>
					 <div class="col-12">
					   <div class="form-check ml-2">
							<input type="checkbox"  class="form-check-input" class="form-control"  name="hide_zadio" id="hide_zadio" <?=($user['hide_zadio']==1?'checked' :'')?>>
							<label for="hide_zadio"><b>Hide Zadio's price for me</b></label>
							
					  </div>
					 </div>	
					 
					 
				<?php 
				if($user['access']!="2" && $user['access']!="5" && $user['access']!="6")
					echo "</div>";
			  ?>
				 
              <br><br>
			  <div><b>Access</b></div>
			  <hr>
			   
			   <div class="col-12 col-sm-12 form-inline">
			   <label class="form-check-label">Access level</label>
			   <div class="form-group">
					<select class="control-sm select2" id="access" name ="access"  style="width:350px!important">
					<option value="0" <?= $user['access']=="0"?"selected":""?>> Blocked (No access)</option>
					<option value="1" <?= $user['access']=="1"?"selected":""?>> Read-only Seller</option>
					<option value="2" <?= $user['access']=="2"?"selected":""?>> Read-only Buyer</option>
					<option value="3" <?= $user['access']=="3"?"selected":""?>> Read-only Seller & Buyer</option>
					<option value="4" <?= $user['access']=="4"?"selected":""?>> Read-Write Seller</option>
					<option value="5" <?= $user['access']=="5"?"selected":""?>> Read-Write Buyer</option>
					<option value="6" <?= $user['access']=="6"?"selected":""?>> Read-Write Seller & Buyer</option>
					</select>
				</div>
			  </div>
			   
			  				
			   <br><br>
				
               <?php if (isset($validation)): ?>
                 <div class="col-12">
                   <div class="alert alert-danger" role="alert">
                     <?= $validation->listErrors() ?>
                   </div>
                 </div>
               <?php endif; ?>
               </div>
     
			   <div class="row">
				<div class="col-12 col-sm-4 d-flex align-items-center">
					<button type="submit" class="btn btn-primary mr-4">Update</button>
					<a href="<?php echo site_url('/messages/newThread/'.$user['id']);?>" 
					title="Message" 
					class="btn btn-outline-success d-flex align-items-center">
					<i class="fas fa-envelope me-1"></i>
					<span>Message</span>
					</a>
				</div>
			</div>
             </form>
           
           
           
       </div>
	 </div>
<?= $this->endsection(); ?>