diff --git a/admin/reports.php b/admin/reports.php index d203586..bcfc2eb 100644 --- a/admin/reports.php +++ b/admin/reports.php @@ -23,117 +23,212 @@ */ ?> category; + echo json_encode($ret); + exit; + +case 'save': + echo "POST: "; + print_r($_POST); + $id = intval($_POST['id']); $reports_id = intval($_POST['reports_id']); - /* reports_id might be < 0, that's ok */ + if($id == -1) { + /* New entry */ + mysql_query("INSERT INTO `reports_committee` (`users_id`,`reports_id`) + VALUES('{$_SESSION['users_uid']}','$reports_id');"); + echo mysql_error(); + $id = mysql_insert_id(); + } + + /* Update entry */ $category = $_POST['category']; $category_exist = $_POST['category_exist']; - $comment = mysql_escape_string(stripslashes($_POST['comment'])); + $comment = mysql_real_escape_string(stripslashes($_POST['comment'])); if($category_exist != '') $category = $category_exist; - $category = mysql_escape_string(stripslashes(trim($category))); + $category = mysql_real_escape_string(stripslashes(trim($category))); + + if($category == '') $category = 'default'; - if($category == '') { - $_SESSION['messages'][] = 'nocategory'; - header("Location: reports.php?edit=1"); - exit; - } - if($reports_id > 0) { + /* SFIAB report */ $type = $_POST['type']; $stock = $_POST['stock']; if(!array_key_exists($type, $report_options['type']['values'])) { - echo "Invalid format: type=$type"; + error_("Invalid format: type=$type"); exit; } if(!array_key_exists($stock, $report_stock)) { - echo "Invalid stock: stock=$stock"; + error_("Invalid stock: stock=$stock"); exit; } } else { + /* Old custom */ $type = ''; $stock = ''; } - mysql_query("INSERT INTO `reports_committee` - (`id`, `users_id` , `reports_id` , `category` , `comment` , `format` , `stock`) - VALUES ( - NULL , '{$_SESSION['users_uid']}', - '$reports_id', '$category', '$comment', - '$type', '$stock' );"); - $_SESSION['messages'][] = 'added'; - header("Location: reports.php?edit=1"); + mysql_query("UPDATE `reports_committee` SET + `category`='$category', + `comment`='$comment', + `format`='$type', + `stock`='$stock' + WHERE id='$id'"); + happy_("Saved"); exit; } //send the header - if($edit_mode == false) { - send_header("My Reports", - array("Committee Main" => "committee_main.php"), - "print/export_reports" - ); +send_header("My Reports", + array("Committee Main" => "committee_main.php"), + "print/export_reports" + ); - /* Send a greeting */ - echo i18n('Welcome to the new report interface. You can select and save specific reports under specific categories so you can always find the report you need without having to go through the list each time. To begin customizing this list, click on the "Click Here to edit your Report List" link at the bottom of this page. '); - echo i18n('The old report list is still available').' '.i18n('here').', but will be deleted in the summer of 2008'; - echo '

'; +/* Send a greeting */ +echo i18n('Welcome to the new report interface. You can select and save specific reports under specific categories so you can always find the report you need without having to go through the list each time. To begin customizing this list, click on the "Edit This List" button at the bottom of this page.'); +?> +

+ +'; - echo '
'; - echo ''.i18n('Click here when you are finished editing your report list').''; - echo '
'; - echo '
'; - } $last_category = ''; $x=0; - echo ""; + echo "
"; while($i = mysql_fetch_object($q)) { - $trclass = ($x % 2 == 0) ? "even" : "odd"; $x++; if($last_category != $i->category) { /* New category */ - echo '"; $last_category = $i->category; @@ -176,17 +261,26 @@ $name = $report_custom[-$i->reports_id]['name']; $url = $report_custom[-$i->reports_id]['custom_url']; } + $name = "$name"; - if($edit_mode == false) - $name = "$name"; - - echo "'; - +?> + + + + + +reports_id > 0) { echo '"; } echo "

'; + echo '

'; if($edit_mode == true) echo i18n('Category').': '; echo "{$i->category}

"; - - if($edit_mode == true) - echo "id}\">\"Remove "; - echo $name.'
comment?> + +
'; echo ''; @@ -198,220 +292,81 @@ } */ - echo "{$i->comment}
"; } + +?> + +
+"> +
+
+ + +
+

- if($edit_mode == false) { - echo '
'; - echo ''.i18n('Click here to edit your Report List').''; - - echo '
'; - echo "

".i18n("All Reports")."

"; - - /* Print all the reports in a pulldown menu for generation */ - echo "
"; - echo ""; - echo ""; - echo "
"; - echo "
"; - - send_footer(); - exit; - } - - echo '
'; - - ?> - - + +
+"> +"> + +
+'.i18n('Add a Report to your Report List').''; - echo "
"; - echo ""; - echo "\n"; - echo '"; - - echo ""; - - $option_keys = array('type','stock'); + + + +
+
'; - echo "
".i18n("Category").":"; - $q = mysql_query("SELECT DISTINCT category FROM reports_committee - WHERE users_id='{$_SESSION['users_uid']}' - ORDER BY category"); - - echo i18n("Existing Category").":
"; - echo i18n("OR New Category").": "; - echo "
+ + + + +$o) { if(!in_array($ok, $option_keys)) continue; echo ""; - echo ""; } - echo ""; - echo ""; +?> + + + + +
::
+ : +
{$o['desc']}:".i18n("Custom")."
".i18n("Comments").":"; - echo "
:
+
+ - - echo ''; - - - - echo '
'; - echo '

Descriptions for All Reports

'; - echo i18n('Click on the report number to try the report with the default report options before you add it to your Report List'); - echo '

'; - echo "\n"; - $x=0; - foreach(array_merge($reports, $report_custom) as $r) { - $trclass = ($x % 2 == 0) ? "even" : "odd"; - $x++; - echo ""; - if($r['custom_url'] == '') { - $url = "admin/reports_gen.php?id={$r['id']}"; - } else { - $url = $r['custom_url']; - } - echo ""; - echo ""; - } - -echo "
$x."; - - echo ""; - echo ""; - echo ""; - echo "
{$r['name']}Created By: {$r['creator']}
{$r['desc']}
"; - - echo "
"; + diff --git a/admin/reports_gen.php b/admin/reports_gen.php index e8688a8..3a7f2d7 100644 --- a/admin/reports_gen.php +++ b/admin/reports_gen.php @@ -87,7 +87,7 @@ echo "".i18n('Comment').":"; echo "{$i->comment}"; } else { - echo "".i18n('This report is NOT in your \'My Reports\' list.').""; + echo "".i18n('This report is NOT in your \'My Reports\' list.').""; } echo '
'; echo "

".i18n('Report Options')."

";