<?

/*
FlexCMS (http://www.flexcms.com)
Flexible, Powerful, Affordable.

Contents of this file are protected by the copyright
notice found at http://www.flexcms.com/flex/pages/copyright.html,
and its usage is subject to the terms of the licensing agreement 
available at http://www.flexcms.com/flex/pages/license.html
*/



	// ========================================================================================
	
	// ========================================================================================
	
	$PageTitle = '<img src="'.$ImagesURL.'/admin/admincp_ecom.gif" width="20" height="21" align="middle"> '.$MsgText[9][116];
	$BrowserTitle = $MsgText[9][116];
	$LocationBar = '<a href="'.$IndexURL.'">'.$MsgText[0][1].'</a> > <a href="' . $MainURL . '/options.html">'.$MsgText[0][4].'</a> > '.$MsgText[9][116];
	
	if ($LoggedIn == 'y') {
		
		ReadPermissions();
		Global $Permissions;
		
		if ($Permissions[904] == 'y') {
		
			
			$PageContents .= '<br><b>'.$MsgText[9][117].':</b><br><br>';
			
			
			if ($Permissions[21] == 'y') {
				
				$PageContents .= $MsgText[9][118].': <a href="'.$MainURL.'/admin/countries.html">'.$MsgText[0][581].'</a>.<br><br>';
			
			}
			
			
			$query = "select * from `".$Settings['DBPrefix']."core-Countries` where AllowSales=1 order by Name asc";
			$result = mysql_query($query) or die (mysql_error());
			while ($row = mysql_fetch_array($result)) {
				
				
				//$PageContents .= '<br><br><b>'.$row['Name'].'</b>';
				$ItemsCount++;
				$PageContents .= '<a href="javascript:ExpandCollapse(\''.$ItemsCount.'\');" style="text-decoration: none;"><img id="img'.$ItemsCount.'" src="'.$ImagesURL.'/admin/minus.gif" border="0" width="9" height="9" alt=""> '.$row['Name'].'</a><br><div id="div'.$ItemsCount.'">';
				
				
				$query3 = "select * from `".$Settings['DBPrefix']."ec-Taxes` where Type='N' and Arguments1='".$row['Code']."' and Deleted!=1 order by Active desc, Title asc";
				$result3 = mysql_query($query3) or die (mysql_error());
				if (mysql_num_rows($result3) > 0) {
					while ($row3 = mysql_fetch_array($result3)) {
					
						while ((substr($row3['Rate'],strlen($row3['Rate'])-1,1) == '0' || substr($row3['Rate'],strlen($row3['Rate'])-1,1) == '.') && $row3['Rate'] != '') {
							$row3['Rate'] = substr($row3['Rate'],0,strlen($row3['Rate'])-1);
						}
						
						if ($row3['Rate'] == '') {
							$row3['Rate'] = '0.0';
						}
					
					
						if ($row3['Active'] == 1) {
							$Status = '<font color="#00aa00">'.$MsgText[9][76].'</font>';
						}
						else {
							$Status = '<font color="#ff0000">'.$MsgText[9][77].'</font>';
						}
					
					
						$PageContents .= '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="'.$MainURL.'/admin/store-taxes-edit/'.$row3['RecordNumber'].'.html">'.$row3['Title'].' '.$row3['Description'].' ('.$row3['Rate'].'%)</a> - '.$Status.'<br>';
					}
					
					$PageContents .= '<img src="'.$ImagesURL.'/admin/spacer.gif" width="1" height="3" alt="" border="0"><br>';
				}
				
				
				$PageContents .= '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="'.$MainURL.'/admin/store-taxes-new/n/'.$row['RecordNumber'].'.html">'.$MsgText[9][119].'</a><br>';
				
				
				$query2 = "select * from `".$Settings['DBPrefix']."core-StatesProvinces` where Country='".$row['Code']."' order by Name asc";
				$result2 = mysql_query($query2) or die (mysql_error());
				if (mysql_num_rows($result2) > 0) {
					$PageContents .= '<img src="'.$ImagesURL.'/admin/spacer.gif" width="1" height="15" alt="" border="0"><br>';								
	
					while ($row2 = mysql_fetch_array($result2)) {
						
						//$PageContents .= '<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'.$row2['Name'];
						
						
						$ItemsCount++;
						$PageContents .= '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="javascript:ExpandCollapse(\''.$ItemsCount.'\');" style="text-decoration: none;"><img id="img'.$ItemsCount.'" src="'.$ImagesURL.'/admin/minus.gif" border="0" width="9" height="9" alt="">&nbsp;'.$row2['Name'].'</a><br><div id="div'.$ItemsCount.'">';
					
						
						$query3 = "select * from `".$Settings['DBPrefix']."ec-Taxes` where Type='S' and Arguments1='".$row['Code']."' and Arguments2='".$row2['Code']."' and Deleted!=1 order by Active desc, Title asc";
						$result3 = mysql_query($query3) or die (mysql_error());
						if (mysql_num_rows($result3) > 0) {
							while ($row3 = mysql_fetch_array($result3)) {
							
								while ((substr($row3['Rate'],strlen($row3['Rate'])-1,1) == '0' || substr($row3['Rate'],strlen($row3['Rate'])-1,1) == '.') && $row3['Rate'] != '') {
									$row3['Rate'] = substr($row3['Rate'],0,strlen($row3['Rate'])-1);
								}
								
								if ($row3['Rate'] == '') {
									$row3['Rate'] = '0.0';
								}
							
							
								if ($row3['Active'] == 1) {
									$Status = '<font color="#00aa00">'.$MsgText[9][76].'</font>';
								}
								else {
									$Status = '<font color="#ff0000">'.$MsgText[9][77].'</font>';
								}
							
								$PageContents .= '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="'.$MainURL.'/admin/store-taxes-edit/'.$row3['RecordNumber'].'.html">'.$row3['Title'].' '.$row3['Description'].' ('.$row3['Rate'].'%)</a> - '.$Status.'<br>';
							}
												
							$PageContents .= '<img src="'.$ImagesURL.'/admin/spacer.gif" width="1" height="3" alt="" border="0"><br>';
						}
					
						$PageContents .= '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="'.$MainURL.'/admin/store-taxes-new/s/'.$row2['RecordNumber'].'.html">'.$MsgText[9][120].'</a><br>';

						$PageContents .= '<img src="'.$ImagesURL.'/admin/spacer.gif" width="1" height="15" alt="" border="0"><br>';
					
					
					
						$query3 = "select * from `".$Settings['DBPrefix']."ec-Taxes` where Type='L' and Arguments1='".$row['Code']."' and Arguments2='".$row2['Code']."' and Deleted!=1 order by Active desc, Title asc";
						$result3 = mysql_query($query3) or die (mysql_error());
						if (mysql_num_rows($result3) > 0) {
							while ($row3 = mysql_fetch_array($result3)) {
							
								while ((substr($row3['Rate'],strlen($row3['Rate'])-1,1) == '0' || substr($row3['Rate'],strlen($row3['Rate'])-1,1) == '.') && $row3['Rate'] != '') {
									$row3['Rate'] = substr($row3['Rate'],0,strlen($row3['Rate'])-1);
								}
								
								if ($row3['Rate'] == '') {
									$row3['Rate'] = '0.0';
								}
							
							
								if ($row3['Active'] == 1) {
									$Status = '<font color="#00aa00">'.$MsgText[9][76].'</font>';
								}
								else {
									$Status = '<font color="#ff0000">'.$MsgText[9][77].'</font>';
								}
							
								$PageContents .= '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="'.$MainURL.'/admin/store-taxes-edit/'.$row3['RecordNumber'].'.html">'.$row3['Title'].' '.$row3['Description'].' ('.$row3['Rate'].'%)</a> - '.$Status.'<br>';
							}
											
							$PageContents .= '<img src="'.$ImagesURL.'/admin/spacer.gif" width="1" height="3" alt="" border="0"><br>';
						}
						
						$PageContents .= '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="'.$MainURL.'/admin/store-taxes-new/l/'.$row2['RecordNumber'].'.html">'.$MsgText[9][121].'</a><br>';

						$PageContents .= '<img src="'.$ImagesURL.'/admin/spacer.gif" width="1" height="5" alt="" border="0"><br>';
					
					
						$PageContents .= '</div>';
						
					}
									
				
				}
				
				$PageContents .= '<img src="'.$ImagesURL.'/admin/spacer.gif" width="1" height="5" alt="" border="0"><br>';
				
				$PageContents .= '</div>';
				
			}
			
						
		
		
			$PageContents .= '<script>

var ItemsCount = '.number_format($ItemsCount,0,'','').';

function CollapseAll() {

	for (x=1; x<=ItemsCount; x++) {
	
		var ElementID = document.getElementById("div"+x);
		var ImgElementID = document.getElementById("img"+x);
		
		ElementID.style.display = "none"
		ImgElementID.src = "'.$ImagesURL.'/admin/plus.gif";
	
	}

}

function ExpandCollapse(IDNumber) {

	var ElementID = document.getElementById("div"+IDNumber);
	var ImgElementID = document.getElementById("img"+IDNumber);
	
	if (ElementID.style.display != "none") {
		ElementID.style.display = "none"
		ImgElementID.src = "'.$ImagesURL.'/admin/plus.gif";
	}
	else {
		ElementID.style.display = ""
		ImgElementID.src = "'.$ImagesURL.'/admin/minus.gif";
	}

}

CollapseAll();

</script>';
		
		
		}
		else {
		
			$PageContents = $MsgText[0][97];
		
		}

	}
	else {
	
		RedirectToLogin();
	
	}

	// ========================================================================================




?>
