<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: 			*/
// +----------------------------------------------------------------------+
// | PHP version 4/5                                                      |
// +----------------------------------------------------------------------+
// | Copyright (c) 2004-2008 ARMIA INC                                    |
// +----------------------------------------------------------------------+
// | This source file is a part of iScripts EasyCart                      |
// +----------------------------------------------------------------------+
// | Authors: Jipson<jipson.thomas@armiasystems.com>             		  |
// +----------------------------------------------------------------------+
?>
<?php echo $javascript->link('jquery.js');?>
<?php echo $javascript->link('hint.js'); ?> 
<?php echo $javascript->link('ui.datepicker.js'); ?>
<script>
	//Code for the project	
	$(document).ready(function()	
	{	
	$('#sales_fdate').datepick({minDate: '<?php echo $dflt_mindate;?>' , maxDate:'<?php echo $dflt_maxdate;?>', 
	dateFormat: 'yy-mm-dd',closeAtTop: false, showStatus: true,  showOn: 'both', buttonImageOnly: true,
	 buttonImage: '<?php echo $cnfg["sitebasefolder"]."/img/calendar.gif";?>' });	
	 
	 $('#sales_tdate').datepick({minDate: '<?php echo $dflt_mindate;?>' , maxDate:'<?php echo $dflt_maxdate;?>', 
	dateFormat: 'yy-mm-dd',closeAtTop: false, showStatus: true,  showOn: 'both', buttonImageOnly: true,
	 buttonImage: '<?php echo $cnfg["sitebasefolder"]."/img/calendar.gif";?>' });	
	 
	});
</script>
<script>
function submitForm(thisform)
{
 // 
  var fromdate=$('#from_date').val();
  var todate=$('#to_date').val();
   $('#fdate').val(fromdate);
   $('#tdate').val(todate);
   thisform.submit();
  }
  </script>

<div align="center" class="subheading">
  <div align="left">SALES REPORT</div>
            </div>
            <br />
			<div align="left" id="item_details_admin">
							<div>
							<form name="report" action="<?php echo $cnfg["sitebasefolder"];?>/<?php echo $this->params["controller"];?>/<?php echo $this->params["action"];?>/1" method="post">
							From <input type="text"  name="sales_fdate"  id="sales_fdate" size="15" readonly="readonly" value="<?php echo $mindate;?>" onclick="return false;"/>
							&nbsp;&nbsp;&nbsp;
							To <input type="text"  name="sales_tdate"  id="sales_tdate" size="15" readonly="readonly" value="<?php echo $maxdate;?>" onclick="return false;"
							/>
							<input type="button" value="view"  onclick="return submitForm(document.report);"/>
							&nbsp;&nbsp;&nbsp;<b>Show</b>
							<select name="filter" id="filter" onchange="document.report.submit();">
							<option value="5" <?php if($filterval==5) print "selected=selected";?>>5</option>
							<option value="10" <?php if($filterval==10) print "selected=selected";?>>10</option>
							<option value="15" <?php if($filterval==15) print "selected=selected";?>>15</option>
							<option value="<?php echo $totrec;?>" <?php if($filterval==$totrec) print "selected=selected";?>>All</option>
							</select>
							&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
							<input type="button" value="Export to CSV" onClick="javascript:window.location='../salescsv/<?php echo $mindate;?>/<?php echo $maxdate;?>'">
							<input type="button" value="Export to Excel" onClick="javascript:window.location='../salesxls/<?php echo $mindate;?>/<?php echo $maxdate;?>'">
							</form>
							</div> <br />
						
			
				<!--items display area start -->
				  <div align="center" id="items_display_area_admin">
						   <div id="list_admin_top">
											   <div class="list9"><strong>#</strong></div>
											    <div class="list11"><strong>Order Number</strong></div>
												<div class="list14"><strong>Date</strong></div>
												<div class="list14"><strong>Username</strong></div>
												<div class="list14"><strong>Order status</strong></div>
												<div class="list14"><strong>Coupon code</strong></div>
												<div class="list14"><strong>Discount</strong></div>		
												<div class="list12"><strong>Total</strong></div>																
												<div align="left" class="float_clear"><?php echo $html->image('/img/clear.gif', array('width' => 1, 'height' => 1));?></div>
							</div>
		
								<?php 
									$_count=1;			
										if(!empty($reportdet))
										 {
											foreach($reportdet as $det)
												{ ?>
								<div id="list_admin">
												<div class="list9"><?php echo $_count;?></div>
												<div class="list11"><?php echo $det["ORD"]["id"];?></div>
												<div class="list14"><?php
												 $ord_dt = strtotime($det["ORD"]["date"]);											          
												 echo date("m-d-Y",$ord_dt);?></div>
												<div class="list14"><?php echo Sanitize::html($det["USR"]["uname"]);?></div>										
												<div class="list14"><?php echo Sanitize::html($det["ORS"]["name"]);?></div>
												<div class="list14"><?php if($det["CPN"]["code"]<>'') echo Sanitize::html($det["CPN"]["code"]); else echo "-";?></div>		
												<div class="list14"><?php echo $det["ORD"]["discount"];?></div>				
												<div class="list12"><?php echo $det["ORD"]["total_price"];?></div>		
												<div align="left" class="float_clear"><?php echo $html->image('/img/clear.gif', array('width' => 1, 'height' => 1));?></div>									
												
								</div>
					 <?php  $_count++; 	}  ?>
					 
									 <div id="admin_bottom">		
												<div>&nbsp;</div>
												<div> <?php echo $pagination; ?></div>
												<div>&nbsp;</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="admin_bottom">									
												
												<div>&nbsp;</div>
												<div><strong>Sorry no reports found !</strong></div>
												<div>&nbsp;</div>	
												<div>&nbsp;</div>	
												<div>&nbsp;</div>										
												<div align="left" class="float_clear"><?php echo $html->image('/img/clear.gif', array('width' => 1, 'height' => 1));?></div>
								</div>			     
					 <?php } ?>