foreach ($units as $unit) {
     $options[$unit] = get_vocab($unit);
 }
 $params = array('name' => 'area_min_ba_units', 'value' => array_search($min_ba_units, $options), 'options' => $options);
 generate_select($params);
 echo "</div>\n";
 // Maximum book ahead
 echo "<div>\n";
 $params = array('label' => get_vocab("max_book_ahead") . ":", 'name' => 'area_max_ba_enabled', 'value' => $max_book_ahead_enabled, 'class' => 'enabler');
 generate_checkbox($params);
 $attributes = array('class="text"', 'type="number"', 'min="0"', 'step="1"');
 $params = array('name' => 'area_max_ba_value', 'value' => $max_ba_value, 'attributes' => $attributes);
 generate_input($params);
 $params = array('name' => 'area_max_ba_units', 'value' => array_search($max_ba_units, $options), 'options' => $options);
 // options same as before
 generate_select($params);
 echo "</div>\n";
 // The max_per booking policies
 echo "<table>\n";
 echo "<thead>\n";
 echo "<tr>\n";
 echo "<th></th>\n";
 echo "<th>" . get_vocab("this_area") . "</th>\n";
 echo "<th title=\"" . get_vocab("whole_system_note") . "\">" . get_vocab("whole_system") . "</th>\n";
 echo "</tr>\n";
 echo "</thead>\n";
 echo "<tbody>\n";
 foreach ($interval_types as $interval_type) {
     echo "<tr>\n";
     echo "<td><label>" . get_vocab("max_per_{$interval_type}") . ":</label></td>\n";
     echo "<td><input class=\"enabler checkbox\" type=\"checkbox\" id=\"area_max_per_{$interval_type}_enabled\" name=\"area_max_per_{$interval_type}_enabled\"" . ($max_per_interval_area_enabled[$interval_type] ? " checked=\"checked\"" : "") . ">\n";
Пример #2
0
function generate_search_criteria(&$vars)
{
    global $booking_types, $select_options;
    global $private_somewhere, $approval_somewhere, $confirmation_somewhere;
    global $user_level, $tbl_entry, $tbl_area, $tbl_room;
    global $field_natures, $field_lengths;
    global $report_search_field_order;
    echo "<fieldset>\n";
    echo "<legend>" . get_vocab("search_criteria") . "</legend>\n";
    foreach ($report_search_field_order as $key) {
        switch ($key) {
            case 'report_start':
                echo "<div id=\"div_report_start\">\n";
                echo "<label>" . get_vocab("report_start") . ":</label>\n";
                genDateSelector("from_", $vars['from_day'], $vars['from_month'], $vars['from_year']);
                echo "</div>\n";
                break;
            case 'report_end':
                echo "<div id=\"div_report_end\">\n";
                echo "<label>" . get_vocab("report_end") . ":</label>\n";
                genDateSelector("to_", $vars['to_day'], $vars['to_month'], $vars['to_year']);
                echo "</div>\n";
                break;
            case 'areamatch':
                $options = sql_query_array("SELECT area_name FROM {$tbl_area} ORDER BY area_name");
                if ($options === FALSE) {
                    trigger_error(sql_error(), E_USER_WARNING);
                    fatal_error(FALSE, get_vocab("fatal_db_error"));
                }
                echo "<div id=\"div_areamatch\">\n";
                $params = array('label' => get_vocab("match_area") . ':', 'name' => 'areamatch', 'options' => $options, 'force_indexed' => TRUE, 'value' => $vars['areamatch']);
                generate_datalist($params);
                echo "</div>\n";
                break;
            case 'roommatch':
                // (We need DISTINCT because it's possible to have two rooms of the same name
                // in different areas)
                $options = sql_query_array("SELECT DISTINCT room_name FROM {$tbl_room} ORDER BY room_name");
                if ($options === FALSE) {
                    trigger_error(sql_error(), E_USER_WARNING);
                    fatal_error(FALSE, get_vocab("fatal_db_error"));
                }
                echo "<div id=\"div_roommatch\">\n";
                $params = array('label' => get_vocab("match_room") . ':', 'name' => 'roommatch', 'options' => $options, 'force_indexed' => TRUE, 'value' => $vars['roommatch']);
                generate_datalist($params);
                echo "</div>\n";
                break;
            case 'typematch':
                echo "<div id=\"div_typematch\">\n";
                $options = array();
                foreach ($booking_types as $type) {
                    $options[$type] = get_type_vocab($type);
                }
                $params = array('label' => get_vocab("match_type") . ':', 'name' => 'typematch[]', 'id' => 'typematch', 'options' => $options, 'force_assoc' => TRUE, 'value' => $vars['typematch'], 'multiple' => TRUE, 'attributes' => 'size="5"');
                generate_select($params);
                echo "<span>" . get_vocab("ctrl_click_type") . "</span>\n";
                echo "</div>\n";
                break;
            case 'namematch':
                echo "<div id=\"div_namematch\">\n";
                $params = array('label' => get_vocab("match_entry") . ':', 'name' => 'namematch', 'value' => $vars['namematch']);
                generate_input($params);
                echo "</div>\n";
                break;
            case 'descrmatch':
                echo "<div id=\"div_descrmatch\">\n";
                $params = array('label' => get_vocab("match_descr") . ':', 'name' => 'descrmatch', 'value' => $vars['descrmatch']);
                generate_input($params);
                echo "</div>\n";
                break;
            case 'creatormatch':
                echo "<div id=\"div_creatormatch\">\n";
                $params = array('label' => get_vocab("createdby") . ':', 'name' => 'creatormatch', 'value' => $vars['creatormatch']);
                generate_input($params);
                echo "</div>\n";
                break;
            case 'match_private':
                // Privacy status
                // Only show this part of the form if there are areas that allow private bookings
                if ($private_somewhere) {
                    // If they're not logged in then there's no point in showing this part of the form because
                    // they'll only be able to see public bookings anyway (and we don't want to alert them to
                    // the existence of private bookings)
                    if (empty($user_level)) {
                        echo "<input type=\"hidden\" name=\"match_private\" value=\"" . PRIVATE_NO . "\">\n";
                    } else {
                        echo "<div id=\"div_privacystatus\">\n";
                        $options = array(PRIVATE_BOTH => get_vocab("both"), PRIVATE_NO => get_vocab("default_public"), PRIVATE_YES => get_vocab("default_private"));
                        $params = array('label' => get_vocab("privacy_status") . ':', 'name' => 'match_private', 'options' => $options, 'value' => $vars['match_private']);
                        generate_radio_group($params);
                        echo "</div>\n";
                    }
                }
                break;
            case 'match_confirmed':
                // Confirmation status
                // Only show this part of the form if there are areas that require approval
                if ($confirmation_somewhere) {
                    echo "<div id=\"div_confirmationstatus\">\n";
                    $options = array(CONFIRMED_BOTH => get_vocab("both"), CONFIRMED_YES => get_vocab("confirmed"), CONFIRMED_NO => get_vocab("tentative"));
                    $params = array('label' => get_vocab("confirmation_status") . ':', 'name' => 'match_confirmed', 'options' => $options, 'value' => $vars['match_confirmed']);
                    generate_radio_group($params);
                    echo "</div>\n";
                }
                break;
            case 'match_approved':
                // Approval status
                // Only show this part of the form if there are areas that require approval
                if ($approval_somewhere) {
                    echo "<div id=\"div_approvalstatus\">\n";
                    $options = array(APPROVED_BOTH => get_vocab("both"), APPROVED_YES => get_vocab("approved"), APPROVED_NO => get_vocab("awaiting_approval"));
                    $params = array('label' => get_vocab("approval_status") . ':', 'name' => 'match_approved', 'options' => $options, 'value' => $vars['match_approved']);
                    generate_radio_group($params);
                    echo "</div>\n";
                }
                break;
            default:
                // Must be a custom field
                $var = "match_{$key}";
                global ${$var};
                $params = array('label' => get_loc_field_name($tbl_entry, $key) . ':', 'name' => $var, 'value' => isset(${$var}) ? ${$var} : NULL);
                echo "<div>\n";
                // Output a checkbox if it's a boolean or integer <= 2 bytes (which we will
                // assume are intended to be booleans)
                if ($field_natures[$key] == 'boolean' || $field_natures[$key] == 'integer' && isset($field_lengths[$key]) && $field_lengths[$key] <= 2) {
                    generate_checkbox($params);
                } else {
                    // If $select_options is defined we want to force a <datalist> and not a
                    // <select>.  That's because if we have options such as
                    // ('tea', 'white coffee', 'black coffee') we want the user to be able to type
                    // 'coffee' which will match both 'white coffee' and 'black coffee'.
                    if (isset($select_options["entry.{$key}"]) && !empty($select_options["entry.{$key}"])) {
                        $params['options'] = $select_options["entry.{$key}"];
                        // We force the values to be used and not the keys.   We will convert
                        // back to values when we construct the SQL query.
                        $params['force_indexed'] = TRUE;
                        generate_datalist($params);
                    } else {
                        $params['field'] = "entry.{$key}";
                        generate_input($params);
                    }
                }
                echo "</div>\n";
                break;
        }
        // switch
    }
    echo "</fieldset>\n";
}
Пример #3
0
function create_field_entry_type($disabled = FALSE)
{
    global $booking_types, $type;
    echo "<div id=\"div_type\">\n";
    $params = array('label' => get_vocab("type") . ":", 'name' => 'type', 'disabled' => $disabled, 'options' => array(), 'force_assoc' => TRUE, 'value' => $type);
    foreach ($booking_types as $key) {
        $params['options'][$key] = get_type_vocab($key);
    }
    generate_select($params);
    echo "</div>\n";
}
Пример #4
0
function generate_transactions_table($transactions, $categories)
{
    // 1st pass - transform
    $by_account = array();
    foreach ($transactions as $t) {
        if (!array_key_exists($t['account_name'], $by_account)) {
            $by_account[$t['account_name']] = array();
        }
        $by_account[$t['account_name']][] = $t;
    }
    // 2nd pass - render
    $html = '';
    foreach ($by_account as $k => $v) {
        $html .= "<tr'><td colspan='4'><font color='#789CC7'><strong>{$k}</strong></font></td></tr>";
        foreach ($v as $tr) {
            $html .= "<tr>";
            $html .= "<td>" . $tr['transaction_date'] . "</td>";
            $html .= "<td class='yui-dt-col-description'>" . "<a href=''>" . htmlentities($tr['description']) . "</a>" . "<div style='display:none'>" . $tr['id'] . "</div>" . "</td>";
            $curr = $tr['category'];
            $html .= "<td>" . generate_select('category', $categories, $curr, 'category', 'category', $tr['id']) . "</td>";
            if ($tr['amount'] < 0) {
                $klass = 'row-debit';
            } else {
                $klass = 'row-credit';
            }
            $html .= "<td class='{$klass}'>£" . number_format($tr['amount'], 2) . "</td>";
            $html .= "</tr>";
        }
    }
    return $html;
}
                 // if the field was disabled then we still need to pass through the value as a hidden input
                 if ($level < $min_user_editing_level) {
                     echo "<input type=\"hidden\" name=\"{$var_name}\" value=\"" . $data[$key] . "\">\n";
                 }
                 break;
             case 'email':
                 generate_input($label_text, $var_name, $data[$key], FALSE, isset($maxlength["users.{$key}"]) ? $maxlength["users.{$key}"] : NULL, 'type=email multiple');
                 break;
             default:
                 // Output a checkbox if it's a boolean or integer <= 2 bytes (which we will
                 // assume are intended to be booleans)
                 if ($field['nature'] == 'boolean' || $field['nature'] == 'integer' && isset($field['length']) && $field['length'] <= 2) {
                     echo "<label for=\"{$var_name}\">{$label_text}</label>\n";
                     echo "<input type=\"checkbox\" class=\"checkbox\" " . "id=\"{$var_name}\" name=\"{$var_name}\" value=\"1\"" . (!empty($data[$key]) ? " checked=\"checked\"" : "") . ">\n";
                 } elseif (!empty($select_options["users.{$key}"])) {
                     generate_select($label_text, $var_name, $data[$key], $select_options["users.{$key}"]);
                 } elseif ($field['nature'] == 'character' && isset($field['length']) && $field['length'] > $text_input_max) {
                     generate_textarea($label_text, $var_name, $data[$key]);
                 } else {
                     generate_input($label_text, $var_name, $data[$key], FALSE, isset($maxlength["users.{$key}"]) ? $maxlength["users.{$key}"] : NULL);
                 }
                 break;
         }
         // end switch
         echo "</div>\n";
 }
 // end switch
 // Then output any error messages associated with the field
 // except for the password field which is a special case
 switch ($key) {
     case 'email':
Пример #6
0
function create_field_entry_type($disabled = FALSE)
{
    global $booking_types, $type;
    global $sql_mysqli_conn;
    echo "<div id=\"div_type\">\n";
    $params = array('label' => get_vocab("type") . ":", 'name' => 'type', 'disabled' => $disabled, 'options' => array(), 'force_assoc' => TRUE, 'value' => $type);
    $sql = "SELECT code,description FROM codes";
    $res = $sql_mysqli_conn->query($sql);
    /*  foreach ($res as $key)
      {
        $params['options'][$key] = $key;
      }*/
    while ($row = $res->fetch_assoc()) {
        $params['options'][$row['code']] = $row['description'];
    }
    generate_select($params);
    $res->free();
    echo "</div>\n";
}
Пример #7
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";
}
// CUSTOM FIELDS
foreach ($fields as $field) {
    $key = $field['name'];
    if (!in_array($key, $standard_fields['entry'])) {
        $var_name = VAR_PREFIX . $key;
        $value = $custom_fields[$key];
        $label_text = get_loc_field_name($tbl_entry, $key) . ":";
        echo "<div>\n";
        // Output a checkbox if it's a boolean or integer <= 2 bytes (which we will
        // assume are intended to be booleans)
        if ($field['nature'] == 'boolean' || $field['nature'] == 'integer' && isset($field['length']) && $field['length'] <= 2) {
            echo "<label for=\"{$var_name}\">{$label_text}</label>\n";
            echo "<input type=\"checkbox\" class=\"checkbox\" " . "id=\"{$var_name}\" name=\"{$var_name}\" value=\"1\" " . (!empty($value) ? " checked=\"checked\"" : "") . ">\n";
        } elseif (count($select_options["entry.{$key}"]) > 0) {
            $mandatory = array_key_exists("entry.{$key}", $is_mandatory_field) && $is_mandatory_field["entry.{$key}"] ? true : false;
            generate_select($label_text, $var_name, $value, $select_options["entry.{$key}"], $mandatory);
        } elseif ($field['nature'] == 'character' && isset($field['length']) && $field['length'] > $text_input_max) {
            generate_textarea($label_text, $var_name, $value);
        } else {
            generate_input($label_text, $var_name, $value);
        }
        echo "</div>\n";
    }
}
// REPEAT BOOKING INPUTS
if ($edit_type == "series" && $repeats_allowed) {
    // If repeats are allowed and the edit_type is a series (which means
    // that either you're editing an existing series or else you're making
    // a new booking) then print the repeat inputs
    echo "<fieldset id=\"rep_info\">\n";
    echo "<legend></legend>\n";
function create_field_entry_custom_field($field, $key, $disabled = FALSE)
{
    global $custom_fields, $tbl_entry, $select_options;
    global $is_mandatory_field, $text_input_max;
    $var_name = VAR_PREFIX . $key;
    $value = $custom_fields[$key];
    $label_text = get_loc_field_name($tbl_entry, $key) . ":";
    $mandatory = array_key_exists("entry.{$key}", $is_mandatory_field) && $is_mandatory_field["entry.{$key}"] ? true : false;
    echo "<div>\n";
    // Output a checkbox if it's a boolean or integer <= 2 bytes (which we will
    // assume are intended to be booleans)
    if ($field['nature'] == 'boolean' || $field['nature'] == 'integer' && isset($field['length']) && $field['length'] <= 2) {
        echo "<label for=\"{$var_name}\">{$label_text}</label>\n";
        echo "<input type=\"checkbox\" class=\"checkbox\" " . "id=\"{$var_name}\" name=\"{$var_name}\" value=\"1\" " . (!empty($value) ? " checked=\"checked\"" : "") . ($disabled ? " disabled=\"disabled\"" : "") . ($mandatory ? " required" : "") . ">\n";
    } elseif (!empty($select_options["entry.{$key}"])) {
        generate_select($label_text, $var_name, $value, $select_options["entry.{$key}"], $mandatory, $disabled);
    } elseif ($field['nature'] == 'character' && isset($field['length']) && $field['length'] > $text_input_max) {
        // HTML5 does not allow a pattern attribute for the textarea element
        $attributes = isset($is_mandatory_field["entry.{$key}"]) && $is_mandatory_field["entry.{$key}"] ? "required" : "";
        generate_textarea($label_text, $var_name, $value, $disabled, $attributes);
    } else {
        $is_integer_field = $field['nature'] == 'integer' && $field['length'] > 2;
        if ($is_integer_field) {
            $attributes = 'type="number" step="1"';
        } else {
            $attributes = 'type="text"';
        }
        if (isset($is_mandatory_field["entry.{$key}"]) && $is_mandatory_field["entry.{$key}"]) {
            $attributes .= ' required';
            // 'required' is not sufficient for strings, because we also want to make sure
            // that the string contains at least one non-whitespace character
            $attributes .= $is_integer_field ? '' : ' pattern="' . REGEX_TEXT_POS . '"';
        }
        generate_input($label_text, $var_name, $value, $disabled, NULL, $attributes);
    }
    if ($disabled) {
        echo "<input type=\"hidden\" name=\"{$var_name}\" value=\"{$value}\">\n";
    }
    echo "</div>\n";
}