<?php

require "_admin/_globals.php";
require CLASS_MP_BUSINESS;
require CLASS_ADS;
$biz = new handleBusiness();
$ads = new handleAds();
$page = 1;
if ($_GET["page"] != "") {
    $page = $_GET["page"];
}
$list_biz = $biz->searchBusinesses($_GET["search"], $_GET["city"], $_GET["alpha"], $page);
$map_pointer = $list_biz["cords"];
$list_cats = $biz->listCats($_GET["search"], 1);
?>

<?php 
getHeader("public", "yes");
?>

<div class="content-full">
	<div id="link-column-container" class="white">
		<div id="link-column">
			<?php 
if ($list_cats["counter"] != "0") {
    echo $list_cats["display"];
}
if ($list_biz["cities"] != "") {
    echo $list_biz["cities"];
}
?>
<?php

require "_globals.php";
require SECURITY;
include CLASS_MP_BUSINESS;
include CLASS_ADS;
$biz = new handleBusiness();
$ads = new handleAds();
if (isset($_POST["submit"])) {
    $ads->adCreate();
    $rem_scpm[$_POST["scpm"]] = " selected";
    if ($_POST["ufn"] == 1) {
        $rem_ufn = " checked";
    }
    $ads->createAdSheet();
    header("location: " . $_SERVER["PHP_SELF"] . "?id=" . $_GET["id"] . "&adid=" . $ads->rec["id"] . "&m=1");
    exit;
} else {
    $rem_scpm[$ads->rec["cpm"]] = " selected";
    if ($ads->rec["ufn"] == 1) {
        $rem_ufn = " checked";
    }
    if ($ads->rec["reset_cpm"] == 1) {
        $rem_resest = " checked";
    }
}
if (isset($_GET["m"])) {
    $mess[1] = "1 Ad created/modified successfully.";
    $message = $mess[$_GET["m"]];
}
?>
<?php

require "_globals.php";
require SECURITY;
include CLASS_MP_BUSINESS;
include CLASS_ADS;
$biz = new handleBusiness();
$ads = new handleAds();
$ads->rec["marketplace_id"] = $biz->rec["record_id"];
if (isset($_POST["submit"])) {
    $ads->adCreate();
    $ads->createAdSheet();
    header("location: " . $_SERVER["PHP_SELF"] . "?id=" . $_GET["id"] . "&m=1");
    exit;
}
if (isset($_GET["m"])) {
    $mess[1] = "1 Ad created successfully.";
    $mess[2] = "1 Ad has been deleted.";
    $message = $mess[$_GET["m"]];
}
if ($_GET["delete"] == "yes") {
    $ads->deleteAd();
    header("location: " . $_SERVER["PHP_SELF"] . "?id=" . $_GET["id"] . "&m=2");
    exit;
}
?>

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

require "_admin/_globals.php";
require CLASS_ADS;
$ads = new handleAds();
?>

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

<div id="link-column-container">
	</div>
<div id="content-column-content">
	<div class="content-title">Gift Cards FAQ's</div>
	<div style="margin: 20px;"><?php 
echo loadTemplate("faq.giftcards.php");
?>
</div>
	</div>
<div id="side-column">
	<a href="coupons.php" class="small white"><img src="<?php 
echo IMAGEDIR;
?>
/view_all_coupons.jpg" border=0 style="margin-top:10px;"></a>
	<p class="medium white"><?php 
echo $ads->num_coupons;
?>
 total coupons!</p>
	<div class="coupon-box"><?php 
echo $ads->buildAd(200);
<?php

require "_admin/_globals.php";
require CLASS_ADS;
$ads = new handleAds();
$build = $ads->buildCoupons($_GET[category]);
if (is_array($build[1])) {
    $options = "<a href=\"" . $php_self . "?category=\" class=\"blue medium\">All Coupons</a> | ";
    foreach ($build[1] as $key => $value) {
        $options .= "<a href=\"" . $php_self . "?category=" . $key . "\" class=\"blue medium\">" . $key . " (" . $value . ")</a> | ";
    }
    $options = substr($options, 0, strlen($options) - 2);
}
?>

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

<div class="content-detail">
	
	<h5 class="gold extra-large" style="margin:0px;">Marketplace Coupons</h5>
	<h5 class="blue medium" style="margin:6px 2px;"><?php 
echo $options;
?>
</h5>
	<?php 
echo $build[0];
?>

	</div>