dixonjoseph.k Posted October 27, 2015 Share Posted October 27, 2015 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. 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted October 27, 2015 Share Posted October 27, 2015 if you are searching for closed tickets, shouldn't the status = "Closed" ? an "Answered" ticket isn't necessarily closed... 0 Quote Link to comment Share on other sites More sharing options...
dixonjoseph.k Posted October 28, 2015 Author Share Posted October 28, 2015 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. 0 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.