  <?php $__env->startSection('content'); ?>
<?php Fun::lang()?>
<script>
    function searching(){
        $("#datatable_project").DataTable().draw(true);
    }
</script>
<div class="title-page">
    <div class="page-bar">
        <ul class="page-breadcrumb">
            <li><a href="#"><i class="fa fa-dashboard"></i> Dashboard</a></li>
            <li><a href="#">Operation</a></li>
            <li><a href="#">Manage Product</a></li>
            <li><a href="#">project</a></li>
        </ul>
    </div>
</div>
    <div class="page">
        <div class="top-content">
            <div class="row">
                <div class="col-sm-12 col-xs-12">
                    <div class="title-page">
                        <div class="pull-left">
                            <h3>Projects</h3>
                        </div>
                    </div>
                    <?php if (app(\Illuminate\Contracts\Auth\Access\Gate::class)->check('Project-Create')): ?>
                    <div class="pull-right">
                        <a class="button_sm button_primary" href="<?php echo e(route('projects.create')); ?>"><span class="fa fa-plus"></span>  Create New</a>
                    </div>
                    <?php endif; ?>
                    <div class="pull-right">
                        <a class="button_sm button_info" href="javascript:void(0)" id="filter-toggle-search"><span class="fa fa-plus"></span>  Filter Toggle</a>
                    </div>
                </div>
            </div>
        </div>
        <div class="box-body table-responsive">
            <div class="row" id="toggle-seaching">
                <div class="col-md-6">
                    <div class="form-group">
                        <strong >Code :</strong>
                        <?php echo Form::text('code',null, array('class' => 'form-control')); ?>

                    </div>
                </div>
                <div class="col-md-6">
                    <div class="form-group">
                        <strong >Project Name :</strong>
                        <?php echo Form::text('project_name',null, array('class' => 'form-control')); ?>

                    </div>
                </div>
                <div class="col-md-12" style="text-align:right;margin-bottom:40px !important;">
                    <a class="button_sm button_success" href="javascript:void(0)" id="search-submit" onclick="searching()"><span class="fa fa-search"></span> Search</a>
                </div>
            </div>
            <table id="datatable_project" class="table table-striped table-bordered table-hover nowrap">
                <thead>
                    <tr>
                        <th>NO</th>
                        <th>Project Image</th>
                        <th>Code</th>
                        <th>Name</th>
                        <th>Description</th>
                        
                        <th>Commission amount</th>
                        <th>Commission</th>
                        <th>Address</th>
                        <th>Action</th>
                    </tr>
                </thead>
                <tbody>
                   
                </tbody>
            </table>

        </div>
    </div>
    <?php echo $__env->make('administrator.projects.confirm-delete', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>
    <?php $__env->stopSection(); ?>
    <?php $__env->startSection('js'); ?>
    <script type="text/javascript">
            $(document).ready(function() {
                $('#main-spinner').show();
                $('#datatable_project').DataTable({
                    ordering: true,
                    processing:true,
                    "serverSide": true,
                    ajax: {
                        url:"<?php echo e(route('datatable.get_projects')); ?>",
                        type:"GET",
                        data:function(d){
                            d.code = $("input[name=code]").val();
                            d.project_name = $("input[name=project_name]").val();
                        },
                    },
                    columns: [{
                        data: 'DT_RowIndex'
                    },
                    {data: 'feature'},
                    {
                        data: 'project_code'
                    }, {
                        data: 'project_name'
                    }, {
                        data: 'project_des'
                    }
                    ,{
                        data: 'commission_amount'
                    }
                    , {
                        data: 'commission'
                    }
                    , {
                        data: 'address'
                    }, {
                        data: 'action'
                    }, ],
                    "initComplete": function(settings, json) {
                        $('#main-spinner').hide();
                    }
                });

                $.fn.dataTable.ext.errMode = 'throw';
                $(document).on('click','.confirm_delete',function(){
                    var id = $(this).data('id');
                    $('#delete-id').val(id);
                    $('#form-delete').modal('show');
                });
                $('#form-delete-item').on('submit',function (e) {
                    e.preventDefault();
                    $.ajaxSetup({
                        headers: {
                            'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
                        }
                    });
                    var form = $('#form-delete-item').serialize();
                    $('#main-spinner').show();
                    $.ajax({
                        url:"<?php echo e(route('projects.delete')); ?>",
                        type:"POST",
                        dataType:"JSON",
                        data:form,
                        success:function (data) {
                            $('#main-spinner').hide();
                            $('#form-delete').modal('hide');
                            $('#datatable_item').DataTable().ajax.reload();
                            $('#delete-success').show();
                            $('#p-text').html(data.message);
                            $('#confirm-delete').removeAttr('disabled');
                            location.reload();
                        },
                        error:function (err) {
                            console.log(err);
                        }
                    });
                });
            });
    </script>
    <?php $__env->stopSection(); ?>
<?php echo $__env->make('adminlte::page', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>