<?php ob_start();
require_once 'database.php';
require_once 'history.php';
require_once 'usercheck.php';
require_once 'errors.php';
define ("SOLVED_DEFECT_CODE",3);
define ("RESOLUTION_ENCLOSURE_TITLE","Resolution");
if ($fResolutionTime == "") {
tter_errorWithBackButton("You must specify a resolution time.</br>");
exit;
}
// connect to the db
ttdb_connect($connection);
ttdb_beginTransaction($connection);
$date = date('Y-m-d H:i:s');
// update the status of the defect
$updatesql="update defect ".
" set iiddefectstatus = ".SOLVED_DEFECT_CODE.
", iresolutiontime =$fResolutionTime".
", dresolutiondate = '$date'".
", iidresolutiontype = $fResolutionType".
" where iid=$iddefect;";
// execute it
$result= ttdb_execQuery($connection,$updatesql);
if(!$result){
tter_errorWithBackButton("An error occurred updating the database. [$updatesql]</br>");
ttdb_rollbackTransaction($connection);
exit;
}
tt_historyEntry($connection, $iddefect, "Moved to state Resolved by $ddts_username");
$newEnclosureId = ttdb_getSequenceValue($connection, 'enclosure');
// insert also the enclosure
$insertsql="insert into enclosure ".
"(iid, iiddefect,stitle,stext) ".
"values ($newEnclosureId, $iddefect,'".
RESOLUTION_ENCLOSURE_TITLE."','$fResolutionDescription');";
$result= ttdb_execQuery($connection,$insertsql);
if(!$result){
tter_errorWithBackButton("An error ocurred inserting description. [$insertsql]</br>");
ttdb_rollbackTransaction($connection);
exit;
}
tt_historyEntry($connection, $iddefect, "Added enclosure ".RESOLUTION_ENCLOSURE_TITLE." by $ddts_username");
// go to the VisualizeForm page
ttdb_commitTransaction($connection);
ttdb_close($connection);
require_once('triggers.php');
executeTrigger("resolve", $iddefect);
header("Location: visualize.php?iddefect=$iddefect");
ob_end_flush();
?>