Jump to content

Get closed inactive ticket details


dixonjoseph.k

Recommended Posts

Hi,

 

We are creating a hook which is used to send email with the details of closed tickets which are inactive for 72+hrs. Unfortunately it is not taking all tickets, missing of a few tickets. You can see the code below. Anybody can help us. Hope that any will help us.

 


function hook_before_cron_job_for_close_tickets()
{   
   $query = "SELECT tid,title FROM tbltickets where HOUR(TIMEDIFF(NOW(), lastreply)) >= 72 and status ='Answered'" ;
$result = mysql_query($query);

$tickets = array();
$titles = array();

$cnt = mysql_num_rows($result);
if($cnt > 0)
{
	for($x=0; $x<$cnt ;$x++)
	{			
		$tickt_id = mysql_result($result,$x,'tid');
		$title =  mysql_result($result,$x,'title');

		$tickets[$x] = $tickt_id;
		$titles[$x] = $title;
	}

       $content = "        <h4>Ticket             Title</h4>";

	for($x=0; $x<$cnt ;$x++)
	{
		$content .= "    ".$tickets[$x]."         ".$titles[$x]." <br>";
	}

            $header = "From: support@hostsailor.com\r\n"; 
	$header.= "MIME-Version: 1.0\r\n"; 
	$header.= "Content-Type: text/html; charset=utf-8\r\n"; 
	$header.= "X-Priority: 1\r\n"; 

	mail('example@gmail.com','Tickets Closed today',$content,$header);
}		

  return true;
}

add_hook("PreCronJob",1,"hook_before_cron_job_for_close_tickets");

 

Thanks.

Link to comment
Share on other sites

Thanks for your reply.

 

Actually, there is a cron job in whmcs may be you know it will close the inactive tickets( tickets with status as "Answered" and no reply for 72+hrs) automatically after 72+hrs if it has no other replies. So what we I did is that used PreCronJob hook, it should work just before cron job. So we have to take the "Answered" status tickets with lastreply >= 72. But it is missing some tickets yet.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated