3,54 → 3,6 |
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" |
62,28 → 14,24 |
$table = new Table(array('Name', 'Category', 'Type', 'Number', '', '')); |
$table->set_table_class('telbook list'); |
|
$person = NULL; |
$last_person_id = 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'], |
'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'], |
)); |
$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']; |
} |
add_person($table, $person); |
|
$g_display->add_html_text($table->build()); |
$g_display->add_template('telbook_list_end'); |
|