/asterisk-stats/trunk/telbook_export_list.php |
---|
File deleted |
/asterisk-stats/trunk/telbook_export_update.php |
---|
File deleted |
/asterisk-stats/trunk/telbook_export_details.php |
---|
File deleted |
/asterisk-stats/trunk/tables.sql |
---|
41,28 → 41,13 |
userfield varchar(255) |
); |
create table telbook_export ( |
export_id serial primary key, |
export_name varchar(255) not null unique, |
export_comment text |
); |
create table telbook_categories ( |
category_id serial primary key, |
category_name varchar(255) not null unique, |
category_export_key integer, |
category_comment text |
); |
create table telbook_categories_export ( |
export_id integer, |
category_id integer, |
category_export_title varchar(255), |
primary key (export_id, category_id), |
foreign key (export_id) references telbook_export(export_id), |
foreign key (category_id) references telbook_categories(category_id) |
); |
create table telbook_persons ( |
person_id serial primary key, |
person_name varchar(255) not null unique, |
82,12 → 67,3 |
foreign key (entry_person) references telbook_persons(person_id) |
); |
create table telbook_entries_export ( |
export_id integer, |
entry_id integer, |
primary key (export_id, entry_id), |
foreign key (export_id) references telbook_export(export_id), |
foreign key (entry_id) references telbook_entries(entry_id) |
); |
/asterisk-stats/trunk/includes/display.php |
---|
90,7 → 90,7 |
protected $rowid = 0; |
protected $rows = array(); |
protected $row_styles = array(); |
protected $header_rows = array(); |
protected $hdr = array(); |
#Define an array to store the stylesheet classes for each row |
protected $table_class = ''; |
97,11 → 97,12 |
protected $header_class = ''; |
function __construct($header = array()) { |
array_push($this->header_rows, $header); |
$this->hdr = $header; |
} |
public function destroy() { |
$this->header_rows = array(); |
$this->hdr = array(); |
$this->sc = array(); |
$this->rows = array(); |
} |
113,10 → 114,6 |
$this->rows[] = array(); |
} |
public function add_header_row($row) { |
array_push($this->header_rows, $row); |
} |
public function addcell($data) { |
$key = count($this->rows) - 1; |
if($key < 0) { |
172,19 → 169,14 |
$output = "<$tag>\n"; |
#Display the header |
if(count($this->header_rows) > 0) { |
$output .= "\t<thead>\n"; |
if($this->hdr) { |
$output .= "\t<thead>\n\t\t<tr>\n"; |
foreach($this->header_rows as $row) { |
$output .= "\t\t<tr>\n"; |
foreach($row as $cell) { |
foreach($this->hdr as $cell) { |
$output .= $this->build_cell($cell, 'th'); |
} |
$output .= "\t\t</tr>\n"; |
} |
$output .= "\t</thead>\n"; |
$output .= "\t\t</tr>\n\t</thead>\n"; |
} |
$output .= "\t<tbody>\n"; |
205,20 → 197,9 |
} |
} |
function display_input($type, $name, $value = NULL, $additional = NULL) { |
return '<input type="' . htmlspecialchars($type) . '" name="' . htmlspecialchars($name) . '"' |
. ($value == NULL ? '' : ' value="' . htmlspecialchars($value) . '"') |
. ($additional == NULL ? '' : " $additional") |
. '>'; |
function display_input($type, $name, $value = '') { |
return '<input type="' . htmlspecialchars($type) . '" name="' |
. htmlspecialchars($name) . '" value="' . htmlspecialchars($value) . "\">"; |
} |
function ellipsis($str, $len) { |
if(strlen($str) <= $len) { |
return htmlspecialchars($str); |
} |
else { |
return (htmlspecialchars(substr($str, 0, $len)) . '…'); |
} |
} |
?> |
/asterisk-stats/trunk/telbook_update.php |
---|
6,8 → 6,6 |
if(array_key_exists('delete', $_POST)) { |
$id = $_POST['id']; |
$db->begin_transaction(); |
$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 where person_id=$1", array($id)); |
$db->commit_transaction(); |
40,12 → 38,7 |
} |
} |
$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)); |
# save entries |
$entries_id = array(); |
foreach($_POST as $key => $value) { |
if(substr($key, 0, strlen('entry_title-')) == 'entry_title-') { |
$entry_count = substr($key, strlen('entry_title-')); |
59,35 → 52,10 |
. " (entry_value, entry_title, entry_person, entry_comment)" |
. " values ($1, $2, $3, $4)", |
array($entry_value, $entry_title, $id, $entry_comment)); |
$db->query("select currval('telbook_entries_entry_id_seq')"); |
if($line = $db->fetch_row_idx()) { |
$entries_id[$entry_count] = $line[0]; |
} |
} |
} |
} |
# save entries export targets |
foreach($_POST as $key => $value) { |
if(substr($key, 0, strlen('entry_export-')) == 'entry_export-') { |
$substr_len = strlen('entry_export-'); |
$pos = strpos($key, '-', $substr_len); |
if($pos) { |
$entry_count = substr($key, $substr_len, $pos - $substr_len); |
$export_id = substr($key, $pos+1); |
$entry_id = $entries_id[$entry_count]; |
if($export_id && $entry_id) { |
$db->query_params("insert into telbook_entries_export" |
. " (export_id, entry_id)" |
. " values ($1, $2)", |
array($export_id, $entry_id)); |
} |
} |
} |
} |
$db->commit_transaction(); |
header("Location: telbook_list.php"); |
/asterisk-stats/trunk/originate_form.php |
---|
10,8 → 10,7 |
$db->query_params("select entry_title, entry_value, person_name" |
. " from telbook_entries join telbook_persons on person_id=entry_person" |
. " where entry_title=$1" |
. " order by upper(person_name), person_name," |
. " upper(entry_title), entry_title, upper(entry_value), entry_value", |
. " order by person_name, entry_title, entry_value", |
array($g_config['originate_src'])); |
$src_list = ""; |
/asterisk-stats/trunk/template/telbook_export_details.tpl |
---|
File deleted |
/asterisk-stats/trunk/template/telbook_category_details_begin.tpl |
---|
File deleted |
/asterisk-stats/trunk/template/telbook_category_details_end.tpl |
---|
File deleted |
/asterisk-stats/trunk/template/telbook_export_list_end.tpl |
---|
File deleted |
/asterisk-stats/trunk/template/telbook_category_details.tpl |
---|
0,0 → 1,25 |
<form method="POST" action="telbook_categories_update.php"> |
<input type=hidden name=id value="${CATEGORY_ID}"> |
<table class="telbook edit"> |
<tr> |
<th>Name</th> |
<td><input type=text name=category_name value="${CATEGORY_NAME}"></td> |
</tr> |
<tr> |
<th>Comment</th> |
<td><textarea name=category_comment>${CATEGORY_COMMENT}</textarea></td> |
</tr> |
<tr> |
<th>Export Key</th> |
<td><input type=text name=category_export_key value="${CATEGORY_EXPORT_KEY}"></td> |
</tr> |
<tr class="buttons"> |
<td colspan=2> |
<input type=reset name="reset" value="Reset"> |
<input type=submit name=update value="Update"> |
<input type=submit name=delete value="Delete"> |
</td> |
</tr> |
</table> |
</form> |
Property changes: |
Added: svn:mergeinfo |
/asterisk-stats/trunk/template/telbook_list_end.tpl |
---|
1,9 → 1,8 |
<p><a href="telbook_details.php">New person</a></p> |
<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> |
<li><a href="telbook_export.php?type=panasonic">Panasonik</a></li> |
</ul> |
/asterisk-stats/trunk/telbook_list.php |
---|
8,8 → 8,7 |
. " from telbook_persons p" |
. " 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 upper(person_name), person_name," |
. " upper(entry_title), entry_title, upper(entry_value), entry_value"); |
. " order by person_name, entry_title, entry_value"); |
$table = new Table(array('Name', 'Category', 'Type', 'Number', '', '')); |
$table->set_table_class('telbook list'); |
/asterisk-stats/trunk/telbook_categories_details.php |
---|
7,7 → 7,7 |
$category = array(); |
if($id) { |
$db->query_params("select category_id, category_name, category_comment" |
$db->query_params("select category_id, category_name, category_comment, category_export_key" |
. " from telbook_categories" |
. " where category_id=$1", array($id)); |
15,6 → 15,7 |
$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 { |
21,28 → 22,12 |
$category['CATEGORY_ID'] = ''; |
$category['CATEGORY_NAME'] = ''; |
$category['CATEGORY_COMMENT'] = ''; |
$category['CATEGORY_EXPORT_KEY'] = ''; |
} |
$g_display->add_variables($category); |
# export targets |
$table = new Table(array('Export Target', 'Export Title')); |
$db->query_params("select ex.export_id, export_name, export_comment," |
. " ce.category_id, ce.category_export_title" |
. " from telbook_export ex" |
. " left join telbook_categories_export ce on ce.export_id=ex.export_id and ce.category_id=$1" |
. " order by upper(export_name), export_name, category_id", array($id)); |
while($line = $db->fetch_row()) { |
$table->newrow(); |
$table->addcell($line['export_name']); |
$table->addcell(array('html' => display_input( |
'text', 'export_title-' . $line['export_id'], $line['category_export_title']))); |
} |
$g_display->add_template('telbook_category_details'); |
# show |
$g_display->add_template('telbook_category_details_begin'); |
$g_display->add_html_text($table->build()); |
$g_display->add_template('telbook_category_details_end'); |
Epilog(); |
?> |
/asterisk-stats/trunk/telbook_details.php |
---|
5,126 → 5,63 |
$id = $_GET['id']; |
# export targets |
$export_targets = array(); |
$export_header = array(); |
$db->query("select export_id, export_name, export_comment from telbook_export" |
. " order by upper(export_name), export_name"); |
while($line = $db->fetch_row()) { |
array_push($export_targets, array( |
'export_id' => $line['export_id'], |
'export_name' => $line['export_name'], |
'export_comment' => $line['export_comment'], |
)); |
array_push($export_header, array( |
'html' => ellipsis($line['export_name'], 1), |
'comment' => $line['export_name'], |
)); |
} |
# person and entries |
$person = NULL; |
$table = new Table(array( |
array('text' => 'Type', 'rowspan' => 2), |
array('text' => 'Number', 'rowspan' => 2), |
array('text' => 'Comment', 'rowspan' => 2), |
array('text' => 'Export', 'colspan' => count($export_targets)), |
)); |
$table->add_header_row($export_header); |
$person = array(); |
$table = new Table(array('Type', 'Number', 'Comment')); |
$table->set_table_class('telbook list'); |
$entry_count = 0; |
function add_entry_inputs($table, $entry_count, $entry) |
function add_entry_inputs($table, $entry_count, $entry_title, $entry_value, $entry_comment) |
{ |
global $export_targets; |
++$entry_count; |
$table->newrow(); |
$table->addcell(array('html' => display_input( |
'text', 'entry_title-' . $entry_count, $entry['title']))); |
'text', 'entry_title-' . $entry_count, $entry_title))); |
$table->addcell(array('html' => display_input( |
'text', 'entry_value-' . $entry_count, $entry['value']))); |
'text', 'entry_value-' . $entry_count, $entry_value))); |
$table->addcell(array('html' => display_input( |
'text', 'entry_comment-' . $entry_count, $entry['comment']))); |
'text', 'entry_comment-' . $entry_count, $entry_comment))); |
foreach($export_targets as $target) { |
$table->addcell(array('html' => display_input( |
'checkbox', 'entry_export-' . $entry_count . '-' . $target['export_id'], |
NULL, |
($entry['export'][$target['export_id']] ? 'checked' : NULL)))); |
} |
return $entry_count; |
} |
if($id) { |
$db->query_params("select person_id, person_name, person_comment, person_category," |
. " e.entry_id, entry_title, entry_value, entry_comment, export_id" |
. " entry_title, entry_value, entry_comment" |
. " from telbook_persons p" |
. " left join telbook_entries e on p.person_id=e.entry_person" |
. " left join telbook_entries_export ex on e.entry_id=ex.entry_id" |
. " where person_id=$1" |
. " order by upper(person_name), person_name, upper(entry_title), entry_title, export_id", |
array($id)); |
. " where person_id=$1", array($id)); |
$entry = NULL; |
$first_line = true; |
while($line = $db->fetch_row()) { |
if($person == NULL) { |
$person = array( |
'PERSON_ID' => $line['person_id'], |
'PERSON_NAME' => $line['person_name'], |
'PERSON_COMMENT' => $line['person_comment'], |
'PERSON_CATEGORY' => $line['person_category'], |
); |
if($first_line) { |
$person['PERSON_ID'] = $line['person_id']; |
$person['PERSON_NAME'] = $line['person_name']; |
$person['PERSON_COMMENT'] = $line['person_comment']; |
$person['PERSON_CATEGORY'] = $line['person_category']; |
$first_line = false; |
} |
if($line['entry_value']) { |
if($entry != NULL && $entry['id'] != $line['entry_id']) { |
$entry_count = add_entry_inputs($table, $entry_count, $entry); |
$entry = NULL; |
$entry_count = add_entry_inputs($table, $entry_count, |
$line['entry_title'], $line['entry_value'], $line['entry_comment']); |
} |
if($entry == NULL) { |
$entry = array( |
'id' => $line['entry_id'], |
'title' => $line['entry_title'], |
'value' => $line['entry_value'], |
'comment' => $line['entry_comment'], |
'export' => array(), |
); |
} |
$entry['export'][$line['export_id']] = true; |
} |
} |
# show the last one |
if($entry != NULL) { |
$entry_count = add_entry_inputs($table, $entry_count, $entry); |
} |
} |
else { |
$person = array( |
'PERSON_ID' => '', |
'PERSON_NAME' => '', |
'PERSON_COMMENT' => '', |
'PERSON_CATEGORY' => '', |
); |
$person['PERSON_ID'] = ''; |
$person['PERSON_NAME'] = ''; |
$person['PERSON_COMMENT'] = ''; |
$person['PERSON_CATEGORY'] = ''; |
} |
$g_display->add_variables($person); |
for($i = 0; $i < 5; ++$i) { |
$entry_count = add_entry_inputs($table, $entry_count, array( |
'id' => '', |
'title' => '', |
'value' => '', |
'comment' => '', |
'export' => array(), |
)); |
$entry_count = add_entry_inputs($table, $entry_count, '', '', ''); |
} |
# categories select box |
$db->query("select category_id, category_name from telbook_categories" |
. " order by upper(category_name), category_name"); |
$db->query("select category_id, category_name from telbook_categories order by category_name"); |
$categories_list = "\n\t\t\t\t<option value=''>(none)</option>"; |
while($line = $db->fetch_row()) { |
$categories_list .= "\n\t\t\t\t<option value='" |
/asterisk-stats/trunk/telbook_categories_update.php |
---|
5,12 → 5,7 |
if(array_key_exists('delete', $_POST)) { |
$id = $_POST['id']; |
$db->begin_transaction(); |
$db->query_params("update telbook_persons set person_category=NULL" |
. " where person_category=$1", array($id)); |
$db->query_params("delete from telbook_categories_export where category_id=$1", array($id)); |
$db->query_params("delete from telbook_categories where category_id=$1", array($id)); |
$db->commit_transaction(); |
header("Location: telbook_categories_list.php"); |
$g_display->add_text('Information deleted successfully'); |
19,44 → 14,20 |
$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); |
$db->begin_transaction(); |
if($id) { |
$db->query_params("update telbook_categories set" |
. " category_name=$2, category_comment=$3" |
. " category_name=$2, category_comment=$3, category_export_key=$4" |
. " where category_id=$1", |
array($id, $category_name, $category_comment)); |
array($id, $category_name, $category_comment, $category_export_key)); |
} |
else { |
$db->query_params("insert into telbook_categories" |
. " (category_name, category_comment) values ($1, $2)", |
array($category_name, $category_comment)); |
$db->query("select currval('telbook_categories_category_id_seq')"); |
if($line = $db->fetch_row_idx()) { |
$id = $line[0]; |
. " (category_name, category_comment, category_export_key) values ($1, $2, $3)", |
array($category_name, $category_comment, $category_export_key)); |
} |
} |
$db->query_params("delete from telbook_categories_export where category_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_categories_export" |
. " (export_id, category_id, category_export_title)" |
. " values ($1, $2, $3)", |
array($export_id, $id, $value)); |
} |
} |
} |
$db->commit_transaction(); |
header("Location: telbook_categories_list.php"); |
$g_display->add_text('Information saved successfully'); |
} |
/asterisk-stats/trunk/telbook_categories_list.php |
---|
3,10 → 3,10 |
include_once('includes/common.php'); |
Prolog(); |
$db->query("select category_id, category_name, category_comment" |
. " from telbook_categories order by upper(category_name), category_name"); |
$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', '')); |
$table = new Table(array('Name', 'Comment', 'Export Key', '')); |
$table->set_table_class('telbook list category_list'); |
while($line = $db->fetch_row()) { |
13,6 → 13,7 |
$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'))); |
} |