Subversion Repositories general

Compare Revisions

Ignore whitespace Rev 1396 → Rev 1399

/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();
 
?>