Added emailtemplate for Cancel notification

This commit is contained in:
Frank Schubert
2024-07-11 17:50:41 +02:00
parent 3b35bd561e
commit 8807d7197e
12 changed files with 254 additions and 9 deletions

View File

@@ -99,7 +99,17 @@
<?php endif; ?>
</td>
</tr><tr>
<td colspan="2"><h4>Verrechnungsdaten<?=(array_key_exists("billing", $address->links) && is_array($address->links["billing"]) && count($address->links["billing"])) ? " (<span class='text-danger'>Achtung: Seperate Rechnungsadresse vorhanden</span>)" : ""?> </h4></td>
<td colspan="2">
<h4>
Verrechnungsdaten
<?php if(array_key_exists("billing", $address->links_to) && is_array($address->links_to["billing"]) && count($address->links_to["billing"])): ?>
(<span class='text-danger'>Achtung: Seperate Rechnungsadresse vorhanden</span>)
<?php elseif(array_key_exists("billing", $address->linked_as) && is_array($address->linked_as["billing"]) && count($address->linked_as["billing"])): ?>
<span class='text-success'>(Ist aktive Rechnungsadresse)</span>
<?php endif; ?>
</h4>
</td>
</tr><tr>
<th>UID</th>
<td><?=$address->uid?></td>
@@ -243,7 +253,19 @@
<?php if(is_array($address->contracts) && count($address->contracts)): ?>
<ul class="list-group list-group-flush">
<?php foreach($address->contracts as $contract): ?>
<li class="list-group-item"><a href="<?=self::getUrl("Contract", "View", ["id" => $contract->id])?>" class="<?=($contract->price < 0) ? "text-danger" : ""?>"><?=$contract->product_name?> <?=($contract->matchcode) ? "[".$contract->matchcode."]" : ""?></a> <span class='text-secondary'><?=($contract->finish_date) ? "Fertigstellung: ".date('d.m.Y', $contract->finish_date) : "in Herstellung"?></span></li>
<li class="list-group-item">
<a href="<?=self::getUrl("Contract", "View", ["id" => $contract->id])?>" class="<?=($contract->price < 0) ? "text-danger" : ""?>">
<?=$contract->product_name?> <?=($contract->matchcode) ? "[".$contract->matchcode."]" : ""?>
</a>
<?php if(is_array($contract->voicenumbers)): ?>
<span class="text-pink">
(<?=implode(", ", $contract->voicenumbers)?>)
</span>
<?php endif; ?>
<span class='text-secondary'>
<?=($contract->finish_date) ? "Fertigstellung: ".date('d.m.Y', $contract->finish_date) : "in Herstellung"?>
</span>
</li>
<?php endforeach; ?>
</ul>
<?php endif; ?>

View File

@@ -73,7 +73,7 @@
<div class="card-body">
<div class="form-group row">
<label class="col-lg-2 col-form-label" for="cancel_date">Kyndigungsdatum:</label>
<label class="col-lg-2 col-form-label" for="cancel_date">Kündigungsdatum:</label>
<div class="col-lg-10">
<input type="text" class="form-control" name="cancel_date" id="cancel_date" value="<?=($term_end_date) ? $term_end_date->format("d.m.Y") : ""?>">
</div>

View File

@@ -24,6 +24,7 @@
<div class="card-body">
<a href="<?=self::getUrl("Contract","Index")?>" class="btn btn-sm btn-secondary mr-1"><i class="fas fa-list"></i> Zurück zur Vertragsübersicht</a>
<a href="<?=self::getUrl("Contract","edit", ['contract_id' => $contract->id, 'f' => "view"])?>" class="btn btn-sm btn-outline-success"><i class="fas fa-edit"></i> Vertrag bearbeiten</a>
<?php if($me->username == "fronk"): ?><a href="<?=self::getUrl("Contract","sendCancelNotification", ['contract_id' => $contract->id])?>" class="btn btn-sm btn-purple"><i class="fas fa-edit"></i> Temp button</a><?php endif; ?>
</div>
</div>

View File

