Esempio n. 1
0
function describe_span($starts, $ends)
{
    global $lang;
    $start_date = strftime('%A %d %B %Y', $starts);
    $start_time = strftime("%T", $starts);
    $duration = $ends - $starts;
    if ($start_time == "00:00:00" && $duration == 60 * 60 * 24) {
        return $start_date . " - " . $lang["all_day"];
    }
    toTimeString($duration, $dur_units);
    return $start_date . " " . $start_time . " - " . $duration . " " . $dur_units;
}
Esempio n. 2
0
function describe_span($starts, $ends)
{
    global $twentyfourhour_format;
    $start_date = utf8_strftime('%A %d %B %Y', $starts);
    $start_time = utf8_strftime(hours_minutes_seconds_format(), $starts);
    $duration = $ends - $starts;
    if ($start_time == "00:00:00" && $duration == 60 * 60 * 24) {
        return $start_date . " - " . get_vocab("all_day");
    }
    toTimeString($duration, $dur_units);
    return $start_date . " " . $start_time . " - " . $duration . " " . $dur_units;
}
Esempio n. 3
0
function describe_span($starts, $ends)
{
    global $twentyfourhour_format;
    $start_date = userdate($starts, '%A %d %B %Y');
    $start_time = userdate($starts, hours_minutes_seconds_format());
    $duration = $ends - $starts;
    if ($start_time == "00:00:00" && $duration == 60 * 60 * 24) {
        return $start_date . " - " . get_string('all_day', 'block_mrbs');
    }
    toTimeString($duration, $dur_units);
    return $start_date . " " . $start_time . " - " . $duration . " " . $dur_units;
}
Esempio n. 4
0
function describe_span($starts, $ends)
{
    global $twentyfourhour_format;
    $start_date = utf8_strftime('%A %d %B %Y', $starts);
    if ($twentyfourhour_format) {
        $timeformat = "%H:%M:%S";
    } else {
        # This bit's necessary, because it seems %p in strftime format
        # strings doesn't work
        $ampm = utf8_date("a", $starts);
        $timeformat = "%I:%M:%S{$ampm}";
    }
    $start_time = utf8_strftime($timeformat, $starts);
    $duration = $ends - $starts;
    if ($start_time == "00:00:00" && $duration == 60 * 60 * 24) {
        return $start_date . " - " . get_vocab("all_day");
    }
    toTimeString($duration, $dur_units);
    return $start_date . " " . $start_time . " - " . $duration . " " . $dur_units;
}
Esempio n. 5
0
function describe_span($starts, $ends, $dformat)
{
    global $vocab, $twentyfourhour_format;
    $start_date = utf8_strftime($dformat, $starts);
    if ($twentyfourhour_format) {
        $timeformat = "%T";
    } else {
        $ampm = date("a", $starts);
        $timeformat = "%I:%M{$ampm}";
    }
    $start_time = strftime($timeformat, $starts);
    $duration = $ends - $starts;
    if ($start_time == "00:00:00" && $duration == 60 * 60 * 24) {
        return $start_date . " - " . get_vocab("all_day");
    }
    toTimeString($duration, $dur_units);
    return $start_date . " " . $start_time . " - " . $duration . " " . $dur_units;
}
Esempio n. 6
0
    echo '<h2>' . get_vocab('booking_in_past') . '</h2>';
    if ($rep_type != 0 && !empty($reps)) {
        echo '<p>' . get_vocab('booking_in_past_explain_with_periodicity') . $str_date . '</p>';
    } else {
        echo '<p>' . get_vocab('booking_in_past_explain') . $str_date . '</p>';
    }
    echo '<a href="' . $back . '&amp;Err=yes">' . get_vocab('returnprev') . '</a>';
    include 'include/trailer.inc.php';
    die;
}
if ($error_duree_max_resa_area == 'yes') {
    $area_id = grr_sql_query1('SELECT area_id FROM ' . TABLE_PREFIX . "_room WHERE id='" . protect_data_sql($room_id) . "'");
    $duree_max_resa_area = grr_sql_query1('SELECT duree_max_resa_area FROM ' . TABLE_PREFIX . "_area WHERE id='" . $area_id . "'");
    print_header();
    $temps_format = $duree_max_resa_area * 60;
    toTimeString($temps_format, $dur_units, true);
    echo '<h2>' . get_vocab('error_duree_max_resa_area') . $temps_format . ' ' . $dur_units . '</h2>';
    echo '<a href="' . $back . '&amp;Err=yes">' . get_vocab('returnprev') . '</a>';
    include 'include/trailer.inc.php';
    die;
}
if ($error_delais_max_resa_room == 'yes') {
    print_header();
    echo '<h2>' . get_vocab('error_delais_max_resa_room') . '</h2>';
    echo '<a href="' . $back . '&amp;Err=yes">' . get_vocab('returnprev') . '</a>';
    include 'include/trailer.inc.php';
    die;
}
if ($error_chevaussement == 'yes') {
    print_header();
    echo '<h2>' . get_vocab('error_chevaussement') . '</h2>';
Esempio n. 7
0
                        } else {
                            echo '<tr><td class="E"><b>'.get_vocab('rep_rep_days').'</b> '.$opt.'</td></tr>'."\n";
                        }*/
        } else {
            $tplArrayEditEntry['pasPeriode']['opt'] = false;
        }
        if ($enable_periods == 'y') {
            list($start_period, $start_date) = period_date_string($start_time);
        } else {
            $start_date = time_date_string($start_time, $dformat);
        }
        $duration = $end_time - $start_time;
        if ($enable_periods == 'y') {
            toPeriodString($start_period, $duration, $dur_units);
        } else {
            toTimeString($duration, $dur_units, true);
        }
        $tplArrayEditEntry['pasPeriode']['startDate'] = $start_date;
        $tplArrayEditEntry['pasPeriode']['duration'] = $duration;
        $tplArrayEditEntry['pasPeriode']['durUnits'] = $dur_units;
        $tplArrayEditEntry['pasPeriode']['repEndDate'] = $rep_end_date;
        /*echo '<tr><td class="E"><b>'.get_vocab('date').get_vocab('deux_points').'</b> '.$start_date.'</td></tr>'."\n";
          echo '<tr><td class="E"><b>'.get_vocab('duration').'</b> '.$duration.' '.$dur_units.'</td></tr>'."\n";
          echo '<tr><td class="E"><b>'.get_vocab('rep_end_date').'</b> '.$rep_end_date.'</td></tr>'."\n";*/
    }
}
/*    echo '</table>',PHP_EOL;
    echo '</td>',PHP_EOL,'</tr>',PHP_EOL,'</table>',PHP_EOL;*/
