<?php $__env->startSection('title'); ?><?php echo app('translator')->get('quickadmin.customer-management.fields.list'); ?> <?php $__env->stopSection(); ?>
<?php $__env->startSection('customCss'); ?>
<meta name="csrf-token" content="<?php echo e(csrf_token()); ?>" >
<link rel="stylesheet" href="<?php echo e(asset('admintheme/assets/css/printView-datatable.css')); ?>">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.9.0/css/bootstrap-datepicker.min.css">


<style>
    
</style>
<?php $__env->stopSection(); ?>
<?php $__env->startSection('main-content'); ?>

<div class="card MainBox">
    <div class="mainHeading">
        <h4 class="text-nopwrap"><?php echo e(ucwords($customer->name)); ?></h4>
        <ul class="top_align_right">
            <li><?php if (isset($component)) { $__componentOriginal4fc2bce81e6643975498c1caac0c8935 = $component; } ?>
<?php if (isset($attributes)) { $__attributesOriginal4fc2bce81e6643975498c1caac0c8935 = $attributes; } ?>
<?php $component = Illuminate\View\AnonymousComponent::resolve(['view' => 'components.svg-icon','data' => ['icon' => 'phone']] + (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag ? $attributes->all() : [])); ?>
<?php $component->withName('svg-icon'); ?>
<?php if ($component->shouldRender()): ?>
<?php $__env->startComponent($component->resolveView(), $component->data()); ?>
<?php if (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag): ?>
<?php $attributes = $attributes->except(\Illuminate\View\AnonymousComponent::ignoredParameterNames()); ?>
<?php endif; ?>
<?php $component->withAttributes(['icon' => 'phone']); ?>
<?php echo $__env->renderComponent(); ?>
<?php endif; ?>
<?php if (isset($__attributesOriginal4fc2bce81e6643975498c1caac0c8935)): ?>
<?php $attributes = $__attributesOriginal4fc2bce81e6643975498c1caac0c8935; ?>
<?php unset($__attributesOriginal4fc2bce81e6643975498c1caac0c8935); ?>
<?php endif; ?>
<?php if (isset($__componentOriginal4fc2bce81e6643975498c1caac0c8935)): ?>
<?php $component = $__componentOriginal4fc2bce81e6643975498c1caac0c8935; ?>
<?php unset($__componentOriginal4fc2bce81e6643975498c1caac0c8935); ?>
<?php endif; ?> <?php echo e($customer->phone_number); ?></li>
            <li><?php if (isset($component)) { $__componentOriginal4fc2bce81e6643975498c1caac0c8935 = $component; } ?>
<?php if (isset($attributes)) { $__attributesOriginal4fc2bce81e6643975498c1caac0c8935 = $attributes; } ?>
<?php $component = Illuminate\View\AnonymousComponent::resolve(['view' => 'components.svg-icon','data' => ['icon' => 'location']] + (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag ? $attributes->all() : [])); ?>
<?php $component->withName('svg-icon'); ?>
<?php if ($component->shouldRender()): ?>
<?php $__env->startComponent($component->resolveView(), $component->data()); ?>
<?php if (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag): ?>
<?php $attributes = $attributes->except(\Illuminate\View\AnonymousComponent::ignoredParameterNames()); ?>
<?php endif; ?>
<?php $component->withAttributes(['icon' => 'location']); ?>
<?php echo $__env->renderComponent(); ?>
<?php endif; ?>
<?php if (isset($__attributesOriginal4fc2bce81e6643975498c1caac0c8935)): ?>
<?php $attributes = $__attributesOriginal4fc2bce81e6643975498c1caac0c8935; ?>
<?php unset($__attributesOriginal4fc2bce81e6643975498c1caac0c8935); ?>
<?php endif; ?>
<?php if (isset($__componentOriginal4fc2bce81e6643975498c1caac0c8935)): ?>
<?php $component = $__componentOriginal4fc2bce81e6643975498c1caac0c8935; ?>
<?php unset($__componentOriginal4fc2bce81e6643975498c1caac0c8935); ?>
<?php endif; ?> <?php echo e($customer->area->address ?? ''); ?></li>
        </ul>
    </div>
    <div class="card-body p-0">
        <div class="mx-0 mb-4 floatingLabel">
            <form action="" id="yearFilterForm">
                <div class="form-group">
                    <label for="year" class="select_year"><?php echo app('translator')->get('quickadmin.customers.fields.select_year'); ?></label>
                    <div class="selectyear d-flex align-items-center">
                        <select class="form-control" name="year" id="year" data-customerid=<?php echo e($customer->uuid); ?>>
                            <?php $__currentLoopData = $yearlist; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $data): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                            <option value="<?php echo e($data); ?>" <?php echo e($year == $data ? 'selected' : ''); ?>><?php echo e($data); ?></option>
                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                        </select>
                    </div>
                </div>
            </form>            
        </div>
        <div class="table-responsive fixed_Search">
            <table class="table custom_table table_Footer party_list_main">
                <thead>
                    <tr>
                        <th><?php echo app('translator')->get('quickadmin.customers.fields.particulars'); ?></th>
                        <th><?php echo app('translator')->get('quickadmin.customers.fields.debit'); ?></th>
                        <th><?php echo app('translator')->get('quickadmin.customers.fields.credit'); ?></th>
                        <th><?php echo app('translator')->get('quickadmin.customers.fields.closing_blance'); ?></th>
                        <th class="text-center"><?php echo app('translator')->get('quickadmin.qa_action'); ?></th>
                    </tr>
                    <tr>
                        <th colspan="3"><?php echo app('translator')->get('quickadmin.customers.fields.opening_blance'); ?></th>
                        <th colspan="2">₹ <?php echo e(number_format(abs($openingBalance), 2, '.', ',')); ?><?php echo e($openingBalance<=1 ? ' Cr' : ' Dr'); ?> </th>
                    </tr>
                </thead>
                <tbody>                    
                    <?php
                        $totalSales = 0;
                        $totalCashReceipt = 0;                        
                        $lastClosingBalance = 0 ;
                    ?>

                    <?php $__empty_1 = true; $__currentLoopData = $monthlyData; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $index => $data): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>

                        <?php
                            if($index === 0){
                                $monthlyClosingBalance = $lastClosingBalance + $data['sales'] + $openingBalance - ($data['cashreceipt']);
                            }
                            else{
                                $monthlyClosingBalance = $lastClosingBalance + $data['sales'] - ($data['cashreceipt']);
                            }

                            $monthlyClosingBalanceFormatted = $monthlyClosingBalance + $openingBalance;
                        ?>

                        <tr>
                            <td><?php echo e(\Carbon\Carbon::createFromFormat('Y-m', $data['month'])->format('F Y')); ?></td>
                            <td><?php echo e(number_format($data['sales'], 2, '.', ',')); ?></td>
                            <td><?php echo e(number_format($data['cashreceipt'], 2, '.', ',')); ?></td>
                            <td><?php echo e(number_format(abs($monthlyClosingBalanceFormatted), 2, '.', ',')); ?><?php echo e($monthlyClosingBalanceFormatted<=1 ? ' Cr' : ' Dr'); ?></td>
                            <td>
                                <div>
                                    <a class="customer-month-detail" href="<?php echo e(route('customers.month.view', ['uuid' => $customer->uuid, 'month' => $data['month']])); ?>">
                                        <?php if (isset($component)) { $__componentOriginal4fc2bce81e6643975498c1caac0c8935 = $component; } ?>
