<?php
$pageRef='Customer care';
include('includes/header.php');
?>
<script>
function backToUnanswered(){
window.location.href = 'http://127.0.0.1/Oreste/questions.php?qType=una';
}
function disableAll(value){
var el;
//disable/enable links
el = document.getElementsByTagName('a');
for(var i=0;i<el.length;i++){
if(value == 'disabled'){
el[i].disabled = true;
}else if(value == 'enabled'){
el[i].disabled = false;
}
}
}
function successInCreatingAnswerF(transport){
var args=transport.responseText.evalJSON();
disableAll('enabled');
//Success in create request
//Operation result advice
$('qResult').style.display='block';
$('qResult').innerHTML=args.opText;
if(parseInt(args.opResult) == 0){
//Success in create operation
window.location.href = 'http://127.0.0.1/Oreste/questions.php?qType=una';
}else{
//Failure in create operation
}
}
function failureInCreatingAnswerF(){
//Failure in create request
disableAll('enabled');
alert('<?php echo _T("NI_answerForm_III"); ?>');
}
function sendAnswer(qid){
var mail = $F('qMail');
var body = $F('qDomanda');
var answer = $F('qRisposta');
if(formValidationRules.validate()){
disableAll('disabled');
$('qResult').innerHTML = '<?php echo _T("NI_answerForm_IV"); ?>';
OL_createNewAnswer(mail, body, answer, qid, {onSuccess: successInCreatingAnswerF, onFailure: failureInCreatingAnswerF});
}else{
alert('<?php echo _T("NI_answerForm_I"); ?>');
}
}
</script>
<?php
$getQuestion = mysql_query("SELECT * FROM questions WHERE questID='$_GET[qid]'");
while($row = mysql_fetch_array($getQuestion)) {
$body=$row[questBody];
$mail=$row[questMail];
$name=$row[questName];
$surname=$row[questSurname];
}
?>
<form id="formToValidate">
<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><?php echo _T("Actions") ?></span></span><div class="BlockContentBorder">
<ul>
<?php echo "<li><a href=\"javascript:sendAnswer('" . $_GET[qid] . "');\">" . _T("Send the answer") . "</a></li>"; ?>
<?php echo "<li><a href=\"javascript:backToUnanswered();\">" . _T("Back to unanswered question") . "</a></li>"; ?>
</ul>
</div>
</div>
</div>
</div>
<div class="MainColumn">
<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="qNome" 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="qCognome" 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 id="qDomanda" style="width:95%;" rows="7" disabled="disabled"><?php echo $body ?></textarea></td> </tr>
<tr valign="top"><td><b><?php echo _T("Answer") ?> </b></td><td width="95%"><textarea id="qRisposta" style="width:95%;" rows="7" class="required" title="<?php echo _T("NI_answerForm_II") ?>"></textarea></td> </tr>
</table>
</div>
</div>
</div>
</div>
</div>
</form>
<script>
// ************************************************************
// * Observe window load event to call the init page function *
// ************************************************************
Event.observe(window, 'load', function(){
// *****************************************
// * Load faqs table for the first time *
// *****************************************
//questionTableLoad('<?php echo $_GET[qType] ?>', 'qTable', 'qMenu', 'w');
// **************************
// * 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>