<?php

require "_globals.php";
require SECURITY;
include CLASS_MP_BUSINESS;
$biz = new handleBusiness();
if (isset($_POST["submit"])) {
    $biz->createNewCompany();
    foreach ($_POST["fields"] as $db_field => $db_value) {
        $biz->updateData($db_field, $db_value, $biz->rec["record_id"]);
    }
    $biz->updateData("latitude", $_POST["latitude"], $biz->rec["record_id"]);
    $biz->updateData("longitude", $_POST["longitude"], $biz->rec["record_id"]);
    $biz->updateData("search_terms", $_POST["search_terms"], $biz->rec["record_id"]);
    foreach ($_POST["day"] as $key => $value) {
        if ($value["closed"] == "on") {
            $build .= "CL|";
        } elseif ($value["by_appointment"] == "on") {
            $build .= "BA|";
        } else {
            $build .= $value["o_hour"] . ":" . $value["o_min"] . "-" . $value["c_hour"] . ":" . $value["c_min"] . "|";
        }
    }
    $business_hours = rtrim($build, "|");
    $biz->updateData("business_hours", $business_hours, $biz->rec["record_id"]);
    if (trim($_POST["new_sd_cat"]) != "") {
        $biz->addServiceDirectoryCat();
    }
    $biz->__construct();
    header("location: company_edit.php?id=" . $biz->id . "&m=2");
    exit;
<?php

require "_globals.php";
require SECURITY;
include CLASS_MP_BUSINESS;
$biz = new handleBusiness();
if (isset($_POST["submit"])) {
    foreach ($_POST["fields"] as $db_field => $db_value) {
        $biz->updateData($db_field, $db_value, $_POST["id"]);
    }
    $biz->updateData("profile_text", $_POST["profile_text"], $_POST["id"]);
    $message = "1 This listing has been updated.";
    $biz->__construct();
}
$profile_flag_option[$biz->rec["profile_flag"]] = " checked";
?>

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

<script type="text/javascript" src="<?php 
echo PATHTOHTML . PATHTOADMIN;
?>
/ckeditor/ckeditor.js"></script>

<h3>Edit Company Profile</h3>

<?php 
echo $biz->buildCard();
?>
<?php

require "_globals.php";
require SECURITY;
include CLASS_MP_BUSINESS;
$biz = new handleBusiness();
if (isset($_POST["submit"])) {
    if ($_POST["category_select"] == "") {
        $message = "2 Please select a category.  Categories were not updated.";
    } else {
        if (true === $biz->updateData($_POST["category_number"], $_POST["category_select"], $_GET["id"])) {
            $message = "1 Category has been updated successfully.  You should see the update reflected below.";
        } else {
            $message = "2 There was an error updating this category.";
        }
        $biz->__construct();
    }
}
if (isset($_GET["remove"])) {
    $message = "2 There was an error removing this category.  Categories were not updated.";
    if (true === $biz->updateData($_GET["remove"], "", $_GET["id"])) {
        $message = "1 Category has been removed.  You should see the update reflected below.";
    }
    $biz->__construct();
}
?>

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

require "_globals.php";
require SECURITY;
include CLASS_MP_BUSINESS;
$biz = new handleBusiness();
if (isset($_POST["submit"])) {
    foreach ($_POST["fields"] as $db_field => $db_value) {
        $biz->updateData($db_field, $db_value, $_POST["id"]);
    }
    $biz->saveMedia();
    $biz->saveIcons();
    $message = "1 This listing has been updated.";
    $biz->__construct();
}
if (isset($_GET["remove"])) {
    $biz->removeMedia($_GET["remove"]);
}
$business_hours_flag_option[$biz->rec["business_hours_flag"]] = " checked";
$bold_flag_option[$biz->rec["bold_flag"]] = " checked";
$highlight_flag_option[$biz->rec["highlight_flag"]] = " checked";
$sponsor_flag_option[$biz->rec["sponsor_flag"]] = " checked";
$profile_flag_option[$biz->rec["profile_flag"]] = " checked";
$product_flag_option[$biz->rec["product_flag"]] = " checked";
$gallery_flag_option[$biz->rec["gallery_flag"]] = " checked";
$video_flag_option[$biz->rec["video_flag"]] = " checked";
?>

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

require "_globals.php";
require SECURITY;
include CLASS_MP_BUSINESS;
$biz = new handleBusiness();
if (isset($_GET["submit"])) {
    if ($_GET["category_select"] == "") {
        $message = "2 Please select a category.  Categories were not updated.";
    } else {
        if (true === $biz->updateData($_GET["category_number"], $_GET["category_select"], $_GET["id"])) {
            $message = "1 Category has been updated successfully.  You should see the update reflected below.";
        } else {
            $message = "2 There was an error updating this category.";
        }
        $biz->__construct();
    }
}
?>

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

<h3>Update Company Categories</h3>

<?php 
echo $biz->buildCard();
?>

<?php