<?php if (isset($attributes)) { $__attributesOriginal4fc2bce81e6643975498c1caac0c8935 = $attributes; } ?>
<?php $component = Illuminate\View\AnonymousComponent::resolve(['view' => 'components.svg-icon','data' => ['icon' => 'view']] + (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag ? $attributes->all() : [])); ?>
<?php $component->withName('svg-icon'); ?>
<?php if ($component->shouldRender()): ?>
<?php $__env->startComponent($component->resolveView(), $component->data()); ?>
<?php if (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag): ?>
<?php $attributes = $attributes->except(\Illuminate\View\AnonymousComponent::ignoredParameterNames()); ?>
<?php endif; ?>
<?php $component->withAttributes(['icon' => 'view']); ?>
<?php echo $__env->renderComponent(); ?>
<?php endif; ?>
<?php if (isset($__attributesOriginal4fc2bce81e6643975498c1caac0c8935)): ?>
<?php $attributes = $__attributesOriginal4fc2bce81e6643975498c1caac0c8935; ?>
<?php unset($__attributesOriginal4fc2bce81e6643975498c1caac0c8935); ?>
<?php endif; ?>
<?php if (isset($__componentOriginal4fc2bce81e6643975498c1caac0c8935)): ?>
<?php $component = $__componentOriginal4fc2bce81e6643975498c1caac0c8935; ?>
<?php unset($__componentOriginal4fc2bce81e6643975498c1caac0c8935); ?>
<?php endif; ?>
                                    </a>                                                               
                                </div>
                            </td>
                        </tr>
                        <?php
                            $totalSales += $data['sales'];
                            $totalCashReceipt += $data['cashreceipt'];
                            $lastClosingBalance = $monthlyClosingBalance;
                        ?>

                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
                        <tr>
                            <td colspan="5">No records found</td>
                        </tr>
                    <?php endif; ?>

                </tbody>
                <tfoot>
                    
                    <tr>
                        <th>Grand Total</th>
                        <th>₹ <?php echo e(number_format($totalSales, 2, '.', ',')); ?></th>
                        <th>₹ <?php echo e(number_format($totalCashReceipt, 2, '.', ',')); ?></th>
                        <th colspan="2">₹ <?php echo e(number_format($totalSales - ($totalCashReceipt) + $openingBalance , 2, '.', ',')); ?></th>
                    </tr>
                </tfoot>          
            </table>
        </div>
    </div>
</div>

<?php $__env->stopSection(); ?>
<?php $__env->startSection('customJS'); ?>
<script type="text/javascript" src="//cdn.jsdelivr.net/momentjs/latest/moment.min.js"></script>
<script>

$(document).ready(function (){

    $.ajaxSetup({
        headers: {
        'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
        }
    });

    $(document).on('change','#yearFilterForm #year', function(e){
        e.preventDefault();
        var year = $(this).val();
        var customerId = $(this).attr('data-customerid');
        var hrefUrl = "<?php echo e(route('customers.monthly.show', ':uuid')); ?>".replace(':uuid', customerId) + '?year=' + year;
        window.location.href = hrefUrl;
    });
       
});
    
</script>
<?php $__env->stopSection(); ?>

<?php echo $__env->make('layouts.app', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH /home/hipldemo2/public_html/billing-software.hipl-staging2.com/resources/views/admin/customer/view-allmonthly-detail.blade.php ENDPATH**/ ?>