<?php
$pageRef='Customer care';
include('includes/header.php');
?>
<script>
function setLabelEventHandlers(){
//Stick the changePosition handler to the change event of all select objects of class sLabelMove
setTimeout("$$('select.sLabelMove').each(function(s){Event.observe(s,'change',function(){changePosition(s);})})", 1);
//Stick the changeLabelName handler to the change event of all input objects of class iLabelName
setTimeout("$$('input.iLabelName').each(function(s){Event.observe(s,'change',function(){changeLabelName(s);})})", 1);
//Stick the modifingLabelName handler to the keydown event of all input objects of class iLabelName
setTimeout("$$('input.iLabelName').each(function(s){Event.observe(s,'keydown',function(){modifingLabelName(s);})})", 1);
//Stick the deleteLabel handler to the keydown event of all input objects of class aLabelDelete
setTimeout("$$('a.aLabelDelete').each(function(s){Event.observe(s,'click',function(){deleteLabel(s);})})", 1);
}
function labelReload(){
OL_labelTableLoad({elementToFill: 'labelTable', onSuccess: setLabelEventHandlers});
}
function modifingLabelName(inputField){
inputField.style.backgroundColor='#FFDDDD';
}
function successInUpdatingLabelNameF(transport){
var args=transport.responseText.evalJSON();
//Success in update request
labelReload();
//Operation result advice
$('qResult').style.display='block';
$('qResult').innerHTML=args.opText;
if(parseInt(args.opResult) == 0){
//Success in updating operation
}else{
//Failure in updating operation
}
}
function failureInUpdatingLabelNameF(){
//Failure in updating request
labelReload();
alert('<?php echo _T("NI_labels_I") ?>');
}
function changeLabelName(inputField){
inputField.style.backgroundColor='#FFFFFF';
OL_updateLabelName($(inputField).id, $F(inputField), {onSuccess: successInUpdatingLabelNameF, onFailure: failureInUpdatingLabelNameF});
}
function successInCreatingLabel(transport){
var args=transport.responseText.evalJSON();
//Success in create request
//Operation result advice
$('qResult').style.display='block';
$('qResult').innerHTML=args.opText;
if(parseInt(args.opResult) == 0){
//Success in create operation
labelReload();
}else{
//Failure in create operation
}
}
function failureInCreatingLabel(){
//Failure in create request
alert('<?php echo _T("NI_labels_I") ?>');
}
function labelCreate(){
var lName = $F('label');
var lParent = $F('folder');
if(formValidationRules.validate()){
OL_createNewLabel(lName, lParent, {onSuccess: successInCreatingLabel, onFailure: failureInCreatingLabel});
}else{
alert('<?php echo _T("NI_labels_II") ?>');
}
OL_labelTableLoad({elementToFill: 'labelTable', onSuccess: setLabelEventHandlers});
}
function successInUpdatingLabelPosF(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
OL_labelTableLoad({elementToFill: 'labelTable', onSuccess: setLabelEventHandlers});
}else{
//Failure in update operation
}
}
function failureInUpdatingLabelPosF(){
//Failure in update operation
alert('<?php echo _T("NI_labels_III"); ?>');
}
function changePosition(par){
var args = par
var newParent = $F(par);
var labelId = par.name;
OL_updateLabelPosition(labelId, newParent, {onSuccess: successInUpdatingLabelPosF, onFailure: failureInUpdatingLabelPosF});
}
function successInDeletingLabelF(transport){
var args=transport.responseText.evalJSON();
//Success in delete request
//Operation result advice
$('qResult').style.display='block';
$('qResult').innerHTML=args.opText;
if(parseInt(args.opResult) == 0){
//Success in delete operation
OL_labelTableLoad({elementToFill: 'labelTable', onSuccess: setLabelEventHandlers});
}else{
//Failure in delete operation
}
}
function failureInDeletingLabelF(){
//Failure in delete request
alert('<?php echo _T("NI_labels_IV"); ?>');
}
function deleteLabel(elem){
var args = elem.name.split("_");
var labelId = args[0];
var labelName = args[1];
//answer = confirm('L\'etichetta '+labelName+' verrą cancellata insieme a tutte le sue sotto etichette.\n\nLe F.A.Q. catalogate sotto le etichette cancellate verranno \nspostate nelle domande valutate');
answer = confirm('<?php echo _T("NI_labels_V") ?>');
if(answer != 0){
OL_deleteLabel(labelId, {onSuccess: successInDeletingLabelF, onFailure: failureInDeletingLabelF});
}else{
}
}
function questionManagement(){
window.location.href = 'http://<?php echo $_SERVER['SERVER_ADDR']?>/Oreste/questions.php';
}
function backToCCare(){
window.location.href='http://<?php echo $_SERVER['SERVER_ADDR']?>/Oreste/customerCare.php';
}
</script>
<?php
$nodeNumber;
$node;
function getLabelF($nodeName, $nodeId, $nodeLevel){
global $nodeNumber;
global $node;
if($nodeName == 'root'){
$nodeNumber = 0;
}
//cast the function to show the label
$node[$nodeNumber]['nodeName'] = $nodeName;
$node[$nodeNumber]['nodeId'] = $nodeId;
$node[$nodeNumber]['nodeLevel'] = $nodeLevel;
$nodeNumber++;
//serch for label's sons
$getLabels = mysql_query("SELECT * FROM labels WHERE labelParent='" . $nodeId . "'");
if(mysql_num_rows($getLabels)){
while($row = mysql_fetch_array($getLabels)) {
getLabelF($row[labelName], $row[labelID], $row[labelTab]);
}
}
}
getLabelF('root', 1, 0);
?>
<div id="qResult" class="OpResult"></div>
<div class="Columns">
<div class="Column1">
<!-- *********************************************************** -->
<!-- * Menu tab * -->
<!-- *********************************************************** -->
<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:questionManagement();\">" . _T("Question management") . "</a></li>"; ?>
<?php echo "<li><a href=\"javascript:backToCCare();\">" . _T("Back to customer care") . "</a></li>"; ?>
</ul>
</div>
</div>
</div>
<!-- *********************************************************** -->
<!-- * New label * -->
<!-- *********************************************************** -->
<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("New label") ?></span></span><div class="BlockContentBorder">
<table style="width:100%;">
<tr><td style="width: 10%;"><?php echo _T("Label") ?></td> <td><input class="required" title="<?php echo _T("NI_labels_VI") ?>" id="label" type="text" style="width: 100%" /></td> </tr>
<tr><td><?php echo _T("in") ?></td>
<td>
<select id="folder" class="required" title="<?php echo _T("NI_labels_VII") ?>" style="width: 100%">
<?php
$lIndex = 0;
while($lIndex < $nodeNumber){
$rIndex = 0;
$lRoot='';
while($rIndex<$node[$lIndex]['nodeLevel']){$rIndex++;$node[$lIndex]['nodeName']='--' . $node[$lIndex]['nodeName'];}
echo "<option value=\"" . $node[$lIndex]['nodeId'] . "\">" . $node[$lIndex]['nodeName'] . "</option>";
$lIndex++;
}
?>
</select>
</td>
</tr>
<tr><td style="color: white;">in</td> <td></td> </tr>
<tr><td colspan="2" style="text-align: center;"><a href="javascript:labelCreate()"><?php echo _T("Save label") ?></a></td> </tr>
<tr><td colspan="2"><iframe id="saveLabel" style="display:none; font-size:0.8em; width:95%; height:50px; align:center;" name="saveLabel"></iframe></td></tr>
</table>
</div>
</div>
</div>
</form>
</div>
<div class="MainColumn">
<!-- *********************************************************** -->
<!-- * Label table * -->
<!-- *********************************************************** -->
<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("Labels") ?></span></span><div class="BlockContentBorder" id="labelTable">
</div>
</div>
</div>
</div>
</div>
<script>
// ************************************************************
// * Observe window load event to call the init page function *
// ************************************************************
Event.observe(window, 'load', function(){
// *****************************************
// * Load labels table for the first time *
// *****************************************
OL_labelTableLoad({elementToFill: 'labelTable', onSuccess: setLabelEventHandlers});
// **************************
// * 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>