@@ -0,0 +1,113 @@
<?php
$this->setReturnValue([
'filename' => "xinon-kuendigungsbestaetigung-".$owner->customer_number.".pdf"
]);
?>
<!DOCTYPE html>
<html>
<head>
<title>Kündigungsbestätigung</title>
<meta charset="utf-8" />
<link href="<?=$ressourcePathPrefix?>fontawesome/css/all.min.css" rel="stylesheet" type="text/css" />
<!--<link href="<?=$ressourcePathPrefix?>assets/css/bootstrap.min.css" rel="stylesheet" type="text/css" />-->
<link href="<?=$ressourcePathPrefix?>assets/css/print.css" rel="stylesheet" type="text/css" />
<style type="text/css">
body {
margin-left: 48pt;
margin-right: 48pt;
font-size: 12pt;
}
</style>
</head>
<body>
<div style="border-top: 1pt solid #000">
&nbsp;
</div>
<div>
<img src="<?=$ressourcePathPrefix?>assets/images/xinon-full.png" style="height: 100pt;" />
</div>
<div style="height:48pt;"></div>
<div>
<?php if($owner->company): ?>
<?=nl2br($owner->company)?><br />
<?php endif; ?>
<?php if($owner->getFullName()): ?>
<?=$owner->getFullName()?><br />
<?php endif; ?>
<?=$owner->street?><br />
<?=$owner->zip?> <?=$owner->city?>
</div>
<div style="height:56pt;"></div>
<div>
<div style="float: right">
<div style="margin-right: 0">Studenzen, <?=date("d.m.Y")?></div>
</div>
<div style="width: 50%">
<h3>Kündigungsbetätigung</h3>
</div>
</div>
<p>Ihre Kundennummer: <?=$owner->customer_number?></p>
<div style="height:12pt; clear: both;"></div>
<div>
<p>Sehr geehrter Kunde,</p>
<div>
<p>wir haben Ihre Kündigung erhalten und bedauern es, dass Sie unsere Services nicht mehr in Anspruch nehmen möchten.</p>
<p>Gemäß der vertraglich vereinbarten Kündigungsfrist bestätigen wir, dass Ihre Produkte und Services wie folgt
gekündigt werden:</p>
</div>
<table style="border-collapse: collapse; width: 80%; margin: auto;">
<tr style="border: 1pt solid #aaa">
<th style="padding: 2pt 8pt 2pt 8pt; text-align: left">Produkt / Service</th>
<th style="padding: 2pt 8pt 2pt 8pt; text-align: left">Kündigungsdatum</th>
</tr>
<tr style="border: 1px solid #aaa;">
<td style="padding: 2pt 8pt 2pt 8pt; text-align: left;">
<?=$contract->product_name?>
<?php if($contract->matchcode): ?>
<br /><i><?=$contract->matchcode?></i>
<?php endif; ?>
</td>
<td style="padding: 2pt 8pt 2pt 8pt; font-weight: bold; text-align: left; vertical-align: top"><?=date("d.m.Y", $contract->cancel_date)?></td>
</tr>
<?php foreach($linked_contracts as $link): ?>
<tr style="border: 1px solid #aaa;">
<td style="padding: 2pt 8pt 2pt 8pt; text-align: left;">
<?=$link->product_name?>
<?php if($link->matchcode): ?>
<br /><i><?=$link->matchcode?></i>
<?php endif; ?>
</td>
<td style="padding: 2pt 8pt 2pt 8pt; font-weight: bold; text-align: left;; vertical-align: top"><?=date("d.m.Y", $link->cancel_date)?></td>
</tr>
<?php endforeach; ?>
</table>
<div>
<p>Die gekündigten Produkte und Services stehen Ihnen nach dem Kündigungsdatum nicht mehr zur Verfügung</p>
<p>Sollten Sie keine Produkte oder Services mehr von uns beziehen, werden Ihre in unserem System gespeicherten Daten
gemäß den gesetzlichen Vorgaben nach Ablauf der vorgeschriebenen Fristen gelöscht.</p>
<p>Die Abrechnung der Entgelte für die genutzten Services erfolgt bis zum genannten Datum und wird Ihnen entsprechend übermittelt.</p>
<p>Wir bedanken uns für Ihr Vertrauen und wünschen Ihnen alles Gute für die Zukunft.</p>
</div>
<div style="height:1.2pt;"></div>
<p>Mit freundlichen Grüßen,</p>
<p>Xinon GmbH</p>
</div>
</body>