$tplArrayEditEntry['vocab']['cancel'] = get_vocab('cancel');
$tplArrayEditEntry['vocab']['save'] = get_vocab('save');
$tplArrayEditEntry['vocab']['cancel'] = get_vocab('cancel');
Esempio n. 8
0
    }
}
// Get the details of all the enabled areas
$areas = array();
$sql = "SELECT id, area_name, resolution, default_duration, default_duration_all_day,\n               enable_periods, timezone,\n               morningstarts, morningstarts_minutes, eveningends , eveningends_minutes,\n               max_duration_enabled, max_duration_secs, max_duration_periods\n          FROM {$tbl_area}\n         WHERE disabled=0\n      ORDER BY area_name";
$res = sql_query($sql);
if ($res) {
    for ($i = 0; $row = sql_row_keyed($res, $i); $i++) {
        // Make sure we've got the correct resolution when using periods (it's
        // probably OK anyway, but just in case)
        if ($row['enable_periods']) {
            $row['resolution'] = 60;
        }
        // Generate some derived settings
        $row['max_duration_qty'] = $row['max_duration_secs'];
        toTimeString($row['max_duration_qty'], $row['max_duration_units']);
        // Get the start and end of the booking day
        if ($row['enable_periods']) {
            $first = 12 * SECONDS_PER_HOUR;
            // If we're using periods we just go to the end of the last slot
            $last = $first + count($periods) * $row['resolution'];
        } else {
            $first = ($row['morningstarts'] * 60 + $row['morningstarts_minutes']) * 60;
            $last = ($row['eveningends'] * 60 + $row['eveningends_minutes']) * 60 + $row['resolution'];
            // If the end of the day is the same as or before the start time, then it's really on the next day
            if ($first >= $last) {
                $last += SECONDS_PER_DAY;
            }
        }
        $row['first'] = $first;
        $row['last'] = $last;
$starttime = round_t_down($starttime, $resolution, $am7);
$endtime = round_t_up($endtime, $resolution, $am7);
// If they asked for 0 minutes, and even after the rounding the slot length is still
// 0 minutes, push that up to 1 resolution unit.
if ($endtime == $starttime) {
    $endtime += $resolution;
}
// Now get the duration, which will be needed for email notifications
// (We do this before we adjust for DST so that the user sees what they expect to see)
$duration = $endtime - $starttime;
$date = getdate($starttime);
if ($enable_periods) {
    $period = ($date['hours'] - 12) * 60 + $date['minutes'];
    toPeriodString($period, $duration, $dur_units, FALSE);
} else {
    toTimeString($duration, $dur_units, FALSE);
}
// Adjust the endtime for DST
$endtime += cross_dst($starttime, $endtime);
if (isset($rep_type) && $rep_type != REP_NONE && isset($rep_end_month) && isset($rep_end_day) && isset($rep_end_year)) {
    // Get the repeat entry settings
    $end_date = $start_seconds + mktime(0, 0, 0, $rep_end_month, $rep_end_day, $rep_end_year);
} else {
    $rep_type = REP_NONE;
    $end_date = 0;
    // to avoid an undefined variable notice
}
if (!isset($rep_day)) {
    $rep_day = array();
}
$rep_opt = "";
Esempio n. 10
0
function describe_span($starts, $ends, $dformat)
{
    global $vocab, $twentyfourhour_format;
    $start_date = utf8_strftime($dformat, $starts);
    if ($twentyfourhour_format) {
        $timeformat = '%T';
    } else {
        $ampm = date('a', $starts);
        $timeformat = "%I:%M{$ampm}";
    }
    $start_time = strftime($timeformat, $starts);
    $duration = $ends - $starts;
    if ($start_time == '00:00:00' && $duration == 60 * 60 * 24) {
        return $start_date . ' - ' . get_vocab('all_day');
    }
    toTimeString($duration, $dur_units);
    return $start_date . ' ' . $start_time . ' - ' . $duration . ' ' . $dur_units;
}
Esempio n. 11
0
function create_field_entry_max_duration()
{
    global $max_duration_enabled, $max_duration_secs, $max_duration_periods;
    // The max duration policies
    echo "<fieldset>\n";
    echo "<legend>" . get_vocab("booking_durations") . "</legend>\n";
    echo "<div>\n";
    $params = array('label' => get_vocab("max_duration") . ":", 'name' => 'area_max_duration_enabled', 'value' => $max_duration_enabled, 'class' => 'enabler');
    generate_checkbox($params);
    echo "</div>\n";
    echo "<div>\n";
    $attributes = array('class="text"', 'type="number"', 'min="0"', 'step="1"');
    $params = array('name' => 'area_max_duration_periods', 'label' => get_vocab("mode_periods") . ':', 'value' => $max_duration_periods, 'attributes' => $attributes);
    generate_input($params);
    echo "</div>\n";
    echo "<div>\n";
    $max_duration_value = $max_duration_secs;
    toTimeString($max_duration_value, $max_duration_units);
    $attributes = array('class="text"', 'type="number"', 'min="0"', 'step="1"');
    $params = array('name' => 'area_max_duration_value', 'label' => get_vocab("mode_times") . ':', 'value' => $max_duration_value, 'attributes' => $attributes);
    generate_input($params);
    $units = array("seconds", "minutes", "hours", "days", "weeks");
    $options = array();
    foreach ($units as $unit) {
        $options[$unit] = get_vocab($unit);
    }
    $params = array('name' => 'area_max_duration_units', 'value' => array_search($max_duration_units, $options), 'options' => $options);
    generate_select($params);
    echo "</div>\n";
    echo "</fieldset>\n";
}
Esempio n. 12
0
     $rep_opt = isset($row['rep_opt']) ? $row['rep_opt'] : NULL;
     $rep_num_weeks = isset($row['rep_num_weeks']) ? $row['rep_num_weeks'] : NULL;
     if ($enable_periods) {
         list($start_period, $start_date) = period_date_string($row['start_time']);
     } else {
         $start_date = time_date_string($row['start_time']);
     }
     if ($enable_periods) {
         list(, $end_date) = period_date_string($row['end_time'], -1);
     } else {
         $end_date = time_date_string($row['end_time']);
     }
     // The optional last parameters below are set to FALSE because we don't want the units
     // translated - otherwise they will end up getting translated twice, resulting
     // in an undefined index error.
     $enable_periods ? toPeriodString($start_period, $duration, $dur_units, FALSE) : toTimeString($duration, $dur_units, FALSE);
 }
 // Now that we know the room, check that we have confirm rights for it if necessary
 if (($action == "accept" || $action == "reject") && !auth_book_admin($user, $room_id)) {
     showAccessDenied($day, $month, $year, $area, isset($room) ? $room : "");
     exit;
 }
 // ACTION = "ACCEPT"
 if ($action == "accept") {
     if (!mrbsConfirmEntry($id, $series)) {
         $returl .= "&error=accept_failed";
     } elseif ($need_to_send_mail) {
         $result = notifyAdminOnBooking(TRUE, $id, $series, $action);
     }
 }
 // ACTION = "MORE_INFO"
Esempio n. 13
0
/**
 * Gather all fields values for an entry. Used for emails to get previous
 * entry state.
 *
 * @param int     $id       entry id to get data
 * @param int     $series   1 if this is a serie or 0
 * @return bool             TRUE or PEAR error object if fails
 */
function getPreviousEntryData($id, $series)
{
    global $tbl_area, $tbl_entry, $tbl_repeat, $tbl_room, $enable_periods;
    //
    $sql = "\n    SELECT  e.name,\n            e.description,\n            e.create_by,\n            r.room_name,\n            a.area_name,\n            e.type,\n            e.room_id,\n            e.repeat_id,\n            e.timestamp,\n            (e.end_time - e.start_time) AS tbl_e_duration,\n            e.start_time AS tbl_e_start_time,\n            e.end_time AS tbl_e_end_time,\n            a.area_admin_email,\n            r.room_admin_email";
    // Here we could just use $tbl_repeat.start_time, and not use alias,
    // as the last column will take precedence using mysql_fetch_array,
    // but for portability purpose I will not use it.
    if (1 == $series) {
        $sql .= ", re.rep_type, re.rep_opt, re.rep_num_weeks,\n            (re.end_time - re.start_time) AS tbl_r_duration,\n            re.start_time AS tbl_r_start_time,\n            re.end_time AS tbl_r_end_time,\n            re.end_date AS tbl_r_end_date";
    }
    $sql .= "\n    FROM {$tbl_entry} e, {$tbl_room} r, {$tbl_area} a ";
    1 == $series ? $sql .= ', ' . $tbl_repeat . ' re ' : '';
    $sql .= "\n    WHERE e.room_id = r.id\n    AND r.area_id = a.id\n    AND e.id={$id}";
    1 == $series ? $sql .= " AND e.repeat_id = re.id" : '';
    //
    $res = sql_query($sql);
    !$res ? fatal_error(0, sql_error()) : '';
    sql_count($res) < 1 ? fatal_error(0, get_string('invalid_entry_id', 'block_mrbs')) : '';
    $row = sql_row_keyed($res, 0);
    sql_free($res);
    // Store all needed values in $mail_previous array to pass to
    // notifyAdminOnDelete function (shorter than individual variables -:) )
    $mail_previous['namebooker'] = $row['name'];
    $mail_previous['description'] = $row['description'];
    $mail_previous['createdby'] = $row['create_by'];
    $mail_previous['room_name'] = $row['room_name'];
    $mail_previous['area_name'] = $row['area_name'];
    $mail_previous['type'] = $row['type'];
    $mail_previous['room_id'] = $row['room_id'];
    $mail_previous['repeat_id'] = $row['repeat_id'];
    $mail_previous['updated'] = getMailTimeDateString($row[8]);
    $mail_previous['area_admin_email'] = $row['area_admin_email'];
    $mail_previous['room_admin_email'] = $row['room_admin_email'];
    // If we use periods
    if ($enable_periods) {
        // If we delete a serie, start_time and end_time must
        // come from $tbl_repeat, not $tbl_entry.
        //
        // This is not a serie
        if (1 != $series) {
            list($mail_previous['start_period'], $mail_previous['start_date']) = getMailPeriodDateString($row['tbl_e_start_time']);
            list($mail_previous['end_period'], $mail_previous['end_date']) = getMailPeriodDateString($row['tbl_e_end_time'], -1);
            // need to make DST correct in opposite direction to entry creation
            // so that user see what he expects to see
            $mail_previous['duration'] = $row['tbl_e_duration'] - cross_dst($row['tbl_e_start_time'], $row['tbl_e_end_time']);
        } else {
            list($mail_previous['start_period'], $mail_previous['start_date']) = getMailPeriodDateString($row['tbl_r_start_time']);
            list($mail_previous['end_period'], $mail_previous['end_date']) = getMailPeriodDateString($row['tbl_r_end_time'], 0);
            // use getMailTimeDateString as all I want is the date
            $mail_previous['rep_end_date'] = getMailTimeDateString($row['tbl_r_end_date'], FALSE);
            // need to make DST correct in opposite direction to entry creation
            // so that user see what he expects to see
            $mail_previous['duration'] = $row['tbl_r_duration'] - cross_dst($row['tbl_r_start_time'], $row['tbl_r_end_time']);
            $mail_previous['rep_opt'] = "";
            switch ($row['rep_type']) {
                case 2:
                case 6:
                    $rep_day[0] = $row['rep_opt'][0] != "0";
                    $rep_day[1] = $row['rep_opt'][1] != "0";
                    $rep_day[2] = $row['rep_opt'][2] != "0";
                    $rep_day[3] = $row['rep_opt'][3] != "0";
                    $rep_day[4] = $row['rep_opt'][4] != "0";
                    $rep_day[5] = $row['rep_opt'][5] != "0";
                    $rep_day[6] = $row['rep_opt'][6] != "0";
                    if ($row['rep_type'] == 6) {
                        $mail_previous['rep_num_weeks'] = $row['rep_num_weeks'];
                    } else {
                        $mail_previous['rep_num_weeks'] = "";
                    }
                    break;
                default:
                    $rep_day = array(0, 0, 0, 0, 0, 0, 0);
            }
            for ($i = 0; $i < 7; $i++) {
                $wday = ($i + $weekstarts) % 7;
                if ($rep_day[$wday]) {
                    $mail_previous['rep_opt'] .= day_name($wday) . " ";
                }
            }
            $mail_previous['rep_num_weeks'] = $row['rep_num_weeks'];
        }
        toPeriodString($mail_previous['start_period'], $mail_previous['duration'], $mail_previous['dur_units']);
    } else {
        // This is not a serie
        if (1 != $series) {
            $mail_previous['start_date'] = getMailTimeDateString($row['tbl_e_start_time']);
            $mail_previous['end_date'] = getMailTimeDateString($row['tbl_e_end_time']);
            // need to make DST correct in opposite direction to entry creation
            // so that user see what he expects to see
            $mail_previous['duration'] = $row['tbl_e_duration'] - cross_dst($row['tbl_e_start_time'], $row['tbl_e_end_time']);
        } else {
            $mail_previous['start_date'] = getMailTimeDateString($row['tbl_r_start_time']);
            $mail_previous['end_date'] = getMailTimeDateString($row['tbl_r_end_time']);
            // use getMailTimeDateString as all I want is the date
            $mail_previous['rep_end_date'] = getMailTimeDateString($row['tbl_r_end_date'], FALSE);
            // need to make DST correct in opposite direction to entry creation
            // so that user see what he expects to see
            $mail_previous['duration'] = $row['tbl_r_duration'] - cross_dst($row['tbl_r_start_time'], $row['tbl_r_end_time']);
            $mail_previous['rep_opt'] = "";
            switch ($row['rep_type']) {
                case 2:
                case 6:
                    $rep_day[0] = $row['rep_opt'][0] != "0";
                    $rep_day[1] = $row['rep_opt'][1] != "0";
                    $rep_day[2] = $row['rep_opt'][2] != "0";
                    $rep_day[3] = $row['rep_opt'][3] != "0";
                    $rep_day[4] = $row['rep_opt'][4] != "0";
                    $rep_day[5] = $row['rep_opt'][5] != "0";
                    $rep_day[6] = $row['rep_opt'][6] != "0";
                    if ($row['rep_type'] == 6) {
                        $mail_previous['rep_num_weeks'] = $row['rep_num_weeks'];
                    } else {
                        $mail_previous['rep_num_weeks'] = "";
                    }
                    break;
                default:
                    $rep_day = array(0, 0, 0, 0, 0, 0, 0);
            }
            for ($i = 0; $i < 7; $i++) {
                $wday = ($i + $weekstarts) % 7;
                if ($rep_day[$wday]) {
                    $mail_previous['rep_opt'] .= day_name($wday) . " ";
                }
            }
            $mail_previous['rep_num_weeks'] = $row['rep_num_weeks'];
        }
        toTimeString($mail_previous['duration'], $mail_previous['dur_units']);
    }
    1 == $series ? $mail_previous['rep_type'] = $row['rep_type'] : ($mail_previous['rep_type'] = 0);
    // return entry previous data as an array
    return $mail_previous;
}
Esempio n. 14
0
}
# If we have not been provided with starting time
if (empty($start_hour) && $morningstarts < 10) {
    $start_hour = "0{$morningstarts}";
}
if (empty($start_hour)) {
    $start_hour = "{$morningstarts}";
}
if (empty($start_min)) {
    $start_min = "00";
}
// Remove "Undefined variable" notice
if (!isset($rep_num_weeks)) {
    $rep_num_weeks = "";
}
$enable_periods ? toPeriodString($start_min, $duration, $dur_units) : toTimeString($duration, $dur_units);
#now that we know all the data to fill the form with we start drawing it
if (!getWritable($create_by, getUserName())) {
    showAccessDenied($day, $month, $year, $area);
    exit;
}
print_header($day, $month, $year, $area);
?>

