5,63 → 5,126 |
|
$id = $_GET['id']; |
|
# 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'], |
)); |
} |
|
# person and entries |
$person = array(); |
$table = new Table(array('Type', 'Number', 'Comment')); |
$person = NULL; |
$table = new Table(array( |
array('text' => 'Type', 'rowspan' => 2), |
array('text' => 'Number', 'rowspan' => 2), |
array('text' => 'Comment', 'rowspan' => 2), |
array('text' => 'Export', 'colspan' => count($export_targets)), |
)); |
$table->add_header_row($export_header); |
$table->set_table_class('telbook list'); |
|
$entry_count = 0; |
function add_entry_inputs($table, $entry_count, $entry_title, $entry_value, $entry_comment) |
function add_entry_inputs($table, $entry_count, $entry) |
{ |
global $export_targets; |
|
++$entry_count; |
$table->newrow(); |
$table->addcell(array('html' => display_input( |
'text', 'entry_title-' . $entry_count, $entry_title))); |
'text', 'entry_title-' . $entry_count, $entry['title']))); |
$table->addcell(array('html' => display_input( |
'text', 'entry_value-' . $entry_count, $entry_value))); |
'text', 'entry_value-' . $entry_count, $entry['value']))); |
$table->addcell(array('html' => display_input( |
'text', 'entry_comment-' . $entry_count, $entry_comment))); |
'text', 'entry_comment-' . $entry_count, $entry['comment']))); |
|
foreach($export_targets as $target) { |
$table->addcell(array('html' => display_input( |
'checkbox', 'entry_export-' . $entry_count . '-' . $target['export_id'], |
NULL, |
($entry['export'][$target['export_id']] ? 'checked' : NULL)))); |
} |
|
return $entry_count; |
} |
|
if($id) { |
$db->query_params("select person_id, person_name, person_comment, person_category," |
. " entry_title, entry_value, entry_comment" |
. " e.entry_id, entry_title, entry_value, entry_comment, export_id" |
. " from telbook_persons p" |
. " left join telbook_entries e on p.person_id=e.entry_person" |
. " where person_id=$1", array($id)); |
. " left join telbook_entries_export ex on e.entry_id=ex.entry_id" |
. " where person_id=$1" |
. " order by upper(person_name), person_name, upper(entry_title), entry_title, export_id", |
array($id)); |
|
$first_line = true; |
$entry = NULL; |
while($line = $db->fetch_row()) { |
if($first_line) { |
$person['PERSON_ID'] = $line['person_id']; |
$person['PERSON_NAME'] = $line['person_name']; |
$person['PERSON_COMMENT'] = $line['person_comment']; |
$person['PERSON_CATEGORY'] = $line['person_category']; |
$first_line = false; |
if($person == NULL) { |
$person = array( |
'PERSON_ID' => $line['person_id'], |
'PERSON_NAME' => $line['person_name'], |
'PERSON_COMMENT' => $line['person_comment'], |
'PERSON_CATEGORY' => $line['person_category'], |
); |
} |
|
if($line['entry_value']) { |
$entry_count = add_entry_inputs($table, $entry_count, |
$line['entry_title'], $line['entry_value'], $line['entry_comment']); |
if($entry != NULL && $entry['id'] != $line['entry_id']) { |
$entry_count = add_entry_inputs($table, $entry_count, $entry); |
$entry = NULL; |
} |
|
if($entry == NULL) { |
$entry = array( |
'id' => $line['entry_id'], |
'title' => $line['entry_title'], |
'value' => $line['entry_value'], |
'comment' => $line['entry_comment'], |
'export' => array(), |
); |
} |
|
$entry['export'][$line['export_id']] = true; |
} |
} |
# show the last one |
if($entry != NULL) { |
$entry_count = add_entry_inputs($table, $entry_count, $entry); |
} |
} |
else { |
$person['PERSON_ID'] = ''; |
$person['PERSON_NAME'] = ''; |
$person['PERSON_COMMENT'] = ''; |
$person['PERSON_CATEGORY'] = ''; |
$person = array( |
'PERSON_ID' => '', |
'PERSON_NAME' => '', |
'PERSON_COMMENT' => '', |
'PERSON_CATEGORY' => '', |
); |
} |
$g_display->add_variables($person); |
|
for($i = 0; $i < 5; ++$i) { |
$entry_count = add_entry_inputs($table, $entry_count, '', '', ''); |
$entry_count = add_entry_inputs($table, $entry_count, array( |
'id' => '', |
'title' => '', |
'value' => '', |
'comment' => '', |
'export' => array(), |
)); |
} |
|
# categories select box |
$db->query("select category_id, category_name from telbook_categories order by category_name"); |
$db->query("select category_id, category_name from telbook_categories" |
. " order by upper(category_name), category_name"); |
$categories_list = "\n\t\t\t\t<option value=''>(none)</option>"; |
while($line = $db->fetch_row()) { |
$categories_list .= "\n\t\t\t\t<option value='" |