<div class="d-flex flex-row" style="max-height: 300px; overflow-y: scroll;">
    <table class="table table-bordered">
        <thead class="text-muted">
        <tr>
            <th scope="col"><?php echo e(\App\CentralLogics\translate('item')); ?></th>
            <th scope="col" class="text-center"><?php echo e(\App\CentralLogics\translate('qty')); ?></th>
            <th scope="col"><?php echo e(\App\CentralLogics\translate('price')); ?></th>
            <th scope="col"><?php echo e(\App\CentralLogics\translate('delete')); ?></th>
        </tr>
        </thead>
        <tbody>
        <?php
        $subtotal = 0;
        $discount = 0;
        $discount_type = 'amount';
        $discount_on_product = 0;
        $total_tax = 0;
        ?>
        <?php if(session()->has('cart') && count( session()->get('cart')) > 0): ?>
            <?php
            $cart = session()->get('cart');
            if (isset($cart['discount'])) {
                $discount = $cart['discount'];
                $discount_type = $cart['discount_type'];
            }
            ?>
            <?php $__currentLoopData = session()->get('cart'); $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $key => $cartItem): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                <?php if(is_array($cartItem)): ?>
                    <?php
                    $product_subtotal = ($cartItem['price']) * $cartItem['quantity'];
                    $discount_on_product += ($cartItem['discount'] * $cartItem['quantity']);
                    $subtotal += $product_subtotal;

                    //tax calculation
                    $product = \App\Model\Product::find($cartItem['id']);
                    $total_tax += \App\CentralLogics\Helpers::tax_calculate($product, $cartItem['price']) * $cartItem['quantity'];

                    ?>
                    <tr>
                        <td class="media align-items-center">
                            <img class="avatar avatar-sm mr-1"
                                 src="<?php echo e(asset('storage/app/public/product')); ?>/<?php echo e(json_decode($cartItem['image'], true)[0]); ?>"
                                 onerror="this.src='<?php echo e(asset('public/assets/admin/img/160x160/img2.jpg')); ?>'"
                                 alt="<?php echo e($cartItem['name']); ?> image">
                            <div class="media-body">
                                <h5 class="text-hover-primary mb-0"><?php echo e(Str::limit($cartItem['name'], 10)); ?></h5>
                                <small><?php echo e(Str::limit($cartItem['variant'], 20)); ?></small>
                            </div>
                        </td>
                        <td class="align-items-center text-center">
                            <input type="number" data-key="<?php echo e($key); ?>" style="width:50px;text-align: center;"
                                   value="<?php echo e($cartItem['quantity']); ?>" min="1" onkeyup="updateQuantity(event)">
                        </td>
                        <td class="text-center px-0 py-1">
                            <div class="btn">
                                <?php echo e(Helpers::set_symbol($product_subtotal)); ?>

                            </div> <!-- price-wrap .// -->
                        </td>
                        <td class="align-items-center text-center">
                            <a href="javascript:removeFromCart(<?php echo e($key); ?>)" class="btn btn-sm btn-outline-danger"> <i
                                    class="tio-delete-outlined"></i></a>
                        </td>
                    </tr>
                <?php endif; ?>
            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
        <?php endif; ?>
        </tbody>
    </table>
</div>

<?php
$total = $subtotal;
$discount_amount = ($discount_type == 'percent' && $discount > 0) ? (($total * $discount) / 100) : $discount;
$discount_amount += $discount_on_product;
$total -= $discount_amount;

$extra_discount = session()->get('cart')['extra_discount'] ?? 0;
$extra_discount_type = session()->get('cart')['extra_discount_type'] ?? 'amount';
if ($extra_discount_type == 'percent' && $extra_discount > 0) {
    $extra_discount = ($subtotal * $extra_discount) / 100;
}
if ($extra_discount) {
    $total -= $extra_discount;
}
?>
<div class="box p-3">
    <dl class="row text-sm-right">
        <dt class="col-sm-6"><?php echo e(\App\CentralLogics\translate('sub_total')); ?> :</dt>
        <dd class="col-sm-6 text-right"><?php echo e(Helpers::set_symbol($subtotal)); ?></dd>


        <dt class="col-sm-6"><?php echo e(\App\CentralLogics\translate('product')); ?> <?php echo e(\App\CentralLogics\translate('discount')); ?>:
        </dt>
        <dd class="col-sm-6 text-right"> - <?php echo e(Helpers::set_symbol(round($discount_amount,2))); ?></dd>

        <dt class="col-sm-6"><?php echo e(\App\CentralLogics\translate('extra')); ?> <?php echo e(\App\CentralLogics\translate('discount')); ?>:
        </dt>
        <dd class="col-sm-6 text-right">
            <button class="btn btn-sm" type="button" data-toggle="modal" data-target="#add-discount"><i
                    class="tio-edit"></i>
            </button> - <?php echo e(Helpers::set_symbol($extra_discount)); ?></dd>

        <dt class="col-sm-6"><?php echo e(\App\CentralLogics\translate('tax')); ?> :</dt>
        <dd class="col-sm-6 text-right"><?php echo e(Helpers::set_symbol(round($total_tax,2))); ?></dd>

        <dt class="col-sm-6"><?php echo e(\App\CentralLogics\translate('total')); ?> :</dt>
        <dd class="col-sm-6 text-right h4 b"><?php echo e(Helpers::set_symbol(round($total+$total_tax, 2))); ?></dd>
    </dl>
    <div class="row">
        <div class="col-md-6">
            <a href="#" class="btn btn-danger btn-sm btn-block" onclick="emptyCart()"><i
                    class="fa fa-times-circle "></i> <?php echo e(\App\CentralLogics\translate('Cancel')); ?> </a>
        </div>
        <div class="col-md-6">
            <button type="button" class="btn  btn-primary btn-sm btn-block" data-toggle="modal"
                    data-target="#paymentModal"><i class="fa fa-shopping-bag"></i>
                <?php echo e(\App\CentralLogics\translate('Order')); ?> </button>
        </div>
    </div>
