@extends('layouts.master')

@section('content')
<div class="content">
    <div class="row">
        <form action="{{ url('admin/employee/store') }}" enctype="multipart/form-data" method="POST" role="form">
        <div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
            <header class="panel-heading" style="height:50px;">
                <div class="pull-left">
                    {{$title}}
                </div>
                <div>
                     @if(\Auth::user()->utype==1)
                        <a href="{{ url('admin/employee') }}" class="btn btn-sm btn-info pull-right"><i class="fa fa-list"></i> Employee List</a> <br><br>
                    @endif
                </div>
            </header>
        </div>
        <div class="col-xs-6 col-sm-6 col-md-6 col-lg-6">
            <div class="panel panel-default">
                <div class="panel-heading">
                    <h3 class="panel-title">Employee Information : <small>Please Add Recent First</small></h3>
                </div>
                <div class="panel-body">
                    {{ csrf_field() }}
                    <div class="form-group {{ $errors->has('name') ? 'has-error' : '' }}">
                        <label for="name">Full Name <i class="text-danger">*</i></label>
                        <input type='text' name="name" id="name" class="form-control" value="{{ old('name') }}" placeholder="Full Name" required="" >
                        <lebel class="text-danger"> {{ $errors->first('name') }}</lebel>
                    </div>
                    <div class="form-group {{ $errors->has('personal_email') ? 'has-error' : '' }}">
                        <label for="personal_email">Personal Email <i class="text-danger">*</i></label>
                        <input type='email' name="personal_email" id="personal_email" class="form-control" value="{{ old('personal_email') }}" required=""  placeholder="Personal Email">
                        <lebel class="text-danger"> {{ $errors->first('personal_email') }}</lebel>
                    </div>
                    <div class="form-group {{ $errors->has('phone') ? 'has-error' : '' }}">
                        <label for="phone">Phone1 <i class="text-danger">*</i></label>
                        <input type='text' name="phone" value="{{ old('phone') }}" id="phone" required="" class="form-control"   placeholder="Phone Number">
                        <lebel class="text-danger"> {{ $errors->first('phone') }}</lebel>
                    </div>
                    <div class="form-group">
                        <label for="phonetwo">Phone2</label>
                        <input type='text' name="phonetwo" value="{{ old('phonetwo') }}" id="phonetwo" class="form-control"   placeholder="Phone Number">
                    </div>
                    <div class="form-group {{ $errors->has('birth_day') ? 'has-error' : '' }}">
                        <label for="birth_day">Date of birth <i class="text-danger">*</i></label>
                        <input type='text' name="birth_day" id="birth_day" class="form-control date" placeholder="Date of birth" value="{{ old('birth_day') }}" required="" >
                        <lebel class="text-danger"> {{ $errors->first('birth_day') }}</lebel>
                    </div>

                    <div class="form-group {{ $errors->has('present_address') ? 'has-error' : '' }}">
                        <label for="present_address">Present Address <i class="text-danger">*</i></label>
                        <input type='text' name="present_address" id="present_address" class="form-control" placeholder="Present Address" value="{{ old('present_address') }}" required="" >
                        <lebel class="text-danger"> {{ $errors->first('present_address') }}</lebel>
                    </div>
                    <div class="form-group">
                        <label for="per_address">Permanent Address</label>
                        <input type='text' name="per_address" id="per_address" value="{{ old('per_address') }}" class="form-control" placeholder="Permanent Address">
                    </div>
                    <div class="form-group">
                        <label for="note">Note</label>
                        <textarea type='text' name="note" id="note" value="{{ old('note') }}" class="form-control" placeholder="Note"></textarea>
                    </div>
                    <div class="form-group">
                        <label for="facebook">Facebook</label>
                        <input type='text' name="facebook" value="{{ old('facebook') }}" id="facebook" class="form-control" placeholder="Facebook">
                    </div>
                    <div class="form-group">
                        <label for="skype">Skype</label>
                        <input type='text' name="skype" value="{{ old('skype') }}" id="skype" class="form-control" placeholder="Skype">
                    </div>
                    <div class="form-group">
                        <label for="linkedin">Linkedin</label>
                        <input type='text' name="linkedin" value="{{ old('linkedin') }}" id="linkedin" class="form-control" placeholder="Linkedin">
                    </div>
                    <div class="form-group">
                        <label for="linkedin">Picture</label>
                        <input type='file' name="image" class='form-control'>
                    </div>

                    <div class="clearfix"></div>
                    

                </div>
            </div>
        </div>

        <div class="col-xs-6 col-sm-6 col-md-6 col-lg-6">
            <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">Employment Details: <small>Please Add Recent First</small></h3>
                    </div>
                    <div class="panel-body">
                        <div class="form-group {{ $errors->has('joining_date') ? 'has-error' : '' }}">
                            <label for="joining_date">Joining Date <i class="text-danger">*</i></label>
                            <input type='text' name="joining_date" id="joining_date" class="form-control date" placeholder=" Date" value="{{ old('joining_date') }}" required="" >
                            <lebel class="text-danger"> {{ $errors->first('joining_date') }}</lebel>
                        </div>
                        <div class="form-group {{ $errors->has('current_designation') ? 'has-error' : '' }}">
                            <label for="current_designation">Designation <i class="text-danger">*</i></label>
                            <select name="current_designation" class='form-control' id="current_designation" required="" >
                                <option disabled selected value>Choose One..</option>
                                @foreach($all_designation as $info)
                                <option value="{{ $info->id }}">{{ $info->name }}</option>
                                @endforeach
                            </select>
                            <lebel class="text-danger"> {{ $errors->first('current_designation') }}</lebel>
                        </div>
                        <div class="form-group {{ $errors->has('salary_grade') ? 'has-error' : '' }}">
                            <label for="salary_grade">Salary Grade <i class="text-danger">*</i></label>
                            <select name="salary_grade" class='form-control' id="salary_grade" required="" >
                                <option disabled selected value>Choose One..</option>
                                @foreach($all_grade as $row)
                                <option value="{{ $row->id }}">{{ $row->name }}</option>
                                @endforeach
                            </select>
                            <lebel class="text-danger"> {{ $errors->first('salary_grade') }}</lebel>
                        </div>
                    </div>
                </div>
            </div>
            <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">File Upload : <small>Please Add Recent First</small></h3>
                    </div>
                    <div class="panel-body">
                    
                        <table class="table table-bordered tbl-items">
                            <thead>
                                <tr>
                                    <th>#</th>
                                    <th width="35%">Document Type</th>
                                    <th>File</th>
                                    <th>Action</th>
                                </tr>
                            </thead>
                            <tbody class="filebody">
                                <tr>
                                    <td class="no">1</td>
                                    <td>
                                        <select name="document_id[]" class='form-control'>
                                            <option disabled selected value>Choose One..</option>
                                            @foreach($all_document as $info)
                                            <option value="{{ $info->id }}">{{ $info->document_name }}</option>
                                            @endforeach
                                        </select>
                                    </td>
                                    <td>
                                        <input type='file' name="file[]" class='form-control'>
                                    </td>
                                    <td><input id="delete_item" type="button" class="btn btn-danger" value="x"></td>
                                </tr>
                            </tbody>
                        </table>
                        <button type='button' id='add_file' class='btn btn-sm' title='Add New Item'><i class="fa fa-plus"></i> Add more item</button>
                    </div>
                </div>
            </div>
        </div>
        <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">Academic Information : <small>Please Add Recent First</small></h3>
                </div>
                <div class="panel-body">
                    <table class="table table-bordered tbl-items">
                        <thead>
                            <tr>
                                <th>#</th>
                                <th width="17%">Education Level</th>
                                <th width="23%">Institute</th>
                                <th>Major/Group</th>
                                <th>Marks/CGPA</th>
                                <th>Passing Year</th>
                                <th>Duration</th>
                                <th>Action</th>
                            </tr>
                        </thead>
                        <tbody class="resultbody">
                            <tr>
                                 <td class="no">1</td>
                                <td>
                                    <select name="edu_level[]" class='form-control' >
                                        <option disabled selected value>Choose One..</option>
                                        @foreach($all_level as $info)
                                        <option value="{{ $info->id }}">{{ $info->level_name }}</option>
                                        @endforeach
                                    </select>
                                </td>
                                <td>
                                    <input type='text' name="institute[]" class='form-control' placeholder="Institute" >
                                </td>
                                <td>
                                    <input type='text' name="major[]" class='form-control' placeholder="Major" >
                                </td>
                                <td>
                                    <input type='text' name="marks[]" class='form-control' placeholder="Marks" >
                                </td>
                                <td>
                                    <input type='text' name="passing_year[]" class='form-control' placeholder="Passing Year">
                                </td>
                                <td>
                                    <input type='text' name="duration[]" class='form-control' placeholder="Duration">
                                </td>
                                <td><input id="delete_item" type="button" class="btn btn-danger" value="x"> </td>
                            </tr>
                        </tbody>
                    </table>
                    <button type='button' id='add_item' class='btn btn-sm' title='Add New Item'><i class="fa fa-plus"></i> Add more item</button>
                </div>
            </div>
        </div>
        
        <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">Work Experience : <small>Please Add Recent First</small></h3>
                </div>
                <div class="panel-body">
                    <table class="table table-bordered tbl-items">
                        <thead>
                            <tr>
                                <th>#</th>
                                <th>Org Name</th>
                                <th>Org Contact</th>
                                <th>Designation</th>
                                <th>Start Date</th>
                                <th>End Date</th>
                                <th>Action</th>
                            </tr>
                        </thead>
                        <tbody class="expbody">
                            <tr>
                                 <td class="no">1</td>
                                <td>
                                    <input type='text' name="org_name[]" class='form-control' placeholder="Name">
                                </td>
                                <td>
                                    <input type='text' name="org_contact[]" class='form-control' placeholder="Contact">
                                </td>
                                <td>
                                    <select name="designation[]" class='form-control'>
                                        <option disabled selected value>Choose One..</option>
                                        @foreach($all_designation as $data)
                                        <option value="{{ $data->id }}">{{ $data->name }}</option>
                                        @endforeach
                                    </select>
                                </td>
                                <td>
                                    <input type='text' name="start_date[]" class='form-control date' placeholder=" Date">
                                </td>
                                <td>
                                    <input type='text' name="end_date[]" class='form-control date' placeholder=" date">
                                </td>
                                <td><input id="delete_exp" type="button" class="btn btn-danger" value="x"> </td>
                            </tr>
                        </tbody>
                    </table>
                    <button type='button' id='add_exp' class='btn btn-sm' title='Add New Item'><i class="fa fa-plus"></i> Add more item</button>
                </div>
            </div>
        </div>

        <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">Reference / Emergency Contact : <small>Please Add Recent First</small></h3>
                </div>
                <div class="panel-body">
                    <table class="table table-bordered tbl-items">
                        <thead>
                            <tr>
                                <th>#</th>
                                <th>Person Name</th>
                                <th>Relation</th>
                                <th>Phone 1</th>
                                <th>Phone 2</th>
                                <th>Email</th>
                                <th width="18%">Address</th>
                                <th>Action</th>
                            </tr>
                        </thead>
                        <tbody class="refbody">
                            <tr>
                                 <td class="no">1</td>
                                <td>
                                    <input type='text' name="person_name[]" class='form-control' placeholder="Name">
                                </td>
                                <td>
                                    <input type='text' name="relation[]" class='form-control' placeholder="Relation">
                                </td>
                                <td>
                                    <input type='text' name="phone1[]" class='form-control' placeholder="Phone 1" >
                                </td>
                                <td>
                                    <input type='text' name="phone2[]" class='form-control' placeholder="Phone 2">
                                </td>
                                <td>
                                    <input type='text' name="email[]" class='form-control' placeholder="Email Address">
                                </td>
                                <td>
                                    <input type='text' name="address[]" class='form-control' placeholder="Address">
                                </td>
                                <td><input id="delete_ref" type="button" class="btn btn-danger" value="x"> </td>
                            </tr>
                        </tbody>
                    </table>
                    <button type='button' id='add_item_ref' class='btn btn-sm' title='Add New Item'><i class="fa fa-plus"></i> Add more item</button>
                </div>
                <div class="panel-footer pull-right">
                    <button type="submit" class="btn btn-primary"><i class="fa fa-save"></i> Save data</button>
                    <a href="{{ url('admin/employee') }}" class="btn btn-default">
                    <i class="fa fa-times"></i> Cancel</a>
                </div>
            </div>
        </div>

        </form>
    </div>
