}
 if ($period == "daily" && !isset($offset)) {
     $output["status"] = "error";
     add_error("Please ensure you enter a number of days which this event should repeat after.");
     $output["message"] = display_error();
 } elseif ($period == "weekly" && !@count($weekdays)) {
     $output["status"] = "error";
     add_error("Please ensure you select at least one day of the week which this event should repeat on.");
     $output["message"] = display_error();
 }
 if (!isset($output["status"]) || $output["status"] != "error") {
     if (isset($period) && $period) {
         $dates = events_process_recurring_eventtimes($period, $event_start, isset($offset) && $offset ? $offset : (isset($week_offset) && $week_offset ? $week_offset : "1"), $weekdays, $recurring_end);
         $output["events"] = array();
         if (@count($dates)) {
             $restricted_days = Models_RestrictedDays::fetchAll($ENTRADA_USER->getActiveOrganisation());
             foreach ($dates as $date) {
                 $restricted = false;
                 if ($restricted_days && @count($restricted_days)) {
                     $date_string = date("Y-m-d", $date);
                     foreach ($restricted_days as $restricted_day) {
                         $restricted_string = date("Y-m-d", $restricted_day->getCalculatedDate(date("Y", $date), date("n", $date), $date));
                         if ($restricted_string == $date_string) {
                             $restricted = true;
                             break;
                         }
                     }
                 }
                 $output["events"][] = array("date" => (isset($output["dates"]) && $output["dates"] ? "\n" : "") . date("Y-m-d", $date), "restricted" => $restricted);
             }
             $output["status"] = "success";
Example #2
0
                 } else {
                     add_error("An error occurred when attempting to update a restricted day [" . $PROCESSED["orday_id"] . "], an administrator has been informed, please try again later.");
                     application_log("error", "Error occurred when updating restricted day, DB said: " . $db->ErrorMsg());
                 }
             } else {
                 $PROCESSED["organisation_id"] = $ORGANISATION_ID;
                 if ($day->fromArray($PROCESSED)->insert()) {
                     add_success("The restricted day has successfully been updated. You will be redirected to the restricted days index in 5 seconds, or you can <a href=\"" . ENTRADA_URL . "/admin/settings/manage/restricteddays?org=" . $ORGANISATION_ID . "\">click here</a> if you do not wish to wait.");
                     add_statistic("restricted_day", "insert", "orday_id", $db->Insert_ID(), $ENTRADA_USER->getID());
                 } else {
                     add_error("An error occurred when attempting to create a new restricted day, an administrator has been informed, please try again later.");
                     application_log("error", "Error occurred when updating a restricted day, DB said: " . $db->ErrorMsg());
                 }
             }
         } else {
             $day = new Models_RestrictedDays();
             $day->fromArray($PROCESSED);
             $STEP = 1;
         }
         break;
     default:
         break;
 }
 switch ($STEP) {
     case 2:
         if ($ERROR) {
             echo display_error();
             $ONLOAD[] = "setTimeout('window.location=\\'" . ENTRADA_URL . "/admin/settings/manage/restricteddays?org=" . $ORGANISATION_ID . "\\'', 5000)";
         }
         if ($SUCCESS) {
             echo display_success();
Example #3
0
    ?>
	<h1>Manage Restricted Days</h1>

	<div class="clearfix space-below">
		<div class="pull-right">
			<a href="<?php 
    echo ENTRADA_URL;
    ?>
/admin/settings/manage/restricteddays?section=add&amp;org=<?php 
    echo $ORGANISATION_ID;
    ?>
" class="btn btn-primary">Add New Restricted Days</a>
		</div>
	</div>
	<?php 
    $restricted_days = Models_RestrictedDays::fetchAll($ORGANISATION_ID);
    if ($restricted_days) {
        ?>
	<form action ="<?php 
        echo ENTRADA_URL;
        ?>
/admin/settings/manage/restricteddays?section=delete&amp;org=<?php 
        echo $ORGANISATION_ID;
        ?>
" method="post">
	<table class="tableList" cellspacing="0" cellpadding="1" border="0" summary="List of Restricted Days">
		<colgroup>
			<col class="modified" />
			<col class="title" />
		</colgroup>
		<thead>
Example #4
0
    header("Location: " . ENTRADA_URL);
    exit;
} elseif (!$ENTRADA_ACL->amIAllowed('configuration', 'delete', false)) {
    $ONLOAD[] = "setTimeout('window.location=\\'" . ENTRADA_URL . "/admin/" . $MODULE . "\\'', 15000)";
    $ERROR++;
    $ERRORSTR[] = "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 {
    $BREADCRUMB[] = array("url" => ENTRADA_URL . "/admin/settings/manage/restricteddays?org=" . $ORGANISATION_ID . "&section=delete", "title" => "Delete Restricted Days");
    echo "<h1>Delete Restricted Days</h1>";
    if (isset($_POST["remove_ids"])) {
        foreach ($_POST["remove_ids"] as $day_id) {
            if ($tmp_input = clean_input($day_id, "numeric")) {
                $PROCESSED["delete"][] = $tmp_input;
                $days[] = Models_RestrictedDays::fetchRow($tmp_input);
            }
        }
    }
    switch ($STEP) {
        case 2:
            foreach ($days as $day) {
                $day_data = $day->toArray();
                $day_data["day_active"] = 0;
                if ($day->fromArray($day_data)->update()) {
                    add_statistic("restricted_days", "delete", "orday_id", $day->getID(), $ENTRADA_USER->getID());
                    if (!$ERROR) {
                        add_success("Successfully deleted the restricted day '<strong>" . $day->getName() . "</strong>'. You will now be redirected to the restricted days index; this will happen <strong>automatically</strong> in 5 seconds or <a href=\"" . ENTRADA_URL . "/admin/settings/manage/restricteddays?org=" . $ORGANISATION_ID . "\"><strong>click here</strong></a> to continue.");
                    }
                } else {
                    add_error("Failed to delete the restricted day '<strong>" . $day->getName() . "</strong>', an Administrator has been informed, please try again later. You will now be redirected to the restricted days index; this will happen <strong>automatically</strong> in 5 seconds or <a href=\"" . ENTRADA_URL . "/admin/settings/manage/restricteddays?org=" . $ORGANISATION_ID . "\"><strong>click here</strong></a> to continue.");
    } elseif (isset($_POST["event_start"]) && (int) $_POST["event_start"]) {
        $event_start = $_POST["event_start"];
        $date_string = date("Y-m-d", $event_start);
    }
    if (isset($_GET["date_string"]) && (int) strtotime($_GET["date_string"])) {
        $date_string = $_GET["date_string"];
        $event_start = strtotime($date_string);
    } elseif (isset($_POST["date_string"]) && (int) strtottime($_POST["date_string"])) {
        $date_string = $_POST["date_string"];
        $event_start = strtotime($date_string);
    }
    if (isset($_GET["organisation_id"]) && (int) $_GET["organisation_id"]) {
        $organisation_id = $_GET["organisation_id"];
    } elseif (isset($_POST["organisation_id"]) && (int) $_POST["organisation_id"]) {
        $organisation_id = $_POST["organisation_id"];
    }
    if ($event_start && $date_string && $organisation_id) {
        $restricted_days = Models_RestrictedDays::fetchAll($organisation_id);
        foreach ($restricted_days as $restricted_day) {
            $restricted_string = date("Y-m-d", $restricted_day->getCalculatedDate(date("Y", $event_start), date("n", $event_start), $event_start));
            if ($restricted_string == $date_string) {
                echo "Found";
                break;
            }
        }
        if ($restricted_string != $date_string) {
            echo "Not Found";
        }
    }
    exit;
}