<?php
$pageRef='Home';
include('includes/header.php');
?>
<script>
function successInUpdatingQuestionF(transport){
var args=transport.responseText.evalJSON();
//Success in update request
//Operation result advice
$('qResult').style.display='block';
$('qResult').innerHTML=args.opText;
if(parseInt(args.opResult) == 0){
//Success in update operation
}else{
//Failure in update operation
}
}
function failureInUpdatingQuestionF(){
//Failure in update request
alert('<?php echo _T("NI_questionForm_I"); ?>');
}
function modifyQuestion(qid){
var mail = $F('qMail');
var question = $F('qQuestion');
var answer = $F('qAnswer');
//window.location.href='pages/do/saveQuestionUpdate.php?add='+mail+'&quest='+question+'&answ='+answer+'&qid='+qid;
if(formValidationRules.validate()){
OL_updateAnsweredQuestion(qid, question, answer, {elementToFill:'qResult', onSuccess: successInUpdatingQuestionF, onFailure: failureInUpdatingQuestionF});
}else{
// ***************************************************************************************************************************************************
// * Alert sentence: 'There are invalid fields (look at tips in the form)'
// ***************************************************************************************************************************************************
alert('<?php echo _T("NI_questionForm_II"); ?>');
}
}
function backToAnsweredQuestion(){
window.location.href='http://127.0.0.1/Oreste/questions.php?qType=ans';
}
</script>
<?php
$questionId = $_GET[qid];
$getQuestion = mysql_query("SELECT * FROM questions WHERE questID='$questionId'");
while($row = mysql_fetch_array($getQuestion)) {
$body=$row[questBody];
$mail=$row[questMail];
$name=$row[questName];
$surname=$row[questSurname];
$answer=$row[questAnswer];
}
?>
<div id="qResult" class="OpResult"></div>
<div class="Columns">
<div class="Column1">
<div class="Block"><div class="BlockBL"><div></div></div><div class="BlockBR"><div></div></div><div class="BlockTL"></div><div class="BlockTR"><div></div></div><div class="BlockT"></div><div class="BlockR"><div></div></div><div class="BlockB"><div></div></div><div class="BlockL"></div><div class="BlockC"></div><div class="BlockContent"><span class="BlockHeader"><span>Azioni</span></span><div class="BlockContentBorder">
<ul>
<?php echo "<li><a href=\"javascript:backToAnsweredQuestion();\">" . _T("Back to answered question") . "</a></li>"; ?>
<?php echo "<li><a href=\"javascript:modifyQuestion('" . $questionId . "');\">" . _T("Save changes") . "</a></li>"; ?>
</ul>
</div>
</div>
</div>
</div>
<div class="MainColumn">
<form id="formToValidate">
<div class="Block"><div class="BlockBL"><div></div></div><div class="BlockBR"><div></div></div><div class="BlockTL"></div><div class="BlockTR"><div></div></div><div class="BlockT"></div><div class="BlockR"><div></div></div><div class="BlockB"><div></div></div><div class="BlockL"></div><div class="BlockC"></div><div class="BlockContent"><span class="BlockHeader"><span><?php echo _T("Answer form"); ?></span></span><div class="BlockContentBorder">
<table width="100%">
<tr valign="top"><td><b><?php echo _T("Name") ?></b></td> <td width="95%"><input type="text" id="qName" style="width:95%;" disabled="disabled" value="<?php echo $name ?>"> </td></tr>
<tr valign="top"><td><b><?php echo _T("Surname") ?></b></td> <td width="95%"><input type="text" id="qSurname" style="width:95%;" disabled="disabled" value="<?php echo $surname ?>"> </td></tr>
<tr valign="top"><td><b><?php echo _T("Email") ?></b></td> <td width="95%"><input type="text" id="qMail" style="width:95%;" disabled="disabled" value="<?php echo $mail ?>"> </td></tr>
<tr valign="top"><td><b><?php echo _T("Question") ?></b></td> <td width="95%"><textarea class="required" title="<?php echo _T("NI_questionForm_III"); ?>" id="qQuestion" style="width:95%;" rows="7"><?php echo $body ?></textarea> </td></tr>
<tr valign="top"><td><b><?php echo _T("Answer") ?></b></td> <td width="95%"><textarea class="required" title="<?php echo _T("NI_questionForm_IV"); ?>" id="qAnswer" style="width:95%;" rows="7"><?php echo $answer ?></textarea> </td></tr>
</table>
</div>
</div>
</div>
</form>
</div>
</div>
<script>
// ************************************************************
// * Observe window load event to call the init page function *
// ************************************************************
Event.observe(window, 'load', function(){
// **************************
// * Install event handlers *
// **************************
Event.observe('qResult', 'mouseover', function(){OL_makeThisElementInvisible('qResult');});
// *********************
// * Install validator *
// *********************
formValidationRules = new Validation('formToValidate',{immediate:true, onSubmit:false, useTitles:true, stopOnFirst:false});
});
</script>
<!-- tags opened in the header -->
</div>
</div>
</div>
</body>
</html>