Added emailtemplate for Cancel notification
This commit is contained in:
@@ -30,6 +30,7 @@ class Contract extends mfBaseModel {
|
||||
private $relocationTo;
|
||||
private $vatgroup;
|
||||
private $vatrate;
|
||||
private $voicenumbers;
|
||||
private $finisher;
|
||||
private $canceler;
|
||||
private $creator;
|
||||
@@ -203,6 +204,12 @@ class Contract extends mfBaseModel {
|
||||
|
||||
}
|
||||
|
||||
public function getVoicenumbers() {
|
||||
$voicenumber = $this->getConfigValue("voicenumberblock_voicenumber");
|
||||
$numbers = json_decode($voicenumber->json);
|
||||
return $numbers;
|
||||
}
|
||||
|
||||
public function getConfigValue($itemname) {
|
||||
$configvalues = $this->getProperty("configvalues");
|
||||
if(!$configvalues) return null;
|
||||
@@ -224,6 +231,54 @@ class Contract extends mfBaseModel {
|
||||
return true;
|
||||
}
|
||||
|
||||
public function sendCancelNotification($linked_contracts = []) {
|
||||
$pdf_vars = [
|
||||
"contract" => $this,
|
||||
"linked_contracts" => $linked_contracts,
|
||||
"owner" => $this->getProperty("owner")
|
||||
];
|
||||
$pdf = new PdfForm("Emailtemplates/attachments/cancel_notification.pdf", $pdf_vars);
|
||||
//$pdf->download();
|
||||
//exit;
|
||||
$pdfpath = $pdf->render();
|
||||
$tvalue = $pdf->getReturnedValues();
|
||||
$pdfname = $tvalue["filename"];
|
||||
|
||||
// send email to customer
|
||||
$tpl = new Layout();
|
||||
$tpl->setTemplate("Emailtemplates/customer/cancel_notification");
|
||||
|
||||
foreach($pdf_vars as $name => $val) {
|
||||
$tpl->set($name, $val);
|
||||
}
|
||||
|
||||
$body = $tpl->render();
|
||||
$values = $tpl->getReturnedValue();
|
||||
|
||||
$subject = $values['subject'];
|
||||
$from = $values['from_email'];
|
||||
$from_name = $values['from_email_name'];
|
||||
$to = $this->owner->email;
|
||||
|
||||
if(!$subject || !$from || !$from_name || !$to) {
|
||||
$this->log->warn("Service PIN Email not sent. (subject: '$subject', from: '$from_name', from_email: '$from', to: '$to')");
|
||||
} else {
|
||||
$email = new Emailnotification();
|
||||
$email->setSubject($subject);
|
||||
$email->setBody($body);
|
||||
$email->setFrom($from, $from_name);
|
||||
$email->setTo($to);
|
||||
$email->setHeader("X-".MFAPPNAME."-Cid", $this->id);
|
||||
$email->addAttachment($pdfpath, null, $pdfname, "application/pdf");
|
||||
$email->send();
|
||||
|
||||
$email->setTo("office@xinon.at");
|
||||
$email->send();
|
||||
|
||||
$this->log->info(__METHOD__.": Sending Cancel Notication for ".$this->owner_id." to $to");
|
||||
}
|
||||
}
|
||||
|
||||
public function getProperty($name) {
|
||||
if($this->$name == null) {
|
||||
|
||||
@@ -336,6 +391,12 @@ class Contract extends mfBaseModel {
|
||||
$this->vatrate = $vatrate;
|
||||
return $this->vatrate;
|
||||
}
|
||||
|
||||
if($name == "voicenumbers") {
|
||||
$numbers = $this->getVoicenumbers();
|
||||
$this->voicenumbers = $numbers;
|
||||
return $this->voicenumbers;
|
||||
}
|
||||
|
||||
if($name == "journals") {
|
||||
$this->journals = array_reverse(ContractjournalModel::search(["contract_id" => $this->id]));
|
||||
|
||||
Reference in New Issue
Block a user