<?php $__env->startSection('section-title', 'Damage'); ?>
<?php $__env->startSection('page-title', 'Damage List'); ?>
<?php if(check_permission('damage.create')): ?>
    <?php $__env->startSection('action-button'); ?>
        <a href="<?php echo e(route('damage.create')); ?>" class="btn add_list_btn">
            <i class="mr-2 feather icon-plus"></i>
            Add Damage
        </a>
    <?php $__env->stopSection(); ?>
<?php endif; ?>
<?php $__env->startSection('content'); ?>
    <div class="row">
        <div class="col-lg-12">
            <div class="card card-body card_style mb-2" style="margin-top: -3px" id="h-hide">
                <form action="<?php echo e(route('damage.index')); ?>">
                    <div class="form-row">
                        <div class="form-group col-md-4">
                            <select class="select2" name="product_id">
                                <option selected value="">Select Product</option>
                                <?php $__currentLoopData = $products; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $product): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                    <option value="<?php echo e($product->id); ?>" <?php if(isset($oneProduct)): ?> <?php if($product->id == $oneProduct->id): ?> selected <?php endif; ?> <?php endif; ?>><?php echo e($product->name); ?></option>
                                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                            </select>
                        </div>
                        <div class="form-group col-md-4">
                            <input type="date" name="start_date" class="form-control" value="<?php echo e((isset($sdate))?date('Y-m-d', strtotime($sdate)):''); ?>">
                        </div>
                        <div class="form-group col-md-4">
                            <input type="date" name="end_date" class="form-control" value="<?php echo e((isset($edate))?date('Y-m-d', strtotime($edate)):''); ?>">
                        </div>
                    </div>
                    <div class="form-row mt-2">
                        <div class="form-group col-12">
                            <button class="btn add_list_btn" type="submit">
                                    <i class="fa fa-sliders"></i> Filter
                            </button>
                            <a href="<?php echo e(route('damage.index')); ?>" class="btn add_list_btn_reset">Reset</a>
                            <a href="" class="btn add_list_btn float-right" onclick="window.print()">Print</a>
                        </div>
                    </div>
                </form>
            </div>
            <div class="card m-b-30 card_style">
                <div class="card-body">
                    <div class="table-responsive">
                        <table id="datatable-buttons" class="table table-striped text-center">
                            <thead class="header_bg">
                                <tr>
                                    <th class="header_style_left">#SL</th>
                                    <th>Date</th>
                                    <th>Product Name</th>
                                    <th>Amount</th>
                                    <th class="header_style_right">Action</th>
                                </tr>
                            </thead> 
                            <tbody>
                                <?php
                                    $sub_total = 0;
                                ?>
                                <?php $__empty_1 = true; $__currentLoopData = $damages; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $key => $data): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
                                <?php
                                    $sub_total += $data->total_amount;
                                ?>
                                    <tr>
                                        
                                        <td class="table_data_style_left"><?php echo e($key + 1); ?></td>
                                        <td><?php echo e($data->date); ?></td>
                                        <td>
                                            <?php $__currentLoopData = $data->damageItems; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $item): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                                <ul>
                                                    <?php if($item->product->unit->related_unit == null): ?>
                                                        <li><?php echo e($item->product?->name); ?> (<?php echo e($item->rate); ?> * <?php echo e($item->main_qty ." ". $item->product->unit->name); ?> = <?php echo e($item->subtotal); ?>)</li>
                                                    <?php else: ?>
                                                    <li><?php echo e($item->product?->name); ?> (<?php echo e($item->rate); ?> * <?php echo e($item->main_qty ." ". $item->product->unit->name ." ". $item->sub_qty . " ".$product->unit->related_unit->name); ?> = <?php echo e($item->subtotal); ?>)</li>
                                                    <?php endif; ?>
                                                </ul>
                                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                        </td>
                                        <td><?php echo e($data->total_amount); ?></td>
                                        <td class="table_data_style_right">

                                            <div class="dropdown">
                                                <button class="btn add_extra_btn btn-sm dropdown-toggle" type="button"
                                                    id="dropdownMenuButton" data-toggle="dropdown">
                                                    Action
                                                </button>
                                                <div class="dropdown-menu" aria-labelledby="dropdownMenuButton">
                                                    

                                                    
                                                    <?php if(check_permission('damage.delete')): ?>
                                                        <a class="dropdown-item text-danger" href="#"
                                                            data-toggle="modal" data-target="#deleteModal-<?php echo e($data->id); ?>">
                                                            <i class="feather icon-trash"></i> Delete
                                                        </a>
                                                    <?php endif; ?>
                                                </div>
                                            </div>
                                        </td>
                                    </tr>

                                    
                                    <form action="<?php echo e(route('damage.delete', $data->id)); ?>" method="POST">
                                        <?php echo csrf_field(); ?>
                                        <?php if (isset($component)) { $__componentOriginal37b7f052626c638ba0443fdb400d6f57 = $component; } ?>
<?php if (isset($attributes)) { $__attributesOriginal37b7f052626c638ba0443fdb400d6f57 = $attributes; } ?>
<?php $component = App\View\Components\DeleteModal::resolve([] + (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag ? (array) $attributes->getIterator() : [])); ?>
<?php $component->withName('delete-modal'); ?>
<?php if ($component->shouldRender()): ?>
<?php $__env->startComponent($component->resolveView(), $component->data()); ?>
<?php if (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag && $constructor = (new ReflectionClass(App\View\Components\DeleteModal::class))->getConstructor()): ?>
<?php $attributes = $attributes->except(collect($constructor->getParameters())->map->getName()->all()); ?>
<?php endif; ?>
<?php $component->withAttributes(['title' => 'Damage','id' => ''.e($data->id).'']); ?>
<?php echo $__env->renderComponent(); ?>
<?php endif; ?>
<?php if (isset($__attributesOriginal37b7f052626c638ba0443fdb400d6f57)): ?>
<?php $attributes = $__attributesOriginal37b7f052626c638ba0443fdb400d6f57; ?>
<?php unset($__attributesOriginal37b7f052626c638ba0443fdb400d6f57); ?>
<?php endif; ?>
<?php if (isset($__componentOriginal37b7f052626c638ba0443fdb400d6f57)): ?>
<?php $component = $__componentOriginal37b7f052626c638ba0443fdb400d6f57; ?>
<?php unset($__componentOriginal37b7f052626c638ba0443fdb400d6f57); ?>
<?php endif; ?>
                                    </form>

                                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
                                    <tr>
                                        <td colspan="100%" class="text-center no_data_style text-danger">No Data Available</td>
                                    </tr>
                                <?php endif; ?>
                            </tbody>
                            <tfooter>
                                <tr class="footer_style" style=" font-size: 20px; font-width: 700; font-family:sans-serif">
                                    <td colspan="2" class="table_data_style_left"></td>
                                    <td colspan="1" class="text-right text-white"> <strong> Total Price: </strong></td>
                                    <td colspan="2" class="text-left text-white table_data_style_right"><strong> <?php echo e(number_format($sub_total,2)); ?> TK </strong></td>
                                </tr>
                            </tfooter>
                        </table>
                    </div>
                </div>
            </div>
        </div>
    </div>
<?php $__env->stopSection(); ?>

<?php echo $__env->make('backend.layouts.master', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH D:\laragon\www\new demo multi-bank\resources\views/backend/pages/damage/index.blade.php ENDPATH**/ ?>