Copyright (C) 2005 James Grant This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; see the file COPYING. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ ?> "; echo ""; foreach($fields as $k=>$f) { $sel = ($selected == $k) ? 'selected=\"selected\"': '' ; echo ""; } echo ""; } /* */ function parse_fields($f) { $ret = array(); if(!is_array($_POST[$f])) return array(); foreach($_POST[$f] as $c) { if(trim($c) == '') continue; $ret[] = stripslashes($c); } return $ret; } function parse_options($f) { $ret = array(); if(!is_array($_POST[$f])) return array(); foreach($_POST[$f] as $c=>$v) { if(trim($c) == '') continue; $ret[$c] = stripslashes($v); } return $ret; } /* Decode the report */ $report = array(); $report['id'] = intval($_POST['id']); $report['name'] = stripslashes($_POST['name']); $report['creator'] = stripslashes($_POST['creator']); $report['desc'] = stripslashes($_POST['desc']); $report['type'] = stripslashes($_POST['type']); $report['col'] = parse_fields('col'); $report['group'] = parse_fields('group'); $report['sort'] = parse_fields('sort'); $report['distinct'] = parse_fields('distinct'); $report['option'] = parse_options('option'); // print_r($report); $loadaction = $_POST['loadaction']; $colaction = $_POST['colaction']; $repaction = $_POST['repaction']; $repaction_save = $repaction; /* Sort out priorities */ if($loadaction != '') { $report = report_load(intval($_POST['id'])); $colaction = ''; $repaction = ''; } if($colaction != '') { $repaction = ''; } if($repaction == 'try') { /* Try this report save it to the database under a new report, and mark it as * temporary, so when the generator finishes with it, it deletes it */ report_gen($report); exit; } send_header("Administration - Reports > Editor"); if($repaction == 'save') { /* Save the report */ $report['id'] = report_save($report); echo happy(i18n("Report Saved")); } if($repaction == 'del') { report_delete($report['id']); echo happy(i18n("Report Deleted")); } /* ---- Setup ------ */ $n_columns = intval($_POST['ncolumns']); $n = count($report['col']) + 1; if($n > $n_columns) $n_columns = $n; if($colaction == 'add') $n_columns+=3; switch($report['type']) { case 'student': $fields = $report_students_fields; break; case 'judge': $fields = $report_judges_fields; break; case 'awards': $fields = $report_awards_fields; break; } echo "<< ".i18n("Back to Reports")."
"; echo "
"; echo "
"; echo ""; echo ""; echo "
"; echo "
"; echo "
"; echo ""; echo ""; echo "

Report Information

"; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo "
Name:
Created By:
Description:
Type:
"; echo "

Report Data

"; echo ""; $x=0; foreach($report['col'] as $f) { echo ""; echo ""; $x++; } for(;$x<$n_columns;$x++) { echo ""; echo ""; } echo ""; echo ""; echo "
Column ".($x + 1).": "; field_selector("col[]", "col$x", $f); echo "
Column ".($x + 1).": "; field_selector("col[]", "col$x", ''); echo "
"; echo ""; echo ""; echo "
\n"; echo "

Grouping

"; for($x=0;$x<2;$x++) { echo "Group By".($x + 1).": "; field_selector("group[]", "group$x", $report['group'][$x]); echo "
"; } echo "

Sorting

"; for($x=0;$x<3;$x++) { echo "Sort By".($x + 1).": "; field_selector("sort[]", "sort$x", $report['sort'][$x]); echo "
"; } echo "

Distinct

"; echo "Distinct Column: "; field_selector("distinct[]", "distinct0", $report['distinct'][0]); echo "

Options

"; foreach($options as $ok=>$o) { echo "{$o['desc']}:
\n"; } echo "
"; echo ""; echo ""; echo "
"; send_footer(); ?>