1,85 → 1,33 |
<?php |
|
include_once('includes/common.php'); |
Prolog(); |
|
$display = new template_handler('template'); |
$id = $_GET['id']; |
$category = array(); |
|
$display->add_template('header'); |
include('includes/menu.php'); |
if($id) { |
$db->query_params("select category_id, category_name, category_comment, category_export_key" |
. " from telbook_categories" |
. " where category_id=$1", array($id)); |
|
if(array_key_exists('edit', $_GET)) { |
$category = array(); |
|
if($_GET['edit']) { |
$db->query_params("select category_id, category_name, category_comment, category_export_key" |
. " from telbook_categories" |
. " where category_id=$1", array($_GET['edit'])); |
|
if($line = $db->fetch_row()) { |
$category['CATEGORY_ID'] = $line['category_id']; |
$category['CATEGORY_NAME'] = $line['category_name']; |
$category['CATEGORY_COMMENT'] = $line['category_comment']; |
$category['CATEGORY_EXPORT_KEY'] = $line['category_export_key']; |
} |
if($line = $db->fetch_row()) { |
$category['CATEGORY_ID'] = $line['category_id']; |
$category['CATEGORY_NAME'] = $line['category_name']; |
$category['CATEGORY_COMMENT'] = $line['category_comment']; |
$category['CATEGORY_EXPORT_KEY'] = $line['category_export_key']; |
} |
else { |
$category['CATEGORY_ID'] = ''; |
$category['CATEGORY_NAME'] = ''; |
$category['CATEGORY_COMMENT'] = ''; |
$category['CATEGORY_EXPORT_KEY'] = ''; |
} |
$display->add_variables($category); |
|
$display->add_template('telbook_category_edit'); |
} |
else if(array_key_exists('delete', $_POST)) { |
$id = $_POST['id']; |
$db->query_params("delete from telbook_categories where category_id=$1", array($id)); |
|
header("Location: $PHP_SELF"); |
$display->add_text('Information deleted successfully'); |
else { |
$category['CATEGORY_ID'] = ''; |
$category['CATEGORY_NAME'] = ''; |
$category['CATEGORY_COMMENT'] = ''; |
$category['CATEGORY_EXPORT_KEY'] = ''; |
} |
else if(array_key_exists('update', $_POST)) { |
$id = $_POST['id']; |
$category_name = $_POST['category_name']; |
$category_comment = $_POST['category_comment']; |
$category_export_key = ($_POST['category_export_key'] ? $_POST['category_export_key'] : NULL); |
$g_display->add_variables($category); |
|
if($id) { |
$db->query_params("update telbook_categories set" |
. " category_name=$2, category_comment=$3, category_export_key=$4" |
. " where category_id=$1", |
array($id, $category_name, $category_comment, $category_export_key)); |
} |
else { |
$db->query_params("insert into telbook_categories" |
. " (category_name, category_comment, category_export_key) values ($1, $2, $3)", |
array($category_name, $category_comment, $category_export_key)); |
} |
$g_display->add_template('telbook_category_edit'); |
|
header("Location: $PHP_SELF"); |
$display->add_text('Information saved successfully'); |
} |
else { |
$db->query("select category_id, category_name, category_comment, category_export_key" |
. " from telbook_categories order by category_name"); |
Epilog(); |
|
$table = new Table(array('Name', 'Comment', 'Export Key', '')); |
$table->set_table_class('telbook list category_list'); |
|
while($line = $db->fetch_row()) { |
$table->newrow(); |
$table->addcell($line['category_name']); |
$table->addcell($line['category_comment']); |
$table->addcell($line['category_export_key']); |
$table->addcell(array('class' => 'link', 'html' => |
display_link($PHP_SELF . '?edit=' . $line['category_id'], 'Edit'))); |
} |
$display->add_html_text($table->build()); |
$display->add_template('telbook_category_list_end'); |
} |
|
$display->add_template('footer'); |
echo $display; |
|
?> |
Property changes: |
Added: svn:mergeinfo |