</div>
@stop


@section('script')
<script type="text/javascript">
    $(function () {
        $('#add_item').click(function () {
            var n = ($('.resultbody tr').length - 0) + 1;
            var tr = '<tr><td class="no">' + n + '</td>' +
                    '<td><select name="edu_level[]" class="form-control" required="" ><option disabled selected value>Choose One..</option>@foreach($all_level as $info)<option value="{{ $info->id}}">{{ $info->level_name }}</option>@endforeach</select></td>'+
                    '<td><input type="text" class="institute form-control" required=""  name="institute[]" placeholder="Institute" ></td>'+
                    '<td><input type="text" class="major form-control" required=""  name="major[]" placeholder="Major" ></td>'+
                    '<td><input type="text" class="marks form-control" required=""  name="marks[]"  placeholder="Marks"></td>'+
                    '<td><input type="text" class="passing_year form-control" required=""  name="passing_year[]" placeholder="Passing Year"></td>'+
                    '<td><input type="text" class="duration form-control" name="duration[]" placeholder="Duration"></td>'+
                    '<td><input id="delete_item" type="button" class="btn btn-danger" value="x"></td>';

            $('.resultbody').append(tr);
        });
        $('.resultbody').delegate('#delete_item', 'click', function () {
            $(this).parent().parent().remove();
        });
    });
