<?php require('header.php');?>
      <section class="pt-3 pb-3 page-info section-padding border-bottom bg-white">
         <div class="container">
            <div class="row">
               <div class="col-md-12">
                  <a href="index.php"><strong><span class="mdi mdi-home"></span> Home</strong></a> <span class="mdi mdi-chevron-right"></span> <a href="#">Checkout</a>
               </div>
            </div>
         </div>
      </section>


    <?php 
        if(isset($_SESSION['pin_code'])){
            $s_pin = $_SESSION['pin_code'];
        }
        else {
            $s_pin = '';
        }
        
        $statement2222 = $this->db->query("SELECT * FROM tbl_delivery_address WHERE user_id=? AND status=?",array($_SESSION['customer']['cust_id'],1));
        $result222 = $statement2222->result_array();
        foreach ($result222 as $row222) {
            $_SESSION['SH_address_id'] = $row222['delivery_address_id'];
            $SH_name = $row222['name'];
            $SH_phone = $row222['phone'];
            $SH_state = $row222['state'];
            $SH_district = $row222['district'];
            $SH_pin_code = $row222['pin_code'];
            // $SH_address = $row222['address'];
            $SH_address = '';
            
            
            $_SESSION['SH_name'] = $SH_name ;
            $_SESSION['SH_phone'] = $SH_phone ;
            $_SESSION['SH_state'] = $SH_state ;
            $_SESSION['SH_district'] = $SH_district;
            $_SESSION['SH_pin_code'] = $SH_pin_code;
            $_SESSION['SH_address'] = $SH_address;
            // print_r($_SESSION);
            
        }
        if(isset($_SESSION['SH_name'])){
            $SH_name = $_SESSION['SH_name'];
            $SH_phone = $_SESSION['SH_phone'];
            $SH_state = $_SESSION['SH_state'];
            $SH_district = $_SESSION['SH_district'];
            $SH_pin_code = $_SESSION['SH_pin_code'];
            $SH_address = $_SESSION['SH_address'];
        }
        
        
    if(isset($_SESSION['SH_name'])){
        if(isset($_POST['SH_name'])){
        if(isset($s_pin)){
        	$cust_datetime = date('Y-m-d h:i:s');
    
            // saving into the database
            $statement = $this->db->query("UPDATE tbl_delivery_address SET 
            name=?,
            phone=?,
            state=?,
            district=?,
            pin_code=?,
            addon=?,
            updated=?,
            status=?
            WHERE 
            user_id=?
            ",array(
            strip_tags($_POST['SH_name']),
            strip_tags($_POST['SH_phone']),
            strip_tags($_POST['SH_state']),
            strip_tags($_POST['SH_district']),
            $s_pin,
            $cust_datetime,
            $cust_datetime,
            1,
            $_SESSION['customer']['cust_id']
            ));
    
    
           
    }
    else
    {
        $this->session->set_flashdata('error','Please Provide Delivery Pin Code.');
    }
        redirect(base_url('checkout'));
    }
    }
    else
    {
        if(isset($_POST['SH_name'])){
        if(isset($s_pin)){
        	$cust_datetime = date('Y-m-d h:i:s');
    
            $statement = $this->db->query("UPDATE tbl_delivery_address SET status=? WHERE user_id=?",array(0,$_SESSION['customer']['cust_id']));
            // saving into the database
            $statement = $this->db->query("INSERT INTO  tbl_delivery_address (
            user_id,
            name,
            phone,
            state,
            district,
            pin_code,
            address,
            addon,
            updated,
            status
            ) VALUES (?,?,?,?,?,?,?,?,?,?)",array(
            $_SESSION['customer']['cust_id'],
            strip_tags($_POST['SH_name']),
            strip_tags($_POST['SH_phone']),
            strip_tags($_POST['SH_state']),
            strip_tags($_POST['SH_district']),
            $s_pin,
            strip_tags($_POST['SH_address']),
            $cust_datetime,
            $cust_datetime,
            1
            ));
    
    
           
    }
    else
    {
        $this->session->set_flashdata('error','Please Provide Delivery Pin Code.');
    }
        redirect(base_url('checkout'));
    }
    }
        
