<?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>             		  |
// +----------------------------------------------------------------------+
?>

<?php echo $javascript->link('jquery.js'); ?>
<?php echo $javascript->link('hint.js'); ?> 
<script language="JavaScript" type="text/JavaScript">
function clickSearch()
{
	document.frmUsers.submit();
}
</script>
<div align="center" class="subheading">
              <div align="left">Users</div>
            </div>
            <br />			
<?php if($session->check('Message.flash')) { ?><div id="okbox"><font color="#446423"><?php $session->flash(); ?></font></div><?php } ?>
			<div align="left" id="item_details_admin">
				<!--items serach area start -->					
					<form action="" method="get" name="frmUsers">
    				<div style="padding-left:35px;">
  		 			 <select name="cmbSearchType" class="box2_admin">
					<option value="uname"  <?php if($cmbSearchType == "uname" || $cmbSearchType == ""){ echo("selected"); } ?>>User Name</option>
					<option value="email"  <?php if($cmbSearchType == "email"){ echo("selected"); } ?>>Email</option>
				   </select> &nbsp;
				   <input type="text" name="txtSearch" maxlength="50" value="<?php echo(htmlentities($txtSearch)); ?>" class="box2_admin" >
				   <a style="cursor:pointer" onClick="javascript:clickSearch();"><?php echo $html->image('/img/search_bttn.gif');?></a>
	               </div>		
	               <br />							
                   </form>	
                   <br />		
                 <!--items serach area end -->			
			 
			 
				
				<label><strong><?php echo $html->link('Add New User','/users/add');?> >></strong></label>
				 <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="listp6"><strong><?php echo $paginator->sort('User Name', 'uname'); ?></strong></div>
										<div class="list7"><strong><?php echo $paginator->sort('Email', 'email'); ?></strong></div>	
										<div class="listp6"><strong><?php echo $paginator->sort('User Type', 'usertype'); ?></strong></div>	
										<div class="list6"><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
								$cnt=1;
							   if(!empty($usr)){
					foreach ($usr as $user){?>   
										<div id="list_admin">
														<div class="list9"><?php echo $cnt++;?></div>
														<div class="listp6">
														<?php 
												         $uname=Sanitize::html($user['User']['uname']);
												         if(strlen($uname)> 20)
													     {
												          $uname=substr($uname, 0, 20)."..."; ?>
													      <a href="#" class="tooltip" title="<?php echo Sanitize::html($user['User']['uname']); ?>" style="text-decoration:none;" onclick="return false;">
												          <?php echo $uname; ?>
												          </a>	
													      <?php } else {
												          echo $uname; }?>														
														</div>
														
														<div class="list7">														
														<?php 
												         $emailaddress=Sanitize::html($user['User']['email']);
												         if(strlen($emailaddress)> 50)
													     {
												          $emailaddress=substr($emailaddress, 0, 50)."..."; ?>
													      <a href="#" class="tooltip" title="<?php echo Sanitize::html($user['User']['email']); ?>" style="text-decoration:none;" onclick="return false;">
												          <?php echo $emailaddress; ?>
												          </a>	
													      <?php } else {
												          echo $emailaddress; }?>		
														</div> 
														
														<div class="listp6">
														<?php 
														 $type=Sanitize::html($user['User']['usertype']);
														 if($type=='R')
														 echo 'Registered User';
														 else  if($type=='G')
														 echo 'Guest User';
														 ?>
														</div> 
														
														<div class="list6">
														<?php echo $html->link('Edit', 
				"/users/edit/".$user['User']['id'])." / ".$html->link('Delete', 
				"/users/delete/".$user['User']['id'],null,'Are you sure to delete this User'); ?>
														</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><?php echo $this->renderElement('pagination'); // Render the pagination element ?> </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 users found!</strong></div>																		
														<div align="left" class="float_clear"><?php echo $html->image('/img/clear.gif', array('width' => 1, 'height' => 1));?></div>
										</div>			     
							 <?php } ?>