  <?php $__env->startSection('content'); ?>
<?php Fun::lang()?>
    <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="#">Manage Stock</a></li>
                <li><a href="#">Items</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>Items</h3>
                        </div>
                    </div>
                    <div class="pull-right">
                        <?php if (app(\Illuminate\Contracts\Auth\Access\Gate::class)->check('Item-House-Create')): ?>
                        <a class="button_sm button_primary" href="<?php echo e(route('items.create')); ?>"><span class="fa fa-plus"></span>  Create House</a>
                        <?php endif; ?>
                        <a class="button_sm button_info" href="<?php echo e(route('items.create_condo')); ?>"><span class="fa fa-plus"></span>  Create Condo</a>
                        
                        
                        
                    </div>
                    <div class="pull-right">
                        <?php if (app(\Illuminate\Contracts\Auth\Access\Gate::class)->check('Item-Edit')): ?>
                        <a class="button_sm button_warning" href="<?php echo e(route('items.edit-multiple')); ?>"><span class="fa fa-edit"></span>  Raise Item Price</a>
                        <?php endif; ?>
                    </div>
                    <div class="pull-right">
                        <?php if (app(\Illuminate\Contracts\Auth\Access\Gate::class)->check('Item-Commission-Edit')): ?>
                        <a class="button_sm button_info" href="<?php echo e(route('items.edit-multiple-commission')); ?>"><span class="fa fa-edit"></span>  Update Commission</a>
                        <?php endif; ?>
                    </div>
                    
                        
                    
                </div>
            </div>
        </div>
       <div class="box-body table-responsive">
            <table id="datatable_item" class="table table-striped table-bordered table-hover nowrap">
                <thead>
                    <tr>
                        <th>NO</th>
                        <th>Category</th>
                        <th>Sub Category</th>
                        <th>Project</th>
                        <th>Item Group</th>
                        <th>Item Zone</th>
                        <th>Item Name</th>
                        <th>Real Estate Number</th>
                        <th>House Size</th>
                        <th>Land Size</th>
                        <th>Item Cost</th>
                        <th>Sale Price</th>
                        <th>Commission Amount</th>
                        <th>Commission</th>
                        <th>Status</th>
                        <th>Action</th>
                    </tr>
                </thead>
            </table>
        </div>
    </div>
    <?php echo $__env->make('administrator.items.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_item').DataTable({
                ordering: false,
                serverSide: true,
                lengthMenu: [[20, 30, 50, 100,200,500,1000], [20, 30, 50, 100,200,500,1000]],
                ajax: "<?php echo e(route('datatable.get_items')); ?>",
                columns:
                [
                    {data: 'DT_RowIndex','searchable': false},
                    {data: 'category_name','name':'nso007_category_stock.category_name'},
                    {data: 'sub_category_name','name':'nso007_sub_category_stock.sub_category_name'},
                    {data: 'project_name','name':'nso007_project_stock.project_name'},
                    {data: 'item_group_name','name':'nso007_item_group.item_group_name'},
                    {data: 'item_zone_name','name':'nso007_item_zone.item_zone_name'},
                    {data: 'item_house','name':'nso007_item_stock.item_house'},
                    {data: 'item_title_number','name':'nso007_item_stock.item_title_number'},
                    {data: 'item_size_house','name':'nso007_item_stock.item_size_house'},
                    {data: 'item_size_land','name':'nso007_item_stock.item_size_land'},
                    {data: 'item_cost','name':'nso007_item_stock.item_cost'},
                    {data: 'item_price','name':'nso007_item_stock.item_price'},
                    {data: 'commission_amount','searchable': false},
                    {data: 'commission','searchable': false},
                    {data: 'available','searchable': false},
                    {data: 'action','searchable': false},
                ],

                "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('items_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');
                    },
                    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(); ?>