21,7 → 21,11 |
$export_type = ($_POST['export_type'] ? $_POST['export_type'] : NULL); |
$export_comment = $_POST['export_comment']; |
|
$db->begin_transaction(); |
|
if($id) { |
$db->query_params("delete from telbook_entries_export where export_id=$1", array($id)); |
$db->query_params("delete from telbook_persons_export where export_id=$1", array($id)); |
$db->query_params("update telbook_export set" |
. " export_name=$2, export_type=$3, export_comment=$4" |
. " where export_id=$1", |
31,8 → 35,41 |
$db->query_params("insert into telbook_export" |
. " (export_name, export_type, export_comment) values ($1, $2, $3)", |
array($export_name, $export_type, $export_comment)); |
|
$db->query("select currval('telbook_export_export_id_seq')"); |
if($line = $db->fetch_row_idx()) { |
$id = $line[0]; |
} |
} |
|
# save persons |
foreach($_POST as $key => $value) { |
if($value) { |
if(substr($key, 0, strlen('person_title-')) == 'person_title-') { |
$person_id = substr($key, strlen('person_title-')); |
|
$db->query_params("insert into telbook_persons_export" |
. " (export_id, person_id, person_export_title)" |
. " values ($1, $2, $3)", |
array($id, $person_id, $value)); |
} |
} |
} |
|
# save entries |
foreach($_POST as $key => $value) { |
if(substr($key, 0, strlen('entry-')) == 'entry-') { |
$entry_id = substr($key, strlen('entry-')); |
|
$db->query_params("insert into telbook_entries_export" |
. " (export_id, entry_id)" |
. " values ($1, $2)", |
array($id, $entry_id)); |
} |
} |
|
$db->commit_transaction(); |
|
header("Location: telbook_export_list.php"); |
$g_display->add_text('Information saved successfully'); |
} |