/asterisk-stats/trunk/includes/display.php |
---|
78,11 → 78,8 |
} |
function display_link($url, $label) { |
if(!$label) { |
$label = $url; |
} |
return '<A HREF="' . htmlspecialchars($url) . '">' . htmlspecialchars($label) . '</a>'; |
return '<a href="' . htmlspecialchars($url) . '">' |
. ($label ? htmlspecialchars($label) : ' ') . '</a>'; |
} |
class Table { |
/asterisk-stats/trunk/template/telbook_export_details.tpl |
---|
File deleted |
/asterisk-stats/trunk/template/telbook_export_details_end.tpl |
---|
0,0 → 1,12 |
</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_export_details_begin.tpl |
---|
0,0 → 1,21 |
<form method="POST" action="telbook_export_update.php"> |
<input type=hidden name=id value="${EXPORT_ID}"> |
<table class="telbook edit"> |
<tr> |
<th>Name</th> |
<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> |
<tr> |
<td colspan=2> |
Property changes: |
Added: svn:mergeinfo |
/asterisk-stats/trunk/template/telbook_category_list_end.tpl |
---|
1,3 → 1,3 |
<p><a href="telbook_categories_details.php?edit=">New category</a></p> |
<p><a href="telbook_categories_details.php">New category</a></p> |
<p><a href="telbook_list.php">Back to tel. book</a></p> |
/asterisk-stats/trunk/template/telbook_export_list_end.tpl |
---|
1,3 → 1,3 |
<p><a href="telbook_export_details.php?edit=">New export target</a></p> |
<p><a href="telbook_export_details.php">New export target</a></p> |
<p><a href="telbook_list.php">Back to tel. book</a></p> |
/asterisk-stats/trunk/telbook_list.php |
---|
15,7 → 15,9 |
'export_comment' => $line['export_comment'], |
)); |
array_push($export_header, array( |
'html' => ellipsis($line['export_name'], 1), |
'html' => '<a href="' . htmlspecialchars( |
'telbook_export_details.php?id=' . $line['export_id']) . '">' |
. ellipsis($line['export_name'], 1), |
'comment' => $line['export_name'], |
)); |
} |
32,12 → 34,16 |
if($new_person) { |
$table->addcell(array( |
'text' => $person['person_name'], |
'html' => display_link('telbook_details.php?id=' |
. $person['person_id'], $person['person_name']), |
'comment' => $person['person_comment'], |
'rowspan' => count($person['entries']), |
)); |
$table->addcell(array( |
'text' => $person['category_name'], |
'html' => ($person['category_id'] |
? display_link('telbook_categories_details.php?id=' |
. $person['category_id'], $person['category_name']) |
: ' '), |
'comment' => $person['category_comment'], |
'rowspan' => count($person['entries']), |
)); |
75,7 → 81,7 |
} |
} |
$db->query("select person_id, person_name, person_comment, category_name," |
$db->query("select person_id, person_name, person_comment, category_id, category_name," |
. " category_comment, e.entry_id, entry_title, entry_value, entry_comment, export_id" |
. " from telbook_persons p" |
. " left join telbook_categories c on p.person_category=c.category_id" |
86,10 → 92,12 |
$table = new Table(array( |
array('text' => 'Name', 'rowspan' => 2), |
array('text' => 'Category', 'rowspan' => 2), |
array('html' => display_link('telbook_categories_list.php', 'Category'), |
'rowspan' => 2), |
array('text' => 'Type', 'rowspan' => 2), |
array('text' => 'Number', 'rowspan' => 2), |
array('text' => 'Export', 'colspan' => count($export_targets)), |
array('html' => display_link('telbook_export_list.php', 'Export'), |
'colspan' => count($export_targets)), |
array('text' => '', 'rowspan' => 2), |
array('text' => '', 'rowspan' => 2), |
)); |
106,6 → 114,7 |
'person_id' => $line['person_id'], |
'person_name' => $line['person_name'], |
'person_comment' => $line['person_comment'], |
'category_id' => $line['category_id'], |
'category_name' => $line['category_name'], |
'category_comment' => $line['category_comment'], |
'entries' => array(), |
114,7 → 123,6 |
} |
if($entry == NULL || $entry['entry_id'] != $line['entry_id']) { |
$export = array(); |
$entry = array( |
'entry_id' => $line['entry_id'], |
'entry_title' => $line['entry_title'], |
/asterisk-stats/trunk/telbook_export_list.php |
---|
11,7 → 11,8 |
while($line = $db->fetch_row()) { |
$table->newrow(); |
$table->addcell($line['export_name']); |
$table->addcell(array('class' => 'link', 'html' => |
display_link('telbook_export_details.php?id=' . $line['export_id'], $line['export_name']))); |
$table->addcell($line['export_comment']); |
$table->addcell(array('class' => 'link', 'html' => |
display_link('telbook_export_details.php?id=' . $line['export_id'], 'Edit'))); |
/asterisk-stats/trunk/telbook_categories_list.php |
---|
11,7 → 11,9 |
while($line = $db->fetch_row()) { |
$table->newrow(); |
$table->addcell($line['category_name']); |
$table->addcell(array('class' => 'link', 'html' => |
display_link('telbook_categories_details.php?id=' . $line['category_id'], |
$line['category_name']))); |
$table->addcell($line['category_comment']); |
$table->addcell(array('class' => 'link', 'html' => |
display_link('telbook_categories_details.php?id=' . $line['category_id'], 'Edit'))); |
/asterisk-stats/trunk/telbook_export_update.php |
---|
21,7 → 21,11 |
$export_type = ($_POST['export_type'] ? $_POST['export_type'] : NULL); |
$export_comment = $_POST['export_comment']; |
$db->begin_transaction(); |
if($id) { |
$db->query_params("delete from telbook_entries_export where export_id=$1", array($id)); |
$db->query_params("delete from telbook_persons_export where export_id=$1", array($id)); |
$db->query_params("update telbook_export set" |
. " export_name=$2, export_type=$3, export_comment=$4" |
. " where export_id=$1", |
31,8 → 35,41 |
$db->query_params("insert into telbook_export" |
. " (export_name, export_type, export_comment) values ($1, $2, $3)", |
array($export_name, $export_type, $export_comment)); |
$db->query("select currval('telbook_export_export_id_seq')"); |
if($line = $db->fetch_row_idx()) { |
$id = $line[0]; |
} |
} |
# save persons |
foreach($_POST as $key => $value) { |
if($value) { |
if(substr($key, 0, strlen('person_title-')) == 'person_title-') { |
$person_id = substr($key, strlen('person_title-')); |
$db->query_params("insert into telbook_persons_export" |
. " (export_id, person_id, person_export_title)" |
. " values ($1, $2, $3)", |
array($id, $person_id, $value)); |
} |
} |
} |
# save entries |
foreach($_POST as $key => $value) { |
if(substr($key, 0, strlen('entry-')) == 'entry-') { |
$entry_id = substr($key, strlen('entry-')); |
$db->query_params("insert into telbook_entries_export" |
. " (export_id, entry_id)" |
. " values ($1, $2)", |
array($id, $entry_id)); |
} |
} |
$db->commit_transaction(); |
header("Location: telbook_export_list.php"); |
$g_display->add_text('Information saved successfully'); |
} |
/asterisk-stats/trunk/telbook_export_details.php |
---|
38,8 → 38,99 |
} |
$g_display->add_html_variables(array('TYPES' => $types_list)); |
$g_display->add_template('telbook_export_details'); |
# person and entries |
function add_person($table, $person) |
{ |
if(!$person) return; |
$new_person = true; |
foreach($person['entries'] as $entry) { |
$table->newrow(); |
if($new_person) { |
$table->addcell(array( |
'text' => $person['person_name'], |
'comment' => $person['person_comment'], |
'rowspan' => count($person['entries']), |
)); |
$table->addcell(array( |
'html' => display_input( |
'text', 'person_title-' . $person['person_id'], |
$person['export_title']), |
'rowspan' => count($person['entries']), |
)); |
$table->addcell(array( |
'text' => $person['category_name'], |
'comment' => $person['category_comment'], |
'rowspan' => count($person['entries']), |
)); |
} |
$table->addcell(array( |
'text' => $entry['entry_title'], |
'comment' => $entry['entry_comment'], |
)); |
$table->addcell(array( |
'text' => $entry['entry_value'], |
'comment' => $entry['entry_comment'], |
)); |
$table->addcell(array('html' => display_input( |
'checkbox', 'entry-' . $entry['entry_id'], |
NULL, |
($entry['export_id'] ? 'checked' : NULL)))); |
$new_person = false; |
} |
} |
$person = NULL; |
$table = new Table(array('Name', 'Export Label', 'Category', 'Type', 'Number', 'Include')); |
$table->set_table_class('telbook list'); |
$db->query_params("select p.person_id, person_name, person_comment, person_export_title," |
. " category_name, category_comment," |
. " e.entry_id, entry_title, entry_value, entry_comment," |
. " ex.export_id" |
. " from telbook_persons p" |
. " left join telbook_persons_export pe on p.person_id=pe.person_id and pe.export_id=$1" |
. " left join telbook_categories c on p.person_category=c.category_id" |
. " 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 and ex.export_id=$1" |
. " order by upper(person_name), person_name," |
. " upper(entry_title), entry_title, upper(entry_value), entry_value, export_id", |
array($id)); |
$person = NULL; |
while($line = $db->fetch_row()) { |
if($person == NULL || $line['person_id'] != $person['person_id']) { |
add_person($table, $person); |
$person = array( |
'person_id' => $line['person_id'], |
'person_name' => $line['person_name'], |
'person_comment' => $line['person_comment'], |
'export_title' => $line['person_export_title'], |
'category_name' => $line['category_name'], |
'category_comment' => $line['category_comment'], |
'entries' => array(), |
); |
} |
array_push($person['entries'], array( |
'entry_id' => $line['entry_id'], |
'entry_title' => $line['entry_title'], |
'entry_value' => $line['entry_value'], |
'entry_comment' => $line['entry_comment'], |
'export_id' => $line['export_id'], |
)); |
} |
add_person($table, $person); |
$g_display->add_template('telbook_export_details_begin'); |
$g_display->add_html_text($table->build()); |
$g_display->add_template('telbook_export_details_end'); |
Epilog(); |
?> |
/asterisk-stats/trunk/telbook_categories_update.php |
---|
23,6 → 23,10 |
$db->begin_transaction(); |
if($id) { |
$db->query_params("delete from telbook_categories_export where category_id=$1", array($id)); |
$db->query_params("update telbook_persons set person_category=NULL" |
. " where person_category=$1", array($id)); |
$db->query_params("update telbook_categories set" |
. " category_name=$2, category_comment=$3" |
. " where category_id=$1", |
39,9 → 43,7 |
} |
} |
$db->query_params("delete from telbook_categories_export where category_id=$1", array($id)); |
# save entries |
# save export targets |
foreach($_POST as $key => $value) { |
if(substr($key, 0, strlen('export_title-')) == 'export_title-') { |
$export_id = substr($key, strlen('export_title-')); |
55,6 → 57,17 |
} |
} |
# save persons |
foreach($_POST as $key => $value) { |
if(substr($key, 0, strlen('person-')) == 'person-') { |
$person_id = substr($key, strlen('person-')); |
$db->query_params("update telbook_persons set person_category=$1" |
. " where person_id=$2", |
array($id, $person_id)); |
} |
} |
$db->commit_transaction(); |
header("Location: telbook_categories_list.php"); |
/asterisk-stats/trunk/telbook_categories_details.php |
---|
33,14 → 33,40 |
. " 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_link('telbook_export_details.php?id=' |
. $line['export_id'], $line['export_name']))); |
$table->addcell(array('html' => display_input( |
'text', 'export_title-' . $line['export_id'], $line['category_export_title']))); |
} |
# persons |
$person = NULL; |
$persons_table = new Table(array('Name', 'Include')); |
$persons_table->set_table_class('telbook list'); |
$db->query_params("select person_id, person_name, person_comment, category_id" |
. " from telbook_persons p" |
. " left join telbook_categories c on p.person_category=c.category_id and c.category_id=$1" |
. " order by upper(person_name), person_name", |
array($id)); |
while($line = $db->fetch_row()) { |
$persons_table->newrow(); |
$persons_table->addcell(array( |
'html' => display_link('telbook_details.php?id=' |
. $line['person_id'], $line['person_name']), |
'comment' => $line['person_comment'], |
)); |
$persons_table->addcell(array('html' => display_input( |
'checkbox', 'person-' . $line['person_id'], |
NULL, |
($line['category_id'] ? 'checked' : NULL)))); |
} |
# show |
$g_display->add_template('telbook_category_details_begin'); |
$g_display->add_html_text($table->build()); |
$g_display->add_html_text($persons_table->build()); |
$g_display->add_template('telbook_category_details_end'); |
Epilog(); |