@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_source')}}</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_source')}} </h3>
                        </div>
                        <div class="pull-right">
                            <a href="{{route('lead-source-agency.create')}}" class="button_sm button_info"><span class="fa fa-plus"></span>  {{__('administrator.add_new')}}</a>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <div class="wrapper-table">
            <table id="datatable_products" width="100%" class="table table-striped">
                <thead>
                <tr>
                    <th> # </th>
                    <th>{{ __('administrator.lead_name') }}</th>
                    <th>{{ __('administrator.note') }}</th>
                    <th> {{ __('administrator.action') }}</th>
                </tr>
                </thead>
                <tbody>

                </tbody>
            </table>
        </div>
        </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: [[20, 30, 50, 100,200,500,1000], [20, 30, 50, 100,200,500,1000]],
                ajax: "{{ route('datatable_lead_source_agency') }}",
                columns:
                    [
                        {data: 'DT_RowIndex'},
                        {data: 'source_name'},
                        {data: 'note'},
                        {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: "/lead-source/"+id,
                    type: 'DELETE',
                    data: {
                        "_token": token,
                    },
                    success: function (){
                        $('#form_delete').modal('hide');

                        location.reload();

                    }
                });
            });
        });
    </script>
@stop



