
<?php $__env->startSection('title'); ?>
    Report - <?php echo e($title); ?>

<?php $__env->stopSection(); ?>

<?php $__env->startSection('styles'); ?>
    <style>
        .bootstrap-switch-large {
            width: 200px;
        }
    </style>
<?php $__env->stopSection(); ?>

<?php $__env->startSection('navbar-content'); ?>
    <div class="content-header">
        <div class="container-fluid">
            <div class="row mb-2">
                <div class="col-sm-6">
                    <h1 class="m-0">
                        Report </h1>
                </div><!-- /.col -->

            </div><!-- /.row -->
        </div><!-- /.container-fluid -->
    </div>
<?php $__env->stopSection(); ?>

<?php $__env->startSection('admin-content'); ?>
    <div class="row">

        <div class="col-md-12">
            <form action="<?php echo e(route('report.purchase.purchase')); ?>" method="POST" enctype="multipart/form-data">
                <?php echo csrf_field(); ?>
                <div class="card card-outline card-info no-print">
                    <div class="card-body">
                        <div class="row  no-print">
                            <div class="box-header with-border" style="cursor: pointer;">
                                <h6 class="box-title">
                                    <i class="fa fa-filter" aria-hidden="true"></i> Filters
                                </h6>
                            </div>
                        </div>

                        <div class="row no-print">
                            <div class="col-md-2">
                                <div class="form-group">
                                    <label>Date Range:</label>
                                    <input type="text" class="form-control" value="<?php echo e($request->dateRange); ?>"
                                        name="dateRange" value="" id="reservation" />
                                    <?php $__errorArgs = ['dateRange'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?>
                                        <span class="error text-red text-bold"> <?php echo e($message); ?></span>
                                    <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
                                </div>
                            </div>
                            <div class="col-md-2">
                                <div class="form-group">
                                    <label>Type </label>
                                    <select class="form-control select2" name="type" id="typeSelect">
                                        <option value="Branch">Branch</option>
                                        <option value="Project">Project</option>
                                    </select>
                                </div>
                            </div>

                            <div class="col-md-2" id="branchSelect">
                                <div class="form-group">
                                    <label>Branch </label>
                                    <select class="form-control select2" name="branch_id">
                                        <option value="all" selected>All branches</option>
                                        <?php $__currentLoopData = $branch; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $key => $value): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                            <option <?php echo e($branch_id == $value->id ? 'selected' : ''); ?>

                                                value="<?php echo e($value->id); ?>">
                                                <?php echo e($value->branchCode . ' - ' . $value->name); ?>

                                            </option>
                                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                    </select>
                                    <?php $__errorArgs = ['branch_id'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?>
                                        <span class="error text-red text-bold"> <?php echo e($message); ?></span>
                                    <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
                                </div>
                            </div>

                            <div class="col-md-2" id="projectSelect">
                                <div class="form-group">
                                    <label>Project </label>
                                    <select class="form-control select2" name="project_id">
                                        <option value="all" selected>All Project</option>
                                        <?php $__currentLoopData = $projects; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $key => $value): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                            <option <?php echo e($project_id == $value->id ? 'selected' : ''); ?>

                                                value="<?php echo e($value->id); ?>">
                                                <?php echo e($value->name); ?>

                                            </option>
                                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                    </select>
                                    <?php $__errorArgs = ['project_id'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?>
                                        <span class="error text-red text-bold"> <?php echo e($message); ?></span>
                                    <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
                                </div>
                            </div>
                            <div class="col-md-2">
                                <div class="form-group">
                                    <label>Product </label>
                                    <select class="form-control select2 " name="product_id">
                                        <option value="all" selected>All Products</option>
                                        <?php $__currentLoopData = $product; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $key => $value): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                            <option <?php echo e($product_id == $value->id ? 'selected' : ''); ?>

                                                value="<?php echo e($value->id); ?>">
                                                <?php echo e($value->productCode . ' - ' . $value->name); ?>

                                            </option>
                                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                    </select>
                                    <?php $__errorArgs = ['product_id'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?>
                                        <span class="error text-red text-bold"> <?php echo e($message); ?></span>
                                    <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
                                </div>
                            </div>
                            <div class="col-md-2">
                                <div class="form-group">
                                    <label>Ledger </label>
                                    <select class="form-control select2 supid" name="ledger_id" id="ledger_id">
                                        <option value="all">All</option>
                                        <?php if (isset($component)) { $__componentOriginalc254754b9d5db91d5165876f9d051922ca0066f4 = $component; } ?>
<?php $component = $__env->getContainer()->make(Illuminate\View\AnonymousComponent::class, ['view' => 'components.account','data' => ['setAccounts' => $ledgers]]); ?>
<?php $component->withName('account'); ?>
<?php if ($component->shouldRender()): ?>
<?php $__env->startComponent($component->resolveView(), $component->data()); ?>
<?php $component->withAttributes(['setAccounts' => \Illuminate\View\Compilers\BladeCompiler::sanitizeComponentAttribute($ledgers)]); ?>
<?php echo $__env->renderComponent(); ?>
<?php endif; ?>
<?php if (isset($__componentOriginalc254754b9d5db91d5165876f9d051922ca0066f4)): ?>
<?php $component = $__componentOriginalc254754b9d5db91d5165876f9d051922ca0066f4; ?>
<?php unset($__componentOriginalc254754b9d5db91d5165876f9d051922ca0066f4); ?>
<?php endif; ?>
                                    </select>
                                </div>
                            </div>
                            <div class="col-md-2">
                                <div class="form-group">
                                    <label>&nbsp;</label><br>
                                    <button type="submit" class="btn btn-sm btn-success"><i class="fa fa-search"></i>
                                        Search</button>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
                <div id="load_data"></div>
            </form>
        </div>
        <?php
            // dd($purchaseDetails);
        ?>
        <?php if(isset($purchaseDetails) && !empty($purchaseDetails)): ?>
            <div class="col-md-12">
                <div class="card card-default">
                    <div class="card-header no-print">
                        <h3 class="card-title">Purchse Report</h3>
                        <a onclick="window.print()" target="_blank" class="btn btn-default float-right my-2 no-print"><i
                                class="fas fa-print"></i>
                            Print</a>
                        <div id="tableActions" class=" float-right my-2 no-print"></div>
                    </div>
                    <div class="card-body">

                        <div class="invoice p-3 mb-3">
                            <div class="row">
                                <div class="col-12 table-responsive">
                                    <table class="table  table-bordered">
                                        <tr>
                                            <td style="text-align: center">
                                                <?php if(isset($companyInfo->logo)): ?>
                                                    <a href="<?php echo e(route('home')); ?>">
                                                        <img width="200px"
                                                            src="<?php echo e(asset('/backend/logo/' . $companyInfo->logo)); ?>"
                                                            style="" alt="">
                                                    </a>
                                                <?php endif; ?>
                                            </td>
                                            <td width="70%" style="text-align: center">
                                                <h3>Purchase Report</h3>
                                                <h4><b>From Date: <?php echo e($from_date); ?></b>, <b>To date: <?php echo e($to_date); ?>

                                                    </b></h4>
                                            </td>
                                        </tr>
                                    </table>
                                    <div class="table-responsive">
                                        <table id="datatablexcel"
                                            class="display table-hover table table-bordered table-striped">
                                            <thead>
                                                <tr>
                                                    <th>SL</th>
                                                    <th>Date</th>
                                                    <?php if($request->type == 'Branch'): ?>
                                                        <th>Branch</th>
                                                    <?php else: ?>
                                                        <th>Project</th>
                                                    <?php endif; ?>
                                                    <th>Supplier</th>
                                                    <th>Category</th>
                                                    <th>Product</th>
                                                    <th>Purchase Price</th>
                                                    <th>Quantiry</th>
                                                    <th>Total</th>
                                                </tr>
                                            </thead>
                                            <tbody>

                                                <?php $__currentLoopData = $purchaseDetails; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $key => $item): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                                    <tr>
                                                        <td><?php echo e($key + 1); ?></td>
                                                        <td><?php echo e($item->date); ?></td>
                                                        <td>
                                                        <?php if($request->type == 'Branch'): ?>
                                                            <?php echo e($item->branch->branchCode . ' - ' . $item->branch->name); ?>

                                                            <?php else: ?>
                                                            <?php echo e($item->branch->branchCode . ' - ' . $item->branch->name); ?>

                                                        <?php endif; ?>
                                                        </td>
                                                        <td><?php echo e($item->supcode . ' - ' . $item->supname); ?></td>
                                                        <td><?php echo e($item->catname); ?></td>
                                                        <td><?php echo e($item->pcode . ' - ' . $item->pname); ?></td>

                                                        <td align="right"><?php echo e($item->unit_price); ?></td>
                                                        <td align="right"><?php echo e($item->quantity); ?></td>
                                                        <td align="right"><?php echo e($item->total_price); ?></td>
                                                    </tr>
                                                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                            </tbody>
                                            <tfoot>
                                                <tr>
                                                    <th colspan="6" style="text-align: center">Total</th>
                                                    <th style="text-align: right;"><?php echo e($ttlppruchasePrice ?? ''); ?></th>
                                                    <th style="text-align: right;"><?php echo e($ttlQty ?? ''); ?></th>
                                                    <th style="text-align: right;"><?php echo e($grandTotal ?? ''); ?></th>
                                                </tr>
                                            </tfoot>

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




                                <div class="col-md-4  float-left">
                                    <br>
                                    <br>

                                    <p>Prepared By:_____________<br />
                                        Date:____________________
                                    </p>
                                </div>
                                <div class="col-md-6 text-center">
                                </div>
                                <div class="col-md-2  ">
                                    <br>
                                    <br>
                                    <p>Approved By:________________<br />
                                        Date:_________________</p>
                                </div>

                                <hr>


                                <div class="col-md-12 bg-success" style="text-align: center">
                                    Thank you for choosing <?php echo e($companyInfo->company_name ?? 'N/A'); ?> products.
                                    We believe you will be satisfied by our services.
                                </div>
                                <!-- /.col -->



                            </div>
                            <!-- Table row -->

                        </div>

                    </div>
                </div>
            </div>
        <?php endif; ?>
        <!-- /.col-->
    </div>
<?php $__env->stopSection(); ?>
<?php $__env->startSection('scripts'); ?>
    <?php echo $__env->make('backend.pages.reports.excel', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?>

    <script>
        $(document).ready(function() {
            function toggleFields() {
                let selectedType = $("#typeSelect").val();
                if (selectedType === "Branch") {
                    $("#branchSelect").show();
                    $("#projectSelect").hide();
                } else {
                    $("#branchSelect").hide();
                    $("#projectSelect").show();
                }
            }

            // Run function on page load to set initial state
            toggleFields();

            // Run function when "Type" is changed
            $("#typeSelect").on("change", function() {
                toggleFields();
            });
        });
    </script>
<?php $__env->stopSection(); ?>

<?php echo $__env->make('backend.layouts.master', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH I:\jubayer\resources\views/backend/pages/reports/purchase.blade.php ENDPATH**/ ?>