?>
      <section class="checkout-page section-padding">
         <div class="container">
            <div class="row">
               <div class="col-md-8">
                  <div class="checkout-step">
                     <div class="accordion" id="accordionExample">
                        <div class="card checkout-step-one">
                           <div class="card-header" id="headingOne">
                              <h5 class="mb-0">
                                 <button class="btn btn-link" type="button" data-toggle="collapse" data-target="#collapseOne" aria-expanded="true" aria-controls="collapseOne">
                                     Select Delivery Address
                                 </button>
                              </h5>
                           </div>
                           <div id="collapseOne" class="collapse show" aria-labelledby="headingOne" data-parent="#accordionExample">
                              <div class="card-body">
                                 <!--<p>We need your phone number so that we can update you about your order.</p>-->
                                 <div class="row">
                                        <div class="col-sm-12 col-12">
                                            <?php if(!isset($_SESSION['SH_district'])){ ?>
                                            
                                            <div class="form-check" style="width: 100%;height:auto;background: #eee;border-radius:5px;padding:10px 40px;">
                                                  <label class="form-check-label" data-target="#shipping_address_modal" data-toggle="modal" for="radio1">
                                                    <input type="radio" class="form-check-input" id="radio1" name="optradio" value="option1" checked="">
                                                    <div style="border: 2px  solid #ccc;border-radius: 10px;padding:10px 40px;text-align:center;">
                                                        <i class="mdi mdi-plus text-info"></i> Add Address
                                                    </div>
                                                  </label>
                                            </div>
                                            <?php } else { ?>
                                            <div class="form-check" style="width: 100%;height:auto;background: #eee;border-radius:5px;padding:10px 40px;">
                                                  <label class="form-check-label" for="radio1">
                                                    <input type="radio" class="form-check-input" id="radio1" name="optradio" value="option1" checked="">
                                                    <div style="border: 2px  solid #ccc;border-radius: 10px;padding:5px 10px;">
                                                        <strong>
                                                            <?=$_SESSION['SH_name'].',<br>';?>
                                                        </strong>
                                                        <span>
                                                            <?=$_SESSION['SH_district'].', '.$_SESSION['SH_state'].', '.$s_pin.' <br>+91 '.$_SESSION['SH_phone'];?>
                                                        </span>
                                                    </div>
                                                  </label>
                                            </div>
                                            <div class="col-12 text-center">
                                                <hr>
                                                <button class="btn btn-md btn-primary" data-target="#shipping_address_modal" data-id="<?=$_SESSION['SH_address_id'];?>" data-toggle="modal">Update Address</button>
                                            </div>
                                            <?php } ?>
                                            
                                        </div>
                                    </div>
                              </div>
                           </div>
                        </div>
                     </div>
                  </div>
                <div class="col-12"><br></div>
                <div class="card">
                     <h5 class="card-header">My Cart <span class="text-secondary float-right">(<?php
                                        if(isset($_SESSION['cart_p_id'])) {
                                            echo count($_SESSION['cart_p_id']);
                                        } else {echo '0';}
                                    ?> item)</span></h5>
                     <div class="card-body pt-0 pr-0 pl-0 pb-0">
                         
                         
                         <?php
                                
                                        $table_total_price = 0;
                                        $table_total_price_new=0;
                                        $i=0;
                                        if(isset($_SESSION['cart_p_id'])){
                                            foreach($_SESSION['cart_p_id'] as $key => $value)
                                            {
                                            $i++;
                                            $arr_cart_p_id[$i] = $value;
                                            }
                                        
                                        
                                        $i=0;
                                            foreach($_SESSION['cart_size_id'] as $key => $value)
                                            {
                                            $i++;
                                            $arr_cart_size_id[$i] = $value;
                                            }
                                        
                                        $i=0;
                                        foreach($_SESSION['cart_size_name'] as $key => $value)
                                        {
                                        $i++;
                                        $arr_cart_size_name[$i] = $value;
                                        }
                                        $i=0;
                                        foreach($_SESSION['cart_color_id'] as $key => $value)
                                        {
                                        $i++;
                                        $arr_cart_color_id[$i] = $value;
                                        }
                                        $i=0;
                                        foreach($_SESSION['cart_color_name'] as $key => $value)
                                        {
                                        $i++;
                                        $arr_cart_color_name[$i] = $value;
                                        }
                                        $i=0;
                                        foreach($_SESSION['cart_p_qty'] as $key => $value)
                                        {
                                        $i++;
                                        $arr_cart_p_qty[$i] = $value;
                                        }
                                        $i=0;
                                        foreach($_SESSION['cart_p_current_price'] as $key => $value)
                                        {
                                        $i++;
                                        $arr_cart_p_current_price[$i] = $value;
                                        }
                                        
                                        
                                        $i=0;
                                        foreach($_SESSION['cart_p_old_price'] as $key => $value)
                                        {
                                        $i++;
                                        $arr_cart_p_old_price[$i] = $value;
                                        }
                                        
                                        
                                        $i=0;
                                        foreach($_SESSION['cart_p_name'] as $key => $value)
                                        {
                                        $i++;
                                        $arr_cart_p_name[$i] = $value;
                                        }
                                        $i=0;
                                        foreach($_SESSION['cart_p_featured_photo'] as $key => $value)
                                        {
                                        $i++;
                                        $arr_cart_p_featured_photo[$i] = $value;
                                        }
                                        }
                                        ?>
                                        <?php 
                                        if(isset($arr_cart_p_id)) {
                                        for($i=1;$i<=count($arr_cart_p_id);$i++){
                                        ?>



                                        
                                            <input type="hidden" id="s1_<?=$i;?>" value="<?=$arr_cart_p_id[$i]; ?>">
                                            <input type="hidden" id="s2_<?=$i;?>" value="<?=$arr_cart_size_id[$i]; ?>">
                                            <input type="hidden" id="s3_<?=$i;?>" value="<?=$arr_cart_color_id[$i]; ?>">
                                            <input type="hidden" id="as1_<?=$arr_cart_p_id[$i];?>" value="<?=$arr_cart_p_id[$i]; ?>">
                                            <input type="hidden" id="as2_<?=$arr_cart_p_id[$i];?>" value="<?=$arr_cart_size_id[$i]; ?>">
                                            <input type="hidden" id="as3_<?=$arr_cart_p_id[$i];?>" value="<?=$arr_cart_color_id[$i]; ?>">
                                            <input type="hidden" id="pid_<?=$i;?>" name="product_id[]" value="<?=$arr_cart_p_id[$i]; ?>">
                                            <input type="hidden" id="pname_<?=$i;?>" name="product_name[]" value="<?=$arr_cart_p_name[$i]; ?>">
                                            
                                            
                                            
            <div class="cart-list-product" id="cartdel_<?=$arr_cart_p_id[$i]; ?><?=$arr_cart_size_id[$i]; ?>">
                <div class="row">
                   <div class="col-4"><img class="img-fluid" src="<?=base_url('uploads/shop/product/'.$arr_cart_p_featured_photo[$i]); ?>" alt="<?=$arr_cart_p_name[$i]; ?>"></div>
                   <div class="col-8">
                       
                   
               <!--<span class="badge badge-success">50% OFF</span>-->
               <a class="float-right remove-cart" href="javascript: void(0);" onclick="return removeItem('<?=$arr_cart_p_id[$i]; ?>','<?=$arr_cart_p_id[$i]; ?><?=$arr_cart_size_id[$i]; ?>','<?=$arr_cart_size_id[$i]; ?>
                ');"><i class="mdi mdi-close"></i></a>
               <h5><a href="#"><?=$arr_cart_p_name[$i]; ?></a></h5>
               <h6><strong><span class="mdi mdi-approval"></span> Available in</strong> - <?=$arr_cart_size_name[$i]; ?></h6>
               <p class="offer-price mb-0">
                    <span><?='&#8377;'.number_format($arr_cart_p_current_price[$i]*$arr_cart_p_qty[$i],2); ?></span>
                    <del class="text-black-50 font-weight-normal"><?='&#8377;'.number_format($arr_cart_p_old_price[$i]*$arr_cart_p_qty[$i],2); ?></del>
                    <br>
                    <span class="text-success font-italic">You save <?php
                    
                    $m =  $arr_cart_p_old_price[$i]*$arr_cart_p_qty[$i];
                    $n = $arr_cart_p_current_price[$i]*$arr_cart_p_qty[$i];
                    $o =  $m-$n;
                    echo '&#8377;';
                    echo number_format($o,2);
                    
                    // calculate total amount
                    $row_total_price = $m;
                    if(isset($table_total_price)){
                        $table_total_price = $table_total_price + $row_total_price;
                        $table_total_price_new = $table_total_price_new + $n;
                    }
                    else{
                        $table_total_price=$row_total_price;
                        $table_total_price_new = $n;
                    }
                            
                            
                    ?></span>
                    <br>
                    <span class="text-black-50 font-weight-normal">
                        QTY : <?=$arr_cart_p_qty[$i];?>
                    </span>                             
               </p>
               </div>
               </div>
            </div>
            <?php }
                                        }
                                        else
                                        {
                                            ?>
                                            <div class="col-md-12 text-center">
                                                <img src="<?=base_url('uploads/empty-cart.png');?>" class="img-fluid" />
                                            </div>
                                            <?php
                                        }
            ?>
    
                     </div>
                     <div 
                  </div>
               </div>
            </div>
            <div class="col-12"><br></div>
               </div>
               <div class="col-md-4">
                  <div class="card">
                     <h5 class="card-header">Payment Details</h5>
                     <div class="card-body pt-0 pr-0 pl-0 pb-0">
                         
                         
                        <?php
                            $statement4 = $this->db->query("SELECT * FROM tbl_shipping_cost_all WHERE status=? AND  min_amt <= ? AND max_amt >= ?",array(1,$table_total_price,$table_total_price));
                            if(count($statement4->result_array())){
                            $result4 = $statement4->result_array();
                            foreach ($result4 as $row4) {
                                $shipping_cost = $row4['amount'];
                            }
                        
                         
                         
                                $final_total = $table_total_price_new+$shipping_cost;
                            }
                            else{
                                $final_total=$table_total_price_new;
                                $shipping_cost=0;
                            }
                        
                        
                                ?>
         
         <div class="cart-sidebar-footer">
             <div class="row">
                 <div class="col-sm-12">
            <div class="cart-store-details">
                <div class="form-group">
                         <label>Have a Coupon Code</label>
                         <div id="message_c"></div>
                         <div class="input-group">
                             <input class="form-control" type="text" placeholder="Enter Coupon Code" id="enter_coupon_code">
                             <span class="input-group-btn">
                                 <button class="btn btn-success btn-lg1" id="apply_coupon_code" onclick="apply_coupon_code()">Apply</button>
                             </span>
                             
                         </div>
                 </div>
                
             <p>MRP Total - <strong class="float-right"><?=LANG_VALUE_1; ?> <?=number_format($table_total_price,2); ?></strong></p>
             <p>Discount - <strong class="float-right"><?=LANG_VALUE_1; ?> <?=$save = number_format($table_total_price-$table_total_price_new,2); ?></strong></p>
             <p>Sub Total - <strong class="float-right"><?=LANG_VALUE_1; ?> <?=number_format($table_total_price_new,2); ?></strong></p>
            
              <p>Shipping cost - <strong class="float-right"><?php if($shipping_cost==0){ echo 'FREE';}else{ echo LANG_VALUE_1.number_format($shipping_cost,2);} ?></strong></p>
              <p>Coupon Discount - 
              <strong class="float-right"  id="discount_c">
                  <?php 
                  if(isset($_SESSION['discount_percentage'])){
                      echo LANG_VALUE_1;
                      echo $ff = ($table_total_price_new/100)*$_SESSION['discount_percentage'];
                      $gg =  $final_total-$ff-$save;
                      $save = $save+$ff;
                  }
                  else
                  {
                        $gg=$final_total;
                        echo LANG_VALUE_1.'0.00';
                        
                  } 
                  
                  ?></strong>
                  <input type="hidden" id="final_total_c" value="<?=$table_total_price_new;?>">
                  <input type="hidden" id="shipping_cost" value="<?=$shipping_cost;?>">
                </p>
              <p>Total Amount - <strong class="float-right" id="to_pay"><?=LANG_VALUE_1.number_format($gg,2);$gg = number_format($gg,2); ?></strong></p>
              <p> <strong class="float-right text-success" id="you_save">You Save <?=LANG_VALUE_1.$save; ?></strong></p>
              <input type="hidden" id="you_save1" value="<?=$save;?>">
              
            </div>
            </div>
            
           <div class="col-sm-12 text-center d-none"> <hr>
                <form action="#paytm/PaytmKit/pgRedirect.php" method="post">
                
                    <input id="ORDER_ID" tabindex="1" maxlength="20" size="20" type="hidden"	name="ORDER_ID" autocomplete="off" value="<?=rand(1111,9999);?>" >
                    <input id="CUST_ID" tabindex="2" maxlength="12" size="12" name="CUST_ID" autocomplete="off" value="ORDS55402581"  type="hidden">
                    <input id="INDUSTRY_TYPE_ID" tabindex="4" maxlength="12" size="12" name="INDUSTRY_TYPE_ID" autocomplete="off" value="Retail"  type="hidden">
                    <input id="CHANNEL_ID" tabindex="4" maxlength="12" size="12" name="CHANNEL_ID" autocomplete="off" value="WEB"  type="hidden">
                    <input type='hidden' value='<?=$gg; ?>'  id="amount3" name='TXN_AMOUNT' >
                    
                    <input type='hidden' value='<?=$_SESSION['customer']['cust_phone']; ?>' name='mob' >
                    <input type="hidden" name="coupon_id" id="coupon_id2" value="<?php if(isset($coupon_id)){echo $coupon_id; }?>">
                    <input type="hidden" name="coupon_discount" id="coupon_discount2" value="<?php if(isset($ff)){echo $ff; }?>">
                    
                    <button class="btn btn-block btn-info" type="submit" name="form3">
                        <span class="float-left">
                            <span class="mdi mdi-credit-card"></span> Pay Online  
                        </span>
                        <span class="float-right">
                            <?=LANG_VALUE_1; ?> <b  id="amount4"><?=$gg; ?></b>
                        </span>
                    </button>
                    
                </form>  
           </div>
           <div class="col-sm-12">
               <hr>
                <form action="<?=base_url('Cash_on_delivery');?>" method="post" >
                
                        <input type="hidden" name="coupon_id" id="coupon_id" value="<?php if(isset($coupon_id)){echo $coupon_id; }?>">
                        <input type="hidden" name="coupon_discount" id="coupon_discount" value="<?php if(isset($ff)){echo $ff; }?>">
                        <input type="hidden" name="amount" id="amount" value="<?php if(isset($gg)){echo $gg; }?>">
                        <input type="hidden" name="shipping_address" id="shipping_address" value="<?php if(isset($_SESSION['SH_address_id'])){echo $_SESSION['SH_address_id']; }?>">
                        
                        
                        <input type="hidden" name="transaction_info" class="form-control" value="This Booking By COD. At <?=date('d M Y h:i:s A').". "; if(isset($c)){echo $c; }?> ">
                        <?php 
                                                if(!isset($_SESSION['SH_address_id'])){
                            
                        ?>
                            <button  onclick="alert('Please Add Delivery Address');return false;"  data-target="#shipping_address_modal" data-toggle="modal"  class="btn btn-block btn-secondary" name="form3">
                                <span class="float-left">
                                    <span class="mdi mdi-cart-outline"></span> Cash on Delivery  
                                </span>
                                <span class="float-right"><?=LANG_VALUE_1; ?> <b  id="amount2"><?=$gg; ?></b></span>
                            </button>
                        
                        <?php 
                        }

                        elseif(!empty($s_pin)){ ?>
                        
                            <button type="submit" class="btn  btn-block btn-secondary" name="form3"><span class="float-left"><span class="mdi mdi-cart-outline"></span> Cash on Delivery  </span><span class="float-right"><?=LANG_VALUE_1; ?> <b  id="amount2"><?=$gg; ?></b></span></button>
                        <?php 
                            
                            
                        }
                        else{
                            
                        ?>
                            <button  onclick="alert('Please Enter Delivery Pincode');return false;"  data-target="#pin_modal" data-toggle="modal"  class="btn btn-block btn-secondary" name="form3">
                                <span class="float-left">
                                    <span class="mdi mdi-cart-outline"></span> Cash on Delivery  
                                </span>
                                <span class="float-right"><?=LANG_VALUE_1; ?> <b  id="amount2"><?=$gg; ?></b></span>
                            </button>
                        
                        <?php 
                        }
                        ?>
                </form>
           </div>
       </div>
         </div>
         
                         
                         
                     </div>
                     <div 
                  </div>
               </div>
            </div>
         </div>
         </div>
         </div>
      </section>
     
     
     <script>
         // <!--apply coupon script-->
                 function apply_coupon_code(){
            var coupon = $("#enter_coupon_code").val();
            var final_total = $("#final_total_c").val();
          if(coupon){
            $.ajax({
                    url:"coupon.php",
                    type:"POST",
                    data:{coupon: coupon,final_total: final_total},
                    // dataType: 'json',
                    success:function(data)
                        {
                            
                            var obj = JSON.parse(data);
                            if(obj.succ == 1){
                                $("#message_c").html('<b id="success" class="text-success">Coupon Aplied Successfully. '+ obj.message +'</b>');
                                
                                var final_total = $("#final_total_c").val();
                                var discount_c = parseFloat(final_total/100)*parseFloat(obj.discount_percentage);
                                var discount_c2 = discount_c;
                                var shipping_cost = $("#shipping_cost").val();
                                
                                var to_pay = parseFloat(final_total)-parseFloat(discount_c)+parseFloat(shipping_cost);
                                var to_pay = to_pay.toFixed(2);
                                var discount_c = discount_c.toFixed(2);
                                $("#discount_c").html('&#8377; '+ discount_c);
                                $("#coupon_discount2").val(discount_c);
                                $("#coupon_id2").val(obj.coupon_id);
                                $("#coupon_discount").val(discount_c);
                                $("#coupon_id").val(obj.coupon_id);
                                
                                
                                $("#to_pay").html('&#8377; '+ to_pay);
                                $("#amount").val(to_pay);
                                $("#amount2").html(to_pay);
                                var you_save = parseFloat($("#you_save1").val());
                                var vvv = you_save+discount_c2;
                                var vvv = vvv.toFixed(2);
                                $("#you_save").html('You Save &#8377;' + vvv);
                                $("#amount3").val(to_pay);
                                $("#amount4").html(to_pay);
                                // $("#success").fadeOut(3500);
                                
                            }
                            if(obj.error == 1){
                                $("#message_c").html('<b id="error" class="text-danger">Invalid, Expired or Used Coupon.</b>');
                                $("#discount_c").html('&#8377;0.00');
                                var final_total = parseFloat($("#final_total_c").val());
                                var shipping_cost = parseFloat($("#shipping_cost").val());
                                var final_total =  final_total+shipping_cost;
                                $("#to_pay").html('&#8377; '+final_total.toFixed(2));4
                                
                                
                                $("#coupon_discount2").val('0.00');
                                $("#coupon_id2").val('');
                                $("#coupon_discount").val('0.00');
                                $("#coupon_id").val('');
                                
                                var you_save = parseFloat($("#you_save1").val());
                                var vvv = you_save;
                                $("#you_save").html('You Save &#8377;' + vvv);
                                
                                $("#amount").val(final_total.toFixed(2));
                                $("#amount2").html(final_total.toFixed(2));
                                $("#amount3").val(final_total.toFixed(2));
                                $("#amount4").html(final_total.toFixed(2));
                                // $("#error").fadeOut(3500);
                                
                            }
                        }
                    
                });
              }
             
			}  
