Jump to content

Create support ticket when a Invoice is paid


Richzendy

Recommended Posts

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?

Link to comment
Share on other sites

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'
            ]);
        }
    }

    ...
}

 

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.

Loading...
×
×
  • Create New...