<?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 EasyCart                      |
// +----------------------------------------------------------------------+
// | Authors: Jipson<jipson.thomas@armiasystems.com>             		  |
// +----------------------------------------------------------------------+
?>
<?php echo $javascript->link('jquery.js'); ?>
<?php echo $javascript->link('hint.js'); ?>
<script>
$(document).ready(function() 
{
  <?php if(isset($tab)) { ?>
  var tabval='<?php echo $tab;?>'
  showdiv(tabval);  
  <?php } ?>  
});
</script>
<script language="JavaScript" type="text/JavaScript">
function clickSearch()
{
	document.frmUsers.submit();
}
function showdiv1(){
	document.getElementById('txdiv').style.display='none';
	var buttons = document.setting.elements.tax_option; 
	if(buttons[1].checked){
		document.getElementById('txdiv').style.display='inline';
	}
}
function showdiv(val){
	
	if(val == 1){
		val = 'general';
	}else if(val == 2){
		val = 'domain';
	}
	
	if( val == 'general'){
		document.getElementById('general').style.display = 'inline';
		<?php if($gendata["tax_option"] == "statetax"){ ?>
			document.getElementById("tabs5").innerHTML = "<li class='toplinks' id='current'><a href='#' onClick='javascript: showdiv(1);'><span>General Setting</span></a></li><li class='toplinks'><a href='#' onClick='javascript: showdiv(2);'><span>Tax Rates</span></a></li>";
		<?php }else{ ?>
			document.getElementById("tabs5").innerHTML = "<li class='toplinks' id='current'><a href='#' onClick='javascript: showdiv(1);'><span>General Setting</span></a></li>";
		<?php } ?>
	}else{
		document.getElementById('general').style.display = 'none';
	}
	if( val == 'domain'){
	
		document.getElementById('domain').style.display = 'inline';
		document.getElementById("tabs5").innerHTML = "<li class='toplinks'><a href='#' onClick='javascript: showdiv(1);'><span>General Setting</span></a></li><li class='toplinks' id='current'><a href='#' onClick='javascript: showdiv(2);'><span>Tax Rates</span></a></li>";
	}else{
		document.getElementById('domain').style.display = 'none';

	}
}
</script>
<?php $help='In this page you can opt for no tax to all customers, 
a fixed tax rate, or tax based on any country/state. 
The administrator can also choose the base to categorize the taxes as subtotal or subtotal + shipping. The administrator can use taxable address as a billing address or shipping address.
If the administrator opts fixed tax rates, they can create a tax name. 
If the administrator wants a specific tax based on a state and/or country, the tax rate tab is enabled.
In this tab, the administrator can add/edit/delete any/tax rates for states or countries. In most jurisdictions you collect taxes for states with nexus, based on the shipping address.
 For example: if you have a store in the state of California, you have to collect taxes from all customers in California. Please obtain legal advice for your local tax laws.';
 ?>
 <div align="center" class="subheading">
              <div align="left">Tax Settings
			  <a href="#" class="tooltip" title="<?php echo $help;?>" onclick="return false;">
			 <?php echo $html->image('/img/hint.png', array('border' => 0, 'text-decoration' => 'none'));?>	
			 </a>		
			 </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">
                      <div align="left" class="inner_content_area_admin">					  
					  
					   <div id="tabs5">
						  <!-- CSS Tabs -->
						  <li class="toplinks" <?php if(!isset($tab) || $tab == "gen"){ ?>id="current" <?php } ?>><a href="#" onClick="javascript: showdiv('general');"><span>General</span></a></li>
						  <li class="toplinks" <?php if(isset($tab) && $tab == "rat"){ ?>id="current" <?php } ?>><a href="#" onClick="javascript: showdiv('domain');"><span>Tax Rates</span></a></li>     
						</div>
					  
					  
					  
