- Do a reload on report selection when adding a report. FIXME: I need to find

a way to make this page not jump back to the top after the reload.
This commit is contained in:
dave 2007-12-10 09:14:48 +00:00
parent 1e6ffcfa7f
commit 9bd50a5e5a

View File

@ -45,6 +45,12 @@
exit; exit;
} }
$reports_id = 0;
if($action == 'reload') {
$edit_mode = true;
$reports_id = intval($_POST['reports_id']);
}
if($action == 'add') { if($action == 'add') {
$reports_id = intval($_POST['reports_id']); $reports_id = intval($_POST['reports_id']);
/* reports_id might be < 0, that's ok */ /* reports_id might be < 0, that's ok */
@ -114,8 +120,10 @@
echo '<table>'; echo '<table>';
$last_category = ''; $last_category = '';
$x=0;
while($i = mysql_fetch_object($q)) { while($i = mysql_fetch_object($q)) {
$trclass = ($x % 2 == 0) ? "even" : "odd";
$x++;
if($last_category != $i->category) { if($last_category != $i->category) {
/* New category */ /* New category */
echo '<h4>'; echo '<h4>';
@ -135,25 +143,27 @@
if($edit_mode == false) if($edit_mode == false)
$name = "<a href=\"{$config['SFIABDIRECTORY']}/$url\">$name</a>"; $name = "<a href=\"{$config['SFIABDIRECTORY']}/$url\">$name</a>";
echo "<table><tr><td colspan=\"2\">$name</td></tr>"; echo "<table width=\"100%\"><tr class=\"$trclass\"><td>";
echo "<tr><td width=\"20px\">";
if($edit_mode == true) {
echo "<a title=\"Remove Report\" href=\"committee_reports.php?action=unlink&id={$i->id}\"><img src=\"".$config['SFIABDIRECTORY']."/images/16/button_cancel.".$config['icon_extension']."\" border=\"0\" alt=\"Remove Report\" /></a>";
}
echo "</td>"; echo "<table><tr><td colspan=\"2\">";
echo "<td><span style=\"font-size: 0.75em;\">"; if($edit_mode == true)
echo "<a title=\"Remove Report\" href=\"committee_reports.php?action=unlink&id={$i->id}\"><img src=\"".$config['SFIABDIRECTORY']."/images/16/button_cancel.".$config['icon_extension']."\" border=\"0\" alt=\"Remove Report\" /></a>&nbsp;";
echo $name.'</td></tr>';
/*
if($i->reports_id > 0) { if($i->reports_id > 0) {
echo '<tr><td width=\"20px\"></td><td>';
echo '<span style=\"font-size: 0.75em;\">';
echo i18n('Format').": {$i->format}, "; echo i18n('Format').": {$i->format}, ";
echo i18n('Paper').": {$report_stock[$i->stock]['name']}, "; echo i18n('Paper').": {$report_stock[$i->stock]['name']}, ";
echo i18n('Year').": {$config['FAIRYEAR']}"; echo i18n('Year').": {$config['FAIRYEAR']}";
} else { echo '</span>';
echo i18n('Custom report, no options available'); echo '</td></tr>';
} }
echo "</span></td></tr>"; */
echo "<tr><td></td><td>{$i->comment}</td></tr>"; echo "<tr><td width=\"20px\"></td><td><span style=\"font-size: 0.85em;\">{$i->comment}</span></td></tr>";
echo "</table>"; echo "</table></tr></td></table>";
} }
} }
@ -187,23 +197,36 @@
echo '<hr />'; echo '<hr />';
?>
<SCRIPT language="JavaScript">
function add_reload()
{
document.addreport.action.value='reload';
document.addreport.submit();
return true;
}
</SCRIPT>
<?
/* Create an add report box */ /* Create an add report box */
echo '<h4>'.i18n('Add a Report to your Report List').'</h4>'; echo '<h4>'.i18n('Add a Report to your Report List').'</h4>';
echo "<form method=\"post\" action=\"committee_reports.php\">"; echo "<form method=\"post\" name=\"addreport\"action=\"committee_reports.php\">";
echo "<input type=\"hidden\" name=\"action\" value=\"add\">"; echo "<input type=\"hidden\" name=\"action\" value=\"add\">";
echo "<table>\n"; echo "<table>\n";
echo '<tr><td colspan="2">'; echo '<tr><td colspan="2">';
echo "<select name=\"reports_id\">"; echo "<select name=\"reports_id\" onChange=\"add_reload()\">";
$x=0; $x=0;
foreach($reports as $r) { foreach($reports as $r) {
$x++; $x++;
echo "<option value=\"{$r['id']}\">$x. {$r['name']}</option>"; $sel = ($reports_id == $r['id']) ? 'selected="selected"' : '';
echo "<option value=\"{$r['id']}\" $sel>$x. {$r['name']}</option>";
} }
$rid = -1; $rid = -1;
foreach($report_custom as $r) { foreach($report_custom as $r) {
$x++; $x++;
echo "<option value=\"$rid\">$x. {$r['name']}</option>"; $sel = ($reports_id == $rid) ? 'selected="selected"' : '';
echo "<option value=\"$rid\" $sel>$x. {$r['name']}</option>";
$rid--; $rid--;
} }
@ -223,13 +246,15 @@
echo "OR New Category: <input type=\"text\" name=\"category\">"; echo "OR New Category: <input type=\"text\" name=\"category\">";
echo "</td></tr>"; echo "</td></tr>";
/* Load the full specific report */
if($reports_id > 0) $report = report_load($reports_id);
$option_keys = array('type','stock'); $option_keys = array('type','stock');
foreach($report_options as $ok=>$o) { foreach($report_options as $ok=>$o) {
if(!in_array($ok, $option_keys)) continue; if(!in_array($ok, $option_keys)) continue;
echo "<tr><td>{$o['desc']}:</td>"; echo "<tr><td>{$o['desc']}:</td>";
echo "<td><select name=\"$ok\" id=\"$ok\">"; echo "<td><select name=\"$ok\" id=\"$ok\">";
foreach($o['values'] as $k=>$v) { foreach($o['values'] as $k=>$v) {
$sel = ($r['option'][$ok] == $k) ? 'selected=\"selected\"' : ''; $sel = ($report['option'][$ok] == $k) ? 'selected=\"selected\"' : '';
echo "<option value=\"$k\" $sel>$v</option>"; echo "<option value=\"$k\" $sel>$v</option>";
} }
echo "</select></td></tr>"; echo "</select></td></tr>";