Added internal billing NBE email for external products

This commit is contained in:
Frank Schubert
2023-02-28 16:43:17 +01:00
parent 5610efdb94
commit 1aa4bdd89e
7 changed files with 124 additions and 7 deletions
@@ -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))?>
+1 -1
View File
@@ -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; ?>