
<?php $__env->startSection('content'); ?>
<?php Fun::lang()?>
<style>
    .padding-5{
        padding: 5px !important;
    }
    .fa-pencil{
        cursor: pointer !important;
    }
    .jconfirm .jconfirm-box div.jconfirm-content-pane .jconfirm-content{
        overflow: hidden;
    }
    .ui-timepicker-container{
        z-index: 99999999 !important;
    }
    .select2-container--open{
        z-index: 99999999 !important;

    }
</style>
<div class="row">
    <div class="col-xs-12">
        <div class="box">
            <div class="box-header">
                <div class="row">
                <div class="col-sm-12 col-xs-12">
                    <div class="title-add">
                        <div class="pull-left">
                            <h3><?php echo e(__('administrator.pospect')); ?></h3>
                        </div>
                        <div class="pull-right">
                            <a href="<?php echo e(url("lead-report?type=meeting")); ?>">
                                <button class="btn btn-success btn-xs <?php echo e(request()->type == 'meeting' ? 'bg-aqua-active':''); ?>"><?php echo e(__('administrator.meeting_log')); ?></button>
                            </a>
                            <a href="<?php echo e(url("lead-report?type=appointmentasd")); ?>">
                                <button class="btn btn-success btn-xs <?php echo e(request()->type == 'appointment' ? 'bg-aqua-active':''); ?>"><?php echo e(__('administrator.appointment_log')); ?></button>
                            </a>
                            <a href="<?php echo e(url("lead-report?type=call_log")); ?>">
                                <button class="btn btn-success btn-xs <?php echo e(request()->type == 'call_log' ? 'bg-aqua-active':''); ?>"><?php echo e(__('administrator.call_log')); ?></button>
                            </a>
                        </div>
                    </div>
                </div>
            </div>
            </div>
            <div class="box-body table-responsive">
                <table id="data_table" width="100%" class="table table-bordered table-striped dataTable table-responsive">
                <thead>
                    <tr>
                        <th>N°</th>
                        <th ><?php echo e(__('administrator.register_date')); ?></th>
                        <th ><?php echo e(__('administrator.agent')); ?></th>
                        <th ><?php echo e(__('administrator.name')); ?></th>
                        <th ><?php echo e(__('administrator.sex')); ?></th>
                        <th><?php echo e(__('administrator.contact')); ?></th>
                        <th><?php echo e(__('administrator.address')); ?></th>
                        <th><?php echo e(__('administrator.status')); ?></th>
                    </tr>
                    <tr>
                        <td></td>
                        <td>
                            <input type="text" name="datepicker" class="form-control datepicker" placeholder="<?php echo e(__('administrator.date')); ?>" autocomplete="off">
                        </td>
                        <td>
                            <?php if((\Auth::user()->is_role == 'Administrator')): ?>
                                <?php echo Form::select('agent', getAgent(), null, ['class' => 'agent form-control select2', 'placeholder' => __('administrator.agent')]); ?>

                            <?php endif; ?>
                        </td>
                        
                        <td>
                            <input type="text" name="last_name" class="form-control last_name" placeholder="<?php echo e(__('administrator.name')); ?>" autocomplete="off">
                        </td>
                        <td></td>
                        <td>
                            <input type="text" name="contact" class="form-control" placeholder="<?php echo e(__('administrator.contact')); ?>" autocomplete="off">
                        </td>
                        <td>
                             <input type="text" name="address" class="form-control" placeholder="<?php echo e(__('administrator.address')); ?>" autocomplete="off">
                        </td>
                        <td>
                            <?php echo Form::select('task', ['meeting' => 'Meeting', 'appointment' => 'Appointment', 'call_log' => 'Call_log'], null, ['class' => 'task form-control select2', 'placeholder' => __('administrator.task_type')]); ?>

                        </td>
                    </tr>
                </thead>
                <tbody>

                </tbody>
                </tfoot>
            </table>
            </div>
        </div>
    </div>
