<?php
/*---------------------------------------------------+
| PHP-Fusion 6 Content Management System
+----------------------------------------------------+
| Copyright © 2002 - 2005 Nick Jones
| http://www.php-fusion.co.uk/
+----------------------------------------------------+
| Released under the terms & conditions of v2 of the
| GNU General Public License. For details refer to
| the included gpl.txt file or visit http://gnu.org
+----------------------------------------------------*/
require_once "maincore.php";
require_once BASEDIR."subheader.php";
require_once BASEDIR."side_left.php";

if (file_exists(INFUSIONS."suggestion_box/locale/".$settings['locale'].".php")) {
	include INFUSIONS."suggestion_box/locale/".$settings['locale'].".php";
} else {
	include INFUSIONS."suggestion_box/locale/English.php";
}

if (iMEMBER) {

if (!isset($step)) $step = "";

if (isset($_POST['submit_suggestion'])) {
	$suggestion_summary = stripinput($_POST['suggestion_summary']);
	$suggestion_version = stripinput($_POST['suggestion_version']);
	$suggestion_description = stripinput($_POST['suggestion_description']);
	if ($suggestion_summary != "" && $suggestion_description != "") {
		$result = dbquery("INSERT INTO ".$db_prefix."suggestion_box VALUES('', '".$userdata['user_id']."', '$suggestion_summary', '$suggestion_version', '$suggestion_description', '', '".$locale['err142']."', '".time()."')");
	}
	redirect(FUSION_SELF);
}
if ($step == "view") {
	include INCLUDES."comments_include.php";
	if (!$suggestion_id || !isNum($suggestion_id)) fallback(FUSION_SELF);
	opentable($locale['err110']);
	$data = dbarray(dbquery(
		"SELECT ter.*, user_id,user_name FROM ".$db_prefix."suggestion_box ter
		LEFT JOIN ".$db_prefix."users tusr ON ter.suggestion_user=tusr.user_id
		WHERE suggestion_id='".$suggestion_id."'"
	));
	echo "<table width='100%' cellpadding='0' cellspacing='1' class='tbl-border'>
<tr>
<td class='tbl2'><b>".$data['suggestion_summary']."</b></td>
</tr>
<tr>
<td width='125' class='tbl2'>".$locale['err111']."</td>
<td class='tbl1'><a href='".BASEDIR."profile.php?lookup=".$data['user_id']."'>".$data['user_name']."</a> -
".strftime($settings['longdate'], $data['suggestion_datestamp']+($settings['timeoffset']*3600))."</td>
</tr>
<tr>
<td width='125' class='tbl2'>".$locale['err112']."</td>
<td class='tbl1'>".$data['suggestion_version']."</td>
</tr>
<tr>
<td width='125' class='tbl2'>".$locale['err113']."</td>
<td class='tbl1'>".nl2br($data['suggestion_description'])."</td>
</tr>\n";
	if ($data['suggestion_response']) {
		echo "<tr>
<td width='125' class='tbl2'>".$locale['err114']."</td>
<td class='tbl1'>".nl2br($data['suggestion_response'])."</td>
</tr>\n";
	}
	echo "<tr>
<td width='125' class='tbl2'>".$locale['err115']."</td>
<td class='tbl1'>".$data['suggestion_status']."</td>
</tr>
</table>\n";
	closetable();
	showcomments("E","suggestion_box","suggestion_id",$suggestion_id,FUSION_SELF."?step=view&suggestion_id=$suggestion_id","");
	tablebreak();
}

tablebreak();
opentable($locale['err130']);
echo "<form name='reportform' method='post' action='".FUSION_SELF."'>
".$locale['err135']."
<table align='center' cellspacing='0' cellpadding='0' class='tbl'>
<tr>
<td>".$locale['err131']."</td>
<td><input type='text' name='suggestion_summary' class='textbox' style='width:300px;'></td>
</tr>
<tr>
<td valign='top'>".$locale['err134']."</td>
<td><textarea name='suggestion_description' rows='5' class='textbox' style='width:300px;'></textarea></td>
</tr>

<tr>
<td align='center' colspan='2'>
<input type='submit' name='submit_suggestion' value='".$locale['err130']."' class='button'></td>
<hr>
<center>(Laukeliai pa?ymėti * būtini)<center><hr>
</tr>
</table>
</form>\n";
closetable();

} else {
	opentable($locale['err120']);
	echo "<center><br>\n".$locale['err124']."<br><br>\n</center>\n";
	closetable();
}

require_once BASEDIR."side_right.php";
require_once BASEDIR."footer.php";
?>