<div id="general"> <!-- Start of general tab -->		 
	 <div align="left" id="item_details_admin" class="bordernew">				
                  <!--form area start -->
				<form id="setting" name="setting" method="post" enctype="multipart/form-data">				  
						  <div id="grid_admin">
							<div align="left" id="inner_leftcontent">
							  <p class="maintext_inner">Tax Option</p>
							</div>
							<div align="right" id="inner_rightcontent" class="newwidth">
								<span class="maintext_inner">
								
									<input type="radio" name="tax_option" value="notax" <?php if($gendata["tax_option"] == "notax"){ ?> checked <?php } ?> onClick="javascript : showdiv1();" >
									I don't want to apply tax to any orders <br>
	<input type="radio" name="tax_option" value="fixedtax" <?php if($gendata["tax_option"] == "fixedtax"){ ?> checked <?php } ?> onClick="javascript : showdiv1();" >
	I want to apply fixed tax to all orders <br>
	<input type="radio" name="tax_option" value="statetax" <?php if($gendata["tax_option"] == "statetax"){ ?> checked <?php } ?> onClick="javascript : showdiv1();" >I want to apply specific tax based on countries/states

								</span>							
							</div>
							<div align="left" class="float_clear1"><?php echo $html->image('/img/clear.gif', array('width' => 1, 'height' => 1));?></div>
						  </div>
						  
						
					<div id="txdiv">	
						  <div id="grid_admin">
							<div align="left" id="inner_leftcontent">
							  <p class="maintext_inner">Fixed Tax Name</p>
							</div>
							<div align="right" id="inner_rightcontent" class="newwidth">
								<span class="toplinks">
									<input type="text" name="fixedtax_name" value="<?php echo Sanitize::html($gendata["fixedtax_name"]); ?>" class="box2_admin" size="27">
								</span>							
							</div>
							<div align="left" class="float_clear1"><?php echo $html->image('/img/clear.gif', array('width' => 1, 'height' => 1));?></div>
						  </div>
						  
						  
						  <div id="grid_admin">
							<div align="left" id="inner_leftcontent">
							  <p class="maintext_inner">Fixed Tax Rate</p>
							</div>
							<div align="right" id="inner_rightcontent" class="newwidth">
								<span class="toplinks">
									<input type="text" name="fixedtax_rate" value="<?php echo Sanitize::html($gendata["fixedtax_rate"]); ?>" class="box2_admin" size="27">
								</span>							
							</div>
							<div align="left" class="float_clear1"><?php echo $html->image('/img/clear.gif', array('width' => 1, 'height' => 1));?></div>
						  </div>
				   </div>  
						  
						  <div id="grid_admin">
							<div align="left" id="inner_leftcontent">
							  <p class="maintext_inner">Taxable address </p>
							</div>
							<div align="right" id="inner_rightcontent" class="newwidth">
								<span class="maintext_inner">						
									<input type="radio" name="taxable_address" value="shipping" <?php if($gendata["taxable_address"] == "shipping"){ ?> checked <?php } ?>>Shipping Address<input type="radio" name="taxable_address" value="billing" <?php if($gendata["taxable_address"] == "billing"){ ?> checked <?php } ?>>Billing Address									
								</span>							
							</div>
							<div align="left" class="float_clear1"><?php echo $html->image('/img/clear.gif', array('width' => 1, 'height' => 1));?></div>
						  </div>
						  
						  
						  <div id="grid_admin">
							<div align="left" id="inner_leftcontent">
							  <p class="maintext_inner">Tax to</p>
							</div>
							<div align="right" id="inner_rightcontent" class="newwidth">
								<span class="maintext_inner">								
									<input type="radio" name="taxto" value="subtotal" <?php if($gendata["taxto"] == "subtotal"){ ?> checked <?php } ?>>Sub total only<input type="radio" name="taxto" value="gtotal" <?php if($gendata["taxto"] == "gtotal"){ ?> checked <?php } ?>>Subtotal Plus Shipping Charge									
								</span>							
							</div>
							<div align="left" class="float_clear1"><?php echo $html->image('/img/clear.gif', array('width' => 1, 'height' => 1));?></div>
						  </div>
				  
				  
				
                   
							<div id="admin_bottom">
								<div align="left" id="inner_leftcontent">
								  <p class="maintext_inner">&nbsp;</p>
								</div>
								<div align="right" id="inner_rightcontent" class="newwidth">
									<span class="toplinks">
									<input type="submit" value="Save" class="buttn_admin" >
									<input type="button" value="Back" class="buttn_admin"  onClick="javascript:history.go(-1);">	
									</span>
								</div>
								<div align="left" class="float_clear1"><?php echo $html->image('/img/clear.gif', array('width' => 1, 'height' => 1));?></div>
								
				   </form>
                    </div>
                <!--form area end -->
              </div>
              <div align="left" class="float_clear1"></div>
          
            <div align="left" class="float_clear1"><?php echo $html->image('/img/clear.gif', array('width' => 1, 'height' => 1));?></div>
 <br /> <br /> 
