Subversion Repositories general

Compare Revisions

Ignore whitespace Rev 1396 → Rev 1397

/asterisk-stats/trunk/telbook_list.php
3,6 → 3,54
include_once('includes/common.php');
Prolog('Tel. Book Persons');
 
function add_person($table, $person)
{
if(!$person) return;
 
$first_line = true;
foreach($person['entries'] as $entry) {
$table->newrow();
if($first_line) {
$table->addcell(array(
'text' => $person['person_name'],
'comment' => $person['person_comment'],
'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'],
));
 
if($first_line) {
$table->addcell(array(
'class' => 'link',
'html' => display_link('telbook_details.php?id='
. $person['person_id'], 'Edit'),
'rowspan' => count($person['entries']),
));
}
 
$table->addcell(array(
'class' => 'link',
'html' => display_link('originate_form.php?dst='
. $entry['entry_value'], 'Call'),
));
 
$first_line = false;
}
}
 
$db->query("select person_id, person_name, person_comment, category_name,"
. " category_comment, entry_title, entry_value, entry_comment"
. " from telbook_persons p"
14,24 → 62,28
$table = new Table(array('Name', 'Category', 'Type', 'Number', '', ''));
$table->set_table_class('telbook list');
 
$last_person_id = NULL;
$person = NULL;
while($line = $db->fetch_row()) {
$table->newrow();
//$same_person = ($line['person_id'] == $last_person_id);
$table->addcell($same_person ? '' : array('text' => $line['person_name'],
'comment' => $line['person_comment']));
$table->addcell($same_person ? '' : array('text' => $line['category_name'],
'comment' => $line['category_comment']));
$table->addcell(array('text' => $line['entry_title'],
'comment' => $line['entry_comment']));
$table->addcell(array('text' => $line['entry_value'],
'comment' => $line['entry_comment']));
$table->addcell(array('class' => 'link', 'html' =>
$same_person ? '' : display_link('telbook_details.php?id=' . $line['person_id'], 'Edit')));
$table->addcell(array('class' => 'link', 'html' =>
display_link('originate_form.php?dst=' . $line['entry_value'], 'Call')));
$last_person_id = $line['person_id'];
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'],
'category_name' => $line['category_name'],
'category_comment' => $line['category_comment'],
'entries' => array(),
);
}
 
array_push($person['entries'], array(
'entry_title' => $line['entry_title'],
'entry_value' => $line['entry_value'],
'entry_comment' => $line['entry_comment'],
));
}
add_person($table, $person);
 
$g_display->add_html_text($table->build());
$g_display->add_template('telbook_list_end');
 
/asterisk-stats/trunk/telbook_export.php
22,7 → 22,8
. " left join telbook_categories c on p.person_category=c.category_id"
. " 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",
. " order by upper(person_name), person_name,"
. " upper(entry_title), entry_title, upper(entry_value), entry_value",
array($id));
 
header("Content-Type: text/plain");