| 1 |
<?php |
| 2 |
|
| 3 |
namespace WeDevs\ERP\Accounting\Includes\Emails; |
| 4 |
|
| 5 |
use WeDevs\ERP\Email; |
| 6 |
use WeDevs\ERP\Framework\Traits\Hooker; |
| 7 |
|
| 8 |
/** |
| 9 |
* Approved Leave Request |
| 10 |
*/ |
| 11 |
class Transactional_Email extends Email { |
| 12 |
use Hooker; |
| 13 |
|
| 14 |
public function __construct() { |
| 15 |
$this->id = 'transectional-email'; |
| 16 |
$this->title = __( 'New transaction invoice', 'erp' ); |
| 17 |
$this->description = __( 'New invoice notification alert', 'erp' ); |
| 18 |
|
| 19 |
$this->subject = __( 'New invoice has been created', 'erp' ); |
| 20 |
$this->heading = __( 'New transaction invoice', 'erp' ); |
| 21 |
|
| 22 |
$this->find = [ |
| 23 |
'customer_name' => '{customer_name}', |
| 24 |
'invoide_ID' => '{invoide_ID}', |
| 25 |
'amount' => '{amount}', |
| 26 |
'due_date' => '{due_date}', |
| 27 |
'company_name' => '{company_name}', |
| 28 |
]; |
| 29 |
|
| 30 |
$this->action( 'erp_admin_field_' . $this->id . '_help_texts', 'replace_keys' ); |
| 31 |
|
| 32 |
parent::__construct(); |
| 33 |
} |
| 34 |
|
| 35 |
public function get_args() { |
| 36 |
return [ |
| 37 |
'email_heading' => $this->heading, |
| 38 |
'email_body' => wpautop( $this->get_option( 'body' ) ), |
| 39 |
]; |
| 40 |
} |
| 41 |
|
| 42 |
public function trigger( $receiver_email, $attachment = '', $voucher_no, $company ) { |
| 43 |
$this->recipient = $receiver_email; |
| 44 |
$this->heading = $this->get_option( 'heading', $this->heading ); |
| 45 |
$this->subject = $this->get_option( 'subject', $this->subject ); |
| 46 |
|
| 47 |
$voucher_details = erp_acct_get_invoice( $voucher_no ); |
| 48 |
|
| 49 |
$this->replace = [ |
| 50 |
'customer_name' => $voucher_details['customer_name'], |
| 51 |
'invoide_ID' => $voucher_no, |
| 52 |
'amount' => $voucher_details['amount'], |
| 53 |
'due_date' => $voucher_details['due_date'], |
| 54 |
'company_name' => $company->name, |
| 55 |
]; |
| 56 |
|
| 57 |
if ( ! $this->get_recipient() ) { |
| 58 |
return; |
| 59 |
} |
| 60 |
|
| 61 |
$this->send( $this->get_recipient(), $this->get_subject(), $this->get_content(), $this->get_headers(), $attachment ); |
| 62 |
} |
| 63 |
} |
| 64 |
|