コード例 #1
0
 */
if (!defined("IN_REGIONALED_VIEW")) {
    exit;
} elseif (!isset($_SESSION["isAuthorized"]) || !$_SESSION["isAuthorized"]) {
    header("Location: " . ENTRADA_URL);
    exit;
} elseif (!$ENTRADA_ACL->amIAllowed("regionaled", "read")) {
    $ONLOAD[] = "setTimeout('window.location=\\'" . ENTRADA_URL . "/" . $MODULE . "\\'', 15000)";
    $ERROR++;
    $ERRORSTR[] = "Your account does not have the permissions required to use 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"] . "] do not have access to this module [" . $MODULE . "]");
} else {
    $BREADCRUMB[] = array("url" => "", "title" => "Accommodation Details");
    $max_occupants = (int) $APARTMENT_INFO["max_occupants"];
    $apt_occupants = regionaled_apartment_occupants($APARTMENT_INFO["apartment_id"], $APARTMENT_INFO["inhabiting_start"], $APARTMENT_INFO["inhabiting_finish"]);
    $num_occupants = is_array($apt_occupants) ? count($apt_occupants) : 0;
    $apartment_address = ($APARTMENT_INFO["apartment_number"] != "" ? html_encode($APARTMENT_INFO["apartment_number"]) . "-" : "") . html_encode($APARTMENT_INFO["apartment_address"]) . "<br />\n";
    $apartment_address .= html_encode($APARTMENT_INFO["region_name"]) . ($APARTMENT_INFO["province"] ? ", " . html_encode($APARTMENT_INFO["province"]) : "") . "<br />\n";
    $apartment_address .= html_encode($APARTMENT_INFO["apartment_postcode"]) . ", " . html_encode($APARTMENT_INFO["country"]);
    /**
     * Only allow the confirm / reject code to run if the accommodation is
     * not already confirmed.
     */
    if (!$APARTMENT_INFO["confirmed"]) {
        switch ($ACTION) {
            case "accept":
                if ($db->AutoExecute(CLERKSHIP_DATABASE . ".apartment_schedule", array("confirmed" => 1), "UPDATE", "`aschedule_id` = " . $db->qstr($ASCHEDULE_ID) . " AND `apartment_id` = " . $db->qstr($APARTMENT_INFO["apartment_id"]) . " AND `proxy_id` = " . $db->qstr($ENTRADA_USER->getID()))) {
                    $SUCCESS++;
                    $SUCCESSSTR[] = "You have successfully confirmed your accommodation in this apartment from " . date(DEFAULT_DATE_FORMAT, $APARTMENT_INFO["inhabiting_start"]) . " until " . date(DEFAULT_DATE_FORMAT, $APARTMENT_INFO["inhabiting_finish"]) . ".";
                    $APARTMENT_INFO["confirmed"] = 1;
コード例 #2
0
function regionaled_apartment_availability($apartment_ids = array(), $event_start = 0, $event_finish = 0)
{
    global $db;
    if (is_scalar($apartment_ids)) {
        if ((int) $apartment_ids) {
            $apartment_ids = array($apartment_ids);
        } else {
            $apartment_ids = array();
        }
    }
    $output = array();
    $output["openings"] = 0;
    $output["apartments"] = array();
    if (count($apartment_ids) && ($event_start = (int) $event_start) && ($event_finish = (int) $event_finish)) {
        $query = "\tSELECT a.*, b.`country`, c.`province`\n\t\t\t\t\tFROM `" . CLERKSHIP_DATABASE . "`.`apartments` AS a\n\t\t\t\t\tLEFT JOIN `global_lu_countries` AS b\n\t\t\t\t\tON b.`countries_id` = a.`countries_id`\n\t\t\t\t\tLEFT JOIN `global_lu_provinces` AS c\n\t\t\t\t\tON c.`province_id` = a.`province_id`\n\t\t\t\t\tWHERE a.`apartment_id` IN (" . implode(", ", $apartment_ids) . ")\n\t\t\t\t\tAND (a.`available_start` = '0' OR a.`available_start` <= " . $db->qstr($event_start) . ")\n\t\t\t\t\tAND (a.`available_finish` = '0' OR a.`available_finish` > " . $db->qstr($event_finish) . ")";
        $apartments = $db->GetAll($query);
        if ($apartments) {
            foreach ($apartments as $apartment) {
                $occupants = regionaled_apartment_occupants($apartment["apartment_id"], $event_start, $event_finish);
                $occupants_tmp = array();
                $occupancy_totals = array();
                $concurrent_occupants = 0;
                if ($occupants && is_array($occupants)) {
                    foreach ($occupants as $occupant) {
                        $concurrent_occupants = 1;
                        if (count($occupants_tmp)) {
                            foreach ($occupants_tmp as $tmp_occupant) {
                                if (($occupant["inhabiting_start"] >= $tmp_occupant["inhabiting_start"] || $occupant["inhabiting_finish"] >= $tmp_occupant["inhabiting_start"]) && $occupant["inhabiting_start"] <= $tmp_occupant["inhabiting_finish"]) {
                                    $concurrent_occupants++;
                                }
                            }
                        }
                        $occupants_tmp[] = $occupant;
                        $occupancy_totals[] = $concurrent_occupants;
                    }
                }
                if (count($occupancy_totals)) {
                    $concurrent_occupants = max($occupancy_totals);
                } else {
                    $concurrent_occupants = 0;
                }
                if ($concurrent_occupants < $apartment["max_occupants"]) {
                    $openings = $apartment["max_occupants"] - $concurrent_occupants;
                    $output["openings"] += $openings;
                    $output["apartments"][$apartment["apartment_id"]] = array("openings" => $openings, "occupants" => $occupants, "details" => $apartment);
                }
            }
        }
    }
    return $output;
}
コード例 #3
0
$date = time();
$months = array($date, $date + 2629743, $date + 2629743 * 2, $date + 2629743 * 3);
$msg_body = "";
$contact_id = 0;
/*
 *  fetch the apartments
 */
$query = "\tSELECT a.`apartment_id`, \n\t\t\t\t   a.`apartment_title`, \n\t\t\t\t\tCONCAT_WS(' ',a.super_firstname, a.super_lastname) AS `super_full`, \n\t\t\t\t\t`super_email`, \n\t\t\t\t\tCONCAT_WS(' ',a.keys_firstname,a.keys_lastname) AS `keys_full`, \n\t\t\t\t\ta.`keys_email`,\n\t\t\t\t\tb.`region_name`,\n\t\t\t\t\tc.`department_id`,\n\t\t\t\t\tc.`department_title`\n\t\t\t\tFROM `" . CLERKSHIP_DATABASE . "`.`apartments` a\n\t\t\t\tJOIN `" . CLERKSHIP_DATABASE . "`.`regions` AS b\n\t\t\t\tON a.`region_id` = b.`region_id`\n\t\t\t\tLEFT JOIN `" . AUTH_DATABASE . "`.`departments` as c\n\t\t\t\tON a.`department_id` = c.`department_id`\n\t\t\t\tWHERE a.`available_finish` >= " . $db->qstr(time()) . "\n\t\t\t\tOR a.`available_finish` = 0\n\t\t\t\tGROUP BY a.`apartment_id`\n\t\t\t\tORDER BY a.`region_id`, `keys_full`";
if ($apartments = $db->GetAll($query)) {
    foreach ($apartments as $apartment) {
        $msg_body = "";
        $current_contact = $apartment["super_full"] != $apartment["keys_full"] & !empty($apartment["keys_full"]) ? $apartment["keys_full"] : $apartment["super_full"];
        $current_email = $apartment["super_full"] != $apartment["keys_full"] & !empty($apartment["keys_full"]) ? $apartment["keys_email"] : $apartment["super_email"];
        $messages[$current_email]["name"] = $current_contact;
        $messages[$current_email]["region_name"] = $apartment["region_name"];
        if ($occupants = regionaled_apartment_occupants($apartment["apartment_id"], $months[0], $months[3])) {
            $msg_body .= "The following learners are scheduled to stay in <strong>" . $apartment["apartment_title"] . "</strong>.<br /><br />";
            $occupants_list = "<table width=\"100%\" cellpadding=\"0\" border=\"1\">\n";
            $occupants_list .= "\t\t<td width=\"40%\" valign=\"top\"><strong>Occupant Name</strong></td>\n";
            $occupants_list .= "\t\t<td width=\"30%\" valign=\"top\"><strong>Starting Date</strong></td>\n";
            $occupants_list .= "\t\t<td width=\"30%\" valign=\"top\"><strong>Ending Date</strong></td>\n";
            $occupants_list .= "\t</tr>\n";
            foreach ($occupants as $occupant) {
                if (!empty($occupant["occupant_title"])) {
                    $occupant_name = $occupant["occupant_title"];
                } else {
                    $occupant_name = $occupant["fullname"];
                }
                $occupants_list .= "\t<tr>\n";
                $occupants_list .= "\t\t<td>" . $occupant_name . "</td>\n";
                $occupants_list .= "\t\t<td>" . date("l, F j, Y", $occupant["inhabiting_start"]) . "</td>\n";
コード例 #4
0
    exit;
}
if ($EVENT_ID) {
    switch ($_SESSION["permissions"][$ENTRADA_USER->getAccessId()]["group"]) {
        case "student":
            /**
             * Add the accommodation issue sidebar item.
             */
            $sidebar_html = "<strong>Having issues?</strong> If you are having any problems with your accommodations that you would like to report please <a href=\"javascript:sendAccommodation('" . ENTRADA_URL . "/agent-accommodation.php')\" style=\"font-size: 11px; font-weight: bold\">click here</a>.\n";
            new_sidebar_item("Issue Reporting", $sidebar_html, "page-clerkship", "open");
            $query = "\tSELECT *\n\t\t\t\t\t\tFROM `" . CLERKSHIP_DATABASE . "`.`events` AS a\n\t\t\t\t\t\tLEFT JOIN `" . CLERKSHIP_DATABASE . "`.`event_contacts` AS b\n\t\t\t\t\t\tON b.`event_id` = a.`event_id`\n\t\t\t\t\t\tLEFT JOIN `" . CLERKSHIP_DATABASE . "`.`regions` AS c\n\t\t\t\t\t\tON c.`region_id` = a.`region_id`\n\t\t\t\t\t\tLEFT JOIN `" . CLERKSHIP_DATABASE . "`.`apartment_schedule` AS d\n\t\t\t\t\t\tON d.`event_id` = a.`event_id`\n\t\t\t\t\t\tLEFT JOIN `" . CLERKSHIP_DATABASE . "`.`apartments` AS e\n\t\t\t\t\t\tON e.`apartment_id` = d.`apartment_id`\n\t\t\t\t\t\tWHERE a.`event_id` = " . $db->qstr($EVENT_ID) . "\n\t\t\t\t\t\tAND a.`event_status` = 'published'\n\t\t\t\t\t\tAND b.`econtact_type` = 'student'\n\t\t\t\t\t\tAND b.`etype_id` = " . $db->qstr($ENTRADA_USER->getActiveId()) . "\n\t\t\t\t\t\tAND d.`proxy_id` = " . $db->qstr($ENTRADA_USER->getActiveId()) . "\n\t\t\t\t\t\tAND d.`aschedule_status` = 'published'";
            $result = $db->GetRow($query);
            if ($result) {
                $BREADCRUMB[] = array("url" => "", "title" => "Rotation Details");
                $max_occupants = (int) $result["max_occupants"];
                $apt_occupants = regionaled_apartment_occupants($result["apartment_id"], $result["event_start"], $result["event_finish"]);
                $num_occupants = is_array($apt_occupants) ? count($apt_occupants) : 0;
                /**
                 * Determine whether the Google map can be shown.
                 */
                if (defined("GOOGLE_MAPS_API") && GOOGLE_MAPS_API != "") {
                    $show_google_map = true;
                } else {
                    $show_google_map = false;
                }
                if ($show_google_map) {
                    $HEAD[] = "<script type=\"text/javascript\" src=\"" . GOOGLE_MAPS_API . "\"></script>";
                    $ONLOAD[] = "displayGoogleMap()";
                    ?>
					<script type="text/javascript">
					var map = null;
コード例 #5
0
} else {
    require_once "Entrada/calendar/calendar.class.php";
    $HEAD[] = "<script type=\"text/javascript\" src=\"" . ENTRADA_URL . "/javascript/calendar/script/xc2_timestamp.js\"></script>\n";
    $HEAD[] = "<link href=\"" . ENTRADA_RELATIVE . "/css/calendar.css?release=" . html_encode(APPLICATION_VERSION) . "\" rel=\"stylesheet\" type=\"text/css\" media=\"all\" />";
    /**
     * Check to see if user is requesting the calendar show a specific date.
     */
    if (isset($_GET["dstamp"]) && ($tmp_input = clean_input($_GET["dstamp"], array("nows", "int")))) {
        $timestamp = fetch_timestamps("month", $tmp_input);
    } else {
        $timestamp = fetch_timestamps("month", time());
    }
    $calendar = new Calendar();
    $calendar->setBaseUrl(ENTRADA_URL . "/admin/regionaled/apartments/manage");
    $calendar->setCharset(DEFAULT_CHARSET);
    $schedule = regionaled_apartment_occupants($APARTMENT_INFO["apartment_id"], $timestamp["start"], $timestamp["end"]);
    if ($schedule) {
        foreach ($schedule as $result) {
            $event = array();
            $event["timestamp_start"] = $result["inhabiting_start"];
            $event["timestamp_end"] = $result["inhabiting_finish"];
            switch ($result["occupant_type"]) {
                case "undergrad":
                    $event["calendar_id"] = 1;
                    break;
                case "postgrad":
                    $event["calendar_id"] = 2;
                    break;
                case "other":
                default:
                    $event["calendar_id"] = 0;