@extends('layouts.app')
@section('title','Create new login user | ')
@section('content')
 <!-- Content Header (Page header) -->
 <div class="content-header">
      <div class="container-fluid">
        <div class="row mb-2">
          <div class="col-sm-6">
            <h1 class="m-0">User Registration</h1>
          </div><!-- /.col -->
          <div class="col-sm-6">
            <ol class="breadcrumb float-sm-right">
              <li class="breadcrumb-item"><a href="#">Home</a></li>
              <li class="breadcrumb-item active">User Registration</li>
            </ol>
          </div><!-- /.col -->
        </div><!-- /.row -->
      </div><!-- /.container-fluid -->
    </div>
    <!-- /.content-header -->
 <!-- Main content -->
 <section class="content">
      <div class="container-fluid">
      
      <div class="card card-default">
          <div class="card-header">
            <h3 class="card-title">Create new login user</h3>
            <div class="card-tools">
              <button type="button" class="btn btn-tool" data-card-widget="collapse">
                <i class="fas fa-minus"></i>
              </button>
            </div>
          </div>
          <!-- /.card-header -->
          <div class="card-body">
            @if (session('success'))
            <div class="alert alert-success alert-dismissible fade show" role="alert">
                <strong>{{ session('success') }}</strong>
                <button type="button" class="close" data-dismiss="alert" aria-label="Close">
                    <span aria-hidden="true">&times;</span>
                </button>
            </div>
            @endif
            @if (session('error'))
            <div class="alert alert-danger alert-dismissible fade show" role="alert">
                <strong>{{ session('success') }}</strong>
                <button type="button" class="close" data-dismiss="alert" aria-label="Close">
                    <span aria-hidden="true">&times;</span>
                </button>
            </div>
            @endif
            @if (session('warning'))
            <div class="alert alert-warning alert-dismissible fade show" role="alert">
                <strong>{{ session('warning') }}</strong>
                <button type="button" class="close" data-dismiss="alert" aria-label="Close">
                    <span aria-hidden="true">&times;</span>
                </button>
            </div>
            @endif
            @if(Auth::user()->user_role == 1 || Auth::user()->user_role == 2 || Auth::user()->user_role == 3)
            <form action="{{ route('store.new.employee') }}" method="post" autocomplete="off">
            @csrf
                <div class="row">
                    <div class="col-md-6">
                        <div class="form-group">
                            <label for="EmpFullname">Full Name</label>
                            <input type="text" name="full_name" class="form-control   @if( $errors->has('full_name')) is-invalid border-danger  @endif" value="{{ old('full_name') }}" id="EmpFullname" placeholder="eg. Rahul">
                            @if ($errors->has('full_name'))
                            <span id="EmpFullname-error" class="error text-danger invalid-feedback">{{ $errors->first('full_name') }}</span>
                            <small></small>
                            @endif
                        </div>
                    </div>
                    <div class="col-md-6">
                        <div class="form-group">
                            <label for="EmpEmail">Email</label>
                            <input type="email" name="email" class="form-control @if( $errors->has('email')) is-invalid border-danger  @endif" id="EmpEmail" value="{{ old('email') }}"  placeholder="eg. example@example.com">
                            @if ($errors->has('email'))
                            <span id="EmpEmail-error" class="error text-danger invalid-feedback">{{ $errors->first('email') }}</span>
                            <small></small>
                            @endif
                        </div>
                    </div>
                    <div class="col-md-6">
                        <div class="form-group">
                            <label for="EmpMobile">Mobile</label>
                            <input type="number" name="mobile_number" class="form-control @if( $errors->has('mobile_number')) is-invalid border-danger  @endif"  id="EmpMobile" value="{{ old('mobile_number') }}"  placeholder="eg. 9748252525" min="6000000001" max="9999999999">
                            @if ($errors->has('mobile_number'))
                            <span id="EmpMobile-error" class="error text-danger invalid-feedback">{{ $errors->first('mobile_number') }}</span>
                            <small></small>
                            @endif
                        </div>
                    </div>
                    <div class="col-md-6">
                        <div class="form-group">
                            <label for="district">District</label>
                            <select name="district" class="custom-select form-control @if( $errors->has('district')) is-invalid border-danger  @endif" id="district">
                              @if($districts->count() > 0)
                              <option value="">Select District</option>
                              @foreach($districts as $distict)
                                <option value="{{ $distict->district_id }}"  @if(old('district') == $distict->district_id) selected @endif>{{ $distict->district_name }}</option>
                              @endforeach  
                              @endif
                            </select>
                            @if ($errors->has('district'))
                            <span id="district-error" class="error text-danger invalid-feedback">{{ $errors->first('district') }}</span>
                            <small></small>
                            @endif
                        </div>
                    </div>
                    <div class="col-md-6">
                        <div class="form-group">
                            <label for="user_role">User Role</label>
                            <select name="user_role" class="custom-select form-control @if( $errors->has('user_role')) is-invalid border-danger  @endif" id="user_role">
                                <option value="">Select Employee Role</option>
                                <option value="2"  @if(old('user_role') == 2) selected @endif>Admin/HR</option>
                                <!-- <option value="3" @if(old('user_role') == 3) selected @endif>Team Lead</option> -->
                                <option value="4" @if(old('user_role') == 4) selected @endif>Employee</option>
                            </select>
                            @if ($errors->has('user_role'))
                            <span id="user_role-error" class="error text-danger invalid-feedback">{{ $errors->first('user_role') }}</span>
                            <small></small>
                            @endif
                        </div>
                    </div>
                    <div class="col-md-12">
                        <div class="form-group">
                            <a href="{{ route('list.all.employees') }}" class="btn btn-secondary">Back</a>
                            <button type="submit" class="btn btn-primary">Create User</button>
                        </div>
                    </div>
                </div>
            </form>
            @else 
            <p class="text-info">Permission denied: You don't have access permission to access this page</p>
            @endif
          </div>
        </div>
        <!-- /.card -->
      </div><!--/. container-fluid -->
    </section>
    <!-- /.content -->
@stop