
<?php $__env->startSection('content'); ?>
<style>
    .input_upload{
            width:100px;
            height:35px;
            position:absolute;
            bottom:-34px;
            right:350px;
        }
</style>
    <!-- begin::main content -->
    <main class="main-content">
        <div class="container">
            <!-- begin::page header -->
            <div class="page-header">
                <h3>Item List</h3>
                <nav aria-label="breadcrumb">
                    <ol class="breadcrumb">
                        <li class="breadcrumb-item"><a href="<?php echo e(asset('dashboard')); ?>"><?php echo e(__('message.dashboard')); ?></a></li>
                        <li class="breadcrumb-item active" aria-current="page"><?php echo e(__('message.list')); ?></li>
                    </ol>
                </nav>
            </div>
            <!-- end::page header -->
            <div class="card">

                <div class="card-header">
                    
                    <div class="row mt-3">
                        <div class="col-md-5">
                            <form action="<?php echo e(asset('account/item')); ?>" method="get">
                                
                                <div class="company-field-box">
                                        <div>
                                            <div class="input-group">
                                                <div class="input-group-prepend">
                                                    <button type="button" class="btn border input-group-text filter-company-btn px-4">
                                                        <i class="ti ti-filter fa-lg"></id></i>
                                                    </button>
                                                </div>
                                                    
                                                    <input type="search" value="<?php echo e(isset($_GET['search']) ? $_GET['search'] : null); ?>" name="search" placeholder="Item Name" class="form-control border-right-0 seach-input">
                                                    <button class="btn border border-left-0" type="submit" style="margin-left:-5px;">
                                                        <i class="ti ti-search fa-lg"></i>
                                                    </button>
                                                    <a class="btn btn-white border" href="<?php echo e(asset('account/item')); ?>"><i class="ti ti-reload fa-lg"></i></a>
                                                    
                                            </div>
                                            <div class="filter-form-box d-none">
                                                <div class="diamond"></div>
                                                <form method="get" action="<?php echo e(asset('account/item')); ?>">
                                                    <div class="form-group">
                                                        <label>Name</label>
                                                        <input value="<?php echo e(isset($_GET['name']) ? $_GET['name'] : null); ?>" type="text" name="name" class="form-control" >
                                                    </div>
                                                    <div class="form-group row">
                                                            <div class="form-group col-6">
                                                                <label>Designation</label>
                                                                <input type="text" name="designation" value="<?php echo e(isset($_GET['designation']) ? $_GET['designation'] : null); ?>" class="form-control" >
                                                            </div>

                                                            <div class="form-group col-6">
                                                                <label>Received Date</label>
                                                                <input type="date" name="received_date" value="<?php echo e(isset($_GET['received_date']) ? $_GET['received_date'] : null); ?>" class="form-control" >
                                                            
                                                            </div>
                                                    </div>
                                                                                                        
                                                    <div class="row">
                                                        <div class="form-group col-6">
                                                            <label>Department</label>
                                                            <select class="form-control" name="department">
                                                                <option selected disabled>SELECT</option>
                                                                
                                                            </select>
                                                           
                                                        </div>
                                                        
                                                        <div class="form-group col-6">
                                                            <?php $award = isset($_GET['award_type_id']) ? $_GET['award_type_id'] : null; ?>
                                                            <label>Award Type</label>
                                                            <select class="form-control" name="award_type_id">
                                                                <option selected disabled>SELECT</option>
                                                                
                                                            </select>
                                                        </div>
                                                        
                                                    </div>
                                                    <div class="row">
                                                        <div class="form-group col-6">
                                                            <label>Start Date</label>
                                                            <input type="date" name="start_date" value="<?php echo e(isset($_GET['start_date']) ? $_GET['start_date'] : null); ?>"  class="form-control" id="start_date">
                                                        </div>
                                                        
                                                        <div class="form-group col-6">
                                                            <label>End Date</label>
                                                            <input type="date" name="end_date" value="<?php echo e(isset($_GET['end_date']) ? $_GET['end_date'] : null); ?>" class="form-control" id="end_date">
                                                        </div>
                                                        
                                                    </div>
                                                    <div class="row">
                                                        <div class="form-group col-12 d-flex justify-content-end">
                                                            <button type="submit" class="btn btn-success mr-5 px-4 apply-button">Apply </button>
                                                        
                                                            <a href="<?php echo e(asset('account/item')); ?>" class="btn btn-primary px-3 text-white">Clear</a>
                                                        </div>
                                                    </div>
                                                </form>
                                            </div>
                                        </div>
                                </div>
                            </form>
                        </div>
                        <div class="col-md-1"></div>
                        <div class="col-md-6 d-flex justify-content-end">
                            <div>
                                <a data-toggle="tooltip" data-original-title="Add Item"
                                    href="<?php echo e(asset('account/add-item')); ?>" class="btn m-r-10 btn-outline-secondary pull-left">
                                    <i class="ti ti-plus fa-lg"></i>
                                </a>
                                <button data-toggle="tooltip" id="delete-multiple" data-original-title="Delete All"
                                     class="btn m-r-10 btn-outline-secondary pull-left">
                                    <i class="ti ti-trash fa-lg"></i>
                                </button>
                            </div>
                            <div>
                                <a data-toggle="tooltip" data-original-title="Export Items"
                                    href="<?php echo e(asset('account/export-items')); ?>"
                                    class="btn btn-outline-secondary text-uppercase mr-2"><i
                                        class="fa fa-download fa-lg"></i>
                                </a>
                            </div>

                            <div>
                                <button type="button" class="btn btn-outline-secondary text-uppercase  mr-2" data-toggle="modal" data-target="#importModal"><i
                                        class="fa fa-upload fa-lg"></i>
                                        
                                </button>
                            </div>
                        </div>
                    </div>
                </div>

                <div class="card-body">

                    <?php if(isset($items)): ?>

                        <div class="table-responsive">
                            <table class="table table-striped table-bordered">
                                <thead>
                                    <tr>
                                        <th>
                                            <input type="checkbox" id="checkAll" />
                                        </th>
                                        <th class="wrap">S.NO</th>
                                        <th>NAME</th>
                                        <th>CATEGORY</th>
                                        <th>DESCRIPTION</th>                                                                             
                                        <th>ACTION</th>
                                    </tr>
                                </thead>
                                <tbody>
                                    <?php if(!empty($items)): ?>
                                        <?php $__currentLoopData = $items; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $key=>$value): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                       
                                           <tr>
                                                <td>
                                                    <input type="checkbox" class="item_check" value="<?php echo e($value->id); ?>" />
                                                </td>
                                                <td><?php echo e(++$key); ?></td>
                                                <td>
                                                    <?php echo e($value->name); ?> 
                                                </td>
                                                <td>
                                                    <?php echo e($value->cat_name ?? "Uncategorized"); ?>

                                                </td>
                                                <td><?php echo e($value->description); ?></td>
                                                
                                                <td>
                                                    
                                              
                                                <div class="btn-group">
                                                        <a class="btn btn-sm btn-outline-info" href="<?php echo e(asset('account/edit-item/'.$value->id)); ?>"><i class="fa fa-pencil"></i></a>
                                                        
                                                        <button class="btn btn-sm btn-outline-danger reg-delete-btn" reg_id="<?php echo e($value->id); ?>" data-toggle="tooltip"
                                                            data-original-title="Delete Item"  ><i
                                                                class="ti ti-trash fa-lg"></i>
                                                        </button>
                                                        
                                                    </div>
                                                </td>
                                           </tr>
                                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                    <?php else: ?>
                                        <h1>No Record Found!!</h1>
                                    <?php endif; ?>
                                </tbody>
                            </table>
                        </div>

                        
                        <div class="mt-3 d-flex justify-content-center">
                        <?php echo e($items->links('pagination::bootstrap-4')); ?> 
                        </div>
                        
                    <?php endif; ?>
                </div>
            </div>
        </div>

        <!-- The Modal -->
        <div class="modal" id="importModal">
        <div class="modal-dialog modal-dialog-centered">
            <div class="modal-content">

            <!-- Modal Header -->
            <div class="modal-header bg-success  rounded-0">
                <h4 class="modal-title">Import Items</h4>
                <button type="button" class="close" data-dismiss="modal">&times;</button>
            </div>

            <!-- Modal body -->
            <div class="modal-body">
                <div class="row">
                    <div class="col-md-3 py-5">
                        <i class="fa fa-warning text-warning" style="font-size:50px"></i>
                    </div>
                    <div class="col-md-9 import-content">
                        <p>Import Items (.xls, .xlsx)</p>
                        <p><strong>Follow these steps:</strong></p>
                        <p>1. Download the Excel template to your computer by clicking the <strong>Download</strong> button.</p>
                        <p>2. Integrate your data into the template file, minding the column names.</p>
                        <p>3. Click the <strong>Import</strong> button.</p>
                        <p><strong>IMPORTANT</strong></p>
                        <p>- If you do not have data for a particular column, leave it empty and do not move or delete the column.</p>
                        
                    </div>
                </div>
            

                                
            </div>

            <!-- Modal footer -->
            <div class="modal-footer position-relative">
                <form  class="import-customer-form" enctype="multipart/form-data">
                <?php echo csrf_field(); ?>
                <div class="">
                    <div class="">
                        <div class="" style="position:relative">
                            <input type="file" accept="" name="excel_file" class="input_upload input_file_upload" style="z-index:5;opacity:0;cusor:pointer;">
                            <button type="submit" class="btn btn-success text-uppercase input_upload input_upload_btn text-white mr-2">
                            <i class="fa fa-upload pr-2"></i>
                                    Import
                            </button>
                        </div>
                    </div>
                    <div class="">
                        <div class="d-flex justify-content-center">
                            <a href="<?php echo e(asset('public/item_sample.xlsx')); ?>" class="btn btn-info" download>Download Sample &nbsp<i class="fa fa-download"></i></a>
                        </div>
                        
                    </div>
                </div>    
                    
                    
                </form>
            </div>

            </div>
        </div>
        </div>



    </main>
    <!-- end::main content -->
