/home/mip/mip/app/Modules/Client/Views/applicants/search-applicant/index.blade.php
@extends('Client::layouts')
@section('page-body')
    <!-- Content Header (Page header) -->
    <section class="content-header">
        <h1>
            <i class="fa fa-{{$pageIcon ? $pageIcon : 'angle-double-right'}}" aria-hidden="true"></i> {{$pageTitle}}
            <br>
            <small>{{$pageDescription}}</small>
        </h1>
        <ol class="breadcrumb">
            <li><a href="{{ route(config('modules.client').'.applicants.index') }}"><i class="fa fa-file-text-o"></i> Applicants</a></li>
            <li class="active"></i> {{$pageTitle}}</li> 
        </ol>
    </section>
    <!-- Main content -->
    <section class="content"> 
        @include('Client::message')
        <div class="box box-default">
            <div class="box-header with-border">
            </div>
            <div class="box-body">
                <div class="col-md-12">
                    <div class="form-group">
                        <label class="control-label col-md-3"></label>
                        <div class="col-md-6">
                            <form action="{{route(config('modules.client').'.search-applicants.index')}}" id="search-filter" method="GET" role="form">
                                <div class="input-group">
                                    <input class="form-control" placeholder="Type first name or last name to search." name="name" type="text" autocomplete="off" value="{{Input::get('name')}}">
                                    <span class="input-group-btn">
                                        <button class="btn btn-primary btn-flat" type="submit"><i class="fa fa-search"></i></button>
                                    </span>
                                </div>
                            </form>
                        </div>
                    </div>
                </div>
                <div class="hidden-xs hidden-sm">
                    <br><br><br>
                </div>
                <div class="search-applicant" style="display:none;">
                    <table class="table table-bordered table-striped table-hover" id="search-applicant-table" width="100%">
                        <thead>
                            <tr>
                                <th>#</th>
                                <th>Name</th>
                                <th>Mobile No.</th>
                                <th>Position Applied</th>
                                <th>Date Applied</th>
                            </tr>
                        </thead>
                   </table>
                </div>
            </div>                
        </div>
    </section>
@stop
@section('page-js')
<script type="text/javascript">
$(document).ready(function(){
    if($('#search-filter [name="name"]').val() != ''){
        var searchTable = $('#search-applicant-table').DataTable({
            "processing": true,
            "serverSide": true,
            "pagingType": "input",
            "filter":false,
            "lengthChange": false,
            "pageLength": 15,
            "scrollCollapse": true,
            "scrollY":"220px",
            language: {
                "processing": '<i class=\"fa fa-spinner fa-spin fa-2x\" style=\"color: black;\"></i>',
                "zeroRecords": "No matching records found",
            },
            ajax: {
                url: '{{ route(config('modules.client').'.search-applicants.datatables-index') }}', 
                type: 'POST',
                "data": function(d){
                    d.name = $('#search-filter [name="name"]').val();
                }
            },
            "dom": "<'row'<'col-sm-6'i><'col-sm-6 text-right'l>>" +
                    "<'row'<'col-sm-12'tr>>" +
                    "<'row'<'col-sm-5'><'col-sm-7'p>>",
            columns: [
                {
                    width:'10px', searchable: false, orderable: false,
                    render: function (data, type, row, meta) {
                        return meta.row + meta.settings._iDisplayStart + 1;
                    }
                },
                { data: 'full_name', name: 'full_name' , sortable: true, searchable: false},
                { data: 'mobile_number', name: 'mobile_number', sortable: false, searchable: false},
                { data: 'position', name: 'position', sortable: false, searchable: false},
                { data: 'apply_date', name: 'apply_date', sortable: false, searchable: false},
            ],
            fnDrawCallback: function ( oSettings ) {         
            },
            "order": [[1, "asc"]],
        });
    }

    function searchApplicant(){
        var search = $('#search-filter [name="name"]').val();
        if(search != ''){
            searchTable.draw();
            $('.search-applicant').show();
        }else{
          $('.search-applicant').hide();
        }
    }
    searchApplicant();
    $('#search-filter').on('submit', function(e){
        searchApplicant();
        e.preventDefault();
    });
});
</script>
@include('Client::notify')
@stop