Copyright (C) 2007 James Grant Copyright (C) 2007 David 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. */ ?> prepare("DELETE FROM reports_committee WHERE users_id='{$_SESSION['users_uid']}' AND id='$id'"); $stmt->execute(); happy_('Report successfully removed'); exit; case 'reload': $edit_mode = true; $reports_id = intval(get_value_from_array($_POST, 'reports_id')); exit; case 'load_report': $id = intval($_GET['id']); /* Load report */ if($id == -1) { $reports_id = intval($_GET['reports_id']); $report = report_load($reports_id); $ret['id'] = -1; $ret['reports_id'] = $reports_id; $ret['type'] = $report['option']['type']; $ret['stock'] = $report['option']['stock']; $ret['comment'] = $report['desc']; $ret['name'] = $report['name']; $ret['category'] = ''; } else { $q = $pdo->prepare("SELECT * FROM reports_committee WHERE id='$id'"); $ret = $q->fetch(PDO::FETCH_ASSOC); $ret['type'] = $ret['format']; } /* Load available categories */ $q = $pdo->prepare("SELECT DISTINCT category FROM reports_committee WHERE users_id='{$_SESSION['users_uid']}' ORDER BY category"); $q->execute(); while($i = $q->fetch(PDO::FETCH_OBJ)) $ret['cat'][] = $i->category; echo json_encode($ret); exit; case 'save': echo "POST: "; print_r($_POST); $id = intval($_POST['id']); $reports_id = intval($_POST['reports_id']); if($id == -1) { /* New entry */ $stmt = $pdo->prepare("INSERT INTO `reports_committee` (`users_id`,`reports_id`) VALUES('{$_SESSION['users_uid']}','$reports_id');"); $stmt->execute(); show_pdo_errors_if_any($pdo); $id = $pdo->lastInsertId(); } /* Update entry */ $category = $_POST['category']; $category_exist = $_POST['category_exist']; $comment = stripslashes($_POST['comment']); if($category_exist != '') $category = $category_exist; $category = stripslashes(trim($category)); if($category == '') $category = 'default'; if($reports_id > 0) { /* SFIAB report */ $type = $_POST['type']; $stock = $_POST['stock']; if(!array_key_exists($type, $report_options['type']['values'])) { error_("Invalid format: type=$type"); exit; } if(!array_key_exists($stock, $report_stock)) { error_("Invalid stock: stock=$stock"); exit; } } else { /* Old custom */ $type = ''; $stock = ''; } $stmt = $pdo->prepare("UPDATE `reports_committee` SET `category`='$category', `comment`='$comment', `format`='$type', `stock`='$stock' WHERE id='$id'"); $stmt->execute(); happy_("Saved"); exit; } //send the header 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 "Edit This List" button at the bottom of this page.'); ?>

prepare("SELECT reports_committee.*,reports.name FROM reports_committee LEFT JOIN reports ON reports.id=reports_committee.reports_id WHERE users_id='{$_SESSION['users_uid']}' ORDER BY category,id"); $q->execute(); show_pdo_errors_if_any($pdo); if($q->rowCount()== 0) { echo i18n('You have no reports saved'); } else { $last_category = ''; $x=0; echo ""; while($i = $q->fetch(PDO::FETCH_OBJ)) { $x++; if($last_category != $i->category) { /* New category */ echo '"; $last_category = $i->category; } if($i->reports_id > 0) { // $url = "admin/reports_gen.php?id={$i->reports_id}&show_options=1"; $name = "reports_id})\">{$i->name}"; } else { $name = "reports_id]['custom_url']}\"> {$report_custom[-$i->reports_id]['name']}"; } ?> reports_id > 0) { echo ''; } */ } echo "

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

comment?>
'; echo ''; echo i18n('Format').": {$i->format}, "; echo i18n('Paper').": {$report_stock[$i->stock]['name']}, "; echo i18n('Year').": {$config['FAIRYEAR']}"; echo ''; echo '
"; } ?>
">

$r) { $r['id'] = -$id; $reports[-$id] = $r; } ?>


"> ">