function PageContent()
{
    ?>
    
            <div class="layout center-flex">

                <?php 
    $aLabels = array();
    $aLinks = array();
    $aLabels[0] = 'Home';
    $aLinks[0] = 'mainpage.php';
    $aLabels[1] = 'Category List';
    $aLinks[1] = 'category_list.php';
    $aLabels[2] = 'iBeacon';
    $aLinks[2] = '';
    echo Helpers::CreateBreadCrumbs($aLabels, $aLinks);
    ?>

                <div class="bigbotspace flex-container space-between">
                    <p class="larger auto heading">iBeacon</p>
                    <!--
                    <a href="category_admin.php" class="button_link"><button class="">Add New Ibeacon</button></a>
                    -->
                </div>
            </div>
    
            <div class="layout">
    
                <table class="tablestyle" id="list_table">
                    <thead>
                        <tr>
                            <th>ID</th>
                            <th>Overview Text</th>
                            <th>Images</th>
                            <th class="mid">Actions</th>
                        </tr>
                    </thead>
                    <tbody>
                        <?php 
    $objIbeacon = new Ibeacon();
    $oIbeacon = $objIbeacon->GetAllIbeaconByCategoryId($_REQUEST['cat']);
    $objIbeaconImage = new IbeaconImage();
    foreach ($oIbeacon as $ibeacon) {
        echo '<tr id="img_' . $ibeacon->Id . '">' . PHP_EOL;
        echo '<td>' . $ibeacon->Id . '</td>' . PHP_EOL;
        echo '<td>' . substr($ibeacon->OverviewText, 0, 200) . '</td>' . PHP_EOL;
        echo '<td>(<a href="ibeaconimage_list.php?cat=' . $_REQUEST['cat'] . '&ibeacon=' . $ibeacon->Id . '">' . $objIbeaconImage->getCountIbeaconImageByIbeaconId($ibeacon->Id) . '</a>)</td>' . PHP_EOL;
        echo '<td class="mid"><a href="ibeacon_admin.php?cat=' . $_REQUEST['cat'] . '&id=' . $ibeacon->Id . '"><img src="img/edit-icon.png" /></a></td>' . PHP_EOL;
        echo '</tr>' . PHP_EOL;
    }
    ?>
                    </tbody>
                </table>
    
            </div> <!-- layout -->
    
<?php 
}
<?php

session_start();
if (!isset($_SESSION['sessCategory'])) {
    header('Location: index.php');
    exit;
}
include_once 'inc/classes/Ibeacon.php';
include_once 'inc/classes/IbeaconImage.php';
include_once 'inc/classes/Technology.php';
include_once 'inc/classes/Category.php';
$objIbeacon = new Ibeacon();
$oIbeacon = $objIbeacon->getAllIbeaconByCategoryId($_SESSION['sessCategory']);
$objTechnology = new Technology(2);
$objIbeaconImage = new IbeaconImage();
$oIbeaconImage = $objIbeaconImage->getAllIbeaconImageByIbeaconId($oIbeacon[0]->Id);
$objCategory = new Category($_SESSION['sessCategory']);
$bgcolor = "#F40000";
// Coke red default
if ($objCategory->BackgroundColor != "") {
    $bgcolor = $objCategory->BackgroundColor;
}
$background = $bgcolor . " none repeat scroll 0% 0%";
// this is used in single-product-template.php
?>
<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>Coke Cooler</title>
	<link rel="stylesheet" type="text/css" href="assets/css/bootstrap.min.css">