</script>
<script type="text/javascript">
    $(function () {
        $('#add_exp').click(function () {
            var n = ($('.expbody tr').length - 0) + 1;
            var tr = '<tr><td class="no">' + n + '</td>' +
                    '<td><input type="text" class="org_name form-control" required=""  name="org_name[]" placeholder="Name" ></td>'+
                    '<td><input type="text" class="org_contact form-control" required=""  name="org_contact[]" placeholder="Contact" ></td>'+
                    '<td><select name="designation[]" class="form-control" required="" ><option disabled selected value>Choose One..</option>@foreach($all_designation as $info)<option value="{{ $info->id}}">{{ $info->name }}</option>@endforeach</select></td>'+                    
                    '<td><input type="date" class="form-control date" required=""  name="start_date[]"  placeholder="Start Date"></td>'+
                    '<td><input type="date" class="form-control date" required=""  name="end_date[]" placeholder="End Date"></td>'+
                    '<td><input id="delete_exp" type="button" class="btn btn-danger" value="x"></td>';

            $('.expbody').append(tr);
        });
        $('.expbody').delegate('#delete_exp', 'click', function () {
            $(this).parent().parent().remove();
        });
    });
</script>
<script type="text/javascript">
    $(function () {
        $('#add_item_ref').click(function () {
            var n = ($('.refbody tr').length - 0) + 1;
            var tr = '<tr><td class="no">' + n + '</td>' +
                    '<td><input type="text" class="person_name form-control" required=""  name="person_name[]" placeholder="Name" ></td>'+
                    '<td><input type="text" class="relation form-control" required=""  name="relation[]" placeholder="Relation" ></td>'+
                    '<td><input type="text" class="phone1 form-control" required=""  name="phone1[]" placeholder="Phone 1" ></td>'+
                    '<td><input type="text" class="phone2 form-control" required=""  name="phone2[]"  placeholder="Phone 2"></td>'+
                    '<td><input type="email" class="email form-control" required=""  name="email[]" placeholder="Email Address"></td>'+
                    '<td><input type="text" class="address form-control" name="address[]" placeholder="Address"></td>'+
                    '<td><input id="delete_ref" type="button" class="btn btn-danger" value="x"></td>';

            $('.refbody').append(tr);
        });
        $('.refbody').delegate('#delete_ref', 'click', function () {
            $(this).parent().parent().remove();
        });
    });
</script>

<script type="text/javascript">
    $(function () {
        $('#add_file').click(function () {
            var n = ($('.filebody tr').length - 0) + 1;
            var tr = '<tr><td class="no">' + n + '</td>' +
                    '<td><select name="document_id[]" class="form-control" required="" ><option disabled selected value> Choose One..</option>@foreach($all_document as $info)<option value="{{ $info->id}}">{{ $info->document_name }}</option>@endforeach</select></td>'+
                    '<td><input type="file" name="file[]" class="form-control" required="" ></td>'+
                    '<td><input id="delete_item" type="button" class="btn btn-danger" value="x"></td>';

            $('.filebody').append(tr);
        });
        $('.filebody').delegate('#delete_item', 'click', function () {
            $(this).parent().parent().remove();
        });
    });
</script>
<script type="text/javascript">
$(document).ready(function() {
     $( ".date" ).datepicker({
          changeMonth: true,
          changeYear: true,
          yearRange: "c-100:c+10", 
          dateFormat:"yy-mm-dd"
     });
});
</script><script type="text/javascript">
$(document).ready(function() {
     $( ".date" ).datepicker({
          changeMonth: true,
          changeYear: true,
          yearRange: "c-100:c+10", 
          dateFormat:"yy-mm-dd"
     });
});
</script>

@stop