Jump to content

need help with TicketAdminReply hook


vbatra

Recommended Posts

I want to set the ticket status to "Open" whenever a reply is made by an admin, I am doing so because WHMCS do not log the change in ticket status a response is made to the ticket, my idea is to force my staff to change the ticket status through the dropdown. Below is my code for it but I am getting error 500 with this code.

 

<?php
if (!defined("WHMCS"))
   die("This file cannot be accessed directly");

function set_ticket_open($vars) {

   $tid = $vars['ticketid'];
UPDATE `tbltickets` SET `status`="Open" WHERE `id`="$tid";
}

add_hook("TicketAdminReply",1,"set_ticket_open");

?>

 

 

Can anyone help me with fixing this code or give me any other code that can log the status change in database according to the status selected during "add response".

Link to comment
Share on other sites

use Capsule, it's your friend

<?php

use Illuminate\Database\Capsule\Manager as Capsule;
[color=#007700]if (![/color][color=#0000BB]defined[/color][color=#007700]([/color][color=#DD0000]"WHMCS"[/color][color=#007700])) 
   die([/color][color=#DD0000]"This file cannot be accessed directly"[/color][color=#007700]); 

function [/color][color=#0000BB]set_ticket_open[/color][color=#007700]([/color][color=#0000BB]$vars[/color][color=#007700]) { 

   [/color][color=#0000BB]$tid [/color][color=#007700]= [/color][color=#0000BB]$vars[/color][color=#007700][[/color][color=#DD0000]'ticketid'[/color][color=#007700]]; 

                               $query=Capsule::table('tbltickets')->where('[color=#DD0000]id[/color]', $tid)->update(array('status' => "Open"));
}
[color=#0000BB]add_hook[/color]([color=#DD0000]"TicketAdminReply"[/color],[color=#0000BB]1[/color],[color=#DD0000]"set_ticket_open"[/color]); 
?>
[/color]

 

Also, as far as php errors go, you will be able to debug these by turning on display errors in admin -> setup -> general settings -> other.

Just don't forget to turn that off when done.

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.

×
×
  • 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