<?php  

$customer1 = $this->db->where('c_id', $this->session->userdata('customer'))->get('customer')->result_array();

?>



    <div class="offcanvas-overlay"></div>



    <!-- Page Title/Header Start -->

    <div class="page-title-section section" data-bg-image="assets/images/bg/page-title-1.webp">

        <div class="container">

            <div class="row">

                <div class="col">



                    <div class="page-title">

                        <h1 class="title">Checkout</h1>

                        <ul class="breadcrumb">

                            <li class="breadcrumb-item"><a href="<?php echo base_url(); ?>">Home</a></li>

                            <li class="breadcrumb-item active">Checkout</li>

                        </ul>

                    </div>



                </div>

            </div>

        </div>

    </div>

    <!-- Page Title/Header End -->



    <!-- Checkout Section Start -->

    <div class="section section-padding">

        <div class="container">           



            <div class="row learts-mb-n30">





                <div class="col-lg-6 order-lg-1 learts-mb-30">



                    <div class="section-title2">

                        <h4 class="title">Billing details</h4>

                    </div>

                    <form action="<?php echo base_url();?>order/order_booking/" method="post" id="checkout_form" class="checkout-form learts-mb-50">

                        <div class="row">

                            <div class="col-md-12 col-12 learts-mb-20">

                                <label for="bdFirstName"> Name <abbr class="required">*</abbr></label>

                                <input type="text" name="name" placeholder="Name" value="<?php echo $customer1[0]['name']; ?>" required>

                            </div>

                           

                            <div class="col-md-6 col-12 learts-mb-20">

                                <label for="bdEmail">Email address <abbr class="required">*</abbr></label>

                                <input class="email" type="email" name="email" value="<?php echo $customer1[0]['email']; ?>" placeholder="Email" required>

                            </div>

                            <div class="col-md-6 col-12 learts-mb-30">

                                <label for="bdPhone">Phone <abbr class="required">*</abbr></label>

                                <input type="text" name="mobile" value="<?php echo $customer1[0]['mobile']; ?>" placeholder="Mobile No." required>

                            </div>

                            

                            <div class="col-12 learts-mb-20">

                                <label for="bdTownOrCity">City <abbr class="required">*</abbr></label>

                                <input type="text" name="city" value="<?php echo $customer1[0]['city']; ?>" placeholder="City" required>

                            </div>

                            <div class="col-12 learts-mb-20">

                                <label for="State">State <abbr class="required">*</abbr></label>

                                <input type="text" name="state" value="<?php echo $customer1[0]['state']; ?>" placeholder="State" required>

                            </div>

                            

                            <div class="col-12 learts-mb-20">

                                <label for="bdPostcode">Pincode</label>

                                <input type="text" name="pin"  value="<?php echo $customer1[0]['pin']; ?>" placeholder="Pincode" required>

                            </div>



                            <div class="col-12 learts-mb-20">

                                <label for="bdPostcode">Landmark</label>

                                <input type="text" name="landmark"  value="" placeholder="Landmark" required>

                            </div>



                            <div class="col-12 learts-mb-20">

                                <label for="bdOrderNote">Address</label>

                                <textarea placeholder="Your Full Address" name="address" required><?php echo $customer1[0]['address']; ?></textarea>

                                <input type="hidden" name="payment" id="payment_mode" value="COD">

                            </div>

                        </div>

                    </form>

                </div>



                <div class="col-lg-6 order-lg-2 learts-mb-30">

                    <div class="order-review">

                        <table class="table">

                            <thead>

                                <tr>

                                    <th class="name">Product</th>

                                    <th class="total">Subtotal</th>

                                </tr>

                            </thead>

                            <tbody>

                                <?php  

                                $grang_total=0;
                                $delivery_charge=0;
                                foreach ($chechout_data as $key => $chk_data) {

                                $data_product = $this->db->select('*')->where('prd_id', $chk_data['prd_id'])->get('product')->result_array();

                                $sub_total=$chk_data['quantity']*$data_product['0']['p_sell_price'];

                                $grang_total=$grang_total+$sub_total;
                                $shipping_charge=$chk_data['quantity']*$data_product['0']['shiping_chrg'];
                                $delivery_charge=$delivery_charge+$shipping_charge;
                                ?>

                                <tr>

                                    <td class="name"><?php echo $data_product['0']['p_title']; ?>&nbsp; <strong class="quantity">×&nbsp;<?php echo $chk_data['quantity']; ?></strong></td>

                                    <td class="total"><span>₹ <?php echo $sub_total; ?></span></td>

                                </tr>

                            <?php } 
                            if ($grang_total>1000) {
                                    $delivery_charge=0;
                                }
                                $grang_total=$grang_total+$delivery_charge;
                                if ($delivery_charge=='0') {
                                    $delivery_charge='Free';
                                }
                                else
                                {
                                $delivery_charge=$delivery_charge;
                                }
                            ?>

                               <tr>

                                    <td class="name">Delivery Charge</td>

                                    <td class="total"><span><?php echo $delivery_charge; ?></span></td>

                                </tr> 

                            </tbody>

                            <tfoot>

                                <tr class="subtotal">

                                    <th>Subtotal</th>

                                    <td><span>₹<?php echo $grang_total; ?></span></td>

                                </tr>

                                <tr class="total">

                                    <th>Total</th>

                                    <td><strong><span>₹<?php echo $grang_total; ?></span></strong></td>

                                </tr>

                            </tfoot>

                        </table>

                    </div>



                    <div class="order-payment">

                        <div class="payment-method">

                            <div class="accordion" id="paymentMethod">

                                <div class="card cardcod active">

                                    <div class="card-header">

                                        <button data-bs-toggle="collapse" data-bs-target="#cashkPayments"  onclick="payment('COD');">Cash on delivery </button>

                                    </div>

                                    <div id="cashkPayments" class="collapse" data-bs-parent="#paymentMethod">

                                        <div class="card-body">

                                            <p>Pay with cash on delivery.</p>

                                        </div>

                                    </div>

                                </div>

                                <div class="card cardonline">

                                    <div class="card-header">

                                        <button data-bs-toggle="collapse" data-bs-target="#payPalPayments" onclick="payment('Online');">Online <img src="assets/images/others/pay-2.webp" alt=""></button>

                                    </div>

                                    <div id="payPalPayments" class="collapse" data-bs-parent="#paymentMethod">

                                        <div class="card-body">

                                            <p>Pay via Online; you can pay with your credit card or debit card.</p>

                                        </div>

                                    </div>

                                </div>

                            </div>

                        </div>

                        <div class="text-center">

                            <button class="btn btn-dark btn-outline-hover-dark submitcheckout">place order</button>

                        </div>

                    </div>



                </div>

            </div>

        </div>

    </div>

    <!-- Checkout Section End -->

    <script type="text/javascript">

        function payment(mode)

        {

            $("#payment_mode").val(mode);
            if (mode=='COD') {            
            $(".cardonline").removeClass("active");
            $(".cardcod").addClass("active");
            }
            else
            {
            $(".cardcod").removeClass("active");
            $(".cardonline").addClass("active");
            }

        }



        $('.submitcheckout').click( function() {

        $('#checkout_form').submit();

        });

    </script>

 

 