</div>

<div class="modal fade" id="add-discount" tabindex="-1">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <h5 class="modal-title"><?php echo e(\App\CentralLogics\translate('update_discount')); ?></h5>
                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                    <span aria-hidden="true">&times;</span>
                </button>
            </div>
            <div class="modal-body">
                <form action="<?php echo e(route('admin.pos.discount')); ?>" method="post" class="row">
                    <?php echo csrf_field(); ?>
                    <div class="form-group col-sm-6">
                        <label for=""><?php echo e(\App\CentralLogics\translate('discount')); ?></label>
                        <input type="number" value="<?php echo e(session()->get('cart')['extra_discount'] ?? 0); ?>" class="form-control" name="discount">
                    </div>
                    <div class="form-group col-sm-6">
                        <label for=""><?php echo e(\App\CentralLogics\translate('type')); ?></label>
                        <select name="type" class="form-control">
                            <option
                                value="amount" <?php echo e($extra_discount_type=='amount'?'selected':''); ?>><?php echo e(\App\CentralLogics\translate('amount')); ?>

                                (<?php echo e(\App\CentralLogics\Helpers::currency_symbol()); ?>)
                            </option>
                            <option
                                value="percent" <?php echo e($extra_discount_type=='percent'?'selected':''); ?>><?php echo e(\App\CentralLogics\translate('percent')); ?>

                                (%)
                            </option>
                        </select>
                    </div>
                    <div class="form-group col-sm-12">
                        <button class="btn btn-sm btn-primary"
                                type="submit"><?php echo e(\App\CentralLogics\translate('submit')); ?></button>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>

<div class="modal fade" id="add-tax" tabindex="-1">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <h5 class="modal-title"><?php echo e(\App\CentralLogics\translate('update_tax')); ?></h5>
                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                    <span aria-hidden="true">&times;</span>
                </button>
            </div>
            <div class="modal-body">
                <form action="<?php echo e(route('admin.pos.tax')); ?>" method="POST" class="row">
                    <?php echo csrf_field(); ?>
                    <div class="form-group col-12">
                        <label for=""><?php echo e(\App\CentralLogics\translate('tax')); ?> (%)</label>
                        <input type="number" class="form-control" name="tax" min="0">
                    </div>

                    <div class="form-group col-sm-12">
                        <button class="btn btn-sm btn-primary"
                                type="submit"><?php echo e(\App\CentralLogics\translate('submit')); ?></button>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>
<div class="modal fade" id="paymentModal" tabindex="-1">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <h5 class="modal-title"><?php echo e(\App\CentralLogics\translate('payment')); ?></h5>
                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                    <span aria-hidden="true">&times;</span>
                </button>
            </div>
            <div class="modal-body">
                <form action="<?php echo e(route('admin.pos.order')); ?>" id='order_place' method="post" class="row">
                    <?php echo csrf_field(); ?>
                    <div class="form-group col-12">
                        <label class="input-label" for=""><?php echo e(\App\CentralLogics\translate('amount')); ?> (<?php echo e(\App\CentralLogics\Helpers::currency_symbol()); ?>

                            )</label>
                        <input type="number" class="form-control" name="amount" min="0" step="0.01"
                               value="<?php echo e(round($total+$total_tax, 2)); ?>" disabled>
                    </div>
                    <div class="form-group col-12">
                        <label class="input-label" for=""><?php echo e(\App\CentralLogics\translate('type')); ?></label>
                        <select name="type" class="form-control">
                            <option value="cash"><?php echo e(\App\CentralLogics\translate('cash')); ?></option>
                            <option value="card"><?php echo e(\App\CentralLogics\translate('card')); ?></option>
                        </select>
                    </div>
                    <div class="form-group col-12">
                        <button class="btn btn-sm btn-primary"
                                type="submit"><?php echo e(\App\CentralLogics\translate('submit')); ?></button>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>

<?php /**PATH /home/v23cd0f9pc3c/public_html/cornermember/resources/views/admin-views/pos/_cart.blade.php ENDPATH**/ ?>