コード例 #1
0
ファイル: report.php プロジェクト: bdwong-mirrors/mrbs
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";
}
コード例 #2
0
  summaryHead.find('tr:first th:even').not(':first').remove();
  summaryHead.find('tr:first th:first').attr('rowspan', '2');
  summaryHead.find('tr:eq(1) th:first').remove();
  summaryDiv.css('visibility', 'visible');
  
  
  <?php 
// Make the area match input on the report page into an auto-complete input
$options = sql_query_array("SELECT area_name FROM {$tbl_area} ORDER BY area_name");
if ($options !== FALSE) {
    echo generate_autocomplete('areamatch', $options);
}
// Make the room match input on the report page into an auto-complete input
// (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) {
    echo generate_autocomplete('roommatch', $options);
}
// Make any custom fields for the entry table that have an array of options
// into auto-complete inputs
foreach ($select_options as $field => $options) {
    if (strpos($field, 'entry.') == 0) {
        echo generate_autocomplete('match_' . substr($field, strlen('entry.')), $options);
    }
}
// We don't support iCal output for the Summary.   So if the Summary button is pressed
// disable the iCal button and, if iCal output is checked, check another format.  If the
// Report button is pressed then re-enable the iCal button.
?>
  $('input[name="output"]').change(function() {