View File

@@ -23,7 +23,7 @@
<table style="width: 100%">
<tr>
<td style="width:50%">
<img src="<?=$ressourcePathPrefix?>assets/pdf/logo-xinon.png" />
<img src="<?=$ressourcePathPrefix?>assets/images/xinon-full.png" />
</td>
<td style="width:50%; text-align: right;">
<table style="text-align: left; width:100%">

View File

@@ -0,0 +1,22 @@
<?php
$this->setReturnValue([
'subject' => "Ihre Kündigung",
'from_email' => "office@xinon.at",
'from_email_name' => "XINON Kundenservice"
]);
?>
Sehr geehrter Kunde,
im Anhang finden Sie Ihre Kündigungsbestätigung.
Wir bedanken uns für Ihr Vertrauen und wünschen Ihnen alles Gute für die Zukunft.
Mit besten Grüßen,
Ihr XINON Team
--
XINON GmbH
p: +43 3115 40 800
f: +43 3115 40 800 10
a: Fladnitz im Raabtal 150, 8322 Studenzen, AUSTRIA
w: www.xinon.at  e: office@xinon.at

View File

@@ -5,7 +5,6 @@
'from_email_name' => "XINON Kundenservice"
]);
?>
Sehr geehrte Damen und Herren,
im Anhang finden Sie weitere Informationen zur Ihrer Breitbandbestellung, sowie Ihren persönlichen Service-PIN.

View File

@@ -8,7 +8,6 @@ $this->setReturnValue([
'from_email_name' => "XINON GmbH - Verrechnung"
]);
?>
Sehr geehrte Damen und Herren,
Im Anhang erhalten Sie Ihre aktuelle <?=($invoice->total < 0) ? "Gutschrift" : "Rechnung"?>.

View File

@@ -12,8 +12,6 @@ $this->setReturnValue([
]);
?>
project: portierung
type: Portierung
status: Neu

View File

@@ -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]));

View File

@@ -195,6 +195,7 @@ class ContractController extends mfBaseController
$this->redirect("Contract", "cancel", ["contract_id" => $contract->id]);
}
$linked_contracts = [];
if(is_array($r->links)) {
foreach($r->links as $link_id => $action) {
if($action == "cancel") {
@@ -205,6 +206,8 @@ class ContractController extends mfBaseController
continue;
}
$linked_contracts[] = $link_contract;
$link_contract->cancel_date = $cancel_date->getTimestamp();
if(!$link_contract->save()) {
$this->layout()->setFlash("Fehler beim Speichern von verlinktem Vertrag", "warning");
@@ -213,11 +216,38 @@ class ContractController extends mfBaseController
}
}
$this->layout()->setFlash("Kündigung gespeichert", "success");
$this->redirect("Contract", "view", ["contract_id" => $contract->id]);
}
protected function sendCancelNotification() {
$contract_id = $this->request->contract_id;
$contract = new Contract($contract_id);
$linked_contracts = [];
foreach($contract->links as $link) {
if($link->origin_contract_id == $contract_id) {
$link_contract = $link->contract;
} else {
$link_contract = $link->origin;
}
if($link_contract->owner_id != $contract->owner_id) continue;
$linked_contracts[] = $link_contract;
}
$contract->sendCancelNotification($linked_contracts);
$this->layout()->setFlash("gesendet", "success");
$this->redirect("Contract", "view", ["contract_id" => $contract_id]);
}
protected function productchangeAction()
{
$this->layout()->setTemplate("Contract/ProductchangeForm");

View File

@@ -145,7 +145,7 @@ class Order extends mfBaseModel {
$to = $owner->email;
if(!$subject || !$from || !$from_name || !$to) {
$this->log->warn("Service PIN Email not sent. (subject: '$subject', from: '$from', from_email: '$from_email', to: '$to')");
$this->log->warn("Service PIN Email not sent. (subject: '$subject', from: '$from_email', from_email: '$from', to: '$to')");
} else {
$email = new Emailnotification();
$email->setSubject($subject);