<?php
include("postget.php");
include_once("common.php");
checklevel(4,$_REQUEST['clientid']);
if ($config[56][1]==1){
	messagetop(_CHANGE_NOT_ALLOWED_IN_DEMO_MODE,'','main.php',0); 
}

include("head_template.php");
echo '
<div class="container">
	<div class="row">


<table width="98%" class="table table-bordered">
		<tr>
		<td align="center" width="100%">
';
$title = 'n';
echo '
		</td>
		</tr>
';

echo '
			<tr valign="top">
				<td>

';


if ($_REQUEST['option']=='addlang'){
	print("<form method='POST' action='languages.php'>");
	print("<span class='sizeextrabold'>".ucfirst(_NEW_LANGUAGE).": </span>");

	print("<select name='newlang' class='sizeextrabold'>");
	$query="SELECT * FROM hd_langcodes ORDER BY name";
	$aq=mysql_query($query,$db_link);
	while($row=mysql_fetch_array($aq)) {
		print ("<option value='".$row[code]."'>".$row[name]." (".$row[code].")</option>");
	};
	print("</select>");
	print(" <input type='submit' name='click' value='"._ADD."'>");

	print("</form>");

}elseif ($_REQUEST['option']=='dellang'){
	print("<form method='POST' action='languages.php'>");

	print("<span class='sizeextrabold'>".ucfirst(_LANGUAGE_TO_BE_DELETED).":</span> <select name='language2delete' class='sizeextrabold'>");
	$result = mysql_query("SHOW COLUMNS FROM hd_languages");
	if (mysql_num_rows($result) > 0) {
		while ($row = mysql_fetch_assoc($result)) {
			if ($row[Field]<>'original' AND $row[Field]<>'en' AND $row[Field]<>'es'){
				print("<option value='".$row[Field]."'>".$row[Field]."</option>");
			}
		}
	}
	print("</select>");

	print("<br><br><span class='sizeextrabold'><font color='red'>".ucfirst(_ARE_YOU_SURE)."?</font>&nbsp;&nbsp;&nbsp;"._WRITE." ".strtoupper(_YES)."</b></span> <input name='aresure' size='5' class='sizeextrabold'>");
	print(" <input type='submit' name='click' value='"._DELETE."' class='btn'>");
	print(" <input type='submit' name='click' value='"._RETURN."' class='btn'>");
	print("</form>");

}elseif ($_REQUEST['newlang']){
	$q = "ALTER TABLE `hd_languages` ADD `".trim(strtolower($_REQUEST[newlang]))."` TEXT NULL";
	if (!mysql_query($q)) {echo '<hr><b>ERROR</b><br>'.mysql_error(); exit;}
	
	yellowbutton('languages.php',lang('_TRANSLATE_TEXT_MANUALLY'),1);

}elseif ($_REQUEST['aresure']==''.strtoupper(_YES).'' AND $_REQUEST['language2delete']){
	$q = "ALTER TABLE `hd_languages` DROP `".trim(strtolower($_REQUEST[language2delete]))."`";
	if (!mysql_query($q)) {echo '<hr><b>ERROR</b><br>'.mysql_error(); exit;}
	go2('languages.php');

}else{
	greenbutton('languages.php?option=addlang',lang('_ADD_LANGUAGE'),1);
	redbutton('languages.php?option=dellang',lang('_DELETE_LANGUAGE'),1);
	
//	echo "<a href='".$serverurl."/languages.php?option=addlang'><b>".strtoupper(_ADD_LANGUAGE)."</b></a>";
//	echo "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
//	echo "<a href='".$serverurl."/languages.php?option=dellang'><b>".strtoupper(_DELETE_LANGUAGE)."</b></a>";
}


echo '
		</td>
		</tr>
		</table>
</div>
</div>
';


////////////////////////////////////////////////////////////////////////////////////

echo '
<div class="container">
	<div class="row">


<table width="98%" class="table table-bordered">
		<tr>
		<td align="center" width="100%">
';
echo _TRANSLATIONS; $title = 'y';
echo '
		</td>
		</tr>
';

echo '
			<tr valign="top">
				<td>

';



echo '
<link rel="stylesheet" type="text/css" media="screen" href="css/data_grid.css">
';

require_once('phpmydatagrid.class.php');


include("languages_grid.php");


echo '
		</td>
		</tr>
		</table>
</div>
</div>
';

//include("foot_template.php");


?>