</div>
<?php $__env->stopSection(); ?>
<?php $__env->startSection('script'); ?>
<script type="text/javascript">
//  start datatable
    var record = 20;
    var page = 1;
    $(document).ready(function() {
        dataTable();
        $.fn.dataTable.ext.errMode = 'throw';
        $('.datepicker').datepicker({
            dateFormat: 'dd-mm-yy',
            autoclose: true,
            onSelect: function(dateText) {
                $('.form-control').trigger('blur');
            }
        });
    });

    $(document).on('blur', '.form-control.input-sm', function() {
        record = $(this).val();
        page = 1;
        $('#data_table').DataTable().destroy();
        dataTable();
    });

    $(document).on('blur', 'input[name="datepicker"], input[name="first_name"], input[name="last_name"], input[name="contact"], input[name="address"]', function(){
        page = 1;
        $('#data_table').DataTable().destroy();
        dataTable();
    });

    $(document).on('change', 'select[name="agent"], select[name="task"]', function(){
        page = 1;
        $('#data_table').DataTable().destroy();
        dataTable();
    });

    $(document).on('click', '.fa.fa-times', function(){
        page = 1;
        $('.form-control').val(null);
        $('select[name="agent"]').val('').trigger('change');
        $('select[name="task"]').val('').trigger('change');
        $('#data_table').DataTable().destroy();
        dataTable();
    });

    $(document).on('click', '.page-item', function() {
        page = $('.page-item.active .page-link').text();
        $('#data_table').DataTable().destroy();
        dataTable();

    });


    function dataTable() {
        var date = $('input[name="datepicker"]').val();
        var first_name = $('input[name="first_name"]').val();
        var last_name = $('input[name="last_name"]').val();
        var contact = $('input[name="contact"]').val();
        var address = $('input[name="address"]').val();
        var task = $('select[name="task"]').val();
        var agent = $('select[name="agent"]').val();
        var type = <?php echo json_encode(request()->type); ?>;


        $('#data_table').DataTable({
            "oLanguage": {
                "sSearch": "<?php echo e(__('administrator.search')); ?>:",
                "sLengthMenu": "<?php echo e(__('administrator.display')); ?> _MENU_ <?php echo e(__('administrator.record_per_page')); ?>",
                "sZeroRecords": "<?php echo e(__('administrator.Nothing_foundsorry')); ?>",
                "sInfo": "<?php echo e(__('administrator.showing')); ?> _START_ <?php echo e(__('administrator.to')); ?> _END_ <?php echo e(__('administrator.of')); ?> _TOTAL_ <?php echo e(__('administrator.record')); ?>",
                "sInfoEmpty": "<?php echo e(__('administrator.showing')); ?> 0 <?php echo e(__('administrator.to')); ?> 0 <?php echo e(__('administrator.of')); ?> 0 <?php echo e(__('administrator.record')); ?>",
                "sInfoFiltered": "(<?php echo e(__('administrator.filter_form')); ?> _MAX_ <?php echo e(__('administrator.total_records')); ?>)",
                "oPaginate": {
                    "sFirst": "<?php echo e(__('administrator.first')); ?>",
                    "sLast": "<?php echo e(__('administrator.last')); ?>",
                    "sNext": "<?php echo e(__('administrator.next')); ?>",
                    "sPrevious": "<?php echo e(__('administrator.previous')); ?>"
                },
            },
            serverSide: true,
            ordering: false,
            searching: false,
            pageLength: record,
            lengthMenu: [20, 30, 50, 100, 200, 500, 1000],
            ajax: {
                url: '<?php echo url("prospect-report"); ?>',
                data:{
                    date,
                    last_name,
                    contact,
                    address,
                    task,
                    agent,
                    record,
                    page
                }
            },
            columns:
                [
                    {data: 'DT_RowIndex'},
                    {data: 'date'},
                    {data: 'agent_name'},
                    {data: 'name'},
                    {data: 'sex'},
                    {data: 'contact'},
                    {data: 'address'},
                    {data: 'convert_status'},
                ],
            "initComplete": function (settings, json) {
                $('select[name="data_table_length"]').val(json.records);
                $('.dataTables_paginate').empty();
                $('#data_table_paginate').twbsPagination('destroy');
                $('#data_table_paginate').twbsPagination({
                    totalPages: json.totalPage,
                    visiblePages: 5,
                    startPage: parseInt(json.activePage),
                    next: 'Next',
                    prev: 'Prev',
                    onPageClick: function (event, pageD) {
                    }
                });
            }
        });
    }
</script>
<?php $__env->stopSection(); ?>

<?php echo $__env->make(branchMenu(), \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH /home/nsowos/public_html/shr-brand/resources/views/crm/lead/report_prospect.blade.php ENDPATH**/ ?>