<SCRIPT LANGUAGE="JavaScript">
// do a little form verifying
function validate_and_submit ()
{
  // null strings and spaces only strings not allowed
  if(/(^$)|(^\s+$)/.test(document.forms["main"].name.value))
  {
Esempio n. 15
0
    $start_day = $day;
    $start_month = $month;
    $start_year = $year;
    $start_hour = $hour;
    $start_min = $minute;
    $duration = 60 * 60;
    $type = "I";
    $room_id = $room;
    $rep_id = 0;
    $rep_type = 0;
    $rep_end_day = $day;
    $rep_end_month = $month;
    $rep_end_year = $year;
    $rep_day = array(0, 0, 0, 0, 0, 0, 0);
}
toTimeString($duration, $dur_units);
#now that we know all the data to fill the form with we start drawing it
if (!getWritable($create_by, getUserName())) {
    showAccessDenied($day, $month, $year, $area);
    exit;
}
print_header($day, $month, $year, $area);
?>

<SCRIPT LANGUAGE="JavaScript">
// do a little form verifying
function validate_and_submit ()
{
  if(document.forms["main"].name.value == "")
  {
    alert ( "You have not entered a\nBrief Description." );
     echo "<div class=\"group ampm\">\n";
     $checked = $eveningends < 12 ? "checked=\"checked\"" : "";
     echo "<label><input name=\"area_evening_ampm\" type=\"radio\" value=\"am\" {$checked}>" . utf8_strftime($strftime_format['ampm'], mktime(1, 0, 0, 1, 1, 2000)) . "</label>\n";
     $checked = $eveningends >= 12 ? "checked=\"checked\"" : "";
     echo "<label><input name=\"area_evening_ampm\" type=\"radio\" value=\"pm\" {$checked}>" . utf8_strftime($strftime_format['ampm'], mktime(13, 0, 0, 1, 1, 2000)) . "</label>\n";
     echo "</div>\n";
 }
 echo "</div>\n";
 echo "</div>\n";
 // last_slot
 echo "</fieldset>\n";
 // Booking policies
 $min_ba_value = $min_book_ahead_secs;
 toTimeString($min_ba_value, $min_ba_units);
 $max_ba_value = $max_book_ahead_secs;
 toTimeString($max_ba_value, $max_ba_units);
 echo "<fieldset id=\"booking_policies\">\n";
 echo "<legend>" . get_vocab("booking_policies") . "</legend>\n";
 // Note when using periods
 echo "<div id=\"book_ahead_periods_note\"" . ($enable_periods ? '' : ' class="js_none"') . ">\n";
 echo "<label></label><span>" . get_vocab("book_ahead_note_periods") . "</span>";
 echo "</div>\n";
 // Minimum book ahead
 echo "<div>\n";
 $params = array('label' => get_vocab("min_book_ahead") . ":", 'name' => 'area_min_ba_enabled', 'value' => $min_book_ahead_enabled, 'class' => 'enabler');
 generate_checkbox($params);
 $attributes = array('class="text"', 'type="number"', 'min="0"', 'step="1"');
 $params = array('name' => 'area_min_ba_value', 'value' => $min_ba_value, 'attributes' => $attributes);
 generate_input($params);
 $units = array("seconds", "minutes", "hours", "days", "weeks");
 $options = array();
$areas = array();
$sql = "SELECT id, area_name, resolution, default_duration, enable_periods,\r\n               morningstarts, morningstarts_minutes, eveningends , eveningends_minutes\r\n          FROM {$tbl_area}\r\n         WHERE disabled=0\r\n      ORDER BY area_name";
$res = sql_query($sql);
if ($res) {
    for ($i = 0; $row = sql_row_keyed($res, $i); $i++) {
        $areas[$row['id']] = $row;
        // The following config settings aren't yet per-area, but we'll treat them as if
        // they are to make it easier to change them to per-area settings in the future.
        $areas[$row['id']]['max_duration_enabled'] = $max_duration_enabled;
        $areas[$row['id']]['max_duration_secs'] = $max_duration_secs;
        $areas[$row['id']]['max_duration_periods'] = $max_duration_periods;
        // Clean up the settings, getting rid of any nulls and casting boolean fields into bools
        $areas[$row['id']] = clean_area_row($areas[$row['id']]);
        // Generate some derived settings
        $areas[$row['id']]['max_duration_qty'] = $areas[$row['id']]['max_duration_secs'];
        toTimeString($areas[$row['id']]['max_duration_qty'], $areas[$row['id']]['max_duration_units']);
    }
}
?>

<script type="text/javascript">
//<![CDATA[

var currentArea = <?php 
echo $area_id;
?>
;
var areas = [];
<?php 
// give JavaScript a copy of the PHP array $areas
foreach ($areas as $area) {