<?php
$this->load->view("top_application");
$discount_amount = $this->session->userdata('discount_amount');
?>
<div class="breadcrumb clearfix">
  <div class="container" >
    <!-- breadcrumb -->

    <a class="home" href="<?php echo site_url(); ?>" title="Return to Home">Home</a>
    <span class="navigation-pipe">&nbsp;</span>
    <span class="navigation_page">Confirm Address</span>
  </div>
</div>
<!-- ./breadcrumb -->
<!-- page heading-->
<div id="columns">
  <div class="container">
    <h2 class="page-heading">
      <span class="page-heading-title2">Confirm Address</span>
    </h2>
    <div class="page-content page-order">
      <ul class="step">
        <li><span>01. Summary</span></li>
        <li><span>02. Sign in</span></li>
        <li><span>03. Shipping Address</span></li>
        <li class="current-step"><span>04. Review Order</span></li>
        <li><span>05. Payment</span></li>
      </ul>
    </div>
    <!-- ../page heading-->
    <div class="page-content">
      <div class="row">
        <div class="col-sm-9">
          <div class="box-inputfeilds">
            <div class="row">  
              <div class="col-sm-6">
                <div class="top-cs">
                  <p>We will deliver your order here</p>
                </div>
              </div>
              <div class="col-sm-6">
                <div class="top-cs">
                  <a href="<?php echo site_url('products'); ?>" class="button pull-right">Continue Shopping</a>
                </div>
              </div>
              <div class="col-sm-6">              
                <h3>Shipping Address</h3>
                <div class="cb20"></div>
                <ul class="value-box">
                  <li class="control">
                    <label for="name"><strong>Name</strong></label>
                    <?php
                    echo $posted_data['name'];
                    ?>
                  </li>
                  <li class="control">
                    <label for="name"><strong>Mobile Number</strong></label>
                    <?php echo $posted_data['mobile']; ?>
                  </li>
                  <li class="control">
                    <label for="name"><strong>Address</strong></label>
                    <?php echo $posted_data['address']; ?>
                  </li>	
                  <?php
                  if ($posted_data['landmark'] != '') {
                    ?>
                    <li class="control">
                      <label for="name"><strong>Landmark</strong></label>
                      <?php echo $posted_data['landmark']; ?>
                    </li>
                    <?php
                  }
                  ?>
                  <li class="control">
                    <label for="name"><strong>City</strong></label>
                    <?php echo $posted_data['city']; ?>
                  </li>
                  <!--li class="control" hidden="hidden">
                    <label for="name"><strong><?php echo ($this->session->userdata('lang') == 'p') ? $this->lang->line('pincode') : 'Pincode'; ?></strong></label>
                  <?php echo $posted_data['zipcode']; ?>
                  </li-->
                  <li class="control">
                    <label for="name"><strong>State</strong></label>
                    <?php echo $posted_data['state']; ?>
                  </li>
                  <li class="control">
                    <label for="name"><strong>Country</strong></label>
                    <?php
                    echo $scountry = $posted_data['country'];
                    ?>
                  </li>
                </ul>
              </div>         
              <div class="col-sm-6">               
                <h3>Billing Address</h3>
                <div class="cb20"></div>
                <ul class="value-box">
                  <li class="control">
                    <label for="name"><strong>Name</strong> </label>
                    <?php
                    echo $posted_data['bil_name'];
                    ?>
                  </li>
                  <li class="control">
                    <label for="name"><strong>Mobile Number</strong></label>
                    <?php echo $posted_data['bil_mobile']; ?>
                  </li>
                  <li class="control">
                    <label for="name"><strong>Address</strong></label>
                    <?php echo $posted_data['bil_address']; ?>
                  </li>	
                  <?php
                  if ($posted_data['bil_landmark'] != '') {
                    ?>
                    <li class="control">
                      <label for="name"><strong>Landmark</strong></label>
                      <?php echo $posted_data['bil_landmark']; ?>
                    </li>
                    <?php
                  }
                  ?>
                  <li class="control">
                    <label for="name"><strong>City</strong></label>
                    <?php echo $posted_data['bil_city']; ?>
                  </li>
                  <!--li class="control" hidden="hidden">
                    <label for="name"><strong><?php echo ($this->session->userdata('lang') == 'p') ? $this->lang->line('pincode') : 'Pincode'; ?></strong></label>
                  <?php echo $posted_data['bil_zipcode']; ?>
                  </li-->
                  <li class="control">
                    <label for="name"><strong>State</strong></label>
                    <?php echo $posted_data['bil_state']; ?>
                  </li>
                  <li class="control">
                    <label for="name"><strong>Country</strong></label>
                    <?php
                    echo $bcountry = $posted_data['bil_country'];
                    ?>
                  </li>
                </ul>
                <button class="button pull-right" onclick="window.location.href = '<?php echo site_url('cart/delivery_info'); ?>';">Edit Address</button>
              </div>
            </div>
          </div>
        </div>
        <div class="column col-xs-12 col-sm-3" id="left_column">
          <!-- block best sellers -->
          <div class="block left-module">
            <p class="title_block">My Cart</p>
            <div class="block_content">
              <ul class="products-block best-sell">
                <?php
                $cart = $this->cart->contents();
                $totalAmount = $origAmount = $discountAmt = 0;
                $i = 1;
                foreach ($cart as $items) {
                  $totalAmount +=$items['price'] * $items['qty'];
                  ?>
                  <li>
                    <div class="products-block-left">
                      <a href="#">
                        <img src="<?php echo get_image('product_images', $items['img'], '80', '80', 'R'); ?>" alt="">
                      </a>
                    </div>
                    <div class="products-block-right">
                      <p class="product-name">
                        <a href="#"><?php echo $items['origname']; ?></a>
                      </p>
                      <p class="product-price"><?php echo display_price($items['price']); ?></span></p>
                      <p class="product-name"><?php echo ($this->session->userdata('lang') == 'p') ? $this->lang->line('qty') : 'Qty'; ?>: <?php echo $items['qty']; ?></span></p>
                    </div>
                  </li>
                  <?php
                  $i++;
                }
                ?>
              </ul>
            </div>
          </div>
          <div class="checkout-page">
            <div class="box-border">
              <ul class="shipping_method">
                <?php
                if ($discount_amount > 0) {
                  ?>
                  <li>
                    <p class="subcaption "><?php echo 'Discount'; ?>: <span class="bold"><?php echo display_price($discount_amount); ?></span></p>
                  </li>
                  <?php
                }
                ?>
                <li>
                  <p class="subcaption "><?php echo ($this->session->userdata('lang') == 'p') ? $this->lang->line('payable_amount') : 'Payable Amount'; ?>: <span class="bold"><?php echo display_price($totalAmount - $discount_amount); ?></span></p>
                </li>
              </ul>
            </div>
          </div>
          <div class="block left-module">
            <p class="title_block">Payment Options</p>
            <div class="block-content">
              <form name="" id="paymentForm" method="post" action="">  
                <div>
                  <input id="radio2" name="pay" value="payu" type="radio" checked>
                  <label for="radio2">Pay Now (Debit & Credit Card)</label>
                </div>
                <div>
                  <input id="radio2" name="pay" value="COD" type="radio" >
                  <label for="radio2">Cash on Delivery</label>
                </div>
                <div class="m10x0">
                  <input name="terms" id="checkTerms" value="1" class="checkbox_left" required="" type="checkbox"> <span>I Agree. <a href="<?php echo site_url('terms-conditions'); ?>" class="tnch" target="_blank">Terms And Conditions.</a> </span>
                </div>

                <!-- For Payu Money -->
                <?php
                //trace($this->session->userdata); 
                $posteddata = $this->session->userdata('posted_data');
                ?>
                <input type="hidden" name="key" value="fIMaqPur" />
                <input type="hidden" name="hash" value=""/>
                <input type="hidden" name="txnid" value="" />
                <input type="hidden" name="amount" value="<?php echo $totalAmount-$discount_amount; ?>" />
                <input type="hidden" name="firstname" value="<?php echo $posteddata['name']; ?>" />
                <input type="hidden" name="email" value="<?php echo ($this->session->userdata('username')) ? $this->session->userdata('username') : $posteddata['email']; ?>" />
                <input type="hidden" name="phone" value="<?php echo $posteddata['mobile']; ?>" />
                <input type="hidden" name="productinfo" value="RJ Attires Clothing" />
                <input type="hidden" name="service_provider" value="payu_paisa" size="64" />
                <!-- End here -->

                <div class="confirm-order">
                  <button class="button payButton" type="submit">Complete Order</button>
                </div>
              </form>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</div>

<?php $this->load->view("bottom_application"); ?>
<script type="text/javascript">
  $('.payButton').click(function (e) {
    e.preventDefault();
    if ($("#checkTerms").is(':checked')) {
      $('#paymentForm').submit();
    }
    else {
      alert('Please Check to agree RJ Attires Terms & Conditions.');
    }
  });
</script>