<?php Fun::lang() ?>

<table class="table table-striped table-hover ">
    <thead>
    <tr>
        <th>#</th>
        <th><?php echo e(__('administrator.date')); ?></th>
        <th><?php echo e(__('administrator.description')); ?></th>
        <th><?php echo e(__('administrator.reference')); ?></th>
        <th><?php echo e(__('administrator.user')); ?></th>
        <th><?php echo e(__('administrator.pay_to_receive_from')); ?></th>
        <th><?php echo e(__('administrator.note')); ?></th>
        <th><?php echo e(__('administrator.cash_in')); ?></th>
        <th><?php echo e(__('administrator.cash_out')); ?></th>
        <th><?php echo e(__('administrator.balance')); ?></th>
        <th><?php echo e(__('administrator.action')); ?></th>
    </tr>
    </thead>
    <tbody>
    <?php
        $balance = 0;
        $balance_kh = 0;
        $key = 1;
        $old_amount = @$old_amount?$old_amount:0;
    ?>
    <?php if($old_amount): ?>
        <tr>
            <td><?php echo e($key++); ?></td>
            <td><?php echo e(date('d-m-Y')); ?></td>
            <td><?php echo e(__('administrator.opening_balance')); ?></td>
            <td><?php echo e(date('dmY00001')); ?></td>
            <td><?php echo e(Auth::user()->name); ?></td>
            <td></td>
            <td></td>
            <td></td>
            <td></td>
            <td>$ <?php echo e($old_amount); ?></td>
            <td></td>
        </tr>
    <?php endif; ?>
    <?php $__currentLoopData = $cash_in_out; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $row): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
        <?php
            $user = findUser($row->user_id);
            if($row->invoice_id){
                $customer = findCustomer($row->pay_to_receive_from);
                $customer = $customer?$customer->customer_name:'';
            }else{
                $customer = $row->pay_to_receive_from;
            }
         $cash_out = ($row->cash_type=='cash_out'?$row->amount:'');
        $cash_in = ($row->cash_type=='cash_in'?$row->amount:'');
        if($row->cash_type=='cash_in'){
            if($row->currency_id==1){
             $balance_kh += $cash_in;
            }
            if($row->currency_id==2){
             $balance += $cash_in;
            }
        }
        $currency = findCurrency($row->currency_id);
        $currency = $currency?$currency->symbol:'';
        $cash_out = $cash_out?($currency.$cash_out):'';
        $cash_in = $cash_in?($currency.$cash_in):'';
        ?>

        <tr>
            <td><?php echo e($key++); ?></td>
            <td><?php echo e(date('d-m-Y',strtotime($row->date))); ?></td>
            <td><?php echo e($row->description); ?></td>
            <td><?php echo e($row->invoice_number); ?></td>
            <td><?php echo e($user->name); ?></td>
            <td><?php echo e($customer); ?></td>
            <td><?php echo e($row->note); ?></td>
            <td><?php echo e($cash_in); ?></td>
            <td><?php echo e($cash_out); ?></td>
            <td>៛<?php echo e($balance_kh); ?>, $<?php echo e($balance); ?></td>
            <td><a data-href="<?php echo e(route('cash-in-cash-out.edit',$row->id)); ?>"
                   class="button_warning get_edit_form"><?php echo e(__('administrator.edit')); ?></a></td>
        </tr>
    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
    </tbody>
</table>
<div class="text-right">
    <?php echo $cash_in_out->render(); ?>

</div>


<?php /**PATH /home/nsowos/public_html/shr-brand/resources/views/pos/cash-in-out/get-data-table.blade.php ENDPATH**/ ?>