<?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'); ?>
<?php echo $javascript->link('tooltip.js'); ?>
<script language="JavaScript" type="text/JavaScript">
function clickSearch()
{
	document.frmUsers.submit();
}
function getsrch(){
	var w = document.getElementById("cmbSearchType").selectedIndex;
	var sp = document.getElementById("cmbSearchType").options[w].value;
	if(sp == 'type'){
		document.getElementById("cmbsrch").innerHTML = '<select name="txtSearch" id="txtSearch" class="box2_admin"><option value="Perc">Percentage</option><option value="Amt">Amount</option></select>';
	}else{
		document.getElementById("cmbsrch").innerHTML = '<input type="text" name="txtSearch" maxlength="50" value="<?php echo(htmlentities($txtSearch)); ?>" class="box2_admin">';
	}
}
</script>
<div align="center" class="subheading">
              <div align="left">Gift Cards</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">
				<!--Search area start -->			
				
					<form action="" method="get" name="frmUsers">
    				<div>		
					<div style="float:left">
					<select id="cmbSearchType" name="cmbSearchType" onBlur="javascript:getsrch();" class="box2_admin">
					<option value="code"  <?php if($cmbSearchType == "code" || $cmbSearchType == ""){ echo("selected"); } ?>>Gift Card Name</option>
					<option value="amt"  <?php if($cmbSearchType == "amt"){ echo("selected"); } ?>>Gift amount</option>
				   </select>				   
				   <label id="cmbsrch"><input type="text" name="txtSearch" maxlength="50" value="<?php echo(htmlentities($txtSearch)); ?>"  class="box2_admin" > </label>
				   </div>
				   <div>
				   <a style="cursor:pointer" onClick="javascript:clickSearch();"><?php echo $html->image('/img/search_bttn.gif');?></a>
	              </div>		
				  </div>
	               </form>	
                  <br />		
				  <!--Search area end -->		
				  
           
				 <br /><br />	
				 <label class="btn_style-org"><strong><?php echo $html->link('Add New Gift Card','/giftcards/add');?> >></strong></label>
				 <?php if(count($giftcards) > 0) { ?>
				 <label class="btn_style-org"><strong><?php echo $html->link('Export to csv','/giftcards/gcardcsv');?> >></strong></label>
				 <label class="btn_style-org"><strong><?php echo $html->link('Export to xls','/giftcards/gcardxls');?> >></strong></label>
				 <?php } ?>
				 <div class="clear"></div>
				 <br /><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="listp6"><strong><?php echo $paginator->sort('Gift Card Name', 'Giftcard.gift_code'); ?></strong></div>
											<div class="listp5"><strong><?php echo $paginator->sort('Gift Amount', 'Giftcard.gift_amnt'); ?></strong></div>												
											<div class="listp6"><strong><?php echo $paginator->sort('Description', 'Giftcard.descr'); ?></strong></div>	
											<div class="listp6"><strong>Image</strong></div>	
											<div class="listp7"><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($giftcards)){
					foreach ($giftcards as $cards){?>   
										<div id="list_admin">
														<div class="list9"><?php echo $cnt++;?></div>
														<div class="listp6">

														<?php  echo Sanitize::html($cards['Giftcard']['gift_code']); ?>
														</div>														
														
														<div class="listp5">
														<?php  echo Sanitize::html($cards['Giftcard']['gift_amnt']); ?>
														</div>                                        
														
														<div class="listp6">
														<?php 
														$descr=$cards['Giftcard']['descr'];
														if(strlen($descr)>20)
														$descr=substr($descr, 0, 20)."...";
														else
														$descr=$descr; ?>	
														<a href="#" class="tooltip" title="<?php echo $cards['Giftcard']['descr']; ?>" style="text-decoration:none;" onclick="return false;">
														<?php echo Sanitize::html($descr); ?>
														</a>
														</div>
														
														<div class="listp6">
														 <?php
														if(isset($cards["Giftcard"]["gift_img"]) && $cards["Giftcard"]["gift_img"]  <> '')
														{								 								 
														$img = explode(".",$cards["Giftcard"]["gift_img"]);
														$ext='.'.end(explode(".",$cards["Giftcard"]["gift_img"]));
														?>
														<a href='<?php echo $cnfg["sitebasefolder"];?>/img/products/<?php echo $img[0].'_thumb'.$ext;?>' class="preview" onclick="return false;">View</a>			
														<?php } ?> 
														</div> 
														 
														<div class="listp7">
														<?php echo $html->link('Edit', 
				"/giftcards/edit/".$cards['Giftcard']['id'])." / ".$html->link('Delete', 
				"/giftcards/delete/".$cards['Giftcard']['id'],null,'Are you sure to delete this Gift Card.'); ?>
														</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>&nbsp;</div>
														<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="admin_bottom">									
														
														<div>&nbsp;</div>
														<div><strong>Sorry no gift cards found !</strong></div>
														<div align="left" class="float_clear"><?php echo $html->image('/img/clear.gif', array('width' => 1, 'height' => 1));?></div>
										</div>			     
							 <?php } ?>
							 </div>							
 <div align="left" class="float_clear1"></div>
</div>
 <div align="left" class="float_clear1"><?php echo $html->image('/img/clear.gif');?></div> 