<?php $this->load->view('top');?>
<div class="page_breadcrumbs">
  <div class="container">
    <ul>
      <li><a href="<?= site_url(); ?>" title="Home">Home</a>
      </li>
      <li>Thank You</li>
    </ul>
  </div>
</div>
<section class="sec-message thank_you">
  <div class="container">
      <div class="sec-content">
    <h1 class="bg-title text-center" style="margin-top:7%">
      <?php echo ($ordmaster['payment_status'] == 'Paid' || $ordmaster['payment_method'] == 'Cash') ? 'Order Placed' : 'Payment Failed'; ?>

    </h1>
    <div class="clearfix"></div>
    <div class="row">
      <div class="col-md-12 col-sm-12 col-xs-12">
        <h4 class="mb-70 thankyou-text text-center"> 
          <?php
          if (is_array($ordmaster) && !empty($ordmaster)) {
            if ($ordmaster['payment_status'] == 'Paid' || $ordmaster['payment_method'] == 'Cash') {
              ?>
            <img src="<?php echo theme_url();?>images/check.gif" class="check-icon"/>
              Thank you for choosing <?php echo SITENAME;?><br/>
              <b>Order Confirmation Number</b>: #DS_<?php echo $ordmaster['order_id']; ?> is Confirmed!
              <?php
            } else {
              ?>
            <img src="<?php echo theme_url();?>images/failed.gif" class="check-icon"/>
              <b>Your Order</b> #DS_<?php echo $ordmaster['order_id']; ?> has been canceled/declined!
              <?php
            }
          } else {
            ?>
            <b>Your Order</b> at <?php echo SITENAME;?> has been canceled/declined!
            <?php
          }
          ?>
        </h4>
        <br/>
        <?php
        if (is_array($ordmaster) && !empty($ordmaster)) {
          ?>
          <table class="table table-bordered table-hover hidden_mobile">
            <thead>
              <tr>
                <th>Product</th>
                <th>Price</th>
                <th>Quantity</th>
                <th>Sub Total</th>
              </tr>
            </thead>
            <tbody>
              <?php
              $gTotal = 0;
              //echo '<pre>'; print_r($orddetail); exit();
              foreach ($orddetail as $key => $val) {
                $gTotal += ($val['product_price'] * $val['quantity']);
                $gTotal = $gTotal + $ordmaster['shipping_amount'];
                $catid = get_db_field_value("wps_products", "category_id", "WHERE products_id = '" . $val['products_id'] . "'");
                if (!is_array($val['size_id'])) {
                  $size_name = get_db_field_value("wps_sizes", "size_name", "WHERE size_id = '" . $val['size_id'] . "'");
                }
                if (!is_array($val['color_id'])) {
                  $color_name = get_db_field_value("wps_colors", "color_name", "WHERE color_id = '" . $val['color_id'] . "'");
                }
                ?>
                <tr>
                  <td align="left">
                    <b><?php echo $val['product_name']; ?></b><br>
                    <?php
                    if (isset($color_name) && $color_name != '') {
                      ?>
                      <br/><strong>Color: </strong><?= $color_name; ?> 
                      <?php
                    }
                    ?>
                    <br/>
                    <?php
                    if (isset($val['size_id']) && $val['size_id'] != '') {
                      ?>
                      <strong>Size: </strong><?= $size_name; ?><br/>
                      <?php
                    }
                    ?>
                  </td>
                 
                  <td align="left">  <?php if($catid==2){ echo display_price($val['product_price']);} else { echo display_price_india($val['product_price']); } ?></td>
                  <td><?php echo $val['quantity']; ?></td>
                  <td align="left"> <?php if($catid==2){ echo display_price($val['product_price'] * $val['quantity']);} else { echo display_price_india($val['product_price'] * $val['quantity']); } ?></td>
                </tr>
                <?php
              }
              ?>
            </tbody>
            <tfoot>
              <tr>
                <td colspan="3" align="left"><strong>Payment Method:</strong></td>
                <td align="left"><?php echo $ordmaster['payment_method']; ?></td>
              </tr>

              <tr>
                <?php $deliveryCharge = $ordmaster['shipping_amount']; ?>
                <td colspan="3" align="left"><strong>Shipping Amount:</strong></td>
                <td align="left"><?php if($catid==2){ echo display_price($deliveryCharge);} else { echo display_price_india($deliveryCharge); } ?></td>
              </tr>


              <?php if ($ordmaster['coupon_discount_amount'] > 0) { ?>
                <tr>
                  <td colspan="3" align="left"><strong>Discount Amount:</strong></td>
                  <td align="left">- <?php if($catid==2){ echo display_price($ordmaster['coupon_discount_amount']);} else { echo display_price_india($ordmaster['coupon_discount_amount']); } ?></td>
                </tr>
              <?php } ?>
              <tr>
                <td colspan="3" align="left"><strong>Total:</strong></td>
                <td align="left"><?php if($catid==2){ echo display_price($ordmaster['total_amount']);} else { echo display_price_india($ordmaster['total_amount']); } ?></td>
              </tr>
            </tfoot>
          </table>
          <table class="table table-bordered table-hover hidden_desktop">
            <tbody>
              <?php
//              trace($ordmaster);
//                exit;
              $gTotal = 0;
              foreach ($orddetail as $key => $val) {
                $gTotal += ($val['product_price'] * $val['quantity']);
                $gTotal = $gTotal + $ordmaster['shipping_amount'];
                ?>
                <tr>
                  <td><b>Product</b></td>
                  <td align="left">
                    <b><?php echo $val['product_name']; ?></b>
                  </td>
                </tr>
                <tr>
                  <td>Unit Price</td>
                  <td><?php if($catid==2){ echo display_price($val['product_price']);} else { echo display_price_india($val['product_price']); } ?></td>
                </tr>
                <tr>
                  <td>Quantity</td>
                  <td><?php echo $val['quantity']; ?></td>
                </tr>
                <tr>
                  <td>Sub Total</td>
                  <td>  <?php if($catid==2){ echo display_price($val['product_price'] * $val['quantity']);} else { echo display_price_india($val['product_price'] * $val['quantity']); } ?></td>
                </tr>
                <?php
              }
              ?>
            </tbody>
            <tfoot>
              <tr>
                <td align="left"><strong>Payment Method:</strong></td>
                <td align="left"><?php echo $ordmaster['payment_method']; ?></td>
              </tr>
              <tr>
                <?php $deliveryCharge = $ordmaster['shipping_amount']; ?>
                <td align="left"><strong>Shipping Amount:</strong></td>
                <td align="left"><?php if($catid==2){ echo display_price($deliveryCharge);} else { echo display_price_india($deliveryCharge); } ?></td>
              </tr>
              <!-- <tr>
                <?php $deliveryCharge = ($deliverypin) ? $deliverycost['delivery_charge'] : 'Free'; ?>
                <td  align="left"><strong>Shipping Amount:</strong></td>
                <td align="left"> <?php echo display_price($deliveryCharge); ?></td>
              </tr> -->

              <?php if ($ordmaster['coupon_discount_amount'] > 0) { ?>
                <tr>
                  <td align="left"><strong>Discount Amount:</strong></td>
                  <td align="left">- <?php if($catid==2){ echo display_price($ordmaster['coupon_discount_amount']);} else { echo display_price_india($ordmaster['coupon_discount_amount']); } ?></td>
                </tr>
              <?php } ?>

              <tr>
                <td align="left"><strong>Total:</strong></td>
                <td align="left"> <?php if($catid==2){ echo display_price($ordmaster['total_amount']);} else { echo display_price_india($ordmaster['total_amount']); } ?></td>
              </tr>
            </tfoot>
          </table>
          <?php
        }
        ?>
        <div class="text-center">
        <a href="<?= site_url(); ?>" class="home_btn_1" title="Home">Home</a>
        <a href="<?= base_url('products'); ?>" class="shopping_continue_btn" title="Continue Shopping">Continue Shopping</a>
        </div>
        <br/><br/>
      </div>
    </div>
      </div>
  </div>
    
</section>

<?php $this->load->view('bottom'); ?>