3,14 → 3,34 |
include_once('includes/common.php'); |
Prolog('Tel. Book Persons'); |
|
# 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'], |
)); |
} |
|
function add_person($table, $person) |
{ |
global $export_targets; |
|
if(!$person) return; |
|
$first_line = true; |
$new_person = true; |
foreach($person['entries'] as $entry) { |
$table->newrow(); |
if($first_line) { |
|
if($new_person) { |
$table->addcell(array( |
'text' => $person['person_name'], |
'comment' => $person['person_comment'], |
32,7 → 52,11 |
'comment' => $entry['entry_comment'], |
)); |
|
if($first_line) { |
foreach($export_targets as $target) { |
$table->addcell($entry['export'][$target['export_id']] ? 'x' : ''); |
} |
|
if($new_person) { |
$table->addcell(array( |
'class' => 'link', |
'html' => display_link('telbook_details.php?id=' |
47,22 → 71,34 |
. $entry['entry_value'], 'Call'), |
)); |
|
$first_line = false; |
$new_person = false; |
} |
} |
|
$db->query("select person_id, person_name, person_comment, category_name," |
. " category_comment, entry_title, entry_value, entry_comment" |
. " 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" |
. " 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" |
. " order by upper(person_name), person_name," |
. " upper(entry_title), entry_title, upper(entry_value), entry_value"); |
. " upper(entry_title), entry_title, upper(entry_value), entry_value, export_id"); |
|
$table = new Table(array('Name', 'Category', 'Type', 'Number', '', '')); |
$table = new Table(array( |
array('text' => 'Name', 'rowspan' => 2), |
array('text' => 'Category', 'rowspan' => 2), |
array('text' => 'Type', 'rowspan' => 2), |
array('text' => 'Number', 'rowspan' => 2), |
array('text' => 'Export', 'colspan' => count($export_targets)), |
array('text' => '', 'rowspan' => 2), |
array('text' => '', 'rowspan' => 2), |
)); |
$table->add_header_row($export_header); |
$table->set_table_class('telbook list'); |
|
$person = NULL; |
$entry = NULL; |
$export = NULL; |
while($line = $db->fetch_row()) { |
if($person == NULL || $line['person_id'] != $person['person_id']) { |
add_person($table, $person); |
74,13 → 110,23 |
'category_comment' => $line['category_comment'], |
'entries' => array(), |
); |
$entry = NULL; |
} |
|
array_push($person['entries'], array( |
'entry_title' => $line['entry_title'], |
'entry_value' => $line['entry_value'], |
'entry_comment' => $line['entry_comment'], |
)); |
if($entry == NULL || $entry['entry_id'] != $line['entry_id']) { |
$export = array(); |
$entry = array( |
'entry_id' => $line['entry_id'], |
'entry_title' => $line['entry_title'], |
'entry_value' => $line['entry_value'], |
'entry_comment' => $line['entry_comment'], |
'export' => $export, |
); |
array_push($person['entries'], $entry); |
$entry_num = count($person['entries'])-1; |
} |
|
$person['entries'][$entry_num]['export'][$line['export_id']] = true; |
} |
add_person($table, $person); |
|