<?php $__env->startSection('title', 'Daily Ledger Report'); ?>

<?php $__env->startPush('css'); ?>
<!-- bootstrap-datetimepicker -->
<!--<link rel="stylesheet" href="<?php echo e(asset('myfile/backend/assets/datepicker/zebra_datepicker.min.css')); ?>" type="text/css">
	<link rel="stylesheet" href="<?php echo e(asset('myfile/backend/assets/datepicker/examples.css')); ?>" type="text/css">-->
<style>
    #search-btn {
        margin-top: 24px;
    }
    thead,tbody {
        font-size: 12px;
    }
    .text-center,h3,h4,p {
        line-height: 15px;
        font-weight: bold;
    }
    .border p {
        background: teal;
        padding: 4px;
        text-align: center;
        color: white;
        font-weight: bold;
    }
    .bg-success2 {
        background-color: #b9d8ac;
        font-size: 15px;
    }
    .bg-info2 {
        background-color: #add9ef;
        font-size: 15px;
    }
   .bg-secondary {
        background: #5a6365;
        color: white;
        font-size: 18px;
    }
</style>
<?php $__env->stopPush(); ?>
<?php $__env->startSection('content'); ?>
<div class="right_col" role="main">
    <div class="">
        <div class="row">
            <div class="col-md-12 col-sm-12 col-xs-12">
                <div class="x_panel">
                    <div class="x_title">
                        <h2 class="widget-title">Daily Ledger</h2>
                        <ul class="nav navbar-right panel_toolbox">
                            <li>
                                <a class="collapse-link" onclick="printDiv('printableArea')">
                                    <i class="fa fa-1x fa-print"></i>
                                </a>
                            </li>
                            <li><a class="collapse-link"><i class="fa fa-chevron-up"></i></a></li>
                            <li class="dropdown">
                                <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button"
                                    aria-expanded="false"><i class="fa fa-wrench"></i></a>
                                <ul class="dropdown-menu" role="menu">
                                    <li><a href="#">Settings 1</a></li>
                                    <li><a href="#">Settings 2</a></li>
                                </ul>
                            </li>
                            <li><a class="close-link"><i class="fa fa-close"></i></a></li>
                        </ul>
                        <div class="clearfix"></div>
                    </div>
                    <div class="row">
                        <div class="col-md-12 col-sm-12 col-xs-12">
                            <div class="x_content" id="printableArea">
                                <div class="row">
                                    <div class="col-xs-12 col-sm-12">
                                        <div class="row">
                                            <div class="col-xs-1"></div>
                                            <div class="col-xs-1">
                                                <img src="<?php echo e(asset('storage/about/'.about()->logo)); ?>" class="img-responsive img-thumbnail" alt="logo" width="85px" height="75px">
                                            </div>
                                            <div class="col-xs-8">
                                                <div class="text-center">
                                                    <h3>Daily Ledger</h3>
                                                    <h4><?php echo e(about()->english_name); ?></h4>
                                                    <p>Phone: <?php echo e(about()->phone); ?>, Email: <?php echo e(about()->email); ?></p>
                                                    <p>Address: <?php echo e(about()->address); ?> </p>
                                                    <p>Date: <?php echo e(date('d-m-Y')); ?></p>
                                                </div>
                                            </div>
                                            <div class="col-xs-2"></div>
                                        </div>
                                        <hr>
                                        <div class="border">
                                            <p>Sale Details</p>
                                        </div>
                                        <table class="table table-bordered">
                                            <thead>
                                                <tr>
                                                    <th>SL</th>
                                                    <th>Customer</th>
                                                    <th>Total Sale</th>
                                                    <th>Payment</th>
                                                    <th>Due</th>
                                                    <th>Remark</th>
                                                </tr>
                                            </thead>
                                            <tbody>
                                                <?php $__currentLoopData = $sales; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $l=>$sale): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                                <tr>
                                                    <td><?php echo e($l+1); ?></td>
                                                    <td><?php echo e($sale->customer->name); ?></td>
                                                    <td><?php echo e($sale->grand_total_price); ?></td>
                                                    <td><?php echo e($sale->payment); ?></td>
                                                    <td><?php echo e($sale->due_amount); ?></td>
													<td></td>
                                                </tr>
                                                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                            </tbody>
											<tfoot>
												<tr>
													<th colspan="2">Total:</th>
													<th><?php echo e($sales->sum('grand_total_price')); ?></th>
													<th><?php echo e($sales->sum('payment')); ?></th>
													<th><?php echo e($sales->sum('due_amount')); ?></th>
													<th></th>
												</tr>
											</tfoot>
                                        </table>
                                        <div class="row">
                                            <div class="col-xs-12 col-sm-6 col-md-6">
                                                <div class="border">
                                                    <p>Bank Transactions</p>
                                                </div>
                                                <table class="table table-bordered table-condensed">
                                                    <thead>
                                                        <tr>
                                                            <th>SL</th>
                                                            <th>Bank</th>
                                                            <th>Deposit</th>
                                                            <th>Loan</th>
                                                            <th>Withdraw</th>
                                                        </tr>
                                                    </thead>
                                                    <tbody>
														<?php 
															$dp = 0;
															$ln = 0;
															$wit = 0;
                                                         ?>
                                                        <?php $__currentLoopData = $transactions; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $w=>$wt): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                                        <?php 
															$dp +=  $wt->transaction_status == 'Deposit' ? $wt->transaction_amount : 0;
															$ln += $wt->transaction_status == 'Loan' ? $wt->transaction_amount : 0;
															$wit += $wt->transaction_status == 'Withdraw' ? $wt->transaction_amount : 0;
                                                         ?>
                                                        <tr>
                                                            <td><?php echo e($w+1); ?></td>
                                                            <td><?php echo e($wt->bank->bank_name); ?></td>
                                                            <td><?php echo e($wt->transaction_status == 'Deposit' ? $wt->transaction_amount : 0); ?>

                                                            </td>
                                                            <td><?php echo e($wt->transaction_status == 'Loan' ? $wt->transaction_amount : 0); ?>

                                                            </td>
                                                            <td><?php echo e($wt->transaction_status == 'Withdraw' ? $wt->transaction_amount : 0); ?>

                                                            </td>
                                                        </tr>
                                                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                                    </tbody>
                                                    <tfoot>
                                                        <tr>
                                                            <th colspan="2">Total</th>
                                                            <th><?php echo e($dp); ?></th>
                                                            <th><?php echo e($ln); ?></th>
                                                            <th><?php echo e($wit); ?></th>
                                                        </tr>
                                                    </tfoot>
                                                </table>
                                            </div>
                                            <div class="col-xs-12 col-sm-6 col-md-6">
                                                <div class="border">
                                                    <p>Expense Details</p>
                                                </div>
                                                <table class="table table-bordered table-condensed">
                                                    <thead>
                                                        <tr>
                                                            <th>SL</th>
                                                            <th>Type</th>
                                                            <th>Amount</th>
                                                        </tr>
                                                    </thead>
                                                    <tbody>
                                                        <?php $__currentLoopData = $expenses; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $e=>$ex): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                                        <tr>
                                                            <td><?php echo e($e+1); ?></td>
                                                            <td><?php echo e($ex->expensetype->type_name); ?></td>
                                                            <td><?php echo e($ex->expense_amount); ?></td>
                                                        </tr>
                                                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                                    </tbody>
                                                    <tfoot>
                                                        <tr>
                                                            <th colspan="2">Total</th>
                                                            <th><?php echo e($expenses->sum('expense_amount')); ?></th>
                                                        </tr>
                                                    </tfoot>
                                                </table>
                                            </div>
                                        </div>
                                        <div class="row">
                                            <div class="col-xs-12 col-sm-6 col-md-6">
                                                <div class="border">
                                                    <p>Total Calculation</p>
                                                </div>
                                                <table class="table table-bordered table-condensed">
                                                    <tbody>
                                                        <tr>
                                                            <th class='bg-success'>Credit</th>
                                                            <th class='bg-success'>Amount</th>
                                                            <th class='bg-info'>Debit</th>
                                                            <th class='bg-info'>Amount</th>
                                                        </tr>
                                                        <tr>
                                                            <th class='bg-success'>Total Sale:</th>
                                                            <th class='bg-success'><?php echo e($sales->sum('grand_total_price')); ?></th>
                                                            <th class='bg-info'>Total Due:</th>
                                                            <th class='bg-info'><?php echo e($sales->sum('due_amount')); ?></th>
                                                        </tr>
                                                        <tr>
                                                            <th class='bg-success'>Last Day Cash:</th>
                                                            <th class='bg-success'><?php echo e($lastday_cash->balance); ?></th>
                                                            <th class='bg-info'>Total Expense:</th>
                                                            <th class='bg-info'><?php echo e($expenses->sum('expense_amount')); ?></th>
                                                        </tr>
                                                        <tr>
                                                            <th class='bg-success'>Previous Due Payment:</th>
                                                            <th class='bg-success'><?php echo e($cpayment - $sales->sum('payment')); ?></th>
                                                            <th class='bg-info'>Supplier Payments:</th>
                                                            <th class='bg-info'><?php echo e($spayment); ?></th>
                                                        </tr>
                                                        <tr>
                                                            <th class='bg-success'>Total Bank Withdraw + Loan:</th>
                                                            <th class='bg-success'><?php echo e($wit + $ln); ?></th>
                                                            <th class='bg-info'>Total Bank Deposit:</th>
                                                            <th class='bg-info'><?php echo e($dp); ?></th>
                                                        </tr>
                                                        <?php 
                                                            $pdp = $cpayment - $sales->sum('payment');
                                                            $debit = $expenses->sum('expense_amount') + $dp + $spayment ;
                                                            $credit = $sales->sum('payment') + $lastday_cash->balance + $pdp + $wit + $ln ;
                                                         ?>
                                                        <tr>
                                                            <th class='bg-success2'>Total Credit</td>
                                                            <th class='bg-success2'><?php echo e($credit); ?></td>
                                                            <th class='bg-info2'>Total Debit</td>
                                                            <th class='bg-info2'><?php echo e($debit); ?></td>
                                                        </tr>
                                                        <tr class='bg-secondary'>
                                                            <th colspan='2'>Today cash in hand:</th>
                                                            <th colspan='2'><?php echo e($credit - $debit); ?></th>
                                                        </tr>
                                                    </tbody>
                                                </table>
                                            </div>
                                            <div class="col-xs-12 col-sm-4 col-md-4"></div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<?php $__env->stopSection(); ?>

<?php $__env->startPush('js'); ?>

<!-- Jquery Plugin For Date Calender-->
<!--<script type="text/javascript" src="<?php echo e(asset('myfile/backend/assets/datepicker/zebra_datepicker.src.js')); ?>"></script>
<script type="text/javascript" src="<?php echo e(asset('myfile/backend/assets/datepicker/examples.js')); ?>"></script>-->
<script>
$(document).ready(function() {
    // select2 section
    // $('.select2').select2()	;
});

function printDiv(divName) {
    var printContents = document.getElementById(divName).innerHTML;
    var originalContents = document.body.innerHTML;

    document.body.innerHTML = printContents;

    window.print();

    document.body.innerHTML = originalContents;
}
</script>
<?php $__env->stopPush(); ?>
<?php echo $__env->make('backend.layouts.master', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>