?> <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&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&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>
} 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";
} 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; }