<?php

require "_globals.php";
require SECURITY;
require ADCHEATSHEET;
require CLASS_LUNCHSPECIAL;
$lunch = new handleLunchSpecial();
?>

<?php 
getHeader("admin");
?>

<h3>Lunch Specials</h3>

<table class="form">
	<tr>
		<td class="field-name">Date:</td>
		<td class="field-value"><?php 
echo fixDate($lunch->date);
?>
</td>
		<td></td>
	</tr>
	<tr>
		<td class="field-name">Views:</td>
		<td class="field-value"><?php 
echo number_format($lunch->views);
?>
</td>
		<td></td>
<?php

require "_globals.php";
require SECURITY;
require ADCHEATSHEET;
require CLASS_LUNCHSPECIAL;
$lunch = new handleLunchSpecial();
if (isset($_POST[submit])) {
    $lunch->adimages = $_POST["adselect"];
    $lunch->adheading = $_POST["adheading"];
    $lunch->adspecial = $_POST["adspecial"];
    if (false === ($error = $lunch->checkRequired())) {
        $error = $lunch->checkDate();
        if ($error == false) {
            $lunch->updateMenu();
            header("location: " . $_SERVER["PHP_SELF"] . "?menuid=" . $lunch->menuid . "&s=1");
            exit;
        }
    }
}
if ($_GET["s"]) {
    $s_mess[1] = "You have successfully created/modified a lunch menu.";
    $success = $s_mess[$_GET["s"]];
}
?>

<?php 
getHeader("admin");
?>

<h3>Lunch Specials</h3>
<?php

$ads_to_display = 2;
require "_admin/_globals.php";
require CONFIG_ADS;
require AD_FILE;
require CLASS_LUNCHSPECIAL;
$lunch = new handleLunchSpecial();
$rand = $lunch->randomAds($ads_to_display, $_GET["menu"]);
?>

<?php 
include LUNCHHEADER;
?>


<?php 
for ($i = 0; $i < count($rand); $i++) {
    $lunch->updateAdStats($lunch->adkeys[$rand[$i]], "1");
    $build .= "<div class=\"lunch-special\">\r";
    $build .= "<div class=\"display-image\">\r";
    $build .= "<a href=\"lunch_special_print.php?id=" . $lunch->adkeys[$rand[$i]] . "\">";
    $build .= "<img src=\"" . $lunch->adimages[$rand[$i]] . "\">";
    $build .= "</a>";
    $build .= "</div>\r";
    $build .= "<div class=\"display-text\">\r";
    $build .= "<h3>" . $lunch->adheading[$rand[$i]] . "</h3>";
    $build .= "<p>" . $lunch->adspecial[$rand[$i]] . "</p>";
    $build .= "<p><a href=\"lunch_special_print.php?id=" . $lunch->adkeys[$rand[$i]] . "\">Print Me</a></p>";
    $build .= "</div>\r";
    $build .= "</div>\r";
<?php

require "_globals.php";
require SECURITY;
require ADCHEATSHEET;
require CLASS_LUNCHSPECIAL;
$lunch = new handleLunchSpecial();
?>

<?php 
getHeader("admin");
?>

<h3>Lunch Specials</h3>
<p><b>Select the date that you would like to view</b></p>

<?php 
echo $lunch->listSpecials();
?>

<?php 
getFooter("admin");
<?php

$ads_to_display = 2;
require "_admin/_globals.php";
require CONFIG_ADS;
require AD_FILE;
require CLASS_LUNCHSPECIAL;
$lunch = new handleLunchSpecial();
$rand = $lunch->getAd($_GET["id"]);
?>

<?php 
include LUNCHHEADER;
?>


<?php 
$build .= "<div class=\"lunch-special\">\r";
$build .= "<div class=\"display-image\">\r";
$build .= "<img src=\"" . $lunch->adimages[$rand[$i]] . "\">";
$build .= "</div>\r";
$build .= "<div class=\"display-text\">\r";
$build .= "<h3>" . $lunch->adheading[$rand[$i]] . "</h3>";
$build .= "<p>" . $lunch->adspecial[$rand[$i]] . "</p>";
$build .= "</div>\r";
$build .= "</div>\r";
echo $build;
?>

<br style="display: block; clear: both; height: 1px;">