<?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('hint.js');
	echo $javascript->link('ui.datepicker.js'); 
?>
<script>
	//Code for the project	
	$(document).ready(function()	
	{	
	$('#user_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";?>' });	
	 
	 $('#user_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 fromdate=$('#from_date').val();
  var todate=$('#to_date').val();
   $('#fdate').val(fromdate);
   $('#tdate').val(todate);
   thisform.submit();
  }
  </script>

<label align="center"><font color="#FF0000"><?php $session->flash(); ?></font></label>		
<div align="center" class="subheading">
 <div align="left">USER REPORT</div>
</div>
<br />

<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="user_fdate"  id="user_fdate" size="15" readonly="readonly" value="<?php echo $mindate;?>" onclick="return false;"/>
&nbsp;&nbsp;&nbsp;
To <input type="text"  name="user_tdate"  id="user_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 />	
 <?php if(count($reportdet) > 0) { ?>
<label class="btn_style-org"><strong><?php echo $html->link('Export to csv','/users/usercsv');?> >></strong></label>
<label class="btn_style-org"><strong><?php echo $html->link('Export to xls','/users/userxls');?> >></strong></label>
<?php } ?>


<br />	 <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'];
		?>
<div align="left" id="item_details_admin">
				<!--items display area start -->
				 <table width="100%"  border="0" cellspacing="0" cellpadding="0" id="items_display_area_admin_table">
				  <tr>
					<td align="left" valign="top"><table width="100%"  border="0" cellspacing="1" cellpadding="6">
					  <tr align="left" valign="middle" id="list_admin_top">
						<td class="brd-ryt brd-btm" width="4%">#</td>
						<td class="brd-ryt brd-btm" width="11%"><strong><?php echo $paginator->sort('User name', 'User.uname'); ?></strong></td>
						<td class="brd-ryt brd-btm" width="13%">
						<strong><?php				
						    echo $html->link(__('Name', true), array(
							'controller' => 'users',
							'action' => 'reports',
							'page' => $pval,
							'frmdate'=> $mindate,
							'todate'=> $maxdate,
							'sort' => 'uadd.fname',
							'direction' => (empty($this->passedArgs['direction']) || $this->passedArgs['direction'] == 'asc')?'desc' : 'asc',
							'limit' => $this->passedArgs['limit']						
							
						));
						?></strong>						
						</td>
						<td class="brd-ryt brd-btm" width="13%">
						<strong><?php				
						    echo $html->link(__('Email', true), array(
							'controller' => 'users',
							'action' => 'reports',
							'page' => $pval,
							'frmdate'=> $mindate,
							'todate'=> $maxdate,
							'sort' => 'uadd.email',
							'direction' => (empty($this->passedArgs['direction']) || $this->passedArgs['direction'] == 'asc')?'desc' : 'asc',
							'limit' => $this->passedArgs['limit']						
							
						));
						?></strong>	
						</td>
						
						<td class="brd-ryt brd-btm" width="12%">
						<strong><?php				
						    echo $html->link(__('Address', true), array(
							'controller' => 'users',
							'action' => 'reports',
							'page' => $pval,
							'frmdate'=> $mindate,
							'todate'=> $maxdate,
							'sort' => 'uadd.address',
							'direction' => (empty($this->passedArgs['direction']) || $this->passedArgs['direction'] == 'asc')?'desc' : 'asc',
							'limit' => $this->passedArgs['limit']						
							
						));
						?></strong>
						
						</td>
						<td class="brd-ryt brd-btm" width="11%">
						<strong><?php				
						    echo $html->link(__('Zip', true), array(
							'controller' => 'users',
							'action' => 'reports',
							'page' => $pval,
							'frmdate'=> $mindate,
							'todate'=> $maxdate,
							'sort' => 'uadd.zip',
							'direction' => (empty($this->passedArgs['direction']) || $this->passedArgs['direction'] == 'asc')?'desc' : 'asc',
							'limit' => $this->passedArgs['limit']						
							
						));
						?></strong>
						
						</td>
						<td class="brd-ryt brd-btm" width="11%">
						<strong><?php						
						    echo $html->link(__('Phone', true), array(
							'controller' => 'users',
							'action' => 'reports',
							'page' => $pval,
							'frmdate'=> $mindate,
							'todate'=> $maxdate,
							'sort' => 'uadd.phone',
							'direction' => (empty($this->passedArgs['direction']) || $this->passedArgs['direction'] == 'asc')?'desc' : 'asc',
							'limit' => $this->passedArgs['limit']						
							
						));
						?></strong>
						
						</td>	
						<td class="brd-ryt brd-btm" width="13%">
						<strong><?php						
						    echo $html->link(__('Fax', true), array(
							'controller' => 'users',
							'action' => 'reports',
							'page' => $pval,
							'frmdate'=> $mindate,
							'todate'=> $maxdate,
							'sort' => 'uadd.fax',
							'direction' => (empty($this->passedArgs['direction']) || $this->passedArgs['direction'] == 'asc')?'desc' : 'asc',
							'limit' => $this->passedArgs['limit']						
							
						));
						?></strong>
						</td>
						<td width="12%" class=" brd-btm">
						<strong><?php echo $paginator->sort('Regdate', 'User.reg_date'); ?></strong>
						</td>					
					  </tr>
					
					
					 <?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($reportdet))
						{
						  foreach($reportdet as  $data)
						{ ?> 					  
						  <tr align="left" valign="middle" id="list_admin">
							<td class="brd-ryt"><?php echo $cnt++;?></td>
							<td class="brd-ryt">							
							<?php 
										$uname=Sanitize::html($data['User']['uname']);
										if(strlen($uname)>10)
										$uname=substr($uname, 0, 10)."...";
										else
										$uname=$uname; ?>	
										<a href="#" class="tooltip" title="<?php echo $data['User']['uname']; ?>" style="text-decoration:none;" onclick="return false;">
										<?php echo $uname; ?>
										</a>
										</td>
							<td class="brd-ryt"><?php echo Sanitize::html($data['uadd']['fname'])." ".Sanitize::html($data['uadd']['lname']); ?></td>
							<td class="brd-ryt">							
							<?php 
										$cemail=Sanitize::html($data['User']['email']);
										if(strlen($cemail)>10)
										$cemail=substr($cemail, 0, 10)."...";
										else
										$cemail=$cemail; ?>	
										<a href="#" class="tooltip" title="<?php echo $data['User']['email']; ?>" style="text-decoration:none;" onclick="return false;">
										<?php echo $cemail; ?>
										</a>
							</td>							
							<td class="brd-ryt"><?php
							if($data['uadd']['address']<>'') 
							{						
							 echo $data['uadd']['address'].'<br>'.$data['uadd']['city'].",<br>".$data['uadd']['state'].", ".$data['uadd']['country'];
							 }
							  ?>							 
							 </td>
							<td class="brd-ryt"><?php echo Sanitize::html($data['uadd']['zip']);?></td>
							<td class="brd-ryt">
							<?php 
							$disp_str=Sanitize::html($data['uadd']['phone']);
							 if($data['uadd']['mobile']<>'')
							 {  
							   if( $data['uadd']['mobile']<>'')
								 {  
									 $disp_str.=" /<br >";
								 }
							    $disp_str.=Sanitize::html($data['uadd']['mobile']); 
							 }							 
							           if(strlen($disp_str)>20)
										$disp_str1=substr($disp_str, 0, 20)."...";
										else
										$disp_str1=$disp_str; ?>	
										<a href="#" class="tooltip" title="<?php echo htmlentities($disp_str); ?>" style="text-decoration:none;" onclick="return false;">
										<?php echo $disp_str1; ?>
								        </a>							 
							 </td>
							<td class="brd-ryt"><?php							
							            $faxno=Sanitize::html($data['uadd']['fax']);
										if(strlen($faxno)>20)
										$faxno=substr($faxno, 0, 20)."...";
										else
										$faxno=$faxno; ?>	
										<a href="#" class="tooltip" title="<?php echo $data['uadd']['fax']; ?>" style="text-decoration:none;" onclick="return false;">
										<?php echo $faxno; ?>
										</a></td>
										<td><?php echo Sanitize::html($data[0]['reg_date']);?></td>
							
						  </tr>  
					   <?php  }  ?>					  
					</table>
					 
					  <table width="100%"  border="0" cellspacing="0" cellpadding="0" id="admin_bottom">
						<tr>
						  <td class="brd-ryt" align="center">
						 
						  <?php echo $paginator->numbers(); ?>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<?php echo $paginator->counter(); ?>	
						  </td>
						</tr>
					  </table>
					  <?php }  else { ?>					     
						<tr id="list_admin">
						  <td align="center" colspan="10">No Records Found.</td>
						</tr>					  
					  <?php } ?>
					  </td>
				  </tr>
				</table>
				 <div align="left" class="float_clear1"></div>
</div>
 <div align="left" class="float_clear1"><?php echo $html->image('/img/clear.gif');?></div> 