
<?php $__env->startSection('content'); ?>
    <!-- begin::main content -->
    <main class="main-content">
        <div class="container">
            <!-- begin::page header -->
            <div class="page-header">
                <h3>Debit Note 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">
                <?php if (isset($component)) { $__componentOriginal8a5ba9c90b64d384232e9948b1023e746ba08e74 = $component; } ?>
<?php $component = $__env->getContainer()->make(App\View\Components\FlashMessage::class, []); ?>
<?php $component->withName('flashMessage'); ?>
<?php if ($component->shouldRender()): ?>
<?php $__env->startComponent($component->resolveView(), $component->data()); ?>
<?php $component->withAttributes([]); ?>
<?php echo $__env->renderComponent(); ?>
<?php endif; ?>
<?php if (isset($__componentOriginal8a5ba9c90b64d384232e9948b1023e746ba08e74)): ?>
<?php $component = $__componentOriginal8a5ba9c90b64d384232e9948b1023e746ba08e74; ?>
<?php unset($__componentOriginal8a5ba9c90b64d384232e9948b1023e746ba08e74); ?>
<?php endif; ?>
                    <div class="row mt-3">
                        <div class="col-md-5">
                            <form action="<?php echo e(asset('account/debit-note')); ?>" 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="Debit Note Number" 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/debit-note')); ?>"><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/debit-note')); ?>">
                                                    <div class="form-group">
                                                        <label>Date</label>
                                                        <input value="<?php echo e(isset($_GET['date']) ? $_GET['date'] : null); ?>" type="date" name="date" class="form-control" >
                                                    </div>
                                                    
                                                            <div class="form-group ">
                                                                <label>Bill Number</label>
                                                                <input type="text" name="bill_number" value="<?php echo e(isset($_GET['bill_number']) ? $_GET['bill_number'] : null); ?>" class="form-control" >
                                                            </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/debit-note')); ?>" class="btn btn-primary px-3 text-white">Clear</a>
                                                        </div>
                                                    </div>
                                                </form>
                                            </div>
                                        </div>
                                </div>
                            </form>
                        </div>
                        <div class="col-md-4"></div>
                        <div class="col-md-3 d-flex justify-content-end">
                            <div>
                            
                                <a data-toggle="tooltip" data-original-title="Add debit Note"
                                    href="<?php echo e(asset('account/add-debit-note')); ?>" class="btn m-r-10 btn-outline-secondary pull-left">
                                    <i class="ti ti-plus fa-lg"></i>
                                </a>
                                <button data-toggle="tooltip" data-original-title="Delete All"
                                     class="btn m-r-10 btn-outline-secondary pull-left delete_all_invoice">
                                    <i class="ti ti-trash fa-lg"></i>
                                </button>
                                <button title="Export Delivery Challan"
                                    data-toggle="modal" data-target="#invoiceModal"
                                     class="btn m-r-10 btn-outline-secondary pull-left">
                                    <i class="fa fa-download fa-lg"></i>
                                </button>
                            </div>
                        </div>
                    </div>
                </div>

                <div class="card-body">

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

                        <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>DEBIT NOTE NO.</th>
                                        <th>BILL NO.</th>
                                        <th>BILL DATE</th>                                                                             
                                        <th>DATE</th>
                                        <th>VENDOR</th>
                                        <th>STATUS</th>
                                        <th>ACTION</th>
                                    </tr>
                                </thead>
                                <tbody>
                                    <?php if(!empty($debit_notes)): ?>
                                        <?php $__currentLoopData = $debit_notes; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $key=>$value): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                       
                                           <tr>
                                                <td>
                                                    <input type="checkbox" class="check_invoice" value="<?php echo e($value->id); ?>" />
                                                </td>
                                                <td><?php echo e(++$key); ?></td>
                                                <td>
                                                    <?php echo e($value->debit_note_number); ?>

                                                </td>
                                                <td>
                                                    <?php echo e($value->bill_number); ?>

                                                </td>
                                                <td><?php echo e($value->bill_date); ?></td>
                                                <td><?php echo e($value->date); ?></td>
                                
                                                <td><?php echo e($value->customer_name); ?></td>
                                                <td>
                                                    <select class="form-control change_quote_status" quotes_id="<?php echo e($value->id); ?>">
                                                        <option value="pending" <?php echo e($value->status == "pending" ? "selected" : ''); ?>>Pending</option>
                                                        <option value="reject" <?php echo e($value->status == "reject" ? "selected" : ''); ?>>Reject</option>
                                                        <option value="accept" <?php echo e($value->status == "accept" ? "selected" : ''); ?>>Accept</option>
                                                    </select>
                                                </td>
                                                
                                                <td>
                                                    
                                              
                                                <div class="btn-group">
                                                        <!-- <a class="btn btn-sm btn-outline-info" href="<?php echo e(asset('account/get-invoice/'.$value->id)); ?>"><i class="fa fa-eye"></i></a> -->
                                                        <a class="btn btn-sm btn-outline-info" href="<?php echo e(asset('account/edit-debit-note/'.$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="Debit Note Invoice"  ><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($debit_notes->links('pagination::bootstrap-4')); ?> 
                        </div>
                        
                    <?php endif; ?>
                </div>
            </div>
        </div>
        <!-- The Modal -->
        <div class="modal" id="invoiceModal">
            <div class="modal-dialog modal-lg">
                <div class="modal-content">

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

                <!-- Modal body -->
                <div class="modal-body">
                    <p><strong>Please select the document period.</strong></p>
                    <form action="<?php echo e(asset('account/export-debit-note')); ?>" method="get">
                        <div class="row">
                            <div class="col-md-6">
                                <div class="form-group">
                                    <label>Start Date</label>
                                    <input type="date" name="start_date" class="form-control">
                                </div>
                            </div>
                            <div class="col-md-6">
                                <div class="form-group">
                                    <label>End Date</label>
                                    <input type="date" name="start_date" class="form-control">
                                </div>
                            </div>
                        </div>
                        
                        <div class="d-flex justify-content-end">
                            <button type="submit" class="btn btn-success">Export</button>
                        </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() {
                $('.check_invoice: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: "post",
                            data: {
                                "id": id
                            },
                            url: "<?php echo e(asset('account/delete-debit-note')); ?>",
                            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_all_invoice").click(function() {
                var URL = "<?php echo e(asset('account/multiple-delete-debit-note')); ?>";
                var parent_ids = [];
                $('.check_invoice: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();
                            },
                            error: function(xhr)
                            {
                                swal("failed!", "failed !", "error");
                                window.location.reload();
                            }
                        });
                    }
                });
            });

            $(".change_quote_status").on("change",function(){
                var status = $(this).val();
                var id = $(this).attr("quotes_id");

                        $.ajax({
                            type: "post",
                            headers: {
                                'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
                            },
                            data: {
                                id,
                                status
                            },
                            url: "<?php echo e(asset('account/debit-note-status-change')); ?>",
                            dataType: "html",
                            success: function(result) 
                            {
                                toastr.success("debit note status changed !");
                            },
                            error: function(error,xhr,status)
                            {
                                toastr.error("Failed !");
                            }
                        });
            });

            $(".purpose-btn").click(function(){
                
                $("#purposeModal").modal();
            });
            
        });
    </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/debit_note/list.blade.php ENDPATH**/ ?>