<?

/*
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 = $MsgText[0][581];
	$BrowserTitle = $MsgText[0][581];
	$LocationBar = '<a href="'.$IndexURL.'">'.$MsgText[0][1].'</a> > <a href="' . $MainURL . '/options.html">'.$MsgText[0][4].'</a> > '.$MsgText[0][581];
	
	if ($LoggedIn == 'y') {
		
		ReadPermissions();
		Global $Permissions;
		
		if ($Permissions[21] == 'y') {
		
			
			$query = "select * from `".$Settings['DBPrefix']."core-Countries` order by Name asc";
			$result = mysql_query($query) or die (mysql_error());
			while ($row = mysql_fetch_array($result)) {
				
				if ($NumbersList != '') {
					$NumbersList .= ',';
				}
				$NumbersList .= $row['RecordNumber'];
				
				if ($row['AllowUsers'] == 1) {
					$UsersPart = '<td align="center"><input type="checkbox" name="AllowUsers-'.$row['RecordNumber'].'" value="1" checked></td>';
				}
				else {
					$UsersPart = '<td align="center"><input type="checkbox" name="AllowUsers-'.$row['RecordNumber'].'" value="1"></td>';
				}
				
				
				if ($IM['ec'] == 'y') {
				
					if ($row['AllowSales'] == 1) {
						$StorePart = '<td align="center"><input type="checkbox" name="AllowSales-'.$row['RecordNumber'].'" value="1" checked></td>';
					}
					else {
						$StorePart = '<td align="center"><input type="checkbox" name="AllowSales-'.$row['RecordNumber'].'" value="1"></td>';
					}
				
				}
												
				$DataRows .= '<tr><td><font face="'.$FontFace.'" size="'.$FontSize.'"><a href="'.$MainURL.'/admin/countries-edit/'.$row['RecordNumber'].'.html">'.$row['Name'].' ('.$row['Code'].')</a></font></td>'.$UsersPart.$StorePart.'</tr>';
				
			}
			
			
			if ($IM['ec'] == 'y') {
			
				$StorePart = '<td align="center"><font face="'.$FontFace.'" size="'.$FontSize.'"><b>'.$MsgText[0][608].'</b></font></td>';
				$StorePart2 = '<td align="center"><font face="'.$FontFace.'" size="'.$FontSize.'"><a href="javascript:SelectAll(2);">'.$MsgText[0][610].'</a><br><a href="javascript:DeSelectAll(2);">'.$MsgText[0][611].'</a></font></td>';
				
				$StoreTextPart = $MsgText[0][612];
			
			}
			else {
				$StoreTextPart = $MsgText[0][613];
			}
			
			$PageContents = '<form name="CountriesRegions" action="'.$MainURL.'/admin/countries-save" method="post"><input type="hidden" name="FormDataFiller" value="FormDataFiller">'.$StoreTextPart.'  '.$MsgText[0][614].'<br><br><b>'.$MsgText[0][615].'</b><br><br><br><div align="center"><table border="0" cellpadding="5" cellspacing="0">
    <tr>
      <td><font face="'.$FontFace.'" size="'.$FontSize.'"><b>'.$MsgText[0][616].'</b></font></td>
      <td align="center"><font face="'.$FontFace.'" size="'.$FontSize.'"><b>'.$MsgText[0][609].'</b></font></td>'.$StorePart.'
    </tr>
	<tr>
      <td>&nbsp;</td>
      <td align="center"><font face="'.$FontFace.'" size="'.$FontSize.'"><a href="javascript:SelectAll(1);">'.$MsgText[0][610].'</a><br><a href="javascript:DeSelectAll(1);">'.$MsgText[0][611].'</a></font></td>'.$StorePart2.'
    </tr>
	'.$DataRows.'
	
	<script>
		
	var NumbersList = new Array('.$NumbersList.');
	
	function SelectAll(UsersSales) {
		if (UsersSales == 1) {
			for (x=0; x<NumbersList.length; x++) {
				document.forms["CountriesRegions"].elements["AllowUsers-"+NumbersList[x]].checked = true;
			}
		}
		if (UsersSales == 2) {
			for (x=0; x<NumbersList.length; x++) {
				document.forms["CountriesRegions"].elements["AllowSales-"+NumbersList[x]].checked = true;
			}
		}
	}
	function DeSelectAll(UsersSales) {
		if (UsersSales == 1) {
			for (x=0; x<NumbersList.length; x++) {
				document.forms["CountriesRegions"].elements["AllowUsers-"+NumbersList[x]].checked = false;
			}
		}
		if (UsersSales == 2) {
			for (x=0; x<NumbersList.length; x++) {
				document.forms["CountriesRegions"].elements["AllowSales-"+NumbersList[x]].checked = false;
			}
		}
	}
	</script>
</table><br><br><br><input type="submit" value="'.$MsgText[0][123].'" style="'.$FormStyle.'"></div></form>';
		
		
		}
		else {
		
			$PageContents = $MsgText[0][97];
		
		}

	}
	else {
	
		RedirectToLogin();
	
	}

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




?>
