<?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()	
	{	
	$('#ordr_fdate').datepick({minDate: '<?php echo $dflt_mindate;?>' , maxDate:'<?php echo $dflt_maxdate;?>', 
	dateFormat: 'mm-dd-yy',closeAtTop: false, showStatus: true,  showOn: 'both', buttonImageOnly: true,
	 buttonImage: '<?php echo $cnfg["sitebasefolder"]."/img/calendar.gif";?>' });	
	 
	 $('#ordr_tdate').datepick({minDate: '<?php echo $dflt_mindate;?>' , maxDate:'<?php echo $dflt_maxdate;?>', 
	dateFormat: 'mm-dd-yy',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"];?>" method="post">
							From <input type="text"  name="ordr_fdate"  id="ordr_fdate" size="15" readonly="readonly" value="<?php echo $mindate;?>" onclick="return false;"/>
							&nbsp;&nbsp;&nbsp;
							To <input type="text"  name="ordr_tdate"  id="ordr_tdate" size="15" readonly="readonly" value="<?php echo $maxdate;?>" onclick="return false;"
							/>
							<input type="button" value="view"  onclick="return submitForm(document.report);"/>												
							</form>
							</div> 
							<br />	 <br />		
							 <?php if(count($reportdet) > 0) { ?>	
							 <label class="btn_style-org"><strong><?php echo $html->link('Export to csv','/order_details/productcsv');?> >></strong></label>
							 <label class="btn_style-org"><strong><?php echo $html->link('Export to xls','/order_details/productxls');?> >></strong></label>
							 <?php } ?>
							 <div class="clear"></div>
							 <br />	 <br />		
			
			<?php 

      if($mindate <> '' &&  $maxdate <> ''){
       $paginator->options(array('url'=>array_merge(array('frmdate'=>$mindate,
	   'todate'=>$maxdate),$this->passedArgs))); } 
	   
	     $pval='';
			if(isset($this->passedArgs['page']))
			$pval=$this->passedArgs['page'];
			 ?>
				 <!--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="list7"><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>Quantities Purchased</strong></div>	
                                                                                                <div class="list11 no-brder"><strong>Sold Amount</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);	
									$subtot=0;			
										if(!empty($reportdet))
										 {
											foreach($reportdet as $det)
												{
												$subtot+=$det[0]["tot_price"];
												 ?>
								<div id="list_admin">
												<div class="list9"><?php echo $cnt++;?></div>
												<div class="list7"><?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_qty"]);?></div>
												<div class="list11 no-brder"><?php echo $curlogo.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  }  ?>
					 <div id="list_admin">
												<div class="list9"></div>
												<div class="list7"></div>																				
												<div class="list11"></div>
												<div class="list11"><strong>Subtotal</strong></div>	
                                                                                                <div class="list11 no-brder"><strong><?php echo $curlogo.$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 $paginator->numbers(); ?>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<?php echo $paginator->counter(); ?>	 </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> 