* @copyright Copyright 2010 Queen's University. All Rights Reserved.
 *
*/
if (!defined("PARENT_INCLUDED") || !defined("IN_AWARDS")) {
    exit;
} elseif (!isset($_SESSION["isAuthorized"]) || !$_SESSION["isAuthorized"]) {
    header("Location: " . ENTRADA_URL);
    exit;
} elseif (!$ENTRADA_ACL->amIAllowed("awards", "update", false)) {
    add_error("Your account does not have the permissions required to use this feature of this module.<br /><br />If you believe you are receiving this message in error please contact <a href=\"mailto:" . html_encode($AGENT_CONTACTS["administrator"]["email"]) . "\">" . html_encode($AGENT_CONTACTS["administrator"]["name"]) . "</a> for assistance.");
    echo display_error();
    application_log("error", "Group [" . $_SESSION["permissions"][$ENTRADA_USER->getAccessId()]["group"] . "] and role [" . $_SESSION["permissions"][$ENTRADA_USER->getAccessId()]["role"] . "] does not have access to this module [" . $MODULE . "]");
} else {
    require_once "Models/awards/InternalAwards.class.php";
    require_once "Models/awards/InternalAwardReceipts.class.php";
    process_manage_award_details();
    $awards = InternalAwards::get(true);
    $PAGE_META["title"] = "Awards Listing";
    $PAGE_META["description"] = "";
    $PAGE_META["keywords"] = "";
    ?>
	<div id="award_messages">
		<?php 
    display_status_messages();
    ?>
	</div>
	<h1>Awards Listing</h1>
	
	<?php 
    $show_new_award_form = isset($_GET["show"]) && $_GET["show"] == "add_new_award" ? true : false;
    ?>
function process_awards_admin()
{
    if (isset($_POST['action'])) {
        $action = $_POST['action'];
        switch ($action) {
            case "add_award_recipient":
            case "remove_award_recipient":
            case "edit_award_details":
                $award_id = isset($_POST['award_id']) ? $_POST['award_id'] : 0;
                if ($award_id) {
                    $award = InternalAward::get($award_id);
                    process_manage_award_details();
                    display_status_messages();
                    echo award_recipients_list($award);
                }
                break;
            case "remove_award":
                $award_id = isset($_POST['award_id']) ? $_POST['award_id'] : 0;
                if (!$award_id) {
                    break;
                }
            case "new_award":
                process_manage_award_details();
                display_status_messages();
                $awards = InternalAwards::get(true);
                if ($awards) {
                    echo awards_list($awards);
                }
                break;
        }
    }
}