Added externel product billing email
This commit is contained in:
123
Layout/default/Emailtemplates/order/billing_external_energie.php
Normal file
123
Layout/default/Emailtemplates/order/billing_external_energie.php
Normal file
@@ -0,0 +1,123 @@
|
||||
<?php
|
||||
$term_id = $order->terminations[0]->id;
|
||||
$op = OrderProductModel::getFirst(['order_id' => $order->id, 'termination_id' => $term_id]);
|
||||
|
||||
$billing_start = date('U');
|
||||
if($op->billing_delay) {
|
||||
$billing_start = strtotime("+".$op->billing_delay." months");
|
||||
}
|
||||
//var_dump($order->terminations[0]->building);exit;
|
||||
$this->setReturnValue([
|
||||
'subject' => $order->partner_number." - "
|
||||
."hergestellt am ".date("d.m.Y", $order->finish_date) . " - "
|
||||
."Verrechnung ab ".date("m", $billing_start)."/".date("Y", $billing_start)." - "
|
||||
.str_replace("\n", " ", str_replace("\r", "", $order->owner->getCompanyOrName())),
|
||||
|
||||
'from_email' => TT_OUTGOING_EMAIL,
|
||||
'from_email_name' => TT_OUTGOING_EMAIL_NAME
|
||||
]);
|
||||
|
||||
$nne_products = [];
|
||||
?>
|
||||
|
||||
Rechnungspositionen
|
||||
====================
|
||||
|
||||
Anzahl | Produktname | Verrechungsperiode | Preis periodisch | Preis Herstellung
|
||||
-----------------------------------------------------------------------------------------------------------------------
|
||||
<?php foreach($order->products as $op): ?>
|
||||
<?php if($op->product->price_nne > 0.0) $nne_products[] = $op; ?>
|
||||
<?=sprintf("%-12s", substr($op->amount,0,12))?> | <?=utf8_encode(sprintf("%-42s", utf8_decode(substr($op->product->name,0,42))))?> | <?=utf8_encode(sprintf("%-18s", utf8_decode(($op->billing_period == 12) ? "Jährlich " : (($op->billing_period == 1) ? "Monatlich" : $op->billing_period."-monatlich")) ))?> | <?=sprintf("EUR %-12s", substr($op->price,0,12))?> | EUR <?=$op->price_setup?>
|
||||
|
||||
-----------------------------------------------------------------------------------------------------------------------
|
||||
<?php endforeach; ?>
|
||||
|
||||
<?php if(is_array($order->terminations) && count($order->terminations)): ?>
|
||||
Anschluss
|
||||
==========
|
||||
<?php foreach($order->terminations as $term): ?>
|
||||
<?=$term->getAddress()?>
|
||||
|
||||
<?php endforeach; ?>
|
||||
<?php endif; ?>
|
||||
|
||||
|
||||
Bestelldetails
|
||||
===============
|
||||
Bestelldatum: <?=date("d.m.Y", $order->order_date)?>
|
||||
|
||||
Bestellung abgeschlossen: <?=date("d.m.Y", $order->finish_date)?>
|
||||
|
||||
Einwilligung Datenschutz: <?=($order->allow_contact)? "Ja" : "Nein"?>
|
||||
|
||||
|
||||
|
||||
Vertragsinhaber
|
||||
================
|
||||
Firma: <?=$order->owner->company?>
|
||||
|
||||
Vorname: <?=$order->owner->firstname?>
|
||||
|
||||
Nachname: <?=$order->owner->lastname?>
|
||||
|
||||
Straße: <?=$order->owner->street?>
|
||||
|
||||
PLZ: <?=$order->owner->zip?>
|
||||
|
||||
Ort: <?=$order->owner->city?>
|
||||
|
||||
Land: <?=$order->owner->country?>
|
||||
|
||||
Telefon: <?=$order->owner->phone?>
|
||||
|
||||
Fax: <?=$order->owner->fax?>
|
||||
|
||||
Mobiltelefon: <?=$order->owner->mobile?>
|
||||
|
||||
Email: <?=$order->owner->email?>
|
||||
|
||||
<?php if($order->billingaddress_id > 0 && $order->billingaddress_id != $order->owner_id): ?>
|
||||
|
||||
|
||||
Rechnungsempfänger
|
||||
===================
|
||||
Firma: <?=$order->billingaddress->company?>
|
||||
|
||||
Vorname: <?=$order->billingaddress->firstname?>
|
||||
|
||||
Nachname: <?=$order->billingaddress->lastname?>
|
||||
|
||||
Straße: <?=$order->billingaddress->street?>
|
||||
|
||||
PLZ: <?=$order->billingaddress->zip?>
|
||||
|
||||
Ort: <?=$order->billingaddress->city?>
|
||||
|
||||
Land: <?=$order->billingaddress->country?>
|
||||
|
||||
Telefon: <?=$order->billingaddress->phone?>
|
||||
|
||||
Fax: <?=$order->billingaddress->fax?>
|
||||
|
||||
Mobiltelefon: <?=$order->billingaddress->mobile?>
|
||||
|
||||
Email: <?=$order->billingaddress->email?>
|
||||
|
||||
<?php endif; ?>
|
||||
|
||||
|
||||
Verrechnung
|
||||
============
|
||||
<?php if($order->billing_type == "invoice"): ?>
|
||||
Verrechnungsart: Rechnung
|
||||
<?php else: ?>
|
||||
Verrechnungsart: SEPA Bankeinzug
|
||||
Bank: <?=$order->bank_account_bank?>
|
||||
|
||||
Kontoinhaber: <?=$order->bank_account_owner?>
|
||||
|
||||
IBAN: <?=$order->bank_account_iban?>
|
||||
|
||||
BIC: <?=$order->bank_account_bic?>
|
||||
|
||||
<?php endif; ?>
|
||||
@@ -24,7 +24,7 @@
|
||||
Rechnungspositionen
|
||||
====================
|
||||
|
||||
Anzahl | Produktname | Verrechungsperiode | Preis periodisch | Preis Herstellung
|
||||
Anzahl | Produktname | Verrechungsperiode | Preis periodisch | Preis Herstellung
|
||||
-----------------------------------------------------------------------------------------------------------------------
|
||||
<?php foreach($order->products as $op): ?>
|
||||
<?php if($op->product->price_nne > 0.0) $nne_products[] = $op; ?>
|
||||
|
||||
@@ -122,6 +122,42 @@ class Order extends mfBaseModel {
|
||||
}
|
||||
}
|
||||
|
||||
public function sendExtBillinfoEmail() {
|
||||
// TODO template rendern auslagern nach Emailtempate klasse
|
||||
$tpl = new Layout();
|
||||
$tpl->setTemplate("Emailtemplates/order/billing_external_energie");
|
||||
$tpl->set("order", $this);
|
||||
$body = $tpl->render();
|
||||
|
||||
$values = $tpl->getReturnedValue();
|
||||
|
||||
$this->finish_date = null;
|
||||
$this->save();
|
||||
|
||||
//var_dump($values); echo "<pre class='text-monospace'>".$body."</pre>"; exit;
|
||||
|
||||
$subject = $values['subject'];
|
||||
$from = $values['from_email'];
|
||||
$from_name = $values['from_email_name'];
|
||||
$to = TT_EXTERNAL_BILLING_EMAIL_TO;
|
||||
|
||||
if(!$subject || !$from || !$from_name || !$to) {
|
||||
$this->log->warn("Internl Billing Email not sent. (subject: '$subject', from: '$from', from_email: '$from_name', to: '$to')");
|
||||
|
||||
return false;
|
||||
} else {
|
||||
$email = new Emailnotification();
|
||||
$email->setSubject($subject);
|
||||
$email->setBody($body);
|
||||
$email->setFrom($from, $from_name);
|
||||
$email->setTo($to);
|
||||
$email->setHeader("X-Xinon-Oid", $this->id);
|
||||
$email->send();
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public function getProperty($name) {
|
||||
if($this->$name == null) {
|
||||
|
||||
|
||||
@@ -494,6 +494,10 @@ class OrderController extends mfBaseController {
|
||||
$order->save();
|
||||
}
|
||||
|
||||
|
||||
$ext_products = false;
|
||||
$int_products = false;
|
||||
|
||||
//var_dump($r->products);exit;
|
||||
// validate and add products
|
||||
if(is_array($r->products) && count($r->products)) {
|
||||
@@ -546,7 +550,11 @@ class OrderController extends mfBaseController {
|
||||
}
|
||||
|
||||
// if product is not external and customer is new, create customer_number and service pin
|
||||
if(!$prod->external ) {
|
||||
if($prod->external) {
|
||||
$ext_products = true;
|
||||
} else {
|
||||
$int_products = true;
|
||||
|
||||
if(!$owner->customer_number) {
|
||||
$last_num = AddressModel::getLastCustomerNumber();
|
||||
$this->log->debug("last_num: $last_num");
|
||||
@@ -660,8 +668,21 @@ class OrderController extends mfBaseController {
|
||||
|
||||
// send order finish email
|
||||
if($send_to_bill_email) {
|
||||
if(!$order->sendIntBillinfoEmail()) {
|
||||
$this->layout()->setFlash("Beim Senden der Billing Benachrichtigung ist ein Fehler aufgetreten.", "warning");
|
||||
|
||||
if($ext_products && !$int_products) {
|
||||
if(!$order->sendExtBillinfoEmail()) {
|
||||
$this->layout()->setFlash("Beim Senden der externen Billing Benachrichtigung ist ein Fehler aufgetreten.", "warning");
|
||||
}
|
||||
}
|
||||
|
||||
if($int_products) {
|
||||
if(!$order->sendIntBillinfoEmail()) {
|
||||
$this->layout()->setFlash("Beim Senden der Billing Benachrichtigung ist ein Fehler aufgetreten.", "warning");
|
||||
}
|
||||
}
|
||||
|
||||
if($int_products && $ext_products) {
|
||||
$this->layout()->setFlash("Eigene und Fremdprodukte gefunden, nur interne Billing Benachrichtigung verschickt.", "warning");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user