Revision: 1385
http://mrbs.svn.sourceforge.net/mrbs/?rev=1385&view=rev
Author: cimorrison
Date: 2010-07-25 20:59:45 +0000 (Sun, 25 Jul 2010)
Log Message:
-----------
Added custom field information to report output. (Report search criteria
still to be extended to include custom fields).
Modified Paths:
--------------
mrbs/branches/custom_entry_fields/web/report.php
Modified: mrbs/branches/custom_entry_fields/web/report.php
===================================================================
--- mrbs/branches/custom_entry_fields/web/report.php 2010-07-25 18:20:58 UTC
(rev 1384)
+++ mrbs/branches/custom_entry_fields/web/report.php 2010-07-25 20:59:45 UTC
(rev 1385)
@@ -126,6 +126,7 @@
function csv_report_header($display)
{
global $csv_row_sep;
+ global $custom_fields, $tbl_entry;
// Build an array of values to go into the header row
$values = array();
@@ -141,7 +142,12 @@
}
$values[] = get_vocab("fulldescription_short");
$values[] = get_vocab("type");
- $values[] = get_vocab("createdby");
+ $values[] = get_vocab("createdby");
+ // Now do the custom fields
+ foreach ($custom_fields as $key => $value)
+ {
+ $values[] = get_loc_field_name($tbl_entry, $key);
+ }
$values[] = get_vocab("lastupdate");
// Remove any HTML entities from the values
@@ -179,6 +185,7 @@
global $enable_periods;
global $output_as_csv;
global $csv_row_sep;
+ global $custom_fields, $field_natures, $field_lengths, $tbl_entry;
// Initialise the line for CSV reports
$line = "";
@@ -316,6 +323,35 @@
echo "<td>" . escape($row['create_by']) . "</td>\n";
echo "</tr>\n";
}
+
+ // Now do any custom fields
+ foreach ($custom_fields as $key => $value)
+ {
+ // Output a yes/no 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)) )
+ {
+ $value = empty($value) ? get_vocab("no") : get_vocab("yes");
+ }
+ // Otherwise output a string
+ else
+ {
+ $value = (isset($value)) ? $value : '';
+ }
+
+ if ($output_as_csv)
+ {
+ $line = csv_row_add_value($line, $value);
+ }
+ else
+ {
+ echo "<tr>\n";
+ echo "<td>" . get_loc_field_name($tbl_entry, $key) . ":</td>\n";
+ echo "<td>" . escape($value) . "</td>\n";
+ echo "</tr>\n";
+ }
+ }
// Last updated:
if ($output_as_csv)
@@ -567,6 +603,21 @@
$output_as_csv = $summarize & CSV;
+// Get information about custom fields
+$fields = sql_field_info($tbl_entry);
+$custom_fields = array();
+$field_natures = array();
+$field_lengths = array();
+foreach ($fields as $field)
+{
+ if (!in_array($field['name'], $standard_fields['entry']))
+ {
+ $custom_fields[$field['name']] = '';
+ }
+ $field_natures[$field['name']] = $field['nature'];
+ $field_lengths[$field['name']] = $field['length'];
+}
+
// print the page header
if ($output_as_csv)
{
@@ -812,11 +863,17 @@
$sql = "SELECT E.id AS entry_id, E.start_time, E.end_time, E.name,
E.description, "
. "E.type, E.create_by, "
. sql_syntax_timestamp_to_unix("E.timestamp") . " AS last_updated"
- . ", A.area_name, R.room_name"
- . " FROM $tbl_entry E, $tbl_area A, $tbl_room R"
- . " WHERE E.room_id = R.id AND R.area_id = A.id"
- . " AND E.start_time < $report_end AND E.end_time > $report_start";
+ . ", A.area_name, R.room_name";
+ // Get any custom fields
+ foreach ($custom_fields as $custom_field => $value)
+ {
+ $sql .= ", E.$custom_field";
+ }
+ $sql .= " FROM $tbl_entry E, $tbl_area A, $tbl_room R"
+ . " WHERE E.room_id = R.id AND R.area_id = A.id"
+ . " AND E.start_time < $report_end AND E.end_time > $report_start";
+
if (!empty($areamatch))
{
// sql_syntax_caseless_contains() does the SQL escaping
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
This SF.net email is sponsored by Sprint
What will you do first with EVO, the first 4G phone?
Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first
_______________________________________________
Mrbs-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mrbs-commits