<?php $__env->startSection('title','Monthly Sale Report'); ?>

<?php $__env->startSection('content'); ?>
    <h4 class="text-center">Accounts Report (<?php echo e(\Carbon\Carbon::parse($request_from_date)->format('d-M-Y')); ?> To <?php echo e(\Carbon\Carbon::parse($request_to_date)->format('d-M-Y')); ?>)</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>
<?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/monthly/accounts.blade.php ENDPATH**/ ?>