<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: 			*/
// +----------------------------------------------------------------------+
// | PHP version 4/5                                                      |
// +----------------------------------------------------------------------+
// | Copyright (c) 2004-2010 ARMIA INC                                    |
// +----------------------------------------------------------------------+
// | This source file is a part of iScripts VistaCart                     |
// +----------------------------------------------------------------------+
// | Authors: Jipson<jipson.thomas@armiasystems.com>             		  |
// +----------------------------------------------------------------------+
?>
<script language="JavaScript" type="text/JavaScript">
function clickSearch()
{
	document.frmUsers.submit();
}
</script>
<?php 
      if($cmbSearchType <> '' &&  $txtSearch <> ''){
       $paginator->options(array('url'=>array_merge(array('cmbSearchType'=>$cmbSearchType,
	   'txtSearch'=>$txtSearch),$this->passedArgs))); }  ?>
<div align="center" class="subheading">
              <div align="left">Orders</div>
            </div>
            <br />
			<?php if($session->check('Message.flash')) { ?><div id="okbox"><font color="#319502"><?php $session->flash(); ?></font></div><?php } ?>
			<div align="left" id="item_details_admin">
				<!--Search display area start -->					
					<form action="<?php echo $sitebase.$sitefolder.'/'.$this->params["controller"];?>" method="post" name="frmUsers">
    				<div>
					<div  style="float:left">
  		 			 <select name="cmbSearchType" class="box2_admin">
					<option value="oid"  <?php  if($cmbSearchType == "oid" || $cmbSearchType == ""){ echo("selected"); } ?>>Order Number</option>
					<option value="orderstatus"  <?php  if($cmbSearchType == "orderstatus"){ echo("selected"); } ?>>Order Status</option>
					<option value="username"  <?php  if($cmbSearchType == "username"){ echo("selected"); } ?>>User Name</option>
					<option value="dateoforder"  <?php  if($cmbSearchType == "dateoforder"){ echo("selected"); } ?>>Date of Order (mm-dd-yyyy)</option>
					</select> &nbsp;
					<input type="text" name="txtSearch" maxlength="50" value="<?php echo(htmlentities($txtSearch)); ?>" class="box2_admin" >
					</div>
					<div>
					<a style="cursor:pointer" onClick="javascript:clickSearch();"><?php echo $html->image('/img/search_bttn.gif');?></a>
					 </div>
					 </div>		
					 <br />							
				    </form>	
					 <br />		
                  <!--Search display area end -->
                                 <label class="btn_style-org"><strong><?php echo $html->link('Place Order','/orders/placeorder/');?> >></strong></label>
				 <?php if(count($odr) > 0) { ?>	
				 <label class="btn_style-org" style="width:175px"><strong><?php echo $html->link('Export to csv','/orders/getcsv');?> >></strong></label>	
				 <label class="btn_style-org"><strong><?php echo $html->link('Export to xls','/orders/getxls');?> >></strong></label>	
				 <?php } ?>
                                 
				 <div class="clear"	></div>
				 <br /><br />		
				
				
              <!--items display area start -->
				  <div align="center" id="items_display_area_admin">
						<form name="customlist" method="post" action="/vistacart/customfieldvalues/edit">									
                       <div id="list_admin_top">
					   					<div class="list9"><strong>#</strong></div>
										<div class="list16"><strong><?php echo $paginator->sort('Order Number', 'Order.id'); ?></strong></div>
										<div class="list16">
										<strong><?php		
										    $pval='';
											if(isset($this->passedArgs['page']))
											$pval=$this->passedArgs['page'];		
											echo $html->link(__('Name', true), array(
											'controller' => 'orders',
											'action' => 'index',
											'page' => $pval,	
											'cmbSearchType'=>$cmbSearchType,
											'txtSearch'=>$txtSearch,							
											'sort' => 'USR.uname',
											'direction' => (empty($this->passedArgs['direction']) || $this->passedArgs['direction'] == 'asc')?'desc' : 'asc',
											'limit' => $this->passedArgs['limit']						
											
										));
										?></strong>						
										</div>	
										<div class="list16"><strong><?php echo $paginator->sort('Date', 'Order.date'); ?></strong></div>	
										<div class="list16"><strong><?php echo $paginator->sort('Total', 'Order.total_price'); ?></strong></div>	
										<div class="list16"><strong><?php echo $paginator->sort('Order Status', 'OrderStatus.name'); ?></strong></div>	
										<div class="list17"><strong>Options</strong></div>										
										<div align="left" class="float_clear"><?php echo $html->image('/img/clear.gif', array('width' => 1, 'height' => 1));?></div>
						</div>
							<?php
							if(!empty($passedarg) && !isset($passedarg["page"]))								
									$cnt=1;
									else if(!empty($passedarg) && $passedarg["page"]==1)
									$cnt=1;
									else
									$cnt=((($passedarg["page"]-1)*($passedarg["limit"]))+1);
						 if(!empty($odr)){
				foreach ($odr as $oder){?>   
									<div id="list_admin">
													<div class="list9"><?php echo $cnt++;?></div>
													<div class="list16">
													<?php echo $html->link($oder['Order']['id'], 
			"/orders/details/".$oder['Order']['id']); ?>
													</div>
													
													<div class="list16">
													<?php echo Sanitize::html($oder['USR']['uname']); ?>
													</div> 
													
													<div class="list16">
													<?php $dt	= strtotime($oder['Order']['date']); echo date("m-d-Y",$dt ); ?>
													</div>                                        
													<div class="list16">
													<?php echo $curlogo.Sanitize::html($oder['Order']['total_price']); ?>
													</div> 
													<div class="list16">
													<?php echo Sanitize::html($oder['ORS']['name']); ?>
													</div> 
													<div class="list17">
													<?php echo $html->link('View Details', 
			"/orders/details/".$oder['Order']['id'])." / ".$html->link('Delete', 
			"/orders/delete/".$oder['Order']['id'],null,'Are you sure you want to delete this Order'); ?>
													</div> 
													<div align="left" class="float_clear"><?php echo $html->image('/img/clear.gif', array('width' => 1, 'height' => 1));?></div>
									</div>
						 <?php 		
						 } ?>
						   <div id="admin_bottom">		
													<div>&nbsp;</div>
													<div>
													
	   <?php echo $paginator->numbers(); ?>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<?php echo $paginator->counter(); ?>	 </div>										
													<div align="left" class="float_clear"><?php echo $html->image('/img/clear.gif', array('width' => 1, 'height' => 1));?></div>
											  </div>			
						 <?php } else { ?>
								  <div id="list_admin">		
													<div>&nbsp;</div>
													<div><strong>Sorry no orders found!</strong></div>																		
													<div align="left" class="float_clear"><?php echo $html->image('/img/clear.gif', array('width' => 1, 'height' => 1));?></div>
									</div>			     
						 <?php } ?>
						 
						 
</div>							
 <div align="left" class="float_clear1"></div>
</div>
 <div align="left" class="float_clear1"><?php echo $html->image('/img/clear.gif');?></div> 