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



//////////////////////////////////////////////////////////////// si se envi� el formulario, cargar los errores
if ($_REQUEST[sendclick]==""._SEND."") {
	$estiloerror = "class='formfielderror'";
	$errors = '';
	if ($_POST['Xcompany']=='') {$errors.= "<br>".ucfirst(_COMPANY).": "._NOT_SPECIFIED.""; $estilocompany=$estiloerror;}
}

//////////////////////////////////////////////////////////////// si no hay errores y se presion� SEND
if($errors=='' AND $_REQUEST[sendclick] ==""._SEND."") {
	if($Xshowintheheader=="on"){$Xshowintheheader=1;}else{$Xshowintheheader=0;}
	if($Xshowintheheader1=="on"){$Xshowintheheader1=1;}else{$Xshowintheheader1=0;}
	if($Xshowintheheader2=="on"){$Xshowintheheader2=1;}else{$Xshowintheheader2=0;}
	if($Xchangelang=="on"){$Xchangelang=1;}else{$Xchangelang=0;}

	mysql_query("UPDATE hd_config SET valor='$Xcompany' WHERE variable='company'",$db_link);
	mysql_query("UPDATE hd_config SET valor='$Xslogan_line1' WHERE variable='slogan_line1'",$db_link);
	mysql_query("UPDATE hd_config SET valor='$Xslogan_line2' WHERE variable='slogan_line2'",$db_link);
	mysql_query("UPDATE hd_config SET valor='$Xshowintheheader' WHERE ref='50'",$db_link);
	mysql_query("UPDATE hd_config SET valor='$Xshowintheheader1' WHERE ref='7'",$db_link);
	mysql_query("UPDATE hd_config SET valor='$Xshowintheheader2' WHERE ref='15'",$db_link);
	mysql_query("UPDATE hd_config SET valor='$Xpagetitle' WHERE ref='2'",$db_link);
	mysql_query("UPDATE hd_config SET valor='$Xdescription' WHERE ref='81'",$db_link);
	mysql_query("UPDATE hd_config SET valor='$Xkeywords' WHERE ref='83'",$db_link);
	mysql_query("UPDATE hd_config SET valor='$Xchangelang' WHERE ref='104'",$db_link);
	mysql_query("UPDATE hd_config SET valor='$lang4admin' WHERE ref='107'",$db_link);
	
	mysql_query("UPDATE hd_clients SET preflang='$lang4admin' WHERE preflang IS NULL",$db_link);

	messagetop(_THE_CHANGES_WHERE_MADE_SUCCESSFULLY,'','preferences.php?option=2',1);


}else{


	$query="SELECT * FROM hd_config ORDER BY ref";
	$result=mysql_query($query,$db_link);
	$fila=0;
	while($row=mysql_fetch_array($result))
	{
		$Config[$fila][0]=$row["variable"] ;
		$Config[$fila][1]="'".$row["valor"]."'";
		$fila++ ;
	}

	print errors($errors); $errors = '';


	print("<form method='POST'>");
	echo '<table class="table table-striped">';
        echo '<tbody>';
	echo '<tr>';
	print("<td>".tip(28)."<b>".ucfirst(_COMPANY).":</b> </td><td>");
	print("<input $estilocompany name=Xcompany value=".$Config[0][1]." size=60>");

	print(" <input type='checkbox' name=Xshowintheheader");
	if ($Config[50][1]=="'1'"){print(" checked");};
	print(">".lang('_SHOW_IN_THE_HEADER')."
	</td></tr>");


	echo '<tr>';
	print("<td>".tip(29)."".ucfirst(_SLOGAN_LINE1).": </td><td>");
	print("<input name=Xslogan_line1 value=".$Config[11][1]." size=100>");
	print(" <input type='checkbox' name=Xshowintheheader1");
	if ($Config[7][1]=="'1'"){print(" checked");};
	print(">".lang('_SHOW_IN_THE_HEADER')."
	</td></tr>
	</td></tr>");

	echo '<tr>';
	print("<td>".tip(30)."".ucfirst(_SLOGAN_LINE2).": </td><td>");
	print("<input name=Xslogan_line2 value=".$Config[12][1]." size=100>");
	print(" <input type='checkbox' name=Xshowintheheader2");
	if ($Config[15][1]=="'1'"){print(" checked");};
	print(">".lang('_SHOW_IN_THE_HEADER')."
	</td></tr>
	</td></tr>");

	echo '<tr>';
	print("<td>".tip(31)."".ucfirst(_PAGE_TITLE).":<br><br>
	<b>&lt;TITLE&gt;</b>".substr($config[2][1],0,10)."...<b>&lt;/TITLE&gt;</b>
	</td><td>");
	print("<input name=Xpagetitle value=".$Config[2][1]." size=100>");
	print("</td></tr>");

	echo '<tr>';
	print("<td>".tip(32)."".ucfirst(_PAGE_DESCRIPTION).":<br><br>
	<b>&lt;meta name=\"description\" content=\"</b>".substr($config[81][1],0,40)."...<b>\"&gt;</b></td><td>");
	print("<textarea name=Xdescription cols=100 rows=5>".$config[81][1]."</textarea>");
	print("</td></tr>");

	echo '<tr>';
	print("<td>".tip(33)."".ucfirst(_KEYWORDS).":<br><br>
	<b>&lt;meta name=\"keywords\" content=\"</b>".substr($config[83][1],0,20)."...<b>\"&gt;</b></td><td>");
	print("<textarea name=Xkeywords cols=100 rows=2>".$config[83][1]."</textarea>");
	print("</td></tr>");

	echo '<tr>';
	print("<td>".tip(35)."".ucfirst(_ALLOW_CHANGE_LANGUAGE)."?: </td><td>");
	print("<input type='checkbox' name=Xchangelang");
	if ($config[104][1]== '1'){print(" checked");};
	print(">
	</td></tr>");

	echo '<tr>';
	print("<td>".tip(36)."".ucfirst(_LANGUAGE_OF_ADMINISTRATION).": </td><td>");
	print("<select name='lang4admin'>");
	$query="SHOW COLUMNS FROM hd_languages";
	$preflangs=mysql_query($query,$db_link);
	while($rowpf=mysql_fetch_assoc($preflangs)) {
		if ($rowpf[Field]<>'original'){
				print ("<option value='".$rowpf[Field]."' ".sele($config[107][1],$rowpf[Field]).">".langname($rowpf[Field])." (".$rowpf[Field].")</option>");
		}
	};
	print("</select>
	</td></tr>");
	
	print("</td></tr></tbody>");


	print("</table>");
	print("<input type=submit name=sendclick value="._SEND." $disabled>$mensaje</form>");

}
?>