</div><!--end of general tab -->





<div id="domain" style="display:inline">  <!-- Start of domain  tab -->			
			<div align="left" id="item_details_admin" class="bordernew">
				<!--items display area start -->
					 <br />	
					<form action="<?php echo $sitebase.$sitefolder.'/'.$this->params["controller"];?>" method="get" name="frmUsers">
					<div>
    				<div style="float:left">
					<select name="cmbSearchType" class="box2_admin">
				
				<?php foreach ($countrylist as $key => $value) { ?>
					<option value="<?php echo $key; ?>"  <?php if($cmbSearchType == $key){ echo("selected"); } ?>><?php echo $value; ?></option>
				<?php } ?>
				</select> &nbsp;
				</div>
				<div>
				<a style="cursor:pointer" onClick="javascript:clickSearch();"><?php echo $html->image('/img/search_bttn.gif');?></a>					
	             </div>		
				 </div>	            				
               </form>	
				<br />			
              <div align="left" id="item_details_admin">
				<!--items display area start -->
				<label class="btn_style-org"><strong><?php echo $html->link('Add New Tax Rate','/states/add');?> >></strong></label>
				<div class="clear"></div>
				 <br />	 <br />		
				
<form name="customlist" method="post" action="/vistacart/customfieldvalues/edit">
				  <div align="center" id="items_display_area_admin">
                                      
                                    <?php 
      if($cmbSearchType <> ''){
       $paginator->options(array('url'=>array_merge(array('cmbSearchType'=>$cmbSearchType,'tab'=> 2),$this->passedArgs))); } else {
       $paginator->options(array('url'=>array_merge(array('tab'=> 2),$this->passedArgs))); }  ?>
						
                       <div id="list_admin_top">
					   					<div class="list9"><strong>#</strong></div>
										<div class="lists1"><strong><?php echo $paginator->sort('State Code', 'code'); ?></strong></div>
										<div class="lists2"><strong><?php echo $paginator->sort('State Name', 'name'); ?></strong></div>	
										<div class="lists2"><strong><?php echo $paginator->sort('Country ', 'Country.country_name'); ?></strong></div>	
										<div class="lists6"><strong><?php echo $paginator->sort('Tax Name', 'tax_name'); ?></strong></div>	
										<div class="lists5"><strong><?php echo $paginator->sort('Tax Rate', 'tax_rate'); ?></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
				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($data)){
	foreach ($data as $datas){?>   
						<div id="list_admin">
										<div class="list9"><?php echo $cnt++;?></div>
										<div class="lists1">
										<?php echo Sanitize::html($datas['State']['code']); ?>
										</div>
										
										<div class="lists2">
										<?php echo Sanitize::html($datas['State']['name']); ?>
                                        </div> 
										
										<div class="lists2">
										<?php echo Sanitize::html($datas['State']['country_name']); ?>
                                        </div>                                        
										<div class="lists6">
										<?php echo Sanitize::html($datas['State']['tax_name']); ?>
                                        </div> 
										<div class="lists5">
										<?php echo Sanitize::html($datas['State']['tax_rate']); ?>
                                        </div> 
										<div class="listp7">
										<?php echo $html->link('Edit', "/states/edit/".$datas['State']['id'])." / ".$html->link('Delete', "/states/delete/".$datas['State']['id'],null,'Are you sure you want to delete this Tax details'); ?>
                                        </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>&nbsp;</div>
										<div  id="admin_bottom">
										
										 <?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="list_admin">									
										
										<div>&nbsp;</div>
										<div><strong>Sorry no Tax Rates 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>
</div></div>


</div> <!-- Ends of domain tab -->	
									
                    
 </div>							
<div align="left" class="float_clear1"></div>           
<div align="left" class="float_clear1"><?php echo $html->image('/img/clear.gif');?></div>
			
			
<?php
if(!isset($tab)){ ?>
<script language="javascript">
		showdiv('general');
		</script>
<?php
}else{
	if($tab== 'gen'){ ?>
		<script language="javascript">
		showdiv('general');
		</script>
	<?php }elseif($tab == 'domain'){?>
		<script language="javascript">
		showdiv('domain');
		</script>
	<?php }else{ ?>
		<script language="javascript">
		showdiv('general');
		</script>
<?php
	 }
	} ?>
 <script language="javascript" type="text/javascript">
showdiv1();
</script>