1,85 → 1,25 |
<?php |
|
include_once('includes/common.php'); |
Prolog(); |
|
$display = new template_handler('template'); |
$db->query("select category_id, category_name, category_comment, category_export_key" |
. " from telbook_categories order by category_name"); |
|
$display->add_template('header'); |
include('includes/menu.php'); |
$table = new Table(array('Name', 'Comment', 'Export Key', '')); |
$table->set_table_class('telbook list category_list'); |
|
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']; |
} |
} |
else { |
$category['CATEGORY_ID'] = ''; |
$category['CATEGORY_NAME'] = ''; |
$category['CATEGORY_COMMENT'] = ''; |
$category['CATEGORY_EXPORT_KEY'] = ''; |
} |
$display->add_variables($category); |
|
$display->add_template('telbook_category_edit'); |
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('telbook_categories_details.php?id=' . $line['category_id'], 'Edit'))); |
} |
else if(array_key_exists('delete', $_POST)) { |
$id = $_POST['id']; |
$db->query_params("delete from telbook_categories where category_id=$1", array($id)); |
$g_display->add_html_text($table->build()); |
$g_display->add_template('telbook_category_list_end'); |
|
header("Location: $PHP_SELF"); |
$display->add_text('Information deleted successfully'); |
} |
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); |
Epilog(); |
|
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)); |
} |
|
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"); |
|
$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 |