Your IP : 216.73.217.79


Current Path : /var/www/cesa.co.za/
Upload File :
Current File : /var/www/cesa.co.za/savebecs.php

<?php
// Long version
include_once($_SERVER['DOCUMENT_ROOT'] . "/php/inc_db.php");

$sql = "SELECT * FROM BECS ORDER BY BECSID DESC";
$rec = mysqli_query($conni, $sql);
if ($row = mysqli_fetch_assoc($rec)) {
	if ($row["IsOpen"] == 0) {
		echo "The BECS is closed.";
		die();
	}
	$sStartDate = date("d F Y", strtotime($row["StartDate"]));
	$sEndDate = date("d F Y", strtotime($row["EndDate"]));
	$sDeadline = date("d F Y", strtotime($row["Deadline"]));
	$sDocLink = "public_downloads/" . urlencode($row["DownloadFile"]);

	$iYear = intval(date("Y", strtotime($row["StartDate"])));
	$sStartMonth = date("F", strtotime($row["StartDate"]));
	$sEndMonth = date("F", strtotime($row["EndDate"]));

	$sPast6Months = date("M", strtotime($row["StartDate"])) . " - " . date("M Y", strtotime($row["EndDate"]));
	$sNext6Months = date("M", strtotime("+6 months", strtotime($row["StartDate"]))) . " - " . date("M Y", strtotime("+6 months", strtotime($row["EndDate"])));
	$sNextNext6Months = date("M", strtotime("+1 year", strtotime($row["StartDate"]))) . " - " . date("M Y", strtotime("+1 year", strtotime($row["EndDate"])));
} else {
	die();
}
mysqli_free_result($rec);

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<title>CESA Bi-Annual Economic and Capacity Survey</title>
	<style type="text/css">
		<!--
		body,
		td,
		th {
			font-family: Verdana, Arial, Helvetica, sans-serif;
			font-size: 12px;
		}

		.style1 {
			color: #CC0033;
			font-weight: bold;
		}

		li {
			padding-top: 10px;
			padding-bottom: 10px;
			border-bottom: 1px solid #DDDDDD;
		}

		.alt {
			background-color: #EEEEEE;
		}

		body {
			margin-left: 10px;
			margin-top: 10px;
			margin-right: 10px;
			margin-bottom: 10px;
		}
		-->
	</style>
</head>

<body>
	<h1><img src="images/cesa.gif" alt="CESA" width="192" height="75" align="left" />CESA Bi-Annual Economic and Capacity Survey</h1>
	<?php

	include($_SERVER['DOCUMENT_ROOT'] . "/inc/auth.inc");
	$db = mysqli_connect($loghost, $logid, $logpwd, $dbname);

	$sql = "SELECT mis_id FROM mis WHERE firm_id='" . intval($_POST["FirmID"]) . "'";
	$rec = mysqli_query($db, $sql);
	if ($row = mysqli_fetch_assoc($rec)) {
		$mis_id = $row["mis_id"];
		$sql = "DELETE FROM mis_fields WHERE mis_id='" . $mis_id . "'";
		mysqli_query($db, $sql);
	} else {
		$sql = "INSERT INTO mis (firm_id, date_updated) VALUES ('" . intval($_POST["FirmID"]) . "', '" . date("Y-m-d H:i") . "')";
		mysqli_query($db, $sql);
		$mis_id = mysqli_insert_id($db);
	}
	mysqli_free_result($rec);
	foreach ($_POST as $fieldname => $fieldvalue) {
		$sql = "INSERT INTO mis_fields (mis_id, field_name, field_value) VALUES ('" . $mis_id . "', '" . $fieldname . "', '" . $fieldvalue . "')";
		mysqli_query($db, $sql) or die(mysqli_error($db) . ": " . $sql);
	}
	if ($_POST["savenow"] == "1") {
	?>
		<p><b>Your responses have been saved. You can close this window, but please make a note of the address you should use to return to complete the questionnaire:</b></p>
		<p><b><a href="http://www.cesa.co.za/becs.php?FirmID=<?php echo $_POST["FirmID"]; ?>">http://www.cesa.co.za/becs.php?FirmID=<?php echo $_POST["FirmID"]; ?></a></b></p>
		<p><b>NOTE:</b> If you do not use the address above to return to complete the questionnaire, your previous responses will not appear. Please bookmark this link.</p>
	<?php
	} else {
		$sql = "UPDATE mis SET date_completed='" . date("Y-m-d H:i") . "' WHERE mis_id='" . $mis_id . "'";
		mysqli_query($db, $sql);
	?>
		<p><b>Thank you for taking the time to complete our questionnaire. Your responses have been saved. You may now close this window.</b></p>
	<?php
	}
	?>
</body>

</html>