Merge branch 'master' into devbyspi
This commit is contained in:
@@ -0,0 +1,83 @@
|
||||
<?php
|
||||
|
||||
$this->setReturnValue([
|
||||
'filename' => "Wichtige Kundeninformation ".$owner->customer_number.".pdf"
|
||||
]);
|
||||
?>
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Wichtige Kundeninformation zu Ihrem Glasfaseranschluss</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" />
|
||||
</head>
|
||||
<body styl="font-size: 36pt;">
|
||||
|
||||
<!--div style="border-top: 1pt solid #000">
|
||||
|
||||
</div-->
|
||||
|
||||
<table style="width: 100%">
|
||||
<tr>
|
||||
<td style="width:50%">
|
||||
<img src="<?=$ressourcePathPrefix?>assets/pdf/logo-address-<?=$netowner->id?>.png" style="max-width: 100%"/>
|
||||
</td>
|
||||
<td style="width:50%; text-align: right;"> </td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
|
||||
<div style="height:24pt;"></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:24pt;"></div>
|
||||
|
||||
<div class="center">
|
||||
<h2>Wichtige Kundeninformation zu Ihrem<br />Glasfaseranschluss</h2>
|
||||
</div>
|
||||
|
||||
<div style="height:12pt;"></div>
|
||||
|
||||
<div>
|
||||
<p>Sehr geehrte Damen und Herren,</p>
|
||||
<p>wir freuen uns sehr, dass Sie sich für einen Glasfaseranschluss im Netz der <?=$netowner->company?> entschieden haben. Hiermit möchten wir Ihnen gerne den Eingang Ihrer Bestellung bestätigen.</p>
|
||||
<p>Bezüglich der gegebenenfalls erforderlichen Termine für die Installation melden wir uns (bzw. unsere Partner vom Leitungsbau) sobald die Herstellung möglich ist.</p>
|
||||
<p>Ihr persönlicher Service-PIN lautet: <?=$owner->spin?></p>
|
||||
<p>Gemäß der EU-Datenschutzverordnung sind wir dazu verpflichtet, mit den uns anvertrauten Kundendaten sorgsam umzugehen. Dazu gehört die Abfrage eines Service-PINs mit welchem Sie bei uns auch
|
||||
telefonische Auskünfte (z.B. vergessene Passwörter, Rechnungsauskünfte, etc.) erhalten können. Unsere Mitarbeiter werden Sie vor Beantwortung Ihrer Fragen um die Nennung des Service-PINs bitte.
|
||||
Bitte haben Sie Verständnis, dass wir <strong>ohne</strong> korrekte Nennung Ihres <strong>PIN</strong>s keine Auskünfte erteilen können.</p>
|
||||
</div>
|
||||
|
||||
<div style="height:14pt;"> </div>
|
||||
|
||||
<div>
|
||||
<p class="bold">Sollten Sie noch Fragen haben, erreichen Sie uns per Mail an <span style="white-space: nowrap"><?=$netowner->email?></span> oder telefonisch unter der Rufnummer <span style="white-space: nowrap"><?=$netowner->phone?>.</span></p>
|
||||
</div>
|
||||
|
||||
<div style="height:14pt;"> </div>
|
||||
|
||||
<div>
|
||||
<p>Mit freundlichen Grüßen,</p>
|
||||
</div>
|
||||
|
||||
<div style="height:14pt;"> </div>
|
||||
|
||||
<div>
|
||||
<p>Ihr Team der <?=$netowner->company?></p>
|
||||
</div>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
15
Layout/andom-tec/Emailtemplates/customer/new_order.php
Normal file
15
Layout/andom-tec/Emailtemplates/customer/new_order.php
Normal file
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
$this->setReturnValue([
|
||||
'subject' => "Ihre Bestellung wurde erfasst",
|
||||
'from_email' => $netowner->email,
|
||||
'from_email_name' => $netowner->company." Kundenservice"
|
||||
]);
|
||||
?>
|
||||
|
||||
Sehr geehrte Damen und Herren,
|
||||
|
||||
im Anhang finden Sie weitere Informationen zur Ihrer Glasfaserbestellung, sowie Ihren persönlichen Service-PIN.
|
||||
|
||||
Mit freundlichen Grüßen,
|
||||
|
||||
Ihr Team der <?=$netowner->company?>
|
||||
@@ -0,0 +1,131 @@
|
||||
<?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");
|
||||
}
|
||||
|
||||
$subject = "";
|
||||
if($order->upgrade) {
|
||||
$subject .= "[UPGRADE] ";
|
||||
}
|
||||
$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()));
|
||||
|
||||
$this->setReturnValue([
|
||||
'subject' => $subject,
|
||||
|
||||
'from_email' => TT_OUTGOING_EMAIL,
|
||||
'from_email_name' => "XINON Partnerservice"
|
||||
]);
|
||||
|
||||
?>
|
||||
<?php if($order->upgrade): ?>
|
||||
Achtung: UPGRADE
|
||||
<?php endif; ?>
|
||||
|
||||
|
||||
Rechnungspositionen
|
||||
====================
|
||||
|
||||
Anzahl | Produktname | Verrechungsperiode | Preis periodisch | Preis Herstellung
|
||||
-----------------------------------------------------------------------------------------------------------------------
|
||||
<?php foreach($order->products as $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; ?>
|
||||
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
$contacts = $order->owner->getChildrenByType("techcontact");
|
||||
if(!is_array($contacts) || !count($contacts)) {
|
||||
$contacts = [$order->owner];
|
||||
}
|
||||
|
||||
$tos = [];
|
||||
foreach($contacts as $contact) {
|
||||
if($contact->email) {
|
||||
$tos[] = $contact->email;
|
||||
}
|
||||
}
|
||||
|
||||
$customer_string = str_replace(["\r","\n"], " ", $order->owner->getCompanyOrName());
|
||||
|
||||
$subject = "Ihr Übergabeprotokoll / Technikerstammblatt";
|
||||
|
||||
$this->setReturnValue([
|
||||
'subject' => $subject,
|
||||
'to' => $tos,
|
||||
'from_email' => "support@xinon.at",
|
||||
'from_email_name' => "XINON Kundenservice"
|
||||
]);
|
||||
|
||||
?>
|
||||
Sehr geehrte Damen und Herren,
|
||||
|
||||
im Anhang erhalten Sie das technische Übergabeprotokoll zum Anschluss des Kunden <?=$customer_string?> zur weiteren Verwendung.
|
||||
|
||||
Ihr XINON Team
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
$customer_string = str_replace(["\r","\n"], " ", $order->owner->getCompanyOrName())." [".$order->owner->customer_number."]";
|
||||
|
||||
$subject = "Neue PBX-Bestellung eingelangt ($customer_string)";
|
||||
|
||||
$this->setReturnValue([
|
||||
'subject' => $subject,
|
||||
'to' => "einkauf@xinon.at",
|
||||
'from_email' => TT_OUTGOING_EMAIL,
|
||||
'from_email_name' => TT_OUTGOING_EMAIL_NAME
|
||||
]);
|
||||
|
||||
?>
|
||||
<?=str_replace(["\r","\n"], " ", $file->creator->name)?> hat die Bestellung einer Telefonanlage für den Kunden <?=$customer_string?> angelegt - siehe Dokument im Anhang. Bitte um technische Prüfung und Materialabklärung bzw. Herstellungsfreigabe.
|
||||
|
||||
TheTool OrderROBOT (-;
|
||||
|
||||
https://<?=$_SERVER['HTTP_HOST']?><?=self::getUrl("Order","Index",['id' => $order->id])?>
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
$customer_string = str_replace(["\r","\n"], " ", $order->owner->getCompanyOrName())." [".$order->owner->customer_number."]";
|
||||
|
||||
$subject = "Neue Projektbestellung eingelangt ($customer_string)";
|
||||
|
||||
$this->setReturnValue([
|
||||
'subject' => $subject,
|
||||
'to' => "einkauf@xinon.at",
|
||||
'from_email' => TT_OUTGOING_EMAIL,
|
||||
'from_email_name' => TT_OUTGOING_EMAIL_NAME
|
||||
]);
|
||||
|
||||
?>
|
||||
<?=str_replace(["\r","\n"], " ", $file->creator->name)?> hat eine Projektbestellung für den Kunden <?=$customer_string?> angelegt - siehe Dokument im Anhang. Bitte um technische Prüfung und Materialabklärung bzw. Herstellungsfreigabe.
|
||||
|
||||
TheTool OrderROBOT (-;
|
||||
|
||||
https://<?=$_SERVER['HTTP_HOST']?><?=self::getUrl("Order","Index",['id' => $order->id])?>
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
$customer_string = str_replace(["\r","\n"], " ", $order->owner->getCompanyOrName())." [".$order->owner->customer_number."]";
|
||||
|
||||
$subject = "Neue Einzugsermächtigung eingelangt ($customer_string)";
|
||||
|
||||
$this->setReturnValue([
|
||||
'subject' => $subject,
|
||||
'to' => "billing@xinon.at",
|
||||
'from_email' => TT_OUTGOING_EMAIL,
|
||||
'from_email_name' => TT_OUTGOING_EMAIL_NAME
|
||||
]);
|
||||
|
||||
?>
|
||||
<?=str_replace(["\r","\n"], " ", $file->creator->name)?> hat soeben eine Einzugsermächtigung für den Kunden <?=$customer_string?> angelegt - siehe Dokument im Anhang. Bitte um Prüfung und Aktualisierung der Bankdaten des Kunden.
|
||||
|
||||
TheTool OrderROBOT (-;
|
||||
|
||||
https://<?=$_SERVER['HTTP_HOST']?><?=self::getUrl("Order","Index",['id' => $order->id])?>
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
$customer_string = str_replace(["\r","\n"], " ", $order->owner->getCompanyOrName())." [".$order->owner->customer_number."]";
|
||||
|
||||
$subject = "Neue Rufnummerportierung ($customer_string)";
|
||||
|
||||
$this->setReturnValue([
|
||||
'subject' => $subject,
|
||||
'to' => "portierung@xinon.at",
|
||||
'from_email' => TT_OUTGOING_EMAIL,
|
||||
'from_email_name' => TT_OUTGOING_EMAIL_NAME
|
||||
]);
|
||||
|
||||
?>
|
||||
<?=str_replace(["\r","\n"], " ", $file->creator->name)?> hat soeben eine Rufnummerportierung für den Kunden <?=$customer_string?> angelegt - siehe Dokument im Anhang. Bitte um Prüfung des Herstellungstermins und Einreichung.
|
||||
|
||||
TheTool OrderROBOT (-;
|
||||
|
||||
https://<?=$_SERVER['HTTP_HOST']?><?=self::getUrl("Order","Index",['id' => $order->id])?>
|
||||
79
Layout/andom-tec/Emailtemplates/order/int_billing_info.php
Normal file
79
Layout/andom-tec/Emailtemplates/order/int_billing_info.php
Normal file
@@ -0,0 +1,79 @@
|
||||
<?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()));
|
||||
|
||||
$this->setReturnValue([
|
||||
'subject' => $subject,
|
||||
|
||||
'from_email' => TT_OUTGOING_EMAIL,
|
||||
'from_email_name' => TT_OUTGOING_EMAIL_NAME
|
||||
]);
|
||||
|
||||
$nne_products = [];
|
||||
?>
|
||||
<?php if($order->upgrade): ?>
|
||||
Achtung: UPGRADE
|
||||
<?php endif; ?>
|
||||
|
||||
Netzgebiet: <?=$order->terminations[0]->building->network->name?>
|
||||
|
||||
Bauabschnitt: <?=(($order->terminations[0]->building->networksection_id) ? $order->terminations[0]->building->networksection->name : "<kein Bauabschnitt>")?>
|
||||
|
||||
Kundennummer: <?=$order->owner->customer_number?>
|
||||
|
||||
Kunde: <?=str_replace("\n", "", str_replace("\r\n", " ", $order->owner->getCompanyOrName()))?>
|
||||
|
||||
Verrechungsstart: <?=date("m", $billing_start)?>/<?=date("Y", $billing_start)?>
|
||||
|
||||
|
||||
Rechnungspositionen
|
||||
====================
|
||||
|
||||
Anzahl | Produktname | Verrechungsperiode | Preis periodisch | Preis Herstellung
|
||||
-----------------------------------------------------------------------------------------------------------------------
|
||||
<?php foreach($order->products as $op): ?>
|
||||
<?php if($op->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(count($nne_products)): ?>
|
||||
|
||||
Gutschriften
|
||||
=============
|
||||
|
||||
<?php if($order->terminations[0]->building->network->owner): ?>
|
||||
Netzeigentümer: <?=$order->terminations[0]->building->network->owner->getCompanyOrName()?>
|
||||
<?php endif; ?>
|
||||
|
||||
Anzahl | Produktname | Verrechungsperiode | Bauabschnitt | NNE
|
||||
-----------------------------------------------------------------------------------------------------------------------
|
||||
<?php foreach($nne_products as $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("%-24s", substr(($op->termination->building->networksection_id) ? $op->termination->building->networksection->name : "<Kein Bauabschnitt>",0,24))?> | EUR <?=$op->price_nne?>
|
||||
|
||||
-----------------------------------------------------------------------------------------------------------------------
|
||||
<?php endforeach; ?>
|
||||
|
||||
<?php endif; // (count($nne_products))?>
|
||||
|
||||
|
||||
@@ -18,23 +18,33 @@
|
||||
<li><a href="<?=self::getUrl("News")?>"><i class="far fa-th-list text-info"></i> News</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if($me->is(["Admin", "netowner"])): ?>
|
||||
<li class="has-submenu">
|
||||
<a href="#">
|
||||
<i class="far fa-database"></i>Stammdaten <div class="arrow-down"></div>
|
||||
</a>
|
||||
<ul class="submenu">
|
||||
<li class="has-sub-submenu">
|
||||
<a href="<?=self::getUrl("Address")?>"><i class="fad fa-user text-info"></i> Personen & Firmen</a>
|
||||
<!--<ul class="sub-submenu">
|
||||
<li><a href="<?=self::getUrl("Address", "Index" , ["filter" => ["addresstype" => ["employee"]]])?>"><i class="fas fa-"></i> Mitarbeiter</a></li>
|
||||
<li><a href="<?=self::getUrl("Address", "Index" , ["filter" => ["addresstype" => ["supplier"]]])?>"><i class="fas fa-"></i> Lieferanten</a></li>
|
||||
</ul>-->
|
||||
</li>
|
||||
<?php if($me->is(["Admin"])): ?>
|
||||
<li class="has-sub-submenu font-weight-bold"><a>Betriebsstammdaten</a></li>
|
||||
<li><a href="<?=self::getUrl("Address")?>"><i class="fad fa-user text-info"></i> Personen & Firmen</a></li>
|
||||
<li><a href="<?=self::getUrl("Product")?>"><i class="far fa-rectangle-list text-info"></i> Produkte</a></li>
|
||||
<li><a href="<?=self::getUrl("Producttech")?>"><i class="fad fa-microchip text-info"></i> Technologien</a></li>
|
||||
<li><a href="<?=self::getUrl("User")?>"><i class="fad fa-users text-info"></i> Benutzer</a></li>
|
||||
<li><a href="<?=self::getUrl("Productgroup")?>"><i class="far fa-list-tree text-info"></i> Produktgruppen</a></li>
|
||||
|
||||
<li><a href="<?=self::getUrl("Network")?>"><i class="fad fa-network-wired text-info"></i> Netzgebiete</a></li>
|
||||
<li class="has-sub-submenu"><a href="<?=self::getUrl("User")?>"><i class="fad fa-users text-info"></i> Benutzer</a></li>
|
||||
|
||||
<li class="has-sub-submenu font-weight-bold mt-1"><a>Grundstammdaten</a></li>
|
||||
<?php endif; ?>
|
||||
<?php if(false && $me->is(["Admin", "netowner"])): ?>
|
||||
<li><a href="<?=self::getUrl("AddressDB")?>"><i class="fas fa-city text-info"></i> GWR / AddressDB</a></li>
|
||||
<?php endif; ?>
|
||||
<?php if($me->is(["Admin"])): ?>
|
||||
<li><a href="<?=self::getUrl("Producttech")?>"><i class="fad fa-microchip text-info"></i> Technologien</a></li>
|
||||
<!--<li><a href="<?=self::getUrl("Contractconfig")?>"><i class="fad fa-gear text-info"></i> ContractConfig</a></li>-->
|
||||
<?php endif; ?>
|
||||
|
||||
</ul>
|
||||
</li>
|
||||
<?php endif; ?>
|
||||
@@ -66,8 +76,7 @@
|
||||
</li>
|
||||
<?php endif; ?>
|
||||
|
||||
<!--
|
||||
<?php if($me->is(["Admin"])): ?>
|
||||
<?php if(false && $me->is(["Admin"])): ?>
|
||||
<li class="has-submenu">
|
||||
<a href="#">
|
||||
<i class="fad fa-phone"></i>Telefonie <div class="arrow-down"></div>
|
||||
@@ -77,17 +86,19 @@
|
||||
</ul>
|
||||
</li>
|
||||
<?php endif; ?>
|
||||
-->
|
||||
<?php if($me->is(["Admin","salespartner"])): ?>
|
||||
|
||||
<?php if($me->is(["Admin","netowner","salespartner"])): ?>
|
||||
<li class="has-submenu">
|
||||
<a href="#">
|
||||
<i class="fal fa-money-bill-wave"></i>Verkauf <div class="arrow-down"></div>
|
||||
</a>
|
||||
<ul class="submenu">
|
||||
<?php if($me->is(["Admin"])): ?>
|
||||
<!--<li><a href="<?=self::getUrl("Preordercampaign")?>"><i class="far fa-calendar-lines text-info"></i> Vorbestellung</a></li>-->
|
||||
<?php if(false && $me->is(["Admin","netowner","salespartner"])): ?>
|
||||
<li><a href="<?=self::getUrl("Preordercampaign")?>"><i class="far fa-calendar-lines text-info"></i> Vorbestellung</a></li>
|
||||
<?php endif; ?>
|
||||
<?php if($me->is(["Admin","salespartner"])): ?>
|
||||
<li><a href="<?=self::getUrl("Order")?>"><i class="far fa-file-signature text-info"></i> Bestellungen</a></li>
|
||||
<?php endif; ?>
|
||||
<li><a href="<?=self::getUrl("Order")?>"><i class="far fa-file-signature text-info"></i> Bestellungen</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<?php endif; ?>
|
||||
@@ -100,7 +111,7 @@
|
||||
<ul class="submenu">
|
||||
<li><a href="<?=self::getUrl("Contract")?>"><i class="fas fa-file-contract"></i> Verträge</a></li>
|
||||
<li><hr /></li>
|
||||
<li><a href="<?=self::getUrl("Contractconfig")?>"><i class="fas fa-wrench"></i> Vertragsconfig</a></li>
|
||||
<li><a href="<?=self::getUrl("Contractconfiggroup")?>"><i class="fas fa-wrench"></i> Vertragsconfig</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<?php endif; ?>
|
||||
|
||||
117
Layout/andom-tec/menu_old.php
Normal file
117
Layout/andom-tec/menu_old.php
Normal file
@@ -0,0 +1,117 @@
|
||||
<div class="topbar-menu">
|
||||
<div class="container-fluid">
|
||||
<div id="navigation">
|
||||
<!-- Navigation Menu-->
|
||||
<ul class="navigation-menu">
|
||||
|
||||
<?php if(!$me->is("Admin")): ?>
|
||||
<li class="has-submenu">
|
||||
<a href="<?=self::getUrl("Dashboard")?>"><i class="fe-airplay"></i> Dashboard</a>
|
||||
</li>
|
||||
<?php endif; ?>
|
||||
|
||||
|
||||
<?php if($me->is("Admin")): ?>
|
||||
<li class="has-submenu">
|
||||
<a href="<?=self::getUrl("Dashboard")?>"><i class="fe-airplay"></i> Dashboard <div class="arrow-down"></div></a>
|
||||
<ul class="submenu">
|
||||
<li><a href="<?=self::getUrl("News")?>"><i class="far fa-th-list text-info"></i> News</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
|
||||
<li class="has-submenu">
|
||||
<a href="#">
|
||||
<i class="far fa-database"></i>Stammdaten <div class="arrow-down"></div>
|
||||
</a>
|
||||
<ul class="submenu">
|
||||
<li class="has-sub-submenu">
|
||||
<a href="<?=self::getUrl("Address")?>"><i class="fad fa-user text-info"></i> Personen & Firmen</a>
|
||||
<!--<ul class="sub-submenu">
|
||||
<li><a href="<?=self::getUrl("Address", "Index" , ["filter" => ["addresstype" => ["employee"]]])?>"><i class="fas fa-"></i> Mitarbeiter</a></li>
|
||||
<li><a href="<?=self::getUrl("Address", "Index" , ["filter" => ["addresstype" => ["supplier"]]])?>"><i class="fas fa-"></i> Lieferanten</a></li>
|
||||
</ul>-->
|
||||
</li>
|
||||
<li><a href="<?=self::getUrl("Product")?>"><i class="far fa-rectangle-list text-info"></i> Produkte</a></li>
|
||||
<li><a href="<?=self::getUrl("Producttech")?>"><i class="fad fa-microchip text-info"></i> Technologien</a></li>
|
||||
<li><a href="<?=self::getUrl("User")?>"><i class="fad fa-users text-info"></i> Benutzer</a></li>
|
||||
<li><a href="<?=self::getUrl("Network")?>"><i class="fad fa-network-wired text-info"></i> Netzgebiete</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<?php endif; ?>
|
||||
|
||||
|
||||
<?php if($me->is(["Admin","netowner","lineplanner","pipeplanner","pipeworker","lineworker"])): ?>
|
||||
<li class="has-submenu">
|
||||
<a href="#">
|
||||
<i class="fas fa-hard-hat"></i>Netzbau <div class="arrow-down"></div>
|
||||
</a>
|
||||
<ul class="submenu">
|
||||
<?php if($me->is(["Admin","netowner","pipeplanner"])): ?><li><a href="<?=self::getUrl("Building")?>"><i class="fas fa-city text-info"></i> Objekte & Anschlüsse</a></li><?php endif; ?>
|
||||
<?php if($me->is(["Admin","netowner","pipeplanner","pipeworker","lineplanner","lineworker"])): ?><li><a href="<?=self::getUrl("Pipework")?>"><i class="fad fa-wrench text-info"></i> Tiefbau</a></li><?php endif; ?>
|
||||
<?php if($me->is(["Admin","netowner","lineplanner","lineworker"])): ?><li><a href="<?=self::getUrl("Linework")?>"><i class="fas fa-ethernet text-info"></i> Leitungsbau</a></li><?php endif; ?>
|
||||
<?php if($me->is(["Admin", "netowner", "netoperator", "lineworker"])): ?><li><a href="<?=self::getUrl("Patching")?>"><i class="fas fa-plug text-info"></i> Patchungen</a></li><?php endif; ?>
|
||||
</ul>
|
||||
</li>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if($me->is(["Admin"])): ?>
|
||||
<li class="has-submenu">
|
||||
<a href="#">
|
||||
<i class="fad fa-running"></i>Netzbetrieb <div class="arrow-down"></div>
|
||||
</a>
|
||||
<ul class="submenu">
|
||||
<li><a href="<?=self::getUrl("Cpeprovisioning")?>"><i class="fad fa-hdd text-info"></i> CPE Provisioning</a></li>
|
||||
<li><a href="<?=self::getUrl("Cpeshipping")?>"><i class="fad fa-shipping-fast text-info"></i> CPE Versand</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<?php endif; ?>
|
||||
|
||||
<!--
|
||||
<?php if($me->is(["Admin"])): ?>
|
||||
<li class="has-submenu">
|
||||
<a href="#">
|
||||
<i class="fad fa-phone"></i>Telefonie <div class="arrow-down"></div>
|
||||
</a>
|
||||
<ul class="submenu">
|
||||
<li><a href="<?=self::getUrl("Voicenumberblock")?>"><i class="fad fa-blender-phone text-info"></i> Rufnummernblöcke</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<?php endif; ?>
|
||||
-->
|
||||
<?php if($me->is(["Admin","salespartner"])): ?>
|
||||
<li class="has-submenu">
|
||||
<a href="#">
|
||||
<i class="fal fa-money-bill-wave"></i>Verkauf <div class="arrow-down"></div>
|
||||
</a>
|
||||
<ul class="submenu">
|
||||
<?php if($me->is(["Admin"])): ?>
|
||||
<!--<li><a href="<?=self::getUrl("Preordercampaign")?>"><i class="far fa-calendar-lines text-info"></i> Vorbestellung</a></li>-->
|
||||
<?php endif; ?>
|
||||
<li><a href="<?=self::getUrl("Order")?>"><i class="far fa-file-signature text-info"></i> Bestellungen</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<?php endif; ?>
|
||||
<!--
|
||||
<?php if($me->is(["Admin"])): ?>
|
||||
<li class="has-submenu">
|
||||
<a href="#">
|
||||
<i class="fas fa-shopping-basket"></i>Verträge<div class="arrow-down"></div>
|
||||
</a>
|
||||
<ul class="submenu">
|
||||
<li><a href="<?=self::getUrl("Contract")?>"><i class="fas fa-file-contract"></i> Verträge</a></li>
|
||||
<li><hr /></li>
|
||||
<li><a href="<?=self::getUrl("Contractconfig")?>"><i class="fas fa-wrench"></i> Vertragsconfig</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<?php endif; ?>
|
||||
-->
|
||||
</ul>
|
||||
<!-- End navigation menu -->
|
||||
|
||||
<div class="clearfix"></div>
|
||||
</div>
|
||||
<!-- end #navigation -->
|
||||
</div>
|
||||
<!-- end container -->
|
||||
</div>
|
||||
<!-- end navbar-custom -->
|
||||
@@ -161,7 +161,7 @@
|
||||
<div class="col-lg-10">
|
||||
<select class="select2 form-control select2-multiple" name="addresstypes[]" id="addresstypes" multiple="multiple" data-placeholder="Choose ...">
|
||||
<?php foreach(TT_ROLES as $role): ?>
|
||||
<option value="<?=$role?>" <?=(array_key_exists($role, $address->types)) ? "selected='selected'" : ""?>><?=__($role)?></option>
|
||||
<option value="<?=$role?>" <?=(is_array($address->types) && array_key_exists($role, $address->types)) ? "selected='selected'" : ""?>><?=__($role)?></option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
</div>
|
||||
@@ -262,7 +262,7 @@
|
||||
<th></th>
|
||||
</tr>
|
||||
<?php foreach(TT_ADDRESS_LINK_TYPES as $type): ?>
|
||||
<?php if(array_key_exists($type, $address->links)): ?>
|
||||
<?php if(is_array($address->links) && count($address->links) && array_key_exists($type, $address->links)): ?>
|
||||
<?php foreach($address->links[$type] as $link): ?>
|
||||
<tr>
|
||||
<td class="font-weight-bold"><?=__($type)?></td>
|
||||
|
||||
@@ -181,11 +181,13 @@
|
||||
</td>
|
||||
<?php endif; ?>
|
||||
<td>
|
||||
<?=$address->customer_number?>
|
||||
<?=($address->spin) ? "<br /><span class='text-pink'>".$address->spin."</span>" : ""?>
|
||||
<a href="<?=self::getUrl("Address", "view", ["id" => $address->id, 'filter' => $filter, 's' => $pagination['start']])?>">
|
||||
<?=$address->customer_number?>
|
||||
<?=($address->spin) ? "<br /><span class='text-pink'>".$address->spin."</span>" : ""?>
|
||||
</a>
|
||||
</td>
|
||||
<td><?=nl2br($address->company)?></td>
|
||||
<td><?=$address->getFullName()?></td>
|
||||
<td><a href="<?=self::getUrl("Address", "view", ["id" => $address->id, 'filter' => $filter, 's' => $pagination['start']])?>"><?=nl2br($address->company)?></a></td>
|
||||
<td><a href="<?=self::getUrl("Address", "view", ["id" => $address->id, 'filter' => $filter, 's' => $pagination['start']])?>"><?=$address->getFullName()?></a></td>
|
||||
<td>
|
||||
<?=$address->street?><br />
|
||||
<?=$address->zip?> <?=$address->city?>
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<h4>Person/Firma</h4>
|
||||
<h3 class="text-center mb-3"><?=$address->getCompanyOrName()?><?=($address->customer_number) ? " [".$address->customer_number."]" : ""?></h3>
|
||||
|
||||
<table class="table table-sm table-striped view-table">
|
||||
<tr>
|
||||
@@ -129,8 +129,7 @@
|
||||
<tr>
|
||||
<th>Typ</th>
|
||||
<th>Firma</th>
|
||||
<th>Vorname</th>
|
||||
<th>Nachname</th>
|
||||
<th>Name</th>
|
||||
<th>Telefon</th>
|
||||
<th>Mobil</th>
|
||||
<th>Email</th>
|
||||
@@ -142,8 +141,7 @@
|
||||
<tr>
|
||||
<td class="font-weight-bold"><?=__($type)?></td>
|
||||
<td><a href="<?=self::getUrl("Address", "view", ["id" => $link->address_id])?>"><?=$link->address->company?></a></td>
|
||||
<td><a href="<?=self::getUrl("Address", "view", ["id" => $link->address_id])?>"><?=$link->address->firstname?></a></td>
|
||||
<td><?=$link->address->lastname?></td>
|
||||
<td><a href="<?=self::getUrl("Address", "view", ["id" => $link->address_id])?>"><?=$link->address->getFullName()?></a></td>
|
||||
<td><?=$link->address->phone?></td>
|
||||
<td><?=$link->address->mobile?></td>
|
||||
<td><?=$link->address->email?></td>
|
||||
@@ -168,7 +166,7 @@
|
||||
<?php if(array_key_exists($type, $address->linked_as)): ?>
|
||||
<?php foreach($address->linked_as[$type] as $link): ?>
|
||||
<tr>
|
||||
<td><?=__($type)?> für:</td>
|
||||
<td><strong><?=__($type)?></strong> für:</td>
|
||||
<td><a href="<?=self::getUrl("Address", "view", ['id' => $link->origin_address_id])?>"><?=$link->origin->getCompanyOrName()?><?=($link->origin->customer_number) ? " [".$link->origin->customer_number."]" : ""?></a></td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
@@ -182,6 +180,49 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php if(is_array($address->contracts) && count($address->contracts)): ?>
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<h4>Verträge</h4>
|
||||
|
||||
<table class="table table-striped table-sm table-bordered table-hover">
|
||||
<tr>
|
||||
<th>Rolle</th>
|
||||
<th>Contract ID</th>
|
||||
<th>Produkt</th>
|
||||
<th>Matchcode</th>
|
||||
<th>Bestelldatum</th>
|
||||
<th>Fertigstellung</th>
|
||||
<th>Kündigung</th>
|
||||
<th></th>
|
||||
</tr>
|
||||
<?php foreach($address->contracts as $contract): ?>
|
||||
<tr>
|
||||
<td class="contract <?=($contract->isCancelled()) ? "canceled" : ""?>">
|
||||
<a href="<?=self::getUrl("Contract", "View", ["id" => $contract->id])?>">
|
||||
<?php if($contract->owner_id == $address->id): ?>
|
||||
Vertragsinhaber
|
||||
<?php elseif($contract->billingaddress_id == $address->id): ?>
|
||||
Rechnungsempfänger
|
||||
<?php endif; ?>
|
||||
</a>
|
||||
</td>
|
||||
<td class="contract <?=($contract->isCancelled()) ? "canceled" : ""?>"><a href="<?=self::getUrl("Contract", "View", ["id" => $contract->id])?>"><?=$contract->id?></a></td>
|
||||
<td class="contract <?=($contract->isCancelled()) ? "canceled" : ""?>"><a href="<?=self::getUrl("Contract", "View", ["id" => $contract->id])?>"><?=$contract->product_name?></a></td>
|
||||
<td class="contract <?=($contract->isCancelled()) ? "canceled" : ""?>"><a href="<?=self::getUrl("Contract", "View", ["id" => $contract->id])?>"><?=$contract->matchcode?></a></td>
|
||||
<td class="contract <?=($contract->isCancelled()) ? "canceled" : ""?>"><?=($contract->order_date) ? date('d.m.Y', $contract->order_date) : ""?></td>
|
||||
<td class="contract <?=($contract->isCancelled()) ? "canceled" : ""?>"><?=($contract->finish_date) ? date('d.m.Y', $contract->finish_date) : ""?></td>
|
||||
<td class="contract <?=($contract->isCancelled()) ? "canceled" : ""?>"><?=($contract->cancel_date) ? date('d.m.Y', $contract->cancel_date) : ""?></td>
|
||||
<td>
|
||||
<a href="<?=self::getUrl("Contract", "deleteLink", ["link_id" => $contract->id])?>" onclick="if(!confirm('Verknüpfung wirklich entfernen?')) return false;" class="text-danger" title="Verknüpfung entfernen"><i class="fas fa-xmark-large"></i></a>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<a href="<?=self::getUrl("Address","Index", ['filter' => $filter, 's' => $s])?>" class="btn btn-secondary mr-1"><i class="fas fa-list"></i> Zurück zur Übersicht</a>
|
||||
|
||||
296
Layout/default/AddressDB/Form.php
Normal file
296
Layout/default/AddressDB/Form.php
Normal file
@@ -0,0 +1,296 @@
|
||||
<?php
|
||||
$urlfilter = [];
|
||||
if($s) {
|
||||
$urlfilter['s'] = $s;
|
||||
}
|
||||
if(is_array($filter) && count($filter)) {
|
||||
$urlfilter["filter"] = $filter;
|
||||
}
|
||||
$posturl = self::getUrl("AddressDB", "save", $urlfilter);
|
||||
|
||||
|
||||
/*
|
||||
* check if address is in one of our networks
|
||||
*/
|
||||
if($address_id && !array_key_exists($address->netzgebiet_id, $my_adb_networks)) {
|
||||
$this->setFlash("Keine Berechtigung", "error");
|
||||
mfBaseController::redirect("AddressDB");
|
||||
}
|
||||
|
||||
?>
|
||||
<?php include(realpath(dirname(__FILE__)."/../../$mfLayoutPackage")."/header.php"); ?>
|
||||
<!-- start page title -->
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<div class="page-title-box">
|
||||
<div class="page-title-right">
|
||||
<ol class="breadcrumb m-0">
|
||||
<li class="breadcrumb-item"><a href="<?=self::getUrl("Dashboard")?>"><?=MFAPPNAME_SLUG?></a></li>
|
||||
<li class="breadcrumb-item"><a href="<?=self::getUrl("AddressDB")?>">GWR / AddressDB</a></li>
|
||||
<li class="breadcrumb-item active"><?=($address->id) ? "bearbeiten" : "Neu" ?></li>
|
||||
</ol>
|
||||
</div>
|
||||
<h4 class="page-title">Adresse</h4>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- end page title -->
|
||||
|
||||
<div class="row">
|
||||
<div class="col-lg-12">
|
||||
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<h4 class="header-title mb-2"><?=($address->id) ? "Adresse bearbeiten" : "Neue Adresse"?></h4>
|
||||
|
||||
<form class="form-horizontal" method="post" action="<?=$posturl?>">
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
|
||||
<?php if(is_array($save_data) && array_key_exists("oaid", $save_data)): ?>
|
||||
<input type="hidden" name="id" value="<?=$save_data['id']?>" />
|
||||
<input type="hidden" name="f" value="<?=$save_data['f']?>" />
|
||||
<?php else: ?>
|
||||
<input type="hidden" name="id" value="<?=$address->id?>" />
|
||||
<input type="hidden" name="f" value="<?=$f?>" />
|
||||
<?php endif; ?>
|
||||
|
||||
|
||||
|
||||
<div class="form-group row">
|
||||
<label class="col-lg-2 col-form-label" for="oaid">OAID</label>
|
||||
<div class="col-lg-10">
|
||||
<?php if(is_array($save_data) && array_key_exists("oaid", $save_data)): ?>
|
||||
<input type="text" class="form-control" name="oaid" id="oaid" value="<?=$save_data['oaid']?>" readonly="readonly" />
|
||||
<?php else: ?>
|
||||
<input type="text" class="form-control" name="oaid" id="oaid" value="<?=$address->oaid?>" readonly="readonly" />
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group row">
|
||||
<label class="col-lg-2 col-form-label" for="adrcd">ADRCD</label>
|
||||
<div class="col-lg-10">
|
||||
<?php if(is_array($save_data) && array_key_exists("strasse", $save_data)): ?>
|
||||
<input type="text" class="form-control" name="adrcd" id="adrcd" value="<?=$save_data['adrcd']?>" />
|
||||
<?php else: ?>
|
||||
<input type="text" class="form-control" name="adrcd" id="adrcd" value="<?=$address->adrcd?>" />
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group row">
|
||||
<label class="col-lg-2 col-form-label" for="extref">Extref</label>
|
||||
<div class="col-lg-10">
|
||||
<?php if(is_array($save_data) && array_key_exists("strasse", $save_data)): ?>
|
||||
<input type="text" class="form-control" name="extref" id="extref" value="<?=$save_data['extref']?>" />
|
||||
<?php else: ?>
|
||||
<input type="text" class="form-control" name="extref" id="extref" value="<?=$address->extref?>" />
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<hr />
|
||||
|
||||
<div class="form-group row">
|
||||
<label class="col-lg-2 col-form-label" for="netzgebiet_id">Netzgebiet *</label>
|
||||
<div class="col-lg-10">
|
||||
<select class="form-control" name="netzgebiet_id" id="netzgebiet_id">
|
||||
<?php foreach($my_adb_networks as $fnet): ?>
|
||||
<?php if(is_array($save_data) && array_key_exists("netzgebiet_id", $save_data) && $save_data['netzgebiet_id']): ?>
|
||||
<option value="<?=$fnet->id?>" <?=($save_data['netzgebiet_id'] == $fnet->id) ? "selected='selected'" : ""?>><?=$fnet->name?></option>
|
||||
<?php else: ?>
|
||||
<option value="<?=$fnet->id?>" <?=($address->netzgebiet_id == $fnet->id) ? "selected='selected'" : ""?>><?=$fnet->name?></option>
|
||||
<?php endif; ?>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<div class="form-group row">
|
||||
<label class="col-lg-2 col-form-label" for="strasse">Straße *</label>
|
||||
<div class="col-lg-10">
|
||||
<?php if(is_array($save_data) && array_key_exists("strasse", $save_data)): ?>
|
||||
<input type="text" class="form-control basicAutoComplete" data-url="<?=self::getUrl('AddressDB','api')?>?do=findStreets&autocomplete=1" name="strasse" id="strasse" value="<?=$save_data['strasse']?>">
|
||||
<?php else: ?>
|
||||
<input type="text" class="form-control basicAutoComplete" data-url="<?=self::getUrl('AddressDB','api')?>?do=findStreets&autocomplete=1" name="strasse" id="strasse" value="<?=$address->strasse->name?>">
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group row">
|
||||
<label class="col-lg-2 col-form-label" for="hausnummer">Hausnummer *</label>
|
||||
<div class="col-lg-10">
|
||||
<?php if(is_array($save_data) && array_key_exists("hausnummer", $save_data)): ?>
|
||||
<input type="text" class="form-control" name="hausnummer" id="hausnummer" value="<?=$save_data['hausnummer']?>">
|
||||
<?php else: ?>
|
||||
<input type="text" class="form-control" name="hausnummer" id="hausnummer" value="<?=$address->hausnummer?>">
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group row">
|
||||
<label class="col-lg-2 col-form-label" for="plz">PLZ *</label>
|
||||
<div class="col-lg-10">
|
||||
<?php if(is_array($save_data) && array_key_exists("plz", $save_data)): ?>
|
||||
<input type="text" class="form-control basicAutoComplete" autocomplete="off" data-url="<?=self::getUrl('AddressDB','api')?>?do=findZips&autocomplete=1" name="plz" id="plz" value="<?=$save_data['plz']?>">
|
||||
<?php else: ?>
|
||||
<input type="text" class="form-control basicAutoComplete" autocomplete="off" data-url="<?=self::getUrl('AddressDB','api')?>?do=findZips&autocomplete=1" name="plz" id="plz" value="<?=$address->plz->plz?>">
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group row">
|
||||
<label class="col-lg-2 col-form-label" for="ortschaft">Ortschaft *</label>
|
||||
<div class="col-lg-10">
|
||||
<?php if(is_array($save_data) && array_key_exists("ortschaft", $save_data)): ?>
|
||||
<input type="text" class="form-control basicAutoComplete" autocomplete="off" data-url="<?=self::getUrl('AddressDB','api')?>?do=findDistricts&autocomplete=1" name="ortschaft" id="ortschaft" value="<?=$save_data['ortschaft']?>">
|
||||
<?php else: ?>
|
||||
<input type="text" class="form-control basicAutoComplete" autocomplete="off" data-url="<?=self::getUrl('AddressDB','api')?>?do=findDistricts&autocomplete=1" name="ortschaft" id="ortschaft" value="<?=$address->ortschaft->name?>">
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group row">
|
||||
<label class="col-lg-2 col-form-label" for="gemeinde">Gemeinde *</label>
|
||||
<div class="col-lg-10">
|
||||
<?php if(is_array($save_data) && array_key_exists("gemeinde", $save_data)): ?>
|
||||
<input type="text" class="form-control basicAutoComplete" autocomplete="off" data-url="<?=self::getUrl('AddressDB','api')?>?do=findCities&autocomplete=1" name="gemeinde" id="gemeinde" value="<?=$save_data['gemeinde']?>">
|
||||
<?php else: ?>
|
||||
<input type="text" class="form-control basicAutoComplete" autocomplete="off" data-url="<?=self::getUrl('AddressDB','api')?>?do=findCities&autocomplete=1" name="gemeinde" id="gemeinde" value="<?=$address->strasse->gemeinde->name?>">
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group row">
|
||||
<label class="col-lg-2 col-form-label" for="grund_nr">Grundstücksnr.</label>
|
||||
<div class="col-lg-10">
|
||||
<?php if(is_array($save_data) && array_key_exists("grund_nr", $save_data)): ?>
|
||||
<input type="text" class="form-control" name="grund_nr" id="grund_nr" value="<?=$save_data['grund_nr']?>">
|
||||
<?php else: ?>
|
||||
<input type="text" class="form-control" name="grund_nr" id="grund_nr" value="<?=$address->grund_nr?>">
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group row">
|
||||
<label class="col-lg-2 col-form-label" for="gps_lat">GPS Breite</label>
|
||||
<div class="col-lg-10">
|
||||
<?php if(is_array($save_data) && array_key_exists("gps_lat", $save_data)): ?>
|
||||
<input type="text" class="form-control" name="gps_lat" id="gps_lat" value="<?=$save_data['gps_lat']?>">
|
||||
<?php else: ?>
|
||||
<input type="text" class="form-control" name="gps_lat" id="gps_lat" value="<?=$address->gps_lat?>">
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group row">
|
||||
<label class="col-lg-2 col-form-label" for="gps_long">GPS Länge</label>
|
||||
<div class="col-lg-10">
|
||||
<?php if(is_array($save_data) && array_key_exists("gps_long", $save_data)): ?>
|
||||
<input type="text" class="form-control" name="gps_long" id="gps_long" value="<?=$save_data['gps_long']?>">
|
||||
<?php else: ?>
|
||||
<input type="text" class="form-control" name="gps_long" id="gps_long" value="<?=$address->gps_long?>">
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<hr />
|
||||
|
||||
<div class="form-group row">
|
||||
<label class="col-lg-2 col-form-label" for="rollout">Rollout Jahr (Ganzzahl)</label>
|
||||
<div class="col-lg-10">
|
||||
<?php if(is_array($save_data) && array_key_exists("rollout", $save_data)): ?>
|
||||
<input type="text" class="form-control" name="rollout" id="rollout" value="<?=$save_data['rollout']?>">
|
||||
<?php else: ?>
|
||||
<input type="text" class="form-control" name="rollout" id="rollout" value="<?=$address->rollout?>">
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group row">
|
||||
<label class="col-lg-2 col-form-label" for="rollout_info">Rollout Info</label>
|
||||
<div class="col-lg-10">
|
||||
<?php if(is_array($save_data) && array_key_exists("rollout_info", $save_data)): ?>
|
||||
<input type="text" class="form-control" name="rollout_info" id="rollout_info" value="<?=$save_data['rollout_info']?>">
|
||||
<?php else: ?>
|
||||
<input type="text" class="form-control" name="rollout_info" id="rollout_info" value="<?=$address->rollout_info?>">
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group row">
|
||||
<label class="col-lg-2 col-form-label" for="freigabe">Erlaubte Bestelltypen</label>
|
||||
<div class="col-lg-10">
|
||||
<select class="form-control select2" name="freigabe[]" id="freigabe" multiple="multiple">
|
||||
<?php if(is_array($save_data) && array_key_exists("freigabe", $save_data)): ?>
|
||||
<option value="interest" <?=(is_array($save_data['freigabe']) && in_array("interest",$save_data['freigabe'])) ? "selected='selected'" : ""?>>Interessensbekundung</option>
|
||||
<option value="provision" <?=(is_array($save_data['freigabe']) && in_array("provision",$save_data['freigabe'])) ? "selected='selected'" : ""?>>Vorsorgeanschluss</option>
|
||||
<option value="order" <?=(is_array($save_data['freigabe']) && in_array("order",$save_data['freigabe'])) ? "selected='selected'" : ""?>>Vollanschluss</option>
|
||||
<option value="reorder" <?=(is_array($save_data['freigabe']) && in_array("reorder",$save_data['freigabe'])) ? "selected='selected'" : ""?>>Nachbestellung</option>
|
||||
<?php else: ?>
|
||||
<option value="interest" <?=(is_array($address->freigaben) && in_array("interest",$address->freigaben)) ? "selected='selected'" : ""?>>Interessensbekundung</option>
|
||||
<option value="provision" <?=(is_array($address->freigaben) && in_array("provision",$address->freigaben)) ? "selected='selected'" : ""?>>Vorsorgeanschluss</option>
|
||||
<option value="order" <?=(is_array($address->freigaben) && in_array("order",$address->freigaben)) ? "selected='selected'" : ""?>>Vollanschluss</option>
|
||||
<option value="reorder" <?=(is_array($address->freigaben) && in_array("reorder",$address->freigaben)) ? "selected='selected'" : ""?>>Nachbestellung</option>
|
||||
<?php endif; ?>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php if(!$address->id): ?>
|
||||
<hr />
|
||||
|
||||
<div class="form-group row">
|
||||
<label class="col-lg-2 col-form-label" for="unit_count">Anzahl Wohneinheiten</label>
|
||||
<div class="col-lg-10">
|
||||
<?php if(is_array($save_data) && array_key_exists("unit_count", $save_data)): ?>
|
||||
<input type="text" class="form-control" name="unit_count" id="unit_count" value="<?=$save_data['unit_count']?>">
|
||||
<?php else: ?>
|
||||
<input type="text" class="form-control" name="unit_count" id="unit_count" value="">
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<div class="form-group row">
|
||||
<label class="col-lg-2"></label>
|
||||
<div class="col-lg-10">
|
||||
<button type="submit" class="btn btn-primary">Speichern</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
$(".select2").select2();
|
||||
|
||||
$('#strasse').autoComplete({minLength: 2}).keydown(preventEnter);
|
||||
$('#plz').autoComplete({minLength: 1}).keydown(preventEnter);
|
||||
$('#gemeinde').autoComplete({minLength: 2}).keydown(preventEnter);
|
||||
$('#ortschaft').autoComplete({minLength: 2}).keydown(preventEnter);
|
||||
$('#hausnummer').keydown(preventEnter);
|
||||
|
||||
function preventEnter() {
|
||||
if(event.keyCode == 13) {
|
||||
event.preventDefault();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<?php include(realpath(dirname(__FILE__)."/../../$mfLayoutPackage")."/footer.php"); ?>
|
||||
216
Layout/default/AddressDB/Index.php
Normal file
216
Layout/default/AddressDB/Index.php
Normal file
@@ -0,0 +1,216 @@
|
||||
<?php
|
||||
$pagination_baseurl = $this->getUrl($Mod,"Index");
|
||||
$pagination_baseurl_params = ["filter" => $filter];
|
||||
$pagination_entity_name = "Adressen";
|
||||
?>
|
||||
<?php include(realpath(dirname(__FILE__)."/../../$mfLayoutPackage")."/header.php"); ?>
|
||||
|
||||
<!-- start page title -->
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<div class="page-title-box">
|
||||
<div class="page-title-right">
|
||||
<ol class="breadcrumb m-0">
|
||||
<li class="breadcrumb-item"><a href="<?=self::getUrl("Dashboard")?>"><?=MFAPPNAME_SLUG?></a></li>
|
||||
<li class="breadcrumb-item active">GWR / AddressDB</li>
|
||||
</ol>
|
||||
</div>
|
||||
<h4 class="page-title">GWR / AddressDB</h4>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- end page title -->
|
||||
|
||||
<div class="row">
|
||||
<div class="col-lg-12">
|
||||
|
||||
<div class="card">
|
||||
<div class="card-body mb-3">
|
||||
<h4 class="header-title mb-3">Filter</h4>
|
||||
|
||||
<form method="get" id="filter_form" action="<?=self::getUrl("AddressDB")?>">
|
||||
<div class="row">
|
||||
|
||||
<div class="col-2">
|
||||
<label class="form-label" for="filter_network_id">Netzgebiet</label>
|
||||
<select name="filter[network_id]" id="filter_network_id" class="form-control">
|
||||
<option></option>
|
||||
<?php foreach($my_adb_networks as $fnet): ?>
|
||||
<option value="<?=$fnet->id?>" <?=($filter['network_id'] == $fnet->id) ? "selected='selected'" : ""?>><?=$fnet->name?></option>
|
||||
<?php endforeach; ?>
|
||||
<?php if($me->isAdmin()):?><option value="null" <?=($filter['network_id'] === "null") ? 'selected="selected"' : ""?>>-- Kein Netzgebiet --</option><?php endif; ?>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="col-1">
|
||||
<label class="form-label" for="filter_zip">PLZ</label>
|
||||
<input type="text" class="form-control" name="filter[zip]" id="filter_zip" value="<?=$filter['zip']?>" />
|
||||
</div>
|
||||
|
||||
<div class="col-2">
|
||||
<div class="<?=(array_key_exists("network_id", $filter) && $filter['network_id'] === "null") ? "hidden" : ""?>" id="filter-gemeinde-id">
|
||||
<label class="form-label" for="filter_gemeinde_id">Gemeinde</label>
|
||||
<select name="filter[gemeinde_id]" id="filter_gemeinde_id" class="form-control">
|
||||
<option></option>
|
||||
<?php foreach($gemeinden as $gemeinde): ?>
|
||||
<option value="<?=$gemeinde->id?>" <?=($filter['gemeinde_id'] == $gemeinde->id) ? "selected='selected'" : ""?>><?=$gemeinde->name?></option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
</div>
|
||||
<div class="<?=(!array_key_exists("network_id", $filter) || $filter['network_id'] !== "null") ? "hidden" : ""?>" id="filter-gemeinde-text">
|
||||
<label class="form-label" for="filter_gemeinde">Gemeinde</label>
|
||||
<input type="text" class="form-control" name="filter[gemeinde]" id="filter_gemeinde" value="<?=$filter['gemeinde']?>" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-2">
|
||||
<div class="<?=(array_key_exists("network_id", $filter) && $filter['network_id'] == "null") ? "hidden" : ""?>" id="filter-ortschaft-id">
|
||||
<label class="form-label" for="filter_ortschaft_id">Ortschaft/Ortsteil</label>
|
||||
<select name="filter[ortschaft_id]" id="filter_ortschaft_id" class="form-control">
|
||||
<option></option>
|
||||
<?php foreach($ortschaften as $ortschaft): ?>
|
||||
<option value="<?=$ortschaft->id?>" <?=($filter['ortschaft_id'] == $ortschaft->id) ? "selected='selected'" : ""?>><?=$ortschaft->name?></option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
</div>
|
||||
<div class="<?=(!array_key_exists("network_id", $filter) || $filter['network_id'] !== "null") ? "hidden" : ""?>" id="filter-ortschaft-text">
|
||||
<label class="form-label" for="filter_ortschaft">Ortsteil</label>
|
||||
<input type="text" class="form-control" name="filter[ortschaft]" id="filter_ortschaft" value="<?=$filter['ortschaft']?>" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-2">
|
||||
<label class="form-label" for="filter_street">Strasse</label>
|
||||
<input type="text" class="form-control" name="filter[street]" id="filter_street" value="<?=$filter['street']?>" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row mt-2">
|
||||
<div class="col-2">
|
||||
<label class="form-label" for="filter_oaid">OAID</label>
|
||||
<input type="text" class="form-control" name="filter[oaid]" id="filter_oaid" value="<?=$filter['oaid']?>" />
|
||||
</div>
|
||||
|
||||
<div class="col-1">
|
||||
<label class="form-label" for="filter_adrcd">Adrcd (GWR)</label>
|
||||
<input type="text" class="form-control" name="filter[adrcd]" id="filter_adrcd" value="<?=$filter['adrcd']?>" />
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<div class="col-2">
|
||||
<label class="form-label" for="filter_extref">extref</label>
|
||||
<input type="text" class="form-control" name="filter[extref]" id="filter_extref" value="<?=$filter['extref']?>" />
|
||||
</div>
|
||||
|
||||
<div class="col-1">
|
||||
<label class="form-label" for="filter_rollout">Rollout Jahr</label>
|
||||
<input type="text" class="form-control" name="filter[rollout]" id="filter_rollout" value="<?=$filter['rollout']?>" />
|
||||
</div>
|
||||
|
||||
<div class="col-2">
|
||||
<label class="form-label" for="filter_rollout_info">Rollout Info</label>
|
||||
<input type="text" class="form-control" name="filter[rollout_info]" id="filter_rollout_info" value="<?=$filter['rollout_info']?>" />
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
<div class="row mt-2">
|
||||
<div class="col">
|
||||
<button type="submit" class="btn btn-primary">Filter anwenden</button>
|
||||
<a class="btn btn-secondary" href="<?=self::getUrl("AddressDB")?>">Filter zurücksetzen</a>
|
||||
<button type="submit" formaction="<?=self::getUrl("AddressDB", "export")?>" id="export-button" class="btn btn-outline-success ml-2"><i class="fas fa-download"></i> CSV-Export</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
<div class="card">
|
||||
<div class="card-body mb-3">
|
||||
<div class="float-left">
|
||||
<h4 class="header-title">Liste aller GWR-Adressen</h4>
|
||||
</div>
|
||||
<div class="float-right">
|
||||
<a class="btn btn-primary mb-2" href="<?=self::getUrl("AddressDB", "add")?>"><i class="fas fa-plus"></i> Neue Adresse anlegen</a>
|
||||
<a class="btn btn-outline-violett mb-2" href="#" onclick="return false;"><i class="fas fa-marker"></i> Bulk update</a>
|
||||
|
||||
</div>
|
||||
|
||||
<?php include(realpath(dirname(__FILE__)."/../")."/tpl/pagination.php"); ?>
|
||||
<?php include(realpath(dirname(__FILE__)."/../")."/tpl/pagination-summary.php"); ?>
|
||||
|
||||
<table class="table table-striped table-hover">
|
||||
<tr>
|
||||
<th>Netzgebiet</th>
|
||||
<th>Adrcd</th>
|
||||
<th>OAID</th>
|
||||
<th>extref</th>
|
||||
<th>PLZ</th>
|
||||
<th>Gemeinde</th>
|
||||
<th>Ortschaft</th>
|
||||
<th>Straße</th>
|
||||
<th>Hausnummer</th>
|
||||
<th>Wohneinheiten</th>
|
||||
<th>Rollout Jahr</th>
|
||||
<th>Rollout Info</th>
|
||||
<th></th>
|
||||
</tr>
|
||||
<?php foreach($addresses as $address): ?>
|
||||
<tr>
|
||||
<td><?=$address->netzgebiet->name?></td>
|
||||
<td><?=$address->adrcd?></td>
|
||||
<td><?=$address->oaid?></td>
|
||||
<td><?=$address->extref?></td>
|
||||
<td><?=$address->plz->plz?></td>
|
||||
<td><?=$address->ortschaft->gemeinde->name?></td>
|
||||
<td><?=$address->ortschaft->name?></td>
|
||||
<td><?=$address->strasse->name?></td>
|
||||
<td><?=$address->hausnummer?></td>
|
||||
<td><?=count($address->wohneinheiten)?></td>
|
||||
<td><?=$address->rollout?></td>
|
||||
<td><?=$address->rollout_info?></td>
|
||||
<td style="text-align: left; letter-spacing: 4px; font-size: 1.1em;">
|
||||
<a href="<?=self::getUrl("AddressDB", "edit", ["id" => $address->id])?>"><i class="far fa-edit" title="Adresse Bearbeiten"></i></a>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
</table>
|
||||
|
||||
<?php include(realpath(dirname(__FILE__)."/../")."/tpl/pagination-summary.php"); ?>
|
||||
<?php include(realpath(dirname(__FILE__)."/../")."/tpl/pagination.php"); ?>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
$('#filter_network_id').change(function() {
|
||||
if($('#filter_network_id').val() === "null") {
|
||||
$('#filter-gemeinde-id').hide();
|
||||
$('#filter-gemeinde-text').show();
|
||||
$('#filter-ortschaft-id').hide();
|
||||
$('#filter-ortschaft-text').show();
|
||||
|
||||
$('#filter-gemeinde-id option:first').prop("selected", "selected");
|
||||
$('#filter-ortschaft-id option:first').prop("selected", "selected");
|
||||
} else {
|
||||
$('#filter-gemeinde-text').hide();
|
||||
$('#filter-gemeinde-id').show();
|
||||
$('#filter-ortschaft-text').hide();
|
||||
$('#filter-ortschaft-id').show();
|
||||
}
|
||||
$('#filter_gemeinde').val("");
|
||||
$('#filter_ortschaft').val("");
|
||||
});
|
||||
|
||||
</script>
|
||||
<?php include(realpath(dirname(__FILE__)."/../../$mfLayoutPackage")."/footer.php"); ?>
|
||||
31
Layout/default/AddressDB/export.csv.php
Normal file
31
Layout/default/AddressDB/export.csv.php
Normal file
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
ob_end_flush();
|
||||
header("Content-type: text/csv");
|
||||
header('Content-disposition: attachment; filename="addressdb-export-'.date('Y-m-d_H-i-s').'.csv"');
|
||||
?>
|
||||
AddressDB_ID;Extref;Adrcd;OAID;Netzgebiet_Extref;Netzgebiet;GKZ;Gemeinde;OKZ;Ortschaft;PLZ;SKZ;Strasse;Hausnummer;Grundstueck;GPS Breite; GPS Laenge;Rollout;Rollout_Info;Freigabe;Nutzungseinheiten
|
||||
<?php
|
||||
$line = 0;
|
||||
|
||||
while($data = mysqli_fetch_object($res)):
|
||||
$netzgebiet = Layout::getMfValuecacheObject("ADBNetzgebiet", $data->netzgebiet_id);
|
||||
$strasse = Layout::getMfValuecacheObject("ADBStrasse", $data->strasse_id);
|
||||
$gemeinde = Layout::getMfValuecacheObject("ADBGemeinde",$strasse->gemeinde_id);
|
||||
$ortschaft = Layout::getMfValuecacheObject("ADBOrtschaft", $data->ortschaft_id);
|
||||
$plz = Layout::getMfValuecacheObject("ADBPlz", $data->plz_id);
|
||||
$freigabe_array = json_decode($data->freigabe);
|
||||
if(is_array($freigabe_array)) {
|
||||
$freigabe = join(", ", $freigabe_array);
|
||||
} else {
|
||||
$freigabe = "";
|
||||
}
|
||||
$unit_count = $data->unit_count;
|
||||
?>
|
||||
<?=$data->id?>;"<?=$data->extref?>";<?=$data->adrcd?>;"<?=$data->oaid?>";"<?=$netzgebiet->extref?>";"<?=$netzgebiet->name?>";<?=$gemeinde->kennziffer?>;"<?=$gemeinde->name?>";<?=$ortschaft->kennziffer?>;"<?=$ortschaft->name?>";"<?=$plz->plz?>";<?=$strasse->kennziffer?>;"<?=$strasse->name?>";"<?=$data->hausnummer?>";"<?=$data->grund_nr?>";<?=$data->gps_lat?>;<?=$data->gps_long?>;<?=$data->rollout?>;"<?=$data->rollout_info?>";"<?=$freigabe?>";<?=$unit_count?>;
|
||||
<?php
|
||||
$i++;
|
||||
if($line % 1000 === 0) {
|
||||
flush();
|
||||
}
|
||||
|
||||
endwhile;
|
||||
34
Layout/default/Admin/Index.php
Normal file
34
Layout/default/Admin/Index.php
Normal file
@@ -0,0 +1,34 @@
|
||||
<?php include(realpath(dirname(__FILE__)."/../../$mfLayoutPackage")."/header.php"); ?>
|
||||
|
||||
<!-- start page title -->
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<div class="page-title-box">
|
||||
<div class="page-title-right">
|
||||
<ol class="breadcrumb m-0">
|
||||
<li class="breadcrumb-item"><a href="javascript: void(0);"><?=MFAPPNAME_SLUG?></a></li>
|
||||
<li class="breadcrumb-item active">Admin</li>
|
||||
</ol>
|
||||
</div>
|
||||
<h4 class="page-title">Admin</h4>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- end page title -->
|
||||
|
||||
<h4>Secret Admin functions</h4>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-12 col-xl-10">
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<div class="row col-12">
|
||||
<div><a href="<?=self::getUrl("Admin", "createNetworkAddressForNetowner")?>">Fehlende NetworkAddress Objekte für Netowner anlegen</a></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<?php include(realpath(dirname(__FILE__)."/../../$mfLayoutPackage")."/footer.php"); ?>
|
||||
@@ -136,14 +136,14 @@
|
||||
<div class="row">
|
||||
<div class="col-lg-6">
|
||||
<div class="form-group row">
|
||||
<label class="col-lg-4 col-form-label" for="gps_lat">GPS Länge (N)</label>
|
||||
<label class="col-lg-4 col-form-label" for="gps_lat">GPS Breite</label>
|
||||
<div class="col-lg-8">
|
||||
<input type="text" class="form-control" name="gps_lat" id="gps_lat" value="<?=$building->gps_lat?>" <?=($building->gps_lat) ? "readonly='readonly'" : ""?> />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group row">
|
||||
<label class="col-lg-4 col-form-label" for="gps_long">GPS Breite (E)</label>
|
||||
<label class="col-lg-4 col-form-label" for="gps_long">GPS Länge</label>
|
||||
<div class="col-lg-8">
|
||||
<input type="text" class="form-control" name="gps_long" id="gps_long" value="<?=$building->gps_long?>" <?=($building->gps_lat) ? "readonly='readonly'" : ""?> />
|
||||
</div>
|
||||
|
||||
@@ -384,9 +384,13 @@
|
||||
accessToken: '<?=TT_MAPBOX_TILE_API_TOKEN?>'
|
||||
}).addTo(buildingMap);
|
||||
|
||||
L.MakiMarkers.accessToken = '<?=TT_MAPBOX_TILE_API_TOKEN?>';
|
||||
|
||||
addMarkers();
|
||||
}
|
||||
|
||||
|
||||
|
||||
function addMarkers() {
|
||||
if(!Array.isArray(buildings) | !buildings.length) {
|
||||
return false;
|
||||
@@ -399,7 +403,36 @@
|
||||
}
|
||||
var gps = [building.gps_lat, building.gps_long];
|
||||
all_coords.push(gps);
|
||||
var marker = L.marker(gps).addTo(buildingMap);
|
||||
|
||||
var icon_color = "#CB2B3E";
|
||||
var icon_name = "home";
|
||||
|
||||
if(building.status == "connected") {
|
||||
icon_color = "#2AAD27";
|
||||
} else if(building.status == "pipework-done") {
|
||||
icon_color = "#CB8427";
|
||||
}
|
||||
|
||||
if(building.type.match(/^(Zwei)/i)) {
|
||||
icon_name = "town";
|
||||
} else if(building.type.match(/^(Mehr)/i)) {
|
||||
icon_name = "city";
|
||||
} else if(building.type.match(/^(Unternehmen)/i)) {
|
||||
icon_name = "industry";
|
||||
} else if(building.type.match(/^(Sender)/i)) {
|
||||
icon_name = "communications-tower";
|
||||
}
|
||||
|
||||
var marker_popup_content = '<?php include(realpath(dirname(__FILE__))."/include/building_popup.php");?>';
|
||||
|
||||
[["street", building.street], ["zip", building.zip], ["city", building.city], ["type", building.type], ["code", building.code], ["popname", building.popname], ["gps", building.gps_lat + ", " + building.gps_long],
|
||||
["contact", building.contact], ["phone", building.phone], ["email", building.email]
|
||||
].forEach(function(item) {
|
||||
marker_popup_content = marker_popup_content.replaceAll("{{" + item[0].toUpperCase() + "}}", item[1]);
|
||||
});
|
||||
|
||||
var icon = L.MakiMarkers.icon({icon: icon_name, color: icon_color, size: "l"});
|
||||
var marker = L.marker(gps, {icon: icon}).addTo(buildingMap).bindPopup(marker_popup_content);
|
||||
markers[building.id] = marker;
|
||||
});
|
||||
|
||||
|
||||
36
Layout/default/Building/include/building_popup.php
Normal file
36
Layout/default/Building/include/building_popup.php
Normal file
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
ob_start();
|
||||
?>
|
||||
<div class="font-weight-bold">
|
||||
{{STREET}}<br />
|
||||
{{ZIP}} {{CITY}}
|
||||
</div>
|
||||
|
||||
<hr />
|
||||
|
||||
<table>
|
||||
<tr>
|
||||
<th>Objekt-ID:</th>
|
||||
<td>{{CODE}}</td>
|
||||
</tr><tr>
|
||||
<th>Gebäudetyp:</th>
|
||||
<td>{{TYPE}}</td>
|
||||
</tr><tr>
|
||||
<th>POP:</th>
|
||||
<td>{{POPNAME}}</td>
|
||||
</tr><tr>
|
||||
<th>GPS:</th>
|
||||
<td><a href="https://maps.google.com/maps?t=k&q=loc:{{GPS}}">{{GPS}}</a></td>
|
||||
</tr><tr>
|
||||
<th>Kontakt:</th>
|
||||
<td>{{CONTACT}}</td>
|
||||
</tr><tr>
|
||||
<th>Telefon:</th>
|
||||
<td>{{PHONE}}</td>
|
||||
</tr><tr>
|
||||
<th>Email:</th>
|
||||
<td>{{EMAIL}}</td>
|
||||
</tr>
|
||||
|
||||
</table>
|
||||
<?=str_replace("\n"," ",ob_get_clean())?>
|
||||
@@ -1,3 +1,13 @@
|
||||
<?php
|
||||
$urlfilter = [];
|
||||
if($s) {
|
||||
$urlfilter['s'] = $s;
|
||||
}
|
||||
if(is_array($filter) && count($filter)) {
|
||||
$urlfilter["filter"] = $filter;
|
||||
}
|
||||
$posturl = self::getUrl("Contract", "save", $urlfilter);
|
||||
?>
|
||||
<?php include(realpath(dirname(__FILE__)."/../../$mfLayoutPackage")."/header.php"); ?>
|
||||
<!-- start page title -->
|
||||
<div class="row">
|
||||
@@ -23,11 +33,15 @@
|
||||
<div class="card-body">
|
||||
<h4 class="header-title mb-2"><?=($contract->id) ? "Vertrag bearbeiten" : "Neuer Vertrag"?></h4>
|
||||
|
||||
<form class="form-horizontal" method="post" action="<?=self::getUrl("Contract", "save")?>">
|
||||
<form class="form-horizontal" method="post" action="<?=$posturl?>">
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
|
||||
<input type="hidden" name="id" value="<?=$contact->id?>" />
|
||||
<input type="hidden" name="id" value="<?=$contract->id?>" />
|
||||
<input type="hidden" name="origin_contract_id" value="<?=$origin_contract_id?>" />
|
||||
<input type="hidden" name="f" value="<?=$f?>" />
|
||||
|
||||
|
||||
<div class="form-group row">
|
||||
<label class="col-lg-2 col-form-label" for="owner_id">Vertragsinhaber *</label>
|
||||
<div class="col-lg-10">
|
||||
@@ -64,6 +78,19 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group row">
|
||||
<label class="col-lg-2 col-form-label" for="matchcode">Anschluss</label>
|
||||
<div class="col-lg-10">
|
||||
<select name="products[<?=$i?>][termination_id]" id="termination_id-<?=$i?>" class="form-control select2">
|
||||
<option></option>
|
||||
<?php foreach($terminations as $t): ?>
|
||||
<option value="<?=$t->id?>" <?=($t->id == $contract->termination_id) ? "selected='selected'" : ""?>><?=$t->code?> - <?=$t->getAddress()?></option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="form-group row">
|
||||
<label class="col-lg-2 col-form-label" for="product_name">Individueller Produktname</label>
|
||||
<div class="col-lg-10">
|
||||
@@ -95,7 +122,7 @@
|
||||
<div class="form-group row">
|
||||
<label class="col-lg-2 col-form-label" for="price_setup">Preis Setup</label>
|
||||
<div class="col-lg-10">
|
||||
<input type="text" class="form-control" name="price" id="price_setup" value="<?=$contract->price_setup?>">
|
||||
<input type="text" class="form-control" name="price_setup" id="price_setup" value="<?=$contract->price_setup?>">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -115,7 +142,7 @@
|
||||
<div class="form-group row">
|
||||
<label class="col-lg-2 col-form-label" for="billing_period">Verrechnungsperiode</label>
|
||||
<div class="col-lg-10">
|
||||
<select class="form-control" name="products[<?=$i?>][billing_period]" id="billing_period-<?=$i?>" placeholder="Verrechnungsperiode">
|
||||
<select class="form-control" name="billing_period" id="billing_period" placeholder="Verrechnungsperiode">
|
||||
<option value="1" <?=($product->billing_period == 1) ? "selected='selected'" : ""?>>Monatlich</option>
|
||||
<option value="12" <?=($product->billing_period == 12) ? "selected='selected'" : ""?>>Jährlich</option>
|
||||
</select>
|
||||
@@ -134,14 +161,14 @@
|
||||
<div class="form-group row">
|
||||
<label class="col-lg-2 col-form-label" for="finish_date">Fertigstellungsdatum</label>
|
||||
<div class="col-lg-10">
|
||||
<input type="text" class="form-control" name="finish_date" id="finish_date" value="<?=$contract->finish_date?>">
|
||||
<input type="text" class="form-control" name="finish_date" id="finish_date" value="<?=($contract->finish_date) ? date("d.m.Y",$contract->finish_date) : ""?>">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group row">
|
||||
<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="<?=$contract->cancel_date?>">
|
||||
<input type="text" class="form-control" name="cancel_date" id="cancel_date" value="<?=($contract->cancel_date) ? date("d.m.Y", $contract->cancel_date) : ""?>">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -159,30 +186,31 @@
|
||||
<div class="card">
|
||||
<div class="card-body" id="link-container">
|
||||
<h4>Verknüpfungen</h4>
|
||||
<?php $linknum = 1337; ?>
|
||||
<div class="form-group row" id="link-<?=$linknum?>">
|
||||
<label class="col-lg-2 col-form-label" for="links_<?=$linknum?>_contract_id"></label>
|
||||
<div class="col-lg-6">
|
||||
<div class="input-group mb-3">
|
||||
<div class="input-group-prepend">
|
||||
<select class="form-control" name="links[<?=$linknum?>][type]">
|
||||
<option value="link">Verknüpfung mit</option>
|
||||
<option value="upgrade">Upgrade von</option>
|
||||
<option value="downgrade">Downgrade von</option>
|
||||
<option value="relocation">Umzug von</option>
|
||||
<option value="productchange">Produktwechsel von</option>
|
||||
</select>
|
||||
</div>
|
||||
<!--input type="text" class="form-control" name="links[<?=$linknum?>][contract_id]" id="links_<?=$linknum?>_contract_id" placeholder="Contact ID oder Suche nach Produkt, Matchcode, Kunde" value="<?=$contract->cancel_date?>"-->
|
||||
<select class="form-control basicAutoComplete link-autocomplete" autocomplete="off" name="links[<?=$linknum?>][contract_id]" id="links_<?=$linknum?>_contract_id" data-linknum="<?=$linknum?>" data-url="<?=self::getUrl('Contract','api')?>?do=findContract&autocomplete=1" placeholder="Contact ID oder Suche nach Produkt, Matchcode, Kunde" data-noresults-text="Keine Suchergebnisse">
|
||||
<option></option>
|
||||
</select>
|
||||
<div class="input-group-append">
|
||||
<button type="button" class="btn btn-danger" onclick="clearNewLink(<?=$linknum?>)"><i class="fas fa-xmark-large mr-1"></i> Entfernen</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<table class="table table-striped table-sm table-bordered">
|
||||
<tr>
|
||||
<th>Verknüpfung</th>
|
||||
<th>Kunde</th>
|
||||
<th>Contract ID</th>
|
||||
<th>Produkt</th>
|
||||
<th>Matchcode</th>
|
||||
<th></th>
|
||||
</tr>
|
||||
<?php foreach($contract->links as $link): ?>
|
||||
<tr>
|
||||
<td><?=__($link->type, "contract")?></td>
|
||||
<td><a href="<?=self::getUrl("Address", "View", ["id" => $link->contract->owner_id])?>"><?=$link->contract->owner->getCompanyOrName()?></a></td>
|
||||
<td><a href="<?=self::getUrl("Contract", "View", ["id" => $link->contract_id])?>"><?=$link->contract_id?></a></td>
|
||||
<td><a href="<?=self::getUrl("Contract", "View", ["id" => $link->contract_id])?>"><?=$link->contract->product->name?></a></td>
|
||||
<td><a href="<?=self::getUrl("Contract", "View", ["id" => $link->contract_id])?>"><?=$link->contract->matchcode?></a></td>
|
||||
<td>
|
||||
<a href="<?=self::getUrl("Contract", "deleteLink", ["link_id" => $link->id])?>" onclick="if(!confirm('Verknüpfung wirklich entfernen?')) return false;" class="text-danger" title="Verknüpfung entfernen"><i class="fas fa-xmark-large"></i></a>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<?php endforeach; ?>
|
||||
</table>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -240,7 +268,7 @@
|
||||
* customer autocomplete
|
||||
*/
|
||||
// kunde
|
||||
<?php if($contract->owner_id && is_object(($contract->owner))): ?>
|
||||
<?php if($contract->owner_id && is_object($contract->owner)): ?>
|
||||
$('#owner_id').autoComplete('set', { value: <?=$contract->owner_id?>, text: '<?=($contract->owner_id) ? str_replace("'", "\\'", str_replace(["\n", "\r"], " ", $contract->owner->getCompanyOrName()))." (".$contract->owner->zip." ".$contract->owner->city.", ".$contract->owner->street.")".(($contract->owner->customer_number) ? " [".$contract->owner->customer_number."]" : "") : ""?>'});
|
||||
<?php else: ?>
|
||||
$('#owner_id').autoComplete();
|
||||
@@ -396,7 +424,7 @@
|
||||
<option value="productchange">Produktwechsel von</option> \
|
||||
</select> \
|
||||
</div> \
|
||||
<select class="form-control basicAutoComplete link-autocomplete" autocomplete="off" name="links[' + linknum + '][contract_id]" id="links_' + linknum + '_contract_id" data-linknum="' + linknum + '" data-url="<?=self::getUrl('Contract','api')?>?do=findContract&autocomplete=1" placeholder="Contact ID oder Suche nach Produkt, Matchcode, Kunde" data-noresults-text="Keine Suchergebnisse"> \
|
||||
<select class="form-control basicAutoComplete link-autocomplete" autocomplete="off" name="links[' + linknum + '][contract_id]" id="links_' + linknum + '_contract_id" data-linknum="' + linknum + '" data-url="<?=self::getUrl('Contract','api')?>?do=findContract&autocomplete=1" placeholder="Contract ID oder Suche nach Produkt, Matchcode, Kunde" data-noresults-text="Keine Suchergebnisse"> \
|
||||
<option></option> \
|
||||
</select> \
|
||||
<div class="input-group-append"> \
|
||||
|
||||
@@ -12,10 +12,10 @@
|
||||
<div class="page-title-right">
|
||||
<ol class="breadcrumb m-0">
|
||||
<li class="breadcrumb-item"><a href="<?=self::getUrl("Dashboard")?>"><?=MFAPPNAME_SLUG?></a></li>
|
||||
<li class="breadcrumb-item active">Verträge</li>
|
||||
<li class="breadcrumb-item active">Aktive Produkte</li>
|
||||
</ol>
|
||||
</div>
|
||||
<h4 class="page-title">Verträge</h4>
|
||||
<h4 class="page-title">Aktive Produkte</h4>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -28,11 +28,16 @@
|
||||
<div class="card-body mb-3">
|
||||
<h4 class="header-title mb-3">Filter</h4>
|
||||
|
||||
<form method="get" action="<?=self::getUrl("Building")?>">
|
||||
<form method="get" action="<?=self::getUrl("Contract")?>">
|
||||
<div class="row">
|
||||
|
||||
<div class="col-1">
|
||||
<label class="form-label" for="filter_owner">Inhaber</label>
|
||||
<label class="form-label" for="filter_owner">Kundennummer</label>
|
||||
<input type="text" class="form-control" name="filter[customer_number]" id="filter_street" value="<?=$filter['customer_number']?>" />
|
||||
</div>
|
||||
|
||||
<div class="col-1">
|
||||
<label class="form-label" for="filter_owner">Inhaber Name</label>
|
||||
<input type="text" class="form-control" name="filter[owner]" id="filter_street" value="<?=$filter['owner']?>" />
|
||||
</div>
|
||||
|
||||
@@ -51,12 +56,19 @@
|
||||
<input type="text" class="form-control" name="filter[product_name]" id="filter_product_name" value="<?=$filter['product_name']?>" />
|
||||
</div>
|
||||
|
||||
<div class="col-2">
|
||||
<label class="form-label" for="filter_show_canceled">Gekündigte Produkte</label>
|
||||
<select class="form-control" name="filter[show_canceled]" id="filter_show_canceled">
|
||||
<option value="0" <?=($filter['show_canceled'] == 0) ? "selected='selected'" : ""?>>Ausblenden</option>
|
||||
<option value="1" <?=($filter['show_canceled'] == 1 ) ? "selected='selected'" : ""?>>Anzeigen</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div class="row mt-2">
|
||||
<div class="col">
|
||||
<button type="submit" class="btn btn-primary">Filter anwenden</button>
|
||||
<a class="btn btn-secondary" href="<?=self::getUrl("Building")?>">Filter zurücksetzen</a>
|
||||
<a class="btn btn-secondary" href="<?=self::getUrl("Contract")?>">Filter zurücksetzen</a>
|
||||
</div>
|
||||
<!--<div class="col">
|
||||
<button class="btn btn-info" type="button" onclick="refreshMap()"><i class="far fa-map"></i> Auf Karte anzeigen</button>
|
||||
@@ -70,10 +82,10 @@
|
||||
<div class="card">
|
||||
<div class="card-body mb-3">
|
||||
<div class="float-left">
|
||||
<h4 class="header-title">Liste aller Verträge</h4>
|
||||
<h4 class="header-title">Liste aller aktiven Produkte</h4>
|
||||
</div>
|
||||
<div class="float-right">
|
||||
<a class="btn btn-primary mb-2" href="<?=self::getUrl("Contract", "add")?>"><i class="fas fa-plus"></i> Neuen Vertrag anlegen</a>
|
||||
<a class="btn btn-primary mb-2" href="<?=self::getUrl("Contract", "add")?>"><i class="fas fa-plus"></i> Neues Produkt anlegen</a>
|
||||
</div>
|
||||
|
||||
<?php include(realpath(dirname(__FILE__)."/../")."/tpl/pagination.php"); ?>
|
||||
@@ -96,10 +108,10 @@
|
||||
</tr>
|
||||
<?php foreach($contracts as $contract): ?>
|
||||
<tr>
|
||||
<td><?=$contract->id?></td>
|
||||
<td><a href="<?=self::getUrl("Address", "View", ["id" => $contract->owner_id])?>" target="_blank"><?=$contract->owner->getCompanyOrName()?></a></td>
|
||||
<td><a href="<?=self::getUrl("Contract", "view", ["id" => $contract->id])?>"><?=$contract->product->name?></a></td>
|
||||
<td><a href="<?=self::getUrl("Contract", "view", ["id" => $contract->id])?>"><?=$contract->matchcode?></a></td>
|
||||
<td><a href="<?=self::getUrl("Contract", "view", ["contract_id" => $contract->id])?>"><?=$contract->id?></a></td>
|
||||
<td><a href="<?=self::getUrl("Address", "View", ["id" => $contract->owner_id])?>" target="_blank"><i class="far fa-eyes" title="Kunde in neuem Tab anzeigen"></i></a> <?=$contract->owner->getCompanyOrName()?></td>
|
||||
<td><a href="<?=self::getUrl("Contract", "view", ["contract_id" => $contract->id])?>"><?=$contract->product_name?></a></td>
|
||||
<td><a href="<?=self::getUrl("Contract", "view", ["contract_id" => $contract->id])?>"><?=$contract->matchcode?></a></td>
|
||||
<!--<td>
|
||||
<?php if($contract->termination_id): ?>
|
||||
<?=$contract->termination->building->street?><br />
|
||||
@@ -127,9 +139,9 @@
|
||||
<td class="text-monospace"><?=date('d.m.Y H:i', $contract->create)?><br /><?=$contract->creator->name?></td>
|
||||
<td class="text-monospace"><?=date('d.m.Y H:i', $contract->edit)?><br /><?=$contract->editor->name?></td>
|
||||
<td style="text-align: left; letter-spacing: 4px; font-size: 1.1em;">
|
||||
<a href="<?=self::getUrl("Contract", "view", ["id" => $contract->id])?>"><i class="far fa-eyes" title="Vertrag anzeigen"></i></a>
|
||||
<a href="<?=self::getUrl("Contract", "edit", ["id" => $contract->id])?>"><i class="far fa-edit" title="Vertrag bearbeiten"></i></a>
|
||||
<a href="<?=self::getUrl("Contract", "cancel", ["id" => $contract->id])?>" class="text-danger" title="Vertrag kündigen"><i class="far fa-file-slash"></i></a>
|
||||
<a href="<?=self::getUrl("Contract", "view", ["contract_id" => $contract->id, "s" => $s, "filter" => $filter])?>"><i class="far fa-eyes" title="Aktives Produkt anzeigen"></i></a>
|
||||
<a href="<?=self::getUrl("Contract", "edit", ["contract_id" => $contract->id, "s" => $s, "filter" => $filter])?>"><i class="far fa-edit" title="Aktives Produkt bearbeiten"></i></a>
|
||||
<a href="<?=self::getUrl("Contract", "cancel", ["contract_id" => $contract->id, "s" => $s, "filter" => $filter])?>" class="text-danger" title="Produkt kündigen"><i class="far fa-file-slash"></i></a>
|
||||
<?php if($contract->orderproduct_id): ?><a href="<?=self::getUrl("Order", "edit", ["id" => $contract->orderproduct->order_id])?>"><i class="far fa-file-signature" title="Bestellung anzeigen"></i></a><?php endif; ?>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
7
Layout/default/Contract/OwnerchangeForm.php
Normal file
7
Layout/default/Contract/OwnerchangeForm.php
Normal file
@@ -0,0 +1,7 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
|
||||
* Click nbfs://nbhost/SystemFileSystem/Templates/Scripting/EmptyPHP.php to edit this template
|
||||
*/
|
||||
|
||||
316
Layout/default/Contract/ProductchangeForm.php
Normal file
316
Layout/default/Contract/ProductchangeForm.php
Normal file
@@ -0,0 +1,316 @@
|
||||
<?php include(realpath(dirname(__FILE__)."/../../$mfLayoutPackage")."/header.php"); ?>
|
||||
|
||||
<!-- start page title -->
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<div class="page-title-box">
|
||||
<div class="page-title-right">
|
||||
<ol class="breadcrumb m-0">
|
||||
<li class="breadcrumb-item"><a href="<?=self::getUrl("Dashboard")?>"><?=MFAPPNAME_SLUG?></a></li>
|
||||
<li class="breadcrumb-item"><a href="<?=self::getUrl("Contract")?>">Aktive Produkte</a></li>
|
||||
<li class="breadcrumb-item"><a href="<?=self::getUrl("Contract", "view", ['id' => $contract->id])?>"><?=$contract->product_name?> [<?=$contract->matchcode?>]</a></li>
|
||||
<li class="breadcrumb-item active">Konfiguration</li>
|
||||
</ol>
|
||||
</div>
|
||||
<h4 class="page-title">Aktives Produkt</h4>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- end page title -->
|
||||
|
||||
<div class="row">
|
||||
<div class="col-lg-12">
|
||||
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<a href="<?=self::getUrl("Contract","View", ['id' => $contract->id, 'filter' => $filter, 's' => $s])?>" class="btn btn-sm btn-secondary mr-1"><i class="fas fa-list"></i> Zurück zur Vertragsansicht</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<h3 class="text-center mb-3"><?=$contract->product_name?> (<?=$contract->id?>)</h3>
|
||||
|
||||
<table class="table table-sm table-striped view-table">
|
||||
<tr>
|
||||
<th style="max-width: 50vw;">Matchcode:</th>
|
||||
<td style="width: 50vw;"><?=$contract->matchcode?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Vertragsinhaber:</th>
|
||||
<td><a href="<?=self::getUrl("Address", "View", ["id" => $contract->owner->id])?>"><?=$contract->owner->getCompanyOrName()?> (<?=$contract->owner->customer_number?>)</a></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Produkt:</th>
|
||||
<td><?=$contract->product_name?> [<?=$contract->product_id?>]<?=($contract->product_name != $contract->product->name) ? " <i>(".$contract->product->name.")</i>" : ""?></td>
|
||||
</tr><tr>
|
||||
<th>Produkt Info:</th>
|
||||
<td><?=$contract->product_info?></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<h4 class="text-center mb-3">Neuer Contract</h4>
|
||||
|
||||
<form method="post" action="<?=self::getUrl("Contract", "saveProductchange")?>">
|
||||
<input type="hidden" name="contract_id" value="<?=$contract->id?>" />
|
||||
|
||||
<div class="row justify-content-center">
|
||||
<div class="col-xl-6">
|
||||
|
||||
<div class="form-group row">
|
||||
<label class="col-lg-2 col-form-label" for="product_id">Produkt</label>
|
||||
<div class="col-lg-10">
|
||||
<select class="form-control basicAutoComplete" autocomplete="off" name="product_id" id="product_id" data-url="<?=self::getUrl('Product','api')?>?do=findProduct&autocomplete=1" placeholder="Tippen zum suchen..." data-noresults-text="Keine Suchergebnisse">
|
||||
<option></option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group row">
|
||||
<label class="col-lg-2 col-form-label" for="matchcode">Matchcode:</label>
|
||||
<div class="col-lg-10">
|
||||
<input type="text" class="form-control" name="matchcode" id="matchcode" value="<?=$contract->matchcode?>">
|
||||
<small class="font-italic">Eindeutige Identifizierung das Produkts. Z.B. Anschlussadresse, Domainname usw.</small>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php if(
|
||||
(is_array($contract->product->attributes) && count($contract->product->attributes))
|
||||
&& (array_key_exists(TT_ATTRIB_TERMINATION_REQUIRED_NAME, $contract->product->attributes)
|
||||
&& $contract->product->attributes[TT_ATTRIB_TERMINATION_REQUIRED_NAME]->value == 1)
|
||||
|| $contract->termination_id
|
||||
): ?>
|
||||
<div class="form-group row" id="termination_id-line">
|
||||
<?php else: ?>
|
||||
<div class="form-group row hidden" id="termination_id-line">
|
||||
<?php endif; ?>
|
||||
<label class="col-lg-2 col-form-label" for="matchcode">Anschluss</label>
|
||||
<div class="col-lg-10">
|
||||
<select name="termination_id" id="termination_id" class="form-control select2">
|
||||
<option></option>
|
||||
<?php foreach($terminations as $t): ?>
|
||||
<option value="<?=$t->id?>" <?=($t->id == $contract->termination_id) ? "selected='selected'" : ""?>><?=$t->code?> - <?=$t->getAddress(true)?></option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group row">
|
||||
<label class="col-lg-2 col-form-label" for="product_name">Individueller Produktname:</label>
|
||||
<div class="col-lg-10">
|
||||
<input type="text" class="form-control" name="product_name" id="product_name" value="<?=$contract->product_name?>">
|
||||
<small class="font-italic">Scheint statt dem echten Produktnamen auf der Rechnung auf</small>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group row">
|
||||
<label class="col-lg-2 col-form-label" for="product_info">Produkt Zusatztext:</label>
|
||||
<div class="col-lg-10">
|
||||
<input type="text" class="form-control" name="product_info" id="product_info" value="<?=$contract->product_info?>">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group row">
|
||||
<label class="col-lg-2 col-form-label" for="price_setup">Preis Setup:</label>
|
||||
<div class="col-lg-10">
|
||||
<input type="text" class="form-control" name="price_setup" id="price_setup" value="<?=$contract->price_setup?>">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group row">
|
||||
<label class="col-lg-2 col-form-label" for="price">Preis Periodisch:</label>
|
||||
<div class="col-lg-10">
|
||||
<input type="text" class="form-control" name="price" id="price" value="<?=$contract->price?>">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group row">
|
||||
<label class="col-lg-2 col-form-label" for="price_nne">Preis NNE</label>
|
||||
<div class="col-lg-10">
|
||||
<input type="text" class="form-control" name="price_nne" id="price_nne" value="<?=$contract->price_nne?>">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group row">
|
||||
<label class="col-lg-2 col-form-label" for="price_nbe">Preis NBE</label>
|
||||
<div class="col-lg-10">
|
||||
<input type="text" class="form-control" name="price_nbe" id="price_nbe" value="<?=$contract->price_nbe?>">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group row">
|
||||
<label class="col-lg-2 col-form-label" for="billing_period">Verrechnungsperiode</label>
|
||||
<div class="col-lg-10">
|
||||
<select class="form-control" name="billing_period" id="billing_period" placeholder="Verrechnungsperiode">
|
||||
<option value="1" <?=($product->billing_period == 1) ? "selected='selected'" : ""?>>Monatlich</option>
|
||||
<option value="12" <?=($product->billing_period == 12) ? "selected='selected'" : ""?>>Jährlich</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group row">
|
||||
<label class="col-lg-2 col-form-label" for="billing_delay">Verzögerter Verrechnungsstart</label>
|
||||
<div class="col-lg-10">
|
||||
<input type="text" class="form-control" name="billing_delay" id="billing_delay" placeholder="Freimonate" value="<?=$contract->billing_delay?>">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<?php if((is_array($contract->linkFrom) && count($contract->linkFrom)) || (is_array($contract->linkTo) && count($contract->linkTo))): ?>
|
||||
<h4>Verknüpfte Verträge</h4>
|
||||
|
||||
<table class="table table-striped table-sm table-bordered table-hover">
|
||||
<tr>
|
||||
<th title="Verlinkten Contract mit neuem Contract verknüpfen">Übernehmen</th>
|
||||
<th title="Verlinkten Contract mit altem Contract zusammen kündigen">Kündigen</th>
|
||||
<th>Kunde</th>
|
||||
<th>Contract ID</th>
|
||||
<th>Produkt</th>
|
||||
<th>Matchcode</th>
|
||||
<th>Bestelldatum</th>
|
||||
<th>Fertigstellung</th>
|
||||
<th>Kündigung</th>
|
||||
</tr>
|
||||
<?php foreach($contract->links as $link): ?>
|
||||
<?php
|
||||
|
||||
if($link->contract_id == $contract->id) {
|
||||
$linkcontract = $link->origin;
|
||||
} else {
|
||||
$linkcontract = $link->contract;
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
<tr>
|
||||
<td><input type="radio" class="form-check" id="link-<?=$link->id?>-action-keep" name="links[<?=$link->id?>]" value="keep" <?=($linkcontract->cancel_date && $linkcontract->cancel_date < date('U')) ? "" : "checked='checked'"?> /></td>
|
||||
<td><input type="radio" class="form-check" id="link-<?=$link->id?>-action-cancel" name="links[<?=$link->id?>]" value="cancel" /></td>
|
||||
<td><a href="<?=self::getUrl("Address", "View", ["id" => $linkcontract->owner_id])?>" target="_blank"><?=$linkcontract->owner->getCompanyOrName()?></a></td>
|
||||
<td class="contract <?=($linkcontract->isCancelled()) ? "canceled" : ""?>"><a href="<?=self::getUrl("Contract", "View", ["contract_id" => $linkcontract->id])?>" target="_blank"><?=$linkcontract->id?></a></td>
|
||||
<td class="contract <?=($linkcontract->isCancelled()) ? "canceled" : ""?>"><a href="<?=self::getUrl("Contract", "View", ["contract_id" => $linkcontract->id])?>" target="_blank"><?=$linkcontract->product_name?></a></td>
|
||||
<td class="contract <?=($linkcontract->isCancelled()) ? "canceled" : ""?>"><a href="<?=self::getUrl("Contract", "View", ["contract_id" => $linkcontract->id])?>" target="_blank"><?=$linkcontract->matchcode?></a></td>
|
||||
<td class="contract <?=($linkcontract->isCancelled()) ? "canceled" : ""?>"><?=($linkcontract->order_date) ? date('d.m.Y', $linkcontract->order_date) : ""?></td>
|
||||
<td class="contract <?=($linkcontract->isCancelled()) ? "canceled" : ""?>"><?=($linkcontract->finish_date) ? date('d.m.Y', $linkcontract->finish_date) : ""?></td>
|
||||
<td class="contract <?=($linkcontract->isCancelled()) ? "canceled" : ""?>"><?=($linkcontract->cancel_date) ? date('d.m.Y', $linkcontract->cancel_date) : ""?></td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
</table>
|
||||
<?php endif; ?>
|
||||
|
||||
|
||||
<!-- TODO: Fileupload -->
|
||||
|
||||
<div class="form-group row">
|
||||
<label class="col-lg-2 col-form-label" for="note">Interne Notiz</label>
|
||||
<div class="col-lg-10">
|
||||
<textarea id="note" class="form-control" name="note" rows="5"><?=$contract->note?></textarea>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
<div class="row">
|
||||
<div class="col text-center">
|
||||
<input type="submit" class="btn btn-primary" value="Produktwechsel speichern" />
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<a href="<?=self::getUrl("Contract","View", ['id' => $contract->id, 'filter' => $filter, 's' => $s])?>" class="btn btn-sm btn-secondary mr-1"><i class="fas fa-list"></i> Zurück zur Vertragsansicht</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<script>
|
||||
$(".select2").select2({
|
||||
allowClear: true,
|
||||
placeholder: ""
|
||||
});
|
||||
/*
|
||||
* product autocomplete
|
||||
*/
|
||||
<?php if($contract->product_id && is_object(($contract->product))): ?>
|
||||
$('#product_id').autoComplete('set', { value: <?=$contract->product_id?>, text: '<?=($contract->product_id) ? str_replace("'", "\\'", str_replace(["\n", "\r"], " ", $contract->product->name))." [".$contract->product_id."]" : ""?>'});
|
||||
<?php else: ?>
|
||||
$('#product_id').autoComplete();
|
||||
<?php endif; ?>
|
||||
|
||||
$('#product_id').keydown(function() {
|
||||
if(event.keyCode == 13) {
|
||||
event.preventDefault();
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
$('#product_id').on("autocomplete.select", function(evt, item) {
|
||||
if(item && item.value === 0) {
|
||||
$('#product_id').autoComplete('set', null);
|
||||
}
|
||||
if(item && item.value) {
|
||||
updateProduct(item.value);
|
||||
}
|
||||
});
|
||||
// product autocomplete
|
||||
|
||||
|
||||
|
||||
function updateProduct() {
|
||||
var pid = $('input[name=product_id]').val();
|
||||
|
||||
$.get("<?=self::getUrl("Product", "Api")?>",
|
||||
{
|
||||
"do": "getProduct",
|
||||
product_id: pid
|
||||
},
|
||||
function (success) {
|
||||
//console.log(success);
|
||||
p = success.result.product;
|
||||
|
||||
$('#product_name').val(p.name);
|
||||
//$('#product_info').val(p.name);
|
||||
$('#billing_delay').val(p.billing_delay);
|
||||
$('#billing_period').val(p.billing_period);
|
||||
$('#price').val(p.price);
|
||||
$('#price_setup').val(p.price_setup);
|
||||
$('#price_nne').val(p.price_nne);
|
||||
$('#price_nbe').val(p.price_nbe);
|
||||
|
||||
if(typeof p.attributes === 'object' && "termination_required" in p.attributes && p.attributes.termination_required == 1) {
|
||||
$('#termination_id-line').show();
|
||||
$('#termination_id').select2({
|
||||
allowClear: true,
|
||||
placeholder: ""
|
||||
});
|
||||
} else {
|
||||
$('#termination_id-line').hide();
|
||||
//$('#termination_id-' + id + '-line').hide();
|
||||
}
|
||||
|
||||
},
|
||||
'json');
|
||||
|
||||
}
|
||||
</script>
|
||||
|
||||
<?php include(realpath(dirname(__FILE__)."/../../$mfLayoutPackage")."/footer.php"); ?>
|
||||
282
Layout/default/Contract/View.php
Normal file
282
Layout/default/Contract/View.php
Normal file
@@ -0,0 +1,282 @@
|
||||
<?php include(realpath(dirname(__FILE__)."/../../$mfLayoutPackage")."/header.php"); ?>
|
||||
|
||||
<!-- start page title -->
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<div class="page-title-box">
|
||||
<div class="page-title-right">
|
||||
<ol class="breadcrumb m-0">
|
||||
<li class="breadcrumb-item"><a href="<?=self::getUrl("Dashboard")?>"><?=MFAPPNAME_SLUG?></a></li>
|
||||
<li class="breadcrumb-item"><a href="<?=self::getUrl("Contract")?>">Aktive Produkte</a></li>
|
||||
<li class="breadcrumb-item active"><?=$contract->product_name?> [<?=$contract->matchcode?>]</li>
|
||||
</ol>
|
||||
</div>
|
||||
<h4 class="page-title">Aktives Produkt</h4>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- end page title -->
|
||||
|
||||
<div class="row">
|
||||
<div class="col-lg-12">
|
||||
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<a href="<?=self::getUrl("Contract","Index", ['filter' => $filter, 's' => $s])?>" 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, 'filter' => $filter, 's' => $s, 'f' => "view"])?>" class="btn btn-sm btn-outline-success"><i class="fas fa-edit"></i> Vertrag bearbeiten</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<?php if(!$contract->finish_date || $contract->finish_date > date('U')): ?>
|
||||
<h2 class="text-center mb-3 text-secondary">In Herstellung</h2>
|
||||
<?php endif; ?>
|
||||
<?php if($contract->isCancelled()): ?>
|
||||
<h2 class="text-center mb-3 text-danger">GEKÜNDIGT</h2>
|
||||
<?php endif; ?>
|
||||
<h3 class="text-center mb-3 <?=($contract->isCancelled()) ? "canceled" : ""?>"><?=$contract->product_name?> [<?=$contract->id?>]</h3>
|
||||
|
||||
<table class="table table-sm table-striped view-table">
|
||||
<tr>
|
||||
<th style="max-width: 50vw;">Matchcode:</th>
|
||||
<td style="width: 50vw;"><?=$contract->matchcode?></td>
|
||||
</tr>
|
||||
<!-- upgrades -->
|
||||
<?php if(is_array($contract->upgradeFrom) && count($contract->upgradeFrom)): ?>
|
||||
<tr>
|
||||
<th>Upgrade von:</th>
|
||||
<td>
|
||||
<?php foreach($contract->upgradeFrom as $link): ?>
|
||||
<a href="<?=self::getUrl("Contract", "View", ["contract_id" => $link->origin_contract_id])?>" class="contract-link <?=($link->origin->cancel_date && $link->origin->cancel_date <= date('U')) ? "canceled" : ""?>"><?=$link->origin->product_name?> [<?=$link->origin->matchcode?>] (<?=$link->origin_contract_id?>)</a><br />
|
||||
<?php endforeach; ?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endif; ?>
|
||||
<?php if(is_array($contract->upgradeTo) && count($contract->upgradeTo)): ?>
|
||||
<tr>
|
||||
<th>Upgrade auf:</th>
|
||||
<td>
|
||||
<?php foreach($contract->upgradeTo as $link): ?>
|
||||
<a href="<?=self::getUrl("Contract", "View", ["contract_id" => $link->contract_id])?>" class="contract-link <?=($link->contract->cancel_date && $link->contract->cancel_date <= date('U')) ? "canceled" : ""?>"><?=$link->contract->product_name?> [<?=$link->contract->matchcode?>] (<?=$link->contract_id?>)</a><br />
|
||||
<?php endforeach; ?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endif; ?>
|
||||
|
||||
<!-- downgrades -->
|
||||
<?php if(is_array($contract->downgradeFrom) && count($contract->downgradeFrom)): ?>
|
||||
<tr>
|
||||
<th>Downgrade von:</th>
|
||||
<td>
|
||||
<?php foreach($contract->downgradeFrom as $link): ?>
|
||||
<a href="<?=self::getUrl("Contract", "View", ["contract_id" => $link->origin_contract_id])?>" class="contract-link <?=($link->origin->cancel_date <= date('U')) ? "canceled" : ""?>"><?=$link->origin->product_name?> [<?=$link->origin->matchcode?>] (<?=$link->origin_contract_id?>)</a><br />
|
||||
<?php endforeach; ?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endif; ?>
|
||||
<?php if(is_array($contract->downgradeTo) && count($contract->downgradeTo)): ?>
|
||||
<tr>
|
||||
<th>Downgrade auf:</th>
|
||||
<td>
|
||||
<?php foreach($contract->downgradeTo as $link): ?>
|
||||
<a href="<?=self::getUrl("Contract", "View", ["contract_id" => $link->contract_id])?>" class="contract-link <?=($link->contract->cancel_date && $link->contract->cancel_date <= date('U')) ? "canceled" : ""?>"><?=$link->contract->product_name?> [<?=$link->contract->matchcode?>] (<?=$link->contract_id?>)</a><br />
|
||||
<?php endforeach; ?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endif; ?>
|
||||
|
||||
<!-- productchange -->
|
||||
<?php if(is_array($contract->productchangeFrom) && count($contract->productchangeFrom)): ?>
|
||||
<tr>
|
||||
<th>Produktwechsel von:</th>
|
||||
<td>
|
||||
<?php foreach($contract->productchangeFrom as $link): ?>
|
||||
<a href="<?=self::getUrl("Contract", "View", ["contract_id" => $link->origin_contract_id])?>" class="contract-link <?=($link->origin->cancel_date <= date('U')) ? "canceled" : ""?>"><?=$link->origin->product_name?> [<?=$link->origin->matchcode?>] (<?=$link->origin_contract_id?>)</a><br />
|
||||
<?php endforeach; ?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endif; ?>
|
||||
<?php if(is_array($contract->productchangeTo) && count($contract->productchangeTo)): ?>
|
||||
<tr>
|
||||
<th>Produktwechsel auf:</th>
|
||||
<td>
|
||||
<?php foreach($contract->productchangeTo as $link): ?>
|
||||
<a href="<?=self::getUrl("Contract", "View", ["contract_id" => $link->contract_id])?>" class="contract-link <?=($link->contract->cancel_date && $link->contract->cancel_date <= date('U')) ? "canceled" : ""?>"><?=$link->contract->product_name?> [<?=$link->contract->matchcode?>] (<?=$link->contract_id?>)</a><br />
|
||||
<?php endforeach; ?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endif; ?>
|
||||
|
||||
<!-- relocation -->
|
||||
<?php if(is_array($contract->relocationFrom) && count($contract->relocationFrom)): ?>
|
||||
<tr>
|
||||
<th>Umzug von:</th>
|
||||
<td>
|
||||
<?php foreach($contract->relocationFrom as $link): ?>
|
||||
<a href="<?=self::getUrl("Contract", "View", ["contract_id" => $link->origin_contract_id])?>" class="contract-link <?=($link->origin->cancel_date && $link->origin->cancel_date <= date('U')) ? "canceled" : ""?>"><?=$link->origin->product_name?> [<?=$link->origin->matchcode?>] (<?=$link->origin_contract_id?>)</a><br />
|
||||
<?php endforeach; ?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endif; ?>
|
||||
<?php if(is_array($contract->relocationTo) && count($contract->relocationTo)): ?>
|
||||
<tr>
|
||||
<th>Umzug auf:</th>
|
||||
<td>
|
||||
<?php foreach($contract->relocationTo as $link): ?>
|
||||
<a href="<?=self::getUrl("Contract", "View", ["contract_id" => $link->contract_id])?>" class="contract-link <?=($link->contract->cancel_date && $link->contract->cancel_date <= date('U')) ? "canceled" : ""?>"><?=$link->contract->product_name?> [<?=$link->contract->matchcode?>] (<?=$link->contract_id?>)</a><br />
|
||||
<?php endforeach; ?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endif; ?>
|
||||
<tr>
|
||||
<th>Vertragsinhaber:</th>
|
||||
<td><a href="<?=self::getUrl("Address", "View", ["id" => $contract->owner_id])?>"><?=$contract->owner->getCompanyOrName()?> [<?=$contract->owner->customer_number?>]</a></td>
|
||||
</tr>
|
||||
<?php if($contract->billingaddress_id): ?>
|
||||
<tr>
|
||||
<th>Rechnungsempfänger:</th>
|
||||
<td><a href="<?=self::getUrl("Address", "View", ["id" => $contract->billingaddress_id])?>"><?=$contract->billingaddress->getCompanyOrName()?> [<?=$contract->billingaddress->customer_number?>]</a></td>
|
||||
</tr>
|
||||
<?php endif; ?>
|
||||
<tr>
|
||||
<th>Produkt:</th>
|
||||
<td><?=$contract->product_name?> [<?=$contract->product_id?>]<?=($contract->product_name != $contract->product->name) ? " <i>(".$contract->product->name.")</i>" : ""?></td>
|
||||
</tr><tr>
|
||||
<th>Produkt Info:</th>
|
||||
<td><?=$contract->product_info?></td>
|
||||
</tr>
|
||||
|
||||
|
||||
<tr>
|
||||
<th>SLA:</th>
|
||||
<td><?=$contract->sla->name?></td>
|
||||
</tr><tr>
|
||||
<th>Externes Produkt:</th>
|
||||
<td><?=($contract->product_external) ? "Ja" : "Nein"?></td>
|
||||
</tr><tr>
|
||||
<th>Setup Preis:</th>
|
||||
<td>€ <?=$contract->price_setup?></td>
|
||||
</tr><tr>
|
||||
<th>Preis Periodisch:</th>
|
||||
<td>€ <?=$contract->price?></td>
|
||||
</tr><tr>
|
||||
<th>Verrechnungsperiode:</th>
|
||||
<td>
|
||||
<?=($contract->billing_period == 1) ? "Monatlich" : ""?>
|
||||
<?=($contract->billing_period == 12) ? "Jährlich" : ""?>
|
||||
<?=($contract->billing_period == 24) ? "Zweijährlich" : ""?>
|
||||
<?=($contract->billing_period == 36) ? "Dreijährlich" : ""?>
|
||||
</td>
|
||||
</tr><tr>
|
||||
<th>Verrechnungsstart Verzögerung:</th>
|
||||
<td><?=$contract->billing_delay?> Monate</td>
|
||||
</tr><tr>
|
||||
<th></th>
|
||||
<td></td>
|
||||
</tr><tr>
|
||||
<th>Bestelldatum:</th>
|
||||
<td class="text-monospace"><?=($contract->order_date) ? date('d.m.Y',$contract->order_date) : ""?></td>
|
||||
</tr><tr>
|
||||
<th>Fertigstellungsdatum:</th>
|
||||
<td class="text-monospace">
|
||||
<?=($contract->finish_date) ? date('d.m.Y',$contract->finish_date) : ""?>
|
||||
<?=($contract->finish_date_by) ? "(".$contract->finisher->name.")" : ""?>
|
||||
</td>
|
||||
</tr><tr>
|
||||
<th>Kündigungsdatum:</th>
|
||||
<td class="text-monospace">
|
||||
<?=($contract->cancel_date) ? date('d.m.Y',$contract->cancel_date) : ""?>
|
||||
<?=($contract->cancel_date_by) ? "(".$contract->canceler->name.")" : ""?>
|
||||
</td>
|
||||
</tr><tr>
|
||||
<th></th>
|
||||
<td></td>
|
||||
</tr><tr>
|
||||
<th>Erstellt:</th>
|
||||
<td class="text-monospace"><?=date('d.m.Y H:i:s',$contract->create)?> (<?=$contract->creator->name?>)</td>
|
||||
</tr><tr>
|
||||
<th>Zuletzt bearbeitet:</th>
|
||||
<td class="text-monospace"><?=date('d.m.Y H:i:s',$contract->edit)?> (<?=$contract->editor->name?>)</td>
|
||||
</tr><tr class="bg-white">
|
||||
<td colspan="2" class="text-center">
|
||||
<a href="<?=self::getUrl("Contractconfig", "edit", ["contract_id" => $contract->id])?>"><button type="button" class="btn btn-sm btn-outline-info">Konfiguration bearbeiten</button></a>
|
||||
<?php if($contract->finish_date && $contract->finish_date < date('U')): ?>
|
||||
<button type="button" class="btn btn-sm btn-outline-secondary">Inhaberwechsel</button>
|
||||
<a href="<?=self::getUrl("Contract", "productchange", ["contract_id" => $contract->id])?>"><button type="button" class="btn btn-sm btn-outline-success">Produkt-/Standortwechsel</button></a>
|
||||
<button type="button" class="btn btn-sm btn-outline-danger">Kündigen</button>
|
||||
<?php else: ?>
|
||||
<a href="<?=self::getUrl("Contract", "finishContract", ['contract_id' => $contract->id])?>" onclick="if(!confirm('Jetzt fertigstellen und in Verrechnung geben?')) return false"><button type="button" class="btn btn-sm btn-success">Fertigstellen</button></a>
|
||||
<?php endif; ?>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php if((is_array($contract->linkFrom) && count($contract->linkFrom)) || (is_array($contract->linkTo) && count($contract->linkTo))): ?>
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<h4>Verknüpfte Verträge <small><a href="<?=self::getUrl("Contract", "add", ["origin_contract_id" => $contract->id])?>"><i class="fas fa-plus"></i>Neuen Contract anlegen</a></small></h4>
|
||||
|
||||
<table class="table table-striped table-sm table-bordered table-hover">
|
||||
<tr>
|
||||
<th>Kunde</th>
|
||||
<th>Contract ID</th>
|
||||
<th>Typ</th>
|
||||
<th>Produkt</th>
|
||||
<th>Matchcode</th>
|
||||
<th>Bestelldatum</th>
|
||||
<th>Fertigstellung</th>
|
||||
<th>Kündigung</th>
|
||||
<th></th>
|
||||
</tr>
|
||||
<?php foreach($contract->links as $link): ?>
|
||||
<?php
|
||||
|
||||
if($link->contract_id == $contract->id) {
|
||||
$direction = "von";
|
||||
$linkcontract = $link->origin;
|
||||
} else {
|
||||
$linkcontract = $link->contract;
|
||||
if($link->type == "upgrade" || $link->type == "downgrade") {
|
||||
$direction = "auf";
|
||||
}
|
||||
if($link->type == "relocation") {
|
||||
$direction = "nach";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
<tr>
|
||||
<td><a href="<?=self::getUrl("Address", "View", ["id" => $linkcontract->owner_id])?>"><?=$linkcontract->owner->getCompanyOrName()?></a></td>
|
||||
<td class="contract <?=($linkcontract->isCancelled()) ? "canceled" : ""?>"><a href="<?=self::getUrl("Contract", "View", ["contract_id" => $linkcontract->id])?>"><?=$linkcontract->id?></a></td>
|
||||
<td class="contract <?=($linkcontract->isCancelled()) ? "canceled" : ""?>"><?=__($link->type, "contract")?> <?=($link->type != "link") ? $direction : ""?></td>
|
||||
<td class="contract <?=($linkcontract->isCancelled()) ? "canceled" : ""?>"><a href="<?=self::getUrl("Contract", "View", ["contract_id" => $linkcontract->id])?>"><?=$linkcontract->product_name?></a></td>
|
||||
<td class="contract <?=($linkcontract->isCancelled()) ? "canceled" : ""?>"><a href="<?=self::getUrl("Contract", "View", ["contract_id" => $linkcontract->id])?>"><?=$linkcontract->matchcode?></a></td>
|
||||
<td class="contract <?=($linkcontract->isCancelled()) ? "canceled" : ""?>"><?=($linkcontract->order_date) ? date('d.m.Y', $linkcontract->order_date) : ""?></td>
|
||||
<td class="contract <?=($linkcontract->isCancelled()) ? "canceled" : ""?>"><?=($linkcontract->finish_date) ? date('d.m.Y', $linkcontract->finish_date) : ""?></td>
|
||||
<td class="contract <?=($linkcontract->isCancelled()) ? "canceled" : ""?>"><?=($linkcontract->cancel_date) ? date('d.m.Y', $linkcontract->cancel_date) : ""?></td>
|
||||
<td>
|
||||
<a href="<?=self::getUrl("Contract", "deleteLink", ["link_id" => $link->id])?>" onclick="if(!confirm('Verknüpfung wirklich entfernen?')) return false;" class="text-danger" title="Verknüpfung entfernen"><i class="fas fa-xmark-large"></i></a>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<a href="<?=self::getUrl("Contract","Index", ['filter' => $filter, 's' => $s])?>" 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, 'filter' => $filter, 's' => $s, 'f' => "view"])?>" class="btn btn-sm btn-outline-success"><i class="fas fa-edit"></i> Vertrag bearbeiten</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php include(realpath(dirname(__FILE__)."/../../$mfLayoutPackage")."/footer.php"); ?>
|
||||
108
Layout/default/Contractconfig/Form.php
Normal file
108
Layout/default/Contractconfig/Form.php
Normal file
@@ -0,0 +1,108 @@
|
||||
<?php include(realpath(dirname(__FILE__)."/../../$mfLayoutPackage")."/header.php"); ?>
|
||||
|
||||
<!-- start page title -->
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<div class="page-title-box">
|
||||
<div class="page-title-right">
|
||||
<ol class="breadcrumb m-0">
|
||||
<li class="breadcrumb-item"><a href="<?=self::getUrl("Dashboard")?>"><?=MFAPPNAME_SLUG?></a></li>
|
||||
<li class="breadcrumb-item"><a href="<?=self::getUrl("Contract")?>">Aktive Produkte</a></li>
|
||||
<li class="breadcrumb-item"><a href="<?=self::getUrl("Contract", "view", ['id' => $contract->id])?>"><?=$contract->product_name?> [<?=$contract->matchcode?>]</a></li>
|
||||
<li class="breadcrumb-item active">Konfiguration</li>
|
||||
</ol>
|
||||
</div>
|
||||
<h4 class="page-title">Aktives Produkt</h4>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- end page title -->
|
||||
|
||||
<div class="row">
|
||||
<div class="col-lg-12">
|
||||
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<a href="<?=self::getUrl("Contract","View", ['id' => $contract->id, 'filter' => $filter, 's' => $s])?>" class="btn btn-sm btn-secondary mr-1"><i class="fas fa-list"></i> Zurück zur Vertragsansicht</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<h3 class="text-center mb-3"><?=$contract->product_name?> (<?=$contract->id?>)</h3>
|
||||
|
||||
<table class="table table-sm table-striped view-table">
|
||||
<tr>
|
||||
<th style="max-width: 50vw;">Matchcode:</th>
|
||||
<td style="width: 50vw;"><?=$contract->matchcode?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Vertragsinhaber:</th>
|
||||
<td><a href="<?=self::getUrl("Address", "View", ["id" => $contract->owner->id])?>"><?=$contract->owner->getCompanyOrName()?> (<?=$contract->owner->customer_number?>)</a></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Produkt:</th>
|
||||
<td><?=$contract->product_name?></td>
|
||||
</tr><tr>
|
||||
<th>Produkt Info:</th>
|
||||
<td><?=$contract->product_info?></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<h4 class="text-center mb-3">Konfiguration bearbeiten</h4>
|
||||
<?php if(is_array($groups) && count($groups)): ?>
|
||||
<form method="post" action="<?=self::getUrl("Contractconfig", "Save")?>">
|
||||
<input type="hidden" name="contract_id" value="<?=$contract->id?>" />
|
||||
<table class="table table-sm table-borderless view-table">
|
||||
<?php foreach($groups as $group): ?>
|
||||
<tr class="bg-light">
|
||||
<th><h4><u><?=$group->name?></u></h4></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<?php foreach($group->items as $item): ?>
|
||||
<tr>
|
||||
<th style="max-width: 50vw;"><?=$item->displayname?>:</th>
|
||||
<td style="width: 50vw;">
|
||||
<?php if($item->type == "enum"): ?>
|
||||
<select class="form-control" name="itemvalues[<?=$item->id?>]">
|
||||
<?php foreach($item->getTypedataArray() as $option): ?>
|
||||
<option value="<?=$option?>" <?=($item->getValue() == $option) ? "selected='selected'" : ""?>><?=$option?></option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
<?php else: ?>
|
||||
<input type="text" class="form-control <?=(is_array($error_items) && in_array($item->id, $error_items)) ? "invalid" : ""?>" name="itemvalues[<?=$item->id?>]" value="<?=(isset($request)) ? $request->itemvalues[$item->id] : $item->getValue()?>" />
|
||||
<?php endif; ?>
|
||||
<small><?=$item->description?></small>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
<?php endforeach; ?>
|
||||
</table>
|
||||
|
||||
|
||||
<div class="row">
|
||||
<div class="col text-center">
|
||||
<input type="submit" class="btn btn-primary" value="Konfiguration speichern" />
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<a href="<?=self::getUrl("Contract","View", ['id' => $contract->id, 'filter' => $filter, 's' => $s])?>" class="btn btn-sm btn-secondary mr-1"><i class="fas fa-list"></i> Zurück zur Vertragsansicht</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php include(realpath(dirname(__FILE__)."/../../$mfLayoutPackage")."/footer.php"); ?>
|
||||
@@ -1,124 +0,0 @@
|
||||
<?php
|
||||
$siteTitle = "Benutzer";
|
||||
?>
|
||||
<?php include(realpath(dirname(__FILE__)."/../../$mfLayoutPackage")."/header.php"); ?>
|
||||
|
||||
<!-- start page title -->
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<div class="page-title-box">
|
||||
<div class="page-title-right">
|
||||
<ol class="breadcrumb m-0">
|
||||
<li class="breadcrumb-item"><a href="<?=self::getUrl("Dashboard")?>">the-tool</a></li>
|
||||
<li class="breadcrumb-item"><a href="<?=self::getUrl("Contract")?>">Verträge</a></li>
|
||||
<li class="breadcrumb-item">Vertragsconfig</li>
|
||||
</ol>
|
||||
</div>
|
||||
<h4 class="page-title">Vertragsconfig</h4>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- end page title -->
|
||||
|
||||
<!-- Main content -->
|
||||
<div class="row">
|
||||
<div class="col-lg">
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
|
||||
<?php if(is_array($groups) && count($groups)): ?>
|
||||
<?php foreach($groups as $group): ?>
|
||||
<h4>Gruppe <?=$group->name?></h4>
|
||||
<form method="post" action="<?=$this->getUrl("User","save")?>">
|
||||
|
||||
<?php if(is_array($group->items) && count($group->items)): ?>
|
||||
<?php $i = 0; foreach($group->items as $item): ?>
|
||||
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
|
||||
|
||||
<div class="p-2 <?=($i % 2 == 0) ? "bg-light" : ""?>">
|
||||
<div class="row">
|
||||
<div class="col-md-11 float-left">
|
||||
<h4 class="header-title">Attribut <span class="text-monospace text-pink"><?=$item->name?></span></h4>
|
||||
</div>
|
||||
<div class="col-md-1 float-right">
|
||||
<small><a class="text-danger" href="<?=self::getUrl("Contractconfig", "delete", ['id' => $item->id])?>" onclick="if(!confirm('Attribut wirklich löschen?')) return false;"><i class="fas fa-trash-alt"></i> löschen</a></small>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md-4">
|
||||
<div class="form-group">
|
||||
<label for="item_<?=$item->id?>_name">Name <small class="text-monospace">[a-z0-9._-]</small></label>
|
||||
<input type="text" class="form-control" id="item_<?=$item->id?>_name" name="item[<?=$item->id?>][name]" value="<?=$item->name?>" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<div class="form-group">
|
||||
<label for="item_<?=$item->id?>_type">Datentyp</label>
|
||||
<select class="form-control" id="item_<?=$item->id?>_type" name="item[<?=$item->id?>][type]">
|
||||
<option value="string">String</option>
|
||||
<option value="int">Ganzzahl</option>
|
||||
<option value="decimal">Dezimalzahl</option>
|
||||
<option value="enum">Auswahl</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-md-4">
|
||||
<div class="form-group" id="ddata_<?=$item->id?>">
|
||||
<label for="item_<?=$item->id?>_data">Auswahldaten (1 Element pro Zeile)</label>
|
||||
<textarea class="form-control" id="item_<?=$item->id?>_data" name="item[<?=$item->id?>][data]"><?=$item->typedata?></textarea>
|
||||
<input type="text" class="form-control" id="item_<?=$item->id?>_pattern" name="item[<?=$item->id?>][pattern]" value="<?=$item->pattern?>" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div class="form-group row">
|
||||
<div class="col-md-4">
|
||||
<div class="form-group">
|
||||
<label for="item_<?=$item->id?>_displayname">Anzeigename</label>
|
||||
<input type="text" class="form-control" id="item_<?=$item->id?>_displayname" name="item[<?=$item->id?>][displayname]" value="<?=$item->displayname?>" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<div class="form-group">
|
||||
<label for="item_<?=$item->id?>_value">Standardwert</label>
|
||||
<input type="text" class="form-control" id="item_<?=$item->id?>_value" name="item[<?=$item->id?>][value]" value="<?=$item->value?>">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-md-4">
|
||||
<div class="form-group">
|
||||
<label for="item_<?=$item->id?>_description">Beschreibung</label>
|
||||
<input type="text" class="form-control" id="item_<?=$item->id?>_description" name="item[<?=$item->id?>][description]" value="<?=$item->description?>" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php $i++; endforeach; ?>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php endforeach; ?>
|
||||
<?php else: ?>
|
||||
<i>Keine Vertragsconfig Gruppen gefunden</i>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script type="text/javascript">
|
||||
$("#address_id").select2({
|
||||
allowClear: true,
|
||||
placeholder: ""
|
||||
});
|
||||
|
||||
</script>
|
||||
|
||||
<?php include(realpath(dirname(__FILE__)."/../")."/footer.php"); ?><?php
|
||||
247
Layout/default/Contractconfig/Index_old.php
Normal file
247
Layout/default/Contractconfig/Index_old.php
Normal file
@@ -0,0 +1,247 @@
|
||||
<?php
|
||||
$siteTitle = "Benutzer";
|
||||
?>
|
||||
<?php include(realpath(dirname(__FILE__)."/../../$mfLayoutPackage")."/header.php"); ?>
|
||||
|
||||
<!-- start page title -->
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<div class="page-title-box">
|
||||
<div class="page-title-right">
|
||||
<ol class="breadcrumb m-0">
|
||||
<li class="breadcrumb-item"><a href="<?=self::getUrl("Dashboard")?>"><?=MFAPPNAME_SLUG?></a></li>
|
||||
<li class="breadcrumb-item"><a href="<?=self::getUrl("Contractconfig")?>">Contractconfig</a></li>
|
||||
<li class="breadcrumb-item">Contractconfig</li>
|
||||
</ol>
|
||||
</div>
|
||||
<h4 class="page-title">Contractconfig</h4>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- end page title -->
|
||||
|
||||
<!-- Main content -->
|
||||
<div class="row">
|
||||
<div class="col-lg">
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
|
||||
<div class="row">
|
||||
<div class="col-4">
|
||||
<div class="form-group">
|
||||
<form method="post" action="<?=self::getUrl("Contractconfig", "addGroup")?>">
|
||||
<label class="form-label" for="">Neue Config Gruppe anlegen</label>
|
||||
<div class="input-group mb-3">
|
||||
<input type="text" class="form-control" name="name" placeholder="Gruppenname..." />
|
||||
<div class="input-group-append">
|
||||
<button type="submit" class="btn btn-primary"><i class="fas fa-plus"></i> Gruppe hinzufügen</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php if(is_array($configgroups) && count($configgroups)): ?>
|
||||
<?php foreach($configgroups as $group): ?>
|
||||
<h4>Gruppe <?=$group->name?> <small><a href="#" onclick="$('#item-form-<?=$group->id?>').toggle()"><i class="fas fa-plus"></i> Neues Element erstellen</a></small></h4>
|
||||
|
||||
<div class="card hidden" id="item-form-<?=$group->id?>">
|
||||
<div class="card-body">
|
||||
<form method="post" action="<?=self::getUrl("Contractconfig", "save")?>">
|
||||
<input type="hidden" name="group_id" value="<?=$group->id?>" />
|
||||
<div class="p-2 <?=($i % 2 == 0) ? "bg-light" : ""?>">
|
||||
<div class="row col">
|
||||
<h5>Neues Config Element</h5>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md-4">
|
||||
<div class="form-group">
|
||||
<label for="item_new_name">Name <small class="text-monospace">[a-z0-9._-]</small></label>
|
||||
<input type="text" class="form-control" id="item_new_name" name="name" value="" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<div class="form-group">
|
||||
<label for="item_new_type">Datentyp</label>
|
||||
<select class="form-control" id="item_new_type" name="type" onchange='toggleTypedata("new")'>
|
||||
<option value="string">String</option>
|
||||
<option value="int">Ganzzahl</option>
|
||||
<option value="decimal">Dezimalzahl</option>
|
||||
<option value="enum">Auswahl</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-md-4">
|
||||
<div class="form-group" id="typedata_new">
|
||||
<div class="enum hidden">
|
||||
<label for="item_new_data">Auswahldaten (1 Element pro Zeile)</label>
|
||||
<textarea class="form-control" style="height: 128px" id="item_new_data" name="data"></textarea>
|
||||
</div>
|
||||
<div class="pattern">
|
||||
<label for="item_new_pattern">Regex Pattern</label>
|
||||
<input type="text" class="form-control" id="item_new_pattern" name="pattern" value="" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div class="form-group row">
|
||||
<div class="col-md-4">
|
||||
<div class="form-group">
|
||||
<label for="item_new_displayname">Anzeigename</label>
|
||||
<input type="text" class="form-control" id="item_new_displayname" name="displayname" value="" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-md-4">
|
||||
<div class="form-group">
|
||||
<label for="item_new_description">Beschreibung</label>
|
||||
<input type="text" class="form-control" id="item_new_description" name="description" value="" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group row">
|
||||
<div class="col">
|
||||
<input type="submit" class="btn btn-primary" value="Speichern" />
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php if(is_array($group->items) && count($group->items)): ?>
|
||||
<?php $i = 0; foreach($group->items as $item): ?>
|
||||
|
||||
<div class="list-group">
|
||||
<a href="#" class="list-group-item list-group-item-action" onclick="$('#item-edit-<?=$item->id?>').toggle()"><span class="text-monospace text-pink"><?=$item->name?></span> - <?=$item->displayname?> [<?=$item->type?>]</a>
|
||||
|
||||
|
||||
<div class="card hidden" id="item-edit-<?=$item->id?>">
|
||||
<div class="card-body">
|
||||
|
||||
<form method="post" action="<?=self::getUrl("Contractconfig", "save")?>">
|
||||
<input type="hidden" name="item_id" value="<?=$item->id?>" />
|
||||
<input type="hidden" name="group_id" value="<?=$group->id?>" />
|
||||
<div class="p-2 <?=($i % 2 == 0) ? "bg-light" : ""?>">
|
||||
<div class="row">
|
||||
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md-4">
|
||||
<div class="form-group">
|
||||
<label for="item_<?=$item->id?>_name">Name <small class="text-monospace">[a-z0-9._-]</small></label>
|
||||
<input type="text" class="form-control" id="item_<?=$item->id?>_name" name="name" value="<?=$item->name?>" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<div class="form-group">
|
||||
<label for="item_<?=$item->id?>_type">Datentyp</label>
|
||||
<select class="form-control" id="item_<?=$item->id?>_type" name="type" onchange="toggleTypedata(<?=$item->id?>)">
|
||||
<option value="string" <?=($item->type == "string") ? "selected='selected'" : ""?>>String</option>
|
||||
<option value="int" <?=($item->type == "int") ? "selected='selected'" : ""?>>Ganzzahl</option>
|
||||
<option value="decimal" <?=($item->type == "decimal") ? "selected='selected'" : ""?>>Dezimalzahl</option>
|
||||
<option value="enum" <?=($item->type == "enum") ? "selected='selected'" : ""?>>Auswahl</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-md-4">
|
||||
<div class="form-group" id="typedata_<?=$item->id?>">
|
||||
<div class="enum <?=($item->type != "enum") ? "hidden" : ""?>">
|
||||
<label for="item_<?=$item->id?>_data">Auswahldaten (1 Element pro Zeile)</label>
|
||||
<textarea class="form-control" style="height: 128px" id="item_<?=$item->id?>_data" name="data"><?=$item->typedata?></textarea>
|
||||
</div>
|
||||
<div class="pattern <?=($item->type != "string") ? "hidden" : ""?>">
|
||||
<label for="item_<?=$item->id?>_pattern">Regex Pattern</label>
|
||||
<input type="text" class="form-control" id="item_<?=$item->id?>_pattern" name="pattern" value="<?=$item->pattern?>" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div class="form-group row">
|
||||
<div class="col-md-4">
|
||||
<div class="form-group">
|
||||
<label for="item_<?=$item->id?>_displayname">Anzeigename</label>
|
||||
<input type="text" class="form-control" id="item_<?=$item->id?>_displayname" name="displayname" value="<?=$item->displayname?>" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-md-4">
|
||||
<div class="form-group">
|
||||
<label for="item_<?=$item->id?>_description">Beschreibung</label>
|
||||
<input type="text" class="form-control" id="item_<?=$item->id?>_description" name="description" value="<?=$item->description?>" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group row">
|
||||
<div class="col-md-11 float-left">
|
||||
<input type="submit" class="btn btn-primary" value="Speichern" />
|
||||
</div>
|
||||
<div class="col-md-1 float-right">
|
||||
<small><a class="text-danger" href="<?=self::getUrl("Contractconfig", "deleteItem", ['id' => $item->id])?>" onclick="if(!confirm('Attribut wirklich löschen?')) return false;"><i class="fas fa-trash-alt"></i> löschen</a></small>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php $i++; endforeach; ?>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php $i++; endforeach; ?>
|
||||
<?php else: ?>
|
||||
<i>Keine Configgruppen gefunden</i>
|
||||
<?php endif; ?>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script type="text/javascript">
|
||||
$("#address_id").select2({
|
||||
allowClear: true,
|
||||
placeholder: ""
|
||||
});
|
||||
|
||||
var item;
|
||||
var hash = window.location.hash.substr(1);
|
||||
var match = hash.match(/item=(\d+)/);
|
||||
if(match && match[1]) {
|
||||
item = match[1]
|
||||
$('#item-edit-' + item).show()
|
||||
var pos = $('#item-edit-' + item).offset().top;
|
||||
$(window).scrollTop(pos);
|
||||
}
|
||||
|
||||
function toggleTypedata(id) {
|
||||
var type = $('#item_' + id + '_type').val();
|
||||
if(type == "enum") {
|
||||
$('#typedata_' + id + " .enum").show();
|
||||
$('#typedata_' + id + " .pattern").hide();
|
||||
} else if(type == "string") {
|
||||
$('#typedata_' + id + " .pattern").show();
|
||||
$('#typedata_' + id + " .enum").hide();
|
||||
} else {
|
||||
$('#typedata_' + id + " .pattern").hide();
|
||||
$('#typedata_' + id + " .enum").hide();
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<?php include(realpath(dirname(__FILE__)."/../")."/footer.php"); ?><?php
|
||||
247
Layout/default/Contractconfiggroup/Index.php
Normal file
247
Layout/default/Contractconfiggroup/Index.php
Normal file
@@ -0,0 +1,247 @@
|
||||
<?php
|
||||
$siteTitle = "Benutzer";
|
||||
?>
|
||||
<?php include(realpath(dirname(__FILE__)."/../../$mfLayoutPackage")."/header.php"); ?>
|
||||
|
||||
<!-- start page title -->
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<div class="page-title-box">
|
||||
<div class="page-title-right">
|
||||
<ol class="breadcrumb m-0">
|
||||
<li class="breadcrumb-item"><a href="<?=self::getUrl("Dashboard")?>"><?=MFAPPNAME_SLUG?></a></li>
|
||||
<li class="breadcrumb-item"><a href="<?=self::getUrl("Contractconfig")?>">Contractconfig</a></li>
|
||||
<li class="breadcrumb-item">Contractconfig</li>
|
||||
</ol>
|
||||
</div>
|
||||
<h4 class="page-title">Contractconfig</h4>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- end page title -->
|
||||
|
||||
<!-- Main content -->
|
||||
<div class="row">
|
||||
<div class="col-lg">
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
|
||||
<div class="row">
|
||||
<div class="col-4">
|
||||
<div class="form-group">
|
||||
<form method="post" action="<?=self::getUrl("Contractconfiggroup", "save")?>">
|
||||
<label class="form-label" for="">Neue Config Gruppe anlegen</label>
|
||||
<div class="input-group mb-3">
|
||||
<input type="text" class="form-control" name="name" placeholder="Gruppenname..." />
|
||||
<div class="input-group-append">
|
||||
<button type="submit" class="btn btn-primary"><i class="fas fa-plus"></i> Gruppe hinzufügen</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php if(is_array($configgroups) && count($configgroups)): ?>
|
||||
<?php foreach($configgroups as $group): ?>
|
||||
<h4>Gruppe <?=$group->name?> <small><a href="#" onclick="$('#item-form-<?=$group->id?>').toggle()"><i class="fas fa-plus"></i> Neues Element erstellen</a></small></h4>
|
||||
|
||||
<div class="card hidden" id="item-form-<?=$group->id?>">
|
||||
<div class="card-body">
|
||||
<form method="post" action="<?=self::getUrl("ContractconfigItem", "save")?>">
|
||||
<input type="hidden" name="group_id" value="<?=$group->id?>" />
|
||||
<div class="p-2 <?=($i % 2 == 0) ? "bg-light" : ""?>">
|
||||
<div class="row col">
|
||||
<h5>Neues Config Element</h5>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md-4">
|
||||
<div class="form-group">
|
||||
<label for="item_new_name">Name <small class="text-monospace">[a-z0-9._-]</small></label>
|
||||
<input type="text" class="form-control" id="item_new_name" name="name" value="" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<div class="form-group">
|
||||
<label for="item_new_type">Datentyp</label>
|
||||
<select class="form-control" id="item_new_type" name="type" onchange='toggleTypedata("new")'>
|
||||
<option value="string">String</option>
|
||||
<option value="int">Ganzzahl</option>
|
||||
<option value="decimal">Dezimalzahl</option>
|
||||
<option value="enum">Auswahl</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-md-4">
|
||||
<div class="form-group" id="typedata_new">
|
||||
<div class="enum hidden">
|
||||
<label for="item_new_data">Auswahldaten (1 Element pro Zeile)</label>
|
||||
<textarea class="form-control" style="height: 128px" id="item_new_data" name="data"></textarea>
|
||||
</div>
|
||||
<div class="pattern">
|
||||
<label for="item_new_pattern">Regex Pattern</label>
|
||||
<input type="text" class="form-control" id="item_new_pattern" name="pattern" value="" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div class="form-group row">
|
||||
<div class="col-md-4">
|
||||
<div class="form-group">
|
||||
<label for="item_new_displayname">Anzeigename</label>
|
||||
<input type="text" class="form-control" id="item_new_displayname" name="displayname" value="" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-md-4">
|
||||
<div class="form-group">
|
||||
<label for="item_new_description">Beschreibung</label>
|
||||
<input type="text" class="form-control" id="item_new_description" name="description" value="" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group row">
|
||||
<div class="col">
|
||||
<input type="submit" class="btn btn-primary" value="Speichern" />
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php if(is_array($group->items) && count($group->items)): ?>
|
||||
<?php $i = 0; foreach($group->items as $item): ?>
|
||||
|
||||
<div class="list-group">
|
||||
<a href="#" class="list-group-item list-group-item-action" onclick="$('#item-edit-<?=$item->id?>').toggle()"><span class="text-monospace text-pink"><?=$item->name?></span> - <?=$item->displayname?> [<?=$item->type?>]</a>
|
||||
|
||||
|
||||
<div class="card hidden" id="item-edit-<?=$item->id?>">
|
||||
<div class="card-body">
|
||||
|
||||
<form method="post" action="<?=self::getUrl("ContractconfigItem", "save")?>">
|
||||
<input type="hidden" name="item_id" value="<?=$item->id?>" />
|
||||
<input type="hidden" name="group_id" value="<?=$group->id?>" />
|
||||
<div class="p-2 <?=($i % 2 == 0) ? "bg-light" : ""?>">
|
||||
<div class="row">
|
||||
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md-4">
|
||||
<div class="form-group">
|
||||
<label for="item_<?=$item->id?>_name">Name <small class="text-monospace">[a-z0-9._-]</small></label>
|
||||
<input type="text" class="form-control" id="item_<?=$item->id?>_name" name="name" value="<?=$item->name?>" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<div class="form-group">
|
||||
<label for="item_<?=$item->id?>_type">Datentyp</label>
|
||||
<select class="form-control" id="item_<?=$item->id?>_type" name="type" onchange="toggleTypedata(<?=$item->id?>)">
|
||||
<option value="string" <?=($item->type == "string") ? "selected='selected'" : ""?>>String</option>
|
||||
<option value="int" <?=($item->type == "int") ? "selected='selected'" : ""?>>Ganzzahl</option>
|
||||
<option value="decimal" <?=($item->type == "decimal") ? "selected='selected'" : ""?>>Dezimalzahl</option>
|
||||
<option value="enum" <?=($item->type == "enum") ? "selected='selected'" : ""?>>Auswahl</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-md-4">
|
||||
<div class="form-group" id="typedata_<?=$item->id?>">
|
||||
<div class="enum <?=($item->type != "enum") ? "hidden" : ""?>">
|
||||
<label for="item_<?=$item->id?>_data">Auswahldaten (1 Element pro Zeile)</label>
|
||||
<textarea class="form-control" style="height: 128px" id="item_<?=$item->id?>_data" name="data"><?=$item->typedata?></textarea>
|
||||
</div>
|
||||
<div class="pattern <?=($item->type != "string") ? "hidden" : ""?>">
|
||||
<label for="item_<?=$item->id?>_pattern">Regex Pattern</label>
|
||||
<input type="text" class="form-control" id="item_<?=$item->id?>_pattern" name="pattern" value="<?=$item->pattern?>" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div class="form-group row">
|
||||
<div class="col-md-4">
|
||||
<div class="form-group">
|
||||
<label for="item_<?=$item->id?>_displayname">Anzeigename</label>
|
||||
<input type="text" class="form-control" id="item_<?=$item->id?>_displayname" name="displayname" value="<?=$item->displayname?>" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-md-4">
|
||||
<div class="form-group">
|
||||
<label for="item_<?=$item->id?>_description">Beschreibung</label>
|
||||
<input type="text" class="form-control" id="item_<?=$item->id?>_description" name="description" value="<?=$item->description?>" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group row">
|
||||
<div class="col-md-11 float-left">
|
||||
<input type="submit" class="btn btn-primary" value="Speichern" />
|
||||
</div>
|
||||
<div class="col-md-1 float-right">
|
||||
<small><a class="text-danger" href="<?=self::getUrl("Contractconfig", "deleteItem", ['id' => $item->id])?>" onclick="if(!confirm('Attribut wirklich löschen?')) return false;"><i class="fas fa-trash-alt"></i> löschen</a></small>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php $i++; endforeach; ?>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php $i++; endforeach; ?>
|
||||
<?php else: ?>
|
||||
<i>Keine Configgruppen gefunden</i>
|
||||
<?php endif; ?>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script type="text/javascript">
|
||||
$("#address_id").select2({
|
||||
allowClear: true,
|
||||
placeholder: ""
|
||||
});
|
||||
|
||||
var item;
|
||||
var hash = window.location.hash.substr(1);
|
||||
var match = hash.match(/item=(\d+)/);
|
||||
if(match && match[1]) {
|
||||
item = match[1]
|
||||
$('#item-edit-' + item).show()
|
||||
var pos = $('#item-edit-' + item).offset().top;
|
||||
$(window).scrollTop(pos);
|
||||
}
|
||||
|
||||
function toggleTypedata(id) {
|
||||
var type = $('#item_' + id + '_type').val();
|
||||
if(type == "enum") {
|
||||
$('#typedata_' + id + " .enum").show();
|
||||
$('#typedata_' + id + " .pattern").hide();
|
||||
} else if(type == "string") {
|
||||
$('#typedata_' + id + " .pattern").show();
|
||||
$('#typedata_' + id + " .enum").hide();
|
||||
} else {
|
||||
$('#typedata_' + id + " .pattern").hide();
|
||||
$('#typedata_' + id + " .enum").hide();
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<?php include(realpath(dirname(__FILE__)."/../")."/footer.php"); ?><?php
|
||||
@@ -23,19 +23,19 @@
|
||||
<table style="width: 100%">
|
||||
<tr>
|
||||
<td style="width:50%">
|
||||
<img src="<?=$ressourcePathPrefix?>assets/pdf/logo.png" />
|
||||
<img src="<?=$ressourcePathPrefix?>assets/pdf/logo-xinon.png" />
|
||||
</td>
|
||||
<td style="width:50%; text-align: right;">
|
||||
<table style="text-align: left; width:100%">
|
||||
<tr>
|
||||
<td style="text-align: right;">Kundennummer:</td>
|
||||
<td><?=$owner->customer_number?></td>
|
||||
<td style="padding-left: 4pt;"><?=$owner->customer_number?></td>
|
||||
</tr><tr>
|
||||
<td style="text-align: right;">Vertrag erfasst am:</td>
|
||||
<td><?=date('d.m.Y', $order->create)?></td>
|
||||
<td style="padding-left: 4pt;"><?=date('d.m.Y', $order->create)?></td>
|
||||
</tr><tr>
|
||||
<td style="text-align: right;">Bestelldatum:</td>
|
||||
<td><?=date('d.m.Y', $order->order_date)?></td>
|
||||
<td style="padding-left: 4pt;"><?=date('d.m.Y', $order->order_date)?></td>
|
||||
</tr><tr>
|
||||
</table>
|
||||
</td>
|
||||
@@ -85,14 +85,14 @@
|
||||
Rechnungsauskünfte, etc) nach Ihrem <strong>persönlichen Service-PIN</strong> fragen.</p>
|
||||
</div>
|
||||
|
||||
<div style="height:48pt;"></div>
|
||||
<div style="height:32pt;"></div>
|
||||
|
||||
<div>
|
||||
<p><strong>Sollten Sie noch Fragen haben erreichen Sie uns per Mail (office@xinon.at) oder
|
||||
telefonisch unter der Rufnummer 03115 40800.</strong></p>
|
||||
telefonisch unter der Rufnummer <span style="white-space: nowrap">03115 40800.</span></strong></p>
|
||||
</div>
|
||||
|
||||
<div style="height:48pt;"></div>
|
||||
<div style="height:32pt;"></div>
|
||||
|
||||
<div>
|
||||
<p>Mit besten Grüßen,</p>
|
||||
|
||||
@@ -302,29 +302,36 @@
|
||||
<td><?=($term->building->getWorkflowvalue('ist_rohrverband_name')) ? $term->building->getWorkflowvalue('ist_rohrverband_name') : $term->building->getWorkflowvalue('rohrverband_name')?></td>
|
||||
<td><?=($term->building->getWorkflowvalue('ist_rohrtype')) ? $term->building->getWorkflowvalue('ist_rohrtype') : $term->building->getWorkflowvalue('rohrtype')?></td>
|
||||
<td>
|
||||
<?php if($term->building->getWorkflowvalue('ist_rohrfarbe')): ?>
|
||||
<?php $rohrfarbe = false;
|
||||
if($term->building->getWorkflowvalue('ist_rohrfarbe')) {
|
||||
$rohrfarbe = $term->building->getWorkflowvalue('ist_rohrfarbe');
|
||||
} elseif($term->building->getWorkflowvalue('rohrfarbe')) {
|
||||
$rohrfarbe = $term->building->getWorkflowvalue('rohrfarbe');
|
||||
}
|
||||
?>
|
||||
<?php if($rohrfarbe): ?>
|
||||
<?php if(TT_CABLE_COLORS[$rohrfarbe]['two-color']): ?>
|
||||
<span
|
||||
style="
|
||||
background-color: #<?=TT_CABLE_COLORS[$term->building->getWorkflowvalue('ist_rohrfarbe')]["hex"]?>;
|
||||
<?php if(TT_CABLE_COLORS[$term->building->getWorkflowvalue('ist_rohrfarbe')]["mark"]): ?>
|
||||
color: #<?=TT_CABLE_COLORS[$term->building->getWorkflowvalue('ist_rohrfarbe')]["hexfg"]?>;
|
||||
<?php else: ?>
|
||||
color: #<?=TT_CABLE_COLORS[$term->building->getWorkflowvalue('ist_rohrfarbe')]["hex"]?>;
|
||||
<?php endif; ?>
|
||||
background: rgb(<?=TT_CABLE_COLORS[$rohrfarbe]["r"]?>,<?=TT_CABLE_COLORS[$rohrfarbe]["g"]?>,<?=TT_CABLE_COLORS[$rohrfarbe]["b"]?>);
|
||||
background: linear-gradient(90deg, rgba(<?=TT_CABLE_COLORS[$rohrfarbe]["r"]?>,<?=TT_CABLE_COLORS[$rohrfarbe]["g"]?>,<?=TT_CABLE_COLORS[$rohrfarbe]["b"]?>,.5) 0%, rgba(<?=TT_CABLE_COLORS[$rohrfarbe]["r"]?>,<?=TT_CABLE_COLORS[$rohrfarbe]["g"]?>,<?=TT_CABLE_COLORS[$rohrfarbe]["b"]?>,.5) 50%, rgba(<?=TT_CABLE_COLORS[$rohrfarbe]["r2"]?>,<?=TT_CABLE_COLORS[$rohrfarbe]["g2"]?>,<?=TT_CABLE_COLORS[$rohrfarbe]["b2"]?>,.5) 50%, rgba(<?=TT_CABLE_COLORS[$rohrfarbe]["r2"]?>,<?=TT_CABLE_COLORS[$rohrfarbe]["g2"]?>,<?=TT_CABLE_COLORS[$rohrfarbe]["b2"]?>,.5) 100%);
|
||||
padding-right: 42px;
|
||||
border-radius: 3px;
|
||||
">-------</span> <?=ucfirst($term->building->getWorkflowvalue('ist_rohrfarbe'))?>
|
||||
<?php elseif($term->building->getWorkflowvalue('rohrfarbe')): ?>
|
||||
"> </span> <?=ucfirst($rohrfarbe)?>
|
||||
|
||||
<?php else: ?>
|
||||
<span
|
||||
style="
|
||||
background-color: #<?=TT_CABLE_COLORS[$term->building->getWorkflowvalue('rohrfarbe')]["hex"]?>;
|
||||
<?php if(TT_CABLE_COLORS[$term->building->getWorkflowvalue('rohrfarbe')]["mark"]): ?>
|
||||
color: #<?=TT_CABLE_COLORS[$term->building->getWorkflowvalue('rohrfarbe')]["hexfg"]?>;
|
||||
background-color: #<?=TT_CABLE_COLORS[$rohrfarbe]["hex"]?>;
|
||||
<?php if(TT_CABLE_COLORS[$rohrfarbe]["mark"]): ?>
|
||||
color: #<?=TT_CABLE_COLORS[$rohrfarbe]["hexfg"]?>;
|
||||
<?php else: ?>
|
||||
color: #<?=TT_CABLE_COLORS[$term->building->getWorkflowvalue('rohrfarbe')]["hex"]?>;
|
||||
color: #<?=TT_CABLE_COLORS[$rohrfarbe]["hex"]?>;
|
||||
<?php endif; ?>
|
||||
border-radius: 3px;
|
||||
">-------</span> <?=ucfirst($term->building->getWorkflowvalue('rohrfarbe'))?>
|
||||
">-------</span> <?=ucfirst($rohrfarbe)?>
|
||||
<?php endif; ?>
|
||||
<?php endif; ?>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
@@ -50,7 +50,7 @@
|
||||
<select name="filter[network_id]" id="filter_network_id" class="form-control">
|
||||
<option></option>
|
||||
<?php foreach($sorted_networks as $fnet => $nid): ?>
|
||||
<option value="<?=$nid?>" <?=($filter['network_id'] == $nid) ? "selected='selected'" : ""?>><?=$fnet?></option>
|
||||
<option value="<?=$nid?>" <?=(is_array($filter) && array_key_exists("network_id", $filter) && $filter['network_id'] == $nid) ? "selected='selected'" : ""?>><?=$fnet?></option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
</div>
|
||||
@@ -285,7 +285,19 @@
|
||||
<td onclick="toggleOrder(<?=$order->id?>)" colspan="6" class="pt-0" style="border-top: none;">
|
||||
<div class="row">
|
||||
<div class="mr-4 order-date-pill <?=($order->shippingdate) ? "active" : ""?>">Versandtermin: <span class="text-monospace"><?=($order->shippingdate) ? "<span class='text-success'>".date("d.m.Y", $order->shippingdate)."</span>" : "--.--.----"?></span></div>
|
||||
<div class="order-date-pill <?=($order->install_date) ? "active" : ""?>">Vorortinstallation: <span class="text-monospace"><?=($order->install_date) ? "<span class='text-success'>".date("d.m.Y",$order->install_date)."</span>" : "--.--.----"?></span></div>
|
||||
<?php if($order->install_date): ?>
|
||||
<div id="date-pill-<?=$order->id?>-install_date" class="order-date-pill active" id="order-install-date-<?=$order->id?>">
|
||||
<span class='text-success'>Vorortinstallation: <?=date("d.m.Y",$order->install_date)?></span>
|
||||
<div>
|
||||
<?php elseif(count($order->install_products)): ?>
|
||||
<div id="date-pill-<?=$order->id?>-install_date" class="order-date-pill active" id="order-install-date-<?=$order->id?>">
|
||||
<span class='text-success'>Vorortinstallation: --.--.----</span>
|
||||
</div>
|
||||
<?php else: ?>
|
||||
<div id="date-pill-<?=$order->id?>-install_date" class="order-date-pill" id="order-install-date-<?=$order->id?>">
|
||||
<span>Vorortinstallation: --.--.----</span>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
@@ -302,7 +314,7 @@
|
||||
<li class="nav-item"><a class="nav-link" href="#order-detail-<?=$order->id?>-contact" data-toggle="tab" aria-expanded="false">Kontakt</a></li>
|
||||
<li class="nav-item"><a class="nav-link" href="#order-detail-<?=$order->id?>-details" data-toggle="tab" aria-expanded="false">Details</a></li>
|
||||
<li class="nav-item"><a class="nav-link" href="#order-detail-<?=$order->id?>-files" data-toggle="tab" aria-expanded="false">Dokumente</a></li>
|
||||
<li class="nav-item"><a class="nav-link" href="#order-detail-<?=$order->id?>-technician" data-toggle="tab" aria-expanded="false">Technische Herstellung</a></li>
|
||||
<!--<li class="nav-item"><a class="nav-link" href="#order-detail-<?=$order->id?>-technician" data-toggle="tab" aria-expanded="false">Technische Herstellung</a></li>-->
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
@@ -625,7 +637,6 @@
|
||||
</tr>
|
||||
<?php $order_count = 0; ?>
|
||||
<?php foreach($orders as $order): ?>
|
||||
<?php //$this->log->debug("blah: ".print_r($order->terminations[0]->workflowitems["customer_setup_date"]->value,true)); ?>
|
||||
<tr class="order-list-tr pb-0 <?=($order_count % 2 == 0) ? "table-bg-even" : ""?>" id="order-<?=$order->id?>">
|
||||
<td>
|
||||
<?=($order->customer_type == "business") ? "<i class='fas fa-buildings text-primary mr-1' title='Businessprodukt vorhanden'></i>" : "<i class='fas fa-user text-danger mr-1' title='Nur Residential Produkte'></i>"?>
|
||||
@@ -731,7 +742,22 @@
|
||||
<div class="mr-4 order-date-pill <?=(count($order->terminations) && $order->terminations[0]->workflowitems["backbone_setup_date"]->value->value_string) ? "active" : ""?>">Leitungsbau Backbone: <span class="text-monospace"><?=(count($order->terminations) && $order->terminations[0]->workflowitems["backbone_setup_date"]->value->value_string) ? "<span class='text-success'>".$order->terminations[0]->workflowitems["backbone_setup_date"]->value->value_string."</span>" : "--.--.----"?></span></div>
|
||||
<div class="mr-4 order-date-pill <?=(count($order->terminations) && $order->terminations[0]->getWorkflowvalue("customer_setup_date")) ? "active" : ""?>">Leitungsbau Kunde: <span class="text-monospace"><?=(count($order->terminations) && $order->terminations[0]->getWorkflowvalue("customer_setup_date")) ? "<span class='text-success'>".$order->terminations[0]->getWorkflowvalue("customer_setup_date")."</span>" : "--.--.----"?></span></div>
|
||||
<div class="mr-4 order-date-pill <?=($order->shippingdate) ? "active" : ""?>">Versandtermin: <span class="text-monospace"><?=($order->shippingdate) ? "<span class='text-success'>".date("d.m.Y", $order->shippingdate)."</span>" : "--.--.----"?></span></div>
|
||||
<div id="date-pill-<?=$order->id?>-install_date" class="order-date-pill <?=($order->install_date) ? "active" : ""?>" id="order-install-date-<?=$order->id?>">Vorortinstallation: <span class="text-monospace"><?=($order->install_date) ? "<span class='text-success'>".date("d.m.Y",$order->install_date)."</span>" : "--.--.----"?></span></div>
|
||||
|
||||
<?php if($order->install_date): ?>
|
||||
<div id="date-pill-<?=$order->id?>-install_date" class="order-date-pill active" id="order-install-date-<?=$order->id?>">
|
||||
<span class='text-success'>Vorortinstallation: <?=date("d.m.Y",$order->install_date)?></span>
|
||||
<div>
|
||||
<?php elseif(count($order->install_products)): ?>
|
||||
<div id="date-pill-<?=$order->id?>-install_date" class="order-date-pill active" id="order-install-date-<?=$order->id?>">
|
||||
<span class='text-success'>Vorortinstallation: --.--.----</span>
|
||||
</div>
|
||||
<?php else: ?>
|
||||
<div id="date-pill-<?=$order->id?>-install_date" class="order-date-pill" id="order-install-date-<?=$order->id?>">
|
||||
<span>Vorortinstallation: --.--.----</span>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
<ol class="breadcrumb m-0">
|
||||
<li class="breadcrumb-item"><a href="<?=self::getUrl("Dashboard")?>"><?=MFAPPNAME_SLUG?></a></li>
|
||||
<li class="breadcrumb-item"><a href="<?=self::getUrl("Preordercampaign")?>">Vorbestellung</a></li>
|
||||
<li class="breadcrumb-item active"><?=($campaign->id) ? "bearbeiten" : "Neu" ?></li>
|
||||
<li class="breadcrumb-item active"><?=($preorder->id) ? "bearbeiten" : "Neu" ?></li>
|
||||
</ol>
|
||||
</div>
|
||||
<h4 class="page-title">Vorbestellung</h4>
|
||||
@@ -47,18 +47,109 @@
|
||||
|
||||
|
||||
<div class="form-group row">
|
||||
<label class="col-lg-2 col-form-label" for="price">Adresse *</label>
|
||||
<label class="col-lg-2 col-form-label" for="adb_hausnummer_id">Adresse *</label>
|
||||
<div class="col-lg-10">
|
||||
<select class="form-control" name="adb_hausnummer_id" id="adb_hausnummer_id" />
|
||||
<?php if($preorder->adb_hausnummer_id): ?>
|
||||
<option value="<?=$preorder->adb_hausnummer_id?>" selected="selected"><?=$preorder->adb_hausnummer->plz->plz?> <?=$preorder->adb_hausnummer->strasse->ortschaft->name?>, <?=$preorder->adb_hausnummer->strasse->name?> <?=$preorder->adb_hausnummer->hausnummer?></option>
|
||||
<?php endif; ?>
|
||||
</select>
|
||||
|
||||
<div id="new-address-toggle" class="alert alert-info mt-1 mb-1 pb-1 pt-1 hidden">
|
||||
<h5><i class="icon fas fa-info-circle"></i> Adresse nicht gefunden?</h5>
|
||||
Vertippt? Richtiges Netzgebiet (<strong><?=$campaign->network->name?></strong>) ?<br /><br /><a href="#" onclick="toggleNewAddress()"><i class="far fa-plus-square"></i> Hier klickem um die Adresse neu anzulegen</a>
|
||||
|
||||
<div id="new-address" class="mt-0 mb-4 hidden">
|
||||
<hr />
|
||||
<div class="row" id="new-address-form">
|
||||
<div class="col-7 border">
|
||||
<div class="mb-3">
|
||||
<h4>Neue Adresse in Adress-Datenbank eintragen:</h4>
|
||||
<small class="text-danger">Alle mit * markierten Felder sind Pflichtfelder</small>
|
||||
</div>
|
||||
<div class="form-group row">
|
||||
<label class="col-lg-3 col-form-label" for="street">Straße <span class="text-danger">*</span> / Hausnummer <span class="text-danger">*</span></label>
|
||||
<div class="col-lg-6">
|
||||
<input type="text" class="form-control basicAutoComplete" autocomplete="off" data-url="<?=self::getUrl('AddressDB','api')?>?do=findStreets&autocomplete=1" name="new_address_street" id="new_address_street" value="<?=$preorder->new_address_street?>" placeholder="Straße" />
|
||||
</div>
|
||||
<div class="col-lg-3">
|
||||
<input type="text" class="form-control" name="new_address_housenumber" id="new_address_housenumber" value="<?=$preorder->new_address_housenumber?>" placeholder="Hausnummer" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group row">
|
||||
<label class="col-lg-3 col-form-label" for="zip">PLZ <span class="text-danger">*</span> / Ort <span class="text-danger">*</span></label>
|
||||
<div class="col-lg-2">
|
||||
<input type="text" class="form-control basicAutoComplete" autocomplete="off" data-url="<?=self::getUrl('AddressDB','api')?>?do=findZips&campaign_id=<?=$campaign->id?>&autocomplete=1" name="new_address_zip" id="new_address_zip" value="<?=$preorder->new_address_zip?>" placeholder="PLZ" />
|
||||
</div>
|
||||
<div class="col-lg-7">
|
||||
<input type="text" class="form-control basicAutoComplete" autocomplete="off" data-url="<?=self::getUrl('AddressDB','api')?>?do=findCities&campaign_id=<?=$campaign->id?>&autocomplete=1" name="new_address_city" id="new_address_city" value="<?=$preorder->new_address_city?>" placeholder="Ort" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group row">
|
||||
<label class="col-lg-3 col-form-label" for="zip">Ortsteil <span class="text-danger">*</span></label>
|
||||
<div class="col-lg-9">
|
||||
<input type="text" class="form-control basicAutoComplete" autocomplete="off" data-url="<?=self::getUrl('AddressDB','api')?>?do=findDistricts&campaign_id=<?=$campaign->id?>&autocomplete=1" name="new_address_district" id="new_address_district" value="<?=$preorder->new_address_zip?>" placeholder="Ortsteil" />
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
<div class="form-group row">
|
||||
<label class="col-lg-3 col-form-label" for="">Wohneinheit</label>
|
||||
<div class="col-lg-4">
|
||||
<div class="form-group row">
|
||||
<label class="col-lg-4 col-form-label text-right" for="">Block:</label>
|
||||
<div class="col-lg-6">
|
||||
<input type="text" class="form-control" name="new_address_block" id="new_address_block" value="<?=$preorder->block?>" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-lg-4">
|
||||
<div class="form-group row">
|
||||
<label class="col-lg-4 col-form-label text-right" for="">Stiege:</label>
|
||||
<div class="col-lg-6">
|
||||
<input type="text" class="form-control" name="new_address_stiege" id="new_address_stiege" value="<?=$preorder->stiege?>" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group row">
|
||||
<label class="col-lg-3 col-form-label" for=""></label>
|
||||
<div class="col-lg-4">
|
||||
<div class="form-group row">
|
||||
<label class="col-lg-4 col-form-label text-right" for="">Stock:</label>
|
||||
<div class="col-lg-6">
|
||||
<input type="text" class="form-control" name="new_address_stock" id="new_address_stock" value="<?=$preorder->stock?>" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-lg-4">
|
||||
<div class="form-group row">
|
||||
<label class="col-lg-4 col-form-label text-right" for="">Tür:</label>
|
||||
<div class="col-lg-6">
|
||||
<input type="text" class="form-control" name="new_address_tuer" id="new_address_tuer" value="<?=$preorder->tuer?>" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="form-group row">
|
||||
<label class="col-lg-2 col-form-label" for="price">Wohneinheit *</label>
|
||||
|
||||
|
||||
|
||||
<div class="form-group row" id="wohneinheit_row">
|
||||
<label class="col-lg-2 col-form-label" for="adb_wohneinheit_id">Wohneinheit *</label>
|
||||
<div class="col-lg-10">
|
||||
<select class="form-control" name="adb_wohneinheit_id" id="adb_wohneinheit_id" />
|
||||
<?php if($preorder->adb_wohneinheit_id): ?>
|
||||
@@ -70,16 +161,22 @@
|
||||
|
||||
|
||||
<div class="form-group row">
|
||||
<label class="col-lg-2 col-form-label" for="product_id">Vertriebspartner</label>
|
||||
<div class="col-lg-10">
|
||||
<select class="form-control" name="partner_id" id="partner_id">
|
||||
<option value=""></option>
|
||||
<label class="col-lg-2 col-form-label" for="product_id">Vertriebspartner</label>
|
||||
<div class="col-lg-10">
|
||||
<select class="form-control" name="partner_id" id="partner_id">
|
||||
<option value=""></option>
|
||||
<?php if($preorder->id): ?>
|
||||
<?php foreach($partners as $partner): ?>
|
||||
<option value="<?=$partner->id?>" <?=($preorder->partner_id == $partner->id) ? "selected='selected'" : ""?>><?=$partner->getCompanyOrName()?></option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
</div>
|
||||
<?php else: ?>
|
||||
<?php foreach($partners as $partner): ?>
|
||||
<option value="<?=$partner->id?>" <?=($me->address_id == $partner->id) ? "selected='selected'" : ""?>><?=$partner->getCompanyOrName()?></option>
|
||||
<?php endforeach; ?>
|
||||
<?php endif; ?>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="preorder-form" class="mt-4">
|
||||
<h4>Vorbestellung & Produkt</h4>
|
||||
@@ -222,52 +319,90 @@
|
||||
<div class="form-group row">
|
||||
<label class="col-lg-2 col-form-label" for="company">Firma</label>
|
||||
<div class="col-lg-10">
|
||||
<input type="text" class="form-control" name="company" id="company" value="<?=$preorder->company?>" />
|
||||
<input type="text" class="form-control" name="company" id="company" value="<?=$preorder->company?>" placeholder="Firma" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group row">
|
||||
<label class="col-lg-2 col-form-label" for="uid">UID</label>
|
||||
<div class="col-lg-10">
|
||||
<input type="text" class="form-control" name="uid" id="uid" value="<?=$preorder->uid?>" />
|
||||
<input type="text" class="form-control" name="uid" id="uid" value="<?=$preorder->uid?>" placeholder="UID" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group row">
|
||||
<label class="col-lg-2 col-form-label" for="firstname">Vorname *</label>
|
||||
<div class="col-lg-10">
|
||||
<input type="text" class="form-control" name="firstname" id="firstname" value="<?=$preorder->firstname?>" />
|
||||
<input type="text" class="form-control" name="firstname" id="firstname" value="<?=$preorder->firstname?>" placeholder="Vorname" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group row">
|
||||
<label class="col-lg-2 col-form-label" for="lastname">Nachname *</label>
|
||||
<div class="col-lg-10">
|
||||
<input type="text" class="form-control" name="lastname" id="lastname" value="<?=$preorder->lastname?>" />
|
||||
<input type="text" class="form-control" name="lastname" id="lastname" value="<?=$preorder->lastname?>" placeholder="Nachname" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group row">
|
||||
<label class="col-lg-2 col-form-label" for="street">Straße *</label>
|
||||
<div class="col-lg-10">
|
||||
<input type="text" class="form-control" name="street" id="street" value="<?=$preorder->street?>" />
|
||||
<label class="col-lg-2 col-form-label" for="street">Straße / Hausnummer *</label>
|
||||
<div class="col-lg-5">
|
||||
<input type="text" class="form-control" name="street" id="street" value="<?=$preorder->street?>" placeholder="Straße" />
|
||||
</div>
|
||||
<div class="col-lg-5">
|
||||
<input type="text" class="form-control" name="housenumber" id="housenumber" value="<?=$preorder->housenumber?>" placeholder="Hausnummer" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group row">
|
||||
<label class="col-lg-2 col-form-label" for=""></label>
|
||||
<div class="col-lg-1">
|
||||
<div class="form-group row">
|
||||
<label class="col-lg-6 col-form-label text-right" for="">Block:</label>
|
||||
<div class="col-lg-6">
|
||||
<input type="text" class="form-control" name="block" id="block" value="<?=$preorder->block?>" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-lg-1">
|
||||
<div class="form-group row">
|
||||
<label class="col-lg-6 col-form-label text-right" for="">Stiege:</label>
|
||||
<div class="col-lg-6">
|
||||
<input type="text" class="form-control" name="stiege" id="stiege" value="<?=$preorder->stiege?>" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-lg-1">
|
||||
<div class="form-group row">
|
||||
<label class="col-lg-6 col-form-label text-right" for="">Stock:</label>
|
||||
<div class="col-lg-6">
|
||||
<input type="text" class="form-control" name="stock" id="stock" value="<?=$preorder->stock?>" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-lg-1">
|
||||
<div class="form-group row">
|
||||
<label class="col-lg-6 col-form-label text-right" for="">Tür:</label>
|
||||
<div class="col-lg-6">
|
||||
<input type="text" class="form-control" name="tuer" id="tuer" value="<?=$preorder->tuer?>" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group row">
|
||||
<label class="col-lg-2 col-form-label" for="zip">PLZ / Ort *</label>
|
||||
<div class="col-lg-3">
|
||||
<input type="text" class="form-control" name="zip" id="zip" value="<?=$preorder->zip?>" />
|
||||
<input type="text" class="form-control" name="zip" id="zip" value="<?=$preorder->zip?>" placeholder="PLZ" />
|
||||
</div>
|
||||
<div class="col-lg-7">
|
||||
<input type="text" class="form-control" name="city" id="city" value="<?=$preorder->city?>" />
|
||||
<input type="text" class="form-control" name="city" id="city" value="<?=$preorder->city?>" placeholder="Ort" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group row">
|
||||
<label class="col-lg-2 col-form-label" for="phone">Telefon</label>
|
||||
<div class="col-lg-10">
|
||||
<input type="text" class="form-control" name="phone" id="phone" value="<?=$preorder->phone?>" />
|
||||
<input type="text" class="form-control" name="phone" id="phone" value="<?=$preorder->phone?>" placeholder="Telefon" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group row">
|
||||
<label class="col-lg-2 col-form-label" for="email">Email</label>
|
||||
<div class="col-lg-10">
|
||||
<input type="text" class="form-control" name="email" id="email" value="<?=$preorder->email?>" />
|
||||
<input type="text" class="form-control" name="email" id="email" value="<?=$preorder->email?>" placeholder="Email" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -293,9 +428,18 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
</form>
|
||||
|
||||
<?php if($preorder->submit_type == "api" && $preorder->submit_request): ?>
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<div class="form-group row">
|
||||
<label class="col-lg-2 col-form-label">Raw API Request</label>
|
||||
<div class="col-lg-10 text-monospace border" style="max-height: 512px; line-break: auto; overflow: auto; white-space: pre"><script>document.write(JSON.stringify(JSON.parse('<?=str_replace(["\n","\r"],"",$preorder->submit_request)?>'), null, "\t"));</script></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -334,7 +478,25 @@
|
||||
$("#setup_product_id").val($("#setup-activation input.value").val());
|
||||
<?php endif; ?>
|
||||
}
|
||||
|
||||
|
||||
$('#new_address_street').autoComplete({minLength: 2}).keydown(preventEnter).change(updateCustomerAddressFromNewAddress).on("autocomplete.select", updateCustomerAddressFromNewAddress);
|
||||
$('#new_address_zip').autoComplete({minLength: 1}).keydown(preventEnter).change(updateCustomerAddressFromNewAddress).on("autocomplete.select", updateCustomerAddressFromNewAddress);
|
||||
$('#new_address_city').autoComplete({minLength: 2}).keydown(preventEnter).change(updateCustomerAddressFromNewAddress).on("autocomplete.select", updateCustomerAddressFromNewAddress);
|
||||
$('#new_address_district').autoComplete({minLength: 2}).keydown(preventEnter);
|
||||
$('#new_address_housenumber').keydown(preventEnter).change(updateCustomerAddressFromNewAddress).on("autocomplete.select", updateCustomerAddressFromNewAddress);
|
||||
$('#new_address_block').keydown(preventEnter);
|
||||
$('#new_address_stiege').keydown(preventEnter);
|
||||
$('#new_address_stock').keydown(preventEnter);
|
||||
$('#new_address_tuer').keydown(preventEnter);
|
||||
|
||||
|
||||
function preventEnter() {
|
||||
if(event.keyCode == 13) {
|
||||
event.preventDefault();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$("#product_id").select2({
|
||||
allowClear: true,
|
||||
@@ -363,12 +525,20 @@
|
||||
|
||||
$('#adb_hausnummer_id').select2({
|
||||
ajax: {
|
||||
url: '<?=self::getUrl("AddressDB", "api", ["do" => "findAddress"])?>',
|
||||
url: '<?=self::getUrl("AddressDB", "api", ["do" => "findAddress", "campaign_id" => $campaign->id])?>',
|
||||
delay: 250,
|
||||
dataType: 'json'
|
||||
},
|
||||
minimumInputLength: 3,
|
||||
placeholder: "Suche nach Straße, Hausnummer, Ort"
|
||||
placeholder: "Suche nach Straße, Hausnummer, Ort",
|
||||
allowClear: true
|
||||
});
|
||||
|
||||
$('#adb_hausnummer_id').on('select2:close', function(e) {
|
||||
if(!$('#adb_hausnummer_id').val()) {
|
||||
$('#new-address-toggle').show();
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
|
||||
@@ -376,6 +546,28 @@
|
||||
var hausnummer_id = $('#adb_hausnummer_id').val();
|
||||
if(!hausnummer_id) return;
|
||||
|
||||
$('#new-address-toggle').hide();
|
||||
$('#new-address').hide();
|
||||
|
||||
$.get('<?=self::getUrl("AddressDB", "Api")?>',
|
||||
{
|
||||
do: "getAddressByHousenumber",
|
||||
hausnummer_id: hausnummer_id
|
||||
},
|
||||
function(success) {
|
||||
if(success.status != "OK") {
|
||||
return;
|
||||
}
|
||||
var address = success.result;
|
||||
console.log(address);
|
||||
$('#new_address_street').val(address.strasse);
|
||||
$('#new_address_housenumber').val(address.hausnummer);
|
||||
$('#new_address_zip').val(address.plz);
|
||||
$('#new_address_city').val(address.ort);
|
||||
$('#new_address_district').val(address.ortschaft);
|
||||
},
|
||||
'json');
|
||||
|
||||
|
||||
$.get('<?=self::getUrl("AddressDB", "Api")?>',
|
||||
{
|
||||
@@ -434,6 +626,14 @@
|
||||
"json");
|
||||
});
|
||||
|
||||
function updateCustomerAddressFromNewAddress() {
|
||||
$('input[name=street]').val($('#new_address_street').val());
|
||||
$('input[name=housenumber]').val($('#new_address_housenumber').val());
|
||||
$('input[name=zip]').val($('#new_address_zip').val());
|
||||
$('input[name=city]').val($('#new_address_city').val());
|
||||
}
|
||||
|
||||
|
||||
$('#adb_wohneinheit_id').change(function() {
|
||||
val = $('#adb_wohneinheit_id').val();
|
||||
|
||||
@@ -558,6 +758,12 @@
|
||||
'json');
|
||||
|
||||
}
|
||||
|
||||
function toggleNewAddress() {
|
||||
$('#new-address').toggle();
|
||||
$('#wohneinheit_row').toggle();
|
||||
event.preventDefault();
|
||||
}
|
||||
</script>
|
||||
|
||||
<?php include(realpath(dirname(__FILE__)."/../../$mfLayoutPackage")."/footer.php"); ?>
|
||||
@@ -16,7 +16,7 @@
|
||||
<li class="breadcrumb-item active">Vorbestellungen</li>
|
||||
</ol>
|
||||
</div>
|
||||
<h4 class="page-title">Vorbestellungen<?=($campaign) ? " - ".$campaign->name : ""?></h4>
|
||||
<h4 class="page-title">Vorbestellungen<?=(isset($campaign) && $campaign) ? " - ".$campaign->name : ""?></h4>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -36,8 +36,8 @@
|
||||
<label class="form-label" for="filter_preordercampaign_id">Kampagne</label>
|
||||
<select name="filter[preordercampaign_id]" id="filter_preordercampaign_id" class="form-control">
|
||||
<option value="">Alle</option>
|
||||
<?php foreach(PreordercampaignModel::getAll() as $c): ?>
|
||||
<option value="<?=$c->id?>" <?=($c->id == $campaign->id) ? "selected='selected'" : ""?>><?=$c->name?></option>
|
||||
<?php foreach($my_campaigns as $c): ?>
|
||||
<option value="<?=$c->id?>" <?=(isset($campaign) && $c->id == $campaign->id) ? "selected='selected'" : ""?>><?=$c->name?></option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
</div>
|
||||
@@ -61,6 +61,14 @@
|
||||
<option value="order" <?=(isset($filter) && array_key_exists("type", $filter) && in_array("order", $filter['type'])) ? "selected='selected'" : ""?>>Vollanschluss</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="col-2">
|
||||
<label class="form-label" for="filter_addon_services">Zusatzdienste</label>
|
||||
<select name="filter[addon_services]" id="filter_addon_services" class="form-control">
|
||||
<option></option>
|
||||
<option value="1" <?=(array_key_exists("addon_services", $filter) && $filter['addon_services'] == 1) ? "selected='selected'" : ""?>>Nur mit Zusatzdiensten</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="col-2">
|
||||
<label class="form-label" for="filter_address">Anschlussadresse</label>
|
||||
@@ -72,6 +80,17 @@
|
||||
<input type="text" class="form-control" name="filter[kunde]" id="filter_kunde" value="<?=$filter['kunde']?>" />
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div class="row mt-2">
|
||||
<div class="col-2">
|
||||
<label class="form-label" for="filter_address_source">Adressherkunft</label>
|
||||
<select name="filter[address_source]" id="filter_address_source" class="form-control">
|
||||
<option value=""></option>
|
||||
<option value="addressdb" <?=(isset($filter) && array_key_exists("address_source", $filter) && $filter['address_source'] == "addressdb") ? "selected='selected'" : ""?>>thetool AddressDB</option>
|
||||
<option value="manual" <?=(isset($filter) && array_key_exists("address_source", $filter) && $filter['address_source'] == "manual") ? "selected='selected'" : ""?>>manuelle Eingabe</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div class="row mt-2">
|
||||
<div class="col">
|
||||
@@ -94,7 +113,7 @@
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<div class="float-left">
|
||||
<h4 class="header-title">Liste aller Vorbestellungen<?=($campaign) ? " - ".$campaign->name : ""?></h4>
|
||||
<h4 class="header-title">Liste aller Vorbestellungen<?=(isset($campaign) && $campaign) ? " - ".$campaign->name : ""?></h4>
|
||||
</div>
|
||||
<?php if($filter['preordercampaign_id']): ?>
|
||||
<div class="float-right">
|
||||
@@ -131,11 +150,12 @@
|
||||
<?php if($preorder->building_id): ?>
|
||||
<td><?=$preorder->building->street?><br /><?=$preorder->building->zip?> <?=$preorder->building->city?></td>
|
||||
<?php elseif($preorder->adb_hausnummer_id): ?>
|
||||
<td>
|
||||
<td <?=($preorder->address_created) ? "class='alert-warning' title='Manuell angelegt'" : ""?>">
|
||||
<?=$preorder->adb_hausnummer->strasse->name?>
|
||||
<?=$preorder->adb_hausnummer->hausnummer?><br />
|
||||
<?=($preorder->adb_wohneinheit_id) ? ((string)$preorder->adb_wohneinheit ? $preorder->adb_wohneinheit."<br />" : "") : "<i class='text-pink'><keine Wohneinheit></i><br />"?>
|
||||
<?=$preorder->adb_hausnummer->plz->plz?>
|
||||
<?=$preorder->adb_hausnummer->ortschaft->name?><br />
|
||||
<?=$preorder->adb_hausnummer->strasse->gemeinde->name?>
|
||||
</td>
|
||||
<?php else: ?>
|
||||
@@ -144,7 +164,7 @@
|
||||
<td><?=($preorder->connection_count) ? $preorder->connection_count : 1?></td>
|
||||
<td>
|
||||
<?=($preorder->company) ? $preorder->company : $preorder->firstname." ".$preorder->lastname?><br />
|
||||
<?=$preorder->street?><br />
|
||||
<?=$preorder->street?><?=($preorder->housenumber) ? " ".$preorder->housenumber : ""?><br />
|
||||
<?=$preorder->zip?> <?=$preorder->city?>
|
||||
</td>
|
||||
<td>
|
||||
|
||||
@@ -122,6 +122,7 @@
|
||||
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
|
||||
<div class="form-group row">
|
||||
<label class="col-lg-2 col-form-label" for="adb_netzgebiet_ids">Beschränkt auf Salescluster (GWR)</label>
|
||||
<div class="col-lg-10">
|
||||
@@ -142,6 +143,39 @@
|
||||
<small>Diese Felder müssen beim Bestellen angegeben werden</small>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group row">
|
||||
<label class="col-lg-2 col-form-label" for="district_is_city">Ortsteil ist Ort:</label>
|
||||
<div class="col-lg-10">
|
||||
<select class="form-control" name="district_is_city" id="district_is_city">
|
||||
<option value="0" <?=(!$campaign->district_is_city) ? "selected='selected'" : ""?>>Nein</option>
|
||||
<option value="1" <?=($campaign->district_is_city) ? "selected='selected'" : ""?>>Ja</option>
|
||||
</select>
|
||||
<small>Statt Ort muss Ortsteil/Bezirk angegeben werden</small>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group row">
|
||||
<label class="col-lg-2 col-form-label" for="hausnummer_add_zusatz">Adresszusatz an Hausnummer anhängen:</label>
|
||||
<div class="col-lg-10">
|
||||
<select class="form-control" name="hausnummer_add_zusatz" id="hausnummer_add_zusatz">
|
||||
<option value="0" <?=(!$campaign->hausnummer_add_zusatz) ? "selected='selected'" : ""?>>Nein</option>
|
||||
<option value="1" <?=($campaign->hausnummer_add_zusatz) ? "selected='selected'" : ""?>>Ja</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group row">
|
||||
<label class="col-lg-2 col-form-label" for="exist_is_error">Erlaubte Vorbestellungen pro Wohneinheit (API):</label>
|
||||
<div class="col-lg-10">
|
||||
<select class="form-control" name="exist_is_error" id="exist_is_error">
|
||||
<option value="0" <?=(!$campaign->exist_is_error) ? "selected='selected'" : ""?>>Mehr als eine</option>
|
||||
<option value="1" <?=($campaign->exist_is_error) ? "selected='selected'" : ""?>>Maximal eine</option>
|
||||
</select>
|
||||
<small>Weiterer Bestellversuch liefert Fehler zurück</small>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -36,6 +36,18 @@
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<?php if($me->is("Admin")): ?>
|
||||
<div class="col-2">
|
||||
<label class="form-label" for="filter_netowner">Netzbesitzer</label>
|
||||
<select name="filter[netowner]" id="filter_netowner" class="form-control">
|
||||
<option></option>
|
||||
<?php foreach($netowners as $owner): ?>
|
||||
<option value="<?=$owner->id?>" <?=($filter['netowner'] == $owner->id) ? "selected='selected'" : ""?>><?=$owner->getCompanyOrName()?></option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<div class="col-1">
|
||||
<label class="form-label" for="filter_name">Name</label>
|
||||
<input type="text" class="form-control" name="filter[name]" id="filter_name" value="<?=$filter['name']?>" />
|
||||
@@ -59,15 +71,15 @@
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
<div class="card">
|
||||
<div class="card-body mb-3">
|
||||
<div class="float-left">
|
||||
<h4 class="header-title">Liste aller Vorbestellkampagnen</h4>
|
||||
</div>
|
||||
<div class="float-right">
|
||||
<a class="btn btn-primary mb-2" href="<?=self::getUrl("Preordercampaign", "add")?>"><i class="fas fa-plus"></i> Neue Vorbestellkampagne anlegen</a>
|
||||
<?php if($me->is("Admin")): ?>
|
||||
<a class="btn btn-primary mb-2" href="<?=self::getUrl("Preordercampaign", "add")?>"><i class="fas fa-plus"></i> Neue Vorbestellkampagne anlegen</a>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
|
||||
<table class="table table-striped table-hover">
|
||||
@@ -102,15 +114,19 @@
|
||||
<a href="<?=self::getUrl("Preorder", "Index", ["filter" => ["preordercampaign_id" => $camp->id]])?>">
|
||||
<?=$camp->active_preorder_count?>
|
||||
<?php if($camp->homes_total): ?>
|
||||
/ <?=$camp->homes_total?> (<?=(round((count($camp->active_preorders) / $camp->homes_total) * 100, 2))?> %)
|
||||
/ <?=$camp->homes_total?> (<?=(round(($camp->active_preorder_count / $camp->homes_total) * 100, 2))?> %)
|
||||
<?php endif; ?>
|
||||
</a>
|
||||
</td>
|
||||
<td><?=date('d.m.Y',$camp->from)?></td>
|
||||
<td><?=date('d.m.Y',$camp->to)?></td>
|
||||
<td style="text-align: left; letter-spacing: 4px; font-size: 1.1em;">
|
||||
<a href="<?=self::getUrl("Preordercampaign", "edit", ["id" => $camp->id])?>"><i class="far fa-edit" title="Vorbestellkampagne Bearbeiten"></i></a>
|
||||
<a href="<?=self::getUrl("Preordercampaign", "delete", ["id" => $camp->id])?>" class="text-danger" onclick="if(!confirm('Vorbestellkampagne wirklich löschen?')) return false;" title="Vorbestellkampagne Löschen"><i class="fas fa-trash"></i></a>
|
||||
<a href="<?=self::getUrl("Preordercampaign", "downloadAddonServices", ["preordercampaign_id" => $camp->id])?>" title="Bestellte Zusatzdienste exportieren"><i class="far fa-sunset"></i></a>
|
||||
<a href="<?=self::getUrl("Preordernotification", "Index", ["filter" => ["preordercampaign_id" => $camp->id]])?>" title="Email Aussendungen"><i class="far fa-envelope"></i></a>
|
||||
<?php if($me->is("Admin")): ?>
|
||||
<a href="<?=self::getUrl("Preordercampaign", "edit", ["id" => $camp->id])?>"><i class="far fa-edit" title="Vorbestellkampagne Bearbeiten"></i></a>
|
||||
<a href="<?=self::getUrl("Preordercampaign", "delete", ["id" => $camp->id])?>" class="text-danger" onclick="if(!confirm('Vorbestellkampagne wirklich löschen?')) return false;" title="Vorbestellkampagne Löschen"><i class="fas fa-trash"></i></a>
|
||||
<?php endif; ?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
|
||||
8
Layout/default/Preordercampaign/services.csv.php
Normal file
8
Layout/default/Preordercampaign/services.csv.php
Normal file
@@ -0,0 +1,8 @@
|
||||
<?php
|
||||
header("Content-type: text/csv");
|
||||
header('Content-disposition: attachment; filename="preorder-services-'.$campaign->name.'-'.date("Y-m-d_H-m-s").'.csv"');
|
||||
?>
|
||||
Code;Gemeinde;PLZ;Ortschaft;Strasse;Hausnummer;Block;Stiege;Stock;Tuer;Adresszusatz;Adressinfo;Firma;UID;Vorname;Nachname;Kontakt Strasse;Kontakt PLZ;Kontakt Ort;Telefon;Email;Dienstleistung;Data
|
||||
<?php foreach($csv as $c):?>
|
||||
"<?=$c["ucode"]?>";"<?=$c["gemeinde"]?>";"<?=$c["plz"]?>";"<?=$c["ortschaft"]?>";"<?=$c["strasse"]?>";"<?=$c["hausnummer"]?>";"<?=$c["block"]?>";"<?=$c["stiege"]?>";"<?=$c["stock"]?>";"<?=$c["tuer"]?>";"<?=$c["zusatz"]?>";"<?=$c["address_info"]?>";"<?=$c["contact_company"]?>";"<?=$c["contact_uid"]?>";"<?=$c["contact_firstname"]?>";"<?=$c["contact_lastname"]?>";"<?=$c["contact_street"]?>";"<?=$c["contact_plz"]?>";"<?=$c["contact_ort"]?>";"<?=$c["phone"]?>";"<?=$c["email"]?>";"<?=$c["service"]?>";"<?=$c["service_data"]?>"
|
||||
<?php endforeach;
|
||||
368
Layout/default/Preordernotification/Form.php
Normal file
368
Layout/default/Preordernotification/Form.php
Normal file
@@ -0,0 +1,368 @@
|
||||
<?php include(realpath(dirname(__FILE__)."/../../$mfLayoutPackage")."/header.php"); ?>
|
||||
|
||||
<!-- start page title -->
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<div class="page-title-box">
|
||||
<div class="page-title-right">
|
||||
<ol class="breadcrumb m-0">
|
||||
<li class="breadcrumb-item"><a href="<?=self::getUrl("Dashboard")?>"><?=MFAPPNAME_SLUG?></a></li>
|
||||
<li class="breadcrumb-item"><a href="<?=self::getUrl("Preorder")?>">Vorbestellung</a></li>
|
||||
<li class="breadcrumb-item"><a href="<?=self::getUrl("Preordernotification")?>">Emailaussendungen</a></li>
|
||||
<li class="breadcrumb-item active"><?=($notification->id) ? "bearbeiten" : "Neu" ?></li>
|
||||
</ol>
|
||||
</div>
|
||||
<h4 class="page-title"><?=($notification->id) ? "Emailaussendung bearbeiten" : "Neue Emailaussendung" ?></h4>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- end page title -->
|
||||
|
||||
<div class="row">
|
||||
<div class="col-lg-12">
|
||||
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
|
||||
<form class="form-horizontal" method="post" action="<?=self::getUrl("Preordernotification", "save")?>" enctype="multipart/form-data">
|
||||
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
|
||||
<input type="hidden" name="id" value="<?=$notification->id?>" />
|
||||
<input type="hidden" name="preordercampaign_id" value="<?=$campaign->id?>" />
|
||||
|
||||
<h4>Absender</h4>
|
||||
|
||||
<div class="form-group row">
|
||||
<label class="col-lg-2 col-form-label" for="sender_name">Name *</label>
|
||||
<div class="col-lg-10">
|
||||
<input type="text" class="form-control" name="sender_name" id="sender_name" value="<?=($notification->sender_name) ? $notification->sender_name : $campaign->network->owner->getCompanyOrName()?>">
|
||||
<small>Wird beim Empfänger als Absender angezeigt</small>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group row">
|
||||
<label class="col-lg-2 col-form-label" for="sender_email">Emailadresse *</label>
|
||||
<div class="col-lg-10">
|
||||
<input type="text" class="form-control" name="sender_email" id="sender_email" value="<?=($notification->sender_email) ? $notification->sender_email : $campaign->network->owner->email?>">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group row">
|
||||
<label class="col-lg-2 col-form-label" for="sender_replyto">Antworten an (Reply-To):</label>
|
||||
<div class="col-lg-10">
|
||||
<input type="text" class="form-control" name="sender_replyto" id="sender_replyto" value="<?=$notification->sender_replyto?>">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<hr />
|
||||
|
||||
<h4 class="mt-4">Empfänger</h4>
|
||||
<p>Die Aussendung wird an die Kontaktemailadresse aller Bestellungen versendet. Wählen Sie folgende Konditionen aus, um die Empfänger zu beschränken:</p>
|
||||
|
||||
<div class="form-group row">
|
||||
<label class="col-lg-2 col-form-label" for="preordercamaign">Vorbestellkampagne</label>
|
||||
<div class="col-lg-10">
|
||||
<input type="text" class="form-control" name="preordercampaign" id="preordercampaign" value="<?=$campaign->name?>" disabled="disabled">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="form-group row">
|
||||
<label class="col-lg-2 col-form-label" for="type">Bestelltyp</label>
|
||||
<div class="col-lg-10">
|
||||
<select class="form-control select2" name="type[]" id="type" multiple="multiple">
|
||||
<option value="interest" <?=($notification && array_key_exists("type", $notification->filter) && in_array("interest", $notification->filter["type"])) ? "selected='selected'" : ""?>>Interessensbekundung</option>
|
||||
<option value="provision" <?=($notification && array_key_exists("type", $notification->filter) && in_array("provision", $notification->filter["type"])) ? "selected='selected'" : ""?>>Vorsorgeanschluss</option>
|
||||
<option value="order" <?=($notification && array_key_exists("type", $notification->filter) && in_array("order", $notification->filter["type"])) ? "selected='selected'" : ""?>>Vollanschluss</option>
|
||||
<option value="reorder" <?=($notification && array_key_exists("type", $notification->filter) && in_array("reorder", $notification->filter["type"])) ? "selected='selected'" : ""?>>Nachbestellung</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group row">
|
||||
<label class="col-lg-2 col-form-label" for="connection_type">Anschlusstyp</label>
|
||||
<div class="col-lg-10">
|
||||
<select class="form-control select2" name="connection_type[]" id="connection_type" multiple="multiple">
|
||||
<option value="single-dwelling" <?=($notification && array_key_exists("connection_type", $notification->filter) && in_array("single-dwelling", $notification->filter['connection_type'])) ? "selected='selected'" : ""?>>Einfamilienhaus</option>
|
||||
<option value="multi-dwelling" <?=($notification && array_key_exists("connection_type", $notification->filter) && in_array("multi-dwelling", $notification->filter['connection_type'])) ? "selected='selected'" : ""?>>Mehrfamilienhaus</option>
|
||||
<option value="apartment-building" <?=($notification && array_key_exists("connection_type", $notification->filter) && in_array("apartment-building", $notification->filter['connection_type'])) ? "selected='selected'" : ""?>>Mehrparteienhaus</option>
|
||||
<option value="apartment" <?=($notification && array_key_exists("connection_type", $notification->filter) && in_array("apartment", $notification->filter['connection_type'])) ? "selected='selected'" : ""?>>Wohneinheit in Mehrparteienhaus</option>
|
||||
<option value="business" <?=($notification && array_key_exists("connection_type", $notification->filter) && in_array("business", $notification->filter['connection_type'])) ? "selected='selected'" : ""?>>Gewerbebetrieb</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<!--div class="form-group row">
|
||||
<label class="col-lg-2 col-form-label" for="product_id">Vertriebspartner</label>
|
||||
<div class="col-lg-10">
|
||||
<select class="form-control select2" name="partner_id" id="partner_id" multiple="multiple">
|
||||
<option value=""></option>
|
||||
<?php foreach($partners as $partner): ?>
|
||||
<option value="<?=$partner->id?>" <?=($notification->id && $notification->partner_id == $partner->id) ? "selected='selected'" : ""?>><?=$partner->getCompanyOrName()?></option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
</div>
|
||||
</div-->
|
||||
|
||||
<hr />
|
||||
|
||||
|
||||
<h4 class="mt-4">Email</h4>
|
||||
|
||||
<p>Im folgenden Editor können Sie ein HTML-Email verfassen. Verwenden Sie das Menü und die Werkzeugleiste um den Text zu formatieren.</p>
|
||||
<div class="form-group row mt-3 col-12">
|
||||
<label class="form-label" for="subject">Betreff:</label>
|
||||
<input type="text" class="form-control" name="subject" id="subject" value="<?=$notification->subject?>" placeholder="Betreff" style="border-radius:0;" />
|
||||
</div>
|
||||
<textarea id="body_html" name="body_html" placeholder="Bitte geben Sie hier den Emailinhalt ein..." rows="12" style="width: 100%; height: 600px; padding: 10px;"><?= htmlentities($notification->body_html)?></textarea>
|
||||
|
||||
|
||||
<h4 class="mt-4">Dateianhänge</h4>
|
||||
<div class="form-group row mb-3">
|
||||
<div class="col-xl-5 input-grop">
|
||||
<div class="custom-file">
|
||||
<input type="file" name="attachment[]" id="attachment" class="custom-file-input" multiple="multiple" />
|
||||
<label class="custom-file-label" for="attachment"> Datei(en) auswählen</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php if(is_array($notification->files) && count($notification->files)): ?>
|
||||
<div class="row">
|
||||
<div class="col-4">
|
||||
<div class="card" style="">
|
||||
<ul class="list-group list-group-flush">
|
||||
<?php foreach($notification->files as $file): ?>
|
||||
<li id="file-<?=$file->id?>" class="list-group-item"><input type="hidden" name="deletefile[<?=$file->id?>]" id="deletefile-<?=$file->id?>" value="" /><a href="#" onclick="deleteFile(<?=$file->id?>)" class="mr-2"><i class="far fa-trash text-danger"></i></a> <span class="filename"><i class="far fa-file"></i> <?=$file->filename?></span></li>
|
||||
<?php endforeach; ?>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
|
||||
<h4>Versand</h4>
|
||||
<div class="form-group row">
|
||||
<label class="col-lg-2 col-form-label" for="tosend_day">Versandzeitpunkt</label>
|
||||
<div class="col-lg-2">
|
||||
<label>Datum</label>
|
||||
<input type="text" class="form-control" name="tosend_day" id="tosend_date" value="<?=($notification->tosend_date) ? date("d.m.Y", $notification->tosend_date) : ""?>" />
|
||||
<small>Emailversand wird zu diesem Zeitpunkt gestartet</small>
|
||||
</div>
|
||||
<div class="col-lg-2">
|
||||
<label>Uhrzeit</label>
|
||||
<select name="tosend_hour" class="form-control">
|
||||
<?php for($h = 0; $h < 24; $h++): ?>
|
||||
<option value="<?=$h?>" <?=($notification->tosend_date && date('H', $notification->tosend_date) == $h) ? "selected='selected'" : ""?>><?=str_pad($h, 2, "0", STR_PAD_LEFT)?>:00</option>
|
||||
<?php endfor; ?>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<hr />
|
||||
|
||||
<div class="form-group row">
|
||||
<label class="col-lg-2 col-form-label" for="testmail_to">Test Email versenden</label>
|
||||
<div class="col-lg-10">
|
||||
<div class="row">
|
||||
<div class="col-6">
|
||||
|
||||
<div class="input-group mb-3">
|
||||
<div class="input-group-prepend">
|
||||
<span class="input-group-text"><i class="fas fa-envelope"></i></span>
|
||||
</div>
|
||||
<input type="text" class="form-control" name="testmail_to" id="testmail_to" value="" placeholder="Testempfänger" />
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div class="col-6">
|
||||
<button type="submit" name="send_testmail" value="1" class="btn btn-outline-success"><i class="far fa-paper-plane"></i> Testmail jetzt abschicken</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<div class="form-group row">
|
||||
<label class="col-lg-2 col-form-label" for="note">Interne Notiz</label>
|
||||
<div class="col-lg-10">
|
||||
<textarea id="note" class="form-control" name="note" rows="5"><?=$notification->note?></textarea>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group row">
|
||||
<label class="col-lg-2"></label>
|
||||
<div class="col-lg-10">
|
||||
<button type="submit" name="return" value="form" class="btn btn-primary mr-1">Speichern</button>
|
||||
<button type="submit" name="return" value="index" class="btn btn-primary">Speichern und zur Übersicht</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<script type="text/javascript" src="<?=self::getResourcePath()?>plugins/tinymce/tinymce.min.js"></script>
|
||||
<script type="text/javascript" src="<?=self::getResourcePath()?>plugins/bs-custom-file-input/bs-custom-file-input.min.js"></script>
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
var menu_vars = [
|
||||
['vorname', "Vorname"],
|
||||
['nachname', "Nachname"],
|
||||
['firma', "Firma"],
|
||||
['firma_oder_name', "Firma oder Name"],
|
||||
['email', "Emailadresse"],
|
||||
['anschluss_oaid', "Anschluss OAID"],
|
||||
['anschluss_strasse', "Anschluss Straße"],
|
||||
['anschluss_hausnummer', "Anschluss Hausnummer"],
|
||||
['anschluss_plz', "Anschluss PLZ"],
|
||||
['anschluss_ort', "Anschluss Ort"],
|
||||
['anschluss_gemeinde', "Anschluss Gemeinde"],
|
||||
['preorder_code', "Bestellcode"],
|
||||
];
|
||||
|
||||
var menu_vars_items = "";
|
||||
menu_vars.forEach((item) => { menu_vars_items += " " + item[0]});
|
||||
menu_vars_items = menu_vars_items.trim();
|
||||
console.log(menu_vars_items);
|
||||
|
||||
$(function () {
|
||||
tinymce.init({
|
||||
//font_formats: "Arial=arial,sans-serif;",
|
||||
selector: '#body_html',
|
||||
language: 'de',
|
||||
skin: "tinymce-5",
|
||||
plugins: ' code link autolink lists table',
|
||||
paste_block_drop: true,
|
||||
paste_as_text: true,
|
||||
paste_data_images: false,
|
||||
promotion: false,
|
||||
toolbar1: 'undo redo | styles | bold italic underline strikethrough | fontfamily fontsize fontcolor | alignleft aligncenter alignright alignjustify | bullist numlist | outdent indent | table | link unlink | code',
|
||||
toolbar2: 'vorname nachname firma',
|
||||
content_css: "<?=self::getResourcePath()?>/assets/css/tinymce.css",
|
||||
font_family_formats: "Arial=arial,sans-serif; Courier New=courier new,courier,monospace; Georgia=georgia,palatino,serif; Helvetica=helvetica,sans-serif; Lucida Sans=lucida sans unicode,sans-serif; Tahoma=tahoma,arial,helvetica,sans-serif; Times New Roman=times new roman,times,serif",
|
||||
menubar: 'file edit view insert format tools table variables',
|
||||
menu: {
|
||||
variables: { title: 'Textbausteine', items: menu_vars_items }
|
||||
},
|
||||
setup: function (editor) {
|
||||
menu_vars.forEach(function(item) {
|
||||
editor.ui.registry.addMenuItem(item[0], {
|
||||
text: item[1],
|
||||
onAction: function () {
|
||||
editor.insertContent('{{' + item[0].toUpperCase() + '}}');
|
||||
}
|
||||
});
|
||||
});
|
||||
/*
|
||||
editor.ui.registry.addMenuItem('vorname', {
|
||||
text: 'Vorname',
|
||||
onAction: function () {
|
||||
editor.insertContent('{{VORNAME}}');
|
||||
}
|
||||
});
|
||||
editor.ui.registry.addMenuItem('nachname', {
|
||||
text: 'Nachname',
|
||||
onAction: function () {
|
||||
editor.insertContent('{{NACHNAME}}');
|
||||
}
|
||||
});
|
||||
editor.ui.registry.addMenuItem('firma', {
|
||||
text: 'Firma',
|
||||
onAction: function () {
|
||||
editor.insertContent('{{FIRMA}}');
|
||||
}
|
||||
});
|
||||
editor.ui.registry.addMenuItem('firmaodername', {
|
||||
text: 'Firma oder Name',
|
||||
onAction: function () {
|
||||
editor.insertContent('{{FIRMA_ODER_NAME}}');
|
||||
}
|
||||
});
|
||||
editor.ui.registry.addMenuItem('email', {
|
||||
text: 'Emailadresse',
|
||||
onAction: function () {
|
||||
editor.insertContent('{{EMAIL}}');
|
||||
}
|
||||
});*/
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
bsCustomFileInput.init();
|
||||
|
||||
/*$('#body_html').summernote({
|
||||
height: 400,
|
||||
lang: "de-DE",
|
||||
placeholder: "Bitte geben Sie hier den Emailtext ein...",
|
||||
toolbar: [
|
||||
['style', ['style']],
|
||||
['font', ['bold', 'underline', 'clear', 'fontname']],
|
||||
['fontsize', ['fontsize', 'fontsizeunit']],
|
||||
['color', ['color']],
|
||||
['para', ['ul', 'ol', 'paragraph', 'height']],
|
||||
['table', ['table']],
|
||||
['insert', ['link']],
|
||||
['view', ['fullscreen', 'codeview', 'help']]
|
||||
],
|
||||
fontNames: ["Arial", "Arial Black", "Courier New", "Georgia", "Helvetica", "Lucida Sans Unicode", "Tahoma", "Times New Roman"],
|
||||
|
||||
addDefaultFonts: false
|
||||
|
||||
});
|
||||
//$('#body_html').summernote('fontSizeUnit', "pt");
|
||||
//$('#body_html').summernote("fontSize", 12);*/
|
||||
|
||||
$('#tosend_date').datepicker({
|
||||
language: 'de',
|
||||
format: "dd.mm.yyyy",
|
||||
showWeekDays: true,
|
||||
todayBtn: 'linked',
|
||||
autoclose: true
|
||||
});
|
||||
|
||||
$(".select2").select2({
|
||||
allowClear: true,
|
||||
placeholder: ""
|
||||
});
|
||||
});
|
||||
|
||||
function deleteFile(id) {
|
||||
event.preventDefault();
|
||||
console.log($("#deletefile-" + id).val());
|
||||
if(!$("#deletefile-" + id).val()) {
|
||||
$('#file-' + id + " .filename").css("text-decoration", "line-through");
|
||||
$('#file-' + id + " .filename").css("color", "red");
|
||||
$("#deletefile-" + id).val("1");
|
||||
} else {
|
||||
$('#file-' + id + " .filename").removeAttr("style");
|
||||
$("#deletefile-" + id).val("");
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<?php include(realpath(dirname(__FILE__)."/../../$mfLayoutPackage")."/footer.php"); ?>
|
||||
123
Layout/default/Preordernotification/Index.php
Normal file
123
Layout/default/Preordernotification/Index.php
Normal file
@@ -0,0 +1,123 @@
|
||||
<?php include(realpath(dirname(__FILE__)."/../../$mfLayoutPackage")."/header.php"); ?>
|
||||
|
||||
<!-- start page title -->
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<div class="page-title-box">
|
||||
<div class="page-title-right">
|
||||
<ol class="breadcrumb m-0">
|
||||
<li class="breadcrumb-item"><a href="<?=self::getUrl("Dashboard")?>"><?=MFAPPNAME_SLUG?></a></li>
|
||||
<li class="breadcrumb-item"><a href="<?=self::getUrl("Preordercampaign")?>">Vorbestellkampagnen</a></li>
|
||||
<li class="breadcrumb-item active">Emailaussendungen</li>
|
||||
</ol>
|
||||
</div>
|
||||
<h4 class="page-title">Emailaussendungen</h4>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- end page title -->
|
||||
|
||||
<div class="row">
|
||||
<div class="col-lg-12">
|
||||
|
||||
<div class="card">
|
||||
<div class="card-body mb-3">
|
||||
<h4 class="header-title mb-3">Filter</h4>
|
||||
|
||||
<form method="get" action="<?=self::getUrl("Preordernotification")?>">
|
||||
<div class="row">
|
||||
|
||||
<div class="col-2">
|
||||
<label class="form-label" for="filter_preordercampaign_id">Kampagne</label>
|
||||
<select name="filter[preordercampaign_id]" id="filter_preordercampaign_id" class="form-control">
|
||||
<option value="">Alle</option>
|
||||
<?php foreach($my_campaigns as $c): ?>
|
||||
<option value="<?=$c->id?>" <?=(isset($campaign) && $c->id == $campaign->id) ? "selected='selected'" : ""?>><?=$c->name?></option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="col-1">
|
||||
<label class="form-label" for="filter_betreff">Betreff</label>
|
||||
<input type="text" class="form-control" name="filter[betreff]" id="filter_betreff" value="<?=$filter['betreff']?>" />
|
||||
</div>
|
||||
|
||||
<div class="col-2">
|
||||
<label class="form-label" for="filter_sent_date">Status</label>
|
||||
<select name="filter[sent_date]" id="filter_sent_date" class="form-control">
|
||||
<option value="open">Offen</option>
|
||||
<option value="sent">bereits versendet</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="row mt-2">
|
||||
<div class="col">
|
||||
<button type="submit" class="btn btn-primary">Filter anwenden</button>
|
||||
<a class="btn btn-secondary" href="<?=self::getUrl("Preordernotification")?>">Filter zurücksetzen</a>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="card">
|
||||
<div class="card-body mb-3">
|
||||
<div class="float-left">
|
||||
<h4 class="header-title">Liste offener Aussendungen</h4>
|
||||
</div>
|
||||
<div class="float-right">
|
||||
<?php if($filter['preordercampaign_id']): ?>
|
||||
<a class="btn btn-primary mb-2" href="<?=self::getUrl("Preordernotification", "add", ['preordercampaign_id' => $filter['preordercampaign_id']])?>"><i class="fas fa-plus"></i> Neue Aussendung erstellen</a>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
|
||||
<table class="table table-striped table-hover">
|
||||
<tr>
|
||||
<th class="text-center">Versendet</th>
|
||||
<th>Kampagne</th>
|
||||
<th>Betreff</th>
|
||||
<th>Anzahl Empfänger</th>
|
||||
<th>Geplanter Versand</th>
|
||||
<th>Bearbeitet</th>
|
||||
<th>Erstellt</th>
|
||||
<th></th>
|
||||
</tr>
|
||||
<?php foreach($notifications as $notification): ?>
|
||||
<tr>
|
||||
<td class="text-center">
|
||||
<?php if($notification->send_start && $notification->send_finish): ?>
|
||||
<i class='fas fa-check text-success' title='Versand erfolgreich abgeschlossen'></i>
|
||||
<?php elseif($notification->send_start && !$notification->send_finish): ?>
|
||||
<i class='fas fa-loader text-info' title='Versand gestartet'></i>
|
||||
<?php elseif(!$notification->send_start && !$notification->send_finish): ?>
|
||||
<i class='fas fa-remove text-danger' title='Noch nicht versendet'></i>
|
||||
<?php endif; ?>
|
||||
<?=($notification->sent_date) ? date('d.m.Y', $notification->sent_date) : ""?>
|
||||
</td>
|
||||
<td><?=$notification->campaign->name?></td>
|
||||
<td><?=$notification->subject?></td>
|
||||
<td title="Anzahl berechnet am <?=date('d.m.Y H:i', $notification->edit)?>"><?=($notification->recipient_count) ? $notification->recipient_count : ""?></td>
|
||||
<td><?=($notification->tosend_date) ? date('d.m.Y', $notification->tosend_date) : "" ?></td>
|
||||
<td><?=date("d.m.Y H:i",$notification->edit)?> (<?=$notification->editor->name?>)</td>
|
||||
<td><?=date("d.m.Y H:i",$notification->create)?> (<?=$notification->creator->name?>)</td>
|
||||
<td style="text-align: left; letter-spacing: 4px; font-size: 1.1em;">
|
||||
<?php if(!$notification->sent_date): ?>
|
||||
<a href="<?=self::getUrl("Preordernotification", "edit", ["id" => $notification->id])?>"><i class="far fa-edit" title="Aussendung bearbeiten"></i></a>
|
||||
<a href="<?=self::getUrl("Preordernotification", "delete", ["id" => $notification->id])?>" class="text-danger" onclick="if(!confirm('Aussendung wirklich löschen?')) return false;" title="Aussendung Löschen"><i class="fas fa-trash"></i></a>
|
||||
<?php endif; ?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php include(realpath(dirname(__FILE__)."/../../$mfLayoutPackage")."/footer.php"); ?>
|
||||
@@ -114,7 +114,7 @@
|
||||
<div class="col-lg-10">
|
||||
Name: <input type="text" class="form-control" name="producttech_new_name" id="producttech_new_name" value="<?=$producttech_new_name?>">
|
||||
Kundentyp: <select name="producttech_new_customer_type" class="form-control"><option value="residential">Residential</option><option value="business">Business</option></select>
|
||||
RTR Code: <input type="text" class="form-control" name="producttech_new_rtrcode" id="producttech_new_rtrcode" value="<?=$producttech_new_rtrcode?>">
|
||||
<!--RTR Code: <input type="text" class="form-control" name="producttech_new_rtrcode" id="producttech_new_rtrcode" value="<?=$producttech_new_rtrcode?>">-->
|
||||
Beschreibung: <textarea class="form-control" name="producttech_new_description" id="productgroup_new_description"><?=$producttech_new_description?></textarea>
|
||||
Interne Notiz: <textarea class="form-control" name="producttech_new_note" id="productgroup_new_note"><?=$producttech_new_note?></textarea>
|
||||
</div>
|
||||
|
||||
@@ -24,6 +24,81 @@
|
||||
<div class="row">
|
||||
<div class="col-lg-12">
|
||||
|
||||
<div class="card">
|
||||
<div class="card-body mb-3">
|
||||
<h4 class="header-title mb-3">Filter</h4>
|
||||
|
||||
<form method="get" action="<?=self::getUrl("Product")?>">
|
||||
<div class="row">
|
||||
|
||||
<div class="col-2">
|
||||
<label class="form-label" for="filter_network_id">Produktgruppen</label>
|
||||
<select name="filter[productgroup_id][]" id="filter_productgroup_id" class="form-control select2" multiple="multiple">
|
||||
<option></option>
|
||||
<?php foreach(ProductgroupModel::getAll() as $group): ?>
|
||||
<option value="<?=$group->id?>" <?=(is_array($filter) && array_key_exists('productgroup_id', $filter) && in_array($group->id, $filter['productgroup_id'])) ? "selected='selected'" : ""?>><?=$group->name?></option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="col-2">
|
||||
<label class="form-label" for="filter_producttech_id">Technologien</label>
|
||||
<select name="filter[producttech_id][]" id="filter_producttech_id" class="form-control select2" multiple="multiple">
|
||||
<option></option>
|
||||
<?php foreach(ProducttechModel::getAll() as $tech): ?>
|
||||
<option value="<?=$tech->id?>" <?=(is_array($filter) && array_key_exists('producttech_id', $filter) && in_array($tech->id, $filter['producttech_id'])) ? "selected='selected'" : ""?>><?=$tech->name?></option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="col-2">
|
||||
<label class="form-label" for="filter_sla_id">SLA</label>
|
||||
<select name="filter[sla_id]" id="filter_sla_id" class="form-control">
|
||||
<option></option>
|
||||
<?php foreach(SlaModel::getAll() as $sla): ?>
|
||||
<option value="<?=$sla->id?>" <?=(is_array($filter) && array_key_exists('sla_id', $filter) && $filter['sla_id'] == $sla->id) ? "selected='selected'" : ""?>><?=$sla->name?></option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="col-2">
|
||||
<label class="form-label" for="filter_name">Name</label>
|
||||
<input type="text" class="form-control" name="filter[name]" id="filter_name" value="<?=$filter['name']?>" />
|
||||
</div>
|
||||
|
||||
<div class="col-2">
|
||||
<label class="form-label" for="filter_customer_type">Kundentyp</label>
|
||||
<select name="filter[customer_type]" id="filter_customer_type" class="form-control">
|
||||
<option></option>
|
||||
<option value="business" <?=(is_array($filter) && array_key_exists('customer_type', $filter) && $filter['customer_type'] == "business") ? "selected='selected'" : ""?>>Business</option>
|
||||
<option value="residential" <?=(is_array($filter) && array_key_exists('customer_type', $filter) && $filter['customer_type'] == "residential") ? "selected='selected'" : ""?>>Residential</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="col-2">
|
||||
<label class="form-label" for="filter_external">Externe Produkte</label>
|
||||
<select name="filter[external]" id="filter_external" class="form-control">
|
||||
<option></option>
|
||||
<option value="1" <?=(is_array($filter) && array_key_exists('external', $filter) && $filter['external']) ? "selected='selected'" : ""?>>Anzeigen</option>
|
||||
<option value="0" <?=(is_array($filter) && array_key_exists('external', $filter) && !$filter['external']) ? "selected='selected'" : ""?>>Ausblenden</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div class="row mt-2">
|
||||
<div class="col">
|
||||
<button type="submit" class="btn btn-primary">Filter anwenden</button>
|
||||
<a class="btn btn-secondary" href="<?=self::getUrl("Product")?>">Filter zurücksetzen</a>
|
||||
</div>
|
||||
<!--<div class="col">
|
||||
<button class="btn btn-info" type="button" onclick="refreshMap()"><i class="far fa-map"></i> Auf Karte anzeigen</button>
|
||||
</div>-->
|
||||
</div>
|
||||
</form>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="card">
|
||||
<div class="card-body mb-3">
|
||||
<div class="float-left">
|
||||
@@ -34,8 +109,8 @@
|
||||
</div>
|
||||
|
||||
|
||||
<?php //include(realpath(dirname(__FILE__)."/../")."/tpl/pagination.php"); ?>
|
||||
<?php //include(realpath(dirname(__FILE__)."/../")."/tpl/pagination-summary.php"); ?>
|
||||
<?php include(realpath(dirname(__FILE__)."/../")."/tpl/pagination.php"); ?>
|
||||
<?php include(realpath(dirname(__FILE__)."/../")."/tpl/pagination-summary.php"); ?>
|
||||
|
||||
<table class="table table-striped table-hover">
|
||||
<tr>
|
||||
@@ -69,12 +144,17 @@
|
||||
<?php endforeach; ?>
|
||||
</table>
|
||||
|
||||
<?php //include(realpath(dirname(__FILE__)."/../")."/tpl/pagination-summary.php"); ?>
|
||||
<?php //include(realpath(dirname(__FILE__)."/../")."/tpl/pagination.php"); ?>
|
||||
<?php include(realpath(dirname(__FILE__)."/../")."/tpl/pagination-summary.php"); ?>
|
||||
<?php include(realpath(dirname(__FILE__)."/../")."/tpl/pagination.php"); ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script type="text/javascript">
|
||||
$("#filter_productgroup_id").select2({closeOnSelect: false});
|
||||
$("#filter_producttech_id").select2({closeOnSelect: false});
|
||||
</script>
|
||||
|
||||
<?php include(realpath(dirname(__FILE__)."/../../$mfLayoutPackage")."/footer.php"); ?>
|
||||
|
||||
78
Layout/default/Productgroup/Form.php
Normal file
78
Layout/default/Productgroup/Form.php
Normal file
@@ -0,0 +1,78 @@
|
||||
<?php include(realpath(dirname(__FILE__)."/../../$mfLayoutPackage")."/header.php"); ?>
|
||||
|
||||
<!-- start page title -->
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<div class="page-title-box">
|
||||
<div class="page-title-right">
|
||||
<ol class="breadcrumb m-0">
|
||||
<li class="breadcrumb-item"><a href="<?=self::getUrl("Dashboard")?>"><?=MFAPPNAME_SLUG?></a></li>
|
||||
<li class="breadcrumb-item"><a href="<?=self::getUrl("Network")?>">Produktgruppen</a></li>
|
||||
<li class="breadcrumb-item active"><?=($group->id) ? "bearbeiten" : "Neu" ?></li>
|
||||
</ol>
|
||||
</div>
|
||||
<h4 class="page-title">Productgruppen</h4>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- end page title -->
|
||||
|
||||
<div class="row">
|
||||
<div class="col-lg-12">
|
||||
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<h4 class="header-title mb-2"><?=($group->id) ? "Produktgruppe bearbeiten" : "Neue Produktgruppe"?></h4>
|
||||
|
||||
<form class="form-horizontal" method="post" action="<?=self::getUrl("Productgroup", "save")?>">
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
|
||||
<input type="hidden" name="id" value="<?=$group->id?>" />
|
||||
|
||||
<div class="form-group row">
|
||||
<label class="col-lg-2 col-form-label" for="name">Name</label>
|
||||
<div class="col-lg-10">
|
||||
<input type="text" class="form-control" name="name" id="name" value="<?=$group->name?>">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group row">
|
||||
<label class="col-lg-2 col-form-label" for="contractconfiggroups">Contractconfig Groups</label>
|
||||
<div class="col-lg-10">
|
||||
<select class="select2 form-control select2-multiple" name="contractconfiggroups[]" id="contractconfiggroups" multiple="multiple" data-placeholder="Choose ...">
|
||||
<?php foreach(ContractconfiggroupModel::getAll() as $ccgroup): ?>
|
||||
<option value="<?=$ccgroup->id?>" <?=(is_array($group->contractconfiggroups) && array_key_exists($ccgroup->id, $group->contractconfiggroups)) ? "selected='selected'" : ""?>><?=$ccgroup->name?></option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="form-group row">
|
||||
<label class="col-lg-2"></label>
|
||||
<div class="col-lg-10">
|
||||
<button type="submit" class="btn btn-primary">Speichern</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script type="text/javascript">
|
||||
$("#contractconfiggroups").select2({
|
||||
allowClear: true,
|
||||
placeholder: "",
|
||||
closeOnSelect: false
|
||||
});
|
||||
</script>
|
||||
<?php include(realpath(dirname(__FILE__)."/../../$mfLayoutPackage")."/footer.php"); ?>
|
||||
68
Layout/default/Productgroup/Index.php
Normal file
68
Layout/default/Productgroup/Index.php
Normal file
@@ -0,0 +1,68 @@
|
||||
<?php
|
||||
$pagination_baseurl = $this->getUrl($Mod,"Index");
|
||||
$pagination_baseurl_params = ["filter" => $filter];
|
||||
$pagination_entity_name = "Produktgruppen";
|
||||
?>
|
||||
<?php include(realpath(dirname(__FILE__)."/../../$mfLayoutPackage")."/header.php"); ?>
|
||||
|
||||
<!-- start page title -->
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<div class="page-title-box">
|
||||
<div class="page-title-right">
|
||||
<ol class="breadcrumb m-0">
|
||||
<li class="breadcrumb-item"><a href="<?=self::getUrl("Dashboard")?>"><?=MFAPPNAME_SLUG?></a></li>
|
||||
<li class="breadcrumb-item active">Produkte</li>
|
||||
</ol>
|
||||
</div>
|
||||
<h4 class="page-title">Produkte</h4>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- end page title -->
|
||||
|
||||
<div class="row">
|
||||
<div class="col-lg-12">
|
||||
|
||||
<div class="card">
|
||||
<div class="card-body mb-3">
|
||||
<div class="float-left">
|
||||
<h4 class="header-title">Liste aller Produktgruppen</h4>
|
||||
</div>
|
||||
<div class="float-right">
|
||||
<a class="btn btn-primary mb-2" href="<?=self::getUrl("Productgroup", "add")?>"><i class="fas fa-plus"></i> Neue Produktgruppe erstellen</a>
|
||||
</div>
|
||||
|
||||
|
||||
<?php include(realpath(dirname(__FILE__)."/../")."/tpl/pagination.php"); ?>
|
||||
<?php include(realpath(dirname(__FILE__)."/../")."/tpl/pagination-summary.php"); ?>
|
||||
|
||||
<table class="table table-striped table-hover">
|
||||
<tr>
|
||||
<th>Produktgruppe</th>
|
||||
<th>Beschreibung</th>
|
||||
<th>Anzahl Produkte</th>
|
||||
<th></th>
|
||||
</tr>
|
||||
<?php foreach($productgroups as $group): ?>
|
||||
<tr>
|
||||
<td><?=$group->name?></td>
|
||||
<td><?=$group->description?></td>
|
||||
<td><a href="<?=self::getUrl("Product","Index", ['filter' => ['productgroup_id' => [$group->id]]])?>"><?=(is_array($group->products)) ? count($group->products) : "0"?></a></td>
|
||||
<td style="text-align: left; letter-spacing: 4px; font-size: 1.1em;">
|
||||
<a href="<?=self::getUrl("Productgroup", "edit", ["id" => $group->id])?>"><i class="far fa-edit" title="Produktgruppe Bearbeiten"></i></a>
|
||||
<a href="<?=self::getUrl("Productgroup", "delete", ["id" => $group->id])?>" class="text-danger" onclick="if(!confirm('Produktgruppe wirklich löschen?')) return false;" title="Produktgruppe Löschen"><i class="fas fa-trash"></i></a>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
</table>
|
||||
|
||||
<?php include(realpath(dirname(__FILE__)."/../")."/tpl/pagination-summary.php"); ?>
|
||||
<?php include(realpath(dirname(__FILE__)."/../")."/tpl/pagination.php"); ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php include(realpath(dirname(__FILE__)."/../../$mfLayoutPackage")."/footer.php"); ?>
|
||||
@@ -11,14 +11,29 @@ if(preg_match('/^(.+)-1R$/', $color_name, $cmatch)) {
|
||||
<select class="form-control selectpicker show-tick" name="wfitem_<?=$item->name?>" id="wfitem_<?=$item->name?>_<?=$$wftype->id?>" title="Farbe wählen" data-style="btn-outline-<?=$color_name?>">
|
||||
<option></option>
|
||||
<?php foreach(TT_CABLE_COLORS as $name => $color): ?>
|
||||
<option
|
||||
style="background-color: rgba(<?=$color["r"]?>,<?=$color["g"]?>,<?=$color["b"]?>, .5); color: #<?=$color["hexfg"]?>"
|
||||
value="<?=$name?>"
|
||||
data-bg-color="#<?=$color["hex"]?>" <?=($color['mark']) ? "data-icon='fa-ellipsis-h'" : ""?>
|
||||
<?=($name == $item->value->value_string) ? "selected='selected'" : ""?>
|
||||
>
|
||||
<?=ucfirst($name)?>
|
||||
</option>
|
||||
<?php if($color['two-color']): ?>
|
||||
<option
|
||||
style="color: #<?=$color["hexfg"]?>;
|
||||
background: rgb(<?=$color["r"]?>,<?=$color["g"]?>,<?=$color["b"]?>);
|
||||
background: linear-gradient(90deg, rgba(<?=$color["r"]?>,<?=$color["g"]?>,<?=$color["b"]?>,.5) 0%, rgba(<?=$color["r"]?>,<?=$color["g"]?>,<?=$color["b"]?>,.5) 50%, rgba(<?=$color["r2"]?>,<?=$color["g2"]?>,<?=$color["b2"]?>,.5) 50%, rgba(<?=$color["r2"]?>,<?=$color["g2"]?>,<?=$color["b2"]?>,.5) 100%);
|
||||
text-shadow: 1px 1px 2px #<?=$color["hex"]?>;
|
||||
|
||||
"
|
||||
value="<?=$name?>"
|
||||
data-bg-color="#<?=$color["hex"]?>" <?=($color['mark']) ? "data-icon='fa-ellipsis-h'" : ""?>
|
||||
<?=($name == $item->value->value_string) ? "selected='selected'" : ""?>
|
||||
>
|
||||
<?=ucfirst($name)?>
|
||||
</option>
|
||||
<?php else: ?>
|
||||
<option
|
||||
style="background-color: rgba(<?=$color["r"]?>,<?=$color["g"]?>,<?=$color["b"]?>, .5); color: #<?=$color["hexfg"]?>"
|
||||
value="<?=$name?>"
|
||||
data-bg-color="#<?=$color["hex"]?>" <?=($color['mark']) ? "data-icon='fa-ellipsis-h'" : ""?>
|
||||
<?=($name == $item->value->value_string) ? "selected='selected'" : ""?>
|
||||
>
|
||||
<?=ucfirst($name)?>
|
||||
<?php endif; ?>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
|
||||
|
||||
@@ -19,7 +19,8 @@
|
||||
<script type="text/javascript">
|
||||
$(".selectpicker").selectpicker({
|
||||
iconBase: "fas",
|
||||
tickIcon: "check"
|
||||
tickIcon: "check",
|
||||
sanitize: false
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
<script type="text/javascript" src="<?=self::getResourcePath()?>js/bootstrap-datepicker.de.min.js"></script>
|
||||
<script type="text/javascript" src="<?=self::getResourcePath()?>assets/js/geo/geo.js"></script>
|
||||
<script type="text/javascript" src="<?=self::getResourcePath()?>assets/js/leaflet.js"></script>
|
||||
<script type="text/javascript" src="<?=self::getResourcePath()?>assets/js/leaflet.MakiMarkers.js"></script>
|
||||
<script type="text/javascript" src="<?=self::getResourcePath()?>js/popper.min.js"></script>
|
||||
<script type="text/javascript" src="<?=self::getResourcePath()?>js/bootstrap.min.js"></script>
|
||||
<script type="text/javascript" src="<?=self::getResourcePath()?>assets/js/bootstrap-select.min.js"></script>
|
||||
|
||||
@@ -18,27 +18,36 @@
|
||||
<li><a href="<?=self::getUrl("News")?>"><i class="far fa-th-list text-info"></i> News</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if($me->is(["Admin", "netowner"])): ?>
|
||||
<li class="has-submenu">
|
||||
<a href="#">
|
||||
<i class="far fa-database"></i>Stammdaten <div class="arrow-down"></div>
|
||||
</a>
|
||||
<ul class="submenu">
|
||||
<li class="has-sub-submenu">
|
||||
<a href="<?=self::getUrl("Address")?>"><i class="fad fa-user text-info"></i> Personen & Firmen</a>
|
||||
<!--<ul class="sub-submenu">
|
||||
<li><a href="<?=self::getUrl("Address", "Index" , ["filter" => ["addresstype" => ["employee"]]])?>"><i class="fas fa-"></i> Mitarbeiter</a></li>
|
||||
<li><a href="<?=self::getUrl("Address", "Index" , ["filter" => ["addresstype" => ["supplier"]]])?>"><i class="fas fa-"></i> Lieferanten</a></li>
|
||||
</ul>-->
|
||||
</li>
|
||||
<?php if($me->is(["Admin"])): ?>
|
||||
<li class="has-sub-submenu font-weight-bold"><a>Betriebsstammdaten</a></li>
|
||||
<li><a href="<?=self::getUrl("Address")?>"><i class="fad fa-user text-info"></i> Personen & Firmen</a></li>
|
||||
<li><a href="<?=self::getUrl("Product")?>"><i class="far fa-rectangle-list text-info"></i> Produkte</a></li>
|
||||
<li><a href="<?=self::getUrl("Producttech")?>"><i class="fad fa-microchip text-info"></i> Technologien</a></li>
|
||||
<li><a href="<?=self::getUrl("User")?>"><i class="fad fa-users text-info"></i> Benutzer</a></li>
|
||||
<li><a href="<?=self::getUrl("Productgroup")?>"><i class="far fa-list-tree text-info"></i> Produktgruppen</a></li>
|
||||
|
||||
<li><a href="<?=self::getUrl("Network")?>"><i class="fad fa-network-wired text-info"></i> Netzgebiete</a></li>
|
||||
<li class="has-sub-submenu"><a href="<?=self::getUrl("Pop")?>"><i class="fad fa-house text-info"></i> Pops</a></li>
|
||||
<li class="has-sub-submenu"><a href="<?=self::getUrl("User")?>"><i class="fad fa-users text-info"></i> Benutzer</a></li>
|
||||
<li ><a href="<?=self::getUrl("Pop")?>"><i class="fad fa-house text-info"></i> Pops</a></li>
|
||||
<li ><a href="<?=self::getUrl("Devicemanufactor")?>"><i class="fad fa-router text-info"></i> Geräte Hersteller</a></li>
|
||||
<li><a href="<?=self::getUrl("Devicetype")?>"><i class="fad fa-router text-info"></i> Geräte Typen</a></li>
|
||||
<li><a href="<?=self::getUrl("Device")?>"><i class="fad fa-router text-info"></i> Devices</a></li>
|
||||
<li><a href="<?=self::getUrl("Device")?>"><i class="fad fa-router text-info"></i> Devices</a></li>
|
||||
<li class="has-sub-submenu font-weight-bold mt-1"><a>Grundstammdaten</a></li>
|
||||
<?php endif; ?>
|
||||
<?php if($me->is(["Admin", "netowner"])): ?>
|
||||
<li><a href="<?=self::getUrl("AddressDB")?>"><i class="fas fa-city text-info"></i> GWR / AddressDB</a></li>
|
||||
<?php endif; ?>
|
||||
<?php if($me->is(["Admin"])): ?>
|
||||
<li><a href="<?=self::getUrl("Producttech")?>"><i class="fad fa-microchip text-info"></i> Technologien</a></li>
|
||||
<!--<li><a href="<?=self::getUrl("Contractconfig")?>"><i class="fad fa-gear text-info"></i> ContractConfig</a></li>-->
|
||||
<?php endif; ?>
|
||||
|
||||
</ul>
|
||||
</li>
|
||||
<?php endif; ?>
|
||||
@@ -81,17 +90,18 @@
|
||||
</ul>
|
||||
</li>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if($me->is(["Admin","salespartner"])): ?>
|
||||
<?php if($me->is(["Admin","netowner","salespartner"])): ?>
|
||||
<li class="has-submenu">
|
||||
<a href="#">
|
||||
<i class="fal fa-money-bill-wave"></i>Verkauf <div class="arrow-down"></div>
|
||||
</a>
|
||||
<ul class="submenu">
|
||||
<?php if($me->is(["Admin"])): ?>
|
||||
<?php if($me->is(["Admin","netowner","salespartner"])): ?>
|
||||
<li><a href="<?=self::getUrl("Preordercampaign")?>"><i class="far fa-calendar-lines text-info"></i> Vorbestellung</a></li>
|
||||
<?php endif; ?>
|
||||
<li><a href="<?=self::getUrl("Order")?>"><i class="far fa-file-signature text-info"></i> Bestellungen</a></li>
|
||||
<?php if($me->is(["Admin","salespartner"])): ?>
|
||||
<li><a href="<?=self::getUrl("Order")?>"><i class="far fa-file-signature text-info"></i> Bestellungen</a></li>
|
||||
<?php endif; ?>
|
||||
</ul>
|
||||
</li>
|
||||
<?php endif; ?>
|
||||
@@ -104,7 +114,7 @@
|
||||
<ul class="submenu">
|
||||
<li><a href="<?=self::getUrl("Contract")?>"><i class="fas fa-file-contract"></i> Verträge</a></li>
|
||||
<li><hr /></li>
|
||||
<li><a href="<?=self::getUrl("Contractconfig")?>"><i class="fas fa-wrench"></i> Vertragsconfig</a></li>
|
||||
<li><a href="<?=self::getUrl("Contractconfiggroup")?>"><i class="fas fa-wrench"></i> Vertragsconfig</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<?php endif; ?>
|
||||
|
||||
@@ -53,7 +53,7 @@ if($mfPagination_pagecount < 12) {
|
||||
$mfPagination_baseurl_params['s'] = $i * $pagination['count'];
|
||||
|
||||
if(($i == 0 || $i == $mfPagination_pagecount) || ($i >= $show_from && $i <= $show_to)) {
|
||||
$log->debug("show_from: $show_from, show_to: $show_to");
|
||||
//$log->debug("show_from: $show_from, show_to: $show_to");
|
||||
|
||||
$page = [
|
||||
's' => $i * $pagination['count'],
|
||||
|
||||
@@ -2,14 +2,13 @@
|
||||
|
||||
class ADBGemeinde extends mfBaseModel {
|
||||
public $plzs = [];
|
||||
|
||||
private $ortschaften = [];
|
||||
|
||||
protected function init() {
|
||||
$this->db = FronkDB::singleton(ADDRESSDB_DBHOST, ADDRESSDB_DBUSER, ADDRESSDB_DBPASS, ADDRESSDB_DBNAME);
|
||||
$this->table = "Gemeinde";
|
||||
}
|
||||
|
||||
|
||||
public function loadByGemeindeCode($code) {
|
||||
$res = $this->db->select("Gemeinde","*","code=$code");
|
||||
if($this->db->num_rows($res)) {
|
||||
@@ -66,4 +65,35 @@ class ADBGemeinde extends mfBaseModel {
|
||||
}
|
||||
return $list;
|
||||
}
|
||||
|
||||
public function getProperty($name) {
|
||||
if($this->$name == null) {
|
||||
|
||||
if(!$this->id) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if($name == "types") {
|
||||
$this->loadAddresstypes();
|
||||
return $this->types;
|
||||
}
|
||||
|
||||
if($name == "ortschaften") {
|
||||
$this->ortschaften = ADBOrtschaftModel::search(["gemeinde_id" => $this->id]);
|
||||
return $this->ortschaften;
|
||||
}
|
||||
|
||||
$classname = ucfirst($name);
|
||||
$idfield = $name."_id";
|
||||
$this->$name = new $classname($this->$idfield);
|
||||
|
||||
if($this->$name->id) {
|
||||
return $this->$name;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
return $this->$name;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,7 +40,16 @@ class ADBGemeindeModel {
|
||||
$db = FronkDB::singleton(ADDRESSDB_DBHOST, ADDRESSDB_DBUSER, ADDRESSDB_DBPASS, ADDRESSDB_DBNAME);
|
||||
|
||||
$where = self::getSqlFilter($filter);
|
||||
$res = $db->select("Gemeinde", "*", "$where ORDER BY name,code,kennziffer LIMIT 1");
|
||||
$sql = "SELECT Gemeinde.* FROM Gemeinde
|
||||
LEFT JOIN Plz ON (Plz.gemeinde_id = Gemeinde.id)
|
||||
LEFT JOIN GemeindeNetzgebiet ON (GemeindeNetzgebiet.gemeinde_id = Gemeinde.id)
|
||||
LEFT JOIN Netzgebiet ON (GemeindeNetzgebiet.netzgebiet_id = Netzgebiet.id)
|
||||
LEFT JOIN Ortschaft ON (Ortschaft.gemeinde_id = Gemeinde.id)
|
||||
WHERE $where
|
||||
GROUP BY Gemeinde.id
|
||||
ORDER BY name,code,kennziffer
|
||||
LIMIT 1";
|
||||
$res = $db->query($sql);
|
||||
if($db->num_rows($res)) {
|
||||
$data = $db->fetch_object($res);
|
||||
$item = new ADBGemeinde($data);
|
||||
@@ -94,6 +103,7 @@ class ADBGemeindeModel {
|
||||
LEFT JOIN Plz ON (Plz.gemeinde_id = Gemeinde.id)
|
||||
LEFT JOIN GemeindeNetzgebiet ON (GemeindeNetzgebiet.gemeinde_id = Gemeinde.id)
|
||||
LEFT JOIN Netzgebiet ON (GemeindeNetzgebiet.netzgebiet_id = Netzgebiet.id)
|
||||
LEFT JOIN Ortschaft ON (Ortschaft.gemeinde_id = Gemeinde.id)
|
||||
WHERE $where
|
||||
GROUP BY Gemeinde.id
|
||||
ORDER BY name,code,kennziffer";
|
||||
@@ -126,6 +136,15 @@ class ADBGemeindeModel {
|
||||
$where .= " AND Netzgebiet.id=$netzgebiet_id";
|
||||
} elseif(is_array($netzgebiet_id) && count($netzgebiet_id)) {
|
||||
$where .= " AND Netzgebiet.id IN (". implode(",", $netzgebiet_id).")";
|
||||
} elseif($netzgebiet_id === null) {
|
||||
$where .= " AND Netzgebiet.id IS NULL";
|
||||
}
|
||||
}
|
||||
|
||||
if(array_key_exists("netzgebiet_extref", $filter)) {
|
||||
$netzgebiet_extref = FronkDB::singleton()->escape($filter['netzgebiet_extref']);
|
||||
if($netzgebiet_extref) {
|
||||
$where .= " AND Netzgebiet.extref = '$netzgebiet_extref'";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -157,7 +176,7 @@ class ADBGemeindeModel {
|
||||
if(array_key_exists("name%", $filter)) {
|
||||
$name = FronkDB::singleton()->escape($filter['name%']);
|
||||
if($name) {
|
||||
$where .= " AND Gemeinde.`name` like '%$name%'";
|
||||
$where .= " AND Gemeinde.`name` like '$name%'";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -171,7 +190,21 @@ class ADBGemeindeModel {
|
||||
if(array_key_exists("plz%", $filter)) {
|
||||
$plz = FronkDB::singleton()->escape($filter['plz%']);
|
||||
if($plz) {
|
||||
$where .= " AND Plz.plzstring like '%$plz%'";
|
||||
$where .= " AND Plz.plzstring like '$plz%'";
|
||||
}
|
||||
}
|
||||
|
||||
if(array_key_exists("ortschaft", $filter)) {
|
||||
$ortschaft = FronkDB::singleton()->escape($filter['ortschaft']);
|
||||
if($ortschaft) {
|
||||
$where .= " AND Plz.ortschaft = '$ortschaft'";
|
||||
}
|
||||
}
|
||||
|
||||
if(array_key_exists("ortschaft%", $filter)) {
|
||||
$ortschaft = FronkDB::singleton()->escape($filter['ortschaft%']);
|
||||
if($ortschaft) {
|
||||
$where .= " AND Plz.ortschaft like '$ortschaft%'";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,9 +1,12 @@
|
||||
<?php
|
||||
|
||||
class ADBHausnummer extends mfBaseModel {
|
||||
private $netzgebiet;
|
||||
private $ortschaft;
|
||||
private $strasse;
|
||||
private $plz;
|
||||
private $freigaben = [];
|
||||
private $wohneinheiten = [];
|
||||
|
||||
protected function init() {
|
||||
$this->db = FronkDB::singleton(ADDRESSDB_DBHOST, ADDRESSDB_DBUSER, ADDRESSDB_DBPASS, ADDRESSDB_DBNAME);
|
||||
@@ -36,23 +39,87 @@ class ADBHausnummer extends mfBaseModel {
|
||||
return $data;
|
||||
}*/
|
||||
|
||||
public function getNewOAID() {
|
||||
if(!$this->plz_id) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$cc = "AT";
|
||||
$zip = $this->getProperty("plz")->plz;
|
||||
|
||||
for($try = 16; $try > 0; $try--) {
|
||||
$rnd[0] = random_int(0, 255);
|
||||
$rnd[1] = random_int(0, 255);
|
||||
$rnd[2] = random_int(0, 255);
|
||||
$rnd[3] = random_int(0, 255);
|
||||
|
||||
$code = "$cc-$zip-";
|
||||
foreach($rnd as $r) {
|
||||
$code .= str_pad(dechex($r), 2, "0", STR_PAD_LEFT);
|
||||
}
|
||||
|
||||
if(ADBHausnummerModel::search(['oaid' => $code])) {
|
||||
$this->log->warn(__FILE__."::getNewObjectCode: New Code already in use. Trying again for a maximum of $try times.");
|
||||
} else {
|
||||
// code is unique
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if($try == 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $code;
|
||||
}
|
||||
|
||||
public function getProperty($name) {
|
||||
if($this->$name == null) {
|
||||
|
||||
if($name == "freigaben") {
|
||||
$this->freigaben = explode(",", $this->freigabe);
|
||||
$this->freigaben = json_decode($this->freigabe);
|
||||
if(!is_array($this->freigaben)) {
|
||||
$this->freigaben = [];
|
||||
}
|
||||
return $this->freigaben;
|
||||
}
|
||||
|
||||
if($name == "netzgebiet") {
|
||||
$this->netzgebiet = new ADBNetzgebiet($this->netzgebiet_id);
|
||||
return $this->netzgebiet;
|
||||
}
|
||||
|
||||
if($name == "ortschaft") {
|
||||
$this->ortschaft = new ADBOrtschaft($this->ortschaft_id);
|
||||
return $this->ortschaft;
|
||||
}
|
||||
|
||||
if($name == "strasse") {
|
||||
$this->strasse = new ADBStrasse($this->strasse_id);
|
||||
return $this->strasse;
|
||||
}
|
||||
|
||||
if($name == "plz") {
|
||||
$this->plz = new ADBPlz($this->plz_id);
|
||||
$this->plz = mfValuecache::singleton()->get("adbplz-".$this->plz_id);
|
||||
if($this->plz === null) {
|
||||
$this->plz = new ADBPlz($this->plz_id);
|
||||
if($this->plz->id) {
|
||||
mfValuecache::singleton()->set("adplz-".$this->plz_id, $this->plz);
|
||||
}
|
||||
}
|
||||
return $this->plz;
|
||||
}
|
||||
|
||||
if($name == "wohneinheiten") {
|
||||
$this->wohneinheiten = mfValuecache::singleton()->get("adbWohneinheiten-hausnummer-".$this->id);
|
||||
if($this->wohneinheiten === null) {
|
||||
$this->wohneinheiten = ADBWohneinheitModel::search(['hausnummer_id' => $this->id]);
|
||||
if($this->wohneinheiten) {
|
||||
mfValuecache::singleton()->set("adbWohneinheiten-hausnummer-".$this->id, $this->wohneinheiten);
|
||||
}
|
||||
}
|
||||
return $this->wohneinheiten;
|
||||
}
|
||||
|
||||
$classname = ucfirst($name);
|
||||
$idfield = $name."_id";
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
<?php
|
||||
|
||||
class ADBHausnummerModel {
|
||||
public $oaid;
|
||||
public $adrcd;
|
||||
public $netzgebiet_id;
|
||||
public $extref;
|
||||
public $ortschaft_id;
|
||||
@@ -8,12 +10,20 @@ class ADBHausnummerModel {
|
||||
public $strasse_id;
|
||||
public $hausnummer;
|
||||
public $zusatz;
|
||||
public $grund_nr;
|
||||
public $unit_count;
|
||||
public $gps_lat;
|
||||
public $gps_long;
|
||||
public $rollout;
|
||||
public $rollout_info;
|
||||
public $freigabe;
|
||||
public $manual_add;
|
||||
public $manual_add_by;
|
||||
public $manual_add_info;
|
||||
public $manual_update;
|
||||
public $manual_update_by;
|
||||
public $manual_update_info;
|
||||
|
||||
public $create_by = null;
|
||||
public $edit_by = null;
|
||||
public $create = null;
|
||||
public $edit = null;
|
||||
|
||||
@@ -47,7 +57,17 @@ class ADBHausnummerModel {
|
||||
$db = FronkDB::singleton(ADDRESSDB_DBHOST, ADDRESSDB_DBUSER, ADDRESSDB_DBPASS, ADDRESSDB_DBNAME);
|
||||
|
||||
$where = self::getSqlFilter($filter);
|
||||
mfLoghandler::singleton()->debug($where);
|
||||
|
||||
$sql = "SELECT Hausnummer.* FROM Hausnummer
|
||||
LEFT JOIN Ortschaft ON (Ortschaft.id = Hausnummer.ortschaft_id)
|
||||
LEFT JOIN Gemeinde ON (Gemeinde.id = Ortschaft.gemeinde_id)
|
||||
LEFT JOIN Strasse ON (Hausnummer.strasse_id = Strasse.id)
|
||||
LEFT JOIN Plz ON (Hausnummer.plz_id = Plz.id)
|
||||
WHERE $where
|
||||
ORDER BY netzgebiet_id,Gemeinde.id,ortschaft_id,strasse_id,LENGTH(hausnummer), hausnummer
|
||||
LIMIT 1";
|
||||
|
||||
//mfLoghandler::singleton()->debug($where);
|
||||
$res = $db->select("Hausnummer", "*", "$where ORDER BY strasse_id,hausnummer LIMIT 1");
|
||||
if($db->num_rows($res)) {
|
||||
$data = $db->fetch_object($res);
|
||||
@@ -82,8 +102,13 @@ class ADBHausnummerModel {
|
||||
|
||||
$where = self::getSqlFilter($filter);
|
||||
$sql = "SELECT COUNT(*) as cnt FROM Hausnummer
|
||||
LEFT JOIN Ortschaft ON (Ortschaft.id = Hausnummer.ortschaft_id)
|
||||
LEFT JOIN Gemeinde ON (Gemeinde.id = Ortschaft.gemeinde_id)
|
||||
LEFT JOIN Strasse ON (Hausnummer.strasse_id = Strasse.id)
|
||||
LEFT JOIN Plz ON (Hausnummer.plz_id = Plz.id)
|
||||
WHERE $where
|
||||
";
|
||||
";
|
||||
|
||||
|
||||
$res = $db->query($sql);
|
||||
if($db->num_rows($res)) {
|
||||
@@ -93,14 +118,18 @@ class ADBHausnummerModel {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static function search($filter, $limit = false) {
|
||||
public static function search($filter, $limit = false, $returnDBRessource = false) {
|
||||
$items = [];
|
||||
$db = FronkDB::singleton(ADDRESSDB_DBHOST, ADDRESSDB_DBUSER, ADDRESSDB_DBPASS, ADDRESSDB_DBNAME);
|
||||
|
||||
$where = self::getSqlFilter($filter);
|
||||
$sql = "SELECT Hausnummer.* FROM Hausnummer
|
||||
LEFT JOIN Ortschaft ON (Ortschaft.id = Hausnummer.ortschaft_id)
|
||||
LEFT JOIN Gemeinde ON (Gemeinde.id = Ortschaft.gemeinde_id)
|
||||
LEFT JOIN Strasse ON (Hausnummer.strasse_id = Strasse.id)
|
||||
LEFT JOIN Plz ON (Hausnummer.plz_id = Plz.id)
|
||||
WHERE $where
|
||||
ORDER BY strasse_id,hausnummer";
|
||||
ORDER BY netzgebiet_id,Gemeinde.id,ortschaft_id,strasse_id,LENGTH(hausnummer), hausnummer";
|
||||
|
||||
mfLoghandler::singleton()->debug($sql);
|
||||
if(is_array($limit) && count($limit)) {
|
||||
@@ -111,8 +140,16 @@ class ADBHausnummerModel {
|
||||
}
|
||||
}
|
||||
|
||||
mfLoghandler::singleton()->debug($sql);
|
||||
|
||||
$res = $db->query($sql);
|
||||
if($db->num_rows($res)) {
|
||||
|
||||
// hack for AddressDBController::exportAction
|
||||
if($returnDBRessource) {
|
||||
return $res;
|
||||
}
|
||||
|
||||
while($data = $db->fetch_object($res)) {
|
||||
$items[] = new ADBHausnummer($data);
|
||||
}
|
||||
@@ -123,6 +160,36 @@ class ADBHausnummerModel {
|
||||
private static function getSqlFilter($filter) {
|
||||
$where = "1=1 ";
|
||||
|
||||
if(array_key_exists("adrcd", $filter)) {
|
||||
$adrcd = FronkDB::singleton()->escape($filter['adrcd']);
|
||||
if($adrcd) {
|
||||
$where .= " AND Hausnummer.`adrcd` = '$adrcd'";
|
||||
}
|
||||
}
|
||||
|
||||
if(array_key_exists("adrcd%", $filter)) {
|
||||
$adrcd = FronkDB::singleton()->escape($filter['adrcd%']);
|
||||
if($adrcd) {
|
||||
$where .= " AND Hausnummer.`adrcd` like '$adrcd%'";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if(array_key_exists("oaid", $filter)) {
|
||||
$oaid = FronkDB::singleton()->escape($filter['oaid']);
|
||||
if($oaid) {
|
||||
$where .= " AND Hausnummer.`oaid` = '$oaid'";
|
||||
}
|
||||
}
|
||||
|
||||
if(array_key_exists("oaid%", $filter)) {
|
||||
$oaid = FronkDB::singleton()->escape($filter['oaid%']);
|
||||
if($oaid) {
|
||||
$where .= " AND Hausnummer.`oaid` like '$oaid%'";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if(array_key_exists("extref", $filter)) {
|
||||
$extref = FronkDB::singleton()->escape($filter['extref']);
|
||||
if($extref) {
|
||||
@@ -130,12 +197,37 @@ class ADBHausnummerModel {
|
||||
}
|
||||
}
|
||||
|
||||
if(array_key_exists("extref%", $filter)) {
|
||||
$extref = FronkDB::singleton()->escape($filter['extref%']);
|
||||
if($extref) {
|
||||
$where .= " AND Hausnummer.`extref` like '$extref%'";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if(array_key_exists("plz", $filter)) {
|
||||
$plz = FronkDB::singleton()->escape($filter['plz']);
|
||||
if($plz) {
|
||||
$where .= " AND Plz.plz = '$plz'";
|
||||
}
|
||||
}
|
||||
|
||||
if(array_key_exists("plz%", $filter)) {
|
||||
$plz = FronkDB::singleton()->escape($filter['plz%']);
|
||||
if($plz) {
|
||||
$where .= " AND Plz.plz like '$plz%'";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if(array_key_exists("netzgebiet_id", $filter)) {
|
||||
$netzgebiet_id = $filter['netzgebiet_id'];
|
||||
if(is_numeric($netzgebiet_id)) {
|
||||
$where .= " AND Hausnummer.netzgebiet_id=$netzgebiet_id";
|
||||
} elseif(is_array($netzgebiet_id) && count($netzgebiet_id)) {
|
||||
$where .= " AND Hausnummer.netzgebiet_id IN (". implode(",", $netzgebiet_id).")";
|
||||
} elseif($netzgebiet_id === null) {
|
||||
$where .= " AND Hausnummer.netzgebiet_id IS NULL";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -157,10 +249,61 @@ class ADBHausnummerModel {
|
||||
}
|
||||
}
|
||||
|
||||
if(array_key_exists("gemeinde_id", $filter)) {
|
||||
$gemeinde_id = $filter['gemeinde_id'];
|
||||
if(is_numeric($gemeinde_id)) {
|
||||
$where .= " AND Ortschaft.gemeinde_id=$gemeinde_id";
|
||||
} elseif(is_array($gemeinde_id) && count($gemeinde_id)) {
|
||||
$where .= " AND Ortschaft.gemeinde_id IN (". implode(",", $gemeinde_id).")";
|
||||
}
|
||||
}
|
||||
|
||||
if(array_key_exists("gemeinde", $filter)) {
|
||||
$gemeinde = FronkDB::singleton()->escape($filter['gemeinde']);
|
||||
if($gemeinde) {
|
||||
$where .= " AND Gemeinde.name = '$gemeinde'";
|
||||
}
|
||||
}
|
||||
|
||||
if(array_key_exists("gemeinde%", $filter)) {
|
||||
$gemeinde = FronkDB::singleton()->escape($filter['gemeinde%']);
|
||||
if($gemeinde) {
|
||||
$where .= " AND Gemeinde.name like '$gemeinde%'";
|
||||
}
|
||||
}
|
||||
|
||||
if(array_key_exists("ortschaft", $filter)) {
|
||||
$ortschaft = FronkDB::singleton()->escape($filter['ortschaft']);
|
||||
if($ortschaft) {
|
||||
$where .= " AND Ortschaft.name = '$ortschaft'";
|
||||
}
|
||||
}
|
||||
|
||||
if(array_key_exists("ortschaft%", $filter)) {
|
||||
$ortschaft = FronkDB::singleton()->escape($filter['ortschaft%']);
|
||||
if($ortschaft) {
|
||||
$where .= " AND Ortschaft.name like '$ortschaft%'";
|
||||
}
|
||||
}
|
||||
|
||||
if(array_key_exists("ortschaft_id", $filter)) {
|
||||
$ortschaft_id = $filter['ortschaft_id'];
|
||||
if(is_numeric($ortschaft_id)) {
|
||||
$where .= " AND Hausnummer.ortschaft_id=$ortschaft_id";
|
||||
} elseif(is_array($ortschaft_id) && count($ortschaft_id)) {
|
||||
$where .= " AND Hausnummer.ortschaft_id IN (". implode(",", $ortschaft_id).")";
|
||||
}
|
||||
}
|
||||
|
||||
if(array_key_exists("hausnummer", $filter)) {
|
||||
$hausnummer = FronkDB::singleton()->escape($filter['hausnummer']);
|
||||
if($hausnummer) {
|
||||
$where .= " AND Hausnummer.`hausnummer` = '$hausnummer'";
|
||||
if(is_array($filter['hausnummer'])) {
|
||||
$hausnummer = $filter['hausnummer'];
|
||||
$where .= " AND Hausnummer.`hausnummer` IN ('".implode("','", $hausnummer)."')";
|
||||
} else {
|
||||
$hausnummer = FronkDB::singleton()->escape($filter['hausnummer']);
|
||||
if($hausnummer) {
|
||||
$where .= " AND Hausnummer.`hausnummer` = '$hausnummer'";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -171,6 +314,48 @@ class ADBHausnummerModel {
|
||||
}
|
||||
}
|
||||
|
||||
if(array_key_exists("strasse", $filter)) {
|
||||
$strasse = FronkDB::singleton()->escape($filter['strasse']);
|
||||
if($strasse) {
|
||||
$where .= " AND Strasse.name = '$strasse'";
|
||||
}
|
||||
}
|
||||
|
||||
if(array_key_exists("strasse%", $filter)) {
|
||||
$strasse = FronkDB::singleton()->escape($filter['strasse%']);
|
||||
if($strasse) {
|
||||
$where .= " AND Strasse.name like '%$strasse%'";
|
||||
}
|
||||
}
|
||||
|
||||
if(array_key_exists("rollout", $filter)) {
|
||||
$rollout = FronkDB::singleton()->escape($filter['rollout']);
|
||||
if($rollout) {
|
||||
$where .= " AND Hausnummer.rollout = '$rollout'";
|
||||
}
|
||||
}
|
||||
|
||||
if(array_key_exists("rollout%", $filter)) {
|
||||
$rollout = FronkDB::singleton()->escape($filter['rollout%']);
|
||||
if($rollout) {
|
||||
$where .= " AND Hausnummer.rollout like '%$rollout%'";
|
||||
}
|
||||
}
|
||||
|
||||
if(array_key_exists("rollout_info", $filter)) {
|
||||
$rollout_info = FronkDB::singleton()->escape($filter['rollout_info']);
|
||||
if($rollout_info) {
|
||||
$where .= " AND Hausnummer.rollout_info = '$rollout_info'";
|
||||
}
|
||||
}
|
||||
|
||||
if(array_key_exists("rollout_info%", $filter)) {
|
||||
$rollout_info = FronkDB::singleton()->escape($filter['rollout_info%']);
|
||||
if($rollout_info) {
|
||||
$where .= " AND Hausnummer.rollout_info like '%$rollout_info%'";
|
||||
}
|
||||
}
|
||||
|
||||
//var_dump($filter, $where);exit;
|
||||
return $where;
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ class ADBNetzgebietModel {
|
||||
public $extref;
|
||||
public $source;
|
||||
public $source_id;
|
||||
public $freigabe;
|
||||
|
||||
public $create = null;
|
||||
public $edit = null;
|
||||
@@ -90,9 +91,7 @@ class ADBNetzgebietModel {
|
||||
|
||||
$where = self::getSqlFilter($filter);
|
||||
$sql = "SELECT Netzgebiet.* FROM Netzgebiet
|
||||
LEFT JOIN Plz ON (Plz.netzgebiet_id = Netzgebiet.id)
|
||||
WHERE $where
|
||||
GROUP BY Netzgebiet.id
|
||||
ORDER BY name";
|
||||
|
||||
mfLoghandler::singleton()->debug($sql);
|
||||
@@ -116,6 +115,15 @@ class ADBNetzgebietModel {
|
||||
private static function getSqlFilter($filter) {
|
||||
$where = "1=1 ";
|
||||
|
||||
if(array_key_exists("netzgebiet_id", $filter)) {
|
||||
$netzgebiet_id = $filter['netzgebiet_id'];
|
||||
if(is_numeric($netzgebiet_id)) {
|
||||
$where .= " AND Netzgebiet.netzgebiet_id=$netzgebiet_id";
|
||||
} elseif(is_array($netzgebiet_id) && count($netzgebiet_id)) {
|
||||
$where .= " AND Netzgebiet.id IN (". implode(",", $netzgebiet_id).")";
|
||||
}
|
||||
}
|
||||
|
||||
if(array_key_exists("name", $filter)) {
|
||||
$name = FronkDB::singleton()->escape($filter['name']);
|
||||
if($name) {
|
||||
@@ -123,6 +131,13 @@ class ADBNetzgebietModel {
|
||||
}
|
||||
}
|
||||
|
||||
if(array_key_exists("name%", $filter)) {
|
||||
$name = FronkDB::singleton()->escape($filter['name%']);
|
||||
if($name) {
|
||||
$where .= " AND Netzgebiet.`name` LIKE '$name%'";
|
||||
}
|
||||
}
|
||||
|
||||
if(array_key_exists("extref", $filter)) {
|
||||
$extref = FronkDB::singleton()->escape($filter['extref']);
|
||||
if($extref) {
|
||||
|
||||
@@ -31,7 +31,7 @@ class ADBOrtschaft extends mfBaseModel {
|
||||
if($this->$name == null) {
|
||||
|
||||
if($name == "gemeinde") {
|
||||
$this->gemeinde = new ADBGemeinde($this->hausnummer_id);
|
||||
$this->gemeinde = new ADBGemeinde($this->gemeinde_id);
|
||||
return $this->gemeinde;
|
||||
}
|
||||
|
||||
|
||||
@@ -41,7 +41,16 @@ class ADBOrtschaftModel {
|
||||
$db = FronkDB::singleton(ADDRESSDB_DBHOST, ADDRESSDB_DBUSER, ADDRESSDB_DBPASS, ADDRESSDB_DBNAME);
|
||||
|
||||
$where = self::getSqlFilter($filter);
|
||||
$res = $db->select("Ortschaft", "*", "$where ORDER BY name,kennziffer LIMIT 1");
|
||||
$sql = "SELECT Ortschaft.* FROM Ortschaft
|
||||
LEFT JOIN Gemeinde ON (Ortschaft.gemeinde_id = Gemeinde.id)
|
||||
LEFT JOIN Plz ON (Plz.gemeinde_id = Gemeinde.id)
|
||||
LEFT JOIN GemeindeNetzgebiet ON (GemeindeNetzgebiet.gemeinde_id = Gemeinde.id)
|
||||
LEFT JOIN Netzgebiet ON (GemeindeNetzgebiet.netzgebiet_id = Netzgebiet.id)
|
||||
WHERE $where
|
||||
ORDER BY gemeinde_id,Ortschaft.name,Ortschaft.kennziffer
|
||||
LIMIT 1";
|
||||
|
||||
$res = $db->query($sql);
|
||||
if($db->num_rows($res)) {
|
||||
$data = $db->fetch_object($res);
|
||||
$item = new ADBOrtschaft($data);
|
||||
@@ -92,10 +101,15 @@ class ADBOrtschaftModel {
|
||||
|
||||
$where = self::getSqlFilter($filter);
|
||||
$sql = "SELECT Ortschaft.* FROM Ortschaft
|
||||
LEFT JOIN Gemeinde ON (Ortschaft.gemeinde_id = Gemeinde.id)
|
||||
LEFT JOIN Plz ON (Plz.gemeinde_id = Gemeinde.id)
|
||||
LEFT JOIN GemeindeNetzgebiet ON (GemeindeNetzgebiet.gemeinde_id = Gemeinde.id)
|
||||
LEFT JOIN Netzgebiet ON (GemeindeNetzgebiet.netzgebiet_id = Netzgebiet.id)
|
||||
WHERE $where
|
||||
ORDER BY name,kennziffer";
|
||||
GROUP BY Ortschaft.id
|
||||
ORDER BY Ortschaft.name,Ortschaft.kennziffer,gemeinde_id";
|
||||
|
||||
//mfLoghandler::singleton()->debug($sql);
|
||||
mfLoghandler::singleton()->debug($sql);
|
||||
if(is_array($limit) && count($limit)) {
|
||||
if(is_numeric($limit['start']) && is_numeric($limit['count'])) {
|
||||
$sql .= " LIMIT ".$limit['start'].", ".$limit['count'];
|
||||
@@ -116,6 +130,24 @@ class ADBOrtschaftModel {
|
||||
private static function getSqlFilter($filter) {
|
||||
$where = "1=1 ";
|
||||
|
||||
if(array_key_exists("netzgebiet_id", $filter)) {
|
||||
$netzgebiet_id = $filter['netzgebiet_id'];
|
||||
if(is_numeric($netzgebiet_id)) {
|
||||
$where .= " AND Netzgebiet.id=$netzgebiet_id";
|
||||
} elseif(is_array($netzgebiet_id) && count($netzgebiet_id)) {
|
||||
$where .= " AND Netzgebiet.id IN (". implode(",", $netzgebiet_id).")";
|
||||
} elseif($netzgebiet_id === null) {
|
||||
$where .= " AND Netzgebiet.id IS NULL";
|
||||
}
|
||||
}
|
||||
|
||||
if(array_key_exists("netzgebiet_extref", $filter)) {
|
||||
$netzgebiet_extref = FronkDB::singleton()->escape($filter['netzgebiet_extref']);
|
||||
if($netzgebiet_extref) {
|
||||
$where .= " AND Netzgebiet.extref = '$netzgebiet_extref'";
|
||||
}
|
||||
}
|
||||
|
||||
if(array_key_exists("gemeinde_id", $filter)) {
|
||||
$gemeinde_id = $filter['gemeinde_id'];
|
||||
if(is_numeric($gemeinde_id)) {
|
||||
@@ -149,7 +181,21 @@ class ADBOrtschaftModel {
|
||||
if(array_key_exists("name%", $filter)) {
|
||||
$name = FronkDB::singleton()->escape($filter['name%']);
|
||||
if($name) {
|
||||
$where .= " AND Ortschaft.`name` like '%$name%'";
|
||||
$where .= " AND Ortschaft.`name` like '$name%'";
|
||||
}
|
||||
}
|
||||
|
||||
if(array_key_exists("plz", $filter)) {
|
||||
$plz = FronkDB::singleton()->escape($filter['plz']);
|
||||
if($plz) {
|
||||
$where .= " AND Plz.plzstring = '$plz'";
|
||||
}
|
||||
}
|
||||
|
||||
if(array_key_exists("plz%", $filter)) {
|
||||
$plz = FronkDB::singleton()->escape($filter['plz%']);
|
||||
if($plz) {
|
||||
$where .= " AND Plz.plzstring like '$plz%'";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -40,7 +40,16 @@ class ADBPlzModel {
|
||||
$db = FronkDB::singleton(ADDRESSDB_DBHOST, ADDRESSDB_DBUSER, ADDRESSDB_DBPASS, ADDRESSDB_DBNAME);
|
||||
|
||||
$where = self::getSqlFilter($filter);
|
||||
$res = $db->select("Plz", "*", "$where ORDER BY plz LIMIT 1");
|
||||
$sql = "SELECT Plz.* FROM Plz
|
||||
LEFT JOIN Gemeinde ON (Gemeinde.id = Plz.gemeinde_id)
|
||||
LEFT JOIN GemeindeNetzgebiet ON (GemeindeNetzgebiet.gemeinde_id = Plz.gemeinde_id)
|
||||
LEFT JOIN Netzgebiet ON (GemeindeNetzgebiet.netzgebiet_id = Netzgebiet.id)
|
||||
WHERE $where
|
||||
GROUP BY Plz.id
|
||||
ORDER BY plz
|
||||
LIMIT 1";
|
||||
mfLoghandler::singleton()->debug($sql);
|
||||
$res = $db->query($sql);
|
||||
if($db->num_rows($res)) {
|
||||
$data = $db->fetch_object($res);
|
||||
$item = new ADBPlz($data);
|
||||
@@ -119,7 +128,6 @@ class ADBPlzModel {
|
||||
private static function getSqlFilter($filter) {
|
||||
$where = "1=1 ";
|
||||
|
||||
|
||||
if(array_key_exists("netzgebiet_id", $filter)) {
|
||||
$netzgebiet_id = $filter['netzgebiet_id'];
|
||||
if(is_numeric($netzgebiet_id)) {
|
||||
@@ -129,12 +137,19 @@ class ADBPlzModel {
|
||||
}
|
||||
}
|
||||
|
||||
if(array_key_exists("hausnummer_id", $filter)) {
|
||||
$hausnummer_id = $filter['hausnummer_id'];
|
||||
if(is_numeric($hausnummer_id)) {
|
||||
$where .= " AND Plz.hausnummer_id=$hausnummer_id";
|
||||
} elseif(is_array($hausnummer_id) && count($hausnummer_id)) {
|
||||
$where .= " AND Plz.hausnummer_id IN (". implode(",", $hausnummer_id).")";
|
||||
if(array_key_exists("netzgebiet_extref", $filter)) {
|
||||
$netzgebiet_extref = FronkDB::singleton()->escape($filter['netzgebiet_extref']);
|
||||
if($netzgebiet_extref) {
|
||||
$where .= " AND Netzgebiet.extref = '$netzgebiet_extref'";
|
||||
}
|
||||
}
|
||||
|
||||
if(array_key_exists("gemeinde_id", $filter)) {
|
||||
$gemeinde_id = $filter['gemeinde_id'];
|
||||
if(is_numeric($gemeinde_id)) {
|
||||
$where .= " AND Plz.gemeinde_id=$gemeinde_id";
|
||||
} elseif(is_array($gemeinde_id) && count($gemeinde_id)) {
|
||||
$where .= " AND Plz.gemeinde_id IN (". implode(",", $gemeinde_id).")";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -157,7 +172,7 @@ class ADBPlzModel {
|
||||
if(array_key_exists("plzstring%", $filter)) {
|
||||
$plzstring = FronkDB::singleton()->escape($filter['plzstring%']);
|
||||
if($plzstring) {
|
||||
$where .= " AND Plz.`plzstring` like '%$plzstring%'";
|
||||
$where .= " AND Plz.`plzstring` like '$plzstring%'";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -41,7 +41,17 @@ class ADBStrasseModel {
|
||||
$db = FronkDB::singleton(ADDRESSDB_DBHOST, ADDRESSDB_DBUSER, ADDRESSDB_DBPASS, ADDRESSDB_DBNAME);
|
||||
|
||||
$where = self::getSqlFilter($filter);
|
||||
$res = $db->select("Strasse", "*", "$where ORDER BY gemeinde_id,kennziffer,name LIMIT 1");
|
||||
$sql = "SELECT Strasse.* FROM Strasse
|
||||
LEFT JOIN Hausnummer ON (Hausnummer.strasse_id = Strasse.id)
|
||||
LEFT JOIN Plz ON (Plz.id = Hausnummer.plz_id)
|
||||
LEFT JOIN Gemeinde ON (Gemeinde.id = Strasse.gemeinde_id)
|
||||
LEFT JOIN GemeindeNetzgebiet ON (GemeindeNetzgebiet.gemeinde_id = Strasse.gemeinde_id)
|
||||
LEFT JOIN Netzgebiet ON (GemeindeNetzgebiet.netzgebiet_id = Netzgebiet.id)
|
||||
WHERE $where
|
||||
GROUP BY Strasse.id
|
||||
ORDER BY gemeinde_id,name,kennziffer
|
||||
LIMIT 1";
|
||||
$res = $db->query($sql);
|
||||
if($db->num_rows($res)) {
|
||||
$data = $db->fetch_object($res);
|
||||
$item = new ADBStrasse($data);
|
||||
@@ -170,7 +180,7 @@ class ADBStrasseModel {
|
||||
if(array_key_exists("name%", $filter)) {
|
||||
$name = FronkDB::singleton()->escape($filter['name%']);
|
||||
if($name) {
|
||||
$where .= " AND Strasse.`name` like '%$name%'";
|
||||
$where .= " AND Strasse.`name` like '$name%'";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -184,7 +194,7 @@ class ADBStrasseModel {
|
||||
if(array_key_exists("gemeinde%", $filter)) {
|
||||
$gemeinde = FronkDB::singleton()->escape($filter['gemeinde%']);
|
||||
if($gemeinde) {
|
||||
$where .= " AND Gemeinde.`name` like '%$gemeinde%'";
|
||||
$where .= " AND Gemeinde.`name` like '$gemeinde%'";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -198,7 +208,7 @@ class ADBStrasseModel {
|
||||
if(array_key_exists("plz%", $filter)) {
|
||||
$plz = FronkDB::singleton()->escape($filter['plz%']);
|
||||
if($plz) {
|
||||
$where .= " AND Plz.`plzstring` like '%$plz%'";
|
||||
$where .= " AND Plz.`plzstring` like '$plz%'";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -8,6 +8,20 @@ class ADBWohneinheit extends mfBaseModel {
|
||||
$this->table = "Wohneinheit";
|
||||
}
|
||||
|
||||
protected function afterSave() {
|
||||
if(!$this->id) return true;
|
||||
if(!$this->hausnummer_id) return true;
|
||||
|
||||
if(!defined("ADBWohneinheit_onSave_noAutoUnitCount") || !ADBWohneinheit_onSave_noAutoUnitCount) {
|
||||
$unit_count = ADBWohneinheitModel::count(['hausnummer_id' => $this->hausnummer_id]);
|
||||
$hausnummer = $this->getProperty("hausnummer");
|
||||
if($hausnummer->id) {
|
||||
$hausnummer->unit_count = $unit_count;
|
||||
$hausnummer->save();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static function parseHausnummerZusatz($text) {
|
||||
|
||||
$data = [];
|
||||
@@ -53,6 +67,49 @@ class ADBWohneinheit extends mfBaseModel {
|
||||
return $data;
|
||||
}
|
||||
|
||||
public function getNewOAID() {
|
||||
if(!$this->hausnummer_id) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$bcode = $this->getProperty("hausnummer")->oaid;
|
||||
//var_dump($bcode);
|
||||
if(!$bcode) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$codes = [];
|
||||
|
||||
// get existing codes
|
||||
$res = $this->db->select("Wohneinheit", "oaid", "oaid like '$bcode.%'");
|
||||
if($this->db->num_rows($res)) {
|
||||
while($data = $this->db->fetch_object($res)) {
|
||||
$codes[] = $data->oaid;
|
||||
}
|
||||
} else {
|
||||
return $bcode.".001";
|
||||
}
|
||||
|
||||
if(count($codes)) {
|
||||
sort($codes);
|
||||
}
|
||||
|
||||
$last_code = end($codes);
|
||||
|
||||
$m = [];
|
||||
if(preg_match('/\.(\d+)$/', $last_code, $m)) {
|
||||
if($m[1]) {
|
||||
$last_num = $m[1];
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
$new_num = ++$last_num;
|
||||
$code = $bcode.".".sprintf("%03d", $new_num);
|
||||
return $code;
|
||||
}
|
||||
|
||||
public function afterLoad() {
|
||||
//$this->hausnummer = new ADBHausnummer($this->hausnummer_id);
|
||||
//$this->loadStatus();
|
||||
|
||||
@@ -9,6 +9,7 @@ class ADBWohneinheitModel {
|
||||
public $stock;
|
||||
public $tuer;
|
||||
public $zusatz;
|
||||
public $bezeichner;
|
||||
public $nutzung;
|
||||
|
||||
public $create_by = null;
|
||||
@@ -46,7 +47,14 @@ class ADBWohneinheitModel {
|
||||
$db = FronkDB::singleton(ADDRESSDB_DBHOST, ADDRESSDB_DBUSER, ADDRESSDB_DBPASS, ADDRESSDB_DBNAME);
|
||||
|
||||
$where = self::getSqlFilter($filter);
|
||||
$res = $db->select("Wohneinheit", "*", "$where ORDER BY hausnummer_id,block,stiege,LENGTH(stock),stock,LENGTH(tuer),tuer LIMIT 1");
|
||||
$sql = "SELECT Wohneinheit.* FROM Wohneinheit
|
||||
LEFT JOIN Hausnummer ON (Hausnummer.id = Wohneinheit.hausnummer_id)
|
||||
WHERE $where
|
||||
GROUP BY Wohneinheit.id
|
||||
ORDER BY hausnummer_id,block,stiege,LENGTH(stock),stock,LENGTH(tuer),tuer,num
|
||||
LIMIT 1";
|
||||
|
||||
$res = $db->query($sql);
|
||||
if($db->num_rows($res)) {
|
||||
$data = $db->fetch_object($res);
|
||||
$item = new ADBWohneinheit($data);
|
||||
@@ -64,7 +72,7 @@ class ADBWohneinheitModel {
|
||||
|
||||
$db = FronkDB::singleton(ADDRESSDB_DBHOST, ADDRESSDB_DBUSER, ADDRESSDB_DBPASS, ADDRESSDB_DBNAME);
|
||||
|
||||
$res = $db->select("Wohneinheit", "*", "1=1 ORDER BY hausnummer_id,block,stiege,LENGTH(stock),stock,LENGTH(tuer),tuer");
|
||||
$res = $db->select("Wohneinheit", "*", "1=1 ORDER BY hausnummer_id,block,stiege,LENGTH(stock),stock,LENGTH(tuer),tuer,num");
|
||||
if($db->num_rows($res)) {
|
||||
while($data = $db->fetch_object($res)) {
|
||||
$items[] = new ADBWohneinheit($data);
|
||||
@@ -87,7 +95,7 @@ class ADBWohneinheitModel {
|
||||
) as tbl
|
||||
";
|
||||
|
||||
mfLoghandler::singleton()->debug($sql);
|
||||
//mfLoghandler::singleton()->debug($sql);
|
||||
$res = $db->query($sql);
|
||||
if($db->num_rows($res)) {
|
||||
$data = $db->fetch_object($res);
|
||||
@@ -105,9 +113,9 @@ class ADBWohneinheitModel {
|
||||
LEFT JOIN Hausnummer ON (Hausnummer.id = Wohneinheit.hausnummer_id)
|
||||
WHERE $where
|
||||
GROUP BY Wohneinheit.id
|
||||
ORDER BY hausnummer_id,block,stiege,LENGTH(stock),stock,LENGTH(tuer),tuer";
|
||||
ORDER BY hausnummer_id,block,stiege,LENGTH(stock),stock,LENGTH(tuer),tuer,num";
|
||||
|
||||
mfLoghandler::singleton()->debug($sql);
|
||||
//mfLoghandler::singleton()->debug($sql);
|
||||
if(is_array($limit) && count($limit)) {
|
||||
if(is_numeric($limit['start']) && is_numeric($limit['count'])) {
|
||||
$sql .= " LIMIT ".$limit['start'].", ".$limit['count'];
|
||||
|
||||
@@ -4,11 +4,12 @@ class Address extends mfBaseModel {
|
||||
protected $forcestr = ['street','company','zip','phone','fax','mobile','note'];
|
||||
private $parent;
|
||||
private $childaddresses;
|
||||
private $links;
|
||||
private $linked_as;
|
||||
private $links = [];
|
||||
private $linked_as = [];
|
||||
private $types;
|
||||
private $attributes;
|
||||
private $permissions;
|
||||
private $contracts;
|
||||
|
||||
private $phoneparts;
|
||||
|
||||
@@ -181,6 +182,14 @@ class Address extends mfBaseModel {
|
||||
$this->childaddresses = AddressModel::search(['parent' => $this->id]);
|
||||
return $this->childaddresses;
|
||||
}
|
||||
|
||||
if($name == "contracts") {
|
||||
$owning = ContractModel::search(['owner_id' => $this->id]);
|
||||
$billing = ContractModel::search(['billingaddress_id' => $this->id]);
|
||||
$this->contracts = array_merge($owning, $billing);
|
||||
return $this->contracts;
|
||||
}
|
||||
|
||||
/*
|
||||
if($name == "links_to") {
|
||||
$links = AddressLinkModel::search(['address_id' => $this->id]);
|
||||
|
||||
@@ -3,6 +3,46 @@
|
||||
class AddressDB {
|
||||
private $db;
|
||||
private $log;
|
||||
public static $wohneinheit_query = "select `Netzgebiet`.`id` AS `netzgebiet_id`,
|
||||
`Netzgebiet`.`name` AS `netzgebiet`,
|
||||
`Netzgebiet`.`extref` AS `netzgebiet_extref`,
|
||||
`Gemeinde`.`id` AS `gemeinde_id`,
|
||||
`Gemeinde`.`kennziffer` AS `gemeinde_kennziffer`,
|
||||
`Gemeinde`.`code` AS `gemeinde_code`,
|
||||
`Gemeinde`.`name` AS `gemeinde`,
|
||||
`Ortschaft`.`id` AS `ortschaft_id`,
|
||||
`Ortschaft`.`kennziffer` AS `ortschaft_kennziffer`,
|
||||
`Ortschaft`.`name` AS `ortschaft`,
|
||||
`Plz`.`plz` AS `plz`,
|
||||
`Strasse`.`id` AS `strasse_id`,
|
||||
`Strasse`.`kennziffer` AS `strasse_kennziffer`,
|
||||
`Strasse`.`name` AS `strasse`,
|
||||
`Hausnummer`.`id` AS `hausnummer_id`,
|
||||
`Hausnummer`.`oaid` AS `hausnummer_oaid`,
|
||||
`Hausnummer`.`hausnummer` AS `hausnummer`,
|
||||
`Hausnummer`.`extref` AS `hausnummer_extref`,
|
||||
`Hausnummer`.`grund_nr` AS `grund_nr`,
|
||||
`Hausnummer`.`gps_lat` AS `gps_lat`,
|
||||
`Hausnummer`.`gps_long` AS `gps_long`,
|
||||
`Hausnummer`.`rollout` AS `rollout`,
|
||||
`Hausnummer`.`rollout_info` AS `rollout_info`,
|
||||
`Hausnummer`.`freigabe` AS `freigabe`,
|
||||
`Wohneinheit`.`id` AS `wohneinheit_id`,
|
||||
`Wohneinheit`.`oaid` AS `wohneinheit_oaid`,
|
||||
`Wohneinheit`.`extref` AS `wohneinheit_extref`,
|
||||
`Wohneinheit`.`num` AS `num`,
|
||||
`Wohneinheit`.`block` AS `block`,
|
||||
`Wohneinheit`.`stiege` AS `stiege`,
|
||||
`Wohneinheit`.`stock` AS `stock`,
|
||||
`Wohneinheit`.`tuer` AS `tuer`,
|
||||
`Wohneinheit`.`bezeichner` AS `bezeichner`,
|
||||
`Wohneinheit`.`zusatz` AS `zusatz` from `Hausnummer`
|
||||
left join `Netzgebiet` on (`Hausnummer`.`netzgebiet_id` = `Netzgebiet`.`id`)
|
||||
left join `Plz` on (`Plz`.`id` = `Hausnummer`.`plz_id`)
|
||||
left join `Strasse` on (`Strasse`.`id` = `Hausnummer`.`strasse_id`)
|
||||
left join `Ortschaft` on (`Ortschaft`.`id` = `Hausnummer`.`ortschaft_id`)
|
||||
left join `Gemeinde` on (`Gemeinde`.`id` = `Strasse`.`gemeinde_id`)
|
||||
left join `Wohneinheit` on (`Wohneinheit`.`hausnummer_id` = `Hausnummer`.`id`)";
|
||||
|
||||
public function __construct() {
|
||||
$this->db = FronkDB::singleton(ADDRESSDB_DBHOST, ADDRESSDB_DBUSER, ADDRESSDB_DBPASS, ADDRESSDB_DBNAME);
|
||||
@@ -30,4 +70,182 @@ class AddressDB {
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* methods to create or update an Address from strings
|
||||
*/
|
||||
|
||||
public function createUpdateHausnummer($data) {
|
||||
$netzgebiet = null;
|
||||
$gemeinde = null;
|
||||
$ortschaft = null;
|
||||
$strasse = null;
|
||||
$plz = null;
|
||||
$hausnummer = null;
|
||||
|
||||
//var_dump($data);exit;
|
||||
|
||||
if(!array_key_exists("netzgebiet_id", $data)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
foreach(["gemeinde", "ortschaft", "strasse", "plz"] as $field) {
|
||||
$classname = "ADB".ucfirst($field);
|
||||
$idfield = $field."_id";
|
||||
if(!array_key_exists($field."_id", $data)) continue;
|
||||
$$field = new $classname($data[$idfield]);
|
||||
if(!${$field}->id) {
|
||||
$$field = null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$netzgebiet = new ADBNetzgebiet($data['netzgebiet_id']);
|
||||
if(!$netzgebiet->id) {
|
||||
$this->log->debug(__CLASS__."::".__METHOD__.": Missing netzgebiet_id");
|
||||
return false;
|
||||
}
|
||||
|
||||
if(!$gemeinde) {
|
||||
// dont allow creating Gemeinden
|
||||
$this->log->debug(__CLASS__."::".__METHOD__.": Missing Gemeinde");
|
||||
return false;
|
||||
}
|
||||
|
||||
if(!$ortschaft) {
|
||||
// search by kennziffer
|
||||
if(array_key_exists("ortschaft_kennziffer", $data) && $data['ortschaft_kennziffer']) {
|
||||
$ortschaft = ADBOrtschaftModel::getFirst(['kennziffer' => $data['ortschaft_kennziffer']]);
|
||||
}
|
||||
|
||||
if(!$ortschaft) {
|
||||
// search by name
|
||||
if(!array_key_exists("ortschaft", $data) || !$data['ortschaft']) return false;
|
||||
$ortschaft = ADBOrtschaftModel::getFirst(['gemeinde_id' => $gemeinde->id, 'name' => $data['ortschaft']]);
|
||||
}
|
||||
|
||||
if(!$ortschaft) {
|
||||
// create Ortschaft
|
||||
$ortschaft = ADBOrtschaftModel::create([
|
||||
'gemeinde_id' => $gemeinde->id,
|
||||
'kennziffer' => ($data['ortschaft_kennziffer']) ? $data['ortschaft_kennziffer'] : null,
|
||||
'name' => $data['ortschaft']
|
||||
]);
|
||||
if(!$ortschaft->save()) {
|
||||
$this->log->debug(__CLASS__."::".__METHOD__.": Cannot save Ortschaft");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(!$strasse) {
|
||||
// search by kennziffer
|
||||
if(array_key_exists("strasse_kennziffer", $data) && $data['strasse_kennziffer']) {
|
||||
$strasse = ADBStrasseModel::getFirst(['kennziffer' => $data['strasse_kennziffer']]);
|
||||
}
|
||||
|
||||
if(!$strasse) {
|
||||
// search by name
|
||||
if(!array_key_exists("strasse", $data) || !$data['strasse']) return false;
|
||||
$strasse = ADBStrasseModel::getFirst(['gemeinde_id' => $gemeinde->id, 'name' => $data['strasse']]);
|
||||
}
|
||||
|
||||
if(!$strasse) {
|
||||
// create Strasse
|
||||
if(!array_key_exists("strasse", $data) || !$data['strasse']) return false;
|
||||
$strasse = ADBStrasseModel::create([
|
||||
'gemeinde_id' => $gemeinde->id,
|
||||
'kennziffer' => ($data['strasse_kennziffer']) ? $data['strasse_kennziffer'] : null,
|
||||
'name' => $data['strasse']
|
||||
]);
|
||||
if(!$strasse->save()) {
|
||||
$this->log->debug(__CLASS__."::".__METHOD__.": Cannot save Strasse");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(!$plz) {
|
||||
// search by plz
|
||||
if(!array_key_exists("plz", $data) || !$data['plz']) return false;
|
||||
$plz = ADBPlzModel::getFirst(['gemeinde_id' => $gemeinde->id, 'plz' => $data['plz']]);
|
||||
if(!$plz) {
|
||||
// create PLZ
|
||||
$plz = ADBPlzModel::create([
|
||||
'gemeinde_id' => $gemeinde->id,
|
||||
'plz' => $data['plz'],
|
||||
'plzstring' => $data['plz']
|
||||
]);
|
||||
if(!$plz->save()) {
|
||||
$this->log->debug(__CLASS__."::".__METHOD__.": Cannot save PLZ");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(array_key_exists("hausnummer_id", $data)) {
|
||||
// if hausnummer_id is set but empty => fail
|
||||
if(!$data['hausnummer_id']) return false;
|
||||
$hausnummer = new ADBHausnummer($data['hausnummer_id']);
|
||||
if(!$hausnummer->id) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
$me = new User();
|
||||
$me->loadMe();
|
||||
|
||||
// build hausnummer data
|
||||
//$hausnummer_data['oaid'] = (array_key_exists("oaid", $data) && $data['oaid']) ? $data['oaid'] : null;
|
||||
$hausnummer_data['adrcd'] = ($data['adrcd']) ? $data['adrcd'] : null;
|
||||
$hausnummer_data['extref'] = ($data['extref']) ? $data['extref'] : null;
|
||||
$hausnummer_data['netzgebiet_id'] = $netzgebiet->id;
|
||||
$hausnummer_data['ortschaft_id'] = $ortschaft->id;
|
||||
$hausnummer_data['plz_id'] = $plz->id;
|
||||
$hausnummer_data['strasse_id'] = $strasse->id;
|
||||
$hausnummer_data['hausnummer'] = $data['hausnummer'];
|
||||
$hausnummer_data['grund_nr'] = $data['grund_nr'];
|
||||
$hausnummer_data['gps_lat'] = ($data['gps_lat']) ? str_replace(",", ".", $data['gps_lat']) : null;
|
||||
$hausnummer_data['gps_long'] = ($data['gps_long']) ? str_replace(",", ".", $data['gps_long']) : null;
|
||||
$hausnummer_data['rollout'] = (trim($data['rollout'])) ? trim($data['rollout']) : null;
|
||||
$hausnummer_data['rollout_info'] = (trim($data['rollout_info'])) ? trim($data['rollout_info']) : null;
|
||||
$hausnummer_data['freigabe'] = json_encode($data['freigabe']);
|
||||
$hausnummer_data['manual_add'] = date('U');
|
||||
$hausnummer_data['manual_add_by'] = $me->id;
|
||||
$hausnummer_data['manual_add_info'] = "thetool user ".$me->username." via AddressDB";
|
||||
$hausnummer_data['manual_update'] = date('U');
|
||||
$hausnummer_data['manual_update_by'] = $me->id;
|
||||
$hausnummer_data['manual_update_info'] = "thetool user ".$me->username." via AddressDB";
|
||||
|
||||
//var_dump($hausnummer_data, $hausnummer);exit;
|
||||
|
||||
if(!$hausnummer) {
|
||||
// create hausnummer
|
||||
$hausnummer = ADBHausnummerModel::create($hausnummer_data);
|
||||
} else {
|
||||
// update hausnummer
|
||||
$hausnummer->update($hausnummer_data);
|
||||
}
|
||||
|
||||
$hausnummer_id = $hausnummer->save();
|
||||
if(!$hausnummer_id) {
|
||||
$this->log->debug(__CLASS__."::".__METHOD__.": Cannot save Hausnummer");
|
||||
return false;
|
||||
}
|
||||
|
||||
// create OAID
|
||||
if(!$hausnummer->oaid) {
|
||||
$hausnummer->oaid = $hausnummer->getNewOAID();
|
||||
if(!$hausnummer->save()) {
|
||||
$this->log->debug(__CLASS__."::".__METHOD__.": Cannot save Hausnummer OAID");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return $hausnummer_id;
|
||||
}
|
||||
|
||||
public function updateHausnummer($hausnummer_id, $data) {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -9,11 +9,374 @@ class AddressDBController extends mfBaseController {
|
||||
$this->me = $me;
|
||||
$this->layout()->set("me",$me);
|
||||
|
||||
if(!$me->is(["Admin", "netowner", "pipeplanner"])) {
|
||||
if(!$me->is(["Admin", "netowner"])) {
|
||||
$this->redirect("Dashboard");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
protected function indexAction() {
|
||||
$this->layout()->setTemplate("AddressDB/Index");
|
||||
|
||||
$rfilter = $this->request->filter;
|
||||
iF(!is_array($rfilter)) {
|
||||
$rfilter = [];
|
||||
}
|
||||
|
||||
$this->layout->set("filter", $rfilter);
|
||||
|
||||
$filter = $this->getPreparedFilter($rfilter);
|
||||
|
||||
// pagination defaults
|
||||
$pagination = [];
|
||||
$pagination['start'] = 0;
|
||||
$pagination['count'] = 25;
|
||||
$pagination['maxItems'] = 0;
|
||||
|
||||
if(is_numeric($this->request->s)) {
|
||||
$pagination['start'] = intval($this->request->s);
|
||||
}
|
||||
|
||||
|
||||
if($this->me->is("Admin")) {
|
||||
$my_networks = NetworkModel::getAll();
|
||||
if($filter['network_id']) {
|
||||
$filter['netzgebiet_id'] = $filter['network_id'];
|
||||
}
|
||||
} else {
|
||||
$my_networks = $this->me->myNetworks(["netowner", "salespartner"]);
|
||||
}
|
||||
|
||||
$netzgebiet_ids = [];
|
||||
$my_adb_networks = [];
|
||||
foreach($my_networks as $network) {
|
||||
if($network->adb_netzgebiet_id && !in_array($network->adb_netzgebiet_id, $netzgebiet_ids)) {
|
||||
$netzgebiet_ids[] = $network->adb_netzgebiet_id;
|
||||
$my_adb_networks[$network->adb_netzgebiet_id] = new ADBNetzgebiet($network->adb_netzgebiet_id);
|
||||
}
|
||||
}
|
||||
//var_dump($my_networks, $my_adb_networks);
|
||||
if(!$this->me->is("Admin") && array_key_exists("network_id", $filter)) {
|
||||
if(array_key_exists($filter['network_id'], $my_adb_networks)) {
|
||||
$filter['netzgebiet_id'] = $filter['network_id'];
|
||||
} else {
|
||||
unset($filter['network_id']);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$addressdb_filter = $filter;
|
||||
if(!array_key_exists("netzgebiet_id", $addressdb_filter)) {
|
||||
$addressdb_filter['netzgebiet_id'] = $netzgebiet_ids;
|
||||
}
|
||||
//var_dump($my_adb_networks);exit;
|
||||
$this->layout()->set("my_networks", ADBNetzgebietModel::getAll());
|
||||
$this->layout()->set("my_adb_networks", $my_adb_networks);
|
||||
//var_dump($addressdb_filter);exit;
|
||||
|
||||
if($filter['netzgebiet_id'] === "null") {
|
||||
$addressdb_filter['netzgebiet_id'] = 0;
|
||||
$pagination['maxItems'] = ADBHausnummerModel::count($addressdb_filter);
|
||||
$addresses = ADBHausnummerModel::search($addressdb_filter, $pagination);
|
||||
} else if(count($my_adb_networks)) {
|
||||
$pagination['maxItems'] = ADBHausnummerModel::count($addressdb_filter);
|
||||
$addresses = ADBHausnummerModel::search($addressdb_filter, $pagination);
|
||||
}
|
||||
$this->layout()->set("pagination", $pagination);
|
||||
$this->layout()->set("addresses", $addresses);
|
||||
|
||||
// get filter lists
|
||||
$filter_filter = [];
|
||||
if(array_key_exists("netzgebiet_id", $addressdb_filter)) {
|
||||
$filter_filter["netzgebiet_id"] = $netzgebiet_ids;
|
||||
$this->layout()->set("gemeinden", ADBGemeindeModel::search($filter_filter));
|
||||
if(array_key_exists("gemeinde_id", $addressdb_filter)) {
|
||||
$filter_filter['gemeinde_id'] = $addressdb_filter['gemeinde_id'];
|
||||
}
|
||||
$this->layout()->set("ortschaften", ADBOrtschaftModel::search($filter_filter));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
protected function getPreparedFilter($filter) {
|
||||
$new_filter = [];
|
||||
|
||||
if(array_key_exists("street", $filter) && $filter['street']) {
|
||||
$new_filter['strasse%'] = "%".$filter['street'];
|
||||
unset($filter['street']);
|
||||
}
|
||||
|
||||
if(array_key_exists("adrcd", $filter) && $filter['adrcd']) {
|
||||
$new_filter['adrcd%'] = $filter['adrcd'];
|
||||
unset($filter['adrcd']);
|
||||
}
|
||||
|
||||
if(array_key_exists("oaid", $filter) && $filter['oaid']) {
|
||||
$new_filter['oaid%'] = $filter['oaid'];
|
||||
unset($filter['oaid']);
|
||||
}
|
||||
|
||||
if(array_key_exists("extref", $filter) && $filter['extref']) {
|
||||
$new_filter['extref%'] = "%".$filter['extref'];
|
||||
unset($filter['extref']);
|
||||
}
|
||||
|
||||
if(array_key_exists("zip", $filter) && $filter['zip']) {
|
||||
$new_filter['plz%'] = $filter['zip'];
|
||||
unset($filter['zip']);
|
||||
}
|
||||
|
||||
if(array_key_exists("rollout", $filter) && $filter['rollout']) {
|
||||
$new_filter['rollout%'] = $filter['rollout'];
|
||||
unset($filter['rollout']);
|
||||
}
|
||||
|
||||
if(array_key_exists("rollout_info", $filter) && $filter['rollout_info']) {
|
||||
$new_filter['rollout_info%'] = $filter['rollout_info'];
|
||||
unset($filter['rollout_info']);
|
||||
}
|
||||
|
||||
if(array_key_exists("gemeinde", $filter) && $filter['gemeinde']) {
|
||||
$new_filter['gemeinde%'] = $filter['gemeinde'];
|
||||
unset($filter['gemeinde']);
|
||||
unset($filter['gemeinde_id']);
|
||||
}
|
||||
|
||||
if(array_key_exists("ortschaft", $filter) && $filter['ortschaft']) {
|
||||
$new_filter['ortschaft%'] = $filter['ortschaft'];
|
||||
unset($filter['ortschaft']);
|
||||
unset($filter['ortschaft_id']);
|
||||
}
|
||||
|
||||
if(is_array($filter) && count($filter)) {
|
||||
foreach($filter as $name => $value) {
|
||||
if(strlen($value) > 0) $new_filter[$name] = $value;
|
||||
}
|
||||
}
|
||||
|
||||
return $new_filter;
|
||||
}
|
||||
|
||||
protected function addAction() {
|
||||
$this->layout()->setTemplate("AddressDB/Form");
|
||||
|
||||
if($this->me->is("Admin")) {
|
||||
$my_networks = NetworkModel::getAll();
|
||||
} else {
|
||||
$my_networks = $this->me->myNetworks(["netowner", "salespartner"]);
|
||||
}
|
||||
|
||||
$netzgebiet_ids = [];
|
||||
$my_adb_networks = [];
|
||||
foreach($my_networks as $network) {
|
||||
if($network->adb_netzgebiet_id && !in_array($network->adb_netzgebiet_id, $netzgebiet_ids)) {
|
||||
$netzgebiet_ids[] = $network->adb_netzgebiet_id;
|
||||
$my_adb_networks[$network->adb_netzgebiet_id] = new ADBNetzgebiet($network->adb_netzgebiet_id);
|
||||
}
|
||||
}
|
||||
$this->layout()->set("my_adb_networks", $my_adb_networks);
|
||||
|
||||
|
||||
$save_data = [];
|
||||
foreach($this->request->get() as $key => $value) {
|
||||
$save_data[$key] = $value;
|
||||
}
|
||||
//var_dump($save_data);exit;
|
||||
$this->layout()->set("save_data", $save_data);
|
||||
|
||||
}
|
||||
|
||||
protected function editAction() {
|
||||
|
||||
$id = $this->request->id;
|
||||
if(!is_numeric($id) || $id < 1) {
|
||||
$this->layout()->setFlash("Adresse nicht gefunden", "error");
|
||||
$this->redirect("AddressDB");
|
||||
}
|
||||
|
||||
$hausnummer = new ADBHausnummer($id);
|
||||
if(!$hausnummer->id) {
|
||||
$this->layout()->setFlash("Adresse nicht gefunden", "error");
|
||||
$this->redirect("AddressDB");
|
||||
}
|
||||
|
||||
/*if(!in_array($hausnummer->netzgebiet_id, $my_adb_networks)) {
|
||||
$this->layout()->setFlash("Adresse nicht gefunden", "error");
|
||||
$this->redirect("AddressDB");
|
||||
}*/
|
||||
|
||||
$this->layout()->set("address", $hausnummer);
|
||||
|
||||
return $this->addAction();
|
||||
}
|
||||
|
||||
protected function saveAction() {
|
||||
$r = $this->request;
|
||||
$id = $r->id;
|
||||
//var_dump($r->get());exit;
|
||||
|
||||
$address_data = [];
|
||||
|
||||
if(is_numeric($id) && $id > 0) {
|
||||
$mode = "edit";
|
||||
$hausnummer = new ADBHausnummer($id);
|
||||
if(!$hausnummer->id) {
|
||||
$this->layout()->setFlash("Addresse nicht gefunden", "error");
|
||||
$this->redirect("AddressDB");
|
||||
}
|
||||
$address_data['hausnummer_id'] = $hausnummer->id;
|
||||
} else {
|
||||
$mode = "add";
|
||||
}
|
||||
|
||||
$required = ['netzgebiet_id','strasse','hausnummer','plz','ortschaft','gemeinde'];
|
||||
foreach(['adrcd','extref','netzgebiet_id','strasse','hausnummer','plz','ortschaft','gemeinde','grund_nr','gps_lat','gps_long','unit_count'] as $field) {
|
||||
if(in_array($field, $required)) {
|
||||
if(!trim($r->$field)) {
|
||||
$this->layout()->setFlash("'".ucfirst($field)."' darf nicht leer sein!", "error");
|
||||
return $this->addAction();
|
||||
//$this->redirect("AddressDB", $mode, ['id' => $id]);
|
||||
}
|
||||
}
|
||||
$address_data[$field] = $this->db()->escape(trim($r->$field));
|
||||
}
|
||||
|
||||
$gemeinde = ADBGemeindeModel::getFirst(['name' => $address_data['gemeinde']]);
|
||||
if(!$gemeinde->id) {
|
||||
$this->layout()->setFlash("Gemeinde nicht gefunden", "error");
|
||||
return $this->addAction();
|
||||
//$this->redirect("AddressDB", $mode, ['id' => $id]);
|
||||
}
|
||||
|
||||
$address_data['gemeinde_id'] = $gemeinde->id;
|
||||
|
||||
$freigabe = [];
|
||||
if(is_array($r->freigabe) && count($r->freigabe)) {
|
||||
if(in_array("interest", $r->freigabe)) {
|
||||
$freigabe[] = "interest";
|
||||
}
|
||||
if(in_array("provision", $r->freigabe)) {
|
||||
$freigabe[] = "provision";
|
||||
}
|
||||
if(in_array("order", $r->freigabe)) {
|
||||
$freigabe[] = "order";
|
||||
}
|
||||
if(in_array("reorder", $r->freigabe)) {
|
||||
$freigabe[] = "reorder";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$address_data['freigabe'] = $freigabe;
|
||||
|
||||
$rollout = null;
|
||||
$rollout_info = null;
|
||||
if(trim($r->rollout)) {
|
||||
$rollout = intval(trim($r->rollout));
|
||||
}
|
||||
if(trim($r->rollout_info)) {
|
||||
$rollout_info = trim($r->rollout_info);
|
||||
}
|
||||
if(!$rollout_info) {
|
||||
$rollout_info = "unscheduled";
|
||||
}
|
||||
|
||||
$address_data['rollout'] = $rollout;
|
||||
$address_data['rollout_info'] = $rollout_info;
|
||||
|
||||
//var_dump($address_data);exit;
|
||||
|
||||
$adb = new AddressDB();
|
||||
$hausnummer_id = $adb->createUpdateHausnummer($address_data);
|
||||
if(!$hausnummer_id) {
|
||||
$this->layout()->setFlash("Fehler beim Erstellen der Adresse!", "error");
|
||||
return $this->addAction();
|
||||
//$this->redirect("AddressDB");
|
||||
}
|
||||
|
||||
if($mode == "add") {
|
||||
$hausnummer = new ADBHausnummer($hausnummer_id);
|
||||
|
||||
/*
|
||||
* Wohneinheiten erstellen
|
||||
*/
|
||||
if($r->unit_count > 0) {
|
||||
for($i = 1; $i <= $r->unit_count; $i++) {
|
||||
$unit = ADBWohneinheitModel::create([
|
||||
'hausnummer_id' => $hausnummer_id,
|
||||
'num' => $i,
|
||||
]);
|
||||
$unit_id = $unit->save();
|
||||
if(!$unit_id) {
|
||||
$this->log->debug(__CLASS__."::".__METHOD__.": Cannot save Woneinheit");
|
||||
continue;
|
||||
}
|
||||
$unit->oaid = $unit->getNewOAID();
|
||||
$unit->save();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$qs = http_build_query(['filter' => ['oaid' => $hausnummer->oaid]]);
|
||||
//var_dump($qs);exit;
|
||||
$this->layout()->setFlash("Adresse erfolgreich gespeichert", "success");
|
||||
$this->redirect("AddressDB", "Index", $qs);
|
||||
|
||||
}
|
||||
|
||||
protected function exportAction() {
|
||||
$rfilter = $this->request->filter;
|
||||
if(!is_array($rfilter)) {
|
||||
$rfilter = [];
|
||||
}
|
||||
$filter = $this->getPreparedFilter($rfilter);
|
||||
|
||||
|
||||
if($this->me->is("Admin")) {
|
||||
$my_networks = NetworkModel::getAll();
|
||||
} else {
|
||||
$my_networks = $this->me->myNetworks(["netowner", "salespartner"]);
|
||||
}
|
||||
|
||||
$netzgebiet_ids = [];
|
||||
$my_adb_networks = [];
|
||||
foreach($my_networks as $network) {
|
||||
if($network->adb_netzgebiet_id && !in_array($network->adb_netzgebiet_id, $netzgebiet_ids)) {
|
||||
$netzgebiet_ids[] = $network->adb_netzgebiet_id;
|
||||
$my_adb_networks[$network->adb_netzgebiet_id] = new ADBNetzgebiet($network->adb_netzgebiet_id);
|
||||
}
|
||||
}
|
||||
|
||||
if(array_key_exists("network_id", $filter) && $filter['network_id']) {
|
||||
if($this->me->is("Admin")) {
|
||||
$filter['netzgebiet_id'] = $filter['network_id'];
|
||||
} else {
|
||||
if(in_array($filter['network_id'], $netzgebiet_ids)) {
|
||||
$filter['netzgebiet_id'] = $filter['network_id'];
|
||||
}
|
||||
}
|
||||
}
|
||||
unset($filter['network_id']);
|
||||
|
||||
$addressdb_filter = $filter;
|
||||
if(!array_key_exists("netzgebiet_id", $addressdb_filter)) {
|
||||
$addressdb_filter['netzgebiet_id'] = $netzgebiet_ids;
|
||||
}
|
||||
|
||||
// Get mysqli resource from Model so layout can output data as it's retrieved
|
||||
// Fixes lousy performance and horrendous memory usage
|
||||
$res = ADBHausnummerModel::search($addressdb_filter, [], true);
|
||||
|
||||
$this->layout()->setTemplate("AddressDB/export.csv");
|
||||
$this->layout()->set("res", $res);
|
||||
|
||||
//var_dump($filter, $hausnummern);exit;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
protected function apiAction() {
|
||||
if(!$this->me->is(["Admin","netowner"])) {
|
||||
$this->redirect("Dashboard");
|
||||
@@ -28,12 +391,24 @@ class AddressDBController extends mfBaseController {
|
||||
case "getFilteredBuildings":
|
||||
$return = $this->getFilteredBuildingsApi();
|
||||
break;
|
||||
case "getAddressByHousenumber":
|
||||
$return = $this->getAddressByHousenumberApi();
|
||||
break;
|
||||
case "getUnits":
|
||||
$return = $this->getUnitsApi();
|
||||
break;
|
||||
case "findStreets":
|
||||
$return = $this->findStreetsApi();
|
||||
break;
|
||||
case "findDistricts":
|
||||
$return = $this->findDistrictsApi();
|
||||
break;
|
||||
case "findCities":
|
||||
$return = $this->findCitiesApi();
|
||||
break;
|
||||
case "findZips":
|
||||
$return = $this->findZipsApi();
|
||||
break;
|
||||
case 'findBuildings':
|
||||
$return = $this->findBuildingsApi();
|
||||
break;
|
||||
@@ -55,6 +430,20 @@ class AddressDBController extends mfBaseController {
|
||||
private function findAddressApi() {
|
||||
$addresses = [];
|
||||
$search = trim($this->request->q);
|
||||
$campagin_id = ($this->request->campaign_id);
|
||||
|
||||
$campaign = new Preordercampaign($campagin_id);
|
||||
if(!$campaign->id) {
|
||||
header("Content-Type: application/json");
|
||||
echo json_encode(["results" => []]);
|
||||
exit;
|
||||
}
|
||||
|
||||
$scluster_ids = [];
|
||||
foreach($campaign->salesclusters as $scluster) {
|
||||
$scluster_ids[] = $scluster->id;
|
||||
}
|
||||
|
||||
$results = [];
|
||||
|
||||
$search_parts = explode(" ", $search);
|
||||
@@ -62,19 +451,25 @@ class AddressDBController extends mfBaseController {
|
||||
$ort_search = $strasse_search = $plz_search = $hausnummer_search = [];
|
||||
|
||||
foreach($search_parts as $p) {
|
||||
$p = trim($p);
|
||||
$p = $this->db->escape(trim($p));
|
||||
if(!$p) continue;
|
||||
$ort_search[] = "ortschaft like '%$p%'";
|
||||
$strasse_search[] = "strasse like '%$p%'";
|
||||
$ort_search[] = "ortschaft like '$p%'";
|
||||
$strasse_search[] = "strasse like '$p%'";
|
||||
$plz_search[] = "plz like '%$p%'";
|
||||
$hausnummer_search[] = "hausnummer like '%$p%'";
|
||||
}
|
||||
|
||||
$sql = "SELECT * FROM view_hausnummer WHERE (".implode(" OR ", $ort_search).") OR (".implode(" OR ", $strasse_search).") OR (".implode(" OR ", $plz_search).") OR (".implode(" OR ", $hausnummer_search).")";
|
||||
//echo $sql;exit;
|
||||
$where = "1=1";
|
||||
if(count($scluster_ids)) {
|
||||
$where .= " AND netzgebiet_id IN (".implode(', ',$scluster_ids).")";
|
||||
}
|
||||
|
||||
$sql = "SELECT * FROM view_hausnummer WHERE $where AND ((".implode(" OR ", $ort_search).") OR (".implode(" OR ", $strasse_search).") OR (".implode(" OR ", $plz_search).") OR (".implode(" OR ", $hausnummer_search).")) ORDER BY strasse, LENGTH(hausnummer), hausnummer";
|
||||
$this->log->debug($sql);
|
||||
|
||||
$adb = FronkDB::singleton(ADDRESSDB_DBHOST, ADDRESSDB_DBUSER, ADDRESSDB_DBPASS, ADDRESSDB_DBNAME);
|
||||
$res = $adb->query($sql);
|
||||
$this->log->debug("done");
|
||||
|
||||
if(!$adb->num_rows($res)) {
|
||||
header("Content-Type: application/json");
|
||||
@@ -84,22 +479,39 @@ class AddressDBController extends mfBaseController {
|
||||
|
||||
while($data = $adb->fetch_object($res)) {
|
||||
$address_string = $data->plz." ".$data->ortschaft.", ".$data->strasse." ".$data->hausnummer;
|
||||
$sort_key = $data->plz." ".$data->ortschaft." ".$data->strasse;
|
||||
|
||||
$address = [];
|
||||
$address['id'] = $data->hausnummer_id;
|
||||
$address["text"] = $address_string;
|
||||
$address['sort_key'] = $sort_key;
|
||||
$addresses[] = $address;
|
||||
}
|
||||
|
||||
|
||||
// sort results by most occurences of search strings
|
||||
$sort = [];
|
||||
foreach($addresses as $address) {
|
||||
foreach($addresses as $key => $address) {
|
||||
$includes_int = false;
|
||||
$count = 0;
|
||||
foreach($search_parts as $p) {
|
||||
$count += substr_count(strtolower($address['text']), strtolower($p));
|
||||
$p = $this->db->escape(trim($p));
|
||||
if(!$p) continue;
|
||||
if(is_numeric(($p))) {
|
||||
$includes_int = true;
|
||||
if(substr_count(strtolower($address['text']), strtolower($p))) {
|
||||
$count++;
|
||||
}
|
||||
} else {
|
||||
$count += substr_count(strtolower($address['text']), strtolower($p));
|
||||
}
|
||||
}
|
||||
unset($address['sort_key']);
|
||||
//echo $address['text']." $p $count<br />\n";
|
||||
|
||||
if($includes_int && (($count + 1) - count($search_parts) ) < 1) {
|
||||
continue;
|
||||
}
|
||||
if(!array_key_exists($count, $sort)) {
|
||||
$sort[$count] = [];
|
||||
}
|
||||
@@ -136,7 +548,7 @@ class AddressDBController extends mfBaseController {
|
||||
$u = [];
|
||||
$u['id'] = $unit->id;
|
||||
$u['zip'] = $unit->hausnummer->plz->plzstring;
|
||||
$u['city'] = $unit->hausnummer->strasse->ortschaft->name;
|
||||
$u['city'] = $unit->hausnummer->ortschaft->name;
|
||||
$u['street'] = $unit->hausnummer->strasse->name;
|
||||
$u['housenumber'] = $unit->hausnummer->hausnummer;
|
||||
$u['block'] = $unit->block;
|
||||
@@ -152,15 +564,109 @@ class AddressDBController extends mfBaseController {
|
||||
return ['units' => $results];
|
||||
}
|
||||
|
||||
private function findCitiesApi() {
|
||||
$cities = [];
|
||||
$search = $this->request->search;
|
||||
private function getAddressByHousenumberApi() {
|
||||
$zips = [];
|
||||
$hausnummer_id = trim($this->request->hausnummer_id);
|
||||
|
||||
$ort_ids = [];
|
||||
if(!is_numeric($hausnummer_id) || $hausnummer_id < 1) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$hausnummer = new ADBHausnummer($hausnummer_id);
|
||||
|
||||
$result = [
|
||||
'hausnummer_id' => $hausnummer->id,
|
||||
'strasse' => $hausnummer->strasse->name,
|
||||
'hausnummer' => $hausnummer->hausnummer,
|
||||
'plz' => $hausnummer->plz->plz,
|
||||
'ort' => $hausnummer->strasse->gemeinde->name,
|
||||
'ortschaft' => $hausnummer->ortschaft->name
|
||||
];
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
private function findStreetsApi() {
|
||||
$streets = [];
|
||||
$search = trim($this->request->q);
|
||||
|
||||
foreach(ADBStrasseModel::search(['name%' => $search]) as $street) {
|
||||
if(!in_array($street->name, $streets)) {
|
||||
$streets[] = $street->name;
|
||||
}
|
||||
}
|
||||
|
||||
$this->returnJson($streets);
|
||||
}
|
||||
|
||||
private function findZipsApi() {
|
||||
$zips = [];
|
||||
$search = trim($this->request->q);
|
||||
$campaign_id = trim($this->request->campaign_id);
|
||||
|
||||
$plz_search = [];
|
||||
|
||||
if($campaign_id) {
|
||||
$campaign = new Preordercampaign($campaign_id);
|
||||
if(!$campaign->id) {
|
||||
header("Content-Type: application/json");
|
||||
echo json_encode(["results" => []]);
|
||||
exit;
|
||||
}
|
||||
|
||||
$scluster_ids = [];
|
||||
foreach($campaign->salesclusters as $scluster) {
|
||||
$scluster_ids[] = $scluster->id;
|
||||
}
|
||||
$plz_search['netzgebiet_id'] = $scluster_ids;
|
||||
}
|
||||
|
||||
$plz_search['plzstring%'] = $search;
|
||||
|
||||
|
||||
foreach(ADBPlzModel::search($plz_search) as $zip) {
|
||||
if(!in_array($zip->plz, $zips)) {
|
||||
$zips[] = $zip->plz;
|
||||
}
|
||||
}
|
||||
|
||||
$this->returnJson($zips);
|
||||
}
|
||||
|
||||
private function findDistrictsApi() {
|
||||
$districts = [];
|
||||
$search = trim($this->request->q);
|
||||
$autocomplete = $this->request->autocomplete;
|
||||
$campaign_id = trim($this->request->campaign_id);
|
||||
|
||||
$district_search = [];
|
||||
|
||||
if($campaign_id) {
|
||||
$campaign = new Preordercampaign($campaign_id);
|
||||
if(!$campaign->id) {
|
||||
header("Content-Type: application/json");
|
||||
echo json_encode(["results" => []]);
|
||||
exit;
|
||||
}
|
||||
|
||||
$scluster_ids = [];
|
||||
foreach($campaign->salesclusters as $scluster) {
|
||||
$scluster_ids[] = $scluster->id;
|
||||
}
|
||||
$district_search['netzgebiet_id'] = $scluster_ids;
|
||||
}
|
||||
|
||||
$district_search['name%'] = "%".$search;
|
||||
|
||||
foreach(ADBOrtschaftModel::search($district_search) as $district) {
|
||||
if(!in_array($district->name, $districts)) {
|
||||
$districts[] = $district->name;
|
||||
}
|
||||
}
|
||||
/*
|
||||
if(is_numeric($search)) {
|
||||
$adb = FronkDB::singleton(ADDRESSDB_DBHOST, ADDRESSDB_DBUSER, ADDRESSDB_DBPASS, ADDRESSDB_DBNAME);
|
||||
$sql = "SELECT ortschaft_id from view_wohneinheit WHERE plz like '%$search%' GROUP BY ortschaft_id";
|
||||
$sql = "SELECT ortschaft_id from view_wohneinheit WHERE ortschaft like '%$search%' GROUP BY ortschaft_id";
|
||||
$res = $adb->query($sql);
|
||||
|
||||
if($adb->num_rows($res)) {
|
||||
@@ -178,9 +684,18 @@ class AddressDBController extends mfBaseController {
|
||||
$results = ADBOrtschaftModel::search(['name%' => $search]);
|
||||
}
|
||||
|
||||
if($autocomplete) {
|
||||
foreach($results as $city) {
|
||||
if(!in_array($city->name, $cities)) {
|
||||
$cities[] = $city->name;
|
||||
}
|
||||
}
|
||||
$this->returnJson($cities);
|
||||
}
|
||||
|
||||
foreach($results as $city) {
|
||||
$gemeinde = new ADBGemeinde($city->gemeinde_id);
|
||||
|
||||
|
||||
$data = [];
|
||||
$data['id'] = $city->id;
|
||||
$data['gemeinde_id'] = $city->gemeinde_id;
|
||||
@@ -189,8 +704,43 @@ class AddressDBController extends mfBaseController {
|
||||
$data['name'] = $city->name;
|
||||
$cities[] = $data;
|
||||
}
|
||||
*/
|
||||
$this->returnJson($districts);
|
||||
//return ['cities' => $cities];
|
||||
}
|
||||
|
||||
private function findCitiesApi() {
|
||||
$cities = [];
|
||||
$search = $this->request->q;
|
||||
//$autocomplete = $this->request->autocomplete;
|
||||
$campaign_id = trim($this->request->campaign_id);
|
||||
|
||||
$city_search = [];
|
||||
|
||||
if($campaign_id) {
|
||||
$campaign = new Preordercampaign($campaign_id);
|
||||
if(!$campaign->id) {
|
||||
header("Content-Type: application/json");
|
||||
echo json_encode(["results" => []]);
|
||||
exit;
|
||||
}
|
||||
|
||||
$scluster_ids = [];
|
||||
foreach($campaign->salesclusters as $scluster) {
|
||||
$scluster_ids[] = $scluster->id;
|
||||
}
|
||||
$city_search['netzgebiet_id'] = $scluster_ids;
|
||||
}
|
||||
|
||||
$city_search['name%'] = "%".$search;
|
||||
|
||||
foreach(ADBGemeindeModel::search($city_search) as $city) {
|
||||
if(!in_array($city->name, $cities)) {
|
||||
$cities[] = $city->name;
|
||||
}
|
||||
}
|
||||
$this->returnJson($cities);
|
||||
|
||||
return ['cities' => $cities];
|
||||
}
|
||||
|
||||
private function getFilteredBuildingsApi() {
|
||||
|
||||
@@ -114,19 +114,21 @@ class AddresstypeModel {
|
||||
/*
|
||||
* Address Type
|
||||
*/
|
||||
if(is_array($filter['addresstype']) && count($filter['addresstype'])) {
|
||||
$at = $filter['addresstype'];
|
||||
$in = [];
|
||||
foreach(TT_ROLES as $role) {
|
||||
if(in_array($role, $at)) {
|
||||
$in[] = "Addresstype.type = '$role'";
|
||||
if(array_key_exists('addresstype', $filter)) {
|
||||
if(is_array($filter['addresstype']) && count($filter['addresstype'])) {
|
||||
$at = $filter['addresstype'];
|
||||
$in = [];
|
||||
foreach(TT_ROLES as $role) {
|
||||
if(in_array($role, $at)) {
|
||||
$in[] = "Addresstype.type = '$role'";
|
||||
}
|
||||
}
|
||||
|
||||
$or = "";
|
||||
if(count($in)) {
|
||||
$or = implode(" OR ", $in);
|
||||
$where .= " AND ( $or )";
|
||||
}
|
||||
}
|
||||
|
||||
$or = "";
|
||||
if(count($in)) {
|
||||
$or = implode(" OR ", $in);
|
||||
$where .= " AND ( $or )";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
41
application/Admin/AdminController.php
Normal file
41
application/Admin/AdminController.php
Normal file
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
class AdminController extends mfBaseController {
|
||||
|
||||
protected function init() {
|
||||
$this->needlogin=true;
|
||||
$me = new User();
|
||||
$me->loadMe();
|
||||
$this->me = $me;
|
||||
$this->layout()->set("me",$me);
|
||||
|
||||
if(!$me->is(["Admin"])) {
|
||||
$this->redirect("Dashboard");
|
||||
}
|
||||
}
|
||||
|
||||
protected function indexAction() {
|
||||
$this->layout()->setTemplate("Admin/Index");
|
||||
|
||||
}
|
||||
|
||||
|
||||
protected function createNetworkAddressForNetowner() {
|
||||
$i = 0;
|
||||
foreach(NetworkModel::getAll() as $network) {
|
||||
$netaddress = NetworkAddressModel::getFirst(["network_id" => $network->id, "address_id" => $network->owner_id, "addresstype" => "netowner"]);
|
||||
if(!$netaddress) {
|
||||
$netaddress = NetworkAddressModel::create([
|
||||
'network_id' => $network->id,
|
||||
'address_id' => $network->owner_id,
|
||||
'type' => "netowner"
|
||||
]);
|
||||
$netaddress->save();
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
$this->layout()->setFlash("$i NetworkAddress Objekte angelegt.", "success");
|
||||
$this->redirect("Admin");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -4,20 +4,26 @@ class AddressdbApicontroller extends mfBaseApicontroller {
|
||||
private $campaigns = [];
|
||||
private $filter_salescluster_ids = [];
|
||||
private $campaigns_by_scluster = [];
|
||||
|
||||
private $allowed_preordertypes = [];
|
||||
private $district_is_city = false;
|
||||
private $hausnummer_add_zusatz = false;
|
||||
|
||||
protected function init() {
|
||||
$db = $this->db(ADDRESSDB_DBHOST, ADDRESSDB_DBUSER, ADDRESSDB_DBPASS, ADDRESSDB_DBNAME);
|
||||
|
||||
$this->addRoute("/addressdb/getClusters", "getClusters", "GET");
|
||||
$this->addRoute("/addressdb/findAddress", "find", "GET");
|
||||
$this->addRoute("/addressdb/findAddress", "find", "POST");
|
||||
$this->addRoute("/addressdb/findStreet", "findStreet", "GET");
|
||||
$this->addRoute("/addressdb/searchAddress", "search", "GET");
|
||||
$this->addRoute("/addressdb/searchAddress", "search", "POST");
|
||||
$this->addRoute("/addressdb/findStreet", "findStreet", "GET");
|
||||
$this->addRoute("/addressdb/findStreet", "findStreet", "POST");
|
||||
$this->addRoute("/addressdb/findZip", "findZip", "GET");
|
||||
$this->addRoute("/addressdb/findZip", "findZip", "POST");
|
||||
$this->addRoute("/addressdb/findCity", "findCity", "GET");
|
||||
$this->addRoute("/addressdb/findCity", "findCity", "POST");
|
||||
$this->addRoute("/addressdb/findDistrict", "findDistrict", "GET");
|
||||
$this->addRoute("/addressdb/findDistrict", "findDistrict", "POST");
|
||||
|
||||
$this->allowMissingOrigin = true;
|
||||
}
|
||||
@@ -33,10 +39,7 @@ class AddressdbApicontroller extends mfBaseApicontroller {
|
||||
$this->filter_salescluster_ids[] = $campain_scluster->salescluster_id;
|
||||
}
|
||||
|
||||
if(!array_key_exists($campain_scluster->salescluster_id, $this->campaigns_by_scluster)) {
|
||||
$this->campaigns_by_scluster[$campain_scluster->salescluster_id] = [];
|
||||
}
|
||||
$this->campaigns_by_scluster[$campain_scluster->salescluster_id][] = $campaign->id;
|
||||
$this->campaigns_by_scluster[$campain_scluster->salescluster_id] = $campaign->id;
|
||||
|
||||
}
|
||||
$this->campaigns[$campaign->id] = $campaign;
|
||||
@@ -47,6 +50,14 @@ class AddressdbApicontroller extends mfBaseApicontroller {
|
||||
$this->allowed_preordertypes[] = $type->type;
|
||||
}
|
||||
}
|
||||
|
||||
if($campaign->district_is_city == 1) {
|
||||
$this->district_is_city = true;
|
||||
}
|
||||
|
||||
if($campaign->hausnummer_add_zusatz == 1) {
|
||||
$this->hausnummer_add_zusatz = true;
|
||||
}
|
||||
}
|
||||
|
||||
foreach(PreordercampaignOriginhostnameModel::search(['preordercampaign_id' => $campaign->id]) as $origin) {
|
||||
@@ -61,6 +72,23 @@ class AddressdbApicontroller extends mfBaseApicontroller {
|
||||
|
||||
}
|
||||
|
||||
protected function getClusters() {
|
||||
$cluster_search = [];
|
||||
if(count($this->filter_salescluster_ids)) {
|
||||
$cluster_search['netzgebiet_id'] = $this->filter_salescluster_ids;
|
||||
}
|
||||
$clusters = [];
|
||||
foreach(ADBNetzgebietModel::search($cluster_search) as $cluster) {
|
||||
$c = [];
|
||||
$c['id'] = $cluster->extref;
|
||||
$c['name'] = $cluster->name;
|
||||
$clusters[] = $c;
|
||||
}
|
||||
|
||||
return mfResponse::Ok(["clusters" => $clusters]);
|
||||
|
||||
}
|
||||
|
||||
protected function findCity() {
|
||||
// unofficially supporting GET and POST in v1
|
||||
$get = array_merge($this->post, $this->get);
|
||||
@@ -68,13 +96,15 @@ class AddressdbApicontroller extends mfBaseApicontroller {
|
||||
// search parameter is unofficially deprecated but still supported
|
||||
$search = trim($get['search']);
|
||||
$city = trim($get['city']);
|
||||
$district = trim($get['district']);
|
||||
$zip = trim($get['zip']);
|
||||
$search_cluster_id = trim($get['cluster_id']);
|
||||
|
||||
if(!$city) {
|
||||
$city = $search;
|
||||
}
|
||||
|
||||
if(!$city && !$zip) {
|
||||
if(!$city && !$zip && !$search_cluster_id) {
|
||||
return mfResponse::BadRequest(['message' => "No search parameters"]);
|
||||
}
|
||||
|
||||
@@ -82,12 +112,23 @@ class AddressdbApicontroller extends mfBaseApicontroller {
|
||||
if($zip) {
|
||||
$city_search['plz%'] = $zip;
|
||||
}
|
||||
if($district) {
|
||||
$district_search['ortschaft%'] = $zip;
|
||||
}
|
||||
|
||||
if(count($this->filter_salescluster_ids)) {
|
||||
$city_search['netzgebiet_id'] = $this->filter_salescluster_ids;
|
||||
}
|
||||
|
||||
$results = ADBGemeindeModel::search($city_search);
|
||||
if($search_cluster_id) {
|
||||
$city_search['netzgebiet_extref'] = $search_cluster_id;
|
||||
}
|
||||
|
||||
if($this->district_is_city) {
|
||||
$results = ADBOrtschaftModel::search($city_search);
|
||||
} else {
|
||||
$results = ADBGemeindeModel::search($city_search);
|
||||
}
|
||||
|
||||
|
||||
$cities = [];
|
||||
@@ -99,6 +140,62 @@ class AddressdbApicontroller extends mfBaseApicontroller {
|
||||
return mfResponse::Ok(['cities' => array_values($cities)]);
|
||||
}
|
||||
|
||||
protected function findDistrict() {
|
||||
// unofficially supporting GET and POST in v1
|
||||
$get = array_merge($this->post, $this->get);
|
||||
|
||||
// search parameter is unofficially deprecated but still supported
|
||||
$search = $this->db()->escape(trim($get['search']));
|
||||
$city = $this->db()->escape(trim($get['city']));
|
||||
$district = $this->db()->escape(trim($get['district']));
|
||||
$zip = $this->db()->escape(trim($get['zip']));
|
||||
$search_cluster_id = $this->db()->escape(trim($get['cluster_id']));
|
||||
|
||||
if(!$district) {
|
||||
$district = $search;
|
||||
}
|
||||
/*
|
||||
if(!$city && !$zip && !$district) {
|
||||
return mfResponse::BadRequest(['message' => "No search parameters"]);
|
||||
}*/
|
||||
|
||||
$where = "1=1";
|
||||
|
||||
if($district && $district != "%") {
|
||||
$where .= " AND ortschaft like '$district%'";
|
||||
}
|
||||
if($city && $city != "%") {
|
||||
$where .= " AND gemeinde like '$city%'";
|
||||
}
|
||||
if($zip && $zip != "%") {
|
||||
$where .= " AND plz like '$zip%'";
|
||||
}
|
||||
|
||||
if(count($this->filter_salescluster_ids)) {
|
||||
$where .= " AND netzgebiet_id IN (".join(", ", $this->filter_salescluster_ids).")";
|
||||
}
|
||||
|
||||
if($search_cluster_id) {
|
||||
$where .= " AND netzgebiet_extref='$search_cluster_id'";
|
||||
}
|
||||
|
||||
$cities = [];
|
||||
|
||||
$sql = "SELECT gemeinde, ortschaft FROM view_hausnummer WHERE $where GROUP BY gemeinde,ortschaft_id ORDER BY gemeinde, ortschaft";
|
||||
//echo $sql;exit;
|
||||
$res = $this->db()->query($sql);
|
||||
if($this->db()->num_rows($res)) {
|
||||
while($data = $this->db()->fetch_object($res)) {
|
||||
if(!array_key_exists($data->gemeinde, $cities)) {
|
||||
$cities[$data->gemeinde] = [];
|
||||
}
|
||||
$cities[$data->gemeinde][] = $data->ortschaft;
|
||||
}
|
||||
}
|
||||
|
||||
return mfResponse::Ok(['cities' => $cities]);
|
||||
}
|
||||
|
||||
protected function findZip() {
|
||||
// unofficially supporting GET and POST in v1
|
||||
$get = array_merge($this->post, $this->get);
|
||||
@@ -106,8 +203,9 @@ class AddressdbApicontroller extends mfBaseApicontroller {
|
||||
// search parameter is unofficially deprecated but still supported
|
||||
$search = trim($get['search']);
|
||||
$zip = trim($get['zip']);
|
||||
$search_cluster_id = trim($get['cluster_id']);
|
||||
|
||||
if(!$search && !$zip) {
|
||||
if(!$search && !$zip && !$search_cluster_id) {
|
||||
return mfResponse::BadRequest(['message' => "Searchstring cannot be empty!"]);
|
||||
}
|
||||
|
||||
@@ -116,11 +214,16 @@ class AddressdbApicontroller extends mfBaseApicontroller {
|
||||
}
|
||||
|
||||
$zip_search = ['plzstring%' => $zip];
|
||||
|
||||
//var_dump($this->filter_salescluster_ids);exit;
|
||||
if(count($this->filter_salescluster_ids)) {
|
||||
$zip_search['netzgebiet_id'] = $this->filter_salescluster_ids;
|
||||
}
|
||||
|
||||
if($search_cluster_id) {
|
||||
$zip_search['netzgebiet_extref'] = $search_cluster_id;
|
||||
}
|
||||
|
||||
//var_dump($zip_search);exit;
|
||||
$results = ADBPlzModel::search($zip_search);
|
||||
|
||||
|
||||
@@ -138,12 +241,13 @@ class AddressdbApicontroller extends mfBaseApicontroller {
|
||||
$get = array_merge($this->post, $this->get);
|
||||
|
||||
// search parameter is unofficially deprecated but still supported
|
||||
$search = trim($get['search']);
|
||||
$street = trim($get['street']);
|
||||
$city = trim($get['city']);
|
||||
$zip = trim($get['zip']);
|
||||
$search = $this->db()->escape(trim($get['search']));
|
||||
$street = $this->db()->escape(trim($get['street']));
|
||||
$city = $this->db()->escape(trim($get['city']));
|
||||
$zip = $this->db()->escape(trim($get['zip']));
|
||||
$search_cluster_id = $this->db()->escape(trim($get['cluster_id']));
|
||||
|
||||
if(!$search && !$street && !$city && !$zip) {
|
||||
if(!$search && !$street && !$city && !$zip && !$search_cluster_id) {
|
||||
return mfResponse::BadRequest(['message' => "No search parameters"]);
|
||||
}
|
||||
|
||||
@@ -151,24 +255,37 @@ class AddressdbApicontroller extends mfBaseApicontroller {
|
||||
$street = $search;
|
||||
}
|
||||
|
||||
$street_search = ["name%" => $street];
|
||||
$where = "1=1";
|
||||
$where .= " AND strasse like '$street%'";
|
||||
if($city) {
|
||||
$street_search['gemeinde%'] = $city;
|
||||
if($this->district_is_city) {
|
||||
$where .= " AND ortschaft like '$city%'";
|
||||
} else {
|
||||
$where .= " AND gemeinde like '$city%'";
|
||||
}
|
||||
}
|
||||
if($zip) {
|
||||
$street_search['plz%'] = $zip;
|
||||
$where .= " AND plz like '$zip%'";
|
||||
}
|
||||
|
||||
if(count($this->filter_salescluster_ids)) {
|
||||
$street_search['netzgebiet_id'] = $this->filter_salescluster_ids;
|
||||
$where .= " AND netzgebiet_id IN (".join(", ", $this->filter_salescluster_ids).")";
|
||||
}
|
||||
|
||||
$results = ADBStrasseModel::search($street_search);
|
||||
|
||||
if($search_cluster_id) {
|
||||
$where .= " AND netzgebiet_extref='$search_cluster_id'";
|
||||
}
|
||||
|
||||
$streets = [];
|
||||
foreach($results as $result) {
|
||||
$streets[] = $result->name;
|
||||
|
||||
$sql = "SELECT strasse FROM view_hausnummer WHERE $where GROUP BY strasse ORDER BY strasse";
|
||||
//echo "$sql";exit;
|
||||
$res = $this->db()->query($sql);
|
||||
if($this->db()->num_rows($res)) {
|
||||
while($data = $this->db()->fetch_object($res)) {
|
||||
$streets[] = $data->strasse;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$streets = array_unique($streets);
|
||||
@@ -176,17 +293,396 @@ class AddressdbApicontroller extends mfBaseApicontroller {
|
||||
return mfResponse::Ok(['streets' => array_values($streets)]);
|
||||
}
|
||||
|
||||
protected function search() {
|
||||
$get = array_merge($this->post, $this->get);
|
||||
|
||||
$search = $this->db()->escape(trim($get['search']));
|
||||
|
||||
$format = "flat";
|
||||
if($get['format'] == "tree") {
|
||||
$format = "tree";
|
||||
}
|
||||
|
||||
if(!$search) {
|
||||
return mfResponse::BadRequest(['message' => "Search string cannot be empty"]);
|
||||
}
|
||||
if($search == "%") {
|
||||
return mfResponse::BadRequest(['message' => "Search string cannot be empty"]);
|
||||
}
|
||||
|
||||
/*
|
||||
* try direct search
|
||||
*/
|
||||
/*$m = [];
|
||||
if(preg_match('/^([^,]+)\s+(\d+\w+),\s*(\d+),?\s*(.+)$/', $search, $m)) {
|
||||
if($m[1] && $m[2] && $m[3] && $m[4]) {
|
||||
$dsearch['Strasse.name'] = $this->db()->escape(trim($m[1]));
|
||||
$dsearch['Hausnummer.hausnummer'] = $this->db()->escape(trim($m[2]));
|
||||
$dsearch['Plz.plz'] = $this->db()->escape(trim($m[3]));
|
||||
if($this->district_is_city) {
|
||||
$dsearch['Ortschaft.name'] = $this->db()->escape(trim($m[4]));
|
||||
} else {
|
||||
$dsearch['Gemeinde.name'] = $this->db()->escape(trim($m[4]));
|
||||
}
|
||||
|
||||
$where = "1=1";
|
||||
if(count($this->filter_salescluster_ids)) {
|
||||
$where .= " AND netzgebiet_id IN (".implode(",", $this->filter_salescluster_ids).")";
|
||||
}
|
||||
foreach($dsearch as $field => $value) {
|
||||
$where .= " AND $field = '$value'";
|
||||
}
|
||||
|
||||
$sql = AddressDB::$wohneinheit_query;
|
||||
$sql .= "\n WHERE $where";
|
||||
$this->log->debug($sql);
|
||||
|
||||
$res = $this->db()->query($sql);
|
||||
|
||||
if($this->db()->num_rows($res)) {
|
||||
$address = [];
|
||||
$units = [];
|
||||
$hausnummer_id = false;
|
||||
while($data = $this->db()->fetch_object($res)) {
|
||||
if(!$hausnummer_id) {
|
||||
$hausnummer_id = $data->hausnummer_id;
|
||||
|
||||
// get allowed preorderTypes
|
||||
$ptypes = [];
|
||||
if($data->freigabe) {
|
||||
$freigaben = json_decode($data->freigabe);
|
||||
if(is_array($freigaben) && count($freigaben)) {
|
||||
foreach($freigaben as $freigabe) {
|
||||
if(in_array($freigabe, $this->allowed_preordertypes)) {
|
||||
$ptypes[] = $freigabe;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$housenumber = $data->hausnummer;
|
||||
if($this->hausnummer_add_zusatz) {
|
||||
if($data->zusatz) {
|
||||
$housenumber .= " (".$data->zusatz.")";
|
||||
}
|
||||
}
|
||||
|
||||
$address = [
|
||||
'oaid' => $data->hausnummer_oaid,
|
||||
'cluster_id' => $data->netzgebiet_extref,
|
||||
'zip' => $data->plz,
|
||||
'city' => $data->gemeinde,
|
||||
"municipality" => "",
|
||||
'district' => $data->ortschaft,
|
||||
'street' => $data->strasse,
|
||||
'housenumber' => $housenumber,
|
||||
'lot_number' => $data->grund_nr,
|
||||
'building_unit_count' => 0,
|
||||
'gps_lat' => ($data->gps_lat) ? (float)$data->gps_lat : null,
|
||||
'gps_long' => ($data->gps_long) ? (float)$data->gps_long : null,
|
||||
'rollout_year' => ($data->rollout) ? (int)$data->rollout : null,
|
||||
'rollout_info' => $data->rollout_info,
|
||||
'preorderTypes' => $ptypes,
|
||||
'units' => []
|
||||
];
|
||||
if($this->district_is_city) {
|
||||
$address['city'] = $data->ortschaft;
|
||||
$address['municipality'] = $data->gemeinde;
|
||||
} else {
|
||||
unset($address['municipality']);
|
||||
}
|
||||
}
|
||||
if($hausnummer_id && $hausnummer_id != $data->hausnummer_id) {
|
||||
$address = [];
|
||||
break;
|
||||
}
|
||||
|
||||
$units[] = [
|
||||
'oaid' => $data->wohneinheit_oaid,
|
||||
'num' => (int)$data->num,
|
||||
'block' => $data->block,
|
||||
'stiege' => $data->stiege,
|
||||
'stock' => $data->stock,
|
||||
'tuer' => $data->tuer,
|
||||
'zusatz' => $data->zusatz,
|
||||
];
|
||||
}
|
||||
//var_dump($address, $units);exit;
|
||||
$new_addresses = [];
|
||||
if($address) {
|
||||
if($format == "tree") {
|
||||
$new_address = $address;
|
||||
$new_address['units'] = $units;
|
||||
$new_addresses[] = $address;
|
||||
} else {
|
||||
foreach($units as $unit) {
|
||||
$new_address = $address;
|
||||
unset($new_address['units']);
|
||||
$new_address['building_unit_count'] = count($units);
|
||||
$new_address['num'] = $unit['num'];
|
||||
$new_address['block'] = $unit['block'];
|
||||
$new_address['stiege'] = $unit['stiege'];
|
||||
$new_address['stock'] = $unit['stock'];
|
||||
$new_address['tuer'] = $unit['tuer'];
|
||||
$new_address['zusatz'] = $unit['zusatz'];
|
||||
$new_addresses[] = $new_address;
|
||||
}
|
||||
}
|
||||
|
||||
return mfResponse::Ok(['addresses' => $new_addresses]);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}*/
|
||||
|
||||
/*
|
||||
* do normal search
|
||||
*/
|
||||
$search_parts = [];
|
||||
$search = str_replace(",", "", $search);
|
||||
$tmp_search_parts = explode(" ", $search);
|
||||
$ort_search = $strasse_search = $plz_search = $hausnummer_search = [];
|
||||
|
||||
foreach($tmp_search_parts as $p) {
|
||||
$p = $this->db()->escape(trim($p));
|
||||
if(!$p) continue;
|
||||
if(in_array($p,$search_parts)) continue;
|
||||
$search_parts[] = $p;
|
||||
$gem_search[] = "Gemeinde.name like '$p%'";
|
||||
$ort_search[] = "Ortschaft.name like '$p%'";
|
||||
$strasse_search[] = "Strasse.name like '$p%'";
|
||||
$plz_search[] = "Plz.plz like '$p%'";
|
||||
$hausnummer_search[] = "Hausnummer.hausnummer like '$p%'";
|
||||
}
|
||||
|
||||
$where = "1=1";
|
||||
if(count($this->filter_salescluster_ids)) {
|
||||
$where .= " AND netzgebiet_id IN (".implode(",", $this->filter_salescluster_ids).")";
|
||||
}
|
||||
|
||||
$sql = AddressDB::$wohneinheit_query;
|
||||
$sql .= "\n WHERE $where AND ((".implode(" OR ", $ort_search).") OR (".implode(" OR ", $strasse_search).") OR (".implode(" OR ", $plz_search).") OR (".implode(" OR ", $hausnummer_search).")) ORDER BY strasse, LENGTH(hausnummer), hausnummer, LENGTH(tuer),tuer, zusatz, LENGTH(num), num";
|
||||
|
||||
//$sql = "SELECT * FROM view_wohneinheit WHERE $where AND ((".implode(" OR ", $ort_search).") OR (".implode(" OR ", $strasse_search).") OR (".implode(" OR ", $plz_search).") OR (".implode(" OR ", $hausnummer_search).")) ORDER BY strasse, LENGTH(hausnummer), hausnummer, LENGTH(tuer),tuer, zusatz, LENGTH(num), num";
|
||||
$this->log->debug($sql);
|
||||
|
||||
$res = $this->db()->query($sql);
|
||||
|
||||
|
||||
|
||||
if($this->db()->num_rows($res)) {
|
||||
$tmp_addresses = [];
|
||||
while($data = $this->db()->fetch_object($res)) {
|
||||
$address_key = $data->hausnummer_id;
|
||||
if($this->hausnummer_add_zusatz) {
|
||||
$address_key = $data->hausnummer_id."-".$data->zusatz;
|
||||
}
|
||||
//$sort_key = $data->plz." ".$data->gemeinde." ".$data->ortschaft." ".$data->strasse." ".$data->hausnummer." ".$data->zusatz;
|
||||
$sort_key = $data->plz." ".$data->gemeinde." ".$data->ortschaft." ".$data->strasse." ".$data->hausnummer." ".$data->zusatz;
|
||||
if(!array_key_exists($address_key, $tmp_addresses)) {
|
||||
|
||||
// get allowed preorderTypes
|
||||
$ptypes = [];
|
||||
if($data->freigabe) {
|
||||
$freigaben = json_decode($data->freigabe);
|
||||
if(is_array($freigaben) && count($freigaben)) {
|
||||
foreach($freigaben as $freigabe) {
|
||||
if(in_array($freigabe, $this->allowed_preordertypes)) {
|
||||
$ptypes[] = $freigabe;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$housenumber = $data->hausnummer;
|
||||
if($this->hausnummer_add_zusatz) {
|
||||
if($data->zusatz) {
|
||||
$housenumber .= " (".$data->zusatz.")";
|
||||
}
|
||||
}
|
||||
|
||||
$tmp_addresses[$address_key] = [
|
||||
'sort_key' => $sort_key,
|
||||
'oaid' => $data->hausnummer_oaid,
|
||||
'cluster_id' => $data->netzgebiet_extref,
|
||||
'zip' => $data->plz,
|
||||
'city' => $data->gemeinde,
|
||||
"municipality" => "",
|
||||
'district' => $data->ortschaft,
|
||||
'street' => $data->strasse,
|
||||
'housenumber' => $housenumber,
|
||||
'lot_number' => $data->grund_nr,
|
||||
'building_unit_count' => 0,
|
||||
'gps_lat' => ($data->gps_lat) ? (float)$data->gps_lat : null,
|
||||
'gps_long' => ($data->gps_long) ? (float)$data->gps_long : null,
|
||||
'rollout_year' => ($data->rollout) ? (int)$data->rollout : null,
|
||||
'rollout_info' => $data->rollout_info,
|
||||
'preorderTypes' => $ptypes,
|
||||
'units' => []
|
||||
];
|
||||
if($this->district_is_city) {
|
||||
$tmp_addresses[$address_key]['city'] = $data->ortschaft;
|
||||
$tmp_addresses[$address_key]['municipality'] = $data->gemeinde;
|
||||
} else {
|
||||
unset($tmp_addresses[$address_key]['municipality']);
|
||||
}
|
||||
}
|
||||
|
||||
$tmp_addresses[$address_key]['units'][] = [
|
||||
'oaid' => $data->wohneinheit_oaid,
|
||||
'num' => (int)$data->num,
|
||||
'block' => $data->block,
|
||||
'stiege' => $data->stiege,
|
||||
'stock' => $data->stock,
|
||||
'tuer' => $data->tuer,
|
||||
'zusatz' => $data->zusatz,
|
||||
];
|
||||
$tmp_addresses[$address_key]['building_unit_count']++;
|
||||
//if($data->hausnummer_oaid == "AT-8940-30400d5c") var_dump($data);
|
||||
}
|
||||
//exit;
|
||||
//var_dump($tmp_addresses);exit;
|
||||
// sort found addresses by count of found keywords
|
||||
// if there is an int we don't want to show more than one street
|
||||
$sorted_addresses = [];
|
||||
foreach($tmp_addresses as $temp_add) {
|
||||
$includes_int = false;
|
||||
$count = 0;
|
||||
$count_parts = 0;
|
||||
$uniq_parts_count = 0;
|
||||
$uniq_parts_found = [];
|
||||
/*if($temp_add['oaid'] == "AT-8940-30400d5c") {
|
||||
var_dump($temp_add);
|
||||
}*/
|
||||
foreach($search_parts as $p) {
|
||||
$p = $this->db->escape(trim($p));
|
||||
if(strlen($p) === 0) continue;
|
||||
$uniq_parts_count++;
|
||||
if(is_numeric(($p))) {
|
||||
$includes_int = true;
|
||||
$count_parts++;
|
||||
if(substr_count(strtolower($temp_add['sort_key']), strtolower($p))) {
|
||||
$count++;
|
||||
}
|
||||
if(!in_array($p, $uniq_parts_found)) {
|
||||
$uniq_parts_found[] = $p;
|
||||
}
|
||||
} else {
|
||||
$p_count = substr_count(strtolower($temp_add['sort_key']), strtolower($p));
|
||||
if($p_count) {
|
||||
$count += $p_count;
|
||||
$count_parts++;
|
||||
if(!in_array($p, $uniq_parts_found)) {
|
||||
$uniq_parts_found[] = $p;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
unset($temp_add['sort_key']);
|
||||
if($includes_int && (($count + 1) - count($search_parts) ) < 1) {
|
||||
continue;
|
||||
}
|
||||
|
||||
//var_dump(count($search_parts), $count, $count_parts, $temp_add);
|
||||
|
||||
/*if($temp_add['oaid'] == "AT-8954-d6c41665") {
|
||||
echo $temp_add['sort_key'].": AT-8954-d6c41665: count $count; uniq_parts_count $uniq_parts_count; count_parts $count_parts; search_parts ".count($search_parts)."<br /><br />\n";
|
||||
//var_dump();
|
||||
//exit;
|
||||
}*/
|
||||
|
||||
if($count_parts == count($search_parts)) {
|
||||
$count += 50;
|
||||
}
|
||||
|
||||
if($uniq_parts_count <= count($uniq_parts_found)) {
|
||||
if(!array_key_exists($count, $sorted_addresses)) {
|
||||
$sorted_addresses[$count] = [];
|
||||
}
|
||||
$sorted_addresses[$count][] = $temp_add;
|
||||
}
|
||||
}
|
||||
//exit;
|
||||
|
||||
|
||||
ksort($sorted_addresses, SORT_NUMERIC);
|
||||
$sorted_addresses = array_reverse($sorted_addresses, true);
|
||||
//var_dump($sorted_addresses);exit;
|
||||
|
||||
// sort / format
|
||||
if($format == "tree") {
|
||||
foreach($sorted_addresses as $counted_addresses) {
|
||||
foreach($counted_addresses as $cadd) {
|
||||
$addresses[] = $cadd;
|
||||
}
|
||||
}
|
||||
//var_dump($addresses);exit;
|
||||
//$addresses = array_values($sorted_addresses);
|
||||
|
||||
if(!$addresses) $addresses = [];
|
||||
} else {
|
||||
foreach($sorted_addresses as $counted_addresses) {
|
||||
foreach($counted_addresses as $ta) {
|
||||
foreach($ta['units'] as $u) {
|
||||
$new_address = [];
|
||||
$new_address['oaid'] = $u['oaid'];
|
||||
$new_address['building_oaid'] = $ta['oaid'];
|
||||
$new_address['cluster_id'] = $ta['cluster_id'];
|
||||
$new_address['street'] = $ta['street'];
|
||||
$new_address['housenumber'] = $ta['housenumber'];
|
||||
$new_address['zip'] = $ta['zip'];
|
||||
$new_address['city'] = $ta['city'];
|
||||
if(array_key_exists("municipality", $ta)) {
|
||||
$new_address['municipality'] = $ta['municipality'];
|
||||
}
|
||||
$new_address['district'] = $ta['district'];
|
||||
$new_address['lot_number'] = $ta['lot_number'];
|
||||
$new_address['building_unit_count'] = $ta['building_unit_count'];
|
||||
$new_address['num'] = $u['num'];
|
||||
$new_address['block'] = $u['block'];
|
||||
$new_address['stiege'] = $u['stiege'];
|
||||
$new_address['stock'] = $u['stock'];
|
||||
$new_address['tuer'] = $u['tuer'];
|
||||
$new_address['zusatz'] = $u['zusatz'];
|
||||
$new_address['gps_lat'] = $ta['gps_lat'];
|
||||
$new_address['gps_long'] = $ta['gps_long'];
|
||||
$new_address['rollout_year'] = $ta['rollout_year'];
|
||||
$new_address['rollout_info'] = $ta['rollout_info'];
|
||||
$new_address['preorderTypes'] = $ta['preorderTypes'];
|
||||
|
||||
$addresses[] = $new_address;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return mfResponse::Ok(['addresses' => $addresses]);
|
||||
}
|
||||
|
||||
protected function find() {
|
||||
// unofficially supporting GET and POST in v1
|
||||
$get = array_merge($this->post, $this->get);
|
||||
|
||||
$search_cluster_id = $this->db()->escape(trim($get['cluster_id']));
|
||||
$search_street = $this->db()->escape(trim($get['street']));
|
||||
$search_zip = $this->db()->escape(trim($get['zip']));
|
||||
$search_district = $this->db()->escape(trim($get['district']));
|
||||
$search_city = $this->db()->escape(trim($get['city']));
|
||||
$search_housenumber = $this->db()->escape(trim($get['housenumber']));
|
||||
|
||||
$format = "flat";
|
||||
if($get['format'] == "tree") {
|
||||
$format = "tree";
|
||||
}
|
||||
|
||||
if(!$search_street) {
|
||||
if(!$search_street && !$search_cluster_id) {
|
||||
return mfResponse::BadRequest(['message' => "Searchstring cannot be empty!"]);
|
||||
}
|
||||
|
||||
@@ -194,54 +690,148 @@ class AddressdbApicontroller extends mfBaseApicontroller {
|
||||
|
||||
$where = "1=1";
|
||||
|
||||
if($search_zip) {
|
||||
$where .= " AND plz like '%$search_zip%'";
|
||||
if($search_zip && $search_zip != "%") {
|
||||
$where .= " AND Plz.plz like '$search_zip%'";
|
||||
}
|
||||
if($search_city) {
|
||||
$where .= " AND gemeinde like '%$search_city%'";
|
||||
if($search_district && $search_district != "%") {
|
||||
$where .= " AND Ortschaft.name like '$search_district%'";
|
||||
}
|
||||
if($search_street) {
|
||||
$where .= " AND strasse like '%$search_street%'";
|
||||
if($search_city && $search_city != "%") {
|
||||
if($this->district_is_city) {
|
||||
$where .= " AND Ortschaft.name like '$search_city%'";
|
||||
} else {
|
||||
$where .= " AND Gemeinde.name like '$search_city%'";
|
||||
}
|
||||
}
|
||||
if($search_housenumber) {
|
||||
$where .= " AND hausnummer like '%$search_housenumber%'";
|
||||
if($search_street && $search_street != "%") {
|
||||
$where .= " AND Strasse.name like '$search_street%'";
|
||||
}
|
||||
|
||||
$sql = "SELECT * FROM view_wohneinheit WHERE $where ORDER BY plz, gemeinde, ortschaft, strasse, LENGTH(hausnummer), hausnummer, block, stiege, stock, LENGTH(tuer), tuer";
|
||||
if($search_housenumber && $search_housenumber != "%") {
|
||||
$where .= " AND Hausnummer.hausnummer like '$search_housenumber%'";
|
||||
}
|
||||
|
||||
if(count($this->filter_salescluster_ids)) {
|
||||
$where .= " AND Hausnummer.netzgebiet_id IN (".implode(",", $this->filter_salescluster_ids).")";
|
||||
}
|
||||
if($search_cluster_id) {
|
||||
$where .= " AND Netzgebiet.extref='$search_cluster_id'";
|
||||
}
|
||||
//echo $where;
|
||||
//var_dump($this->filter_salescluster_ids);exit;
|
||||
|
||||
$sql = AddressDB::$wohneinheit_query;
|
||||
$sql .= "\n WHERE $where ORDER BY plz, gemeinde, ortschaft, strasse, LENGTH(hausnummer), hausnummer, block, stiege, stock, LENGTH(num), num, LENGTH(tuer), tuer";
|
||||
|
||||
//$sql = "SELECT * FROM view_wohneinheit WHERE $where ORDER BY plz, gemeinde, ortschaft, strasse, LENGTH(hausnummer), hausnummer, block, stiege, stock, LENGTH(num), num, LENGTH(tuer), tuer";
|
||||
$this->log->debug($sql);
|
||||
$res = $this->db()->query($sql);
|
||||
|
||||
if($this->db()->num_rows($res)) {
|
||||
while($data = $this->db()->fetch_object($res)) {
|
||||
|
||||
// get allowed preorderTypes
|
||||
$ptypes = [];
|
||||
if($data->freigabe) {
|
||||
$freigaben = json_decode($data->freigabe);
|
||||
if(is_array($freigaben) && count($freigaben)) {
|
||||
foreach($freigaben as $freigabe) {
|
||||
if(in_array($freigabe, $this->allowed_preordertypes)) {
|
||||
$ptypes[] = $freigabe;
|
||||
$tmp_addresses = [];
|
||||
while($data = $this->db()->fetch_object($res)) {
|
||||
$address_key = $data->hausnummer_id;
|
||||
if($this->hausnummer_add_zusatz) {
|
||||
$address_key = $data->hausnummer_id."-".$data->zusatz;
|
||||
}
|
||||
if(!array_key_exists($address_key, $tmp_addresses)) {
|
||||
|
||||
// get allowed preorderTypes
|
||||
$ptypes = [];
|
||||
if($data->freigabe) {
|
||||
$freigaben = json_decode($data->freigabe);
|
||||
if(is_array($freigaben) && count($freigaben)) {
|
||||
foreach($freigaben as $freigabe) {
|
||||
if(in_array($freigabe, $this->allowed_preordertypes)) {
|
||||
$ptypes[] = $freigabe;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$housenumber = $data->hausnummer;
|
||||
if($this->hausnummer_add_zusatz) {
|
||||
if($data->zusatz) {
|
||||
$housenumber .= " (".$data->zusatz.")";
|
||||
}
|
||||
}
|
||||
|
||||
$tmp_addresses[$address_key] = [
|
||||
'oaid' => $data->hausnummer_oaid,
|
||||
'cluster_id' => $data->netzgebiet_extref,
|
||||
'zip' => $data->plz,
|
||||
'city' => $data->gemeinde,
|
||||
"municipality" => "",
|
||||
'district' => $data->ortschaft,
|
||||
'street' => $data->strasse,
|
||||
'housenumber' => $housenumber,
|
||||
'lot_number' => $data->grund_nr,
|
||||
'building_unit_count' => 0,
|
||||
'gps_lat' => ($data->gps_lat) ? (float)$data->gps_lat : null,
|
||||
'gps_long' => ($data->gps_long) ? (float)$data->gps_long : null,
|
||||
'rollout_year' => ($data->rollout) ? (int)$data->rollout : null,
|
||||
'rollout_info' => $data->rollout_info,
|
||||
'preorderTypes' => $ptypes,
|
||||
'units' => []
|
||||
];
|
||||
if($this->district_is_city) {
|
||||
$tmp_addresses[$address_key]['city'] = $data->ortschaft;
|
||||
$tmp_addresses[$address_key]['municipality'] = $data->gemeinde;
|
||||
} else {
|
||||
unset($tmp_addresses[$address_key]['municipality']);
|
||||
}
|
||||
}
|
||||
|
||||
$tmp_addresses[$address_key]['units'][] = [
|
||||
'oaid' => $data->wohneinheit_oaid,
|
||||
'num' => (int)$data->num,
|
||||
'block' => $data->block,
|
||||
'stiege' => $data->stiege,
|
||||
'stock' => $data->stock,
|
||||
'tuer' => $data->tuer,
|
||||
'zusatz' => $data->zusatz,
|
||||
];
|
||||
$tmp_addresses[$address_key]['building_unit_count']++;
|
||||
|
||||
}
|
||||
if($format == "tree") {
|
||||
/*foreach($tmp_addresses as $ta) {
|
||||
$addresses[] = $ta;
|
||||
}*/
|
||||
$addresses = array_values($tmp_addresses);
|
||||
} else {
|
||||
foreach($tmp_addresses as $ta) {
|
||||
foreach($ta['units'] as $u) {
|
||||
$new_address = [];
|
||||
$new_address['oaid'] = $u['oaid'];
|
||||
$new_address['building_oaid'] = $ta['oaid'];
|
||||
$new_address['cluster_id'] = $ta['cluster_id'];
|
||||
$new_address['street'] = $ta['street'];
|
||||
$new_address['housenumber'] = $ta['housenumber'];
|
||||
$new_address['zip'] = $ta['zip'];
|
||||
$new_address['city'] = $ta['city'];
|
||||
if(array_key_exists("municipality", $ta)) {
|
||||
$new_address['municipality'] = $ta['municipality'];
|
||||
}
|
||||
$new_address['district'] = $ta['district'];
|
||||
$new_address['lot_number'] = $ta['lot_number'];
|
||||
$new_address['building_unit_count'] = $ta['building_unit_count'];
|
||||
$new_address['num'] = $u['num'];
|
||||
$new_address['block'] = $u['block'];
|
||||
$new_address['stiege'] = $u['stiege'];
|
||||
$new_address['stock'] = $u['stock'];
|
||||
$new_address['tuer'] = $u['tuer'];
|
||||
$new_address['zusatz'] = $u['zusatz'];
|
||||
$new_address['gps_lat'] = $ta['gps_lat'];
|
||||
$new_address['gps_long'] = $ta['gps_long'];
|
||||
$new_address['rollout_year'] = $ta['rollout_year'];
|
||||
$new_address['rollout_info'] = $ta['rollout_info'];
|
||||
$new_address['preorderTypes'] = $ta['preorderTypes'];
|
||||
|
||||
$addresses[] = $new_address;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$addresses[] = [
|
||||
'zip' => $data->plz,
|
||||
'city' => $data->gemeinde,
|
||||
'street' => $data->strasse,
|
||||
'housenumber' => $data->hausnummer,
|
||||
'block' => $data->block,
|
||||
'stock' => $data->stock,
|
||||
'stiege' => $data->stiege,
|
||||
'tuer' => $data->tuer,
|
||||
'zusatz' => $data->zusatz,
|
||||
'gps_lat' => $data->gps_lat,
|
||||
'gps_long' => $data->gps_long,
|
||||
'rollout_year' => ($data->rollout) ? (int)$data->rollout : null,
|
||||
'preorderTypes' => $ptypes
|
||||
];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return mfResponse::Ok(['addresses' => $addresses]);
|
||||
|
||||
@@ -10,12 +10,18 @@ class PreorderApicontroller extends mfBaseApicontroller {
|
||||
private $campaigns_by_scluster = [];
|
||||
|
||||
private $allowed_preordertypes = [];
|
||||
|
||||
private $district_is_city = false;
|
||||
private $hausnummer_add_zusatz = false;
|
||||
private $exist_is_error = false;
|
||||
private $require_connectiontype = false;
|
||||
private $allow_unit_update = false;
|
||||
|
||||
protected function init() {
|
||||
$db = $this->db(ADDRESSDB_DBHOST, ADDRESSDB_DBUSER, ADDRESSDB_DBPASS, ADDRESSDB_DBNAME);
|
||||
|
||||
$this->addRoute("/preorder", "submitPreorder", "POST");
|
||||
$this->addRoute("/preorder/:code", "getPreorder", "GET");
|
||||
$this->addRoute("/preorder/:code", "cancelPreorder", "DELETE");
|
||||
|
||||
$this->allowMissingOrigin = true;
|
||||
}
|
||||
@@ -42,7 +48,26 @@ class PreorderApicontroller extends mfBaseApicontroller {
|
||||
$this->allowed_preordertypes[] = $type->type;
|
||||
}
|
||||
}
|
||||
|
||||
if($campaign->district_is_city == 1) {
|
||||
$this->district_is_city = true;
|
||||
}
|
||||
if($campaign->hausnummer_add_zusatz == 1) {
|
||||
$this->hausnummer_add_zusatz = true;
|
||||
}
|
||||
if($campaign->exist_is_error == 1) {
|
||||
$this->exist_is_error = true;
|
||||
}
|
||||
if($campaign->require_connectiontype == 1) {
|
||||
$this->require_connectiontype = true;
|
||||
}
|
||||
if($campaign->allow_unit_update == 1) {
|
||||
$this->allow_unit_update = true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
foreach(PreordercampaignOriginhostnameModel::search(['preordercampaign_id' => $campaign->id]) as $origin) {
|
||||
$this->addAllowedOrigin($origin->hostname);
|
||||
@@ -54,7 +79,76 @@ class PreorderApicontroller extends mfBaseApicontroller {
|
||||
//var_dump($campaign, $this->allowed_origins);exit;
|
||||
}
|
||||
|
||||
protected function getPreorder($code) {
|
||||
$code = trim(strtoupper($code));
|
||||
if(!$code) {
|
||||
return mfResponse::NotFound(["message" => "Preorder not found"]);
|
||||
}
|
||||
|
||||
$preorder = PreorderModel::getFirst(['ucode' => $code]);
|
||||
if(!$preorder) {
|
||||
// try oan id
|
||||
$preorder = PreorderModel::getFirst(['oaid' => $code]);
|
||||
if(!$preorder) {
|
||||
return mfResponse::NotFound(["message" => "Preorder not found"]);
|
||||
}
|
||||
}
|
||||
|
||||
if($preorder->partner_id != $this->me->address_id) {
|
||||
return mfResponse::NotFound(["message" => "Preorder not found"]);
|
||||
}
|
||||
|
||||
$return = $preorder->getApiArray();
|
||||
if(!$return) {
|
||||
return mfResponse::NotFound(["message" => "Preorder not found"]);
|
||||
}
|
||||
|
||||
|
||||
return mfResponse::Ok($return);
|
||||
|
||||
}
|
||||
|
||||
protected function cancelPreorder($code) {
|
||||
$code = trim(strtoupper($code));
|
||||
if(!$code) {
|
||||
return mfResponse::NotFound(["message" => "Preorder not found"]);
|
||||
}
|
||||
|
||||
$preorder = PreorderModel::getFirst(['ucode' => $code, 'partner_id' => $this->me->address_id, 'deleted' => 0, '<status_code' => 800]);
|
||||
if(!$preorder) {
|
||||
// try oan id
|
||||
$preorder = PreorderModel::getFirst(['oaid' => $code, 'partner_id' => $this->me->address_id, 'deleted' => 0, '<status_code' => 800]);
|
||||
if(!$preorder) {
|
||||
return mfResponse::NotFound(["message" => "Preorder not found or cancelled already"]);
|
||||
}
|
||||
}
|
||||
|
||||
// check if user owns preorder
|
||||
if($preorder->partner_id != $this->me->address_id) {
|
||||
return mfResponse::Forbidden(["message" => "Permission denied"]);
|
||||
}
|
||||
|
||||
if($preorder->cancel_request) {
|
||||
if($preorder->cancel_approved) {
|
||||
return mfResponse::Forbidden(["message" => "Order already cancelled"]);
|
||||
} else {
|
||||
return mfResponse::Forbidden(["message" => "Cancellation request was already submitted"]);
|
||||
}
|
||||
}
|
||||
|
||||
// set cancel_date and canceller
|
||||
$preorder->cancel_request = date('U');
|
||||
$preorder->cancel_request_by = $this->me->id;
|
||||
if(!$preorder->save()) {
|
||||
return mfResponse::InternalServerError();
|
||||
}
|
||||
|
||||
return mfResponse::Ok(['message' => "Cancellation request submited"]);
|
||||
|
||||
}
|
||||
|
||||
protected function submitPreorder() {
|
||||
//var_dump($this->post);exit;
|
||||
if(!$this->campaigns) {
|
||||
$this->log->debug("disallowed request because no campaign for apikey");
|
||||
return mfResponse::Forbidden();
|
||||
@@ -65,7 +159,7 @@ class PreorderApicontroller extends mfBaseApicontroller {
|
||||
return mfResponse::BadRequest(["message" => "Invalid preorderType"]);
|
||||
}
|
||||
|
||||
$connection_type = false;
|
||||
$connection_type = null;
|
||||
switch($this->post['connectionType']) {
|
||||
case "single-dwelling":
|
||||
$connection_type = "single-dwelling";
|
||||
@@ -83,7 +177,9 @@ class PreorderApicontroller extends mfBaseApicontroller {
|
||||
$connection_type = "business";
|
||||
break;
|
||||
default:
|
||||
return mfResponse::BadRequest(["message" => "Invalid connectionType"]);
|
||||
if($this->require_connectiontype) {
|
||||
return mfResponse::BadRequest(["message" => "Invalid connectionType"]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -95,7 +191,12 @@ class PreorderApicontroller extends mfBaseApicontroller {
|
||||
return mfResponse::BadRequest(['message' => "customer data missing"]);
|
||||
}
|
||||
|
||||
/*
|
||||
$is_additional_order = false;
|
||||
if(array_key_exists("isAdditionalOrder", $this->post) && $this->post['isAdditionalOrder']) {
|
||||
$is_additional_order = true;
|
||||
}
|
||||
|
||||
/************************************************************
|
||||
* check address
|
||||
*/
|
||||
if(!property_exists($this->post['address'],"street") || !$this->post['address']->street ||
|
||||
@@ -106,20 +207,48 @@ class PreorderApicontroller extends mfBaseApicontroller {
|
||||
return mfResponse::BadRequest(['message' => "Mandatory address fields missing"]);
|
||||
}
|
||||
|
||||
$shipping_address = "customer";
|
||||
if(property_exists($this->post['address'], "is_shipping") && $this->post['address']->is_shipping) {
|
||||
$shipping_address = "address";
|
||||
}
|
||||
|
||||
$address_search = [];
|
||||
foreach(['street' => 'strasse','housenumber' => "hausnummer",'zip' => "plz",'city' => "gemeinde"] as $key => $field_name) {
|
||||
$address_search_fields = [
|
||||
'street' => 'strasse',
|
||||
'housenumber' => "hausnummer",
|
||||
'zip' => "plz"
|
||||
];
|
||||
if($this->district_is_city) {
|
||||
$address_search_fields['city'] = "ortschaft";
|
||||
} else {
|
||||
$address_search_fields['city'] = "gemeinde";
|
||||
}
|
||||
|
||||
foreach($address_search_fields as $key => $field_name) {
|
||||
if(property_exists($this->post['address'], $key)) {
|
||||
$address_search[$field_name] = $this->db()->escape(trim($this->post['address']->$key));
|
||||
}
|
||||
}
|
||||
|
||||
$zusatz = false;
|
||||
if($this->hausnummer_add_zusatz) {
|
||||
$m = [];
|
||||
if(preg_match('/^(.*) \((.+)\)$/', trim($address_search['hausnummer']), $m)) {
|
||||
$address_search['hausnummer'] = $this->db()->escape($m[1]);
|
||||
$zusatz = $m[2];
|
||||
}
|
||||
}
|
||||
|
||||
$unit_search = [];
|
||||
foreach(['block','stiege','stock','tuer'] as $key) {
|
||||
foreach(['block','stiege','stock','tuer','unit_string'] as $key) {
|
||||
if(property_exists($this->post['address'], $key) && trim($this->post['address']->$key)) {
|
||||
$unit_search[$key] = trim($this->post['address']->$key);
|
||||
}
|
||||
}
|
||||
|
||||
if($zusatz) {
|
||||
$unit_search['zusatz'] = $zusatz;
|
||||
}
|
||||
|
||||
/*
|
||||
* check customer
|
||||
*/
|
||||
@@ -134,7 +263,7 @@ class PreorderApicontroller extends mfBaseApicontroller {
|
||||
return mfResponse::BadRequest(['message' => "Mandatory customer fields missing"]);
|
||||
}
|
||||
|
||||
/*
|
||||
/**************************************************************
|
||||
* search address in AddressDB
|
||||
*/
|
||||
$where = "1=1 ";
|
||||
@@ -148,54 +277,83 @@ class PreorderApicontroller extends mfBaseApicontroller {
|
||||
}
|
||||
|
||||
$sql = "SELECT * FROM view_hausnummer WHERE $where";
|
||||
$this->log->debug($sql);
|
||||
$res = $this->db()->query($sql);
|
||||
if(!$this->db()->num_rows($res)) {
|
||||
//var_dump($this->db()->num_rows($res), $this->db()->fetch_object($res));
|
||||
return mfResponse::NotFound(['message' => "Adresse nicht gefunden"]);
|
||||
}
|
||||
|
||||
$address = $this->db()->fetch_object($res);
|
||||
//var_dump($address);exit;
|
||||
|
||||
|
||||
/*
|
||||
/* **************************************************************
|
||||
* search wohneinheit
|
||||
*/
|
||||
$update_unit = false;
|
||||
$assign_unit = false;
|
||||
$where = "1=1 ";
|
||||
$unit = false;
|
||||
if(count($unit_search)) {
|
||||
foreach($unit_search as $field => $value) {
|
||||
if($field == "stock" || $field == "stiege") continue; // only check for block and tuer
|
||||
$where .= " AND `$field` = '$value'";
|
||||
//var_dump($unit_search);exit;
|
||||
if(array_key_exists("unit_string", $unit_search)) {
|
||||
$where .= " AND bezeichner LIKE '".$unit_search['unit_string']."'";
|
||||
} else {
|
||||
foreach($unit_search as $field => $value) {
|
||||
if($field == "stock") continue; // only check for block, stiege and tuer
|
||||
$where .= " AND `$field` = '$value'";
|
||||
}
|
||||
}
|
||||
|
||||
// filter salesclusters
|
||||
if(count($this->filter_salescluster_ids)) {
|
||||
$where .= " AND netzgebiet_id IN (".implode(',', $this->filter_salescluster_ids).")";
|
||||
}
|
||||
|
||||
$sql = "SELECT * FROM view_wohneinheit WHERE 1=1 $where AND hausnummer_id=".$address->hausnummer_id;
|
||||
$sql = "SELECT * FROM view_wohneinheit WHERE $where AND hausnummer_id=".$address->hausnummer_id;
|
||||
$this->log->debug($sql);
|
||||
$res = $this->db()->query($sql);
|
||||
if($this->db()->num_rows($res)) {
|
||||
$unit = $this->db()->fetch_object($res);
|
||||
//return mfResponse::NotFound(['message' => "Wohneinheit nicht gefunden"]);
|
||||
} else {
|
||||
$update_unit = true;
|
||||
}
|
||||
//var_dump($this->db()->num_rows($res), $this->db()->fetch_object($res));
|
||||
} else {
|
||||
// if all unit values are empty try to find the unit with all empty values
|
||||
// failure is not an error, but must be checked by a human at some point
|
||||
|
||||
$where = "hausnummer_id=".$address->hausnummer_id." AND (block = '' OR block IS NULL) AND (stiege = '' OR stiege IS NULL) AND (stock = '' OR stock IS NULL) AND (tuer = '' OR tuer IS NULL)";
|
||||
$where = "hausnummer_id=".$address->hausnummer_id." AND (block = '' OR block IS NULL) AND (stiege = '' OR stiege IS NULL) AND (stock = '' OR stock IS NULL) AND (tuer = '' OR tuer IS NULL) AND (bezeichner = '' OR bezeichner IS NULL)";
|
||||
if($zusatz) {
|
||||
$where .= " AND zusatz='$zusatz'";
|
||||
} else {
|
||||
$where .= " AND (zusatz = '' OR zusatz IS NULL)";
|
||||
}
|
||||
// filter salesclusters
|
||||
if(count($this->filter_salescluster_ids)) {
|
||||
$where .= " AND netzgebiet_id IN (".implode(',', $this->filter_salescluster_ids).")";
|
||||
}
|
||||
|
||||
$sql = "SELECT * FROM view_wohneinheit WHERE $where";
|
||||
$this->log->debug($sql);
|
||||
$res = $this->db()->query($sql);
|
||||
if($this->db()->num_rows($res)) {
|
||||
$unit = $this->db()->fetch_object($res);
|
||||
} else {
|
||||
// XXX
|
||||
//$assign_unit = true;
|
||||
}
|
||||
}
|
||||
|
||||
if($this->exist_is_error && !$is_additional_order) {
|
||||
/*
|
||||
* check if there is an existing preorder for this unit already
|
||||
*/
|
||||
if($unit && $unit->wohneinheit_id) {
|
||||
$existing_preorder = PreorderModel::getFirst(['adb_wohneinheit_id' => $unit->wohneinheit_id, 'deleted' => 0]);
|
||||
if($existing_preorder) {
|
||||
return mfResponse::Forbidden(['message' => "Für diese Wohneinheit liegt bereits eine Bestellung vor"]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$address_info = $this->db()->escape(trim($this->post['address_info']));
|
||||
|
||||
// get correct campaign by salescluster
|
||||
@@ -206,6 +364,10 @@ class PreorderApicontroller extends mfBaseApicontroller {
|
||||
$campaign_id = $this->campaigns_by_scluster[$address->netzgebiet_id];
|
||||
$this->campaign = new Preordercampaign($campaign_id);
|
||||
|
||||
if($this->campaign->from > date('U') || $this->campaign->to < date('U')) {
|
||||
return mfResponse::Forbidden(['message' => "Bestellung in diesem Netzgebiet/Cluster nicht erlaubt"]);
|
||||
}
|
||||
|
||||
/*
|
||||
* build fields
|
||||
*/
|
||||
@@ -219,13 +381,18 @@ class PreorderApicontroller extends mfBaseApicontroller {
|
||||
$preorder_data['submit_request'] = $this->request_json;
|
||||
}
|
||||
$preorder_data['adb_hausnummer_id'] = $address->hausnummer_id;
|
||||
$preorder_data['partner_id'] = $this->me->address_id;
|
||||
|
||||
if($unit) {
|
||||
$preorder_data['adb_wohneinheit_id'] = $unit->wohneinheit_id;
|
||||
$preorder_data['oaid'] = $unit->wohneinheit_oaid;
|
||||
}
|
||||
if($address_info) {
|
||||
$preorder_data['address_info'] = $address_info;
|
||||
}
|
||||
if(property_exists($this->post['address'],"district") && $this->post['address']->district) {
|
||||
$preorder_data['address_district'] = $this->post['address']->district;
|
||||
}
|
||||
|
||||
if($this->post['acceptAgb'] === true) {
|
||||
$preorder_data['accept_agb'] = 1;
|
||||
@@ -240,6 +407,14 @@ class PreorderApicontroller extends mfBaseApicontroller {
|
||||
$preorder_data['accept_withdrawal'] = 1;
|
||||
}
|
||||
|
||||
if($is_additional_order) {
|
||||
$preorder_data['is_additional_order'] = 1;
|
||||
} else {
|
||||
$preorder_data['is_additional_order'] = 0;
|
||||
}
|
||||
$preorder_data['technology'] = ($this->post['technology']) ? $this->post['technology'] : null;
|
||||
$preorder_data['patchposition'] = ($this->post['patchposition']) ? $this->post['patchposition'] : null;
|
||||
|
||||
/*
|
||||
* setup price
|
||||
*/
|
||||
@@ -281,9 +456,9 @@ class PreorderApicontroller extends mfBaseApicontroller {
|
||||
/*
|
||||
* get customer data
|
||||
*/
|
||||
foreach(['company','uid','firstname','lastname','street','zip','city','phone','email'] as $key) {
|
||||
foreach(['company','uid','firstname','lastname','street','housenumber','zip','city','phone','email','block','stiege','stock','tuer', 'unit_string'] as $key) {
|
||||
if(property_exists($customer, $key)) {
|
||||
$preorder_data[$key] = $customer->$key;
|
||||
$preorder_data[$key] = ($customer->$key) ? $customer->$key : null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -322,6 +497,103 @@ class PreorderApicontroller extends mfBaseApicontroller {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//var_dump($this->allow_unit_update, $update_unit);exit;
|
||||
|
||||
/**************************************************
|
||||
* update wohneinheit if allowed
|
||||
* and unit search data was submitted
|
||||
*/
|
||||
|
||||
$unit_changed = false;
|
||||
|
||||
if($this->allow_unit_update && $update_unit) {
|
||||
//var_dump($unit_search);
|
||||
//var_dump($unit);
|
||||
//exit;
|
||||
|
||||
// get available units
|
||||
$exclude_wohneinheit_ids = [];
|
||||
$preorders_in_hausnummer = PreorderModel::search(['adb_hausnummer_id' => $address->hausnummer_id]);
|
||||
if(count($preorders_in_hausnummer)) {
|
||||
|
||||
foreach($preorders_in_hausnummer as $pih) {
|
||||
if($pih->adb_wohneinheit_id) {
|
||||
$exclude_wohneinheit_ids[] = $pih->adb_wohneinheit_id;
|
||||
}
|
||||
}
|
||||
}
|
||||
// get units excluding unavailable units
|
||||
$where = "hausnummer_id=".$address->hausnummer_id;
|
||||
$where .= " AND ( block = '' OR block IS NULL)";
|
||||
$where .= " AND ( stiege = '' OR stiege IS NULL)";
|
||||
$where .= " AND ( stock = '' OR stock IS NULL)";
|
||||
$where .= " AND ( tuer = '' OR tuer IS NULL)";
|
||||
$where .= " AND ( bezeichner = '' OR bezeichner IS NULL)";
|
||||
|
||||
if(count($exclude_wohneinheit_ids)) {
|
||||
$where .= " AND wohneinheit_id NOT IN (". implode(",",$exclude_wohneinheit_ids).")";
|
||||
}
|
||||
$sql = "SELECT * FROM view_wohneinheit WHERE $where";
|
||||
$this->log->debug($sql);
|
||||
$res = $this->db()->query($sql);
|
||||
if(!$this->db()->num_rows($res)) {
|
||||
return mfResponse::Forbidden(['message' => "Keine Wohneinheiten verfügbar"]);
|
||||
}
|
||||
|
||||
$unit_row = $this->db()->fetch_object($res);
|
||||
$unit = new ADBWohneinheit($unit_row->wohneinheit_id);
|
||||
if(!$unit->id) {
|
||||
return mfResponse::InternalServerError(['message' => "unit not found"]);
|
||||
}
|
||||
//echo "blah";exit;
|
||||
|
||||
$change_note_data = [];
|
||||
foreach(['block','stiege','stock','tuer','bezeichner'] as $unit_address_part) {
|
||||
if($unit_search[$unit_address_part]) {
|
||||
$unit->$unit_address_part = $unit_search[$unit_address_part];
|
||||
$unit_changed = true;
|
||||
$change_note_data[] = [
|
||||
'field' => $unit_address_part,
|
||||
'from' => $unit->_old_data->$unit_address_part,
|
||||
'to' => $unit_search[$unit_address_part]
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
if($unit_changed) {
|
||||
$change_note_text = ($unit->note) ? $unit->note : "";
|
||||
$change_note_text .= date("Y-m-d H:i:s").": ";
|
||||
foreach($change_note_data as $cn) {
|
||||
$field = $cn['field'];
|
||||
$from = ($cn['from'] === null) ? "NULL" : "'".$cn['from']."'";
|
||||
$to = ($cn['to'] === null) ? "NULL" : "'".$cn['to']."'";
|
||||
$change_note_text .= "$field from $from to $to; ";
|
||||
}
|
||||
$change_note_text .= "\n";
|
||||
$unit->note = $change_note_text;
|
||||
|
||||
$unit->startTransaction();
|
||||
$unit->save();
|
||||
}
|
||||
//var_dump($unit);exit;
|
||||
|
||||
$preorder_data['adb_wohneinheit_id'] = $unit->id;
|
||||
$preorder_data['oaid'] = $unit->oaid;
|
||||
}
|
||||
|
||||
|
||||
// assign next wohneinheit if no unit search data was submitted
|
||||
/*
|
||||
if($this->allow_unit_update && $assign_unit) {
|
||||
var_dump($unit_search);
|
||||
var_dump($unit);
|
||||
exit;
|
||||
}*/
|
||||
|
||||
|
||||
/*
|
||||
* create preorder record
|
||||
*/
|
||||
@@ -331,10 +603,21 @@ class PreorderApicontroller extends mfBaseApicontroller {
|
||||
$preorder_id = $preorder->save();
|
||||
|
||||
if(!$preorder_id || !$preorder->ucode) {
|
||||
if($unit_changed) $unit->rollbackTransaction();
|
||||
return mfResponse::InternalServerError();
|
||||
}
|
||||
|
||||
return mfResponse::Ok(["code" => $preorder->ucode]);
|
||||
if($unit_changed) $unit->commitTransaction();
|
||||
|
||||
$return = ["code" => $preorder->ucode];
|
||||
if($preorder->oaid) {
|
||||
$return ['oaid'] = $preorder->oaid;
|
||||
}
|
||||
if($addon_data) {
|
||||
$return["additionalData"] = $addon_data;
|
||||
}
|
||||
|
||||
return mfResponse::Ok($return);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -372,14 +372,56 @@ class BuildingController extends mfBaseController {
|
||||
|
||||
private function getFilteredBuildingsApi() {
|
||||
$buildings = [];
|
||||
$filter = $this->request->filter;
|
||||
$filter = [];
|
||||
if(is_array($this->request->filter)) {
|
||||
$filter = $this->request->filter;
|
||||
}
|
||||
|
||||
if(!$this->me->is("Admin")) {
|
||||
$my_networks = $this->me->myNetworks(['netowner','salespartner']);
|
||||
|
||||
$network_ids = [];
|
||||
foreach($my_networks as $net) {
|
||||
$network_ids[] = $net->id;
|
||||
}
|
||||
|
||||
if(array_key_exists("network_id", $filter)) {
|
||||
if(!in_array($filter['network_id'], $network_ids)) {
|
||||
$filter['network_id'] = $network_ids;
|
||||
}
|
||||
} else {
|
||||
$filter['network_id'] = $network_ids;
|
||||
}
|
||||
}
|
||||
|
||||
$results = BuildingModel::search($filter);
|
||||
|
||||
foreach($results as $building) {
|
||||
$data = $building->data;
|
||||
//$this->log->debug("building status: ".print_r($building->status,true));
|
||||
$data = clone($building->data);
|
||||
$data->id = $building->id;
|
||||
$data->status = "none";
|
||||
$data->type = $building->type->name;
|
||||
$data->popname = ($building->pop_id) ? $building->pop->name : "-";
|
||||
|
||||
$terms = [];
|
||||
foreach($building->terminations as $term) {
|
||||
$building_term = [];
|
||||
$building_term['id'] = $term->id;
|
||||
$building_term['status'] = "none";
|
||||
|
||||
//$this->log->debug("building status: ".print_r($building->status,true));
|
||||
if($term->status->code == TT_TERMSTATUS_CONNECTED) {
|
||||
$building_term['status'] = "connected";
|
||||
$data->status = "connected";
|
||||
} elseif($building->status->code == TT_BUILDINGSTATUS_CONNECTED) {
|
||||
$building_term['status'] = "pipework-done";
|
||||
if($data->status != "connected") $data->status = "pipework-done";
|
||||
}
|
||||
$terms[] = $building_term;
|
||||
}
|
||||
|
||||
$data->terminations = $terms;
|
||||
$buildings[] = $data;
|
||||
}
|
||||
|
||||
|
||||
@@ -54,7 +54,7 @@ class BuildingModel {
|
||||
return $model;
|
||||
}
|
||||
|
||||
public static function getFirst() {
|
||||
public static function getFirst($filter = []) {
|
||||
$db = FronkDB::singleton();
|
||||
|
||||
$where = self::getSqlFilter($filter);
|
||||
@@ -105,7 +105,7 @@ class BuildingModel {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static function search($filter, $limit = false) {
|
||||
public static function search($filter=[], $limit = false) {
|
||||
$items = [];
|
||||
$db = FronkDB::singleton();
|
||||
|
||||
@@ -168,7 +168,7 @@ class BuildingModel {
|
||||
}
|
||||
}
|
||||
|
||||
if(is_array($filter['type']) && count($filter['type'])) {
|
||||
if(array_key_exists("type", $filter) && is_array($filter['type']) && count($filter['type'])) {
|
||||
$ot = $filter['type'];
|
||||
$in = [];
|
||||
foreach($ot as $type) {
|
||||
|
||||
@@ -2,22 +2,126 @@
|
||||
|
||||
class Contract extends mfBaseModel {
|
||||
private $owner;
|
||||
private $creator;
|
||||
private $billingaddress;
|
||||
private $product;
|
||||
private $orderproduct;
|
||||
private $termination;
|
||||
private $sla;
|
||||
private $contractConfigGroups;
|
||||
private $contractConfigItems;
|
||||
private $configgroups;
|
||||
private $isCancelled;
|
||||
private $links;
|
||||
private $linkFrom;
|
||||
private $linkTo;
|
||||
private $upgradeFrom;
|
||||
private $upgradeTo;
|
||||
private $downgradeFrom;
|
||||
private $downgradeTo;
|
||||
private $productchangeFrom;
|
||||
private $productchangeTo;
|
||||
private $relocationFrom;
|
||||
private $relocationTo;
|
||||
private $finisher;
|
||||
private $canceler;
|
||||
private $creator;
|
||||
private $editor;
|
||||
|
||||
|
||||
private function getLinks() {
|
||||
$this->linkFrom = [];
|
||||
$this->linkTo = [];
|
||||
$this->upgradeFrom = [];
|
||||
$this->upgradeTo = [];
|
||||
$this->downgradeFrom = [];
|
||||
$this->downgradeTo = [];
|
||||
$this->productchangeFrom = [];
|
||||
$this->productchangeTo = [];
|
||||
$this->relocationFrom = [];
|
||||
$this->relocationTo = [];
|
||||
|
||||
// Links targeting this contract (to)
|
||||
foreach(ContractLinkModel::search(['origin_contract_id' => $this->id]) as $link) {
|
||||
switch($link->type) {
|
||||
case "link":
|
||||
$this->linkTo[] = $link;
|
||||
break;
|
||||
case "upgrade":
|
||||
$this->upgradeTo[] = $link;
|
||||
break;
|
||||
case "downgrade":
|
||||
$this->downgradeTo[] = $link;
|
||||
break;
|
||||
case "productchange":
|
||||
$this->productchangeTo[] = $link;
|
||||
break;
|
||||
case "relocation":
|
||||
$this->relocationTo[] = $link;
|
||||
break;
|
||||
default:
|
||||
$this->log->warn("ContractLink with invalid type: ".$link->id." ".$link->type);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
foreach(ContractLinkModel::search(['contract_id' => $this->id]) as $link) {
|
||||
switch($link->type) {
|
||||
case "link":
|
||||
$this->linkFrom[] = $link;
|
||||
break;
|
||||
case "upgrade":
|
||||
$this->upgradeFrom[] = $link;
|
||||
break;
|
||||
case "downgrade":
|
||||
$this->downgradeFrom[] = $link;
|
||||
break;
|
||||
case "productchange":
|
||||
$this->productchangeFrom[] = $link;
|
||||
break;
|
||||
case "relocation":
|
||||
$this->relocationFrom[] = $link;
|
||||
break;
|
||||
default:
|
||||
$this->log->warn("ContractLink with invalid type: ".$link->id." ".$link->type);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function isCancelled() {
|
||||
if(!$this->id) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if(!$this->cancel_date) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$now = date('U');
|
||||
if($this->cancel_date <= $now) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public function getProperty($name) {
|
||||
if($this->$name == null) {
|
||||
|
||||
if(!$this->id) {
|
||||
return null;
|
||||
if($name == "billingaddress" && $this->billingaddress_id) {
|
||||
$this->billingaddress = mfValuecache::singleton()->get("mfObjectmodel-Address-".$this->billingaddress_id);
|
||||
if($this->billingaddress === null) {
|
||||
$this->billingaddress = new Address($this->billingaddress_id);
|
||||
if($this->billingaddress->id) {
|
||||
mfValuecache::singleton()->set("mfObjectmodel-Address-".$this->billingaddress_id, $this->billingaddress);
|
||||
}
|
||||
}
|
||||
return $this->billingaddress;
|
||||
}
|
||||
|
||||
if($name == "owner") {
|
||||
if($name == "owner" && $this->owner_id) {
|
||||
$this->owner = mfValuecache::singleton()->get("mfObjectmodel-Address-".$this->owner_id);
|
||||
if($this->owner === null) {
|
||||
$this->owner = new Address($this->owner_id);
|
||||
@@ -28,17 +132,12 @@ class Contract extends mfBaseModel {
|
||||
return $this->owner;
|
||||
}
|
||||
|
||||
if($name == "billingaddress") {
|
||||
$this->billingaddress = mfValuecache::singleton()->get("mfObjectmodel-Address-".$this->billingaddress_id);
|
||||
if($this->billingaddress === null) {
|
||||
$this->billingaddress = new Address($this->billingaddress_id);
|
||||
if($this->billingaddress->id) {
|
||||
mfValuecache::singleton()->set("mfObjectmodel-Address-".$this->billingaddress_id, $this->billingaddress);
|
||||
}
|
||||
}
|
||||
return $this->billingaddress;
|
||||
|
||||
if(!$this->id) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
if($name == "product") {
|
||||
$this->product = mfValuecache::singleton()->get("mfObjectmodel-Product-".$this->product_id);
|
||||
if($this->product === null) {
|
||||
@@ -61,6 +160,69 @@ class Contract extends mfBaseModel {
|
||||
return $this->orderproduct;
|
||||
}
|
||||
|
||||
if($name == "contractConfigGroups") {
|
||||
$product = $this->getProperty("product");
|
||||
$this->contractConfigGroups = ContractconfigGroupModel::search(['producttech_id' => $product->producttech_id]);
|
||||
return $this->contractConfigGroups;
|
||||
}
|
||||
|
||||
if($name == "configgroups") {
|
||||
$product = $this->getProperty("product");
|
||||
$this->configgroups = [];
|
||||
foreach(ContractconfiggroupProductgroupModel::search(['productgroup_id' => $product->productgroup_id]) as $ccpg) {
|
||||
$ccpg->contractconfiggroup->setContractId($this->id);
|
||||
$this->configgroups[] = $ccpg->contractconfiggroup;
|
||||
}
|
||||
return $this->configgroups;
|
||||
}
|
||||
|
||||
if($name == "contractConfigItems") {
|
||||
$product = $this->getProperty("product");
|
||||
|
||||
$this->contractConfigItems = [];
|
||||
foreach(ProducttechAttributeModel::search(['producttech_id' => $product->producttech_id, "forcontract" => 1]) as $item) {
|
||||
$item->setContractId($this->id);
|
||||
$this->contractConfigItems [] = $item;
|
||||
}
|
||||
|
||||
return $this->contractConfigItems;
|
||||
}
|
||||
|
||||
if($name == "links") {
|
||||
$this->links = ContractLinkModel::includesContractId($this->id, ["type" => $link]);
|
||||
//var_dump($this->links);exit;
|
||||
return $this->links;
|
||||
}
|
||||
|
||||
if(in_array($name, ['linkFrom','linkTo','upgradeFrom','upgradeTo','downgradeFrom','downgradeTo','productchangeFrom','productchangeTo','relocationFrom','relocationTo'])) {
|
||||
if($this->$name === null) {
|
||||
$this->getLinks();
|
||||
}
|
||||
return $this->$name;
|
||||
}
|
||||
|
||||
if($name == "finisher") {
|
||||
$this->finisher = mfValuecache::singleton()->get("Worker-id-".$this->finish_date_by);
|
||||
if($this->finisher === null) {
|
||||
$this->finisher = new User($this->finish_date_by);
|
||||
if($this->finisher->id) {
|
||||
mfValuecache::singleton()->set("Worker-id-".$this->finish_date_by, $this->finisher);
|
||||
}
|
||||
}
|
||||
return $this->finisher;
|
||||
}
|
||||
|
||||
if($name == "canceler") {
|
||||
$this->canceler = mfValuecache::singleton()->get("Worker-id-".$this->cancel_date_by);
|
||||
if($this->canceler === null) {
|
||||
$this->canceler = new User($this->cancel_date_by);
|
||||
if($this->canceler->id) {
|
||||
mfValuecache::singleton()->set("Worker-id-".$this->cancel_date_by, $this->canceler);
|
||||
}
|
||||
}
|
||||
return $this->canceler;
|
||||
}
|
||||
|
||||
if($name == "creator") {
|
||||
$this->creator = mfValuecache::singleton()->get("Worker-id-".$this->create_by);
|
||||
if($this->creator === null) {
|
||||
@@ -103,4 +265,45 @@ class Contract extends mfBaseModel {
|
||||
return $this->$name;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* When object is cloned, new object will call this funtion to let us clean up the new Contract.
|
||||
* Throws Exception if cloning fails.
|
||||
*/
|
||||
public function __clone() {
|
||||
$me = new User;
|
||||
$me->loadMe();
|
||||
|
||||
$old_id = $this->id;
|
||||
$old_nummer = $this->nummer;
|
||||
unset($this->id);
|
||||
|
||||
|
||||
// cleanup Contract daten
|
||||
$this->orderproduct_id = null;
|
||||
$this->order_date = null;
|
||||
$this->finish_date = null;
|
||||
$this->finish_date_by = null;
|
||||
$this->cancel_date = null;
|
||||
$this->cancel_date_by = null;
|
||||
$this->create_by = $me->id;
|
||||
$this->edit_by = $me->id;
|
||||
|
||||
$this->create = null;
|
||||
$this->edit = null;
|
||||
$this->saved = 0;
|
||||
$this->mode = "new";
|
||||
$this->_old_data = new StdClass();
|
||||
|
||||
//$this->save();
|
||||
|
||||
if($old_id == $this->id) {
|
||||
$this->log->error("save() of cloned Contract $old_nummer failed!");
|
||||
throw new Exception("Saving clone failed.");
|
||||
}
|
||||
|
||||
$this->log->debug("Cloned Contract $old_id");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -47,6 +47,14 @@ class ContractController extends mfBaseController {
|
||||
private function getPreparedFilter($filter) {
|
||||
$new_filter = [];
|
||||
|
||||
if(array_key_exists("show_canceled", $filter)) {
|
||||
if($filter['show_canceled'] == 0) {
|
||||
$new_filter['add-where'] = " AND (cancel_date IS NULL OR cancel_date > UNIX_TIMESTAMP())";
|
||||
}
|
||||
} else {
|
||||
$new_filter['add-where'] = " AND (cancel_date IS NULL OR cancel_date > UNIX_TIMESTAMP())";
|
||||
}
|
||||
|
||||
if(is_array($filter) && count($filter)) {
|
||||
foreach($filter as $name => $value) {
|
||||
$new_filter[$name] = $value;
|
||||
@@ -56,12 +64,13 @@ class ContractController extends mfBaseController {
|
||||
return $new_filter;
|
||||
}
|
||||
|
||||
protected function addAction() {
|
||||
$this->layout()->setTemplate("Contract/Form");
|
||||
}
|
||||
|
||||
protected function editAction() {
|
||||
$id = $this->request->id;
|
||||
protected function viewAction() {
|
||||
$this->layout()->setTemplate("Contract/View");
|
||||
|
||||
$id = $this->request->contract_id;
|
||||
if(!$id) {
|
||||
$id = $this->request->id;
|
||||
}
|
||||
if(!is_numeric($id) || !$id) {
|
||||
$this->layout()->setFlash("Vertrag nicht gefunden", "error");
|
||||
$this->redirect("Contract");
|
||||
@@ -75,11 +84,437 @@ class ContractController extends mfBaseController {
|
||||
|
||||
$this->layout()->set("contract", $contract);
|
||||
|
||||
if($this->request->filter) {
|
||||
$this->layout()->set("filter", $this->request->filter);
|
||||
}
|
||||
if($this->request->s) {
|
||||
$this->layout()->set("filter", $this->request->s);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
protected function productchangeAction() {
|
||||
$this->layout()->setTemplate("Contract/ProductchangeForm");
|
||||
|
||||
$id = $this->request->contract_id;
|
||||
if(!$id) {
|
||||
$id = $this->request->id;
|
||||
}
|
||||
if(!is_numeric($id) || !$id) {
|
||||
$this->layout()->setFlash("Vertrag nicht gefunden", "error");
|
||||
$this->redirect("Contract");
|
||||
}
|
||||
|
||||
$contract = new Contract($id);
|
||||
if(!$contract->id) {
|
||||
$this->layout()->setFlash("Vertrag nicht gefunden", "error");
|
||||
$this->redirect("Contract");
|
||||
}
|
||||
|
||||
$this->layout()->set("contract", $contract);
|
||||
$this->layout()->set("terminations", TerminationModel::getAll());
|
||||
|
||||
if($this->request->filter) {
|
||||
$this->layout()->set("filter", $this->request->filter);
|
||||
}
|
||||
if($this->request->s) {
|
||||
$this->layout()->set("filter", $this->request->s);
|
||||
}
|
||||
}
|
||||
|
||||
protected function saveProductchangeAction() {
|
||||
$r = $this->request;
|
||||
|
||||
$id = $r->contract_id;
|
||||
if(!is_numeric($id) || !$id) {
|
||||
$this->layout()->setFlash("Vertrag nicht gefunden", "error");
|
||||
$this->redirect("Contract");
|
||||
}
|
||||
|
||||
$contract = new Contract($id);
|
||||
if(!$contract->id) {
|
||||
$this->layout()->setFlash("Vertrag nicht gefunden", "error");
|
||||
$this->redirect("Contract");
|
||||
}
|
||||
|
||||
$new_contract = clone($contract);
|
||||
|
||||
|
||||
$contract_data = [];
|
||||
$contract_data['product_id'] = $r->product_id;
|
||||
$contract_data['product_name'] = trim($r->product_name);
|
||||
$contract_data['product_info'] = trim($r->product_info);
|
||||
$contract_data['matchcode'] = trim($r->matchcode);
|
||||
$contract_data['termination_id'] = $r->termination_id;
|
||||
$contract_data['amount'] = 1;
|
||||
$contract_data['price'] = $r->price;
|
||||
$contract_data['price_setup'] = $r->price_setup;
|
||||
$contract_data['price_nne'] = $r->price_nne;
|
||||
$contract_data['price_nbe'] = $r->price_nbe;
|
||||
$contract_data['note'] = trim($r->note);
|
||||
|
||||
/*
|
||||
* termination check
|
||||
*/
|
||||
$product = new Product($r->product_id);
|
||||
if(!$product->id) {
|
||||
$this->layout()->setFlash("Produkt nicht gefunden", "error");
|
||||
$this->redirect("Contract", "productchange", ["contract_id" => $id]);
|
||||
}
|
||||
|
||||
$contract_data['product_external'] = $product->external;
|
||||
$contract_data['product_external_id'] = $product->external_id;
|
||||
$contract_data['sla_id'] = $product->sla_id;
|
||||
|
||||
$require_term = false;
|
||||
if(array_key_exists(TT_ATTRIB_TERMINATION_REQUIRED_NAME, $product->attributes) && $product->attributes[TT_ATTRIB_TERMINATION_REQUIRED_NAME]->value == 1) {
|
||||
//var_dump($prod->attributes);
|
||||
$require_term = true;
|
||||
$termination = new Termination($contract_data['termination_id']);
|
||||
|
||||
if(!$contract_data['termination_id'] || !$termination->id) {
|
||||
$this->layout()->setFlash("Produkt erfordert Anschluss.", "error");
|
||||
$this->redirect("Contract", "productchange", ["contract_id" => $id]);
|
||||
}
|
||||
} else {
|
||||
$contract_data['termination_id'] = null;
|
||||
}
|
||||
|
||||
|
||||
$new_contract->update($contract_data);
|
||||
$new_contract_id = $new_contract->save();
|
||||
|
||||
if(!$new_contract_id) {
|
||||
$this->layout()->setFlash("Neuer Contract konnte nicht gespeichert werden", "error");
|
||||
$this->redirect("Contract", "productchange", ["contract_id" => $id]);
|
||||
}
|
||||
|
||||
|
||||
|
||||
if(is_array($r->links) && count($r->links)) {
|
||||
foreach($r->links as $link_id => $action) {
|
||||
$old_link = new ContractLink($link_id);
|
||||
if(!$old_link->id) continue;
|
||||
$new_link_origin_id = 0;
|
||||
$new_link_origin_id = 0;
|
||||
// check if link contains this contract
|
||||
if($old_link->contract_id == $contract->id) {
|
||||
$new_link_contract_id = $new_contract->id;
|
||||
$new_link_origin_id = $old_link->origin_contract_id;
|
||||
} elseif($old_link->origin_contract_id == $contract->id) {
|
||||
$new_link_contract_id = $old_link->contract_id;
|
||||
$new_link_origin_id = $new_contract->id;
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
|
||||
$new_link = ContractLinkModel::create([
|
||||
'contract_id' => $new_link_contract_id,
|
||||
'origin_contract_id' => $new_link_origin_id,
|
||||
'type' => $old_link->type,
|
||||
]);
|
||||
if(!$new_link->save()) {
|
||||
$this->layout()->setFlash("Konnte neuen Link nicht speichern", "warn");
|
||||
}
|
||||
|
||||
if($action == "cancel") {
|
||||
$old_link->change_action = "cancel";
|
||||
if(!$old_link->save()) {
|
||||
$this->layout()->setFlash("Konnte alten Link nicht speichern", "warn");
|
||||
}
|
||||
}
|
||||
|
||||
//var_dump($new_link);exit;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Upgrade Link erstellen
|
||||
*/
|
||||
$change_type = "upgrade";
|
||||
/*if($contract->product_id != $new_contract->product_id) {
|
||||
$change_type = "upgrade";
|
||||
} elseif($contract->matchcode != $new_contract->matchcode) {
|
||||
$change_type = "relocation";
|
||||
} else {
|
||||
$change_type = "productchange";
|
||||
}*/
|
||||
|
||||
$link = ContractLinkModel::create([
|
||||
'contract_id' => $new_contract_id,
|
||||
'origin_contract_id' => $id,
|
||||
'type' => $change_type
|
||||
]);
|
||||
|
||||
$link_id = $link->save();
|
||||
if(!$link_id) {
|
||||
$this->layout()->setFlash("Konnte Verknüpfung nicht speichern", "warn");
|
||||
}
|
||||
|
||||
$this->layout()->setFlash("Neuer Contract erfolgreich erstellt", "success");
|
||||
$this->redirect("Contract", "view", ["contract_id" => $new_contract_id]);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
protected function finishContractAction() {
|
||||
$r = $this->request;
|
||||
|
||||
$id = $r->contract_id;
|
||||
if(!is_numeric($id) || !$id) {
|
||||
$this->layout()->setFlash("Contract nicht gefunden", "error");
|
||||
$this->redirect("Contract");
|
||||
}
|
||||
|
||||
$contract = new Contract($id);
|
||||
if(!$contract->id) {
|
||||
$this->layout()->setFlash("Contract nicht gefunden", "error");
|
||||
$this->redirect("Contract");
|
||||
}
|
||||
|
||||
$now = date('U');
|
||||
|
||||
/*
|
||||
* Vorgänger Contracts kündigen
|
||||
*/
|
||||
foreach(ContractLinkModel::search(['contract_id' => $id]) as $link) {
|
||||
if(!in_array($link->type, ["upgrade","downgrade","relocation","productchange"])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$origin = $link->origin;
|
||||
$origin->cancel_date = $now;
|
||||
$origin->cancel_date_by = $this->me->id;
|
||||
$origin->edit_by = $this->me->id;
|
||||
if(!$origin->save()) {
|
||||
$this->layout()->setFlash("Achtung: Konnte nicht alle Vorgängercontracts kündigen!", "warn");
|
||||
}
|
||||
|
||||
/*
|
||||
* alte Links übernehmen / kündigen
|
||||
*/
|
||||
foreach(ContractLinkModel::search(['type' => "link", 'contract_id' => $origin->id] ) as $old_link) {
|
||||
// verlinkten Contract kündigen (wenn nicht schon gekündigt)
|
||||
if($old_link->change_action == "cancel" && !$old_link->contract->cancel_date) {
|
||||
$old_link->origin->update([
|
||||
'cancel_date' => $now,
|
||||
'cancel_date_by' => $this->me->id,
|
||||
'edit_by' => $this->me->id
|
||||
]);
|
||||
$old_link->origin->save();
|
||||
|
||||
$old_link->change_action = null;
|
||||
$old_link->save();
|
||||
}
|
||||
}
|
||||
|
||||
foreach(ContractLinkModel::search(['type' => "link", 'origin_contract_id' => $origin->id] ) as $old_link) {
|
||||
// verlinkten Contract kündigen (wenn nicht schon gekündigt)
|
||||
if($old_link->change_action == "cancel" && !$old_link->contract->cancel_date) {
|
||||
$old_link->contract->update([
|
||||
'cancel_date' => $now,
|
||||
'cancel_date_by' => $this->me->id,
|
||||
'edit_by' => $this->me->id
|
||||
]);
|
||||
$old_link->contract->save();
|
||||
|
||||
$old_link->change_action = null;
|
||||
$old_link->save();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
$contract->finish_date = $now;
|
||||
$contract->finish_date_by = $this->me->id;
|
||||
if(!$contract->save()) {
|
||||
$this->layout()->setFlash("Contract konnte nicht gespeichert werden", "error");
|
||||
$this->redirect("Contract", "view", ['contract_id' => $id]);
|
||||
}
|
||||
|
||||
/*
|
||||
* bestehende Links übernehmen oder kündigen
|
||||
*/
|
||||
|
||||
$this->layout()->setFlash("Contract erfolgreich fertiggestellt", "success");
|
||||
$this->redirect("Contract", "view", ['contract_id' => $id]);
|
||||
|
||||
}
|
||||
|
||||
protected function addAction() {
|
||||
$this->layout()->setTemplate("Contract/Form");
|
||||
$this->layout()->set("terminations", TerminationModel::getAll());
|
||||
|
||||
if($this->request->origin_contract_id) {
|
||||
$origin = new Contract($this->request->origin_contract_id);
|
||||
if($origin->id) {
|
||||
$contract = new Contract();
|
||||
$contract->owner_id = $origin->owner_id;
|
||||
$contract->billingaddress_id = $origin->billingaddress_id;
|
||||
$contract->matchcode = $origin->matchcode;
|
||||
//var_dump($contract);exit;
|
||||
$this->layout()->set("contract", $contract);
|
||||
$this->layout()->set("origin_contract_id", $origin->id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected function editAction() {
|
||||
$id = $this->request->contract_id;
|
||||
if(!$id) {
|
||||
$id = $this->request->id;
|
||||
}
|
||||
if(!is_numeric($id) || !$id) {
|
||||
$this->layout()->setFlash("Vertrag nicht gefunden", "error");
|
||||
$this->redirect("Contract");
|
||||
}
|
||||
|
||||
$contract = new Contract($id);
|
||||
if(!$contract->id) {
|
||||
$this->layout()->setFlash("Vertrag nicht gefunden", "error");
|
||||
$this->redirect("Contract");
|
||||
}
|
||||
|
||||
$this->layout()->set("contract", $contract);
|
||||
|
||||
if($this->request->f == "view") $this->layout()->set("f", "view");
|
||||
if($this->request->f != "view") $this->layout()->set("f", "index");
|
||||
|
||||
if($this->request->filter) {
|
||||
$this->layout()->set("filter", $this->request->filter);
|
||||
}
|
||||
if($this->request->s) {
|
||||
$this->layout()->set("filter", $this->request->s);
|
||||
}
|
||||
|
||||
return $this->addAction();
|
||||
}
|
||||
|
||||
|
||||
|
||||
protected function saveAction() {
|
||||
$r = $this->request;
|
||||
//var_dump($r);
|
||||
|
||||
/*
|
||||
* add or edit
|
||||
*/
|
||||
$id = $r->id;
|
||||
if(is_numeric($id) && $id > 0) {
|
||||
$mode = "edit";
|
||||
$contract = new Contract($id);
|
||||
if(!$contract->id) {
|
||||
$this->layout()->setFlash("Vertrag nicht gefunden", "error");
|
||||
$this->redirect("Contract");
|
||||
}
|
||||
} else {
|
||||
$id = false;
|
||||
$mode = "add";
|
||||
}
|
||||
|
||||
//var_dump($r->get());exit;
|
||||
$contract_data = [];
|
||||
$contract_data["owner_id"] = (int)$r->owner_id;
|
||||
$contract_data["billingaddress_id"] = ($r->billingaddress_id) ? (int)$r->billingaddress_id : null;
|
||||
$contract_data["product_id"] = (int)$r->product_id;
|
||||
$contract_data["matchcode"] = $r->matchcode;
|
||||
$contract_data["product_name"] = $r->product_name;
|
||||
$contract_data["product_info"] = $r->product_info;
|
||||
$contract_data['amount'] = ($r->amount) ? (float)$r->amount : 1;
|
||||
$contract_data['price'] = (float)$r->price;
|
||||
$contract_data['price_setup'] = (float)$r->price_setup;
|
||||
$contract_data['price_nne'] = (float)$r->price_nne;
|
||||
$contract_data['price_nbe'] = (float)$r->price_nbe;
|
||||
$contract_data['billing_period'] = (int)$r->billing_period;
|
||||
$contract_data['billing_delay'] = (int)$r->billing_delay;
|
||||
$contract_data['finish_date'] = ($r->finish_date) ? $this->dateToTimestamp($r->finish_date) : null;
|
||||
$contract_data['cancel_date'] = ($r->cancel_date) ? $this->dateToTimestamp($r->cancel_date) : null;
|
||||
$contract_data['note'] = $r->note;
|
||||
|
||||
|
||||
//var_dump($contract_data);exit;
|
||||
|
||||
if($mode == "add") {
|
||||
$contract = ContractModel::create($contract_data);
|
||||
} else {
|
||||
$contract->update($contract_data);
|
||||
}
|
||||
|
||||
$this->layout()->set("contract", $contract);
|
||||
|
||||
if(!$contract_data["owner_id"]) {
|
||||
$this->layout()->setFlash("Bitte Vertragsinhaber auswählen.", "error");
|
||||
return $this->addAction();
|
||||
}
|
||||
if(!$contract_data["product_id"]) {
|
||||
$this->layout()->setFlash("Bitte Produkt auswählen.", "error");
|
||||
return $this->addAction();
|
||||
}
|
||||
if(!$contract_data['billing_period']) {
|
||||
$this->layout()->setFlash("Bitte Rechnungsperiode auswählen.", "error");
|
||||
return $this->addAction();
|
||||
}
|
||||
|
||||
if(!$contract->product_name) {
|
||||
$product = new Product($contract_data["product_id"]);
|
||||
if(!$product->id) {
|
||||
$this->layout()->setFlash("Ungültiges Produkt.", "error");
|
||||
return $this->addAction();
|
||||
}
|
||||
$contract->product_name = $product->name;
|
||||
}
|
||||
|
||||
//var_dump($contract);exit;
|
||||
|
||||
$contract_id = $contract->save();
|
||||
if(!$contract_id) {
|
||||
$this->layout()->setFlash("Fehler beim Speichern.", "error");
|
||||
$this->layout()->set("contract", $contract);
|
||||
return $this->addAction();
|
||||
}
|
||||
|
||||
$this->layout()->setFlash("Vertrag erfolgreich gespeichert.", "success");
|
||||
|
||||
/*
|
||||
* Create link to origin contract if set
|
||||
*/
|
||||
if($mode == "add" && $r->origin_contract_id) {
|
||||
$origin = new Contract($r->origin_contract_id);
|
||||
if($origin->id) {
|
||||
$link = ContractLinkModel::create([
|
||||
'contract_id' => $contract_id,
|
||||
'origin_contract_id' => $origin->id,
|
||||
'type' => 'link'
|
||||
]);
|
||||
$link->save();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* ContractLinks */
|
||||
|
||||
|
||||
$query = [];
|
||||
if($r->s) {
|
||||
$query['s'] = $r->s;
|
||||
}
|
||||
if($r->filter) {
|
||||
$query["filter"] = $r->filter;
|
||||
}
|
||||
if($r->return != "index") {
|
||||
$query['id'] = $contract_id;
|
||||
}
|
||||
|
||||
$qs = http_build_query($query);
|
||||
|
||||
if($mode == "add" || $r->f == "view") {
|
||||
$this->redirect("Contract", "view", $qs, "contract=$contract_id");
|
||||
} else {
|
||||
$this->redirect("Contract", "Index", $qs);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
protected function apiAction() {
|
||||
if(!$this->me->is(["Admin"])) {
|
||||
|
||||
@@ -1,20 +1,29 @@
|
||||
<?php
|
||||
|
||||
class ContractModel {
|
||||
public $name = null;
|
||||
public $description = null;
|
||||
public $orderproduct_id;
|
||||
public $owner_id;
|
||||
public $billingaddress_id;
|
||||
public $termination_id;
|
||||
public $product_id;
|
||||
public $product_name;
|
||||
public $product_info;
|
||||
public $matchcode;
|
||||
public $amount;
|
||||
public $sla_id = null;
|
||||
public $external = null;
|
||||
public $external_id;
|
||||
public $productgroup_id = null;
|
||||
public $producttech_id = null;
|
||||
public $product_external;
|
||||
public $product_external_id;
|
||||
public $price = null;
|
||||
public $price_setup = null;
|
||||
public $price_nne = null;
|
||||
public $price_nbe = null;
|
||||
public $billing_delay = null;
|
||||
public $billing_period = null;
|
||||
public $ivt_id = null;
|
||||
public $order_date;
|
||||
public $finish_date;
|
||||
public $finish_date_by;
|
||||
public $cancel_date;
|
||||
public $cancel_date_by;
|
||||
|
||||
public $note = null;
|
||||
public $create_by = null;
|
||||
@@ -50,7 +59,7 @@ class ContractModel {
|
||||
|
||||
$db = FronkDB::singleton();
|
||||
|
||||
$res = $db->select("Contract", "*", "1 = 1 ORDER BY owner_id,product_id,`create`");
|
||||
$res = $db->select("Contract", "*", "1 = 1 ORDER BY owner_id,`create`");
|
||||
if($db->num_rows($res)) {
|
||||
while($data = $db->fetch_object($res)) {
|
||||
$items[] = new Contract($data);
|
||||
@@ -120,7 +129,7 @@ class ContractModel {
|
||||
LEFT JOIN Product ON (Contract.product_id = Product.id)
|
||||
WHERE $where
|
||||
GROUP BY Contract.id
|
||||
ORDER BY Contract.owner_id,Contract.product_id,Contract.`create`";
|
||||
ORDER BY Contract.owner_id,Contract.`create`";
|
||||
|
||||
if(is_array($limit) && count($limit)) {
|
||||
if(is_numeric($limit['start']) && is_numeric($limit['count'])) {
|
||||
@@ -163,6 +172,13 @@ class ContractModel {
|
||||
}
|
||||
}
|
||||
|
||||
if(array_key_exists("billingaddress_id", $filter)) {
|
||||
$billingaddress_id = $filter['billingaddress_id'];
|
||||
if(is_numeric($billingaddress_id)) {
|
||||
$where .= " AND Contract.billingaddress_id=$billingaddress_id";
|
||||
}
|
||||
}
|
||||
|
||||
if(array_key_exists("product_id", $filter)) {
|
||||
$product_id = $filter['product_id'];
|
||||
if(is_numeric($product_id)) {
|
||||
@@ -192,6 +208,13 @@ class ContractModel {
|
||||
}
|
||||
}
|
||||
|
||||
if(array_key_exists("customer_number", $filter)) {
|
||||
$customer_number = $filter['customer_number'];
|
||||
if(is_numeric($customer_number)) {
|
||||
$where .= " AND Address.customer_number=$customer_number";
|
||||
}
|
||||
}
|
||||
|
||||
if(array_key_exists("owner", $filter)) {
|
||||
$owner = FronkDB::singleton()->escape($filter["owner"]);
|
||||
if($owner) {
|
||||
@@ -199,6 +222,10 @@ class ContractModel {
|
||||
}
|
||||
}
|
||||
|
||||
if(array_key_exists("add-where", $filter)) {
|
||||
$where .= " ".$filter['add-where'];
|
||||
}
|
||||
|
||||
|
||||
//var_dump($filter, $where);exit;
|
||||
return $where;
|
||||
|
||||
69
application/ContractLink/ContractLink.php
Normal file
69
application/ContractLink/ContractLink.php
Normal file
@@ -0,0 +1,69 @@
|
||||
<?php
|
||||
|
||||
class ContractLink extends mfBaseModel {
|
||||
private $contract;
|
||||
private $origin;
|
||||
|
||||
public function getProperty($name) {
|
||||
if($this->$name == null) {
|
||||
|
||||
if(!$this->id) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if($name == "origin") {
|
||||
$this->origin = mfValuecache::singleton()->get("mfObjectmodel-Contract-".$this->origin_contract_id);
|
||||
if($this->origin === null) {
|
||||
$this->origin = new Contract($this->origin_contract_id);
|
||||
if($this->origin->id) {
|
||||
mfValuecache::singleton()->set("mfObjectmodel-Contract-".$this->id, $this->origin);
|
||||
}
|
||||
}
|
||||
return $this->origin;
|
||||
}
|
||||
|
||||
if($name == "creator") {
|
||||
$this->creator = mfValuecache::singleton()->get("Worker-id-".$this->create_by);
|
||||
if($this->creator === null) {
|
||||
$this->creator = new User($this->create_by);
|
||||
if($this->creator->id) {
|
||||
mfValuecache::singleton()->set("Worker-id-".$this->create_by, $this->creator);
|
||||
}
|
||||
}
|
||||
return $this->creator;
|
||||
}
|
||||
|
||||
if($name == "editor") {
|
||||
$this->editor = mfValuecache::singleton()->get("Worker-id-".$this->edit_by);
|
||||
if($this->editor === null) {
|
||||
$this->editor = new User($this->edit_by);
|
||||
if($this->editor->id) {
|
||||
mfValuecache::singleton()->set("Worker-id-".$this->edit_by, $this->editor);
|
||||
}
|
||||
}
|
||||
return $this->editor;
|
||||
}
|
||||
|
||||
|
||||
|
||||
$classname = ucfirst($name);
|
||||
$idfield = $name."_id";
|
||||
$this->$name = mfValuecache::singleton()->get("mfObjectmodel-$name-".$this->$idfield);
|
||||
if(!$this->$name) {
|
||||
$this->$name = new $classname($this->$idfield);
|
||||
}
|
||||
|
||||
|
||||
|
||||
if($this->$name->id) {
|
||||
mfValuecache::singleton()->set("mfObjectmodel-$name-".$this->$name->id, $this->$name);
|
||||
return $this->$name;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return $this->$name;
|
||||
}
|
||||
}
|
||||
171
application/ContractLink/ContractLinkModel.php
Normal file
171
application/ContractLink/ContractLinkModel.php
Normal file
@@ -0,0 +1,171 @@
|
||||
<?php
|
||||
|
||||
class ContractLinkModel {
|
||||
public $contract_id;
|
||||
public $origin_contract_id;
|
||||
public $type;
|
||||
public $change_action;
|
||||
|
||||
public $create_by = null;
|
||||
public $edit_by = null;
|
||||
public $create = null;
|
||||
public $edit = null;
|
||||
|
||||
|
||||
public static function create(Array $data) {
|
||||
$model = new ContractLink();
|
||||
|
||||
foreach($data as $field => $value) {
|
||||
if(property_exists(get_called_class(), $field)) {
|
||||
$model ->$field = $value;
|
||||
}
|
||||
}
|
||||
|
||||
$me = new User();
|
||||
$me->loadMe();
|
||||
|
||||
if($model->create_by === null) {
|
||||
$model->create_by = $me->id;
|
||||
}
|
||||
if($model->edit_by === null) {
|
||||
$model->edit_by = $me->id;
|
||||
}
|
||||
|
||||
return $model;
|
||||
}
|
||||
|
||||
public static function getAll() {
|
||||
$items = [];
|
||||
|
||||
$db = FronkDB::singleton();
|
||||
|
||||
$res = $db->select("ContractLink", "*", "1 = 1 ORDER BY contract_id,origin_contract_id");
|
||||
if($db->num_rows($res)) {
|
||||
while($data = $db->fetch_object($res)) {
|
||||
$items[] = new ContractLink($data);
|
||||
}
|
||||
}
|
||||
return $items;
|
||||
|
||||
}
|
||||
|
||||
public static function getFirst($filter) {
|
||||
$db = FronkDB::singleton();
|
||||
|
||||
$where = self::getSqlFilter($filter);
|
||||
$sql = "SELECT * FROM ContractLink
|
||||
WHERE $where
|
||||
ORDER BY contract_id,origin_contract_id
|
||||
LIMIT 1";
|
||||
//var_dump($sql);exit;
|
||||
$res = $db->query($sql);
|
||||
if($db->num_rows($res)) {
|
||||
$data = $db->fetch_object($res);
|
||||
$item = new ContractLink($data);
|
||||
if($item->id) {
|
||||
return $item;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static function includesContractId($contract_id, $filter=[]) {
|
||||
$items = [];
|
||||
$db = FronkDB::singleton();
|
||||
|
||||
$where = self::getSqlFilter($filter);
|
||||
$sql = "SELECT * FROM ContractLink
|
||||
WHERE (contract_id=$contract_id OR origin_contract_id=$contract_id)
|
||||
AND $where
|
||||
ORDER BY contract_id,origin_contract_id";
|
||||
|
||||
|
||||
mfLoghandler::singleton()->debug($sql);
|
||||
|
||||
$res = $db->query($sql);
|
||||
if($db->num_rows($res)) {
|
||||
while($data = $db->fetch_object($res)) {
|
||||
$items[$data->id] = new ContractLink($data);
|
||||
}
|
||||
}
|
||||
|
||||
return $items;
|
||||
}
|
||||
|
||||
public static function count($filter) {
|
||||
$db = FronkDB::singleton();
|
||||
|
||||
$where = self::getSqlFilter($filter);
|
||||
$sql = "SELECT COUNT(*) FROM ContractLink
|
||||
WHERE $where
|
||||
";
|
||||
|
||||
$res = $db->query($sql);
|
||||
if($db->num_rows($res)) {
|
||||
$data = $db->fetch_object($res);
|
||||
return $data->cnt;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static function search($filter, $limit = false) {
|
||||
//var_dump($filter);exit;
|
||||
$items = [];
|
||||
$db = FronkDB::singleton();
|
||||
|
||||
$where = self::getSqlFilter($filter);
|
||||
$sql = "SELECT * FROM ContractLink
|
||||
WHERE $where
|
||||
ORDER BY contract_id,origin_contract_id";
|
||||
|
||||
if(is_array($limit) && count($limit)) {
|
||||
if(is_numeric($limit['start']) && is_numeric($limit['count'])) {
|
||||
$sql .= " LIMIT ".$limit['start'].", ".$limit['count'];
|
||||
} elseif(is_numeric($count)) {
|
||||
$sql .= " LIMIT ".$limit['count'];
|
||||
}
|
||||
}
|
||||
|
||||
mfLoghandler::singleton()->debug($sql);
|
||||
|
||||
$res = $db->query($sql);
|
||||
if($db->num_rows($res)) {
|
||||
while($data = $db->fetch_object($res)) {
|
||||
$items[$data->id] = new ContractLink($data);
|
||||
}
|
||||
}
|
||||
|
||||
return $items;
|
||||
}
|
||||
|
||||
private static function getSqlFilter($filter) {
|
||||
$where = "1=1 ";
|
||||
|
||||
$db = FronkDB::singleton();
|
||||
|
||||
//var_dump($filter);exit;
|
||||
|
||||
if(array_key_exists("contract_id", $filter)) {
|
||||
$contract_id = $filter['contract_id'];
|
||||
if(is_numeric($contract_id)) {
|
||||
$where .= " AND ContractLink.contract_id = '$contract_id'";
|
||||
}
|
||||
}
|
||||
|
||||
if(array_key_exists("origin_contract_id", $filter)) {
|
||||
$origin_contract_id = $filter['origin_contract_id'];
|
||||
if(is_numeric($origin_contract_id)) {
|
||||
$where .= " AND ContractLink.origin_contract_id = '$origin_contract_id'";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//var_dump($filter, $where);exit;
|
||||
return $where;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -15,9 +15,82 @@ class ContractconfigController extends mfBaseController {
|
||||
}
|
||||
|
||||
protected function indexAction() {
|
||||
$groups = ContractconfigGroupModel::getAll();
|
||||
|
||||
$this->layout()->set("groups", $groups);
|
||||
}
|
||||
|
||||
protected function viewAction() {
|
||||
|
||||
}
|
||||
|
||||
protected function editAction() {
|
||||
$this->layout()->setTemplate("Contractconfig/Form");
|
||||
|
||||
$contract_id = $this->request->contract_id;
|
||||
if(!$contract_id) {
|
||||
$this->layout()->setFlash("Contract ID nicht gefunden.","error");
|
||||
$this->redirect("Contract");
|
||||
}
|
||||
|
||||
$contract = new Contract($contract_id);
|
||||
if(!$contract_id) {
|
||||
$this->layout()->setFlash("Contract ID nicht gefunden.","error");
|
||||
$this->redirect("Contract");
|
||||
}
|
||||
|
||||
if(!is_array($contract->configgroups) || !count($contract->configgroups)) {
|
||||
$this->layout()->setFlash("Produkt hat keine Vertragsconfiggruppen hinterlegt.","info");
|
||||
$this->redirect("Contract", "View", ["id" => $contract_id]);
|
||||
}
|
||||
|
||||
$this->layout()->set("contract", $contract);
|
||||
$this->layout()->set("groups", $contract->configgroups);
|
||||
}
|
||||
|
||||
protected function saveAction() {
|
||||
$r = $this->request;
|
||||
$contract_id = $r->contract_id;
|
||||
|
||||
if(!is_numeric($contract_id) || $contract_id < 1) {
|
||||
$this->layout()->setFlash("Contract ID nicht gefunden.","error");
|
||||
$this->redirect("Contract");
|
||||
}
|
||||
|
||||
if(!is_array($r->itemvalues) || !count($r->itemvalues)) {
|
||||
$this->layout()->setFlash("Keine Änderungen.","info");
|
||||
$this->redirect("Contract");
|
||||
}
|
||||
|
||||
$error_items = [];
|
||||
|
||||
foreach($r->itemvalues as $item_id => $itemvalue) {
|
||||
$item = new ContractconfigItem($item_id);
|
||||
if(!$item->id) {
|
||||
$this->log->warn("Tried to save non-existant ContractconfigItem $item_id");
|
||||
continue;
|
||||
}
|
||||
$item->setContractId($contract_id);
|
||||
if(!$item->value->set($itemvalue)) {
|
||||
$error_items[$item->id] = $item->name;
|
||||
continue;
|
||||
}
|
||||
if(!$item->value->save()) {
|
||||
$this->layout()->set("request", $r);
|
||||
$this->layout()->setFlash("Fehler beim Speichern von".$item->name,"info");
|
||||
return $this->editAction();
|
||||
}
|
||||
}
|
||||
|
||||
if(count($error_items)) {
|
||||
$this->layout()->set("error_items", array_keys($error_items));
|
||||
$this->layout()->set("request", $r);
|
||||
$this->layout()->setFlash("Konfiguration nicht vollständig gespeichert. Fehler in folgenden Feldern:\n<br />".implode(", ", $error_items), "warning");
|
||||
return $this->editAction();
|
||||
}
|
||||
|
||||
$this->layout()->setFlash("Konfiguration gespeichert", "success");
|
||||
$this->redirect("Contract", "view", ['id' => $contract_id]);
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -1,30 +0,0 @@
|
||||
<?php
|
||||
|
||||
class ContractconfigGroup extends mfBaseModel {
|
||||
private $items;
|
||||
private $value;
|
||||
|
||||
|
||||
public function getProperty($name) {
|
||||
if($this->$name == null) {
|
||||
|
||||
if($name == "items") {
|
||||
$this->items = ContractconfigItemModel::search(['group_id' => $this->id]);
|
||||
return $this->items;
|
||||
}
|
||||
|
||||
$classname = ucfirst($name);
|
||||
$idfield = $name."_id";
|
||||
$this->$name = new $classname($this->$idfield);
|
||||
|
||||
if($this->$name->id) {
|
||||
return $this->$name;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
return $this->$name;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,5 +1,77 @@
|
||||
<?php
|
||||
|
||||
class ContractconfigItem extends mfBaseModel {
|
||||
private $value;
|
||||
private $contract_id;
|
||||
|
||||
public function setContractId($contract_id) {
|
||||
if(!is_numeric($contract_id)) {
|
||||
return false;
|
||||
}
|
||||
$this->contract_id = $contract_id;
|
||||
return true;
|
||||
}
|
||||
|
||||
public function getValue() {
|
||||
$value = $this->getProperty("value");
|
||||
if(!$value) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if($this->type == "int") {
|
||||
return $value->int;
|
||||
}
|
||||
if($this->type == "decimal") {
|
||||
return $value->number;
|
||||
}
|
||||
|
||||
return $value->string;
|
||||
}
|
||||
|
||||
public function getTypedataArray() {
|
||||
if(!$this->typedata) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return explode("\n", $this->typedata);
|
||||
}
|
||||
|
||||
public function getProperty($name) {
|
||||
if($this->$name == null) {
|
||||
|
||||
if(!$this->id) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if($name == "value") {
|
||||
if(!$this->contract_id) {
|
||||
return null;
|
||||
}
|
||||
$value = ContractconfigValueModel::getFirst(['item_id' => $this->id, "contract_id" => $this->contract_id]);
|
||||
if(!$value) {
|
||||
$me = new User();
|
||||
$me->loadMe();
|
||||
$value = new ContractconfigValue();
|
||||
$value->item_id = $this->id;
|
||||
$value->contract_id = $this->contract_id;
|
||||
$value->create_by = $me->id;
|
||||
}
|
||||
|
||||
$this->value = $value;
|
||||
return $this->value;
|
||||
}
|
||||
|
||||
$classname = ucfirst($name);
|
||||
$idfield = $name."_id";
|
||||
$this->$name = new $classname($this->$idfield);
|
||||
|
||||
if($this->$name->id) {
|
||||
return $this->$name;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
return $this->$name;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,82 @@
|
||||
<?php
|
||||
|
||||
class ContractconfigItemController extends mfBaseController {
|
||||
|
||||
protected function init() {
|
||||
$this->needlogin=true;
|
||||
$me = new User();
|
||||
$me->loadMe();
|
||||
$this->me = $me;
|
||||
$this->layout()->set("me",$me);
|
||||
|
||||
if(!$me->is(["Admin"])) {
|
||||
$this->redirect("Dashboard");
|
||||
}
|
||||
}
|
||||
|
||||
protected function saveAction() {
|
||||
$r = $this->request;
|
||||
|
||||
$item_id = $r->item_id;
|
||||
if(is_numeric($item_id) && $item_id > 0) {
|
||||
$mode = "edit";
|
||||
$item = new ContractconfigItem($item_id);
|
||||
if(!$item->id) {
|
||||
$this->layout()->setFlash("Element nicht gefunden", "error");
|
||||
$this->redirect("Contractconfiggroup");
|
||||
}
|
||||
} else {
|
||||
$mode = "add";
|
||||
}
|
||||
|
||||
$item_data['contractconfiggroup_id'] = $r->group_id;
|
||||
$item_data['name'] = $r->name;
|
||||
$item_data['displayname'] = $r->displayname;
|
||||
$item_data['description'] = $r->description;
|
||||
|
||||
$item_data['typedata'] = "";
|
||||
$item_data['pattern'] = "";
|
||||
|
||||
switch($r->type) {
|
||||
case "string":
|
||||
$item_data['type'] = "string";
|
||||
$item_data['pattern'] = $r->pattern;
|
||||
break;
|
||||
case "enum":
|
||||
$item_data['type'] = "enum";
|
||||
$item_data['typedata'] = preg_replace(['/\n{2,}/','/^\n+/','/\n+$/'], ["\n",'',''], str_replace("\r","\n",$r->data));
|
||||
break;
|
||||
case "int":
|
||||
$item_data['type'] = "int";
|
||||
break;
|
||||
case "decimal":
|
||||
$item_data['type'] = "decimal";
|
||||
break;
|
||||
default:
|
||||
$this->layout()->setFlash("Ungültiger Datentyp!");
|
||||
$this->redirect("Contractconfiggroup");
|
||||
}
|
||||
|
||||
if($mode == "edit") {
|
||||
$item->update($item_data);
|
||||
} else {
|
||||
$item = ContractconfigItemModel::create($item_data);
|
||||
}
|
||||
|
||||
//var_dump($item);exit;
|
||||
|
||||
$item_id = $item->save();
|
||||
|
||||
if(!$item_id) {
|
||||
$this->layout()->setFlash("Fehler beim Speichern!");
|
||||
$this->redirect("Contractconfiggroup");
|
||||
}
|
||||
|
||||
$this->layout()->setFlash("Element erfolgreich gespeichert", "success");
|
||||
$this->redirect("Contractconfiggroup");
|
||||
//$this->redirect("Contractconfig","Index","","item=$item_id");
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,12 +1,14 @@
|
||||
<?php
|
||||
|
||||
class ContractconfigItemModel {
|
||||
public $order;
|
||||
public $contractconfiggroup_id;
|
||||
public $type;
|
||||
public $name;
|
||||
public $displayname;
|
||||
public $description;
|
||||
public $filename;
|
||||
public $store_filename;
|
||||
public $orig_filename;
|
||||
public $subfolder;
|
||||
public $typedata;
|
||||
public $pattern;
|
||||
|
||||
public $create_by = null;
|
||||
public $edit_by = null;
|
||||
@@ -14,7 +16,7 @@ class ContractconfigItemModel {
|
||||
public $edit = null;
|
||||
|
||||
|
||||
public static function create(Array $data) {
|
||||
public static function create(Array $data) {
|
||||
$model = new ContractconfigItem();
|
||||
|
||||
foreach($data as $field => $value) {
|
||||
@@ -41,7 +43,7 @@ class ContractconfigItemModel {
|
||||
|
||||
$db = FronkDB::singleton();
|
||||
|
||||
$res = $db->select("ContractconfigItem", "*", "1=1 ORDER BY name, `create`");
|
||||
$res = $db->select("ContractconfigItem", "*", "1=1 ORDER BY `order`, name, `create`");
|
||||
if($db->num_rows($res)) {
|
||||
while($data = $db->fetch_object($res)) {
|
||||
$items[] = new ContractconfigItem($data);
|
||||
@@ -55,7 +57,7 @@ class ContractconfigItemModel {
|
||||
$db = FronkDB::singleton();
|
||||
|
||||
$where = self::getSqlFilter($filter);
|
||||
$res = $db->select("ContractconfigItem", "*", "$where LIMIT 1");
|
||||
$res = $db->select("ContractconfigItem", "*", "$where ORDER BY `order`,name LIMIT 1");
|
||||
if($db->num_rows($res)) {
|
||||
$data = $db->fetch_object($res);
|
||||
$item = new ContractconfigItem($data);
|
||||
@@ -73,7 +75,7 @@ class ContractconfigItemModel {
|
||||
$db = FronkDB::singleton();
|
||||
|
||||
$where = self::getSqlFilter($filter);
|
||||
$res = $db->select("ContractconfigItem", "*", "$where ORDER BY name");
|
||||
$res = $db->select("ContractconfigItem", "*", "$where ORDER BY `order`,name");
|
||||
if($db->num_rows($res)) {
|
||||
while($data = $db->fetch_object($res)) {
|
||||
$items[] = new ContractconfigItem($data);
|
||||
@@ -100,6 +102,13 @@ class ContractconfigItemModel {
|
||||
}
|
||||
}
|
||||
|
||||
if(array_key_exists("contractconfiggroup_id", $filter)) {
|
||||
$contractconfiggroup_id = $filter['contractconfiggroup_id'];
|
||||
if(is_numeric($contractconfiggroup_id)) {
|
||||
$where .= " AND contractconfiggroup_id=$contractconfiggroup_id";
|
||||
}
|
||||
}
|
||||
|
||||
if(array_key_exists("group_id", $filter)) {
|
||||
$group_id = $filter['group_id'];
|
||||
if(is_numeric($group_id)) {
|
||||
|
||||
@@ -1,5 +1,63 @@
|
||||
<?php
|
||||
|
||||
class ContractconfigValue extends mfBaseModel {
|
||||
private $item;
|
||||
|
||||
public function set($new_value) {
|
||||
$item = $this->getProperty("item");
|
||||
|
||||
$me = new User();
|
||||
$me->loadMe();
|
||||
$this->edit_by = $me->id;
|
||||
|
||||
if($new_value === null || strlen($new_value) == 0) {
|
||||
$this->int = null;
|
||||
$this->number = null;
|
||||
$this->string = null;
|
||||
return true;
|
||||
}
|
||||
|
||||
if($item->type == "int") {
|
||||
if(!is_numeric($new_value)) return false;
|
||||
$this->int = $new_value;
|
||||
} elseif($item->type == "decimal") {
|
||||
if(!is_float($new_value) && !is_numeric($new_value)) return false;
|
||||
$this->number = $new_value;
|
||||
} elseif(is_scalar($new_value)) {
|
||||
$this->string = $new_value;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public function getProperty($name) {
|
||||
if($this->$name == null) {
|
||||
|
||||
if(!$this->id) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if($name == "item") {
|
||||
$this->item = new ContractconfigItem($this->item_id);
|
||||
if(!$this->item->id) {
|
||||
return null;
|
||||
}
|
||||
return $this->item;
|
||||
}
|
||||
|
||||
$classname = ucfirst($name);
|
||||
$idfield = $name."_id";
|
||||
$this->$name = new $classname($this->$idfield);
|
||||
|
||||
if($this->$name->id) {
|
||||
return $this->$name;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
return $this->$name;
|
||||
}
|
||||
}
|
||||
@@ -1,12 +1,11 @@
|
||||
<?php
|
||||
|
||||
class ContractconfigValueModel {
|
||||
public $name;
|
||||
public $description;
|
||||
public $filename;
|
||||
public $store_filename;
|
||||
public $orig_filename;
|
||||
public $subfolder;
|
||||
public $contract_id;
|
||||
public $item_id;
|
||||
public $string;
|
||||
public $int;
|
||||
public $text;
|
||||
|
||||
public $create_by = null;
|
||||
public $edit_by = null;
|
||||
@@ -51,11 +50,11 @@ class ContractconfigValueModel {
|
||||
|
||||
}
|
||||
|
||||
public static function getFirst() {
|
||||
public static function getFirst($filter) {
|
||||
$db = FronkDB::singleton();
|
||||
|
||||
$where = self::getSqlFilter($filter);
|
||||
$res = $db->select("ContractconfigValue", "*", "$where LIMIT 1");
|
||||
$res = $db->select("ContractconfigValue", "*", "$where ORDER BY item_id, contract_id LIMIT 1");
|
||||
if($db->num_rows($res)) {
|
||||
$data = $db->fetch_object($res);
|
||||
$item = new ContractconfigValue($data);
|
||||
@@ -73,7 +72,7 @@ class ContractconfigValueModel {
|
||||
$db = FronkDB::singleton();
|
||||
|
||||
$where = self::getSqlFilter($filter);
|
||||
$res = $db->select("ContractconfigValue", "*", "$where ORDER BY name, filename");
|
||||
$res = $db->select("ContractconfigValue", "*", "$where ORDER BY item_id, contract_id");
|
||||
if($db->num_rows($res)) {
|
||||
while($data = $db->fetch_object($res)) {
|
||||
$items[] = new ContractconfigValue($data);
|
||||
@@ -86,24 +85,44 @@ class ContractconfigValueModel {
|
||||
$where = "1=1 ";
|
||||
|
||||
//var_dump($filter);exit;
|
||||
if(array_key_exists("name", $filter)) {
|
||||
$name = FronkDB::singleton()->escape($filter['name']);
|
||||
if($name) {
|
||||
$where .= " AND name='$name'";
|
||||
if(array_key_exists("contract_id", $filter)) {
|
||||
$contract_id = $filter['contract_id'];
|
||||
if(is_numeric($contract_id)) {
|
||||
$where .= " AND contract_id=$contract_id";
|
||||
} elseif(is_array($contract_id) && count($contract_id)) {
|
||||
$where .= " AND contract_id IN (". implode(",", $contract_id).")";
|
||||
}
|
||||
}
|
||||
|
||||
if(array_key_exists("filename", $filter)) {
|
||||
$filename = FronkDB::singleton()->escape($filter['filename']);
|
||||
if($filename) {
|
||||
$where .= " AND filename='$filename'";
|
||||
if(array_key_exists("item_id", $filter)) {
|
||||
$item_id = $filter['item_id'];
|
||||
if(is_numeric($item_id)) {
|
||||
$where .= " AND item_id=$item_id";
|
||||
} elseif(is_array($item_id) && count($item_id)) {
|
||||
$where .= " AND item_id IN (". implode(",", $item_id).")";
|
||||
}
|
||||
}
|
||||
|
||||
if(array_key_exists("subfolder", $filter)) {
|
||||
$subfolder = FronkDB::singleton()->escape($filter['subfolder']);
|
||||
if($subfolder) {
|
||||
$where .= " AND subfolder='$subfolder'";
|
||||
if(array_key_exists("int", $filter)) {
|
||||
$int = $filter['int'];
|
||||
if(is_numeric($int)) {
|
||||
$where .= " AND int=$int";
|
||||
} elseif(is_array($int) && count($int)) {
|
||||
$where .= " AND `int` IN (". implode(",", $int).")";
|
||||
}
|
||||
}
|
||||
|
||||
if(array_key_exists("string", $filter)) {
|
||||
$string = FronkDB::singleton()->escape($filter['string']);
|
||||
if($string) {
|
||||
$where .= " AND `string`='$string'";
|
||||
}
|
||||
}
|
||||
|
||||
if(array_key_exists("text", $filter)) {
|
||||
$text = FronkDB::singleton()->escape($filter['text']);
|
||||
if($text) {
|
||||
$where .= " AND `text`='$text'";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
49
application/Contractconfiggroup/Contractconfiggroup.php
Normal file
49
application/Contractconfiggroup/Contractconfiggroup.php
Normal file
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
class Contractconfiggroup extends mfBaseModel {
|
||||
private $items;
|
||||
private $contract_id;
|
||||
|
||||
public function setContractId($contract_id) {
|
||||
if(!is_numeric($contract_id)) {
|
||||
return false;
|
||||
}
|
||||
$this->contract_id = $contract_id;
|
||||
return true;
|
||||
}
|
||||
|
||||
public function getProperty($name) {
|
||||
if($this->$name == null) {
|
||||
|
||||
/*if($name == "items") {
|
||||
$this->items = ContractconfigItemModel::search(['group_id' => $this->id]);
|
||||
return $this->items;
|
||||
}*/
|
||||
|
||||
if($name == "items") {
|
||||
if($this->contract_id) {
|
||||
foreach(ContractconfigItemModel::search(['contractconfiggroup_id' => $this->id]) as $item) {
|
||||
$item->setContractId($this->contract_id);
|
||||
$this->items[] = $item;
|
||||
}
|
||||
} else {
|
||||
$this->items = ContractconfigItemModel::search(['contractconfiggroup_id' => $this->id]);
|
||||
}
|
||||
return $this->items;
|
||||
}
|
||||
|
||||
$classname = ucfirst($name);
|
||||
$idfield = $name."_id";
|
||||
$this->$name = new $classname($this->$idfield);
|
||||
|
||||
if($this->$name->id) {
|
||||
return $this->$name;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
return $this->$name;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
class ContractconfiggroupController extends mfBaseController {
|
||||
|
||||
protected function init() {
|
||||
$this->needlogin=true;
|
||||
$me = new User();
|
||||
$me->loadMe();
|
||||
$this->me = $me;
|
||||
$this->layout()->set("me",$me);
|
||||
|
||||
if(!$me->is(["Admin"])) {
|
||||
$this->redirect("Dashboard");
|
||||
}
|
||||
}
|
||||
|
||||
protected function indexAction() {
|
||||
$groups = ContractconfiggroupModel::search([]);
|
||||
|
||||
$this->layout()->set("configgroups", $groups);
|
||||
}
|
||||
|
||||
|
||||
protected function saveAction() {
|
||||
$groupname = ucfirst(trim($this->request->name));
|
||||
|
||||
if(!$groupname) {
|
||||
$this->layout()->setFlash("Gruppenname darf nicht leer sein!", "error");
|
||||
$this->redirect("Contractconfiggroup");
|
||||
}
|
||||
|
||||
$group = ContractconfiggroupModel::getFirst(["name" => $groupname]);
|
||||
if($group) {
|
||||
$this->layout()->setFlash("Gruppe gibs scho", "warn");
|
||||
$this->redirect("Contractconfiggroup");
|
||||
}
|
||||
|
||||
$group = ContractconfiggroupModel::create(["name" => $groupname]);
|
||||
$group_id = $group->save();
|
||||
if(!$group_id) {
|
||||
$this->layout()->setFlash("Fehler beim Speichern", "error");
|
||||
$this->redirect("Contractconfiggroup");
|
||||
}
|
||||
|
||||
$this->layout()->setFlash("Gruppe $groupname erfolgreich angelegt", "success");
|
||||
$this->redirect("Contractconfiggroup");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -1,12 +1,7 @@
|
||||
<?php
|
||||
|
||||
class ContractconfigGroupModel {
|
||||
class ContractconfiggroupModel {
|
||||
public $name;
|
||||
public $description;
|
||||
public $filename;
|
||||
public $store_filename;
|
||||
public $orig_filename;
|
||||
public $subfolder;
|
||||
|
||||
public $create_by = null;
|
||||
public $edit_by = null;
|
||||
@@ -15,7 +10,7 @@ class ContractconfigGroupModel {
|
||||
|
||||
|
||||
public static function create(Array $data) {
|
||||
$model = new ContractconfigGroup();
|
||||
$model = new Contractconfiggroup();
|
||||
|
||||
foreach($data as $field => $value) {
|
||||
if(property_exists(get_called_class(), $field)) {
|
||||
@@ -41,24 +36,24 @@ class ContractconfigGroupModel {
|
||||
|
||||
$db = FronkDB::singleton();
|
||||
|
||||
$res = $db->select("ContractconfigGroup", "*", "1=1 ORDER BY name, `create`");
|
||||
$res = $db->select("Contractconfiggroup", "*", "1=1 ORDER BY name, `create`");
|
||||
if($db->num_rows($res)) {
|
||||
while($data = $db->fetch_object($res)) {
|
||||
$items[] = new ContractconfigGroup($data);
|
||||
$items[] = new Contractconfiggroup($data);
|
||||
}
|
||||
}
|
||||
return $items;
|
||||
|
||||
}
|
||||
|
||||
public static function getFirst() {
|
||||
public static function getFirst($filter = []) {
|
||||
$db = FronkDB::singleton();
|
||||
|
||||
$where = self::getSqlFilter($filter);
|
||||
$res = $db->select("ContractconfigGroup", "*", "$where LIMIT 1");
|
||||
$res = $db->select("Contractconfiggroup", "*", "$where ORDER BY name, `create` LIMIT 1");
|
||||
if($db->num_rows($res)) {
|
||||
$data = $db->fetch_object($res);
|
||||
$item = new ContractconfigGroup($data);
|
||||
$item = new Contractconfiggroup($data);
|
||||
if($item->id) {
|
||||
return $item;
|
||||
} else {
|
||||
@@ -73,10 +68,19 @@ class ContractconfigGroupModel {
|
||||
$db = FronkDB::singleton();
|
||||
|
||||
$where = self::getSqlFilter($filter);
|
||||
$res = $db->select("ContractconfigGroup", "*", "$where ORDER BY name, filename");
|
||||
$sql = "SELECT Contractconfiggroup.* FROM Contractconfiggroup
|
||||
LEFT JOIN ContractconfiggroupProductgroup ON (Contractconfiggroup.id = ContractconfiggroupProductgroup.contractconfiggroup_id)
|
||||
LEFT JOIN Productgroup ON (ContractconfiggroupProductgroup.productgroup_id = Productgroup.id)
|
||||
WHERE $where
|
||||
GROUP BY Contractconfiggroup.id
|
||||
ORDER BY Contractconfiggroup.name, Contractconfiggroup.`create`
|
||||
";
|
||||
mfLoghandler::singleton()->debug($sql);
|
||||
$res = $db->query($sql);
|
||||
//$res = $db->select("Contractconfiggroup", "*", "$where ORDER BY name, `create`");
|
||||
if($db->num_rows($res)) {
|
||||
while($data = $db->fetch_object($res)) {
|
||||
$items[] = new ContractconfigGroup($data);
|
||||
$items[] = new Contractconfiggroup($data);
|
||||
}
|
||||
}
|
||||
return $items;
|
||||
@@ -89,14 +93,25 @@ class ContractconfigGroupModel {
|
||||
if(array_key_exists("name", $filter)) {
|
||||
$name = FronkDB::singleton()->escape($filter['name']);
|
||||
if($name) {
|
||||
$where .= " AND name='$name'";
|
||||
$where .= " AND Contractconfiggroup.name='$name'";
|
||||
}
|
||||
}
|
||||
|
||||
if(array_key_exists("filename", $filter)) {
|
||||
$filename = FronkDB::singleton()->escape($filter['filename']);
|
||||
if($filename) {
|
||||
$where .= " AND filename='$filename'";
|
||||
if(array_key_exists("producttech_id", $filter)) {
|
||||
$producttech_id = $filter['producttech_id'];
|
||||
if(is_numeric($producttech_id)) {
|
||||
$where .= " AND producttech_id=$producttech_id";
|
||||
} elseif(is_array($producttech_id) && count($producttech_id)) {
|
||||
$where .= " AND producttech_id IN (". implode(",", $producttech_id).")";
|
||||
}
|
||||
}
|
||||
|
||||
if(array_key_exists("productgroup_id", $filter)) {
|
||||
$productgroup_id = $filter['productgroup_id'];
|
||||
if(is_numeric($productgroup_id)) {
|
||||
$where .= " AND productgroup_id=$productgroup_id";
|
||||
} elseif(is_array($productgroup_id) && count($productgroup_id)) {
|
||||
$where .= " AND productgroup_id IN (". implode(",", $productgroup_id).")";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
class ContractconfiggroupProductgroup extends mfBaseModel {
|
||||
private $productgroup;
|
||||
private $contractconfiggroup;
|
||||
|
||||
public function getProperty($name) {
|
||||
if($this->$name == null) {
|
||||
|
||||
if(!$this->id) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if($name == "productgroup") {
|
||||
$this->productgroup = new Productgroup($this->productgroup_id);
|
||||
return $this->productgroup;
|
||||
}
|
||||
|
||||
if($name == "contractconfiggroup") {
|
||||
$this->contractconfiggroup = new Contractconfiggroup($this->contractconfiggroup_id);
|
||||
return $this->contractconfiggroup;
|
||||
}
|
||||
|
||||
$classname = ucfirst($name);
|
||||
$idfield = $name."_id";
|
||||
$this->$name = new $classname($this->$idfield);
|
||||
|
||||
if($this->$name->id) {
|
||||
return $this->$name;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
return $this->$name;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,107 @@
|
||||
<?php
|
||||
|
||||
class ContractconfiggroupProductgroupModel {
|
||||
public $productgroup_id;
|
||||
public $contractconfiggroup_id;
|
||||
|
||||
public $create_by = null;
|
||||
public $edit_by = null;
|
||||
public $create = null;
|
||||
public $edit = null;
|
||||
|
||||
|
||||
public static function create(Array $data) {
|
||||
$model = new ContractconfiggroupProductgroup();
|
||||
|
||||
foreach($data as $field => $value) {
|
||||
if(property_exists(get_called_class(), $field)) {
|
||||
$model ->$field = $value;
|
||||
}
|
||||
}
|
||||
|
||||
$me = new User();
|
||||
$me->loadMe();
|
||||
|
||||
if($model->create_by === null) {
|
||||
$model->create_by = $me->id;
|
||||
}
|
||||
if($model->edit_by === null) {
|
||||
$model->edit_by = $me->id;
|
||||
}
|
||||
|
||||
return $model;
|
||||
}
|
||||
|
||||
public static function getAll() {
|
||||
$items = [];
|
||||
|
||||
$db = FronkDB::singleton();
|
||||
|
||||
$res = $db->select("ContractconfiggroupProductgroup", "*", "1=1");
|
||||
if($db->num_rows($res)) {
|
||||
while($data = $db->fetch_object($res)) {
|
||||
$items[] = new ContractconfiggroupProductgroup($data);
|
||||
}
|
||||
}
|
||||
return $items;
|
||||
|
||||
}
|
||||
|
||||
public static function getFirst($filter) {
|
||||
$db = FronkDB::singleton();
|
||||
|
||||
$where = self::getSqlFilter($filter);
|
||||
$res = $db->select("ContractconfiggroupProductgroup", "*", "$where ORDER BY productgroup_id, contractconfiggroup_id LIMIT 1");
|
||||
if($db->num_rows($res)) {
|
||||
$data = $db->fetch_object($res);
|
||||
$item = new ContractconfiggroupProductgroup($data);
|
||||
if($item->id) {
|
||||
return $item;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static function search($filter) {
|
||||
$items = [];
|
||||
$db = FronkDB::singleton();
|
||||
|
||||
$where = self::getSqlFilter($filter);
|
||||
$res = $db->select("ContractconfiggroupProductgroup", "*", "$where ORDER BY productgroup_id, contractconfiggroup_id");
|
||||
if($db->num_rows($res)) {
|
||||
while($data = $db->fetch_object($res)) {
|
||||
$items[] = new ContractconfiggroupProductgroup($data);
|
||||
}
|
||||
}
|
||||
return $items;
|
||||
}
|
||||
|
||||
private static function getSqlFilter($filter) {
|
||||
$where = "1=1 ";
|
||||
|
||||
//var_dump($filter);exit;
|
||||
if(array_key_exists("productgroup_id", $filter)) {
|
||||
$productgroup_id = $filter['productgroup_id'];
|
||||
if(is_numeric($productgroup_id)) {
|
||||
$where .= " AND productgroup_id=$productgroup_id";
|
||||
} elseif(is_array($productgroup_id) && count($productgroup_id)) {
|
||||
$where .= " AND productgroup_id IN (". implode(",", $productgroup_id).")";
|
||||
}
|
||||
}
|
||||
|
||||
if(array_key_exists("contractconfiggroup_id", $filter)) {
|
||||
$contractconfiggroup_id = $filter['contractconfiggroup_id'];
|
||||
if(is_numeric($contractconfiggroup_id)) {
|
||||
$where .= " AND contractconfiggroup_id=$contractconfiggroup_id";
|
||||
} elseif(is_array($contractconfiggroup_id) && count($contractconfiggroup_id)) {
|
||||
$where .= " AND contractconfiggroup_id IN (". implode(",", $contractconfiggroup_id).")";
|
||||
}
|
||||
}
|
||||
|
||||
//var_dump($filter, $where);exit;
|
||||
return $where;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -18,15 +18,37 @@ class DashboardController extends mfBaseController {
|
||||
|
||||
|
||||
protected function testAction() {
|
||||
$sql = "SELECT tt_preorder.* FROM `thetool_live`.Preorder tt_preorder
|
||||
LEFT JOIN `thetool_addressdb`.view_hausnummer as adb_hausnummer ON (tt_preorder.adb_hausnummer_id = adb_hausnummer.hausnummer_id)
|
||||
WHERE 1=1 AND deleted=0 AND preordercampaign_id=1 AND (adb_hausnummer.gemeinde like '%stift%' OR adb_hausnummer.plz like '%stift%' OR adb_hausnummer.strasse like '%stift%')
|
||||
ORDER By lastname, firstname";
|
||||
$res = $this->db()->query($sql);
|
||||
if($this->db()->num_rows($res)) {
|
||||
$data = $this->db()->fetch_object($res);
|
||||
var_dump($data);exit;
|
||||
var_dump(ADBWohneinheitModel::count(["hausnummer_id" => 1772369]));
|
||||
exit;
|
||||
}
|
||||
|
||||
protected function colorAction() {
|
||||
|
||||
foreach(TT_CABLE_COLORS as $name => $color) {
|
||||
if(!$color['two-color']) continue;
|
||||
$hex = $color['hex'];
|
||||
$hexfg = $color['hexfg'];
|
||||
$hex2 = $color['hex2'];
|
||||
$hexfg2 = $color['hexfg2'];
|
||||
$r = $color['r'];
|
||||
$g = $color['g'];
|
||||
$b = $color['b'];
|
||||
$r2 = $color['r2'];
|
||||
$g2 = $color['g2'];
|
||||
$b2 = $color['b2'];
|
||||
|
||||
|
||||
$class = ".btn-outline-".$name." {
|
||||
color: #$hexfg;
|
||||
border-left-color: #$hex;
|
||||
border-top-color: #$hex;
|
||||
border-right-color: #$hex2;
|
||||
border-bottom-color: #$hex2;
|
||||
background: linear-gradient(90deg, rgba($r,$g,$b,.5) 0%, rgba($r,$g,$b,.5) 50%, rgba($r2,$g2,$b2,.5) 50%, rgba($r2,$g2,$b2,.5) 100%);
|
||||
}";
|
||||
echo "<pre>$class</pre>\n";
|
||||
}
|
||||
exit;
|
||||
}
|
||||
|
||||
protected function pdfAction() {
|
||||
@@ -72,8 +94,8 @@ class DashboardController extends mfBaseController {
|
||||
$email->setBody($body);
|
||||
$email->setFrom($from, $from_name);
|
||||
$email->setTo($to);
|
||||
$email->setHeader("X-xinon-oid", $order->id);
|
||||
$email->setHeader("X-xinon-pid", $product->id);
|
||||
$email->setHeader("X-".MFAPPNAME."-oid", $order->id);
|
||||
$email->setHeader("X-".MFAPPNAME."-pid", $product->id);
|
||||
$email->addAttachment($pdfpath, null, $pdfname, "application/pdf");
|
||||
$email->send();
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ class Emailnotification {
|
||||
private $headers = [];
|
||||
private $subject;
|
||||
private $body;
|
||||
private $html;
|
||||
private $from_name = false;
|
||||
private $email_from = false;
|
||||
private $email_to = false;
|
||||
@@ -14,7 +15,7 @@ class Emailnotification {
|
||||
|
||||
public function __construct() {
|
||||
$this->headers = [
|
||||
'X-Mailer' => 'XINON Mailer',
|
||||
'X-Mailer' => MFAPPNAME.' Mailer',
|
||||
];
|
||||
|
||||
$this->email_from = TT_OUTGOING_EMAIL;
|
||||
@@ -52,6 +53,10 @@ class Emailnotification {
|
||||
$this->body = $body;
|
||||
}
|
||||
|
||||
public function setHtmlBody($html) {
|
||||
$this->html = $html;
|
||||
}
|
||||
|
||||
public function setFrom($email, $name = false) {
|
||||
$this->email_from = $email;
|
||||
$this->from_name = $name;
|
||||
@@ -65,7 +70,7 @@ class Emailnotification {
|
||||
if(!$this->email_to) {
|
||||
return false;
|
||||
}
|
||||
if(!$this->body) {
|
||||
if(!$this->body && !$this->html) {
|
||||
return false;
|
||||
}
|
||||
if(!is_array($this->headers) || !count($this->headers)) {
|
||||
@@ -75,14 +80,15 @@ class Emailnotification {
|
||||
return false;
|
||||
}
|
||||
|
||||
if(!$this->headers['Subject']) {
|
||||
if(!array_key_exists("Subject", $this->headers) || !$this->headers['Subject']) {
|
||||
$this->setHeader("Subject", $this->subject);
|
||||
}
|
||||
|
||||
if(!$this->headers['From'] && $this->from_name) {
|
||||
if((!array_key_exists("From", $this->headers) || !$this->headers['From']) && $this->from_name) {
|
||||
$this->headers['From'] = '"'.$this->from_name.'" <'.$this->email_from.'>';
|
||||
}
|
||||
|
||||
$log = mfLoghandler::singleton();
|
||||
|
||||
//var_dump($this);exit;
|
||||
|
||||
@@ -92,8 +98,13 @@ class Emailnotification {
|
||||
$mimeparams['head_charset']="utf-8";
|
||||
|
||||
$mime = new Mail_mime();
|
||||
$mime->setTXTBody($this->body);
|
||||
|
||||
if($this->body) {
|
||||
$mime->setTXTBody($this->body);
|
||||
}
|
||||
if($this->html) {
|
||||
$mime->setHTMLBody($this->html);
|
||||
}
|
||||
|
||||
//var_dump($this->attachments);exit;
|
||||
|
||||
if(count($this->attachments)) {
|
||||
@@ -108,6 +119,7 @@ class Emailnotification {
|
||||
|
||||
$body = $mime->get($mimeparams);
|
||||
$headers = $mime->headers($this->headers);
|
||||
//$log->debug(print_r($headers, true));
|
||||
|
||||
$mail =& Mail::factory('mail', ["-f ".$this->email_from]);
|
||||
$mail->send($this->email_to, $headers, $body);
|
||||
|
||||
@@ -15,7 +15,11 @@ class File extends mfBaseModel {
|
||||
$id = $this->id;
|
||||
|
||||
// delete file in store
|
||||
$path = MFUPLOAD_FILE_SAVE_PATH."/documents/".$this->store_filename;
|
||||
if($this->subfolder) {
|
||||
$path = MFUPLOAD_FILE_SAVE_PATH."/".$this->subfolder."/".$this->store_filename;
|
||||
} else {
|
||||
$path = MFUPLOAD_FILE_SAVE_PATH."/".$this->store_filename;
|
||||
}
|
||||
if(!unlink($path)) {
|
||||
$this->log->warn(__CLASS__."::delete(): Error unlinking file ($path)");
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ class FileModel {
|
||||
public $store_filename;
|
||||
public $orig_filename;
|
||||
public $subfolder;
|
||||
public $mimetype;
|
||||
|
||||
public $create_by = null;
|
||||
public $edit_by = null;
|
||||
@@ -66,7 +67,7 @@ class FileModel {
|
||||
|
||||
}
|
||||
|
||||
public static function getFirst() {
|
||||
public static function getFirst($filter) {
|
||||
$db = FronkDB::singleton();
|
||||
|
||||
$where = self::getSqlFilter($filter);
|
||||
|
||||
@@ -100,6 +100,17 @@ class NetworkController extends mfBaseController {
|
||||
return $this->add();
|
||||
}
|
||||
|
||||
$netaddress = NetworkAddressModel::getFirst(["network_id" => $new_id, "address_id" => $network->owner_id, "addresstype" => "netowner"]);
|
||||
if(!$netaddress) {
|
||||
$netaddress = NetworkAddressModel::create([
|
||||
'network_id' => $new_id,
|
||||
'address_id' => $network->owner_id,
|
||||
'type' => "netowner"
|
||||
]);
|
||||
//var_dump($netaddress);exit;
|
||||
$netaddress->save();
|
||||
}
|
||||
|
||||
|
||||
$this->layout()->setFlash("Netzgebiet erfolgreich gespeichert.", "success");
|
||||
$this->redirect("Network", "Edit", ['id' => $new_id]);
|
||||
|
||||
@@ -1,15 +1,16 @@
|
||||
<?php
|
||||
|
||||
class NetworkModel {
|
||||
public $name = null;
|
||||
public $owner_id = null;
|
||||
public $sytemowner_action_status = null;
|
||||
public $note = null;
|
||||
public $name;
|
||||
public $owner_id ;
|
||||
public $adb_netzgebiet_id;
|
||||
public $sytemowner_action_status;
|
||||
public $note;
|
||||
|
||||
public $create_by = null;
|
||||
public $edit_by = null;
|
||||
public $create = null;
|
||||
public $edit = null;
|
||||
public $create_by;
|
||||
public $edit_by;
|
||||
public $create;
|
||||
public $edit;
|
||||
|
||||
|
||||
public static function create(Array $data) {
|
||||
@@ -99,10 +100,27 @@ class NetworkModel {
|
||||
$where = "1=1 ";
|
||||
|
||||
//var_dump($filter);exit;
|
||||
|
||||
if(array_key_exists("name", $filter)) {
|
||||
$name = FronkDB::singleton()->escape($filter['name']);
|
||||
if($name) {
|
||||
$where .= " AND Network.`name` = '$name'";
|
||||
}
|
||||
}
|
||||
|
||||
if(array_key_exists("name%", $filter)) {
|
||||
$name = FronkDB::singleton()->escape($filter['name%']);
|
||||
if($name) {
|
||||
$where .= " AND Network.`name` LIKE '$name%'";
|
||||
}
|
||||
}
|
||||
|
||||
if(array_key_exists("owner_id", $filter)) {
|
||||
$ownerid= $filter['owner_id'];
|
||||
if(is_numeric($ownerid)) {
|
||||
$where .= " AND owner_id=$ownerid";
|
||||
$owner_id = $filter['owner_id'];
|
||||
if(is_numeric($owner_id)) {
|
||||
$where .= " AND owner_id=$owner_id";
|
||||
} elseif(is_array($owner_id) && count($owner_id)) {
|
||||
$where .= " AND owner_id IN (". implode(",", $owner_id).")";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -66,7 +66,11 @@ class NetworkAddressModel {
|
||||
$db = FronkDB::singleton();
|
||||
|
||||
$where = self::getSqlFilter($filter);
|
||||
$res = $db->select("NetworkAddress", "*", "$where ORDER BY `type`");
|
||||
$sql = "SELECT * FROM NetworkAddress WHERE $where ORDER BY `type`";
|
||||
mfLoghandler::singleton()->debug($sql);
|
||||
$res = $db->query($sql);
|
||||
|
||||
//$res = $db->select("NetworkAddress", "*", "$where ORDER BY `type`");
|
||||
if($db->num_rows($res)) {
|
||||
$data = $db->fetch_object($res);
|
||||
$item = new NetworkAddress($data);
|
||||
@@ -84,7 +88,9 @@ class NetworkAddressModel {
|
||||
$db = FronkDB::singleton();
|
||||
|
||||
$where = self::getSqlFilter($filter);
|
||||
$res = $db->select("NetworkAddress", "*", "$where ORDER BY `type`");
|
||||
$sql = "SELECT * FROM NetworkAddress WHERE $where ORDER BY `type`";
|
||||
$res = $db->query($sql);
|
||||
//$res = $db->select("NetworkAddress", "*", "$where ORDER BY `type`");
|
||||
if($db->num_rows($res)) {
|
||||
while($data = $db->fetch_object($res)) {
|
||||
$items[$data->id] = new NetworkAddress($data->id);
|
||||
@@ -112,23 +118,25 @@ class NetworkAddressModel {
|
||||
}
|
||||
}
|
||||
|
||||
if(is_array($filter['addresstype']) && count($filter['addresstype'])) {
|
||||
$at = $filter['addresstype'];
|
||||
$in = [];
|
||||
foreach(TT_ROLES as $role) {
|
||||
if(in_array($role, $at)) {
|
||||
$role = $db->escape($role);
|
||||
$in[] = "NetworkAddress.type = '$role'";
|
||||
if(array_key_exists("addresstype", $filter)) {
|
||||
if(is_array($filter['addresstype'])) {
|
||||
$addresstypes = [];
|
||||
foreach(TT_ROLES as $role) {
|
||||
if(in_array($role, $filter['addresstype'])) {
|
||||
$addresstypes[] = $role;
|
||||
}
|
||||
}
|
||||
$where .= " AND NetworkAddress.type IN ('".implode("', '", $addresstypes)."')";
|
||||
} else {
|
||||
$addresstype = FronkDB::singleton()->escape($filter['addresstype']);
|
||||
if(in_array($addresstype, TT_ROLES)) {
|
||||
$where .= " AND NetworkAddress.type = '$addresstype'";
|
||||
}
|
||||
}
|
||||
|
||||
$or = "";
|
||||
if(count($in)) {
|
||||
$or = implode(" OR ", $in);
|
||||
$where .= " AND ( $or )";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
//var_dump($filter, $where);exit;
|
||||
return $where;
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ class Order extends mfBaseModel {
|
||||
private $contracts;
|
||||
private $terminations;
|
||||
private $journals;
|
||||
private $install_products;
|
||||
private $files;
|
||||
private $creator;
|
||||
private $editor;
|
||||
@@ -92,6 +93,68 @@ class Order extends mfBaseModel {
|
||||
}
|
||||
}
|
||||
|
||||
public function sendSpinEmail() {
|
||||
$owner = $this->getProperty("owner");
|
||||
|
||||
$spin_pdf_template = "Emailtemplates/attachments/new_order_spin.pdf";
|
||||
$new_order_template = "Emailtemplates/customer/new_order";
|
||||
|
||||
$pdf_vars = [
|
||||
'order' => $this,
|
||||
'owner' => $owner
|
||||
];
|
||||
|
||||
|
||||
if(TT_CUSTOM_ORDER_PDF_PER_NETOWNER) {
|
||||
$terms = $this->getTerminations();
|
||||
if(is_array($terms) && count($terms) && $terms[0]->id) {
|
||||
$netowner = $terms[0]->building->network->owner;
|
||||
} else {
|
||||
$netowner = new Address(TT_CUSTOM_ORDER_PDF_DEFAULT_OWNER_ID);
|
||||
}
|
||||
$pdf_vars['netowner'] = $netowner;
|
||||
}
|
||||
|
||||
// render service pin PDF
|
||||
$pdf = new PdfForm($spin_pdf_template, $pdf_vars);
|
||||
$pdfpath = $pdf->render();
|
||||
$tvalue = $pdf->getReturnedValues();
|
||||
$pdfname = $tvalue['filename'];
|
||||
|
||||
// send email to customer
|
||||
// TODO template rendern auslagern nach Emailtempate klasse
|
||||
$tpl = new Layout();
|
||||
$tpl->setTemplate($new_order_template);
|
||||
|
||||
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 = $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')");
|
||||
} 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->addAttachment($pdfpath, null, $pdfname, "application/pdf");
|
||||
$email->send();
|
||||
$this->log->info(__CLASS__."::sendSpinEmail(): Sending new SPIN for ".$owner->getCompanyOrName()." (".$owner->id.")");
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public function sendIntBillinfoEmail() {
|
||||
// TODO template rendern auslagern nach Emailtempate klasse
|
||||
$tpl = new Layout();
|
||||
@@ -118,7 +181,7 @@ class Order extends mfBaseModel {
|
||||
$email->setBody($body);
|
||||
$email->setFrom($from, $from_name);
|
||||
$email->setTo($to);
|
||||
$email->setHeader("X-xinon-oid", $this->id);
|
||||
$email->setHeader("X-".MFAPPNAME."-oid", $this->id);
|
||||
$email->send();
|
||||
|
||||
return true;
|
||||
@@ -157,7 +220,7 @@ class Order extends mfBaseModel {
|
||||
$email->setBody($body);
|
||||
$email->setFrom($from, $from_name);
|
||||
$email->setTo($to);
|
||||
$email->setHeader("X-Xinon-Oid", $this->id);
|
||||
$email->setHeader("X-".MFAPPNAME."-Oid", $this->id);
|
||||
$email->send();
|
||||
|
||||
return true;
|
||||
@@ -212,8 +275,8 @@ class Order extends mfBaseModel {
|
||||
$email->setBody($body);
|
||||
$email->setFrom($from, $from_name);
|
||||
$email->setTo($to);
|
||||
$email->setHeader("X-Xinon-Oid", $this->id);
|
||||
$email->setHeader("X-Xinon-OFid", $file->id);
|
||||
$email->setHeader("X-".MFAPPNAME."-Oid", $this->id);
|
||||
$email->setHeader("X-".MFAPPNAME."-OFid", $file->id);
|
||||
$email->addAttachment($filepath, null, $file->file->filename, $mimetype);
|
||||
$email->send();
|
||||
$this->log->info(__CLASS__."::save(): Sending Order Fileupload Email to '$to'");
|
||||
@@ -269,6 +332,21 @@ class Order extends mfBaseModel {
|
||||
return $this->products;
|
||||
}
|
||||
|
||||
if($name == "install_products") {
|
||||
$this->install_products = [];
|
||||
|
||||
foreach($this->getProperty("products") as $orderproduct) {
|
||||
$product = $orderproduct->product;
|
||||
//$atrribs = $product->attributes;
|
||||
//var_dump($attribs);exit;
|
||||
if(is_array($product->attributes) && array_key_exists("vot", $product->attributes) && $product->attributes["vot"] == 1) {
|
||||
$this->install_products[] = $product;
|
||||
}
|
||||
}
|
||||
//var_dump($this->install_products);exit;
|
||||
return $this->install_products;
|
||||
}
|
||||
|
||||
if($name == "customer_type") {
|
||||
$this->customer_type = "residential";
|
||||
foreach($this->getProperty("products") as $order_product) {
|
||||
|
||||
@@ -67,9 +67,12 @@ class OrderController extends mfBaseController {
|
||||
}
|
||||
}
|
||||
|
||||
$filter = [];
|
||||
$rfilter = $this->request->filter;
|
||||
if(!$rfilter) {
|
||||
$rfilter = [];
|
||||
}
|
||||
|
||||
$this->layout->set("filter", $this->request->filter);
|
||||
$this->layout->set("filter", $rfilter);
|
||||
$filter = $this->getPreparedFilter($this->request->filter);
|
||||
|
||||
// pagination defaults
|
||||
@@ -792,14 +795,16 @@ class OrderController extends mfBaseController {
|
||||
}
|
||||
|
||||
// add techcontact as AddressLink to owner if not exists
|
||||
$link = AddressLinkModel::getFirst(['address_id' => $techcontact->id, 'origin_address_id' => $order->owner_id, 'type' => "techcontact"]);
|
||||
if(!$link) {
|
||||
$linkdata = [];
|
||||
$linkdata['address_id'] = $techcontact->id;
|
||||
$linkdata['origin_address_id'] = $order->owner_id;
|
||||
$linkdata['type'] = "techcontact";
|
||||
$link = AddressLinkModel::create($linkdata);
|
||||
$link->save();
|
||||
if($techcontact->id) {
|
||||
$link = AddressLinkModel::getFirst(['address_id' => $techcontact->id, 'origin_address_id' => $order->owner_id, 'type' => "techcontact"]);
|
||||
if(!$link) {
|
||||
$linkdata = [];
|
||||
$linkdata['address_id'] = $techcontact->id;
|
||||
$linkdata['origin_address_id'] = $order->owner_id;
|
||||
$linkdata['type'] = "techcontact";
|
||||
$link = AddressLinkModel::create($linkdata);
|
||||
$link->save();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -868,6 +873,7 @@ class OrderController extends mfBaseController {
|
||||
continue;
|
||||
}
|
||||
$product_data['termination_id'] = $p['termination_id'];
|
||||
$order_termination_id = $p['termination_id'];
|
||||
} else {
|
||||
$product_data['termination_id'] = null;
|
||||
}
|
||||
@@ -905,59 +911,28 @@ class OrderController extends mfBaseController {
|
||||
$owner->save();
|
||||
}
|
||||
}
|
||||
|
||||
// generate and send Service PIN
|
||||
// only if owner_id wasn't changed
|
||||
if(!$owner->spin && (!property_exists($order->_old_data, "owner_id") || $order->owner_id == $order->_old_data->owner_id)) {
|
||||
$this->log->debug(__CLASS__."::save(): creating new SPIN for ".$owner->getCompanyOrName()." (".$owner->id.")");
|
||||
$spin = $owner->generateServicePin();
|
||||
if($spin && !AddressModel::search(['spin' => $spin])) {
|
||||
$owner->spin = $spin;
|
||||
if($owner->save()) {
|
||||
|
||||
// render service pin PDF
|
||||
$pdf = new PdfForm("Emailtemplates/attachments/new_order_spin.pdf", ["owner" => $owner, "order" => $order]);
|
||||
$pdfpath = $pdf->render();
|
||||
$tvalue = $pdf->getReturnedValues();
|
||||
$pdfname = $tvalue['filename'];
|
||||
|
||||
// send email to customer
|
||||
// TODO template rendern auslagern nach Emailtempate klasse
|
||||
$tpl = new Layout();
|
||||
$tpl->setTemplate("Emailtemplates/customer/new_order");
|
||||
$tpl->set("owner", $owner);
|
||||
$body = $tpl->render();
|
||||
|
||||
$values = $tpl->getReturnedValue();
|
||||
|
||||
$subject = $values['subject'];
|
||||
$from = $values['from_email'];
|
||||
$from_name = $values['from_email_name'];
|
||||
$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')");
|
||||
} else {
|
||||
$email = new Emailnotification();
|
||||
$email->setSubject($subject);
|
||||
$email->setBody($body);
|
||||
$email->setFrom($from, $from_name);
|
||||
$email->setTo($to);
|
||||
$email->setHeader("X-Xinon-Oid", $order->id);
|
||||
$email->setHeader("X-Xinon-Pid", $product->id);
|
||||
$email->addAttachment($pdfpath, null, $pdfname, "application/pdf");
|
||||
$email->send();
|
||||
$this->log->info(__CLASS__."::save(): Sending new SPIN for ".$owner->getCompanyOrName()." (".$owner->id.")");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
} else {
|
||||
$this->log->debug(__CLASS__."::save(): NOT creating new SPIN for ".$owner->getCompanyOrName()." (".$owner->id."): SPIN exists or owner of Order was changed");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// generate and send Service PIN, only if:
|
||||
// - owner does not have a Service PIN yet
|
||||
// - there are no external products
|
||||
// - owner_id was not set before or owner_id wasn't changed
|
||||
|
||||
// TODO: move this to Order class
|
||||
if(!$ext_products && !$owner->spin && (!property_exists($order->_old_data, "owner_id") || $order->owner_id == $order->_old_data->owner_id)) {
|
||||
$this->log->debug(__CLASS__."::save(): creating new SPIN for ".$owner->getCompanyOrName()." (".$owner->id.")");
|
||||
$spin = $owner->generateServicePin();
|
||||
if($spin && !AddressModel::search(['spin' => $spin])) {
|
||||
$owner->spin = $spin;
|
||||
if($owner->save()) {
|
||||
$order->sendSpinEmail();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$this->log->debug(__CLASS__."::save(): NOT creating new SPIN for ".$owner->getCompanyOrName()." (".$owner->id."): SPIN exists or owner of Order was changed or external products");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//var_dump($_FILES['OrderFileUpload']);exit;
|
||||
@@ -1210,8 +1185,24 @@ class OrderController extends mfBaseController {
|
||||
$this->redirect("Order");
|
||||
}
|
||||
|
||||
$pdf_vars = [
|
||||
'order' => $order,
|
||||
'owner' => $owner
|
||||
];
|
||||
|
||||
|
||||
if(TT_CUSTOM_ORDER_PDF_PER_NETOWNER) {
|
||||
$terms = $order->terminations;
|
||||
if(is_array($terms) && count($terms) && $terms[0]->id) {
|
||||
$netowner = $terms[0]->building->network->owner;
|
||||
} else {
|
||||
$netowner = new Address(TT_CUSTOM_ORDER_PDF_DEFAULT_OWNER_ID);
|
||||
}
|
||||
$pdf_vars['netowner'] = $netowner;
|
||||
}
|
||||
|
||||
// render service pin PDF
|
||||
$pdf = new PdfForm("Emailtemplates/attachments/new_order_spin.pdf", ["owner" => $owner, "order" => $order]);
|
||||
$pdf = new PdfForm("Emailtemplates/attachments/new_order_spin.pdf", $pdf_vars);
|
||||
$pdfpath = $pdf->render();
|
||||
$tvalue = $pdf->getReturnedValues();
|
||||
$pdfname = $tvalue['filename'];
|
||||
@@ -1239,45 +1230,13 @@ class OrderController extends mfBaseController {
|
||||
$this->redirect("Order");
|
||||
}
|
||||
|
||||
// render service pin PDF
|
||||
$pdf = new PdfForm("Emailtemplates/attachments/new_order_spin.pdf", ["owner" => $owner, "order" => $order]);
|
||||
$pdfpath = $pdf->render();
|
||||
$tvalue = $pdf->getReturnedValues();
|
||||
$pdfname = $tvalue['filename'];
|
||||
|
||||
// TODO template rendern auslagern nach Emailtempate klasse
|
||||
$tpl = new Layout();
|
||||
$tpl->setTemplate("Emailtemplates/customer/new_order");
|
||||
$tpl->set("owner", $owner);
|
||||
$body = $tpl->render();
|
||||
|
||||
$values = $tpl->getReturnedValue();
|
||||
|
||||
//var_dump($values);exit;
|
||||
|
||||
$subject = $values['subject'];
|
||||
$from = $values['from_email'];
|
||||
$from_name = $values['from_email_name'];
|
||||
$to = $owner->email;
|
||||
|
||||
if(!$subject || !$from || !$from_name || !$to) {
|
||||
$this->log->warn("Service PIN Email not sent. (subject: '$subject', from: '$from', from_email: '$from_name', to: '$to')");
|
||||
$this->layout()->setFlash("Beim Email versenden ist ein Fehler aufgetreten.", "error");
|
||||
$this->redirect("Order");
|
||||
} else {
|
||||
$email = new Emailnotification();
|
||||
$email->setSubject($subject);
|
||||
$email->setBody($body);
|
||||
$email->setFrom($from, $from_name);
|
||||
$email->setTo($to);
|
||||
$email->setHeader("X-Xinon-Oid", $order->id);
|
||||
$email->setHeader("X-Xinon-Pid", $product->id);
|
||||
$email->addAttachment($pdfpath, null, $pdfname, "application/pdf");
|
||||
$email->send();
|
||||
|
||||
if($order->sendSpinEmail()) {
|
||||
$this->layout()->setFlash("Service PIN wurde erfolgreich versendet.", "success");
|
||||
$this->redirect("Order");
|
||||
} else {
|
||||
$this->layout()->setFlash("Fehler beim SPIN Versand!", "success");
|
||||
}
|
||||
|
||||
$this->redirect("Order");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
class Preorder extends mfBaseModel {
|
||||
protected $forcestr = ['street','company','zip','phone','email','note'];
|
||||
private $status;
|
||||
private $campaign;
|
||||
private $partner;
|
||||
private $building;
|
||||
@@ -34,6 +35,94 @@ class Preorder extends mfBaseModel {
|
||||
return $ucode;
|
||||
}
|
||||
|
||||
public function getApiArray() {
|
||||
if(!$this->id) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$hausnummer = $this->getProperty("adb_hausnummer");
|
||||
$wohneinheit = $this->getProperty("adb_wohneinheit");
|
||||
$campaign = $this->getProperty("campaign");
|
||||
|
||||
|
||||
$a = [];
|
||||
$a['code'] = strtoupper($this->ucode);
|
||||
$a['oaid'] = $this->oaid;
|
||||
$a['status'] = $this->getProperty("status")->getApiArray();
|
||||
$a['connectionType'] = $this->connection_type;
|
||||
$a['connectionCount'] = ($this->connection_count) ? (int)$this->connection_count : 1;
|
||||
$a['isAdditionalOrder'] = ($this->is_additional_order) ? true : false;
|
||||
$a['technology'] = ($this->technology) ? $this->technology : null;
|
||||
$a['patchposition'] = ($this->patchposition) ? $this->patchposition : null;
|
||||
$a['preorderType'] = $this->type;
|
||||
$a['acceptMarketing'] = ($this->accept_marketing) ? true : false;
|
||||
$a['acceptAgb'] = ($this->accept_agb) ? true : false;
|
||||
$a['acceptDsgvo'] = ($this->accept_dsgvo) ? true : false;
|
||||
$a['acceptWithdrawal'] = ($this->accept_withdrawal) ? true : false;
|
||||
$a['address_info'] = ($this->address_info) ? $this->address_info : null;
|
||||
|
||||
$address = [];
|
||||
$address['cluster_id'] = $hausnummer->netzgebiet->extref;
|
||||
$address['street'] = $hausnummer->strasse->name;
|
||||
$address['housenumber'] = $hausnummer->hausnummer;
|
||||
$address['zip'] = $hausnummer->plz->plz;
|
||||
$address['city'] = $hausnummer->strasse->gemeinde->name;
|
||||
$address['municipality'] = "";
|
||||
$address['district'] = $hausnummer->ortschaft->name;
|
||||
$address['block'] = ($wohneinheit->block) ? $wohneinheit->block : null;
|
||||
$address['stock'] = ($wohneinheit->stock) ? $wohneinheit->stock : null;
|
||||
$address['stiege'] = ($wohneinheit->stiege) ? $wohneinheit->stiege : null;
|
||||
$address['tuer'] = ($wohneinheit->tuer) ? $wohneinheit->tuer : null;
|
||||
$address['unit_string'] = ($wohneinheit->bezeichner) ? $wohneinheit->bezeichner : null;
|
||||
$address['is_shipping'] = ($this->shipping_address == "address") ? true : false;
|
||||
|
||||
if($campaign->district_is_city) {
|
||||
$address['city'] = $hausnummer->ortschaft->name;
|
||||
$address['municipality'] = $hausnummer->strasse->gemeinde->name;
|
||||
} else {
|
||||
unset($address['municipality']);
|
||||
}
|
||||
|
||||
$customer = [];
|
||||
$customer['company'] = ($this->company) ? $this->company : null;
|
||||
$customer['uid'] = ($this->uid) ? $this->uid : null;
|
||||
$customer['firstnam'] = ($this->firstname) ? $this->firstname : null;
|
||||
$customer['lastname'] = ($this->lastname) ? $this->lastname : null;
|
||||
$customer['street'] = ($this->street) ? $this->street : null;
|
||||
$customer['housenumber'] = ($this->housenumber) ? $this->housenumber : null;
|
||||
$customer['zip'] = ($this->zip) ? $this->zip : null;
|
||||
$customer['city'] = ($this->city) ? $this->city : null;
|
||||
$customer['block'] = ($this->block) ? $this->block : null;
|
||||
$customer['stock'] = ($this->stock) ? $this->stock : null;
|
||||
$customer['stiege'] = ($this->stiege) ? $this->stiege : null;
|
||||
$customer['tuer'] = ($this->tuer) ? $this->tuer : null;
|
||||
$customer['unit_string'] = ($this->unit_string) ? $this->unit_string : null;
|
||||
$customer['phone'] = ($this->phone) ? $this->phone : null;
|
||||
$customer['email'] = ($this->email) ? $this->email : null;
|
||||
|
||||
$a['address'] = $address;
|
||||
$a['customer'] = $customer;
|
||||
|
||||
$a['addonServices'] = null;
|
||||
if($this->addon_services) {
|
||||
$addon_services = json_decode($this->addon_services);
|
||||
if(json_last_error() === JSON_ERROR_NONE) {
|
||||
$a['addonServices'] = $addon_services;
|
||||
}
|
||||
}
|
||||
|
||||
$a['additionalData'] = null;
|
||||
if($this->addon_data) {
|
||||
$addon_data = json_decode($this->addon_data);
|
||||
if(json_last_error() === JSON_ERROR_NONE) {
|
||||
$a['additionalData'] = $addon_data;
|
||||
}
|
||||
}
|
||||
|
||||
return $a;
|
||||
}
|
||||
|
||||
|
||||
public function getProperty($name) {
|
||||
if($this->$name == null) {
|
||||
|
||||
@@ -42,6 +131,17 @@ class Preorder extends mfBaseModel {
|
||||
return $this->campaign;
|
||||
}
|
||||
|
||||
if($name == "status") {
|
||||
$this->status = mfValuecache::singleton()->get("mfObjectmodel-Preorderstatus-".$this->status_id);
|
||||
if(!$this->status) {
|
||||
$this->status = new Preorderstatus($this->status_id);
|
||||
if($this->status->id) {
|
||||
mfValuecache::singleton()->set("mfObjectmodel-Preorderstatus-".$this->status_id, $this->status);
|
||||
}
|
||||
}
|
||||
return $this->status;
|
||||
}
|
||||
|
||||
if($name == "partner") {
|
||||
$this->partner = mfValuecache::singleton()->get("mfObjectmodel-Address-".$this->partner_id);
|
||||
if(!$this->partner) {
|
||||
@@ -74,6 +174,9 @@ class Preorder extends mfBaseModel {
|
||||
return $this->adb_wohneinheit;
|
||||
}
|
||||
|
||||
if($name == "addon_services") {
|
||||
|
||||
}
|
||||
|
||||
if($name == "creator") {
|
||||
$user = mfValuecache::singleton()->get("Worker-id-".$this->create_by);
|
||||
|
||||
@@ -9,7 +9,7 @@ class PreorderController extends mfBaseController {
|
||||
$this->me = $me;
|
||||
$this->layout()->set("me",$me);
|
||||
|
||||
if(!$me->is(["Admin", "salespartner"])) {
|
||||
if(!$me->is(["Admin", "netowner", "salespartner"])) {
|
||||
$this->redirect("Dashboard");
|
||||
}
|
||||
}
|
||||
@@ -37,21 +37,49 @@ class PreorderController extends mfBaseController {
|
||||
$pagination['start'] = intval($this->request->s);
|
||||
}
|
||||
|
||||
$campaign_filter = [];
|
||||
$preorder_filter = $filter;
|
||||
$my_campaigns = [];
|
||||
$my_campaign_ids = [];
|
||||
|
||||
if($filter['preordercampaign_id']) {
|
||||
$campaign_id = $filter['preordercampaign_id'];
|
||||
if(is_numeric($campaign_id) && $campaign_id > 0) {
|
||||
$campaign = new Preordercampaign($campaign_id);
|
||||
$this->layout()->set("campaign", $campaign);
|
||||
if($this->me->is("Admin")) {
|
||||
if($filter['preordercampaign_id']) {
|
||||
$this->layout()->set("campaign", new Preordercampaign($filter['preordercampaign_id']));
|
||||
} else {
|
||||
$my_campaigns = PreordercampaignModel::getAll();
|
||||
}
|
||||
$this->layout()->set("my_campaigns", PreordercampaignModel::getAll());
|
||||
} else {
|
||||
$my_networks = $this->me->myNetworks(["netowner", "salespartner"]);
|
||||
//var_dump($my_networks);exit;
|
||||
|
||||
foreach($my_networks as $network) {
|
||||
foreach(PreordercampaignModel::search(['network_id' => $network->id]) as $campaign) {
|
||||
$my_campaigns[] = $campaign;
|
||||
if(!in_array($campaign->id, $my_campaign_ids)) $my_campaign_ids[] = $campaign->id;
|
||||
}
|
||||
}
|
||||
//var_dump($my_network_ids,$my_campaign_ids);exit;
|
||||
$this->layout()->set("my_campaigns", $my_campaigns);
|
||||
|
||||
if($filter['preordercampaign_id'] && in_array($filter['preordercampaign_id'], $my_campaign_ids)) {
|
||||
$campaign_id = $filter['preordercampaign_id'];
|
||||
if(is_numeric($campaign_id) && $campaign_id > 0) {
|
||||
$campaign = new Preordercampaign($campaign_id);
|
||||
$this->layout()->set("campaign", $campaign);
|
||||
}
|
||||
} else {
|
||||
$filter['preordercampaign_id'] = $my_campaign_ids;
|
||||
}
|
||||
}
|
||||
//var_dump($filter);exit;
|
||||
|
||||
$pagination['maxItems'] = PreorderModel::count($filter);
|
||||
if($filter['addon_services']) {
|
||||
$pagination['maxItems'] = PreorderModel::countOrderedAddonservices($filter);
|
||||
$preorders = PreorderModel::searchOrderedAddonservices($filter, $pagination);
|
||||
} else {
|
||||
$pagination['maxItems'] = PreorderModel::count($filter);
|
||||
$preorders = PreorderModel::search($filter, $pagination);
|
||||
}
|
||||
$this->layout()->set("pagination", $pagination);
|
||||
|
||||
$preorders = PreorderModel::search($filter, $pagination);
|
||||
$this->layout()->set("preorders", $preorders);
|
||||
|
||||
}
|
||||
@@ -75,12 +103,27 @@ class PreorderController extends mfBaseController {
|
||||
|
||||
if(array_key_exists("address", $filter)) {
|
||||
$address = $this->db()->escape($filter['address']);
|
||||
$new_filter['add-where'] = " AND (adb_hausnummer.gemeinde like '%$address%' OR adb_hausnummer.plz like '%$address%' OR adb_hausnummer.strasse like '%$address%')";
|
||||
$new_filter['add-where'] .= " AND (adb_hausnummer.gemeinde like '%$address%' OR adb_hausnummer.plz like '%$address%' OR adb_hausnummer.strasse like '%$address%')";
|
||||
}
|
||||
|
||||
if(array_key_exists("kunde", $filter)) {
|
||||
$kunde = $this->db()->escape($filter['kunde']);
|
||||
$new_filter['add-where'] = " AND (firstname like '%$kunde%' OR lastname like '%$kunde%' OR street like '%$kunde%' OR zip like '%$kunde%' OR city like '%$kunde%')";
|
||||
$new_filter['add-where'] .= " AND (company like '%$kunde%' OR firstname like '%$kunde%' OR lastname like '%$kunde%' OR street like '%$kunde%' OR zip like '%$kunde%' OR city like '%$kunde%')";
|
||||
}
|
||||
|
||||
|
||||
$new_filter['addon_services'] = false;
|
||||
if(array_key_exists("addon_services", $filter) && $filter['addon_services'] == 1) {
|
||||
$new_filter['addon_services'] = true;
|
||||
}
|
||||
|
||||
if(array_key_exists("address_source", $filter)) {
|
||||
if($filter['address_source'] == "manual") {
|
||||
$new_filter['address_created'] = true;
|
||||
}
|
||||
if($filter['address_source'] == "addressdb") {
|
||||
$new_filter['address_created'] = null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -121,7 +164,7 @@ class PreorderController extends mfBaseController {
|
||||
//var_dump($products);exit;
|
||||
$this->layout()->set("products", $products);
|
||||
|
||||
$partners = AddressModel::search(['addresstype' => ['salespartner']]);
|
||||
$partners = AddressModel::search(['addresstype' => ['netowner','salespartner']]);
|
||||
$this->layout()->set("partners", $partners);
|
||||
}
|
||||
|
||||
@@ -149,7 +192,7 @@ class PreorderController extends mfBaseController {
|
||||
|
||||
protected function saveAction() {
|
||||
$r = $this->request;
|
||||
//var_dump($r);
|
||||
//var_dump($r);exit;
|
||||
|
||||
/*
|
||||
* add or edit
|
||||
@@ -232,28 +275,33 @@ class PreorderController extends mfBaseController {
|
||||
$data['accept_marketing'] = 1;
|
||||
}
|
||||
|
||||
$data['price'] = ($r->price) ? $r->price : 0;
|
||||
$data['price_setup'] = ($r->price_setup) ? $r->price_setup : 0;
|
||||
$data['price_nne'] = ($r->price_nne) ? $r->price_nne : 0;
|
||||
$data['price_nbe'] = ($r->price_nbe) ? $r->price_nbe : 0;
|
||||
$data['price'] = ($r->price) ? Layout::commaToDot($r->price) : 0;
|
||||
$data['price_setup'] = ($r->price_setup) ? Layout::commaToDot($r->price_setup) : 0;
|
||||
$data['price_nne'] = ($r->price_nne) ? Layout::commaToDot($r->price_nne) : 0;
|
||||
$data['price_nbe'] = ($r->price_nbe) ? Layout::commaToDot($r->price_nbe) : 0;
|
||||
$data['billing_delay'] = ($r->billing_delay) ? $r->billing_delay : 0;
|
||||
|
||||
//var_dump($r->partner_id);exit;
|
||||
if($r->partner_id) {
|
||||
$data['partner_id'] = $r->partner_id;
|
||||
} else {
|
||||
$data['partner_id'] = null;
|
||||
}
|
||||
|
||||
$data['company'] = $r->company;
|
||||
$data['uid'] = $r->uid;
|
||||
$data['firstname'] = $r->firstname;
|
||||
$data['lastname'] = $r->lastname;
|
||||
$data['street'] = $r->street;
|
||||
$data['zip'] = $r->zip;
|
||||
$data['city'] = $r->city;
|
||||
$data['phone'] = $r->phone;
|
||||
$data['email'] = $r->email;
|
||||
$data['note'] = $r->note;
|
||||
$data['company'] = (trim($r->company)) ? trim($r->company) : null;
|
||||
$data['uid'] = (trim($r->uid)) ? trim($r->uid) : null;
|
||||
$data['firstname'] = (trim($r->firstname)) ? trim($r->firstname) : null;
|
||||
$data['lastname'] = (trim($r->lastname)) ? trim($r->lastname) : null;
|
||||
$data['street'] = (trim($r->street)) ? trim($r->street) : null;
|
||||
$data['housenumber'] = (trim($r->housenumber)) ? trim($r->housenumber) : null;
|
||||
$data['block'] = (trim($r->block)) ? trim($r->block) : null;
|
||||
$data['stiege'] = (trim($r->stiege)) ? trim($r->stiege) : null;
|
||||
$data['stock'] = (trim($r->stock)) ? trim($r->stock) : null;
|
||||
$data['tuer'] = (trim($r->tuer)) ? trim($r->tuer) : null;
|
||||
$data['zip'] = (trim($r->zip)) ? trim($r->zip) : null;
|
||||
$data['city'] = (trim($r->city)) ? trim($r->city) : null;
|
||||
$data['phone'] = (trim($r->phone)) ? trim($r->phone) : null;
|
||||
$data['email'] = (trim($r->email)) ? trim($r->email) : null;
|
||||
$data['note'] = (trim($r->note)) ? trim($r->note) : null;
|
||||
|
||||
$data['edit_by'] = $this->me->id;
|
||||
|
||||
@@ -263,16 +311,173 @@ class PreorderController extends mfBaseController {
|
||||
} else {
|
||||
$preorder->update($data);
|
||||
}
|
||||
|
||||
/*
|
||||
* validation
|
||||
*/
|
||||
|
||||
$campaign = new Preordercampaign($preorder->preordercampaign_id);
|
||||
if(!$campaign->id) {
|
||||
$this->layout()->setFlash("Keine Kampagne ausgewählt!", "error");
|
||||
$this->redirect("Preordercampaign");
|
||||
}
|
||||
//var_dump($preorder, $r);exit;
|
||||
// handle new address creation
|
||||
if(!$preorder->adb_hausnummer_id) {
|
||||
// check if new address was submitted
|
||||
$this->log->debug("check if new address was submitted");
|
||||
if($r->new_address_street && $r->new_address_housenumber && $r->new_address_zip && $r->new_address_city && $r->new_address_district) {
|
||||
$city_search = trim($r->new_address_city);
|
||||
$district_search = trim($r->new_address_district);
|
||||
$zip_search = trim($r->new_address_zip);
|
||||
$street_search = trim($r->new_address_street);
|
||||
$housenumber_search = trim($r->new_address_housenumber);
|
||||
|
||||
$block = trim($r->new_address_block);
|
||||
$stiege = trim($r->new_address_stiege);
|
||||
$stock = trim($r->new_address_stock);
|
||||
$tuer = trim($r->new_address_tuer);
|
||||
|
||||
$preorder->new_address_city = $city_search;
|
||||
$preorder->new_address_district = $district_search;
|
||||
$preorder->new_address_zip = $zip_search;
|
||||
$preorder->new_address_street = $street_search;
|
||||
$preorder->new_address_housenumber = $housenumber_search;
|
||||
|
||||
|
||||
$netzgebiet_ids = [];
|
||||
foreach($campaign->salesclusters as $scluster) {
|
||||
$netzgebiet_ids[] = $scluster->id;
|
||||
}
|
||||
$netzgebiet_id = $netzgebiet_ids[0];
|
||||
if(!$netzgebiet_id) {
|
||||
$this->layout()->setFlash("Kann Adresse nicht updaten: Kampagne hat kein Netzgebiet", "error");
|
||||
$this->layout()->set("preorder", $preorder);
|
||||
$this->layout()->set("campaign", $campaign);
|
||||
return $this->addAction();
|
||||
}
|
||||
$netzgebiet = new ADBNetzgebiet($netzgebiet_id);
|
||||
if(!$netzgebiet->id) {
|
||||
$this->layout()->setFlash("Neztgebiet nicht gefunden", "error");
|
||||
$this->layout()->set("preorder", $preorder);
|
||||
$this->layout()->set("campaign", $campaign);
|
||||
return $this->addAction();
|
||||
}
|
||||
|
||||
$city = ADBGemeindeModel::getFirst(['name' => $city_search, 'netzgebiet_id' => $netzgebiet_id]);
|
||||
if(!$city) {
|
||||
$this->layout()->setFlash("Gemeinde nicht Adress-DB gefunden", "error");
|
||||
$this->layout()->set("preorder", $preorder);
|
||||
$this->layout()->set("campaign", $campaign);
|
||||
return $this->addAction();
|
||||
}
|
||||
|
||||
$district = ADBOrtschaftModel::getFirst(['name' => $district_search, 'netzgebiet_id' => $netzgebiet_id]);
|
||||
if(!$district) {
|
||||
$this->layout()->setFlash("Ortsteil nicht Adress-DB gefunden", "error");
|
||||
$this->layout()->set("preorder", $preorder);
|
||||
$this->layout()->set("campaign", $campaign);
|
||||
return $this->addAction();
|
||||
}
|
||||
|
||||
$zip = ADBPlzModel::getFirst(['plz' => $zip_search, 'gemeinde_id' => $city->id]);
|
||||
if(!$zip) {
|
||||
$this->layout()->setFlash("PLZ nicht Adress-DB gefunden", "error");
|
||||
$this->layout()->set("preorder", $preorder);
|
||||
$this->layout()->set("campaign", $campaign);
|
||||
return $this->addAction();
|
||||
}
|
||||
|
||||
$street = ADBStrasseModel::getFirst(['name' => $street_search, 'gemeinde_id' => $city->id]);
|
||||
if(!$street) {
|
||||
$this->log->debug("create street");
|
||||
$street = ADBStrasseModel::create([
|
||||
'ortschaft_id' => $district->id,
|
||||
'gemeinde_id' => $city->id,
|
||||
'name' => $street_search
|
||||
]);
|
||||
|
||||
if(!$street->save()) {
|
||||
$this->layout()->setFlash("Fehler beim Speichern der neuen Straße", "error");
|
||||
$this->layout()->set("preorder", $preorder);
|
||||
$this->layout()->set("campaign", $campaign);
|
||||
return $this->addAction();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$this->log->debug("search hausnummer");
|
||||
$hausnummer = ADBHausnummerModel::getFirst(['netzgebiet_id' => $netzgebiet_ids, 'ortschaft_id' => $district_search, 'gemeinde_id' => $city->id, 'plz_id' => $zip->id, 'strasse_id' => $street->id, 'hausnummer' => $housenumber_search]);
|
||||
if($hausnummer) {
|
||||
// hausnummer gibts scho!
|
||||
$this->layout()->setFlash("Adresse war schon vorhanden!", "warn");
|
||||
$preorder->adb_hausnummer_id = $hausnummer->id;
|
||||
} else {
|
||||
// try with empty netzgebiet
|
||||
$this->log->debug("search hausnummer mit empty netzgebiet");
|
||||
$hausnummer = ADBHausnummerModel::getFirst(['netzgebiet_id' => null, 'ortschaft_id' => $district_search, 'gemeinde_id' => $city->id, 'plz_id' => $zip->id, 'strasse_id' => $street->id, 'hausnummer' => $housenumber_search]);
|
||||
if($hausnummer) {
|
||||
// Hausnummer ohne Netzgebiet gefunden -> update netzgebiet_id
|
||||
$this->log->debug("hausnummer id: updated netzgebiet from NULL to ".$netzgebiet_ids);
|
||||
$hausnummer->netzgebiet_id = $netzgebiet_id;
|
||||
$hausnummer->save();
|
||||
$preorder->adb_hausnummer_id = $hausnummer->id;
|
||||
} else {
|
||||
// try with any netzgebiet
|
||||
$this->log->debug("search hausnummer with ohne netzgebiet");
|
||||
$hausnummer = ADBHausnummerModel::getFirst(['ortschaft_id' => $district_search, 'gemeinde_id' => $city->id, 'plz_id' => $zip->id, 'strasse_id' => $street->id, 'hausnummer' => $housenumber_search]);
|
||||
if($hausnummer) {
|
||||
$this->log->debug("Hausnummer ".$hausnummer->id." in Netzgebiet (".implode(",", $netzgebiet_ids)." gesucht, aber in ".$hausnummer->netzgebiet_id)." gefunden";
|
||||
$this->layout()->setFlash("Neue Adresse ist bereits im Netzgebiet ".$hausnummer->netzgebiet->name." vorhanden", "error");
|
||||
$this->layout()->set("preorder", $preorder);
|
||||
$this->layout()->set("campaign", $campaign);
|
||||
return $this->addAction();
|
||||
} else {
|
||||
// hausnummer anlegen
|
||||
$hausnummer = ADBHausnummerModel::create([
|
||||
'netzgebiet_id' => $netzgebiet_id,
|
||||
'ortschaft_id' => $district->id,
|
||||
'plz_id' => $zip->id,
|
||||
'strasse_id' => $street->id,
|
||||
'hausnummer' => $housenumber_search,
|
||||
'freigabe' => $netzgebiet->freigabe,
|
||||
'manual_add' => date('U'),
|
||||
'manual_add_by' => $this->me->id,
|
||||
'manual_add_info' => "thetool user ".$this->me->username." via Preorder create"
|
||||
]);
|
||||
|
||||
if(!$hausnummer->save()) {
|
||||
$this->layout()->setFlash("Fehler beim Speichern der neuen Adresse", "error");
|
||||
$this->layout()->set("preorder", $preorder);
|
||||
$this->layout()->set("campaign", $campaign);
|
||||
return $this->addAction();
|
||||
}
|
||||
$preorder->adb_hausnummer_id = $hausnummer->id;
|
||||
$preorder->address_created = date('U');
|
||||
$preorder->address_created_by = $this->me->id;
|
||||
$preorder->adb_wohneinheit_id = null;
|
||||
|
||||
// create wohneinheit
|
||||
$wohneinheit = ADBWohneinheitModel::create([
|
||||
'hausnummer_id' => $hausnummer->id,
|
||||
'num' => 1,
|
||||
'block' => ($block) ? $block : null,
|
||||
'stiege' => ($stiege) ? $stiege : null,
|
||||
'stock' => ($stock) ? $stock : null,
|
||||
'tuer' => ($tuer) ? $tuer : null
|
||||
]);
|
||||
if($wohneinheit->save()) {
|
||||
$preorder->adb_wohneinheit_id = $wohneinheit->id;
|
||||
} else {
|
||||
$this->layout()->setFlash("Konnte Wohneinheit nicht speichern", "warn");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* validation
|
||||
*/
|
||||
|
||||
if(!array_key_exists($data['type'], $campaign->types)) {
|
||||
$this->layout()->setFlash("Bitte Vorbestelltyp auswählen!", "error");
|
||||
@@ -324,6 +529,12 @@ class PreorderController extends mfBaseController {
|
||||
|
||||
//var_dump($preorder);exit;
|
||||
|
||||
// unset temporary properties
|
||||
unset($preorder->new_address_city);
|
||||
unset($preorder->new_address_district);
|
||||
unset($preorder->new_address_zip);
|
||||
unset($preorder->new_address_street);
|
||||
unset($preorder->new_address_housenumber);
|
||||
|
||||
/*
|
||||
* generate ucode and save
|
||||
@@ -337,7 +548,7 @@ class PreorderController extends mfBaseController {
|
||||
}
|
||||
|
||||
|
||||
$qs = ['filter' => ['campaign_id' => $preorder->preordercampaign_id]];
|
||||
$qs = ['filter' => ['preordercampaign_id' => $preorder->preordercampaign_id, 'ucode' => $preorder->ucode]];
|
||||
$qs = http_build_query($qs);
|
||||
|
||||
$this->layout()->setFlash("Vorbestellung erfolgreich gespeichert!", "success");
|
||||
|
||||
@@ -2,9 +2,12 @@
|
||||
|
||||
class PreorderModel {
|
||||
public $ucode;
|
||||
public $status_id;
|
||||
public $preordercampaign_id;
|
||||
public $adb_hausnummer_id;
|
||||
public $adb_wohneinheit_id;
|
||||
public $oaid;
|
||||
public $address_district;
|
||||
public $address_info;
|
||||
public $building_id;
|
||||
public $termination_id;
|
||||
@@ -31,15 +34,32 @@ class PreorderModel {
|
||||
public $firstname;
|
||||
public $lastname;
|
||||
public $street;
|
||||
public $housenumber;
|
||||
public $block;
|
||||
public $stiege;
|
||||
public $stock;
|
||||
public $tuer;
|
||||
public $unit_string;
|
||||
public $zip;
|
||||
public $city;
|
||||
public $phone;
|
||||
public $email;
|
||||
public $technology;
|
||||
public $patchposition;
|
||||
public $is_additional_order;
|
||||
public $shipping_address;
|
||||
public $addon_services;
|
||||
public $addon_data;
|
||||
public $submit_type;
|
||||
public $submit_request;
|
||||
|
||||
public $cancel_request;
|
||||
public $cancel_request_by;
|
||||
public $cancel_approved;
|
||||
public $cancel_approved_by;
|
||||
public $deleted;
|
||||
public $deleted_by;
|
||||
|
||||
public $note;
|
||||
|
||||
public $create_by;
|
||||
@@ -93,11 +113,26 @@ class PreorderModel {
|
||||
|
||||
}
|
||||
|
||||
public static function getFirst() {
|
||||
public static function getFirst($filter = false, $order = false) {
|
||||
$db = FronkDB::singleton();
|
||||
|
||||
$where = self::getSqlFilter($filter);
|
||||
$res = $db->select("Preorder", "*", "$where ORDER BY lastname, firstname");
|
||||
|
||||
$orderBy = "lastname, firstname";
|
||||
if($order) $orderBy = $order;
|
||||
|
||||
$sql = "SELECT tt_preorder.* FROM `".FRONKDB_DBNAME."`.Preorder tt_preorder
|
||||
LEFT JOIN `".FRONKDB_DBNAME."`.Preorderstatus tt_preorderstatus ON (tt_preorder.status_id = tt_preorderstatus.id)
|
||||
LEFT JOIN `".ADDRESSDB_DBNAME."`.view_hausnummer as adb_hausnummer ON (tt_preorder.adb_hausnummer_id = adb_hausnummer.hausnummer_id)
|
||||
WHERE $where
|
||||
ORDER BY $orderBy
|
||||
LIMIT 1
|
||||
";
|
||||
|
||||
mfLoghandler::singleton()->debug($sql);
|
||||
|
||||
$res = $db->query($sql);
|
||||
|
||||
if($db->num_rows($res)) {
|
||||
$data = $db->fetch_object($res);
|
||||
$item = new Preorder($data);
|
||||
@@ -110,6 +145,71 @@ class PreorderModel {
|
||||
return null;
|
||||
}
|
||||
|
||||
public static function countOrderedAddonservices($filter) {
|
||||
$db = FronkDB::singleton();
|
||||
|
||||
$where = self::getSqlFilter($filter);
|
||||
$sql = "SELECT COUNT(*) AS cnt FROM `".FRONKDB_DBNAME."`.Preorder tt_preorder
|
||||
LEFT JOIN `".ADDRESSDB_DBNAME."`.view_hausnummer as adb_hausnummer ON (tt_preorder.adb_hausnummer_id = adb_hausnummer.hausnummer_id),
|
||||
JSON_TABLE(addon_services,
|
||||
'$[*]' COLUMNS (
|
||||
ordered VARCHAR(64) PATH '$.ordered'
|
||||
)
|
||||
) a_services
|
||||
WHERE $where
|
||||
AND addon_services IS NOT NULL AND (a_services.ordered = 'true' OR a_services.ordered=1)
|
||||
GROUP BY tt_preorder.id
|
||||
";
|
||||
|
||||
mfLoghandler::singleton()->debug($sql);
|
||||
|
||||
$res = $db->query($sql);
|
||||
if($db->num_rows($res)) {
|
||||
$data = $db->fetch_object($res);
|
||||
return $data->cnt;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static function searchOrderedAddonservices($filter, $limit = false) {
|
||||
$items = [];
|
||||
$db = FronkDB::singleton();
|
||||
|
||||
$where = self::getSqlFilter($filter);
|
||||
|
||||
$sql = "SELECT tt_preorder.* FROM `".FRONKDB_DBNAME."`.Preorder tt_preorder
|
||||
LEFT JOIN `".ADDRESSDB_DBNAME."`.view_hausnummer as adb_hausnummer ON (tt_preorder.adb_hausnummer_id = adb_hausnummer.hausnummer_id),
|
||||
JSON_TABLE(addon_services,
|
||||
'$[*]' COLUMNS (
|
||||
ordered VARCHAR(64) PATH '$.ordered'
|
||||
)
|
||||
) a_services
|
||||
WHERE $where
|
||||
AND addon_services IS NOT NULL AND (a_services.ordered = 'true' OR a_services.ordered=1)
|
||||
GROUP BY tt_preorder.id
|
||||
ORDER BY lastname, firstname
|
||||
|
||||
";
|
||||
|
||||
if(is_array($limit) && count($limit)) {
|
||||
if(is_numeric($limit['start']) && is_numeric($limit['count'])) {
|
||||
$sql .= " LIMIT ".$limit['start'].", ".$limit['count'];
|
||||
} elseif(is_numeric($count)) {
|
||||
$sql .= " LIMIT ".$limit['count'];
|
||||
}
|
||||
}
|
||||
|
||||
mfLoghandler::singleton()->debug($sql);
|
||||
|
||||
$res = $db->query($sql);
|
||||
if($db->num_rows($res)) {
|
||||
while($data = $db->fetch_object($res)) {
|
||||
$items[] = new Preorder($data);
|
||||
}
|
||||
}
|
||||
return $items;
|
||||
}
|
||||
|
||||
public static function count($filter) {
|
||||
$db = FronkDB::singleton();
|
||||
|
||||
@@ -136,6 +236,7 @@ class PreorderModel {
|
||||
$where = self::getSqlFilter($filter);
|
||||
|
||||
$sql = "SELECT tt_preorder.* FROM `".FRONKDB_DBNAME."`.Preorder tt_preorder
|
||||
LEFT JOIN `".FRONKDB_DBNAME."`.Preorderstatus tt_preorderstatus ON (tt_preorder.status_id = tt_preorderstatus.id)
|
||||
LEFT JOIN `".ADDRESSDB_DBNAME."`.view_hausnummer as adb_hausnummer ON (tt_preorder.adb_hausnummer_id = adb_hausnummer.hausnummer_id)
|
||||
WHERE $where
|
||||
ORDER BY lastname, firstname
|
||||
@@ -172,10 +273,63 @@ class PreorderModel {
|
||||
}
|
||||
}
|
||||
|
||||
if(array_key_exists("partner_id", $filter)) {
|
||||
$partner_id = $filter['partner_id'];
|
||||
if(is_numeric($partner_id)) {
|
||||
$where .= " AND partner_id=$partner_id";
|
||||
}
|
||||
}
|
||||
|
||||
if(array_key_exists("status_id", $filter)) {
|
||||
$status_id = $filter['status_id'];
|
||||
if(is_numeric($status_id)) {
|
||||
$where .= " AND status_id=$status_id";
|
||||
}
|
||||
}
|
||||
|
||||
if(array_key_exists("<status_id", $filter)) {
|
||||
$status_id = $filter['<status_id'];
|
||||
if(is_numeric($status_id)) {
|
||||
$where .= " AND status_id < $status_id";
|
||||
}
|
||||
}
|
||||
|
||||
if(array_key_exists(">status_id", $filter)) {
|
||||
$status_id = $filter['>status_id'];
|
||||
if(is_numeric($status_id)) {
|
||||
$where .= " AND status_id > $status_id";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if(array_key_exists("status_code", $filter)) {
|
||||
$status_code = $filter['status_code'];
|
||||
if(is_numeric($status_code)) {
|
||||
$where .= " AND tt_preorderstatus.code=$status_code";
|
||||
}
|
||||
}
|
||||
|
||||
if(array_key_exists("<status_code", $filter)) {
|
||||
$status_code = $filter['<status_code'];
|
||||
if(is_numeric($status_code)) {
|
||||
$where .= " AND tt_preorderstatus.code < $status_code";
|
||||
}
|
||||
}
|
||||
|
||||
if(array_key_exists(">status_code", $filter)) {
|
||||
$status_code = $filter['>status_code'];
|
||||
if(is_numeric($status_code)) {
|
||||
$where .= " AND tt_preorderstatus.code > $status_code";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if(array_key_exists("preordercampaign_id", $filter)) {
|
||||
$preordercampaign_id = $filter['preordercampaign_id'];
|
||||
if(is_numeric($preordercampaign_id)) {
|
||||
$where .= " AND preordercampaign_id=$preordercampaign_id";
|
||||
} elseif(is_array($preordercampaign_id) && count($preordercampaign_id)) {
|
||||
$where .= " AND preordercampaign_id IN (". implode(",", $preordercampaign_id).")";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -212,6 +366,15 @@ class PreorderModel {
|
||||
}
|
||||
}
|
||||
|
||||
if(array_key_exists("address_created", $filter)) {
|
||||
$address_created = $filter['address_created'];
|
||||
if($address_created === true) {
|
||||
$where .= " AND address_created > 0";
|
||||
} elseif($address_created == null) {
|
||||
$where .= " AND address_created IS NULL";
|
||||
}
|
||||
}
|
||||
|
||||
if(array_key_exists("type", $filter)) {
|
||||
$type = $filter['type'];
|
||||
if(is_array($type) && count($type)) {
|
||||
@@ -224,13 +387,31 @@ class PreorderModel {
|
||||
}
|
||||
}
|
||||
|
||||
if(array_key_exists("ucode", $filter)) {
|
||||
$ucode = FronkDB::singleton()->escape($filter['ucode']);
|
||||
if($ucode) {
|
||||
$where .= " AND ucode like '%$ucode%'";
|
||||
if(array_key_exists("connection_type", $filter)) {
|
||||
$connection_type = $filter['connection_type'];
|
||||
if(is_array($connection_type) && count($connection_type)) {
|
||||
$where .= " AND connection_type IN ('".implode("','",$connection_type)."')";
|
||||
} else {
|
||||
$connection_type = FronkDB::singleton()->escape($filter['connection_type']);
|
||||
if($connection_type) {
|
||||
$where .= " AND connection_type like '%$connection_type%'";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(array_key_exists("ucode", $filter)) {
|
||||
$ucode = FronkDB::singleton()->escape($filter['ucode']);
|
||||
if($ucode) {
|
||||
$where .= " AND ucode = '$ucode'";
|
||||
}
|
||||
}
|
||||
|
||||
if(array_key_exists("oaid", $filter)) {
|
||||
$oaid = FronkDB::singleton()->escape($filter['oaid']);
|
||||
if($oaid) {
|
||||
$where .= " AND tt_preorder.oaid = '$oaid'";
|
||||
}
|
||||
}
|
||||
|
||||
if(array_key_exists("gemeinde", $filter)) {
|
||||
$gemeinde = FronkDB::singleton()->escape($filter['gemeinde']);
|
||||
@@ -253,6 +434,7 @@ class PreorderModel {
|
||||
}
|
||||
}
|
||||
|
||||
// custom where clause
|
||||
if(array_key_exists("add-where", $filter)) {
|
||||
$where .= " ".$filter['add-where'];
|
||||
}
|
||||
|
||||
@@ -139,7 +139,7 @@ class Preordercampaign extends mfBaseModel {
|
||||
if($name == "salesclusters") {
|
||||
$items = PreordercampaignSalesclusterModel::search(["preordercampaign_id" => $this->id]);
|
||||
foreach($items as $pog) {
|
||||
$this->salesclusters[$pog->salescluster_id] = $pog;
|
||||
$this->salesclusters[$pog->salescluster_id] = new ADBNetzgebiet($pog->salescluster_id);
|
||||
}
|
||||
return $this->salesclusters;
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ class PreordercampaignController extends mfBaseController {
|
||||
$this->me = $me;
|
||||
$this->layout()->set("me",$me);
|
||||
|
||||
if(!$me->is(["Admin", "salespartner"])) {
|
||||
if(!$me->is(["Admin", "netowner", "salespartner"])) {
|
||||
$this->redirect("Dashboard");
|
||||
}
|
||||
}
|
||||
@@ -19,6 +19,7 @@ class PreordercampaignController extends mfBaseController {
|
||||
|
||||
$this->layout->set("filter", $this->request->filter);
|
||||
|
||||
$filter = [];
|
||||
if($this->request->filter) {
|
||||
$filter = $this->getPreparedFilter($this->request->filter);
|
||||
}
|
||||
@@ -34,43 +35,75 @@ class PreordercampaignController extends mfBaseController {
|
||||
}
|
||||
|
||||
$my_networks = [];
|
||||
|
||||
//var_dump($filter);exit;
|
||||
if($this->me->is("Admin")) {
|
||||
if($filter['network_id']) {
|
||||
if(!is_array($filter['network_id']) && $filter['network_id']) {
|
||||
$my_networks[] = new Network($filter['network_id']);
|
||||
} else {
|
||||
$my_networks = NetworkModel::getAll();
|
||||
}
|
||||
$this->layout()->set("mynetworks", NetworkModel::getAll());
|
||||
|
||||
$netowners = $this->getNetworkOwners($my_network_ids);
|
||||
$this->layout()->set("netowners", $netowners);
|
||||
|
||||
} else {
|
||||
$use_filter_network = false;
|
||||
$my_networks = $this->me->my_networks;
|
||||
|
||||
$my_networks = $this->me->myNetworks(["netowner", "salespartner"]);
|
||||
//var_dump($my_networks);exit;
|
||||
foreach($my_networks as $mn) {
|
||||
if($mn->id == $filter['network_id']) {
|
||||
$use_filter_network = true;
|
||||
continue;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
$this->layout()->set("mynetworks", $my_networks);
|
||||
|
||||
if($use_filter_network) {
|
||||
$my_networks = [];
|
||||
$my_networks[] = new Network($filter['network_id']);
|
||||
}
|
||||
|
||||
$this->layout()->set("mynetworks", $this->me->my_networks);
|
||||
|
||||
$my_network_ids = [];
|
||||
foreach($my_networks as $network) {
|
||||
$my_network_ids[] = $network->id;
|
||||
}
|
||||
$filter['network_id'] = $my_network_ids;
|
||||
}
|
||||
unset($filter['network_id']);
|
||||
|
||||
$campaigns = PreordercampaignModel::search(['network_id' => $my_networks]);
|
||||
|
||||
|
||||
$campaigns = PreordercampaignModel::search($filter);
|
||||
$this->layout()->set("campaigns", $campaigns);
|
||||
|
||||
|
||||
}
|
||||
|
||||
private function getPreparedFilter($filter) {
|
||||
$new_filter = [];
|
||||
|
||||
if(array_key_exists("netowner", $filter) && $filter['netowner']) {
|
||||
if($this->me->is("Admin")) {
|
||||
$owner_id = $filter['netowner'];
|
||||
foreach(NetworkModel::search(['owner_id' => $owner_id]) as $network) {
|
||||
$new_filter['network_id'][] = $network->id;
|
||||
}
|
||||
unset($filter['network_id']);
|
||||
} else {
|
||||
unset($filter['netowner']);
|
||||
}
|
||||
}
|
||||
|
||||
if(array_key_exists("name", $filter) && $filter['name']) {
|
||||
$new_filter['name%'] = "%".$filter['name'];
|
||||
unset($filter['name']);
|
||||
}
|
||||
if(array_key_exists("area", $filter) && $filter['area']) {
|
||||
$new_filter['area%'] = "%".$filter['area'];
|
||||
unset($filter['area']);
|
||||
}
|
||||
|
||||
foreach($filter as $name => $value) {
|
||||
$new_filter[$name] = $value;
|
||||
}
|
||||
@@ -78,7 +111,30 @@ class PreordercampaignController extends mfBaseController {
|
||||
return $new_filter;
|
||||
}
|
||||
|
||||
private function getNetworkOwners() {
|
||||
$owners = [];
|
||||
|
||||
$sql = "SELECT Address.* FROM Preordercampaign
|
||||
LEFT JOIN Network ON (Preordercampaign.network_id = Network.id)
|
||||
LEFT JOIN Address ON (Network.owner_id = Address.id)
|
||||
GROUP BY Address.id
|
||||
ORDER BY Address.company, Address.lastname, Address.firstname
|
||||
";
|
||||
$res = $this->db()->query($sql);
|
||||
if($this->db()->num_rows($reso)) {
|
||||
while($data = $this->db()->fetch_object($res)) {
|
||||
$owners[] = new Address($data->id);
|
||||
}
|
||||
}
|
||||
|
||||
return $owners;
|
||||
}
|
||||
|
||||
protected function addAction() {
|
||||
if(!$this->me->is("Admin")) {
|
||||
$this->redirect("Preordercampaign");
|
||||
}
|
||||
|
||||
$this->layout()->setTemplate("Preordercampaign/Form");
|
||||
|
||||
if($this->me->isAdmin()) {
|
||||
@@ -98,6 +154,10 @@ class PreordercampaignController extends mfBaseController {
|
||||
}
|
||||
|
||||
protected function editAction() {
|
||||
if(!$this->me->is("Admin")) {
|
||||
$this->redirect("Preordercampaign");
|
||||
}
|
||||
|
||||
$id = $this->request->id;
|
||||
if(!is_numeric($id) || !$id) {
|
||||
$this->layout()->setFlash("Vorbestellkampagne nicht gefunden", "error");
|
||||
@@ -116,6 +176,10 @@ class PreordercampaignController extends mfBaseController {
|
||||
}
|
||||
|
||||
protected function saveAction() {
|
||||
if(!$this->me->is("Admin")) {
|
||||
$this->redirect("Preordercampaign");
|
||||
}
|
||||
|
||||
$r = $this->request;
|
||||
//var_dump($r);exit;
|
||||
$id = $r->id;
|
||||
@@ -173,6 +237,23 @@ class PreordercampaignController extends mfBaseController {
|
||||
$data['required_preorder_fields'] = null;
|
||||
}
|
||||
|
||||
if($r->district_is_city == 1) {
|
||||
$data['district_is_city'] = 1;
|
||||
} else {
|
||||
$data['district_is_city'] = 0;
|
||||
}
|
||||
|
||||
if($r->hausnummer_add_zusatz == 1) {
|
||||
$data['hausnummer_add_zusatz'] = 1;
|
||||
} else {
|
||||
$data['hausnummer_add_zusatz'] = 0;
|
||||
}
|
||||
|
||||
if($r->exist_is_error == 1) {
|
||||
$data['exist_is_error'] = 1;
|
||||
} else {
|
||||
$data['exist_is_error'] = 0;
|
||||
}
|
||||
|
||||
$data['edit_by'] = $this->me->id;
|
||||
|
||||
@@ -246,5 +327,84 @@ class PreordercampaignController extends mfBaseController {
|
||||
$this->redirect("Preordercampaign");
|
||||
|
||||
}
|
||||
|
||||
|
||||
protected function downloadAddonServices() {
|
||||
$id = $this->request->preordercampaign_id;
|
||||
if(!is_numeric($id) || !$id) {
|
||||
$this->layout()->setFlash("Vorbestellkampagne nicht gefunden", "error");
|
||||
$this->redirect("Preordercampaign");
|
||||
}
|
||||
|
||||
$campaign = new Preordercampaign($id);
|
||||
if(!$campaign->id) {
|
||||
$this->layout()->setFlash("Vorbestellkampagne nicht gefunden", "error");
|
||||
$this->redirect("Preordercampaign");
|
||||
}
|
||||
|
||||
$this->layout()->set("campaign", $campaign);
|
||||
$preorders = PreorderModel::search(["preordercampaign_id" => $id, "add-where" => "AND JSON_LENGTH(addon_services) > 1"]);
|
||||
|
||||
if(!count($preorders)) {
|
||||
$this->layout->setFlash("Keine Vorbestellungen mit bestellten Dienstleistungen gefunden.");
|
||||
$this->redirect("Preordercampaign");
|
||||
}
|
||||
|
||||
$csv = [];
|
||||
foreach($preorders as $preorder) {
|
||||
$sjson = json_decode($preorder->addon_services);
|
||||
if(!$sjson) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// address data and stuff
|
||||
$general = [
|
||||
"ucode" => $preorder->ucode,
|
||||
"gemeinde" => $preorder->adb_hausnummer->ortschaft->gemeinde->name,
|
||||
"plz" => $preorder->adb_hausnummer->plz->plzstring,
|
||||
"ortschaft" => $preorder->adb_hausnummer->ortschaft->name,
|
||||
"strasse" => $preorder->adb_hausnummer->strasse->name,
|
||||
"hausnummer" => $preorder->adb_hausnummer->hausnummer,
|
||||
"block" => "",
|
||||
"stiege" => "",
|
||||
"stock" => "",
|
||||
"tuer" => "",
|
||||
"zusatz" => "",
|
||||
"address_info" => $preorder->address_info,
|
||||
"contact_firma" => $preorder->company,
|
||||
"contact_uid" => $preorder->uid,
|
||||
"contact_firstname" => $preorder->firstname,
|
||||
"contact_lastname" => $preorder->lastname,
|
||||
"contact_street" => $preorder->street,
|
||||
"contact_plz" => $preorder->zip,
|
||||
"contact_ort" => $preorder->city,
|
||||
"phone" => $preorder->phone,
|
||||
"email" => $preorder->email,
|
||||
];
|
||||
|
||||
if($preorder->adb_wohneinheit_id) {
|
||||
$general["block"] = $preorder->adb_wohneinheit->block;
|
||||
$general["stiege"] = $preorder->adb_wohneinheit->stiege;
|
||||
$general["stock"] = $preorder->adb_wohneinheit->stock;
|
||||
$general["tuer"] = $preorder->adb_wohneinheit->tuer;
|
||||
$general["zusatz"] = $preorder->adb_wohneinheit->zusatz;
|
||||
}
|
||||
|
||||
foreach($sjson as $service) {
|
||||
if(!$service->ordered) continue;
|
||||
|
||||
$s = $general;
|
||||
$s["service"] = $service->service;
|
||||
$data = [];
|
||||
foreach($service->data as $d) {
|
||||
$data[] = (string)$d->name.": ".(is_bool($d->value) ? (int)$d->value : (string)$d->value);
|
||||
}
|
||||
$s["service_data"] = implode("; ", $data);
|
||||
$csv[] = $s;
|
||||
}
|
||||
//var_dump($csv);exit;
|
||||
$this->layout()->setTemplate("Preordercampaign/services.csv");
|
||||
$this->layout()->set("csv", $csv);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user