<?php
$this->load->view("top");
$fieldType = $this->session->userdata('field_type');
?>
<div class="page_breadcrumbs">
		<div class="container">
			<ul>
      <li><a href="<?= site_url(); ?>" title="Home">Home</a>
    </li>
      <li>My Orders</li>
			</ul>
		</div>
	</div>
	<section class="my_account_page">
		<div class="container">
			<div class="row">
				<div class="col-md-9 col-md-push-3">
					<div class="right_side">
						<h1>My Orders</h1>
						<div class="wps_right">
           <?php echo error_message();
          echo validation_message();
          if (is_array($orders) && !empty($orders)) {
            
              ?>
          <div class="my_account">
             <div class="my_account my_order">
            <!--- Start Here-->
            <?php foreach ($orders as $key => $val) {
              $orderDets = $this->order_model->get_order_detail($val['order_id']); ?>
            <div class="order_item">
              <div class="order_top">
                <div class="row">
                  <div class="col-lg-5">
                     <a class="orderID" rel="noopener noreferrer" href="<?php echo site_url(); ?>members/order_details/<?php echo $val['order_id']; ?>"><?php echo $val['invoice_number']; ?></a>
                  </div>
                  <div class="col-lg-3 pull-right text-right"> 
                    <a class="need_btn" href="<?php echo site_url(); ?>members/order_details/<?php echo $val['order_id']; ?>" title="Track"><i class="fa fa-map-marker"></i> Track</a>
                  </div>
                </div>
              </div>
              <div class="order_body">
                 <?php if (is_array($orderDets) && !empty($orderDets)) {
              foreach ($orderDets as $o => $pageVal) {
                $furl = get_db_field_value("wps_products", "friendly_url", "WHERE products_id = '" . $pageVal['products_id'] . "'");
                $img = get_db_field_value("wps_products_media", "media", "WHERE products_id = '" . $pageVal['products_id'] . "'");
                $productName = get_db_field_value("wps_products", "product_name", "WHERE products_id = '" . $pageVal['products_id'] . "'");
                ?>
                <div class="row">
                  <div class="col-lg-5 col-md-5 col-sm-5">
                    <div class="row">
                      <div class="col-lg-4 col-md-4 col-sm-4">
                        <a href="<?=$furl;?>" title="<?php echo $productName; ?>" target="_blank">
                          <img src="<?php echo get_image('products', $img, '110', '67', 'R'); ?>" alt="<?php echo $productName; ?>" title="<?php echo $productName; ?>">
                        </a>
                      </div>
                      <div class="col-lg-8 col-md-8 col-sm-8">
                        <div class="order_info">
                           <a href="<?=$furl;?>" title="<?php echo $productName; ?>" target="_blank"><?php echo $productName; ?></a>
                        </div>
                      </div>
                    </div>
                  </div>
                  <div class="col-lg-7 col-md-7 col-sm-7">
                    <div class="row">
                      <div class="col-lg-3 col-md-3 col-sm-3">
                        <div class="order_price"><?php echo display_price($pageVal['product_price']*$pageVal['quantity']); ?></div>
                      </div>
                     <!--  <div class="col-lg-5 col-md-5 col-sm-5">
                        <div class="delivered">
                          <p>Delivered on Mon, May 20' 2020</p>
                           <small>Your item has been delivered</small>
                        </div>
                      </div>-->
                      
                     <div class="col-lg-4 col-md-4 col-sm-5">
                        <a class="review_product" href="<?php echo site_url(); ?>members/post_review/<?php echo $pageVal['products_id']; ?>" title="Rate & Review Product"><i class="fa fa-star"></i> Rate & Review</a>
                      </div>  
                      
                    </div>
                  </div>
                </div>
              <?php } } ?>
              </div>
              <div class="order_foot">
                <div class="row">
                  <div class="col-lg-6 col-md-6 col-sm-6">
                    <p>Ordered On <?php echo date('d M Y H:i A', strtotime($val['order_received_date'])); ?></p>
                  </div>
                  <div class="col-lg-6 col-md-6 col-sm-6">
                    <p class="text-right">Order Total <strong><?php echo display_price($val['total_amount']); ?></strong>
                    </p>
                  </div>
                </div>
              </div>
            </div>
          <?php } ?>
           
          </div>
          </div>
          <?php }else{ ?>
            <div class="text-center mt10 thank-you">
          <h4 class="mb-70 thankyou-text">Sorry, No Orders Found!</h4>
          <a href="<?=site_url('products');?>" class="checkout_btn" title="Continue Shopping">Continue Shopping</a>
        </div>
      <?php } ?>
						</div>
					</div>
				</div>
				<div class="col-md-3 col-md-pull-9">
				<?php $this->load->view('members/left'); ?>
				</div>
			</div>
		</div>
	</section>

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