Subversion Repositories general

Compare Revisions

Ignore whitespace Rev 1394 → Rev 1395

/asterisk-stats/trunk/telbook_export_list.php
3,10 → 3,10
include_once('includes/common.php');
Prolog();
 
$db->query("select export_id, export_name, export_comment"
$db->query("select export_id, export_name, export_type, export_comment"
. " from telbook_export order by upper(export_name), export_name");
 
$table = new Table(array('Name', 'Comment', ''));
$table = new Table(array('Name', 'Comment', '', ''));
$table->set_table_class('telbook list export_list');
 
while($line = $db->fetch_row()) {
15,6 → 15,14
$table->addcell($line['export_comment']);
$table->addcell(array('class' => 'link', 'html' =>
display_link('telbook_export_details.php?id=' . $line['export_id'], 'Edit')));
 
if($line['export_type']) {
$table->addcell(array('class' => 'link', 'html' =>
display_link('telbook_export.php?id=' . $line['export_id'], 'Export')));
}
else {
$table->addcell('');
}
}
$g_display->add_html_text($table->build());
$g_display->add_template('telbook_export_list_end');
/asterisk-stats/trunk/telbook_export.php
1,13 → 1,29
<?php
 
include_once('includes/common.php');
include_once('includes/export_types.php');
 
if($_GET['type'] == 'panasonic') {
$db->query("select person_name, category_export_key, entry_title, entry_value"
. " from telbook_persons p"
$id = $_GET['id'];
$db->query_params("select export_name, export_type from telbook_export where export_id=$1",
array($id));
if(!($line = $db->fetch_row())) {
die("Export id not found");
}
 
$rev_export_types = array_flip($export_types);
 
if($line['export_type'] == $rev_export_types['panasonic']) {
$db->query_params("select person_name, category_export_title, entry_title, entry_value,"
. " person_export_title"
. " from telbook_entries e"
. " join telbook_entries_export ee on ee.entry_id=e.entry_id"
. " left join telbook_persons p on p.person_id=e.entry_person"
. " left join telbook_persons_export pe on p.person_id=pe.person_id"
. " left join telbook_categories c on p.person_category=c.category_id"
. " left join telbook_entries e on p.person_id=e.entry_person"
. " order by person_name, entry_title, entry_value");
. " left join telbook_categories_export ce on ce.category_id=c.category_id"
. " where ee.export_id=$1"
. " order by person_name, entry_title, entry_value",
array($id));
 
header("Content-Type: text/plain");
echo "; Panasonic Communications Co., Ltd. Phonebook DECT Version 2.00\n";
16,8 → 32,10
 
while($line = $db->fetch_row()) {
if($line[entry_value]) {
$key_base = $line['person_name'] .
($line['entry_title'] ? "/" . $line['entry_title'] : '');
$key_base = ($line['person_export_title'] ? $line['person_export_title']
: $line['person_name']);
$key_base .= ($line['entry_title'] ? "/" . $line['entry_title'] : '');
 
$key = $key_base;
$count = 0;
while($keys[$key]) {
26,11 → 44,14
$keys[$key] = true;
 
echo '"' . $key . '",'
. ($line[category_export_key] ? $line[category_export_key] : 0)
. ($line[category_export_title] ? $line[category_export_title] : 0)
. ',' . $line[entry_value] . "\n";
}
 
}
}
else {
die("Unknown export type");
}
 
?>
/asterisk-stats/trunk/telbook_update.php
9,6 → 9,7
$db->query_params("delete from telbook_entries_export where entry_id"
. " in (select entry_id from telbook_entries where entry_person=$1)", array($id));
$db->query_params("delete from telbook_entries where entry_person=$1", array($id));
$db->query_params("delete from telbook_persons_export where person_id=$1", array($id));
$db->query_params("delete from telbook_persons where person_id=$1", array($id));
$db->commit_transaction();
 
43,8 → 44,23
$db->query_params("delete from telbook_entries_export where entry_id"
. " = (select entry_id from telbook_entries where entry_person=$1)", array($id));
$db->query_params("delete from telbook_entries where entry_person=$1", array($id));
$db->query_params("delete from telbook_persons_export where person_id=$1", array($id));
 
# save entries
foreach($_POST as $key => $value) {
if(substr($key, 0, strlen('export_title-')) == 'export_title-') {
$export_id = substr($key, strlen('export_title-'));
 
if($value) {
$db->query_params("insert into telbook_persons_export"
. " (export_id, person_id, person_export_title)"
. " values ($1, $2, $3)",
array($export_id, $id, $value));
}
}
}
 
# save entries
$entries_id = array();
foreach($_POST as $key => $value) {
if(substr($key, 0, strlen('entry_title-')) == 'entry_title-') {
/asterisk-stats/trunk/telbook_export_update.php
7,6 → 7,7
$id = $_POST['id'];
$db->begin_transaction();
$db->query_params("delete from telbook_categories_export where export_id=$1", array($id));
$db->query_params("delete from telbook_persons_export where export_id=$1", array($id));
$db->query_params("delete from telbook_entries_export where export_id=$1", array($id));
$db->query_params("delete from telbook_export where export_id=$1", array($id));
$db->commit_transaction();
15,20 → 16,21
$g_display->add_text('Information deleted successfully');
}
elseif(array_key_exists('update', $_POST)) {
$id = $_POST['id'];
$export_name = $_POST['export_name'];
$export_comment = $_POST['export_comment'];
$id = $_POST['id'];
$export_name = $_POST['export_name'];
$export_type = ($_POST['export_type'] ? $_POST['export_type'] : NULL);
$export_comment = $_POST['export_comment'];
 
if($id) {
$db->query_params("update telbook_export set"
. " export_name=$2, export_comment=$3"
. " export_name=$2, export_type=$3, export_comment=$4"
. " where export_id=$1",
array($id, $export_name, $export_comment));
array($id, $export_name, $export_type, $export_comment));
}
else {
$db->query_params("insert into telbook_export"
. " (export_name, export_comment) values ($1, $2)",
array($export_name, $export_comment));
. " (export_name, export_type, export_comment) values ($1, $2, $3)",
array($export_name, $export_type, $export_comment));
}
 
header("Location: telbook_export_list.php");
/asterisk-stats/trunk/telbook_details.php
134,8 → 134,23
}
$g_display->add_html_variables(array('CATEGORIES' => $categories_list));
 
# export targets
$export_table = new Table(array('Export Target', 'Export Title'));
$db->query_params("select ex.export_id, export_name, export_comment,"
. " pe.person_id, pe.person_export_title"
. " from telbook_export ex"
. " left join telbook_persons_export pe on pe.export_id=ex.export_id and pe.person_id=$1"
. " order by upper(export_name), export_name, person_id", array($id));
while($line = $db->fetch_row()) {
$export_table->newrow();
$export_table->addcell($line['export_name']);
$export_table->addcell(array('html' => display_input(
'text', 'export_title-' . $line['export_id'], $line['person_export_title'])));
}
 
# show
$g_display->add_template('telbook_details_begin');
$g_display->add_html_text($export_table->build());
$g_display->add_html_text($table->build());
$g_display->add_template('telbook_details_end');
 
/asterisk-stats/trunk/telbook_export_details.php
1,6 → 1,7
<?php
 
include_once('includes/common.php');
include_once('includes/export_types.php');
Prolog();
 
$id = $_GET['id'];
7,23 → 8,36
$export = array();
 
if($id) {
$db->query_params("select export_id, export_name, export_comment"
$db->query_params("select export_id, export_name, export_type, export_comment"
. " from telbook_export"
. " where export_id=$1", array($id));
 
if($line = $db->fetch_row()) {
$export['EXPORT_ID'] = $line['export_id'];
$export['EXPORT_NAME'] = $line['export_name'];
$export['EXPORT_COMMENT'] = $line['export_comment'];
$export['EXPORT_ID'] = $line['export_id'];
$export['EXPORT_NAME'] = $line['export_name'];
$export['EXPORT_TYPE'] = $line['export_type'];
$export['EXPORT_COMMENT'] = $line['export_comment'];
}
}
else {
$export['EXPORT_ID'] = '';
$export['EXPORT_NAME'] = '';
$export['EXPORT_COMMENT'] = '';
$export['EXPORT_ID'] = '';
$export['EXPORT_NAME'] = '';
$export['EXPORT_TYPE'] = '';
$export['EXPORT_COMMENT'] = '';
}
$g_display->add_variables($export);
 
# types select box
$types_list = "\n\t\t\t\t<option value=''>(none)</option>";
asort($export_types);
foreach($export_types as $key => $value) {
$types_list .= "\n\t\t\t\t<option value='"
. htmlspecialchars($key) . "'"
. ($key == $export['EXPORT_TYPE'] ? " selected" : "")
. ">" . htmlspecialchars($value) . "</option>";
}
$g_display->add_html_variables(array('TYPES' => $types_list));
 
$g_display->add_template('telbook_export_details');
 
Epilog();
/asterisk-stats/trunk/includes/export_types.php
0,0 → 1,7
<?
 
$export_types = array(
1 => 'panasonic',
);
 
?>
/asterisk-stats/trunk/tables.sql
44,6 → 44,7
create table telbook_export (
export_id serial primary key,
export_name varchar(255) not null unique,
export_type integer,
export_comment text
);
 
72,6 → 73,16
foreign key (person_category) references telbook_categories(category_id)
);
 
create table telbook_persons_export (
export_id integer,
person_id integer,
person_export_title varchar(255),
 
primary key (export_id, person_id),
foreign key (export_id) references telbook_export(export_id),
foreign key (person_id) references telbook_persons(person_id)
);
 
create table telbook_entries (
entry_id serial primary key,
entry_value varchar(255) not null unique,
/asterisk-stats/trunk/template/telbook_export_details.tpl
6,6 → 6,13
<td><input type=text name=export_name value="${EXPORT_NAME}"></td>
</tr>
<tr>
<th>Export Type</th>
<td>
<select name=export_type>${TYPES}
</select>
</td>
</tr>
<tr>
<th>Comment</th>
<td><textarea name=export_comment>${EXPORT_COMMENT}</textarea></td>
</tr>
/asterisk-stats/trunk/template/telbook_list_end.tpl
2,8 → 2,3
<p><a href="telbook_categories_list.php">Categories</a></p>
<p><a href="telbook_export_list.php">Export Targets</a></p>
 
<p>Export into format:
<ul>
<li><a href="telbook_export.php?type=panasonic">Panasonic</a></li>
</ul>