<?php 
session_start();

define("PUBLIC_ACCESS", 1);
?>

<!DOCTYPE html>
<html lang="en">

<head>
  <meta http-equiv="Content-Language" content="en-us">
  <title>Data Collection</title>
  <meta charset="utf-8">

<link rel="stylesheet" href="/ext/bootstrap/bootstrap.min.css">
<link rel="stylesheet" href="/ext/bootstrap/bootstrap-theme.min.css">
<link rel="stylesheet" href="/site/css/stickythead.css">
<link rel="stylesheet" href="/site/css/bootstrap.css">

<script src="/ext/jquery/jquery-3.1.1.min.js"></script>
<script src="/ext/bootstrap/bootstrap.min.js"></script>
<script src="/ext/jquery/jquery.stickytableheaders.min.js"></script>
 
</head>
<body>

<?php 

$docRoot = $_SERVER['DOCUMENT_ROOT'];
$toolkit = $docRoot .  "/toolkit";

require_once ("$toolkit/livesearch.php");
require_once ("$docRoot/dbtables/model.php");
require_once ("$docRoot/dbtables/view.php");
require_once ("$docRoot/dbtables/controller.php");

$tableName = "";
if (isset($_SESSION['table-name'])) 
  $tableName = $_SESSION['table-name'];

$dbTables = new modDBTables($tableName);
$dbTablesController = new modDBTablesController($dbTables);

//If one of the forms has been submitted, call the relevant controller action
if (isset($_POST['action'])) $dbTablesController->{$_POST['action']}($_POST);

$dbTablesView = new modDBTablesView($dbTables);
echo $dbTablesView->output();

?>

