$self_name $item_id\n";
echo "
\n"
;
}
else {
echo "$self_name $item_id
\n";
echo "\n"
;
}
send_common_trailer();
exit;
}
################################################################
if($confirm) {
## HTML-escape all posted data and reset vars in current scope
esc_r($HTTP_POST_VARS);
extract($HTTP_POST_VARS, EXTR_OVERWRITE);
$err = '';
$op = 'edit_postamp';
if(!start_transaction($conn,$op,$scriptid,$comment)) {
$err .= "Can't start transaction.";
}
else {
## ----------------------------------------------------------------
if($comment) {
$q = pg_exec( $conn,
"INSERT INTO item_comment"
." (tn,sernum,workdate)"
." values"
." (currval('tn'),$sernum,'now');"
);
if(!$q) {
$err .= "Error setting comment.
\n";
}
}
## ----------------------------------------------------------------
$err .= postamp_write_db($sernum, $HTTP_POST_VARS);
## ================================================================
if(!$err) {
if(!pg_exec($conn, "COMMIT;")) {
$err .= "Error commiting changes.";
}
}
}
################################################################
## Exit on a error. But, if DB is successfully modified
## just continue to display an updated page.
if($err) {
pg_exec($conn, "ROLLBACK;");
echo "\n"
;
send_common_trailer();
exit;
}
}
################################################################
# Query DB about current item parameters
echo "$self_name $item_id
\n";
$pa_dat = postamp_query_db($item_id, $item_type, $sernum);
if($pa_dat['error']) {
echo "$pa_dat[error]\n";
}
else {
$data = $pa_dat['data'];
#----------------------------------------------------------------
# Display a form with current parameters as default values
echo ( $pa_dat['data']['base_sernum'] ?
"Installed in $data[base_description]"
." " ## "
: "Not installed. Go to"
." \n"
."PAD Crates to install a $self_name."
)
# ----------------------------------------------------------------
."\n"
;
}
#echo "\n";
#print_r($pa_dat);
#echo "
\n";
################################################################
?>