Beispiel #1
0
function create_date_time_schedule_data($date, $location = DEFAULT_LOCATION_NAME)
{
    //echo "<p>create_date_time_schedule_data function: $date</p>";
    // create the date time schedule data for the specified year and month.
    global $location_db_name;
    // Sanitize for MySQL
    $date = wrap_db_escape_string($date);
    // Check Valid Date
    if (!check_valid_date($date)) {
        $date = '1970-01-01';
    }
    list($year, $month, $day) = explode("-", $date);
    // query for the date time data for the 1st of the month, limit only 1
    $result = wrap_db_query("SELECT * FROM " . DATE_TIME_SCHEDULE_TABLE . " WHERE \r\n\t\t\t\t\t\t" . $location_db_name[$location] . " >= 0 AND \r\n\t\t\t\t\t\tschedule_date_time = '" . $year . "-" . $month . "-01 " . MIN_BOOKING_HOUR . ":00:00' \r\n\t\t\t\t\t\tLIMIT 0,1");
    if (!defined(BOOKING_TIME_INTERVAL)) {
        define(BOOKING_TIME_INTERVAL, 30);
    }
    // If there are no result(s) then we need to create the data for this month.
    if (!(wrap_db_num_rows($result) >= 1) || !$result) {
        // Define Valid Times (hh:mm format)
        $valid_times = get_times_in_range(sprintf("%02d", MIN_BOOKING_HOUR) . ':00', sprintf("%02d", MAX_BOOKING_HOUR) . ':00', BOOKING_TIME_INTERVAL, false);
        // Define Starting Weekday Value (0=Sunday, 1=Monday,...,6=Saturday)
        $dayoftheweekid = beginning_weekday_of_the_month($year, $month);
        for ($i = 1; $i <= 31; $i++) {
            // For Each Day in the Month.
            if (check_valid_date($year . '-' . $month . '-' . $i)) {
                //echo "Loop ID: $i<br />";
                if ($dayoftheweekid == 7) {
                    $dayoftheweekid = 0;
                }
                //echo "Day of the Week ID: $dayoftheweekid <br />";
                foreach ($valid_times as $valid_time) {
                    $result = wrap_db_query("INSERT INTO " . DATE_TIME_SCHEDULE_TABLE . " \r\n\t\t\t\t\t\tSET schedule_date_time = '" . $year . "-" . $month . "-" . sprintf("%02d", $i) . " " . $valid_time . "', day_of_the_week_id = " . $dayoftheweekid);
                }
                $dayoftheweekid++;
            }
            // end of if
        }
        // end of for loop
        // Order the table if modified.
        $result = wrap_db_query("ALTER TABLE " . DATE_TIME_SCHEDULE_TABLE . " ORDER BY schedule_date_time");
        // Optimize all of the main tables.
        $result = wrap_db_query("OPTIMIZE TABLE " . DATE_TIME_SCHEDULE_TABLE);
        $result = wrap_db_query("OPTIMIZE TABLE " . BOOKING_EVENT_TABLE);
        $result = wrap_db_query("OPTIMIZE TABLE " . BOOKING_USER_TABLE);
    }
    // end of if
    return true;
}
Beispiel #2
0
function xst_weekday_of_the_month($xst, $weekday, $year, $month)
{
    $days_in_month = number_of_days_in_month($year, $month);
    $beginning_weekday = beginning_weekday_of_the_month($year, $month);
    // Find 1st occurence of the specified weekday.
    $weekday_difference = $weekday - $beginning_weekday;
    // Add 7 if the weekday value is less than the starting weekday value.
    if ($weekday_difference < 0) {
        $weekday_difference += 7;
    }
    // Add the number of days, to the 1st, required to move to the specified day.
    $first_date = date('Y-m-d', mktime(1, 0, 0, $month, 1 + $weekday_difference, $year));
    // Add 7 for each week in the month (1=1st, 2=2nd, etc).
    $date = add_delta_ymd($first_date, 0, 0, ($xst - 1) * 7);
    // Split the date into its components.
    list($new_year, $new_month, $new_day) = explode("-", $date);
    // If the date is beyond the current month then set $date equal to nothing.
    if ($new_month != $month) {
        $date = '';
    }
    return $date;
}
Beispiel #3
0
<?php

// month_nav_widget.php
// Displays the Month Navigation
// Setup the weekday index array values
$wdays_ind = array();
$wdays_ind = weekday_index_array(WEEK_START);
$days_in_the_month = number_of_days_in_month(SELECTED_DATE_YEAR, SELECTED_DATE_MONTH);
$month_begin_wday = weekday_short_name(beginning_weekday_of_the_month(SELECTED_DATE_YEAR, SELECTED_DATE_MONTH));
?>


<!-- month_nav_widget.php -->
<table cellspacing="2" cellpadding="1" width="100%" border="0">
<!-- header -->
<tr>
<?php 
reset($wdays_ind);
foreach ($wdays_ind as $index) {
    ?>
  <td align="center" valign="middle" class="BgcolorBright"><b class="FontSoftSmall"><?php 
    echo weekday_short_name($index);
    ?>
</b></td>
<?php 
}
?>
</tr>
  <!-- rows -->
<?php 
$count = 0;