function PageContent()
{
    global $objIbeacon;
    ?>
    
        <link rel="stylesheet" href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/themes/smoothness/jquery-ui.css">
        <script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/jquery-ui.min.js"></script>
        <script type="text/javascript">
            $(document).ready(function() {
                // fix to preserve width of cells
                var fixHelper = function(e, ui) {
                    ui.children().each(function() {
                        $(this).width($(this).width());
                    });
                    return ui;
                };
                var saveIndex = function(e, ui) {
                    //alert("New position: " + ui.item.index());
                    //alert("Image Id: " + ui.item.attr("id"));
                    id = ui.item.attr("id").replace("img_", "");
                    $.ajax({
                        url: 'ibeaconimage_list.php',
                        data: {
                            dragsort: 1,
                            idx: ui.item.index(),
                            id: id
                        },
                        type: 'POST',
                        dataType: 'html',
                        success: function (data) {
                            //alert("done");
                        },
                        error: function (xhr, status) {
                            alert('Sorry, there was a problem!');
                        }
                    });
                }; // end saveIndex
    
                $("#list_table tbody").sortable({
                    helper: fixHelper,
                    stop: saveIndex
                }).disableSelection();
    
            }); // end document.ready
        </script>
        <style>
            .icon-resize-vertical:hover {
                cursor:grab;
            }
        </style>        
    
            <div class="layout center-flex">

                <?php 
    $aLabels = array();
    $aLinks = array();
    $aLabels[0] = 'Home';
    $aLinks[0] = 'mainpage.php';
    $aLabels[1] = 'Category List';
    $aLinks[1] = 'category_list.php';
    $aLabels[2] = 'Ibeacon';
    $aLinks[2] = 'ibeacon_list.php?cat=' . $_REQUEST['cat'];
    $aLabels[3] = 'Ibeacon Image List';
    $aList[3] = '';
    echo Helpers::CreateBreadCrumbs($aLabels, $aLinks);
    ?>

                <div class="bigbotspace flex-container space-between">
                    <p class="larger auto heading">Ibeacon Images</p>
                    <a href="ibeaconimage_admin.php?cat=<?php 
    echo $_REQUEST['cat'];
    ?>
&ibeacon=<?php 
    echo $objIbeacon->Id;
    ?>
" class="button_link"><button class="">Add New iBeacon Image</button></a>
                </div>
            </div>
    
            <div class="layout">
    
                <table class="tablestyle" id="list_table">
                    <thead>
                        <tr>
                            <th>ID</th>
                            <th>Image</th>
                            <th class="mid">Order</th>
                            <th class="mid">Actions</th>
                        </tr>
                    </thead>
                    <tbody>
                        <?php 
    $objIbeaconImage = new IbeaconImage();
    $oIbeaconImage = $objIbeaconImage->getAllIbeaconImageByIbeaconId($objIbeacon->Id);
    foreach ($oIbeaconImage as $ibeaconimage) {
        echo '<tr id="img_' . $ibeaconimage->Id . '">' . PHP_EOL;
        echo '<td>' . $ibeaconimage->Id . '</td>' . PHP_EOL;
        echo '<td><img src="/' . $objIbeaconImage->GetPath() . $ibeaconimage->ImageFile . '" style="max-width: 200px;" /></td>' . PHP_EOL;
        echo '<td class="mid"><img src="img/arrow-up-down.png" /></td>' . PHP_EOL;
        echo '<td class="mid"><a href="ibeaconimage_admin.php?cat=' . $_REQUEST['cat'] . '&ibeacon=' . $_REQUEST['ibeacon'] . '&id=' . $ibeaconimage->Id . '"><img src="img/edit-icon.png" /></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="ibeaconimage_delete.php?ibeacon=' . $_REQUEST['ibeacon'] . '&id=' . $ibeaconimage->Id . '"><img src="img/delete-icon.png" /></a></td>' . PHP_EOL;
        echo '</tr>' . PHP_EOL;
    }
    ?>
                    </tbody>
                </table>
    
            </div> <!-- layout -->
    
<?php 
}
$page_title = "";
$id = $_REQUEST['id'];
// id required
if ($id == "") {
    header("Location:mainpage.php");
    exit;
}
// if form was submitted
if ($_POST['commit'] == "Cancel") {
    $objIbeaconImage = new IbeaconImage($id);
    $objIbeacon = new Ibeacon($objIbeaconImage->IbeaconId);
    header("Location:ibeaconimage_list.php?cat=" . $_REQUEST['cat'] . "&ibeacon=" . $objIbeacon->Id);
    exit;
}
if ($_POST['commit'] == "Delete iBeacon Image") {
    $objIbeaconImage = new IbeaconImage($id);
    $objIbeacon = new Ibeacon($objIbeaconImage->IbeaconId);
    $objIbeaconImage->Delete($id);
    header("Location:ibeaconimage_list.php?cat=" . $_REQUEST['cat'] . "&ibeacon=" . $objIbeacon->Id);
    exit;
}
$objIbeaconImage = new IbeaconImage($id);
$objIbeacon = new Ibeacon($objIbeaconImage->IbeaconId);
include "includes/pagetemplate.php";
function PageContent()
{
    global $objIbeaconImage;
    global $objIbeacon;
    global $id;
    ?>
        header("Location:ibeaconimage_list.php?cat=" . $_REQUEST['cat'] . "&ibeacon=" . $_REQUEST['ibeacon']);
        exit;
    } else {
        // update
        $obj = new IbeaconImage($id);
        $obj->update();
        $obj->handleFileUploads();
        $obj->handleDropFileUploads($aDropFields[0], 'ImageFile');
        // redirect to listing list
        header("Location:ibeaconimage_list.php?cat=" . $_REQUEST['cat'] . "&ibeacon=" . $_REQUEST['ibeacon']);
        exit;
    }
} else {
    if ($_REQUEST['mode'] == 'e') {
        //listing
        $objIbeaconImage = new IbeaconImage($id);
        $ibeacon_id = $objIbeaconImage->IbeaconId;
        $image_file = $objIbeaconImage->ImageFile;
        $path = $objIbeaconImage->GetPath();
    } else {
        if ($_REQUEST['mode'] == 'a') {
            $ibeacon_id = $_REQUEST["ibeacon"];
        }
    }
}
include "includes/pagetemplate.php";
function PageContent()
{
    global $id;
    global $ibeacon_id;
    global $image_file;