@extends('layouts.master')

@section('content')
<div class="content">
    @if ($message = Session::get('success'))
        <div class="alert alert-success">
                <p>{{ $message }}</p>
        </div>
    @endif
    <div class="row">
        <div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
            <div class="panel panel-default">
                <div class="panel-heading">
                    <h3 class="panel-title">Leave Request</h3>
                </div>
                <div class="panel-body">
                    <form action="{{ url('user/leave_req') }}" method="POST" class="form-horizontal" role="form">
                            {{ csrf_field() }}
                            <div class="form-group">
                                <label for="purpose" class="col-sm-2">Leave Purpose: </label>
                                <div class="col-sm-6">
                                    <select name="purpose" id="purpose" class="form-control" required>
                                        <option value="">Select leave Purpose</option>
                                        @if($leave_type)
                                            @foreach($leave_type as $head)
                                                <option value="{{ $head->id }}">{{ $head->name }}</option>
                                            @endforeach
                                        @endif
                                    </select>
                                </div>
                            </div>
                            <div class="form-group">
                                <label for="purpose" class="col-sm-2">Apply To: </label>
                                <div class="col-sm-6">
                                    <select name="user_id" id="user_id" class="form-control" required>
                                        <option value="">Select User</option>
                                        @if($users)
                                            @foreach($users as $user)
                                                <option value="{{ $user->id }}">
                                                    {{ $user->name }}
                                                </option>
                                            @endforeach
                                        @endif
                                    </select>
                                </div>

                            </div>
                            <div class="form-group">
                                <label for="due_date" class="col-sm-2">From :</label>
                                <div class="col-sm-6">
                                    <input type='text' name="from" id="from" class="form-control date" placeholder="From Date" required="">
                                </div>
                            </div>
                            <div class="form-group">
                                <label for="due_date" class="col-sm-2">To :</label>
                                <div class="col-sm-6">
                                    <input type='text' name="to" id="to" class="form-control date" placeholder="To Date" required="">
                                </div>
                            </div>
                            <div class="form-group">
                                <label for="description" class="col-sm-2">Application</label>
                                <div class="col-sm-6">
                                    <textarea name="description" rows="7" id="description" class="form-control" placeholder="Description" required=""></textarea>
                                </div>
                            </div>


                            <div class="form-group">
                                <div class="col-sm-10 col-sm-offset-2">
                                    <button type="submit" class="btn btn-info">Request</button>
                                </div>
                            </div>

                    </form>
                </div>
            </div>
        </div>
    </div>
</div>
<script type="text/javascript">
$(document).ready(function() {
     $( ".date" ).datepicker({
          changeMonth: true,
          changeYear: true,
          dateFormat:"yy-mm-dd"
     });
});
</script>
@endsection