@extends('layouts.agencies') @section('content')

    <?php Fun::lang()?>
    <ol class="breadcrumb">
        <li><a href="#">{{__('administrator.Dashboard')}}</a></li>
        <li><a href="#">{{__('administrator.lead')}}</a></li>
        <li class="active">{{__('administrator.lead')}}</li>
    </ol>
    <div class="page">
<div class=container-fluid>
        <div class="top-content">
            <div class="row">
                <div class="col-sm-12 col-xs-12">
                    <div class="title-add">
                        <div class="pull-left">
                            <h3>{{__('administrator.lead')}} </h3>
                        </div>
                        <div class="pull-right">
                            <div class="meun_list">
                                <a href="{{route('meeting-agency.index')}}" class="button_sm button_info bg-olive"><span
                                            class="fa  "></span> {{ __('administrator.meeting_log') }} </a>
                                <a href="{{route('appointment-agency.index')}}" class="button_sm button_info bg-olive"><span
                                            class="fa "></span> {{ __('administrator.appointment_log') }}</a>
                                <a href="{{route('call-log-agency.index')}}" class="button_sm button_info bg-olive"><span
                                            class="fa "></span> {{ __('administrator.call_log') }}</a>
                                <a href="{{route('lead-agency.create')}}" class="button_sm button_success"><span
                                            class="fa fa-plus "></span> {{__('administrator.add_lead')}}</a>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <div class="top-content">
            <div class="row">
                <div class="col-sm-12 col-xs-12">
                    <div class="title-add">
                        {!! Form::open(array('route' => 'lead-agency.index','method'=>'GET')) !!}
                        <div class="form-group col-sm-6 col-xs-12">
                            <div class="col-sm-3 col-xs-12 ">
                                <label for="name">{{__('administrator.agent')}} </label>
                            </div>
                            <div class="col-sm-9">
                                {!! Form::select('agent_id',$agent,null, array('placeholder' =>__('administrator.please_select'),'class' => 'form-control  input-md select2','' )) !!}
                            </div>
                        </div>
                        <div class="form-group col-sm-5 col-xs-12">
                            <div class="col-sm-3 col-xs-12 ">
                                <label for="name">{{__('administrator.date')}} </label>
                            </div>
                            <div class="col-sm-9">
                                {!! Form::text('date',(@$_GET['date']?@$_GET['date']:''), array('placeholder' => __('administrator.date'),'class' => 'form-control  input-sm date_picker','' )) !!}
                            </div>
                        </div>
                        <div class="col-sm-1 col-xs-12">
                            {!! Form::button(__('administrator.search'), array('type' => 'submit','class'=> 'pull-right button_primary',))!!}
                        </div>
                        {{ Form::close() }}
                    </div>
                </div>
            </div>
        </div>
        <div class="box-body">
            <table id="datatable_products" width="100%" class="table table-striped">
                <thead>
                <tr>
                    <th>#</th>
                    <th>{{ __('administrator.date') }}</th>
                    <th>{{__('administrator.agent')}}</th>
                    <th>{{__('administrator.family_name')}}</th>
                    <th>{{__('administrator.name')}}</th>
                    <th>{{ __('administrator.sex') }}</th>
                    <th>{{ __('administrator.contcact') }}</th>
                    <th>{{ __('administrator.address') }}</th>
                    <th>{{ __('administrator.close_deal') }}</th>
                    <th>{{ __('administrator.action') }}</th>
                </tr>
                </thead>
                <tbody>

                </tbody>
            </table>
        </div>
        </div>
        <div class="modal fade bs-modal-lg" id="form_delete" tabindex="-1" role="dialog" aria-hidden="true">
            <div class="modal-dialog modal-dm">
                <div class="modal-content">
                    <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal" aria-hidden="true"></button>
                        <h3 class="modal-title">Are you sure?</h3>
                    </div>
                    <br/>
                    <form role="form" method="delete" id="delete">
                        {{csrf_field()}}
                        <div class="row">
                            <div class="col-md-12">
                                <div class="col-md-10">
                                    <h4>Are you want to delete?</h4>
                                </div>
                            </div>
                        </div>
                        <div class="modal-footer">
                            <button type="button" data-dismiss="modal" class="button_danger"><i class="fa fa-close"></i>
                                No
                            </button>
                            <button type="button" class="button_primary deleteRecord" data-toggle="modal"><i
                                        class="fa fa-save"></i> OK
                            </button>
                        </div>
                    </form>
                </div>
            </div>
        </div>

        @endsection
        @section('script')
            <script type="text/javascript">
                $(document).ready(function () {
                    $('#datatable_products').DataTable({
                        ordering: false,
                        serverSide: true,
                        lengthMenu: [[10, 30, 50, 100, 200, 500, 1000], [10, 30, 50, 100, 200, 500, 1000]],
                        ajax: "{{ route('datatable_crm_lead_agency') }}?agent_id={{isset($_GET['agent_id'])?$_GET['agent_id']:'0'}}&date={{isset($_GET['date'])?$_GET['date']:'0'}}",
                        columns:
                            [
                                {data: 'DT_RowIndex','searchable':false},
                                {data: 'date','name':'nso007_crm_leads.date'},
                                {data: 'agent_name',"name":"users.user_firstname"},
                                {data: 'family_name',"name":'nso007_crm_leads.family_name'},
                                {data: 'name',"name":'nso007_crm_leads.name'},
                                {data: 'sex',"name":'nso007_crm_leads.sex'},
                                {data: 'contact',"name":'nso007_crm_leads.contact'},
                                {data: 'address',"name":'nso007_crm_leads.address'},
                                {data: 'convert_status','searchable':false},
                                {data: 'action'},
                            ],
                        "initComplete": function (settings, json) {
                        }
                    });
                    $.fn.dataTable.ext.errMode = 'throw';
                });
                $(document).on('click', '.delete_products', function () {
                    $('#form_delete').modal('show');
                    var id = $(this).data("id");
                    $(".deleteRecord").click(function () {
                        var token = $("meta[name='csrf-token']").attr("content");
                        $.ajax({
                            url: "{{route('lead.delete_lead')}}",
                            type: 'GET',
                            data: {
                                "id": id,
                                "_token": token,
                            },
                            success: function () {
                                $('#form_delete').modal('hide');
                                location.reload();

                            }
                        });
                    });
                });
            </script>
            <style>
                .table > tbody > tr > td, .table > tbody > tr > th, .table > tfoot > tr > td, .table > tfoot > tr > th, .table > thead > tr > td, .table > thead > tr > th {
                    padding: 8px !important;
                    line-height: 1.42857143 !important;
                    vertical-align: middle !important;
                    border-top: 1px solid #fff !important;
                }
            </style>
@stop



