<!DOCTYPE html>
<html lang="en-US">
<head>
    <title>Cart - Golf Evolution</title>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <?php include 'member_layout/analyticscode.php' ?>
    <link rel="icon" href="<?= base_url()."/public"; ?>/assets/member_images/favicon.png" sizes="192x192" />
    <link rel="apple-touch-icon" href="<?= base_url()."/public"; ?>/assets/member_images/favicon.png" />
    <link rel="preconnect" href="https://fonts.googleapis.com">
    <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
    <link href="https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;700&display=swap" rel="stylesheet">
    <link rel="stylesheet" href="<?= base_url()."/public"; ?>/assets/member_css/front-style.css">
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.4/jquery.min.js"></script>
    <script src="<?= base_url()."/public"; ?>/assets/member_js/ajax.js"></script>
    <input id="url" value="<?= base_url() ?>" type="hidden">
</head>
<body class="cart">

<?php include 'member_layout/header.php' ?>

<section class="pt-5 pb-3 cart-inner">
    <div class="container">
      <h1 class="heading-border">Cart</h1>


    <form method="post" action="<?= base_url('/payment/').md5($token); ?>">

        <?php 
        $cost_sum = 0;
        if (isset($tokendata)) {
        foreach ($tokendata as  $key => $value) { ?>


            <input type ="hidden" name="pack_id[]" value="<?= $value['id'] ?>">
            <input type ="hidden" id="cart_token_id_<?php echo $key; ?>" name="cart_token_id[]" value="<?= $pack_id[$key]['id'] ?>">

            <!-- List of Products -->
            <div class="row border-bottom pt-4 pb-4">
                <div class="col-2 col-lg-1 mt-2">
                    <img src="<?= base_url()."/public"; ?>/assets/member_images/cart-icon.png" width="70" height="70">
                </div>
                <div class="col-10 col-lg-7">
                    <div class="product-name"><?= $value['package_name'] ?></div>
                    <div class="credits-number"><?= $value['credit'] ?> Credits</div>
                    <div class="credit-point"><?= $value['offer_label'] ?></div>
                    <div class="credit-price">1 Credit at $<?= round($value['cost'] / $value['credit'] , 2); ?></div>
                </div>
                <div class="col-8 col-lg-2 mt-4">                            
                    <div class="quantity">   
                    <div class="d-flex"><span class="price-symbol">$</span><span class="price"><?php $number = $value['cost'];echo number_format($number, 2, '.', ''); ?></span><span>x</span></div>  
                                      
                    <div class="qty-no">
                    <button type="button" class="minus"><i class="fa fa-minus"></i></button>
                    <input type="number" onKeyDown="return false" id="0" class="input-text qty text" name="count[]" value="5" title="Qty" size="4" min="1" max="" step="1" placeholder="" inputmode="numeric" autocomplete="off" disabled/>
                       <button type="button" class="plus"><i class="fa fa-plus"></i></button>
                         </div>
                    </div>
                </div>               
                <div class="col-4 col-lg-2 mt-4 text-right-price">
                    <div class="product-price <?php echo $key; ?>">$<?php $number = $value['cost'] * $pack_id[$key]['count'];echo number_format($number, 2, '.', ''); ?></div>
                    <input id="cost_<?php echo $key; ?>" value="<?= $value['cost'] ?>" type="hidden">
                    <div class="remove-product"><a href="<?= base_url('/remove_product/').md5($pack_id[$key]['id']); ?>">Remove</a></div>
                </div>    
            </div>        
        <?php $cost_sum = $cost_sum +$value['cost'] * $pack_id[$key]['count']; } } ?>

        <!-- cart empty msg -->
        <?php if (isset($msg)) { echo '<center>'.$msg.'</center>'; }?>
        


        <?php if (isset($tokendata)) { ?>
            <!-- Product Sub total-->
            <div class="row sub-total border-bottom pt-4 pb-4">
                <div class="col-12">    
                    <div class="row">
                        <div class="col-3 pb-4">
                            <div class="subtotal-label">Subtotal</div>
                        </div> 
                        <div class="col-9">                           
                            <div class="subtotal-price text-right-price subtotal"><span class="price-symbol">$</span><?php $number = $cost_sum;echo number_format($number, 2, '.', ''); ?></div>
                        </div>    
                    </div>

                    <!-- Product Tax-->                                        
                    <div class="row">
                            <div class="col-6 col-lg-6">
                                <div class="subtotal-label">Taxes</div>
                            </div>
                            <div class="col-1 col-lg-2"></div>                          
                                <div class="col-2 col-lg-2 text-end">
                                <div class="taxes pst-label">GST</div>                            
                                </div>
                                <div class="col-3 col-lg-2 text-end">
                                   <input id="gst" value="<?= $gst[0]['value'] ?>" type="hidden">
                                    <div class="subtotal-price text-right-price gst"><span class="price-symbol">$</span><?php $number = $cost_sum * $gst[0]['value'] / 100; echo number_format($number, 2, '.', ''); ?></div>                            
                                </div>
                          
                            <div class="col-6 col-lg-6">                               
                            </div>
                            <?php if ($pst[0]['value'] != 0) { ?>
                            <div class="col-lg-2"></div>
                            <div class="col-lg-2 text-end">
                                <div class="taxes gst-label">PST</div>                            
                            </div>
                            <div class="col-lg-2 text-end">
                                <input id="pst" value="<?= $pst[0]['value'] ?>" type="hidden">
                                <div class="subtotal-price text-right-price pst"><span class="price-symbol">$</span><?= $cost_sum * $pst[0]['value'] / 100; ?></div>                            
                            </div>
                            <?php } ?>
                    </div>
                </div>    
           </div> 
           <!-- Product Sub total-->
           <div class="row pt-4 pb-4">
                <div class="col-3 pb-4">
                        <div class="subtotal-label">Total</div>
                    </div> 
                    <div class="col-9">
                        <div class="subtotal-price text-right-price total"><span class="price-symbol">$</span><?php $number = $cost_sum + $cost_sum * $pst[0]['value'] / 100  + $cost_sum * $gst[0]['value'] / 100 ;echo number_format($number, 2, '.', ''); ?></div>
                </div>               
           </div> 
        <?php } ?>
           <!-- Product Sub total-->
           <div class="row pt-3 pb-4 reverse-flexbtn">
           <?php if (!isset($msg)) { 
                echo '<div class="col-12 col-sm-6 pb-4 text-sm-start text-center">';
           } 
           else {
                echo '<div class="col-12 col-lg-12 pb-4 text-center">';
           } ?>
                        <form class="coupon-field">
                            
                            <a href="<?php 
                            if (session()->has('token')) 
                            {
                               echo base_url('/membership/').md5(session()->get('token'));   
                            }
                            else
                            {
                                echo base_url('membership'); 
                            } 
                            
                            ?>"  class="shopping-btn">Continue Shopping</a>
                        </form>
                    </div> 
                    <?php if (!isset($msg)) { ?>
                    <div class="col-12 col-sm-6 checkout-btn text-center text-sm-end mb-4">
                        <button type="submit">Checkout</button>
                    </div>  
                    <?php } ?>             
           </div>
        </div>       
    </div> 
    </form>

</section>

<?php include 'member_layout/footer.php' ?>

</body>
</html>
