<?php $__env->startSection('title', 'Daily TopSheet'); ?>
<?php $__env->startSection('css'); ?>
    <link rel="stylesheet" href="<?php echo e(asset('./css/print.css')); ?>">
<?php $__env->stopSection(); ?>
<?php $__env->startSection('content'); ?>
    <h4 class="text-center">Top Sheet of (<?php echo e(\Carbon\Carbon::parse($request_date)->format('d-M-Y')); ?>)</h4>

    <div class="container">
        <div class="row">
            <div class="col-xs-6">
                <h5 class="sub-header">Purchase</h5>
                <div class="table-responsive">
                    <table class="table table-striped">
                        <thead>
                        <tr>
                            <th>#</th>
                            <th>Date</th>
                            <th>Company</th>
                            <th>Total</th>
                        </tr>
                        </thead>
                        <tbody>
                        <?php $__currentLoopData = $purchases; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $purchase): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                            <tr>
                                <td><?php echo e('PUR-'. $purchase->purchase_no); ?></td>
                                <td style="width: 15%;"><?php echo e(Carbon\Carbon::parse($purchase->purchase_date)->format('d-M-Y')); ?></td>
                                <td><?php echo e($purchase->company->name); ?></td>
                                <td style="width: 15%"><?php echo e($purchase->grand_total); ?></td>
                            </tr>
                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                        </tbody>
                        <tfoot>
                        <tr>
                            <td colspan="2">Total</td>
                            <td colspan="2" class="text-right"><?php echo e($purchases->sum('grand_total')); ?></td>
                        </tr>
                        </tfoot>
                    </table>
                </div>
            </div>
            <div class="col-xs-6">
                <h5 class="sub-header">Sales</h5>
                <div class="table-responsive">
                    <table class="table table-striped">
                        <thead>
                        <tr>
                            <th class="">#</th>
                            <th class="">Date</th>
                            <th class="">Name</th>
                            <th class="">Total</th>
                        </tr>
                        </thead>
                        <tbody>
                        <?php $__currentLoopData = $sales; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $sale): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                            <tr>
                                <td><?php echo e($sale->sale_no); ?></td>
                                <td style="width: 15%;"><?php echo e(Carbon\Carbon::parse($sale->date)->format('d-M-Y')); ?></td>
                                <td><?php echo e(!empty($sale->customer_id) ? App\Models\Customer::find($sale->customer_id)->name : App\Models\Farmer::find($sale->farmer_id)->name); ?></td>
                                <td style="width: 15%"><?php echo e($sale->grand_total); ?></td>
                            </tr>
                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                        </tbody>
                        <tfoot>
                        <tr>
                            <td colspan="2">Total</td>
                            <td colspan="2" class="text-right"><?php echo e($sales->sum('grand_total')); ?></td>
                        </tr>
                        </tfoot>
                    </table>
                </div>


                <div id="clearfix"></div>
            </div>
        </div>
        <div class="row">
            <h4 class="text-center">Accounts</h4>
            <table class="table table-bordered">
                <thead>
                <tr>
                    <th>Date</th>
                    <th>Origin</th>
                    <th>Heads</th>
                    <th>Company</th>
                    <th>Farmer</th>
                    <th>Employee</th>
                    <th>Category</th>
                    <th>Amount</th>
                    <th>Recipient</th>
                </tr>
                </thead>
                <tbody>
                <?php
                    $i = 1;
                ?>
                <?php $__currentLoopData = $accounts; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $account): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                    <tr>
                        <td style="font-size: 10px;font-weight: bold; width: 15%">
                            <?php echo e(\Carbon\Carbon::parse($account->Date)->format('d-M-Y')); ?>

                        </td>
                        <td>
                            <?php echo e($account->Origin); ?>

                        </td>
                        <td>
                            <?php if($account->Origin === 'Expense'): ?>
                                <?php echo e(!empty($account->Heads) ? App\Models\ExpenseHead::find($account->Heads)->name : 'N/A'); ?>

                            <?php else: ?>
                                <?php echo e(!empty($data->Heads) ? App\Models\PurposeHead::find($account->Heads)->name : 'N/A'); ?>

                            <?php endif; ?>
                        </td>
                        <td>
                            <?php echo e(!empty($data->Company) ? App\Models\Company::find($account->Company)->company_name : 'N/A'); ?>

                        </td>
                        <td>
                            <?php echo e(!empty($account->farmer_id) ? App\Models\Farmer::find($account->farmer_id)->name : 'N/A'); ?>

                        </td>
                        <td>
                            <?php echo e(!empty($account->Employee) ? App\Models\User::find($account->Employee)->name : 'N/A'); ?>

                        </td>
                        <td>
                            <?php echo e($account->Category); ?>

                        </td>
                        <td>
                            <?php echo e($account->Origin === 'Collection' ? '+ '.$account->Amount : '- '.$account->Amount); ?>

                        </td>
                        <td>
                            <?php echo e($account->Recipient); ?>

                        </td>
                    </tr>
                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                </tbody>
                <tfoot>
                <tr>
                    <td colspan="3">
                        T. Expense = <?php echo e(number_format($accounts->where('Origin','Expense')->sum('Amount'),2)); ?>

                    </td>
                    <td colspan="3">
                        T. Payment = <?php echo e(number_format($accounts->where('Origin','Payments')->sum('Amount'),2)); ?>

                    </td>
                    <td colspan="3">
                        T. Collection = <?php echo e(number_format($accounts->where('Origin','Collection')->sum('Amount'),2)); ?>

                    </td>

                </tr>
                </tfoot>

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

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


<?php echo $__env->make('template.print', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH /home/forazitradersbd/public_html/resources/views/admin/reports/daily/topsheet.blade.php ENDPATH**/ ?>