forked from science-ation/science-ation
- Make the default report type 'student'. And load the necessary fields for that
- If the report type is changed, submit the form with a reload, to reload all the available fields.
This commit is contained in:
parent
7ff0b4b104
commit
1b0835a47f
@ -50,80 +50,15 @@
|
|||||||
echo "</select>";
|
echo "</select>";
|
||||||
}
|
}
|
||||||
|
|
||||||
function selector($name, $a, $selected)
|
function selector($name, $a, $selected, $onchange='')
|
||||||
{
|
{
|
||||||
echo "<select name=\"$name\">";
|
echo "<select name=\"$name\" $onchange >";
|
||||||
foreach($a as $v=>$val) {
|
foreach($a as $v=>$val) {
|
||||||
$sel = ($selected == $v) ? 'selected=\"selected\"' : '';
|
$sel = ($selected == $v) ? 'selected=\"selected\"' : '';
|
||||||
echo "<option value=\"$v\" $sel>$val</option>";
|
echo "<option value=\"$v\" $sel>$val</option>";
|
||||||
}
|
}
|
||||||
echo '</select>';
|
echo '</select>';
|
||||||
}
|
}
|
||||||
/*
|
|
||||||
<script type="text/javascript">
|
|
||||||
function reportChange()
|
|
||||||
{
|
|
||||||
var index = document.forms.report.report.selectedIndex;
|
|
||||||
|
|
||||||
document.getElementById('report').submit();
|
|
||||||
return;
|
|
||||||
|
|
||||||
|
|
||||||
/* Clean out existing settings
|
|
||||||
<?foreach($fields as $k=>$f) {
|
|
||||||
echo "document.getElementById('$k').checked=false;\n";
|
|
||||||
}?>
|
|
||||||
document.getElementById('group0').value = '';
|
|
||||||
document.getElementById('group1').value = '';
|
|
||||||
// document.getElementById('group2').value = '';
|
|
||||||
document.getElementById('sort0').value = '';
|
|
||||||
document.getElementById('sort1').value = '';
|
|
||||||
document.getElementById('sort2').value = '';
|
|
||||||
document.getElementById('distinct0').value = '';
|
|
||||||
document.getElementById('type').value = 'pdf';
|
|
||||||
document.getElementById('group_new_page').value = 'no';
|
|
||||||
|
|
||||||
/* Load appropriate settings
|
|
||||||
if(index == 0) {
|
|
||||||
/* Do nothing
|
|
||||||
}
|
|
||||||
<?$x=1;
|
|
||||||
foreach($reports as $r) {
|
|
||||||
echo "else if(index == $x) {\n";
|
|
||||||
foreach($r['cols'] as $c) {
|
|
||||||
echo "document.getElementById('$c').checked=true;\n";
|
|
||||||
}
|
|
||||||
$i = 0;
|
|
||||||
foreach($r['sort'] as $c) {
|
|
||||||
echo "document.getElementById('sort$i').value='$c';\n";
|
|
||||||
$i++;
|
|
||||||
}
|
|
||||||
$i = 0;
|
|
||||||
foreach($r['group'] as $c) {
|
|
||||||
echo "document.getElementById('group$i').value='$c';\n";
|
|
||||||
$i++;
|
|
||||||
}
|
|
||||||
if(is_array($r['distinct'])) {
|
|
||||||
$i = 0;
|
|
||||||
foreach($r['distinct'] as $c) {
|
|
||||||
echo "document.getElementById('distinct$i').value='$c';\n";
|
|
||||||
$i++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(is_array($r['option'])) {
|
|
||||||
foreach($r['option'] as $k=>$v) {
|
|
||||||
echo "document.getElementById('$k').value='$v';\n";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$x++;
|
|
||||||
echo "}\n";
|
|
||||||
}
|
|
||||||
?>
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
</script>
|
|
||||||
*/
|
|
||||||
|
|
||||||
function parse_fields($f)
|
function parse_fields($f)
|
||||||
{
|
{
|
||||||
@ -197,17 +132,28 @@ function reportChange()
|
|||||||
// print("<pre>");print_r($_POST);print("</pre>");
|
// print("<pre>");print_r($_POST);print("</pre>");
|
||||||
// print("<pre>");print_r($report);print("</pre>");
|
// print("<pre>");print_r($report);print("</pre>");
|
||||||
|
|
||||||
|
$reloadaction = $_POST['reloadaction'];
|
||||||
$loadaction = $_POST['loadaction'];
|
$loadaction = $_POST['loadaction'];
|
||||||
$colaction = $_POST['colaction'];
|
$colaction = $_POST['colaction'];
|
||||||
$repaction = $_POST['repaction'];
|
$repaction = $_POST['repaction'];
|
||||||
|
|
||||||
$repaction_save = $repaction;
|
$repaction_save = $repaction;
|
||||||
|
|
||||||
/* Sort out priorities */
|
/* Sort out priorities */
|
||||||
if($loadaction != '') {
|
if($reloadaction != '') {
|
||||||
$report = report_load(intval($_POST['id']));
|
$loadaction = '';
|
||||||
$colaction = '';
|
$colaction = '';
|
||||||
$repaction = '';
|
$repaction = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if($loadaction != '') {
|
||||||
|
$id = intval($_POST['id']);
|
||||||
|
$report = report_load($id);
|
||||||
|
if($id == 0) $report['type'] = 'student';
|
||||||
|
$colaction = '';
|
||||||
|
$repaction = '';
|
||||||
|
}
|
||||||
|
|
||||||
if($colaction != '') {
|
if($colaction != '') {
|
||||||
$repaction = '';
|
$repaction = '';
|
||||||
}
|
}
|
||||||
@ -218,11 +164,23 @@ function reportChange()
|
|||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
send_header("Reports Editor",
|
send_header("Reports Editor",
|
||||||
array('Committee Main' => 'committee_main.php',
|
array('Committee Main' => 'committee_main.php',
|
||||||
'Administration' => 'admin/index.php')
|
'Administration' => 'admin/index.php')
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
|
?>
|
||||||
|
<script type="text/javascript">
|
||||||
|
function reportReload()
|
||||||
|
{
|
||||||
|
document.forms.report.reloadaction.value = 'reload';
|
||||||
|
document.forms.report.submit();
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
<?
|
||||||
|
|
||||||
if($repaction == 'save') {
|
if($repaction == 'save') {
|
||||||
/* Save the report */
|
/* Save the report */
|
||||||
$report['id'] = report_save($report);
|
$report['id'] = report_save($report);
|
||||||
@ -337,9 +295,9 @@ function reportChange()
|
|||||||
'award' => 'Award Report', 'committee' => 'Committee Member Report',
|
'award' => 'Award Report', 'committee' => 'Committee Member Report',
|
||||||
'school' => 'School Report', 'volunteer' => 'Volunteer Report',
|
'school' => 'School Report', 'volunteer' => 'Volunteer Report',
|
||||||
'tour' => 'Tour Report'),
|
'tour' => 'Tour Report'),
|
||||||
|
$report['type'],
|
||||||
$report['type']);
|
"onChange=\"reportReload();\"");
|
||||||
|
echo "<input type=\"hidden\" name=\"reloadaction\" value=\"\">";
|
||||||
echo "</td>";
|
echo "</td>";
|
||||||
echo "</tr></table>";
|
echo "</tr></table>";
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user