






<div class="container marg_top" >
<div class="row">
<div class="col-md-12  registor">

<?php
  $this->load->view('website/user_menu');
?>


<h3  class="sub_hd" >Your Orders</h3>

<br /><br />

<?php
$p_order_id='';
$total_amt = 0;


if($result1):

$atts = array(
      'width'      => '800',
      'height'     => '600',
      'scrollbars' => 'yes',
      'status'     => 'yes',
      'resizable'  => 'yes',
      'screenx'    => '20',
      'screeny'    => '20',
      'class'	   => 'lnk'
    );


?>


<table width="100%">
 <tr style="font-size:12px; font-family:Tahoma, Geneva, sans-serif; color:#2D2D2D;">
 <td colspan="2" height="40" align="left">Click on the order id to view details</td>
 <td colspan="3" align="right">Click on <img src="<?php echo base_url('assets/web_images/pending.png') ; ?>" width="11" border="0"/> button to cancel order.</td>
 </tr> 
 </table>

<table id="cart" class="table table-hover table-condensed" style="font-size:14px; text-align:center;" >


<thead>
<tr >
							<th style="text-align:center;" >No.</th>
							<th  style="text-align:center;" >Order ID</th>
							<th  style="text-align:center;" >Date</th>
                            <th style="text-align:center;" >Status</th>
							<th style="text-align:center;"  >Payment Status</th>
		                    <th  style="text-align:center;" >Cancel</th>
						</tr>
					</thead>









 <?php $i=1; foreach($result1 as $row): ?>

  <tr class="order_view">

    <td><?=$i?></td>

    <td><?php echo anchor_popup(site_url('Userpage/order_details/'.$row['order_id']), $row['order_id'], $atts) ; ?></td>

    <td><?=get_datetime($row['order_date'])?></td>

    <td >

	<?php

    switch($row['status'])

	{

		case 'P' : $status =  'Pending' ; break; 

		case 'D' : $status =  'Delivered' ; break; 

		case 'C' : $status =  'Cancelled by you' ; break; 
		
		case 'A' : $status =  'Cancelled by Admin' ; break; 

		case '1' : $status =  'Confirmed' ; break; 

		default : $status =  'Pending' ; 

	}

	echo $status ;

	?>

    </td>
    
    
    <td>
  <?php /*if($row['payment']==3){ echo"Payment Failed, Try Again";}
   if($row['payment']==1){ echo"Paid, Transaction Complete";}  
  else {  echo" Not Paid"; }*/ ?>
  
  
  <?php if($row['payment']=='' || $row['payment']=='0') {  echo"Not Paid"; } 
  elseif ($row['payment']==1) { echo "Paid, Transaction Complete"; }
  elseif ($row['payment']==3) { echo "Payment Failed,We will contact you Shortly!"; }
  elseif ($row['payment']==5) { echo "Paid, Transaction Complete"; }
  elseif ($row['payment']==6) { echo "Paid, Transaction Complete"; }
 ?>
  
  
  
  
    </td>
    
    

    <td >

    <?php

	

	//if pending

    if($row['status']=='P')
     {  ?>

    <form name="ordercancel_form<?=$i?>" method="post" action="<?php echo site_url('Order_process/cancel') ; ?>">

    <input type="hidden" name="orid"  value="<?=encode_str($row['order_id'])?>"  />

    <input type="hidden" name="uid"  value="<?=encode_str($row['user_id'])?>"  />

    <?php

	$today=date("Y-m-d");

	if($row['order_date']==$today)

	{

	 ?>

     <input type="image" src="<?php echo base_url('assets/web_images/index.png') ; ?>" id="cancel<?=$i?>" title="Cancel Order"/>

     <?php }?>

    <input type="image" src="<?php echo base_url('assets/web_images/pending.png') ; ?>" id="cancel<?=$i?>" title="Cancel Order"

    name="cancel<?=$i?>" onclick="return can()"/>

    </form>

    <script type="text/javascript">

	function can()

	{

		if(confirm('Do you want to cancel this order?'))

		{

		window.document.ordercancel_form<?=$i?>.submit();

		}

		else 

		return false;

	}

	</script>

    <?php	

	}

	

	//if confirmed

	else if($row['status']=='1')

	{

	echo "On Process"; 

	}

	

	//if cancelled

	else if($row['status']=='C' || $row['status']=='A')

	{

	?>

    

    <?php /*?>

	//enable this part if want to reorder the cancelled order

	<form name="ordercancel_form<?=$i?>" method="post" action="<?php echo site_url('order_process/book') ; ?>">

    <input type="hidden" name="orid"  value="<?=encode_str($row['order_id'])?>"  />

    <input type="image" src="<?php echo base_url('assets/web_images/cancelled.png') ; ?>" id="cancel<?=$i?>" title="Book Order"

    name="cancel<?=$i?>" onclick="return ord()"/>

    </form>

    <script type="text/javascript">

	function ord()

	{

		if(confirm('Do you wish to reorder?'))

		{

		window.document.ordercancel_form<?=$i?>.submit()

		}

		else 

		return false;

	}

	</script>

	<?php */?>

    

    <img src="<?php echo base_url('assets/web_images/cancelled.png') ; ?>" border="0" title="cancelled"/>

    <?php

	}

	

	//if Couriered

	else if($row['status']=='D')

	{

	?>

    <img src="<?php echo base_url('assets/web_images/delivered.png') ; ?>" border="0" title="delivered"/>

    <?php

	}

	?>

    </td>

  </tr>

  <?php $i++; endforeach; ?>



</table>


<?php endif; ?>
<p>&nbsp;</p>
  
</div>
</div>
</div>