Richzendy Posted June 10, 2020 Report Posted June 10, 2020 Hi, i'm making a module, and i have a configurable option to add a extra in a service, but this add-on must be created by a support member from our side manually and i want to create a support ticket to our admin staff when this bill is full paid. How i can make this? i'm looking the "Events Handlers" https://docs.blesta.com/display/dev/Event+Handlers But i don't know if this events: "Services.edit" or "Invoices.edit" can be useful to this, in fact i don't know how to use this events on my module, someone have a clue? Quote
Abdy Posted June 10, 2020 Report Posted June 10, 2020 I think it is not necessary to use events for what you are looking for, from the addService() function you can add a condition that if the configurable option exists, a support ticket is created. The addService() function is automatically executed by the cron task when the invoice related to the service has been paid in full. Here's a quick example, assuming that the configurable option for the extra service is named "migration_service": public function addService( $package, array $vars = null, $parent_package = null, $parent_service = null, $status = 'pending' ) { ... if (isset($vars['configoptions']['migration_service'])) { // Create support ticket Loader::loadModels($this, ['SupportManager.SupportManagerTickets']); $ticket = $this->SupportManagerTickets->add([ 'department_id' => 1, 'staff_id' => 1, 'client_id' => 1, 'summary' => 'Subject', 'priority' => 'critical', 'status' => 'open' ]); // Add reply if (!is_null($ticket)) { $this->SupportManagerTickets->addReply($ticket, [ 'client_id' => 1, 'contact_id' => 1, 'type' => 'reply', 'details' => 'Reply text' ]); } } ... } Richzendy 1 Quote
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.