// <!--apply coupon script end-->
         
     </script>
     

     
    
       <div class="modal fade login-modal-main" id="shipping_address_modal">
         <div class="modal-dialog modal-md modal-dialog-centered" role="document">
            <div class="modal-content">
               <div class="modal-header bg-light">
                   <h4 class="heading-design-h4">Delivery Address</h4>
                                      
                   <button type="button" class="close close-top-right" data-dismiss="modal" aria-label="Close">
                           <span aria-hidden="true"><i class="mdi mdi-close"></i></span>
                           <span class="sr-only">Close</span>
                           </button>
               </div>
               <div class="modal-body">
                  <div class="login-modal">
                     <div class="row">
                        <div class="col-lg-12 pad-left-0">
                           
                           <!--<form>-->
                              <div>
                                 <!-- Tab panes -->
                                 <div class="tab-content">
                                    <div class="tab-pane active" role="tabpanel">
                                       
                                       <form   action="<?=base_url('checkout');?>" method="post">
                                    <div class="row">
                                       <div class="col-12">
                                          <div class="form-group">
                                             <label class="control-label">Name <span class="required">*</span></label>
                                             <input name="SH_name" class="form-control border-form-control" required value="<?php if(isset($SH_name)){ echo $SH_name;}else{ echo $_SESSION['customer']['cust_name'];} ?>" placeholder="Gurdeep" type="text">
                                          </div>
                                       </div>
                                       <div class="col-sm-6 col-12">
                                          <div class="form-group">
                                             <label class="control-label">Phone <span class="required">*</span></label>
                                             <div class="input-group input-group-sm">
                                                <div class="input-group-prepend">
                                                  <span class="input-group-text">+91</span>
                                                </div>
                                                 <input name="SH_phone" class="form-control border-form-control" required value="<?php if(isset($SH_phone)){ echo $SH_phone;}else{ echo $_SESSION['customer']['cust_phone'];} ?>" placeholder="0123456789" type="tel" onkeypress="return isNumberKey(event)">
                                             </div>
                                             
                                          </div>
                                       </div>
                                    
									   <div class="col-sm-6 col-12">
                                          <div class="form-group">
                                             <label class="control-label">State <span class="required">*</span></label>
                                                    <select onchange="getdt()" id="statef" name="SH_state" class="form-control border-form-control" style="width: 100%;">
                                                        <!--<option value="">Select State</option>-->
                                                           <?php  
                                                                $statement9 = $this->db->query("SELECT * FROM tbl_state");
                                                                $result9 = $statement9->result_array();                            
                                                                foreach ($result9 as $row) {
                                                                    if(!empty($SH_state)){
                                                                  ?>
                                                                    
                                                                  <option value="<?=$row['state']; ?>" <?php if($row['state'] == $SH_state) {echo 'selected';} ?>><?=$row['state']; ?></option>   
                                                                   
                                                                <?php 
                                                                    }
                                                                    else
                                                                    {
                                                                        ?>
                                                                        <option value="<?=$row['state']; ?>" <?php if($row['state'] == $_SESSION['customer']['cust_state']) {echo 'selected';} ?>><?=$row['state']; ?></option>   
                                                                   
                                                                        <?php
                                                                    }
                                                                    }
                                                                ?>
                                                    </select>
                                    
                                    
                                             
                                          </div>
                                       </div>
                                       
                                        <div class="col-sm-6 col-12">
                                          <div class="form-group">
                                             <label class="control-label">District <span class="required">*</span></label>
                                                <select name="SH_district" id="distgg" class="form-control border-form-control" style="width: 100%;">
                                                    <option value="Patna">Patna</option>
                                                </select> 
                                          </div>
                                       </div>
                                    
                                       <div class="col-sm-6 col-12">
                                          <div class="form-group">
                                             <label class="control-label">Zip Code <span class="required">*</span></label>
                                              <input name="SH_pin_code" class="form-control" required value="<?=$s_pin; ?>" readonly onkeypress="return isNumberKey(event)" onclick="$('#pin_modal').modal('toggle');$('#shipping_address_modal').modal('toggle');$('#shipping_address_modal').modal('toggle');" placeholder="Pin Code" type="tel">
                                          </div>
                                       </div>
                                     
                                    
                                       <!--<div class=" col-12">
                                          <div class="form-group">
                                             <label class="control-label">Shipping Address <span class="required">*</span></label>
                                             <textarea name="SH_address" required class="form-control"><?php if(isset($SH_address)){ echo $SH_address;}else{ echo $_SESSION['customer']['cust_address'];} ?></textarea>
                                             
											 
										</div>
										</div>-->
                                       <div class="col-12"> 
                                       <input type="submit" name="m" class="btn-secondary float-right btn btn-md" value="Save Address">
                                       </div>
                                    </div>
                                   
                                </form>
                                    </div>
                                 </div>
                              </div>
                           <!--</form>-->
                        </div>
                     </div>
                  </div>
               </div>
            </div>
         </div>
      </div>
      
     
     <script>  
	 function getdt(){
    var dt=$("#statef").val();
   

        $.ajax({
                url:"<?=base_url('get/district');?>",
                 type:"POST",
                 data:{dt:dt},
                // dataType: 'json',
                 success:function(data)
                 {
           $("#distgg").html(data);
                 }
                     
                 })

	 }      
</script> 
     
     
      <!-- Footer -->
<?php require('footer.php');?>