Jump to content

Invoice Edit Event


AllToolKits.com

Recommended Posts

I created a plugin, in that i wrote

public function getEvents() {
        return array(
             array(
                'event' => "Invoices.edit",
                'callback' => array("this", "mailme")
            )
            // Add multiple events here
        );  
}

and function mailme as below

public function mailme($event) {
        // This will execute when the "Appcontroller.preAction" event is triggered
        mail("me@mydomain.com", "invoice edit", "An invoice is editted!!!");

    }

But i am not getting any email when an editting. Why it will be so?

I logged in as admin and editted some invoices and no email yet in my inbox.

 

Link to comment
Share on other sites

i have forget to tell you the model is "Emails" and the function is "sendCustom" so the function will be like this

public function mailme($event) {
// This will execute when the "Appcontroller.preAction" event is triggered
Loader::loadModels($this, array("Emails"));
$params = $event->getParams();
$invoice_id = $params['invoice_id']; //
$from = "me@mydomain.com" ; // you can fetch the blesta email also
$from_name ="Your company name "; // you can fetch the blesta email also
$to = "youremail@domain.com";
$subject = "invoice edit";
$body = array();
//$body['html'] = "Your html content";
$body['text'] = "the invoice ". $invoice_id ." has been editted!!!";

$this->Emails->sendCustom($from, $from_name, $to, $subject, array $body, array $tags=null, $cc=null, $bcc=null, array $attachments=null, array $options=null);
}
Link to comment
Share on other sites

It is not enough to simply add an event in Plugin::getEvents(). The events need to be registered in Blesta. This only happens when the plugin is installed or upgraded. You should update the plugin's version so that it can be upgraded to register the events.

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...