<?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');		
	echo $javascript->link('ui.datepicker.js'); 
?>

<script>
	//Code for the project	
	$(document).ready(function()	
	{	
	$('#from_date').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";?>' });	
	 
	 $('#to_date').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 from_date=$.trim($('#from_date').val());
   var to_date=$.trim($('#to_date').val());
   if(from_date==to_date)
   {
     alert("Please Select different dates.");
	 return false;
  }   
   thisform.submit();
}
</script>
<div align="center" class="subheading">
  <div align="left">PRODUCT 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="fdate"  id="from_date" size="15" readonly="readonly" value="<?php echo $mindate;?>" onclick="return false;"/>
					&nbsp;&nbsp;&nbsp;
					To <input type="text"  name="tdate"  id="to_date" 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='../productcsv/<?php echo $mindate;?>/<?php echo $maxdate;?>'">
					<input type="button" value="Export to Excel" onClick="javascript:window.location='../productxls/<?php echo $mindate;?>/<?php echo $maxdate;?>'">
					</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>Product name</strong></div>
												<!-- <div class="list11"><strong>Quantity</strong></div> -->
												<!-- <div class="list11"><strong>Product price</strong></div> -->
												<div class="list11"><strong>Stock Available</strong></div>
												<div class="list11"><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;
									$subtot=0;			
										if(!empty($reportdet))
										 {
											foreach($reportdet as $det)
												{
												$subtot+=$det[0]["tot_price"];
												 ?>
								<div id="list_admin">
												<div class="list9"><?php echo $_count;?></div>
												<div class="list11"><?php echo Sanitize::html($det["Product"]);?></div>																				
												<div class="list11"><?php echo Sanitize::html($det["Avail_stock"]);?></div>
												<div class="list11"><?php echo Sanitize::html($det[0]["tot_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="list_admin">
												<div class="list9"></div>
												<div class="list11"></div>																				
												<div class="list11"><strong>Subtotal</strong></div>
												<div class="list11"><strong><?php echo $subtot;?></strong></div>	
												<div align="left" class="float_clear"><?php echo $html->image('/img/clear.gif', array('width' => 1, 'height' => 1));?></div>									
												
								</div>
					 
									 <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 } ?>
					  <div align="left" class="float_clear1"></div>
</div>
 <div align="left" class="float_clear1"><?php echo $html->image('/img/clear.gif');?></div> 