<?php
include("postget.php");
include_once("common.php");
include("ticketsfunc.php");

if ($_REQUEST['clientid']<>0 AND $_REQUEST['email']==''){
	checklevel(1,$_REQUEST['clientid']);
	$thisclient = 1;
}

if (isset($_SESSION['hd_clientid']) AND $_SESSION['hd_accesslvl']>1){
//	checklevel(1,$_REQUEST['clientid']);
	$thisclient = 1;
}




/////////////////////////////////////////////////////////// cambiar el status
$query="UPDATE hd_tickets SET status='5' WHERE reference=".$_REQUEST['reference']."";
if(!mysql_query($query,$db_link)){
	messagetop(_ERROR,"DEBUG: ".$query."<br>ERROR: ".mysql_error(),'tickets.php',0); 
}

$now=time()+$config[31][1]*3600;
/////////////////////////////////////////////////////////// fijar hora de ultima respuesta
$query="UPDATE hd_tickets SET lastreply='".$now."' WHERE reference=".$_REQUEST['reference']."";
if(!mysql_query($query,$db_link)){
	messagetop(_ERROR,"DEBUG: ".$query."<br>ERROR: ".mysql_error(),'tickets.php',0); 
}

/////////////////////////////////////////////////////////// fijar ultimo respondedor
$query="UPDATE hd_tickets SET lastreplier='".$_SESSION['hd_idc']."' WHERE reference=".$_REQUEST['reference']."";
if(!mysql_query($query,$db_link)){
	messagetop(_ERROR,"DEBUG: ".$query."<br>ERROR: ".mysql_error(),'tickets.php',0); 
}

/////////////////////////////////////////////////////////// cambiar followup
if ($_SESSION['hd_accesslvl']>1) {
	$query="UPDATE hd_tickets SET followup='0' WHERE reference=".$_REQUEST['reference']."";
	if(!mysql_query($query,$db_link)){
		messagetop(_ERROR,"DEBUG: ".$query."<br>ERROR: ".mysql_error(),'tickets.php',0); 
	}
}


addreply(
$_REQUEST['ticketid'],
$_SESSION['hd_clientid'],
lang('_THIS_CASE_IS_CONSIDERED_TO_BE_RESOLVED',$_SESSION['preflang']),
''
);

if ($_SESSION['hd_accesslvl']>1) {
	go2("ticketsview.php?reference=".$_REQUEST['reference']."&clientid=".$_SESSION['hd_clientid']);
}else{
	go2("ticketsview.php?reference=".$_REQUEST['reference']);
}



?>