Added internal billing NBE email for external products
This commit is contained in:
@@ -0,0 +1,77 @@
|
||||
<?php
|
||||
$term_id = $order->terminations[0]->id;
|
||||
$op = OrderProductModel::getFirst(['order_id' => $order->id, 'termination_id' => $term_id]);
|
||||
|
||||
if($order->finish_date) {
|
||||
$billing_start = $order->finish_date;
|
||||
} else {
|
||||
$billing_start = date('U');
|
||||
}
|
||||
|
||||
if($op->billing_delay) {
|
||||
$billing_start = strtotime("+".$op->billing_delay." months");
|
||||
}
|
||||
|
||||
$subject = "";
|
||||
if($order->upgrade) {
|
||||
$subject .= "[UPGRADE] ";
|
||||
}
|
||||
/*$subject .= $order->terminations[0]->building->network->name." - "
|
||||
."Verr. ab ".date("m", $billing_start)."/".date("Y", $billing_start)." - "
|
||||
.$order->owner->customer_number." - "
|
||||
.str_replace("\n", "", str_replace("\r\n", " ", $order->owner->getCompanyOrName()));
|
||||
*/
|
||||
|
||||
$subject .= "[".str_replace(["\r","\n"], " ", $op->product->owner->getCompanyOrName())."] Produkt fertiggestellt - ";
|
||||
|
||||
if(is_array($order->terminations) && count($order->terminations)) {
|
||||
$subject .= $order->terminations[0]->building->network->name." - ";
|
||||
}
|
||||
|
||||
$subject .= ($order->owner->customer_number) ? $order->owner->customer_number." - " : ""
|
||||
.str_replace("\n", "", str_replace("\r\n", " ", $order->owner->getCompanyOrName()));
|
||||
|
||||
$this->setReturnValue([
|
||||
'subject' => $subject,
|
||||
|
||||
'from_email' => "workspace.admin@xinon.at",
|
||||
'from_email_name' => "thetool"
|
||||
]);
|
||||
|
||||
$nbe_total = 0;
|
||||
?>
|
||||
<?php if($order->upgrade): ?>
|
||||
Achtung: UPGRADE
|
||||
<?php endif; ?>
|
||||
project: verrechnung
|
||||
type: Verrechnung
|
||||
status: Neu
|
||||
priority: Standard
|
||||
start date: <?=date("Y-m-01", $billing_start)?>
|
||||
|
||||
due date: <?=date("Y-m-01", $billing_start)?>
|
||||
|
||||
Kundennummer: <?=($op->product->owner->customer_number) ? $op->product->owner->customer_number : "null"?>
|
||||
|
||||
Kundenname: <?=str_replace("\n", "", str_replace("\r\n", " ", $op->product->owner->getCompanyOrName()))?>
|
||||
|
||||
Telefon: <?=($op->product->owner->phone) ? $op->product->owner->phone : "null"?>
|
||||
|
||||
Netzgebiet: <?=$order->terminations[0]->building->network->name?>
|
||||
|
||||
Bauabschnitt: <?=(($order->terminations[0]->building->networksection_id) ? $order->terminations[0]->building->networksection->name : "<kein Bauabschnitt>")?>
|
||||
|
||||
Verrechungsstart: <?=date("m", $billing_start)?>/<?=date("Y", $billing_start)?>
|
||||
|
||||
|
||||
### Rechnungspositionen
|
||||
|
||||
| Anzahl | Produktname | Verrechungsperiode | Preis periodisch | Preis Herstellung | NBE |
|
||||
|--------|-------------|--------------------|-------------------|-------------------|-----|
|
||||
<?php foreach($order->products as $op): ?>
|
||||
<?php if($op->price_nbe > 0.0) $nbe_total += ($op->price_nbe / $op->billing_period); ?>
|
||||
| <?=$op->amount?> | <?=$op->product->name?> | <?=($op->billing_period == 12) ? "Jährlich " : (($op->billing_period == 1) ? "Monatlich" : $op->billing_period."-monatlich")?> | EUR <?=$op->price?> | EUR <?=$op->price_setup?> | EUR <?=$op->price_nbe?> |
|
||||
<?php endforeach; ?>
|
||||
|
||||
|
||||
**Monatliches NBE:** EUR <?=sprintf("%.04f",$nbe_total)?>
|
||||
@@ -72,8 +72,7 @@ Verrechungsstart: <?=date("m", $billing_start)?>/<?=date("Y", $billing_start)?>
|
||||
|--------|-------------|--------------------|-------------------|-------------------|
|
||||
<?php foreach($order->products as $op): ?>
|
||||
<?php if($op->price_nne > 0.0) $nne_products[] = $op; ?>
|
||||
<?=$op->amount?> | <?=$op->product->name?> | <?=($op->billing_period == 12) ? "Jährlich " : (($op->billing_period == 1) ? "Monatlich" : $op->billing_period."-monatlich")?> | EUR <?=$op->price?> | EUR <?=$op->price_setup?>
|
||||
|
||||
| <?=$op->amount?> | <?=$op->product->name?> | <?=($op->billing_period == 12) ? "Jährlich " : (($op->billing_period == 1) ? "Monatlich" : $op->billing_period."-monatlich")?> | EUR <?=$op->price?> | EUR <?=$op->price_setup?> |
|
||||
<?php endforeach; ?>
|
||||
|
||||
<?php if(count($nne_products)): ?>
|
||||
@@ -88,8 +87,7 @@ Netzeigentümer: <?=$order->terminations[0]->building->network->owner->getCompan
|
||||
| Anzahl | Produktname | Verrechungsperiode | Bauabschnitt | NNE |
|
||||
|--------|-------------|--------------------|--------------|-----|
|
||||
<?php foreach($nne_products as $op): ?>
|
||||
<?=$op->amount?> | <?=$op->product->name?> | <?=($op->billing_period == 12) ? "Jährlich " : (($op->billing_period == 1) ? "Monatlich" : $op->billing_period."-monatlich")?> | <?=($op->termination->building->networksection_id) ? $op->termination->building->networksection->name : "<Kein Bauabschnitt>"?> | EUR <?=$op->price_nne?>
|
||||
|
||||
<?=$op->amount?> | <?=$op->product->name?> | <?=($op->billing_period == 12) ? "Jährlich " : (($op->billing_period == 1) ? "Monatlich" : $op->billing_period."-monatlich")?> | <?=($op->termination->building->networksection_id) ? $op->termination->building->networksection->name : "<Kein Bauabschnitt>"?> | EUR <?=$op->price_nne?> |
|
||||
<?php endforeach; ?>
|
||||
|
||||
<?php endif; // (count($nne_products))?>
|
||||
|
||||
@@ -746,7 +746,7 @@
|
||||
</div>
|
||||
<div class="col-1">
|
||||
<label class="form-label" for="price_nbe-<?=$i?>">Preis NBE</label>
|
||||
<input type="text" class="form-control" name="products[<?=$i?>][price_nbe]" id="price_nne-<?=$i?>" value="" placeholder="NBE" />
|
||||
<input type="text" class="form-control" name="products[<?=$i?>][price_nbe]" id="price_nbe-<?=$i?>" value="" placeholder="NBE" />
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
|
||||
@@ -227,6 +227,38 @@ class Order extends mfBaseModel {
|
||||
}
|
||||
}
|
||||
|
||||
public function sendExtBillNbeInfoEmail() {
|
||||
// TODO template rendern auslagern nach Emailtempate klasse
|
||||
$tpl = new Layout();
|
||||
$tpl->setTemplate("Emailtemplates/order/exernal_product_nbe_billing");
|
||||
$tpl->set("order", $this);
|
||||
$body = $tpl->render();
|
||||
|
||||
$values = $tpl->getReturnedValue();
|
||||
|
||||
//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_INTERNAL_BILLING_EMAIL_TO;
|
||||
|
||||
if(!$subject || !$from || !$from_name || !$to) {
|
||||
$this->log->warn("Billing NBE 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-".MFAPPNAME."-oid", $this->id);
|
||||
$email->send();
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public function sendFileuploadEmail(OrderFile $file) {
|
||||
$filetype = $file->name;
|
||||
|
||||
|
||||
@@ -1020,6 +1020,9 @@ class OrderController extends mfBaseController {
|
||||
if(!$order->sendExtBillinfoEmail(new Address($ext_product_owner_id))) {
|
||||
$this->layout()->setFlash("Beim Senden der externen Billing Benachrichtigung ist ein Fehler aufgetreten.", "warning");
|
||||
}
|
||||
if(!$order->sendExtBillNbeInfoEmail(new Address($ext_product_owner_id))) {
|
||||
$this->layout()->setFlash("Beim Senden der internen Billing NBE Benachrichtigung ist ein Fehler aufgetreten.", "warning");
|
||||
}
|
||||
}
|
||||
|
||||
if($int_products) {
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<?php
|
||||
|
||||
class Product extends mfBaseModel {
|
||||
private $owner;
|
||||
private $productgroup;
|
||||
private $producttech;
|
||||
private $sla;
|
||||
@@ -45,6 +46,12 @@ class Product extends mfBaseModel {
|
||||
public function getProperty($name) {
|
||||
if($this->$name == null) {
|
||||
|
||||
if($name == "owner") {
|
||||
if(!$this->external_id) return null;
|
||||
$this->owner = new Address($this->external_id);
|
||||
return $this->owner;
|
||||
}
|
||||
|
||||
if($name == "networks") {
|
||||
$this->networks = [];
|
||||
$productNetworks = ProductNetworkModel::search(['product_id' => $this->id]);
|
||||
|
||||
@@ -32,7 +32,7 @@ class ProductController extends mfBaseController {
|
||||
$filter = $_SESSION[MFAPPNAME.'-Product-filter'];
|
||||
}
|
||||
}
|
||||
//var_dump($filter);
|
||||
|
||||
$this->layout->set("filter", $filter);
|
||||
$filter = $this->getPreparedFilter($filter);
|
||||
|
||||
@@ -46,7 +46,7 @@ class ProductController extends mfBaseController {
|
||||
if(is_numeric($this->request->s)) {
|
||||
$pagination['start'] = intval($this->request->s);
|
||||
}
|
||||
//var_dump($filter);exit;
|
||||
|
||||
$pagination['maxItems'] = ProductModel::count($filter);
|
||||
$this->layout()->set("pagination", $pagination);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user