<?php $__env->stopSection(); ?>
<?php $__env->startPush('footer-script'); ?>
    <!-- begin::dataTable -->
    <script src="<?php echo e(asset('public/admin/js/examples/datatable.js')); ?>"></script>
    <!-- end::dataTable -->
    <script>
        $(document).ready(function() {
            $(".filter-company-btn").click(function(){
            
                if($(".filter-form-box").hasClass("d-none"))
                {
                    $(".filter-form-box").removeClass("d-none");
                }
                else
                {
                    $(".filter-form-box").addClass("d-none");
                }
            });

            $(".reset_password_btn").click(function(){
                var user_id = $(this).attr("user_id");
                $("#user_unique_id").val(user_id);
            });

            $("#checkAll").click(function() {
                $('.item_check:checkbox').not(this).prop('checked', this.checked);
            });
            
            
            $(".reg-delete-btn").click(function(){
                var id = $(this).attr("reg_id");
               
                swal({
                    title: 'Are you sure?',
                    text: 'Once deleted, you will not be recover!',
                    icon: 'warning',
                    dangerMode: true,
                    buttons: ["Cancel", "Yes!"],
                }).then(function(value) {
                    if (value) {
                        $.ajaxSetup({
                            headers: {
                                'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
                            }
                        });
                        $.ajax({
                            type: "delete",
                            data: {
                                "id": id
                            },
                            url: "<?php echo e(asset('account/delete-item')); ?>",
                            dataType: "html",
                            success: function(result) 
                            {
                                swal("success!", "Successfully deleted!", "success");
                                window.location.reload();
                            },
                            error: function(error,xhr,status)
                            {
                                swal("failed!", "failed to delete!", "error");
                               window.location.reload();
                            }
                        });
                       
                    }
                });
                
            });

            $("#delete-multiple").click(function() {
                var URL = "<?php echo e(asset('account/multiple-delete-item')); ?>";
                var parent_ids = [];
                $('.item_check:checkbox:checked').each(function() {
                    parent_ids.push($(this).val());
                });
                swal({
                    title: 'Are you sure?',
                    text: 'Once deleted, you will not be recover!',
                    icon: 'warning',
                    dangerMode: true,
                    buttons: ["Cancel", "Yes!"],
                }).then(function(value) {
                    if (value) {
                        $.ajaxSetup({
                            headers: {
                                'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
                            }
                        });
                        $.ajax({
                            type: "post",
                            data: {
                                "ids": parent_ids
                            },
                            url: URL,
                            dataType: "html",
                            success: function(result) {}
                        });
                        swal("success!", "Successfully deleted!", "success");
                        window.location.reload();
                    }
                });
            });

            $(".input_file_upload").on("change",function(){
                $(".import-customer-form").submit();
            });

            $(".import-customer-form").on("submit", function(event) {
                    // Prevent the default form submission
                    event.preventDefault();
                    
                    
                    $.ajax({
                        type: "POST",
                        url: "<?php echo e(asset('account/import-items')); ?>",
                        headers: {
                                'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
                            },                       
                        data: new FormData(this), 
                        processData: false,
                        contentType: false,
                        cache:false,
                        beforeSend:function()
                        {
                            $(".import-content").html("<h5>Please wait uploading...</h5>");
                        },
                        success: function(response) 
                        {
                            if(response.message=="success")
                            {
                                var div = `<div class='text-success text-center' style='font-size:50px'>
                                <i class='fa fa-check-circle' ></i>
                                <p  style='font-size:20px'>Items Import Successfully !</p>
                            </div>`;
                                $(".import-content").html(div);
                                setTimeout(function(){
                                    window.location.reload();
                                },3000);
                                
                            }
                            else
                            {
                                //console.log(error);
                                var div = `<div class='text-danger text-center' style='font-size:50px'>
                                <i class='fa fa-times-circle' ></i>
                                <p  style='font-size:20px'>Please check the datasheet !</p>
                            </div>`;
                                $(".import-content").html(div);
                            }
                        },
                        error: function(xhr, status, error) 
                        {
                            //console.log(error);
                            var div = `<div class='text-danger text-center' style='font-size:50px'>
                            <i class='fa fa-times-circle' ></i>
                            <p  style='font-size:20px'>Please check the datasheet !</p>
                        </div>`;
                            $(".import-content").html(div);
                        }
                    });
            });
            
        });
    </script>
<?php $__env->stopPush(); ?>

<?php echo $__env->make('layout', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH /var/www/peoplebee.in/accounts-admin/resources/views/accounting/item/list.blade.php ENDPATH**/ ?>