<?php $__env->startSection("content"); ?>
<div class="container">
  <div class="top-content">
    <div class="right-content">
      <div class="title">
        <h2><?php echo e($title); ?></h2>
      </div>
     <!-- <div class="tasks">
        <button class="btn btn-primary" onclick="window.location='<?php echo e(URL::asset('/')); ?>users'">All Users</button>
      </div> -->
    </div>
  </div>
  <div class="main-content">
    <div class="sidebar">
      <nav>
       
      </nav>
    </div>
    <div class="main">
      <div class="row">
        <div class="col-sm-8">
          <form role="form" class="form-horizontal" action="<?php echo e(URL::asset('/')); ?>users/update/<?php echo e($row->id); ?>" method="post">
            <input type="hidden" name="_token" value="<?php echo csrf_token(); ?>">
            <input type="hidden" value="<?php echo e(Auth::user()->company_id); ?>" name="company_id" />
            <input type="hidden" value="<?php echo e(Auth::user()->country); ?>" name="country" />
            <input type="hidden" value="<?php echo e(Auth::user()->state); ?>" name="state" />
            <div class="form-group">
              <label for="name" class="col-sm-2 control-label">Name</label>
              <div class="col-sm-10">
                <input type="text" value="<?php echo e($row->name); ?>" class="form-control" name="name">
              </div>
            </div>
            <div class="form-group">
              <label for="email" class="col-sm-2 control-label">Email</label>
              <div class="col-sm-10">
                <input type="text" value="<?php echo e($row->email); ?>" class="form-control" name="email" disabled>
              </div>
            </div>
            <div class="form-group">
              <label for="phone" class="col-sm-2 control-label">Phone</label>
              <div class="col-sm-10">
                <input type="text" value="<?php echo e($row->phone); ?>" class="form-control" name="phone">
              </div>
            </div>
            <div class="form-group">
              <label for="city" class="col-sm-2 control-label">City</label>
              <div class="col-sm-10">
                <input type="text" value="<?php echo e($row->city); ?>" class="form-control" name="city">
              </div>
            </div>
            <div class="form-group">
              <label for="address" class="col-sm-2 control-label">Address</label>
              <div class="col-sm-10">
                <input type="text" value="<?php echo e($row->address); ?>" class="form-control" name="address">
              </div>
            </div>
            <div class="form-group">
              <label for="post_code" class="col-sm-2 control-label">Post Code</label>
              <div class="col-sm-10">
                <input type="text" value="<?php echo e($row->post_code); ?>" class="form-control" name="post_code">
              </div>
            </div>
            <div class="form-group">
              <label for="role" class="col-sm-2 control-label">Role</label>
              <div class="col-sm-10">
                <select class="form-control" id="role" name="role" onChange="accessibilities($(this).val())">
                 <!--<option></option>-->
                  <?php if(count($roles)): ?>
                  <?php foreach($roles as $role): ?>
                  <option value="<?php echo e($role->id); ?>" <?php if($role->id==$row->role){echo 'selected';} ?>><?php echo e($role->role); ?></option>
                  <?php endforeach; ?>
                  <?php endif; ?>
                </select>
              </div>
            </div>
            <?php $display = ""; if($row->role==1){$display = 'style="display:none;"';} ?>
            <?php $checkbox = "checkbox"; if($row->role==3){$checkbox = 'radio';} ?>
            <div class="form-group" id="accessibilities" <?php echo $display; ?>>
              <label for="role" class="col-sm-2 control-label">Accessibilities</label>
              <div class="col-sm-10">
                <?php if(count($companies)): ?>
              	<?php foreach($companies as $comp): ?>
              	<label><input type="checkbox" value="<?php echo e($comp->id); ?>" name="access[<?php echo e($comp->id); ?>]" onClick="departments($(this), <?php echo e($comp->id); ?>)" <?php if($ude->exists($id, $comp->id)){echo 'checked';} ?>> <?php echo e($comp->name); ?></label> <br>
                	<?php if(count(\App\Categories::whereUser($comp->id))): ?>
                	<ul style="list-style:none;" id="checkbox_<?php echo e($comp->id); ?>">
                    	<?php foreach(\App\Categories::whereUser($comp->id) as $department): ?>
                    	<li><label><input type="<?php echo e($checkbox); ?>" value="<?php echo e($department->id); ?>" name="access[<?php echo e($comp->id); ?>][]" class="departments" <?php if($ude->exists($id, $comp->id, $department->id)){echo 'checked';} ?>> <?php echo e($department->name); ?></label></li>
                        <?php endforeach; ?>
                    </ul>
                    <?php endif; ?>
                <?php endforeach; ?>
                <?php endif; ?>
              </div>
            </div>
            
            <div class="form-group">
              <label for="status" class="col-sm-2 control-label">Status</label>
              <div class="col-sm-10">
                <select class="form-control" id="status" name="status">
                  <option value="on"  <?php if($row->status=="on"){echo 'selected';} ?>>Active</option>
                  <option value="off" <?php if($row->status=="off"){echo 'selected';} ?>>Deactive</option>
                </select>
              </div>
            </div>
            <div class="form-group">
              <div class="col-sm-offset-2 col-sm-10">
                <button type="submit" class="btn btn-info pull-right">Submit</button>
              </div>
            </div>
          </form>
        </div>
      </div>
    </div>
  </div>
</div>
<?php $__env->stopSection(); ?>
<?php $__env->startSection("footer"); ?>
<script>
	function departments(e, id){
		if(e.is(":checked")){
			
		}else{
			
			$("#departments_"+id).hide();
		}
	}
	function accessibilities(role){
		if(role==1){
			$("#accessibilities").hide();
		}
		if(role==2){
			$(".departments").attr("type", "checkbox");
			$("#accessibilities").show();
		}
		if(role==3){
			$(".departments").attr("type", "radio");
			$("#accessibilities").show();
		}
	}
</script>
<?php $__env->stopSection(); ?>
<?php echo $__env->make("app", array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>