Merge branch 'master' into 'devbyspi'

# Conflicts:
#   Layout/default/Device/Detail.php
#   Layout/default/Device/Form.php
#   Layout/default/Device/Index.php
#   application/Device/DeviceController.php
#   application/Device/DeviceModel.php
#   public/assets/css/datatables-std.css
This commit is contained in:
Frank Schubert
2023-03-22 14:36:13 +00:00
99 changed files with 60682 additions and 831 deletions

View File

@@ -19,6 +19,7 @@
<link href="<?=self::getResourcePath()?>assets/css/bootstrap-select.min.css" rel="stylesheet" type="text/css" />
<link href="<?=self::getResourcePath()?>css/bootstrap-datepicker3.min.css" rel="stylesheet" type="text/css" />
<link href="<?=self::getResourcePath()?>plugins/summernote/summernote-bs4.css" rel="stylesheet" type="text/css" />
<link href="<?=self::getResourcePath()?>datatables/datatables.min.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="<?=self::getResourcePath()?>js/jquery.min.js"></script>
<script type="text/javascript" src="<?=self::getResourcePath()?>assets/libs/select2/select2.min.js"></script>
@@ -26,10 +27,12 @@
<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>
<script type="text/javascript" src="<?=self::getResourcePath()?>js/bootstrap-autocomplete.min.js"></script>
<script type="text/javascript" src="<?=self::getResourcePath()?>datatables/datatables.min.js"></script>
<?php if(MFAPPNAME == "devthetool"): ?>
<style type="text/css">

View File

@@ -31,20 +31,21 @@
<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("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" ><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 class="has-sub-submenu"><a href="<?=self::getUrl("Device")?>"><i class="fad fa-router text-info "></i> Devices</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; ?>

View File

@@ -0,0 +1 @@
<?php

View File

@@ -0,0 +1 @@
<?php

View File

@@ -27,163 +27,187 @@
</div>
</div>
<div class="card">
<div class="card-body">
<h3 class="text-center mb-3"><?=$address->getCompanyOrName()?><?=($address->customer_number) ? " [".$address->customer_number."]" : ""?></h3>
<div class="row">
<div class="col-8">
<table class="table table-sm table-striped view-table">
<tr>
<th>Kundennummer</th>
<td><?=$address->customer_number?></td>
</tr><tr>
<th>Firmenname</th>
<td><?=nl2br($address->company)?></td>
</tr><tr>
<th>Vorname</th>
<td><?=$address->firstname?></td>
</tr><tr>
<th>Nachname</th>
<td><?=$address->lastname?></td>
</tr><tr>
<th>Straße</th>
<td><?=$address->street?></td>
</tr><tr>
<th>PLZ / Ort</th>
<td><?=$address->zip?> <?=$address->city?></td>
</tr><tr>
<th>Land</th>
<td><?=$address->country?></td>
</tr><tr>
<th>Telefon</th>
<td><?=$address->phone?></td>
</tr><tr>
<th>Mobil</th>
<td><?=$address->mobile?></td>
</tr><tr>
<th>Fax</th>
<td><?=$address->fax?></td>
</tr><tr>
<th>Email</th>
<td><?=$address->email?></td>
</tr><tr>
<th></th>
<td></td>
</tr><tr>
<th>Service PIN</th>
<td><?=$address->spin?></td>
</tr><tr>
<th>Einwilligungen</th>
<td>
<p><i class="mr-1 fas <?=($address->allow_contact) ? "fa-check text-success" : "fa-xmark-large text-danger"?>"></i> Informationen per Post/Email/Telefon</p>
<p><i class="mr-1 fas <?=($address->allow_spin) ? "fa-check text-success" : "fa-xmark-large text-danger"?>"></i>Auskunft mit Service PIN</p>
</td>
</tr><tr>
<th>Rollen</th>
<td>
<?php if(is_array($address->types) && count($address->types)): ?>
<?php foreach(TT_ROLES as $role): ?>
<ul>
<?php if(array_key_exists($role, $address->types)): ?>
<li><?=__($role)?></li>
<div class="card border-top-primary">
<div class="card-body">
<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>
<th>Kundennummer</th>
<td><?=$address->customer_number?></td>
</tr><tr>
<th>Firmenname</th>
<td><?=nl2br($address->company)?></td>
</tr><tr>
<th>Vorname</th>
<td><?=$address->firstname?></td>
</tr><tr>
<th>Nachname</th>
<td><?=$address->lastname?></td>
</tr><tr>
<th>Straße</th>
<td><?=$address->street?></td>
</tr><tr>
<th>PLZ / Ort</th>
<td><?=$address->zip?> <?=$address->city?></td>
</tr><tr>
<th>Land</th>
<td><?=$address->country?></td>
</tr><tr>
<th>Telefon</th>
<td><?=$address->phone?></td>
</tr><tr>
<th>Mobil</th>
<td><?=$address->mobile?></td>
</tr><tr>
<th>Fax</th>
<td><?=$address->fax?></td>
</tr><tr>
<th>Email</th>
<td><?=$address->email?></td>
</tr><tr>
<th></th>
<td></td>
</tr><tr>
<th>Service PIN</th>
<td><?=$address->spin?></td>
</tr><tr>
<th>Einwilligungen</th>
<td>
<p><i class="mr-1 fas <?=($address->allow_contact) ? "fa-check text-success" : "fa-xmark-large text-danger"?>"></i> Informationen per Post/Email/Telefon</p>
<p><i class="mr-1 fas <?=($address->allow_spin) ? "fa-check text-success" : "fa-xmark-large text-danger"?>"></i>Auskunft mit Service PIN</p>
</td>
</tr><tr>
<th>Rollen</th>
<td>
<?php if(is_array($address->types) && count($address->types)): ?>
<?php foreach(TT_ROLES as $role): ?>
<ul>
<?php if(array_key_exists($role, $address->types)): ?>
<li><?=__($role)?></li>
<?php endif; ?>
</ul>
<?php endforeach; ?>
<?php endif; ?>
</ul>
<?php endforeach; ?>
<?php endif; ?>
</td>
</tr><tr>
<td colspan="2"><h4>Verrechnungsdaten</h4></td>
</tr><tr>
<th>UID</th>
<td><?=$address->uid?></td>
</tr><tr>
<th>Verrechnungsart</th>
<td><?=($address->billing_type == "sepa") ? "SEPA Bankeinzug" : "Rechnung"?></td>
</tr><tr>
<th>Rechnungsversand</th>
<td><?=($address->billing_delivery == "paper") ? "POST" : "Email"?></td>
</tr><tr>
<th>Kreditinstitut</th>
<td><?=$address->bank_account_bank?></td>
</tr><tr>
<th>Kontoinhaber</th>
<td><?=$address->bank_account_owner?></td>
</tr><tr>
<th>IBAN</th>
<td><?=$address->bank_account_iban?></td>
</tr><tr>
<th>BIC</th>
<td><?=$address->bank_account_bic?></td>
</tr><tr>
<td colspan="2"><h4>Zusatzdaten</h4></td>
</tr><tr>
<th>RTR Code</th>
<td><?=$address->attributes['rtrcode']->value?></td>
</tr>
</table>
<h4>Verknüpfungen</h4>
<?php if(is_array($address->links) && count($address->links)): ?>
<div class="card">
<div class="card-body" id="link-container">
<table class="table table-striped table-sm table-bordered">
<tr>
<th>Typ</th>
<th>Firma</th>
<th>Name</th>
<th>Telefon</th>
<th>Mobil</th>
<th>Email</th>
<th></th>
</tr>
<?php foreach(TT_ADDRESS_LINK_TYPES as $type): ?>
<?php if(array_key_exists($type, $address->links)): ?>
<?php foreach($address->links[$type] as $link): ?>
<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->getFullName()?></a></td>
<td><?=$link->address->phone?></td>
<td><?=$link->address->mobile?></td>
<td><?=$link->address->email?></td>
<td>
<a class="mr-2" href="<?=self::getUrl("Address", "view", ["id" => $link->address_id])?>"><i class="far fa-eyes" title="Anzeigen"></i></a>
</td>
</tr>
<?php endforeach; ?>
<?php endif; ?>
<?php endforeach; ?>
</td>
</tr><tr>
<td colspan="2"><h4>Verrechnungsdaten</h4></td>
</tr><tr>
<th>UID</th>
<td><?=$address->uid?></td>
</tr><tr>
<th>Verrechnungsart</th>
<td><?=($address->billing_type == "sepa") ? "SEPA Bankeinzug" : "Rechnung"?></td>
</tr><tr>
<th>Rechnungsversand</th>
<td><?=($address->billing_delivery == "paper") ? "POST" : "Email"?></td>
</tr><tr>
<th>Kreditinstitut</th>
<td><?=$address->bank_account_bank?></td>
</tr><tr>
<th>Kontoinhaber</th>
<td><?=$address->bank_account_owner?></td>
</tr><tr>
<th>IBAN</th>
<td><?=$address->bank_account_iban?></td>
</tr><tr>
<th>BIC</th>
<td><?=$address->bank_account_bic?></td>
</tr><tr>
<td colspan="2"><h4>Zusatzdaten</h4></td>
</tr><tr>
<th>RTR Code</th>
<td><?=$address->attributes['rtrcode']->value?></td>
</tr>
</table>
<h4>Verknüpfungen</h4>
<?php if(is_array($address->links) && count($address->links)): ?>
<div class="card border-top-warning">
<div class="card-body" id="link-container">
<table class="table table-striped table-sm table-bordered">
<tr>
<th>Typ</th>
<th>Firma</th>
<th>Name</th>
<th>Telefon</th>
<th>Mobil</th>
<th>Email</th>
<th></th>
</tr>
<?php foreach(TT_ADDRESS_LINK_TYPES as $type): ?>
<?php if(array_key_exists($type, $address->links)): ?>
<?php foreach($address->links[$type] as $link): ?>
<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->getFullName()?></a></td>
<td><?=$link->address->phone?></td>
<td><?=$link->address->mobile?></td>
<td><?=$link->address->email?></td>
<td>
<a class="mr-2" href="<?=self::getUrl("Address", "view", ["id" => $link->address_id])?>"><i class="far fa-eyes" title="Anzeigen"></i></a>
</td>
</tr>
<?php endforeach; ?>
<?php endif; ?>
<?php endforeach; ?>
</table>
</div>
</div>
<?php endif; ?>
<?php if(is_array($address->linked_as) && count($address->linked_as)): ?>
<h4>Verknüpft als</h4>
<div class="card">
<div class="card-body" id="link-container">
<table class="table-sm table-striped">
<?php foreach(TT_ADDRESS_LINK_TYPES as $type): ?>
<?php if(array_key_exists($type, $address->linked_as)): ?>
<?php foreach($address->linked_as[$type] as $link): ?>
<tr>
<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; ?>
<?php endif; ?>
<?php endforeach; ?>
</table>
</div>
</div>
<?php endif; ?>
</div>
</div>
<?php endif; ?>
<?php if(is_array($address->linked_as) && count($address->linked_as)): ?>
<h4>Verknüpft als</h4>
<div class="card">
<div class="card-body" id="link-container">
<table class="table-sm table-striped">
<?php foreach(TT_ADDRESS_LINK_TYPES as $type): ?>
<?php if(array_key_exists($type, $address->linked_as)): ?>
<?php foreach($address->linked_as[$type] as $link): ?>
<tr>
<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; ?>
<?php endif; ?>
<?php endforeach; ?>
</table>
</div>
</div>
<?php endif; ?>
</div>
<div class="col-4">
<div class="card border-top-success">
<div class="card-header">
Aktive Produkte (Contracts)
</div>
<?php if(is_array($address->contracts) && count($address->contracts)): ?>
<ul class="list-group list-group-flush">
<?php foreach($address->contracts as $contract): ?>
<li class="list-group-item"><a href="<?=self::getUrl("Contract", "View", ["id" => $contract->id])?>"><?=$contract->product_name?> [<?=$contract->matchcode?>]</a> <span class='text-secondary'><?=($contract->finish_date) ? "Fertigstellung: ".date('d.m.Y', $contract->finish_date) : "in Herstellung"?></span></li>
<?php endforeach; ?>
</ul>
<?php endif; ?>
</div>
</div>
</div>
<?php if(is_array($address->contracts) && count($address->contracts)): ?>
<div class="card">
<?php if(is_array($address->active_contracts) && count($address->active_contracts)): ?>
<div class="card border-top-success">
<div class="card-header">
Verträge
</div>
<div class="card-body">
<h4>Verträge</h4>
<table class="table table-striped table-sm table-bordered table-hover">
<tr>
@@ -194,9 +218,8 @@
<th>Bestelldatum</th>
<th>Fertigstellung</th>
<th>Kündigung</th>
<th></th>
</tr>
<?php foreach($address->contracts as $contract): ?>
<?php foreach($address->active_contracts as $contract): ?>
<tr>
<td class="contract <?=($contract->isCancelled()) ? "canceled" : ""?>">
<a href="<?=self::getUrl("Contract", "View", ["id" => $contract->id])?>">
@@ -213,9 +236,7 @@
<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>

View File

@@ -175,6 +175,50 @@
</div>
</div>
<div class="form-group row">
<label class="col-lg-2 col-form-label" for="gdaeigenschaft">GDA-Eigenschaft</label>
<div class="col-lg-10">
<?php if(is_array($save_data) && array_key_exists("gdaeigenschaft", $save_data)): ?>
<input type="text" class="form-control" name="gdaeigenschaft" id="gdaeigenschaft" value="<?=$save_data['gdaeigenschaft']?>">
<?php else: ?>
<input type="text" class="form-control" name="gdaeigenschaft" id="gdaeigenschaft" value="<?=$address->gdaeigenschaft?>">
<?php endif; ?>
</div>
</div>
<div class="form-group row">
<label class="col-lg-2 col-form-label" for="meridian">Meridian</label>
<div class="col-lg-10">
<?php if(is_array($save_data) && array_key_exists("meridian", $save_data)): ?>
<input type="text" class="form-control" name="meridian" id="meridian" value="<?=$save_data['meridian']?>">
<?php else: ?>
<input type="text" class="form-control" name="meridian" id="meridian" value="<?=$address->meridian?>">
<?php endif; ?>
</div>
</div>
<div class="form-group row">
<label class="col-lg-2 col-form-label" for="rw">RW</label>
<div class="col-lg-10">
<?php if(is_array($save_data) && array_key_exists("rw", $save_data)): ?>
<input type="text" class="form-control" name="rw" id="rw" value="<?=$save_data['rw']?>">
<?php else: ?>
<input type="text" class="form-control" name="rw" id="rw" value="<?=$address->rw?>">
<?php endif; ?>
</div>
</div>
<div class="form-group row">
<label class="col-lg-2 col-form-label" for="hw">HW</label>
<div class="col-lg-10">
<?php if(is_array($save_data) && array_key_exists("hw", $save_data)): ?>
<input type="text" class="form-control" name="hw" id="hw" value="<?=$save_data['hw']?>">
<?php else: ?>
<input type="text" class="form-control" name="hw" id="hw" value="<?=$address->hw?>">
<?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">

View File

@@ -158,6 +158,7 @@
<th>Straße</th>
<th>Hausnummer</th>
<th>Wohneinheiten</th>
<th>GDA-Eigenschaft</th>
<th>Rollout Jahr</th>
<th>Rollout Info</th>
<th></th>
@@ -174,6 +175,7 @@
<td><?=$address->strasse->name?></td>
<td><?=$address->hausnummer?></td>
<td><?=count($address->wohneinheiten)?></td>
<td><?=$address->gdaeigenschaft?></td>
<td><?=$address->rollout?></td>
<td><?=$address->rollout_info?></td>
<td style="text-align: left; letter-spacing: 4px; font-size: 1.1em;">

View File

@@ -3,7 +3,7 @@ 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
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;GDA-Eigenschaft;Meridian;RW;HW
<?php
$line = 0;
@@ -21,7 +21,8 @@ while($data = mysqli_fetch_object($res)):
}
$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?>;
<?=$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?>;"<?=$data->gdaeigenschaft?>";"<?=$data->meridian?>";<?=$data->rw?>;<?=$data->hw?>
<?php
$i++;
if($line % 1000 === 0) {

View File

@@ -20,7 +20,7 @@ ob_start();
<td>{{POPNAME}}</td>
</tr><tr>
<th>GPS:</th>
<td><a href="https://maps.google.com/maps?t=k&q=loc:{{GPS}}">{{GPS}}</a></td>
<td><a href="https://maps.google.com/maps?t=k&q=loc:{{GPS}}" target="_blank">{{GPS}}</a></td>
</tr><tr>
<th>Kontakt:</th>
<td>{{CONTACT}}</td>

View File

@@ -158,6 +158,13 @@
<hr />
<div class="form-group row">
<label class="col-lg-2 col-form-label" for="order_date">Bestelldatum</label>
<div class="col-lg-10">
<input type="text" class="form-control" name="order_date" id="order_date" value="<?=($contract->order_date) ? date("d.m.Y",$contract->order_date) : ""?>">
</div>
</div>
<div class="form-group row">
<label class="col-lg-2 col-form-label" for="finish_date">Fertigstellungsdatum</label>
<div class="col-lg-10">
@@ -193,7 +200,6 @@
<th>Kunde</th>
<th>Contract ID</th>
<th>Produkt</th>
<th>Matchcode</th>
<th></th>
</tr>
<?php foreach($contract->links as $link): ?>
@@ -201,8 +207,7 @@
<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", "View", ["id" => $link->contract_id])?>"><?=$link->contract->product->name?> [<?=$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>
@@ -354,9 +359,33 @@
});
$('#product_id').on("autocomplete.select", function(evt, item) {
if(item && item.value === 0) {
$('#product_id').autoComplete('set', null);
if(item) {
if(item.value === 0) {
$('#product_id').autoComplete('set', null);
return;
}
product_id = item.value;
$.get("<?=self::getUrl("Product","api")?>", {
do: "getProduct",
"product_id": product_id
},
function(success) {
if(success.status != "OK") return;
p = success.result.product;
$("#price").val(p.price);
$("#price_setup").val(p.price_setup);
$("#price_nne").val(p.price_nne);
$("#price_nbe").val(p.price_nbe);
$("#billing_delay").val(p.billing_delay);
$("#billing_period").val(p.billing_period);
},
"json"
);
}
});
// product autocomplete

View File

@@ -91,7 +91,7 @@
<?php include(realpath(dirname(__FILE__)."/../")."/tpl/pagination.php"); ?>
<?php include(realpath(dirname(__FILE__)."/../")."/tpl/pagination-summary.php"); ?>
<table class="table table-striped table-hover">
<table class="table table-striped table-hover table-sm">
<tr>
<th>Contract ID</th>
<th>Inhaber</th>
@@ -109,7 +109,7 @@
<?php foreach($contracts as $contract): ?>
<tr>
<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("Address", "View", ["id" => $contract->owner_id])?>" target="_blank"><i class="far fa-eyes" title="Kunde in neuem Tab anzeigen"></i></a> <?=$contract->owner->getCompanyOrName()?> (<?=$contract->owner->customer_number?>)</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>

View File

@@ -27,7 +27,7 @@
</div>
</div>
<div class="card">
<div class="card border-top-success">
<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>
@@ -215,18 +215,113 @@
</div>
</div>
<?php if((is_array($contract->linkFrom) && count($contract->linkFrom)) || (is_array($contract->linkTo) && count($contract->linkTo))): ?>
<div class="card">
<div class="card border-top-warning">
<div class="card-header">
<h5>Journaleinträge</h5>
</div>
<div class="card-body">
<div class="row justify-content-center">
<div class="col-8">
<table class="table table-striped table-sm journal">
<?php if(is_array($contract->journals) && count($contract->journals)): ?>
<?php foreach($contract->journals as $j): ?>
<tr>
<td style="white-space: nowrap" class="text-monospace"><?=date("d.m.Y H:i", $j->create)?> (<?=$j->creator?>)</td>
<?php if($j->type == "text" || $j->type == "phone"):?>
<td><i class="fas <?=($j->type == "text") ? "fa-align-left bg-success" : "fa-phone bg-success"?> text-white p-1"></i></td>
<?php if(strlen($j->text) > 120): ?>
<td style="width: 100%" class="pointer" onclick="toggleTruncatedJournalText(<?=$j->id?>)">
<span id="truncated-<?=$j->id?>"><i class="fas fa-caret-right"></i> <?=self::strtrim(str_replace(["\n", "\r", "\t"]," ", $j->text), 120)?></span>
<span id="fulltext-<?=$j->id?>" class="hidden"><?=nl2br(htmlentities($j->text))?></span>
</td>
<?php else: ?>
<td style="width: 100%">
<?=str_replace(["\n", "\r", "\t"]," ", $j->text)?>
</td>
<?php endif; ?>
</td>
<?php elseif($j->type == "file"): ?>
<td><i class="fas fa-download bg-primary text-white p-1"></i></td>
<td style="width: 100%">
<?php if($j->text): ?>
<?=self::strtrim(str_replace(["\n", "\r", "\t"]," ", $j->text), 128)?><br />
<?php endif; ?>
<a class="text-monospace" href="<?=self::getUrl("File", "download", ["id" => $j->contractfile->file_id])?>"><?=$j->contractfile->name?></a>
</td>
<?php elseif($j->type == "created_from"): ?>
<td><i class="fas fa-cogs text-secondary pl-1"></i></td>
<td style="width: 100%">
<?php if($j->value == "manual"): ?>
<em>Vertrag manuell angelegt</em>
<?php endif; ?>
</td>
<?php elseif($j->type == "link"): ?>
<?php $link = new Contract($j->value); ?>
<td><i class="fas fa-link text-secondary pl-1"></i></td>
<td style="width: 100%"><em>Verknüpfung mit <a href="<?=self::getUrl("Contract", "view", ['contract_id' => $link->id])?>"><?=$link->id?> - <?=$link->product_name?> [<?=$link->matchcode?>]</a> erstellt</em></td>
<?php endif; ?>
<td style="white-space: nowrap">
<a href="<?=self::getUrl("Contractjournal", "edit", ["journal_id" => $j->id])?>" title="Journaleintrag bearbeiten"><i class="fas fa-edit"></i></a>
</td>
</tr>
<?php endforeach; ?>
<?php endif; ?>
<tr>
<td colspan="4">
<div class="ml-3"><button type="button" class="btn btn-sm btn-info" onclick="$('#new-journal').toggle()"><i class="fas fa-plus"></i> Journaleintrag hinzufügen</button></div>
<div id="new-journal" class="card-body hidden border-top mt-2">
<form method="post" action="<?=self::getUrl("Contractjournal", "save")?>" enctype="multipart/form-data">
<input type="hidden" name="contract_id" value="<?=$contract->id?>">
<label for="new_journal_type" class="form-label">Typ</label>
<select name="type" id="new_journal_type" class="form-control mb-2">
<option value="phone">Telefongespräch</option>
<option value="text">Kommentar</option>
<option value="file">Dateiupload</option>
</select>
<label for="new_journal_text" class="form-label">Text</label>
<textarea name="text" id="new_journal_text" class="form-control mb-2" style="height:120px;"></textarea>
<div id="new-journal-file-container" class="hidden">
<label for="new_journal_file" class="form-label">Dateianhang</label>
<input type="file" name="journal_file" id="new_journal_file" class="form-control mb-2" />
</div>
<button class="btn btn-sm btn-primary" type="submit"><i class="fas fa-save mr-1"></i> Speichern</button>
</form>
</div>
</td>
</tr>
</table>
</div>
</div>
</div>
</div>
<div class="card border-top-success">
<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>
<?php if((is_array($contract->linkFrom) && count($contract->linkFrom)) || (is_array($contract->linkTo) && count($contract->linkTo))): ?>
<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>
@@ -254,8 +349,7 @@
<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" : ""?>"><a href="<?=self::getUrl("Contract", "View", ["contract_id" => $linkcontract->id])?>"><?=$linkcontract->product_name?> [<?=$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>
@@ -265,9 +359,10 @@
</tr>
<?php endforeach; ?>
</table>
<?php endif; ?>
</div>
</div>
<?php endif; ?>
<div class="card">
<div class="card-body">
@@ -279,4 +374,21 @@
</div>
</div>
<script>
$(document).ready(function () {
$('#new_journal_type').change(function() {
if($('#new_journal_type').val() == "file") {
$('#new-journal-file-container').show();
} else {
$('#new-journal-file-container').hide();
}
});
});
function toggleTruncatedJournalText(id) {
$("#truncated-" + id).toggle();
$("#fulltext-" + id).toggle();
}
</script>
<?php include(realpath(dirname(__FILE__)."/../../$mfLayoutPackage")."/footer.php"); ?>

View File

@@ -27,7 +27,7 @@
</div>
</div>
<div class="card">
<div class="card border-top-success">
<div class="card-body">
<h3 class="text-center mb-3"><?=$contract->product_name?> (<?=$contract->id?>)</h3>
@@ -53,34 +53,77 @@
</div>
<div class="card">
<div class="card border-top-info">
<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")?>">
<form id="contract-config-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 class="bg-light">
<th><h4><u><?=$group->name?></u></h4></td>
<td></td>
</tr>
<?php foreach($group->items as $item): ?>
<?php
$inputname = "itemvalues[".$item->id."]";
if($item->multiple) {
$inputname .= "[]";
}
$inputid = "itemvalues_".$item->id;
$array_count = 0;
?>
<?php if($item->multiple): ?>
<?php foreach($item->getValue() as $item_value): ?>
<tr id="tr-<?=$inputid?>_<?=$array_count?>">
<th style="max-width: 50vw;"><?=$item->displayname?><span class="array_counter"> (<?=$array_count + 1?>)</span>:</th>
<td style="width: 50vw;">
<input type="text"
class="form-control <?=(is_array($error_items) && in_array($item->id, $error_items)) ? "invalid" : ""?>"
name="<?=$inputname?>"
id="<?=$inputid?>_<?=$array_count?>"
value="<?=(isset($request)) ? htmlentities($request->itemvalues[$item->id][$array_count]) : htmlentities($item_value)?>"
<?=($item->multiple) ? "data-item-multiple='true'" : ""?> />
<small><?=$item->description?></small>
</td>
</tr>
<?php $array_count++; ?>
<?php endforeach; ?>
<tr id="tr-<?=$inputid?>_<?=$array_count?>">
<th style="max-width: 50vw;"><?=$item->displayname?><span class="array_counter"> (<?=$array_count + 1?>)</span>:</th>
<td style="width: 50vw;">
<input type="text"
class="form-control <?=(is_array($error_items) && in_array($item->id, $error_items)) ? "invalid" : ""?>"
name="<?=$inputname?>"
id="<?=$inputid?>_<?=$array_count?>"
value="<?=(isset($request)) ? htmlentities($request->itemvalues[$item->id][$array_count]) : ""?>"
<?=($item->multiple) ? "data-item-multiple='true'" : ""?> />
<small><?=$item->description?></small>
</td>
</tr>
<?php else: ?>
<tr id="tr-<?=$inputid?>_0">
<th style="max-width: 50vw;"><?=$item->displayname?>:</th>
<td style="width: 50vw;">
<?php if($item->type == "enum"): ?>
<select class="form-control" name="<?=$inputname?>" id="<?=$inputid?>" <?=($item->multiple) ? "data-item-multiple='true'" : ""?>>
<?php foreach($item->getTypedataArray() as $option): ?>
<option value="<?=htmlentities($option)?>" <?=($item->getValue() == $option) ? "selected='selected'" : ""?>><?=htmlentities($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="<?=$inputname?>"
id="<?=$inputid?>_0"
value="<?=(isset($request)) ? htmlentities($request->itemvalues[$item->id]) : htmlentities($item->getValue())?>"
<?=($item->multiple) ? "data-item-multiple='true'" : ""?> />
<?php endif; ?>
<small><?=$item->description?></small>
</td>
</tr>
<?php endif; ?>
<?php endforeach; ?>
<?php endforeach; ?>
</table>
@@ -105,4 +148,73 @@
</div>
</div>
<script>
$(document).ready(function() {
$("#contract-config-form input").each(function() {
var input = this;
if(!$(input).attr("name")) return;
//console.log(this);
console.log($(input).attr("name"));
if($(input).data("item-multiple")) {
$(input).change(function() {
addMultipleValueField($(this).prop("id"));
});
}
});
});
function addMultipleValueField(id) {
console.log(id);
var id_match = id.match(/^itemvalues_(\d+)_(\d+)$/);
var elem_id = id_match[1];
var last_elem_count = 0;
var stop = false;
// find last input
$("input[id^=itemvalues_" + elem_id + "_").each(function() {
console.log("input id: " + this.id)
console.log("value: " + $(this).val());
if(!$(this).val()) {
stop = true;
return false;
}
var this_count_match = this.id.match(/^itemvalues_\d+_(\d+)$/);
var this_count = this_count_match[1]
if(this_count.length) {
console.log("last_elem_count: " + last_elem_count);
console.log("this count: " + this_count)
last_elem_count = Math.max(this_count, last_elem_count);
}
});
if(stop) {
return;
}
if(!elem_id.length && !last_elem_count.length) {
return;
}
var new_tr = $("#tr-" + id).clone();
console.log(new_tr);
var new_count = parseInt(last_elem_count) + 1;
new_tr.prop("id", "tr-itemvalues_" + elem_id + "_" + new_count);
new_tr.find("td input[type=text]").prop("id", "itemvalues_" + elem_id + "_" + new_count);
new_tr.find("td input[type=text]").val("");
new_tr.find("td input[type=text]").change(function() {
addMultipleValueField($(this).prop("id"));
});
new_tr.find("span.array_counter").text(" (" + (parseInt(new_count) + 1) + ")");
$(new_tr).insertAfter($("#tr-" + id));
}
</script>
<?php include(realpath(dirname(__FILE__)."/../../$mfLayoutPackage")."/footer.php"); ?>

View File

@@ -34,7 +34,7 @@
<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>
<button type="submit" class="btn btn-purple"><i class="fas fa-plus"></i> Gruppe hinzufügen</button>
</div>
</div>
</form>
@@ -45,163 +45,196 @@
</div>
<?php if(is_array($configgroups) && count($configgroups)): ?>
<div class="row">
<?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 class="col-6 border pb-1">
<h4><?=$group->name?> <small><a href="#" onclick="$('#item-form-<?=$group->id?>').toggle(); return false;"><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>
<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 class="row">
<div class="col-md-1">
<div class="form-group">
<label for="item_new_<?=$item->id?>_order">Sort</label>
<input type="text" class="form-control" id="item_new_<?=$item->id?>_order" name="order" value="" />
</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 class="col-md-3">
<div class="form-group">
<label for="item_new_<?=$group->id?>_name">Name <small class="text-monospace">[a-z0-9._-]</small></label>
<input type="text" class="form-control" id="item_new_<?=$group->id?>_name" name="name" value="" />
</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 class="col-md-4">
<div class="form-group">
<label for="item_new_<?=$group->id?>_type">Datentyp</label>
<select class="form-control" id="item_new_<?=$group->id?>_type" name="type" onchange='toggleTypedata("new_<?=$group->id?>"); return false;'>
<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_<?=$group->id?>">
<div class="enum hidden">
<label for="item_new_<?=$group->id?>_data">Auswahldaten (1 Element pro Zeile)</label>
<textarea class="form-control" style="height: 128px" id="item_new_<?=$group->id?>_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_<?=$group->id?>_pattern" name="pattern" value="" />
</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="form-group row">
<div class="col-md-4">
<div class="form-group">
<label for="item_new_<?=$group->id?>_displayname">Anzeigename</label>
<input type="text" class="form-control" id="item_new_<?=$group->id?>_displayname" name="displayname" value="" />
</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 class="col-md-4">
<div class="form-group">
<label for="item_new_<?=$group->id?>_description">Beschreibung</label>
<input type="text" class="form-control" id="item_new_<?=$group->id?>_description" name="description" value="" />
</div>
</div>
<div class="col-md-4">
<div class="form-group text-center">
<label for="item_<?=$item->id?>_multiple">Mehrfach eintragbar</label>
<input type="checkbox" class="form-control" id="item_<?=$item->id?>_multiple" name="multiple" value="1" <?=($item->multiple) ? "checked='checked'" : ""?> />
</div>
</div>
</div>
<div class="form-group row">
<div class="col">
<input type="submit" class="btn btn-purple" value="Speichern" />
</div>
</div>
</form>
</div>
</div>
</form>
</div>
</div>
<?php $i++; endforeach; ?>
<?php endif; ?>
<?php $i++; endforeach; ?>
<?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 bg-soft-warning" onclick="$('#item-edit-<?=$item->id?>').toggle(); return false;"><i class="fas fa-caret-right pr-1"></i> <span class="text-monospace"><?=($item->order) ? str_pad($item->order, 2, "0", STR_PAD_LEFT) : ""?></span> <span class="text-monospace bg-purple text-white ml-1 p-1"><?=$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-1">
<div class="form-group">
<label for="item_<?=$item->id?>_order">Sort</label>
<input type="text" class="form-control" id="item_<?=$item->id?>_order" name="order" value="<?=$item->order?>" />
</div>
</div>
<div class="col-md-3">
<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="<?=htmlentities($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 class="col-md-4">
<div class="form-group text-center">
<label for="item_<?=$item->id?>_multiple">Mehrfach eintragbar</label>
<input type="checkbox" class="form-control" id="item_<?=$item->id?>_multiple" name="multiple" value="1" <?=($item->multiple) ? "checked='checked'" : ""?> />
</div>
</div>
</div>
<div class="form-group row">
<div class="col-md-10 float-left">
<input type="submit" class="btn btn-purple" value="Speichern" />
</div>
<div class="col-md-2 float-right text-right">
<small><a class="text-danger" href="<?=self::getUrl("ContractconfigItem", "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>
</form>
</div>
</div>
</div>
<?php $i++; endforeach; ?>
<?php endif; ?>
</div>
<?php $i++; endforeach; ?>
</div>
<?php else: ?>
<i>Keine Configgruppen gefunden</i>
<?php endif; ?>

View File

@@ -25,8 +25,7 @@
<li class="breadcrumb-item active">Device Detail</li>
</ol>
</div>
<h4 class="page-title">Device: <span class="font-weight-normal ml-1"><?= $devices->data->name ?></span>
<span class="ml-2">
<h4 class="page-title">Device: <span class="font-weight-normal ml-1"><?= $devices->data->name ?></span> <span class="ml-2">
<a href="<?= self::getUrl("Device", "edit", ["id" => $devices->id, 'returnto' => "device-detail"]) ?>">
<button class="btn btn-primary">Bearbeiten</button>
</a>

View File

@@ -1,25 +1,11 @@
<?php include(realpath(dirname(__FILE__) . "/../../$mfLayoutPackage") . "/header.php"); ?>
<?php
foreach ($devicetypes as $devicetype) {
$deviceTypes[$devicetype->id] = $devicetype->devicemanufactor->name . " " . $devicetype->name;
$deviceTypes[$devicetype->id]=$devicetype->devicemanufactor->name . " " . $devicetype->name;
}
asort($deviceTypes);
if ($device->price == "0.00") {
$price = "";
} else {
$price = $device->price;
}
if ($device->power == "0.0") {
$power = "";
} else {
$power = $device->power;
}
if (isset($_GET['returnto']) && $_GET['returnto'] == "device-detail") {
$cancelUrl = self::getUrl("Device", "Detail", ["id" => $device->id]);
} else {
$cancelUrl = self::getUrl("Device");
}
?>
<link href="<?= self::getResourcePath() ?>assets/css/select2-cstm.css" rel="stylesheet" type="text/css"/>
<!-- start page title -->

View File

@@ -4,7 +4,7 @@ $pagination_baseurl_params = ["filter" => $filter];
$pagination_entity_name = "Device";
?>
<?php include(realpath(dirname(__FILE__) . "/../../$mfLayoutPackage") . "/header.php"); ?>
<link href="<?= self::getResourcePath() ?>assets/css/datatables-std.css" rel="stylesheet" type="text/css"/>
<link href="<?=self::getResourcePath()?>assets/css/datatables-std.css" rel="stylesheet" type="text/css" />
<style>
</style>
@@ -129,13 +129,13 @@ $pagination_entity_name = "Device";
<script type="text/javascript">
var hidesearch = [9];
var hidesearch=[9];
$(document).ready(function () {
});
</script>
<script type="text/javascript" src="<?= self::getResourcePath() ?>assets/js/datatables-std.js"></script>
<script type="text/javascript" src="<?=self::getResourcePath()?>assets/js/datatables-std.js"></script>
<?php include(realpath(dirname(__FILE__) . "/../../$mfLayoutPackage") . "/footer.php"); ?>

View File

@@ -0,0 +1,74 @@
<?php
$term_id = $order->terminations[0]->id;
$op = OrderProductModel::getFirst(['order_id' => $order->id, 'termination_id' => $term_id]);
if($order->finish_date) {
$billing_start = $order->finish_date;
} else {
$billing_start = date('U');
}
if($op->billing_delay) {
$billing_start = strtotime("+".$op->billing_delay." months");
}
$subject = "";
if($order->upgrade) {
$subject .= "[UPGRADE] ";
}
/*$subject .= $order->terminations[0]->building->network->name." - "
."Verr. ab ".date("m", $billing_start)."/".date("Y", $billing_start)." - "
.$order->owner->customer_number." - "
.str_replace("\n", "", str_replace("\r\n", " ", $order->owner->getCompanyOrName()));
*/
$subject .= "[".str_replace(["\r","\n"], " ", $op->product->owner->getCompanyOrName())."] Produkt fertiggestellt - ";
if(is_array($order->terminations) && count($order->terminations)) {
$subject .= $order->terminations[0]->building->network->name;
}
$this->setReturnValue([
'subject' => $subject,
'from_email' => "workspace.admin@xinon.at",
'from_email_name' => "thetool"
]);
$nbe_total = 0;
?>
<?php if($order->upgrade): ?>
Achtung: UPGRADE
<?php endif; ?>
project: verrechnung
type: Verrechnung
status: Neu
priority: Standard
start date: <?=date("Y-m-01", $billing_start)?>
due date: <?=date("Y-m-01", $billing_start)?>
Kundennummer: <?=($op->product->owner->customer_number) ? $op->product->owner->customer_number : "null"?>
Kundenname: <?=str_replace("\n", "", str_replace("\r\n", " ", $op->product->owner->getCompanyOrName()))?>
Telefon: <?=($op->product->owner->phone) ? $op->product->owner->phone : "null"?>
Netzgebiet: <?=$order->terminations[0]->building->network->name?>
Bauabschnitt: <?=(($order->terminations[0]->building->networksection_id) ? $order->terminations[0]->building->networksection->name : "<kein Bauabschnitt>")?>
Verrechungsstart: <?=date("m", $billing_start)?>/<?=date("Y", $billing_start)?>
### Rechnungspositionen
| Anzahl | Produktname | Verrechungsperiode | Preis periodisch | Preis Herstellung | NBE |
|--------|-------------|--------------------|-------------------|-------------------|-----|
<?php foreach($order->products as $op): ?>
<?php if($op->price_nbe > 0.0) $nbe_total += ($op->price_nbe / $op->billing_period); ?>
| <?=$op->amount?> | <?=$op->product->name?> | <?=($op->billing_period == 12) ? "Jährlich " : (($op->billing_period == 1) ? "Monatlich" : $op->billing_period."-monatlich")?> | ~~EUR <?=$op->price?>~~ | ~~EUR <?=$op->price_setup?>~~ | EUR <?=$op->price_nbe?> |
<?php endforeach; ?>
**Monatliches NBE:** EUR <?=sprintf("%.04f",$nbe_total)?>

View File

@@ -2,16 +2,29 @@
$customer_string = str_replace(["\r","\n"], " ", $order->owner->getCompanyOrName())." [".$order->owner->customer_number."]";
$subject = "Neue Rufnummerportierung ($customer_string)";
$subject = "Rufnummernmitnahme $customer_string";
$this->setReturnValue([
'subject' => $subject,
'to' => "portierung@xinon.at",
'from_email' => TT_OUTGOING_EMAIL,
'from_email_name' => TT_OUTGOING_EMAIL_NAME
'to' => "workspace@xinon.at",
'from_email' => "workspace.admin@xinon.at",
'from_email_name' => "thetool"
]);
?>
project: portierung
type: Portierung
status: Neu
priority: Standard
Kundennummer: <?=$order->owner->customer_number?>
Kundenname: <?=str_replace("\n", "", str_replace("\r\n", " ", $order->owner->getCompanyOrName()))?>
Telefon: <?=($order->owner->phone) ? $order->owner->phone : "null"?>
<?=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 (-;

View File

@@ -12,20 +12,30 @@
$billing_start = strtotime("+".$op->billing_delay." months");
}
$subject = "";
if($order->upgrade) {
$subject .= "[UPGRADE] ";
}
$subject .= $order->terminations[0]->building->network->name." - "
/*$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()));
*/
if(is_array($order->terminations) && count($order->terminations)) {
$subject .= $order->terminations[0]->building->network->name." - ";
}
$subject .= $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
'from_email' => "workspace.admin@xinon.at",
'from_email_name' => "thetool"
]);
$nne_products = [];
@@ -34,44 +44,50 @@
Achtung: UPGRADE
<?php endif; ?>
project: verrechnung
type: Verrechnung
status: Neu
priority: Standard
start date: <?=date("Y-m-01", $billing_start)?>
due date: <?=date("Y-m-01", $billing_start)?>
Kundennummer: <?=$order->owner->customer_number?>
Kundenname: <?=str_replace("\n", "", str_replace("\r\n", " ", $order->owner->getCompanyOrName()))?>
Telefon: <?=($order->owner->phone) ? $order->owner->phone : "null"?>
Netzgebiet: <?=$order->terminations[0]->building->network->name?>
Bauabschnitt: <?=(($order->terminations[0]->building->networksection_id) ? $order->terminations[0]->building->networksection->name : "<kein Bauabschnitt>")?>
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
====================
### Rechnungspositionen
Anzahl | Produktname | Verrechungsperiode | Preis periodisch | Preis Herstellung
-----------------------------------------------------------------------------------------------------------------------
| 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?>
-----------------------------------------------------------------------------------------------------------------------
| <?=$op->amount?> | <?=$op->product->name?> | <?=($op->billing_period == 12) ? "Jährlich " : (($op->billing_period == 1) ? "Monatlich" : $op->billing_period."-monatlich")?> | EUR <?=$op->price?> | EUR <?=$op->price_setup?> |
<?php endforeach; ?>
<?php if(count($nne_products)): ?>
Gutschriften
=============
### 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 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?>
-----------------------------------------------------------------------------------------------------------------------
<?=$op->amount?> | <?=$op->product->name?> | <?=($op->billing_period == 12) ? "Jährlich " : (($op->billing_period == 1) ? "Monatlich" : $op->billing_period."-monatlich")?> | <?=($op->termination->building->networksection_id) ? $op->termination->building->networksection->name : "<Kein Bauabschnitt>"?> | EUR <?=$op->price_nne?> |
<?php endforeach; ?>
<?php endif; // (count($nne_products))?>

View File

@@ -746,7 +746,7 @@
</div>
<div class="col-1">
<label class="form-label" for="price_nbe-<?=$i?>">Preis NBE</label>
<input type="text" class="form-control" name="products[<?=$i?>][price_nbe]" id="price_nne-<?=$i?>" value="" placeholder="NBE" />
<input type="text" class="form-control" name="products[<?=$i?>][price_nbe]" id="price_nbe-<?=$i?>" value="" placeholder="NBE" />
</div>
<?php endif; ?>
@@ -1527,7 +1527,7 @@
</div> \
<div class="col-1"> \
<label class="form-label" for="price_nbe-' + i +'">Preis NBE</label> \
<input type="text" class="form-control" name="products[' + i +'][price_nbe]" id="price_nne-' + i +'" value="" placeholder="NBE" /> \
<input type="text" class="form-control" name="products[' + i +'][price_nbe]" id="price_nbe-' + i +'" value="" placeholder="NBE" /> \
</div> \
<?php endif; ?>
\

View File

@@ -31,7 +31,23 @@
<form method="get" action="<?=self::getUrl("Preorder")?>">
<div class="row">
<?php if($me->is("preorderfront")): ?>
<div class="col-2">
<label class="form-label" for="filter_kunde">Kunde (Name oder Adresse)</label>
<input type="text" class="form-control" name="filter[kunde]" id="filter_kunde" value="<?=$filter['kunde']?>" />
</div>
<div class="col-2">
<label class="form-label" for="filter_address">Anschlussadresse</label>
<input type="text" class="form-control" name="filter[address]" id="filter_address" value="<?=$filter['address']?>" />
</div>
<div class="col-2">
<label class="form-label" for="filter_hausnummer">Hausnummer</label>
<input type="text" class="form-control" name="filter[hausnummer]" id="filter_hausnummer" value="<?=$filter['hausnummer']?>" />
</div>
<?php else: ?>
<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">
@@ -91,7 +107,10 @@
</select>
</div>
<?php endif; ?>
</div>
<div class="row mt-2">
<div class="col">
<button type="submit" class="btn btn-primary">Filter anwenden</button>
@@ -100,12 +119,34 @@
<?php else: ?>
<a class="btn btn-secondary" href="<?=self::getUrl("Preorder")?>">Filter zurücksetzen</a>
<?php endif; ?>
<?php if(!$me->is("Preorderfront")): ?>
<button type="submit" formaction="<?=self::getUrl("Preorder", "export")?>" id="export-button" class="btn btn-outline-success ml-2"><i class="fas fa-download"></i> CSV-Export</button>
<?php endif; ?>
</div>
</div>
</form>
</div>
</div>
<?php if($me->is("Admin")): ?>
<div class="card">
<div class="card-body">
<div class="row col" id="map-link">
<a href="#" class="btn btn-success" onclick="refreshMap()"><i class="far fa-map"></i> Übersichtskarte einblenden</a>
</div>
<div class="row hidden" id="map-row">
<div id="preorder-map" style="height:70vh; width: 100%"></div>
<div class="row mt-1">
<div class="col">
<button type="button" class="btn btn-sm btn-outline-secondary" onclick="centerMap()"><i class="far fa-dot-circle fa-fw"></i> Zentrieren</button>
<button type="button" class="btn btn-sm btn-outline-success" onclick="toggleTileset()" title="Zwischen Karte und Satellitenbild umschalten"><i class="far fa-arrow-right-arrow-left fa-fw"></i> Karte/Satellit</button>
</div>
</div>
</div>
</div>
</div>
<?php endif; ?>
<div class="card">
@@ -129,7 +170,7 @@
<table class="table table-striped table-hover">
<tr>
<th>Kampagne</th>
<?php if(!$me->is("preorderfront")): ?><th>Kampagne</th><?php endif; ?>
<th>Bestelltyp</th>
<th>Status</th>
<th>Anschlussadresse</th>
@@ -137,20 +178,20 @@
<th>Kunde</th>
<th>Kontakt</th>
<th>Partner</th>
<th>Anschluss</th>
<th>Attribute</th>
<th>Erstellt</th>
<th>Zuletzt bearbeitet</th>
<th></th>
</tr>
<?php foreach($preorders as $preorder): ?>
<tr>
<td><?=$preorder->campaign->name?></td>
<?php if(!$me->is("preorderfront")): ?><td><?=$preorder->campaign->name?></td><?php endif; ?>
<td><?=__($preorder->type, "preorder")?></td>
<td>Aufgenommen</td>
<?php if($preorder->building_id): ?>
<td><?=$preorder->building->street?><br /><?=$preorder->building->zip?> <?=$preorder->building->city?></td>
<?php elseif($preorder->adb_hausnummer_id): ?>
<td <?=($preorder->address_created) ? "class='alert-warning' title='Manuell angelegt'" : ""?>">
<td <?=($preorder->address_created) ? "class='alert-warning' title='Adresse 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'>&lt;keine Wohneinheit&gt;</i><br />"?>
@@ -173,12 +214,17 @@
</td>
<td><?=($preorder->partner_id) ? $preorder->partner->getCompanyOrName() : ""?></td>
<td><?=($preorder->termination) ? $preorder->termination->code : ""?></td>
<td>
<label><input type="checkbox" name="attributes_bep_specified" id="attributes_bep_specified-<?=$preorder->id?>" data-preorder-id="<?=$preorder->id?>" value="1" <?=(is_array($preorder->attribute) && array_key_exists("bep_specified", $preorder->attribute) && $preorder->attribute["bep_specified"]) ? "checked='checked'" : ""?> /> Borderpoint festgelegt</label><br />
<label><input type="checkbox" name="attributes_inhouse_cabling_supplied" id="attributes_inhouse_cabling_supplied-<?=$preorder->id?>" data-preorder-id="<?=$preorder->id?>" value="1" <?=(is_array($preorder->attribute) && array_key_exists("inhouse_cabling_supplied", $preorder->attribute) && $preorder->attribute["inhouse_cabling_supplied"]) ? "checked='checked'" : ""?> /> Starterpaket erhalten</label>
</td>
<td><?=date('d.m.Y H:i', $preorder->create)?></td>
<td><?=date('d.m.Y H:i', $preorder->edit)?></td>
<td id="update-<?=$preorder->id?>"><?=date('d.m.Y H:i', $preorder->edit)?></td>
<td style="text-align: left; letter-spacing: 4px; font-size: 1.1em;">
<?php if(!$me->is("preorderfront")): ?>
<a href="<?=self::getUrl("Preorder", "edit", ["id" => $preorder->id])?>"><i class="far fa-edit" title="Vorbestellkampagne Bearbeiten"></i></a>
<a href="<?=self::getUrl("Preorder", "delete", ["id" => $preorder->id, "filter" => $filter])?>" class="text-danger" onclick="if(!confirm('Vorbestellung wirklich löschen?')) return false;" title="Vorbestellung Löschen"><i class="fas fa-trash"></i></a>
<?php endif; ?>
</td>
</tr>
<?php endforeach; ?>
@@ -195,7 +241,246 @@
<script type="text/javascript">
$("#filter_type").select2({closeOnSelect: false});
$("#filter_status").select2({closeOnSelect: false});
$(document).ready(function() {
$("#filter_type").select2({closeOnSelect: false});
$("#filter_status").select2({closeOnSelect: false});
var attributes = ["bep_specified", "inhouse_cabling_supplied"];
attributes.forEach(function(attrib) {
$("input[name=attributes_" + attrib + "]").change(function(ev) {
// save new value
var cb = $("#" + ev.currentTarget.id);
var value = $(cb).is(":checked") ? 1 : 0;
var preorder_id = $(cb).data("preorder-id");
$.post("<?=self::getUrl("Preorder", "Api")?>", {
do: "saveAttribute",
id: preorder_id,
attribute: attrib,
value: value
},
function(success) {
if(success.status == "OK") {
attributeSuccess(success.result);
} else {
attributeError(success.result.id, success.result.attribute);
}
},
"json"
);
});
});
});
function attributeSuccess(result) {
var id = result.id
var attribute = result.attribute
var update = result.update
$("#attributes_" + attribute + "-" + id).parent().removeClass("text-danger");
$("#attributes_" + attribute + "-" + id).parent().addClass("text-success");
if(update) {
$("#update-" + id).text(update);
$("#update-" + id).addClass("text-success")
}
setTimeout(function() {
$("#attributes_" + attribute + "-" + id).parent().removeClass("text-success");
$("#update-" + id).removeClass("text-success")
}, 2000, id, attribute);
}
function attributeError(id, attribute) {
$("#attributes_" + attribute + "-" + id).parent().addClass("text-danger");
$("#attributes_" + attribute + "-" + id).prop("checked", !$("#attributes_" + attribute + "-" + id).is(":checked"));
}
/*
* Globals for map display
*/
var preorderMap;
var preorders = [];
var markers = [];
var markerState = true;
var mapCenterPos = [<?=TT_PLACEHOLDER_GPS_LAT?>, <?=TT_PLACEHOLDER_GPS_LONG?>];
var tileLayers = [];
var tilesets = ["mapbox/streets-v12", "mapbox/satellite-streets-v12"];
var currentTileset = "mapbox/streets-v12";
function toggleTileset() {
if(currentTileset == "mapbox/streets-v12") {
currentTileset = "mapbox/satellite-streets-v12";
} else {
currentTileset = "mapbox/streets-v12";
}
console.log("renderMap");
renderMap(true);
}
function refreshMap() {
// get Preorders and render map
$('#map-link').hide();
$('#map-row').show();
getMapdata();
$([document.documentElement, document.body]).animate({
scrollTop: $("#preorder-map").offset().top - 150
}, 500);
}
function renderMap(tilesetChangeOnly = false) {
if(preorderMap) {
if(!tilesetChangeOnly) {
markers.forEach(function(m) {
preorderMap.removeLayer(m);
});
}
} else {
preorderMap = L.map('preorder-map').setView([<?=TT_PLACEHOLDER_GPS_LAT?>, <?=TT_PLACEHOLDER_GPS_LONG?>], 12);
}
if(!(currentTileset in tileLayers)) {
tileLayers[currentTileset] = L.tileLayer('https://api.mapbox.com/styles/v1/{id}/tiles/{z}/{x}/{y}?access_token={accessToken}', {
attribution: 'Map data &copy; <a href="https://www.openstreetmap.org/">OpenStreetMap</a> contributors, <a href="https://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>, Imagery © <a href="https://www.mapbox.com/">Mapbox</a>',
minZoom: 6,
maxZoom: 22,
id: currentTileset,
accessToken: '<?=TT_MAPBOX_TILE_API_TOKEN?>'
});
}
tileLayers[currentTileset].addTo(preorderMap);
// remove all tilesets not currently wanted
tilesets.forEach(function(t) {
if(t != currentTileset && preorderMap.hasLayer(tileLayers[t])) {
preorderMap.removeLayer(tileLayers[t]);
}
});
L.MakiMarkers.accessToken = '<?=TT_MAPBOX_TILE_API_TOKEN?>';
if(!tilesetChangeOnly) {
addMarkers();
}
}
function addMarkers() {
if(!Array.isArray(preorders) | !preorders.length) {
return false;
}
// draw markers and calculate center position
var all_coords = [];
preorders.forEach(function(preorder) {
if(!preorder.gps_lat || !preorder.gps_long) {
return;
}
var gps = [preorder.gps_lat, preorder.gps_long];
all_coords.push(gps);
var icon_color = "#acf0ab";
var icon_name = "home";
if(preorder.type == "interest") {
icon_color = "#ec98a2";
} else if(preorder.type == "provision") {
icon_color = "#ffcd8b";
}
if(preorder.connection_type.match(/^multi/i) || preorder.count > 1) {
icon_name = "town";
} else if(preorder.connection_type.match(/^apartment-building/i)) {
icon_name = "city";
} else if(preorder.connection_type.match(/^business/i)) {
icon_name = "industry";
}
var marker_popup_content = '<?php include(realpath(dirname(__FILE__))."/include/preorder_popup.php");?>';
// popup fields
[
["street", preorder.adb_strasse],
["hausnummer", preorder.adb_hausnummer],
["zip", preorder.adb_plz],
["city", preorder.adb_ort],
["type", preorder.type_label],
["typestyle", "color: #000; background-color: " + icon_color],
["adrcd", preorder.adrcd],
["extref", preorder.extref ? preorder.extref : ""],
["gps", (preorder.gps_lat && preorder.gps_long) ? preorder.gps_lat + ", " + preorder.gps_long : ""],
["contact", (preorder.company ? preorder.company + " " : preorder.firstname + " " + preorder.lastname)],
["phone", preorder.phone ? preorder.phone : ""],
["email", preorder.email ? preorder.email : ""],
["connectiontype", preorder.connection_type_label],
["count", preorder.connection_count]
].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(preorderMap).bindPopup(marker_popup_content);
markers[preorder.id] = marker;
});
// calculate center position
mapCenterPos = GetCenterFromDegrees(all_coords);
preorderMap.setView(mapCenterPos, 12);
return true;
}
function centerMap() {
preorderMap.setView(mapCenterPos, 12);
}
// gets preorders and calls renderMap()
function getMapdata() {
filter = getFilter();
$.post('<?=self::getUrl("Preorder", "Api")?>', {
'do': "getFilteredPreorders",
filter: filter
},function(success) {
if(success.status == "OK") {
if(Array.isArray(success.result.preorders)) {
preorders = success.result.preorders;
renderMap();
}
}
},
'json'
);
}
function getFilter() {
var fields = ['preordercampaign_id', 'status', 'type', 'address', 'kunde', 'address_source'];
var filter = {};
fields.forEach(function(field) {
if(!field) {
return;
}
let val = $('#filter_' + field).val();
if(val.length) {
filter[field] = val;
}
});
return filter;
}
<?php if(is_array($filter) && count($filter)): ?>
//refreshMap();
<?php endif; ?>
</script>
<?php include(realpath(dirname(__FILE__)."/../../$mfLayoutPackage")."/footer.php"); ?>

View File

@@ -0,0 +1,48 @@
<?php
ob_end_flush();
header("Content-type: text/csv");
header('Content-disposition: attachment; filename="preorder-export-'.date('Y-m-d_H-i-s').'.csv"');
?>
Kampagne;Bestelltyp;Status;Anschlusstyp;Anschluss Strasse;Anschluss Hausnummer;Anschluss PLZ;Anschluss Ort;Anschluss Wohneinheit;Anzahl Anschlüsse;Kunde Firma;Kunde UID;Kunde Vorname;Kunde Nachname;Kunde Strasse;Kunde PLZ;Kunde Ort;Kunde Telefon;Kunde Email;Partner;BEP festgelegt;Starterpaket erhalten;
<?php
$line = 0;
while($data = mysqli_fetch_object($res)):
$campaign = Layout::getMfValuecacheObject("Preordercampaign", $data->preordercampaign_id);
$status = Layout::getMfValuecacheObject("Preorderstatus", $data->status_id);
$hausnummer = Layout::getMfValuecacheObject("ADBHausnummer", $data->adb_hausnummer_id);
$wohneinheit = Layout::getMfValuecacheObject("ADBWohneinheit", $data->adb_wohneinheit_id);
$strasse = Layout::getMfValuecacheObject("ADBStrasse", $hausnummer->strasse_id);
$gemeinde = Layout::getMfValuecacheObject("ADBGemeinde",$strasse->gemeinde_id);
$ortschaft = Layout::getMfValuecacheObject("ADBOrtschaft", $hausnummer->ortschaft_id);
$plz = Layout::getMfValuecacheObject("ADBPlz", $hausnummer->plz_id);
$partner = Layout::getMfValuecacheObject("Address", $hausnummer->partner_id);
$unit_data = "";
if($wohneinheit->block) $unit_data .= "Block ".$wohneinheit->block;
if($wohneinheit->stiege) $unit_data .= "Stiege ".$wohneinheit->stiege;
if($wohneinheit->stock) $unit_data .= "Stock ".$wohneinheit->stock;
if($wohneinheit->tuer) $unit_data .= "Tür ".$wohneinheit->tuer;
if($wohneinheit->unit_string) {
$unit_data = $wohneinheit->unit_string;
}
$bep = false;
$inhouse = false;
if($data->attributes) {
$attribs = json_decode($data->attributes, true);
if($attribs['bep_specified']) $bep = true;
if($attribs['inhouse_cabling_supplied']) $inhouse = true;
}
?>
"<?=$campaign->name?>";"<?=__($data->type,"preorder")?>";"<?=$status->name?>";"<?=__($data->connection_type,"preorder")?>";"<?=$strasse->name?>";"<?=$hausnummer->hausnummer?>";"<?=$plz->plz?>";"<?=$ortschaft->name?>";"<?=$unit_data?>";<?=$data->connection_count?>;"<?=$data->company?>";"<?=$data->uid?>";"<?=$data->firstname?>";"<?=$data->lastname?>";"<?=$data->street?>";"<?=$data->zip?>";"<?=$data->city?>";"<?=$data->phone?>";"<?=$data->email?>";"<?=$partner->getCompanyOrName()?>";<?=($bep) ? "1" : "0"?>;<?=($inhouse) ? "1" : "0"?>;
<?php
$i++;
if($line % 1000 === 0) {
flush();
}
endwhile;

View File

@@ -0,0 +1,42 @@
<?php
ob_start();
?>
<div class="font-weight-bold">
{{STREET}} {{HAUSNUMMER}}<br />
{{ZIP}} {{CITY}}
</div>
<hr />
<table class="table table-sm table-striped">
<tr>
<th class="font-weight-bold">Bestelltyp:</th>
<td style="{{TYPESTYLE}}">{{TYPE}}</td>
</tr><tr>
<th class="font-weight-bold">Gebäudetyp:</th>
<td>{{CONNECTIONTYPE}}</td>
</tr><tr>
<th class="font-weight-bold">Anschlüsse:</th>
<td>{{COUNT}}</td>
</tr><tr>
<th class="font-weight-bold">GPS:</th>
<td><a href="https://maps.google.com/maps?t=k&q=loc:{{GPS}}" target="_blank">{{GPS}}</a></td>
</tr><tr>
<th class="font-weight-bold">GWR Adrcd:</th>
<td>{{ADRCD}}</td>
</tr><tr>
<th class="font-weight-bold">Extref:</th>
<td>{{EXTREF}}</td>
</tr><tr>
<th class="font-weight-bold">Kontakt:</th>
<td>{{CONTACT}}</td>
</tr><tr>
<th class="font-weight-bold">Telefon:</th>
<td>{{PHONE}}</td>
</tr><tr>
<th class="font-weight-bold">Email:</th>
<td>{{EMAIL}}</td>
</tr>
</table>
<?=str_replace("\n"," ",ob_get_clean())?>

View File

@@ -95,7 +95,7 @@
<th></th>
</tr>
<?php foreach($campaigns as $camp): ?>
<tr style="<?=(date('U') >= $camp->from && date('U') <= $camp->to) ? "background-color: #f0fff0" : ""?>">
<tr <?=(date('U') >= $camp->from && date('U') <= $camp->to) ? "class='active'" : ""?>>
<td class="text-right">
<?php if(date('U') >= $camp->from && date('U') <= $camp->to): ?>
<span class="fa-stack" title="Vorbestellkampagne aktiv">

View File

@@ -37,6 +37,16 @@
</div>
</div>
<div class="form-group row">
<label class="col-lg-2 col-form-label" for="active">Aktiv *</label>
<div class="col-lg-10">
<select class="select2 form-control " name="active" id="active">
<option value="1" <?=($product->active == 1) ? "selected='selected'" : ""?>>Aktiv</option>
<option value="0" <?=($product->active != 1) ? "selected='selected'" : ""?>>Deaktiviert</option>
</select>
</div>
</div>
<div class="form-group row">
<label class="col-lg-2 col-form-label" for="description">Beschreibung</label>
<div class="col-lg-10">
@@ -237,7 +247,8 @@
<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>
<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>

View File

@@ -62,20 +62,16 @@
</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">
<label class="form-label" for="filter_external_id">Produktbesitzer</label>
<select class="select2 form-control" name="filter[external_id]" id="filter_external_id">
<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>
<?php foreach(AddressModel::search(['addresstype' => ['productowner']]) as $owner): ?>
<option value="<?=$owner->id?>" <?=(is_array($filter) && array_key_exists('external_id', $filter) && $filter['external_id'] == $owner->id) ? "selected='selected'" : ""?>><?=$owner->getCompanyOrName()?></option>
<?php endforeach; ?>
</select>
</div>
<div class="col-2">
<div class="col-1">
<label class="form-label" for="filter_external">Externe Produkte</label>
<select name="filter[external]" id="filter_external" class="form-control">
<option></option>
@@ -84,11 +80,35 @@
</select>
</div>
<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']?>" />
</div>
<div class="col-1">
<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-1">
<label class="form-label" for="filter_active">Status</label>
<select name="filter[active]" id="filter_active" class="form-control">
<option value="1" <?=(is_array($filter) && array_key_exists('active', $filter) && $filter['active']) ? "selected='selected'" : ""?>>Aktiviert</option>
<option value="0" <?=(is_array($filter) && array_key_exists('active', $filter) && !$filter['active']) ? "selected='selected'" : ""?>>Deaktiviert</option>
<option value="all" <?=(is_array($filter) && array_key_exists('active', $filter) && $filter['active'] == "all") ? "selected='selected'" : ""?>>Alle 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("Product")?>">Filter zurücksetzen</a>
<a class="btn btn-secondary" href="<?=self::getUrl("Product", "", ["resetFilter" => 1])?>">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>
@@ -155,6 +175,13 @@
<script type="text/javascript">
$("#filter_productgroup_id").select2({closeOnSelect: false});
$("#filter_producttech_id").select2({closeOnSelect: false});
$("#filter_external_id").change(function() {
console.log($("#filter_external_id").val());
if($("#filter_external_id").val()) {
$("#filter_external").val(1);
}
});
</script>
<?php include(realpath(dirname(__FILE__)."/../../$mfLayoutPackage")."/footer.php"); ?>

View File

@@ -64,6 +64,34 @@
<option value="true" <?=(isset($user) && $user->is("Technician")) ? "selected='selected'" : ""?>>Yes</option>
</select>
</div>
<div class="form-group">
<label for="preorderfront">Preorder Frontdesk:</label>
<select name="preorderfront" class="form-control">
<option value="false" <?=(isset($user) && !$user->is("preorderfront")) ? "selected='selected'" : ""?>>No</option>
<option value="true" <?=(isset($user) && $user->is("preorderfront")) ? "selected='selected'" : ""?>>Yes</option>
</select>
</div>
<div class="form-group" id="preorder-network-container">
<label for="preorder_networks">Preorder Netzgebiete:</label>
<?php
$pns = [];
if($user->id) {
$pns = json_decode((new WorkerFlag($user->id,"preorder_networks"))->value());
if(!$pns) {
$pns = [];
}
}
?>
<select name="preorder_networks[]" id="preorder_networks" class="form-control" multiple="multiple">
<?php foreach(NetworkModel::getAll() as $network): ?>
<option value="<?=$network->id?>" <?=(in_array($network->id, $pns)) ? "selected='selected'" : ""?>><?=$network->name?></option>
<?php endforeach; ?>
</select>
<small>Überschreibt Netzgebiete der Firma. Wenn leer werden Netzgebiete der Firma angezeigt</small>
</div>
<div class="form-group">
<label for="password">Password:</label>
<input type="password" id="password" name="password" class="form-control" value="" />
@@ -113,9 +141,30 @@
<?php endif; ?>
<script type="text/javascript">
$("#address_id").select2({
allowClear: true,
placeholder: ""
$(document).ready(function() {
$("#address_id").select2({
allowClear: true,
placeholder: ""
});
$("#preorder_networks").select2({
allowClear: true,
placeholder: "",
closeOnSelect: false
});
<?php if(!$user || !$user->is("preorderfront")): ?>
$("#preorder-network-container").hide();
<?php endif; ?>
$("select[name=preorderfront]").change(function() {
if($("select[name=preorderfront]").val() == "true") {
$("#preorder-network-container").show();
} else {
$("#preorder-network-container").hide();
}
});
});
</script>

View File

@@ -7,11 +7,11 @@
<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("Voicenumberblock")?>">Rufnummernblöcke</a></li>
<li class="breadcrumb-item"><a href="<?=self::getUrl("Voicenumberblock")?>#block_id=<?=$number->block->id?>"><?=$number->block->number_first?> - <?=$number->block->number_last?></a></li>
<li class="breadcrumb-item active"><?=$number->getFullNumber()?> bearbeiten</li>
<li class="breadcrumb-item"><a href="<?=self::getUrl("Voicenumberblock")?>#block_id=<?=$number->block->id?>"><?=$number->block->first?> - <?=$number->block->last?></a></li>
<li class="breadcrumb-item active"><?=$number->number?> bearbeiten</li>
</ol>
</div>
<h4 class="page-title">Rufnummer <?=$number->getFullNumber()?></h4>
<h4 class="page-title">Rufnummer <?=$number->number?></h4>
</div>
</div>
</div>
@@ -116,10 +116,10 @@
<select name="disabled_reason" class="form-control">
<option></option>
<option value="ported_out" <?=($number->disabled_reason == "ported_out") ? "selected='selected'" : ""?>>Zu neuem Provider portiert</option>
<option value="ported_back">Zum Anker zurückportiert</option>
<option value="reserved">Reserviert</option>
<option value="legacy">Legacy</option>
<option value="damaged">Kaputt</option>
<option value="ported_back" <?=($number->disabled_reason == "ported_back") ? "selected='selected'" : ""?>>Zum Anker zurückportiert</option>
<option value="reserved" <?=($number->disabled_reason == "reserved") ? "selected='selected'" : ""?>>Reserviert</option>
<option value="legacy" <?=($number->disabled_reason == "legacy") ? "selected='selected'" : ""?>>Legacy</option>
<option value="damaged" <?=($number->disabled_reason == "damaged") ? "selected='selected'" : ""?>>Kaputt</option>
</select>
</div>
</div>

View File

@@ -110,9 +110,9 @@
<td onclick="toggleBlock(<?=$block->id?>)"><?=$block->name?></td>
<td onclick="toggleBlock(<?=$block->id?>)"><?=$block->countrycode?></td>
<td onclick="toggleBlock(<?=$block->id?>)"><?=$block->areacode?></td>
<td onclick="toggleBlock(<?=$block->id?>)"><?=$block->base?></td>
<td onclick="toggleBlock(<?=$block->id?>)"><?=$block->getFirst()?></td>
<td onclick="toggleBlock(<?=$block->id?>)"><?=$block->getLast()?></td>
<td onclick="toggleBlock(<?=$block->id?>)"><?=$block->short_prefix?></td>
<td onclick="toggleBlock(<?=$block->id?>)"><?=$block->first?></td>
<td onclick="toggleBlock(<?=$block->id?>)"><?=$block->last?></td>
<td onclick="toggleBlock(<?=$block->id?>)"><?=$block->comment?></td>
<td style="text-align: left; letter-spacing: 4px; font-size: 1.1em;">
<a href="<?=self::getUrl("Voicenumberblock", "edit", ["id" => $block->id])?>"><i class="far fa-edit" title="Bearbeiten"></i></a>

View File

@@ -3,21 +3,22 @@
?>
<div class="card">
<div class="card-body">
<h4 class="header-title">Rufnummern <?=$block->countrycode?><?=$block->areacode?><?=$block->getFirst()?> - <?=$block->countrycode?><?=$block->areacode?><?=$block->getLast()?></h4>
<h4 class="header-title">Rufnummern <?=$block->countrycode?> <?=$block->areacode?> <?=$block->short_first?> - <?=$block->countrycode?> <?=$block->areacode?> <?=$block->short_last?></h4>
<table class="table table-striped table-sm">
<tr>
<th>Nummer</th>
<th>Aktiv</th>
<th>Contract ID</th>
<th>Routing</th>
<th>Portierungsstatus</th>
<th>Sperre</th>
<th>Entsperrung</th>
<th></th>
</tr>
<?php $i = 0; foreach(range($block->getFirst(), $block->getLast()) as $number): ?>
<?php $num = null; $num = VoicenumberModel::getFirst(['voicenumberblock_id' => $block_id, 'number' => ($block->number_prepend_zero) ? "0$number" : $number]) ?>
<?php $i = 0; foreach(range($block->first, $block->last) as $number): ?>
<?php $num = VoicenumberModel::getFirst(['voicenumberblock_id' => $block_id, 'number' => $number]) ?>
<tr>
<td><?=$block->countrycode?> <?=$block->areacode?> <?=($block->number_prepend_zero) ? "0" : ""?><?=$number?></td>
<td><?=$number?></td>
<td>
<?php if($num->active): ?>
<span class="text-success"><i class="fas fa-check"></i></span>
@@ -26,6 +27,7 @@
<span class="text-danger"><i class="fas fa-times"></i></span>
<?php endif; ?>
</td>
<td><a href="<?=self::getUrl("Contract", "view", ["id" => $num->contract_id])?>"><?=$num->contract_id?></a></td>
<td><?=__($num->routing)?></td>
<td>
<?php if($num->ported_out): ?>

View File

@@ -33,7 +33,6 @@
<script type="text/javascript" src="<?=self::getResourcePath()?>assets/js/bootstrap-select.min.js"></script>
<script type="text/javascript" src="<?=self::getResourcePath()?>js/bootstrap-autocomplete.min.js"></script>
<script type="text/javascript" src="<?=self::getResourcePath()?>datatables/datatables.min.js"></script>
<?php if(MFAPPNAME == "devthetool"): ?>
<style type="text/css">

View File

@@ -4,122 +4,135 @@
<!-- 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 if($me->is("preorderfront")): ?>
<li class="has-submenu">
<a href="#">
<i class="fal fa-money-bill-wave"></i>Verkauf <div class="arrow-down"></div>
</a>
<ul class="submenu">
<li><a href="<?=self::getUrl("Preorder")?>"><i class="far fa-calendar-lines text-info"></i> Vorbestellung</a></li>
</ul>
</li>
<?php else: ?>
<?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>
<?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">
<?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("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 ><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 class="has-sub-submenu"><a href="<?=self::getUrl("Device")?>"><i class="fad fa-router text-info "></i> Devices</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($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; ?>
<?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 class="has-sub-submenu"><a href="<?=self::getUrl("Patching")?>"><i class="fas fa-plug text-info"></i> Patchungen</a></li><?php endif; ?>
<?php if($me->is(["Admin", "netowner","pipeplanner","lineplanner","pipeworker", "netoperator", "lineworker"])): ?><li><a href="<?=self::getUrl("Filestore")?>"><i class="fas fa-file text-info"></i> Dateiablage</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","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","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; ?>
</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("Contractconfiggroup")?>"><i class="fas fa-wrench"></i> Vertragsconfig</a></li>
</ul>
</li>
<?php endif; ?>
-->
<?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>
<?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">
<?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("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 ><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 class="has-sub-submenu"><a href="<?=self::getUrl("Device")?>"><i class="fad fa-router text-info "></i> Devices</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($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; ?>
<?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 class="has-sub-submenu"><a href="<?=self::getUrl("Patching")?>"><i class="fas fa-plug text-info"></i> Patchungen</a></li><?php endif; ?>
<?php if($me->is(["Admin", "netowner","pipeplanner","lineplanner","pipeworker", "netoperator", "lineworker"])): ?><li><a href="<?=self::getUrl("Filestore")?>"><i class="fas fa-file text-info"></i> Dateiablage</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","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","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; ?>
</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("Contractconfiggroup")?>"><i class="fas fa-wrench"></i> Vertragsconfig</a></li>
</ul>
</li>
<?php endif; ?>
-->
</ul>
<!-- End navigation menu -->

View File

@@ -1,6 +1,7 @@
<?php
class ADBHausnummer extends mfBaseModel {
protected $forcestr = ["oaid","adrcd","subcd","extref","hausnummer","zusatz","grund_nr","gdaeigenschaft","meridian","rollout_info","rimo_fcp_name"];
private $netzgebiet;
private $ortschaft;
private $strasse;
@@ -85,28 +86,22 @@ class ADBHausnummer extends mfBaseModel {
}
if($name == "netzgebiet") {
$this->netzgebiet = new ADBNetzgebiet($this->netzgebiet_id);
$this->netzgebiet = mfValuecache::singleton()->getMfObject("ADBNetzgebiet", $this->netzgebiet_id);
return $this->netzgebiet;
}
if($name == "ortschaft") {
$this->ortschaft = new ADBOrtschaft($this->ortschaft_id);
$this->ortschaft = mfValuecache::singleton()->getMfObject("ADBOrtschaft", $this->ortschaft_id);
return $this->ortschaft;
}
if($name == "strasse") {
$this->strasse = new ADBStrasse($this->strasse_id);
$this->strasse = mfValuecache::singleton()->getMfObject("ADBStrasse", $this->strasse_id);
return $this->strasse;
}
if($name == "plz") {
$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);
}
}
$this->plz = mfValuecache::singleton()->getMfObject("ADBPlz", $this->plz_id);
return $this->plz;
}

View File

@@ -11,6 +11,10 @@ class ADBHausnummerModel {
public $hausnummer;
public $zusatz;
public $grund_nr;
public $gdaeigenschaft;
public $rw;
public $hw;
public $meridian;
public $unit_count;
public $gps_lat;
public $gps_long;

View File

@@ -0,0 +1,5 @@
<?php
class ADBWohneinheitController extends mfBaseController {
}

View File

@@ -10,6 +10,7 @@ class Address extends mfBaseModel {
private $attributes;
private $permissions;
private $contracts;
private $active_contracts;
private $phoneparts;
@@ -190,6 +191,13 @@ class Address extends mfBaseModel {
return $this->contracts;
}
if($name == "active_contracts") {
$owning = ContractModel::searchActive(['owner_id' => $this->id]);
$billing = ContractModel::searchActive(['billingaddress_id' => $this->id]);
$this->contracts = array_merge($owning, $billing);
return $this->contracts;
}
/*
if($name == "links_to") {
$links = AddressLinkModel::search(['address_id' => $this->id]);

View File

@@ -3,6 +3,9 @@
class AddressDB {
private $db;
private $log;
public $validation_error = [];
public static $wohneinheit_query = "select `Netzgebiet`.`id` AS `netzgebiet_id`,
`Netzgebiet`.`name` AS `netzgebiet`,
`Netzgebiet`.`extref` AS `netzgebiet_extref`,
@@ -204,6 +207,20 @@ class AddressDB {
$hausnummer_data['strasse_id'] = $strasse->id;
$hausnummer_data['hausnummer'] = $data['hausnummer'];
$hausnummer_data['grund_nr'] = $data['grund_nr'];
$hausnummer_data['gdaeigenschaft'] = $data['gdaeigenschaft'];
$hausnummer_data['meridian'] = $data['meridian'];
$hausnummer_data['rw'] = ($data['rw']) ? str_replace(",",".", $data['rw']) : null;
$hausnummer_data['hw'] = ($data['hw']) ? str_replace(",",".", $data['hw']) : null;
if($data['rw'] && !is_numeric($hausnummer_data['rw'])) {
$hausnummer_data['rw'] = null;
$this->validation_error[] = "RW nicht gespeichert: Keine Zahl";
}
if($data['hw'] && !is_numeric($hausnummer_data['hw'])) {
$hausnummer_data['hw'] = null;
$this->validation_error[] = "HW nicht gespeichert: Keine Zahl";
}
$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;

View File

@@ -231,7 +231,7 @@ class AddressDBController extends mfBaseController {
}
$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) {
foreach(['adrcd','extref','netzgebiet_id','strasse','hausnummer','plz','ortschaft','gemeinde','grund_nr','gdaeigenschaft','meridian','rw','hw','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");
@@ -278,7 +278,7 @@ class AddressDBController extends mfBaseController {
if(trim($r->rollout_info)) {
$rollout_info = trim($r->rollout_info);
}
if(!$rollout_info) {
if(!$rollout && !$rollout_info) {
$rollout_info = "unscheduled";
}
@@ -289,6 +289,9 @@ class AddressDBController extends mfBaseController {
$adb = new AddressDB();
$hausnummer_id = $adb->createUpdateHausnummer($address_data);
if(is_array($adb->validation_error) && count($adb->validation_error)) {
$this->layout()->setFlash(implode("<br />\n",$adb->validation_error), "warning");
}
if(!$hausnummer_id) {
$this->layout()->setFlash("Fehler beim Erstellen der Adresse!", "error");
return $this->addAction();

View File

@@ -19,6 +19,7 @@ class PreorderApicontroller extends mfBaseApicontroller {
protected function init() {
$db = $this->db(ADDRESSDB_DBHOST, ADDRESSDB_DBUSER, ADDRESSDB_DBPASS, ADDRESSDB_DBNAME);
$this->addRoute("/preorder/open", "getOpenPreorders", "GET");
$this->addRoute("/preorder", "submitPreorder", "POST");
$this->addRoute("/preorder/:code", "getPreorder", "GET");
$this->addRoute("/preorder/:code", "cancelPreorder", "DELETE");
@@ -79,20 +80,67 @@ class PreorderApicontroller extends mfBaseApicontroller {
//var_dump($campaign, $this->allowed_origins);exit;
}
protected function getOpenPreorders() {
$ts = $this->get['ts'];
$update_ts = 0;
if($ts) {
if(is_numeric($ts)) {
$update_ts = $ts;
} else {
$update_date = new DateTime($ts);
if($update_date) {
$update_ts = $update_date->format('U');
}
}
}
// nicht auf cluster einschränken, sondern auf partner_id
/*
$preorder_search = [];
if(count($this->filter_salescluster_ids)) {
$preorder_search['netzgebiet_id'] = $this->filter_salescluster_ids;
}*/
$preorder_search = [];
$preorder_search['partner_id'] = $this->me->address_id;
if($update_ts) {
$preorder_search['add-where'] = "AND tt_preorder.`edit` > $update_ts";
} else {
// if no timestamp, return only open orders (500 == finished)
$preorder_search['<status_code'] = 500;
}
$return = [];
foreach(PreorderModel::search($preorder_search) as $preorder) {
$return[] = $preorder->getApiArray();
}
return mfResponse::Ok(["preorders" => $return]);
}
protected function getPreorder($code) {
$code = trim(strtoupper($code));
$code = trim($code);
if(!$code) {
return mfResponse::NotFound(["message" => "Preorder not found"]);
}
$preorder = PreorderModel::getFirst(['ucode' => $code]);
$preorder = PreorderModel::getFirst(['ucode' => strtoupper($code), 'partner_id' => $this->me->address_id]);
if(!$preorder) {
// try oan id
$preorder = PreorderModel::getFirst(['oaid' => $code]);
if(!$preorder) {
return mfResponse::NotFound(["message" => "Preorder not found"]);
}
$preorder = PreorderModel::getFirst(['oaid' => strtolower($code), 'partner_id' => $this->me->address_id]);
}
if(!$preorder) {
// try as extref
$preorder = PreorderModel::getFirst(['extref' => $code, 'partner_id' => $this->me->address_id]);
}
if(!$preorder) {
return mfResponse::NotFound(["message" => "Preorder not found"]);
}
if($preorder->partner_id != $this->me->address_id) {
return mfResponse::NotFound(["message" => "Preorder not found"]);
@@ -103,12 +151,12 @@ class PreorderApicontroller extends mfBaseApicontroller {
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"]);
@@ -121,6 +169,24 @@ class PreorderApicontroller extends mfBaseApicontroller {
if(!$preorder) {
return mfResponse::NotFound(["message" => "Preorder not found or cancelled already"]);
}
}*/
$code = trim($code);
if(!$code) {
return mfResponse::NotFound(["message" => "Preorder not found"]);
}
$preorder = PreorderModel::getFirst(['ucode' => strtoupper($code), 'partner_id' => $this->me->address_id, 'deleted' => 0, '<status_code' => 800]);
if(!$preorder) {
// try oan id
$preorder = PreorderModel::getFirst(['oaid' => strtolower($code), 'partner_id' => $this->me->address_id, 'deleted' => 0, '<status_code' => 800]);
}
if(!$preorder) {
// try as extref
$preorder = PreorderModel::getFirst(['extref' => $code, 'partner_id' => $this->me->address_id, 'deleted' => 0, '<status_code' => 800]);
}
if(!$preorder) {
return mfResponse::NotFound(["message" => "Preorder not found"]);
}
// check if user owns preorder
@@ -412,8 +478,9 @@ class PreorderApicontroller extends mfBaseApicontroller {
} 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;
$preorder_data['extref'] = (trim($this->post['extref'])) ? trim($this->post['extref']) : null;
$preorder_data['technology'] = (trim($this->post['technology'])) ? trim($this->post['technology']) : null;
$preorder_data['patchposition'] = (trim($this->post['patchposition'])) ? trim($this->post['patchposition']) : null;
/*
* setup price
@@ -458,7 +525,7 @@ class PreorderApicontroller extends mfBaseApicontroller {
*/
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) ? $customer->$key : null;
$preorder_data[$key] = (trim($customer->$key)) ? trim($customer->$key) : null;
}
}
@@ -611,12 +678,20 @@ class PreorderApicontroller extends mfBaseApicontroller {
$return = ["code" => $preorder->ucode];
if($preorder->oaid) {
$return ['oaid'] = $preorder->oaid;
$return['oaid'] = $preorder->oaid;
}
if($preorder->extref) {
$return['extref'] = $preorder->extref;
}
if($addon_data) {
$return["additionalData"] = $addon_data;
}
$return['created'] = date("c", $preorder->create);
$return['created_ts'] = (int)$preorder->create;
$return['updated'] = date("c", $preorder->edit);
$return['updated_ts'] = (int)$preorder->edit;
return mfResponse::Ok($return);
}

View File

@@ -1,6 +1,8 @@
<?php
class Contract extends mfBaseModel {
protected $forcestr = ["product_name","product_info","matchcode"];
private $owner;
private $billingaddress;
private $product;
@@ -10,7 +12,9 @@ class Contract extends mfBaseModel {
private $contractConfigGroups;
private $contractConfigItems;
private $configgroups;
private $configvalues;
private $isCancelled;
private $journals;
private $links;
private $linkFrom;
private $linkTo;
@@ -160,11 +164,11 @@ class Contract extends mfBaseModel {
return $this->orderproduct;
}
if($name == "contractConfigGroups") {
/*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");
@@ -173,10 +177,21 @@ class Contract extends mfBaseModel {
$ccpg->contractconfiggroup->setContractId($this->id);
$this->configgroups[] = $ccpg->contractconfiggroup;
}
return $this->configgroups;
}
if($name == "contractConfigItems") {
if($name == "configvalues") {
foreach($this->getProperty("configgroups") as $group) {
foreach($group->items as $item) {
$this->configvalues[$item->name] = $item;
}
}
return $this->configvalues;
}
/*if($name == "contractConfigItems") {
$product = $this->getProperty("product");
$this->contractConfigItems = [];
@@ -186,6 +201,11 @@ class Contract extends mfBaseModel {
}
return $this->contractConfigItems;
}*/
if($name == "journals") {
$this->journals = array_reverse(ContractjournalModel::search(["contract_id" => $this->id]));
return $this->journals;
}
if($name == "links") {

View File

@@ -379,6 +379,7 @@ class ContractController extends mfBaseController {
}
$this->layout()->set("contract", $contract);
//var_dump($contract->owner);exit;
if($this->request->f == "view") $this->layout()->set("f", "view");
if($this->request->f != "view") $this->layout()->set("f", "index");
@@ -428,6 +429,7 @@ class ContractController extends mfBaseController {
$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['order_date'] = ($r->order_date) ? $this->dateToTimestamp($r->order_date) : null;
$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;
@@ -474,6 +476,16 @@ class ContractController extends mfBaseController {
return $this->addAction();
}
// create journal
if($mode == "add") {
$journal = ContractjournalModel::create([
'contract_id' => $contract_id,
'type' => "created_from",
'value' => "manual"
]);
$journal->save();
}
$this->layout()->setFlash("Vertrag erfolgreich gespeichert.", "success");
/*
@@ -487,7 +499,22 @@ class ContractController extends mfBaseController {
'origin_contract_id' => $origin->id,
'type' => 'link'
]);
$link->save();
$link_id = $link->save();
if($link_id) {
$journal = ContractjournalModel::create([
'contract_id' => $contract_id,
'type' => "link",
'value' => $origin->id
]);
$journal->save();
$ojournal = ContractjournalModel::create([
'contract_id' => $origin->id,
'type' => "link",
'value' => $contract_id
]);
$ojournal->save();
}
}
}

View File

@@ -116,6 +116,42 @@ class ContractModel {
return 0;
}
public static function searchActive($filter, $limit = false) {
//var_dump($filter);exit;
$items = [];
$db = FronkDB::singleton();
$where = self::getSqlFilter($filter);
$sql = "SELECT Contract.* FROM Contract
LEFT JOIN Address ON (Contract.owner_id = Address.id)
LEFT JOIN OrderProduct ON (Contract.orderproduct_id = OrderProduct.id)
LEFT JOIN `Order` ON (OrderProduct.order_id = `Order`.id)
LEFT JOIN Product ON (Contract.product_id = Product.id)
WHERE $where
AND (cancel_date IS NULL OR cancel_date > UNIX_TIMESTAMP())
GROUP BY Contract.id
ORDER BY Contract.owner_id,Contract.`create`";
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 Contract($data);
}
}
return $items;
}
public static function search($filter, $limit = false) {
//var_dump($filter);exit;
$items = [];

View File

@@ -0,0 +1,5 @@
<?php
class ContractFile extends mfBaseModel {
}

View File

@@ -0,0 +1,149 @@
<?php
class ContractFileModel {
public $contract_id;
public $file_id;
public $name;
public $description;
public $create_by = null;
public $edit_by = null;
public $create = null;
public $edit = null;
public static function create(Array $data) {
$model = new ContractFile();
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 getOne($id) {
if(!is_numeric($id) || !$id) {
throw new Exception("Invalid number", 400);
}
$item = [];
$db = FronkDB::singleton();
$res = $db->select("ContractFile", "*", "id=$id LIMIT 1");
if($db->num_rows($res)) {
$data = $db->fetch_object($res);
$item = new ContractFile($data);
}
return $item;
}
public static function getAll() {
$items = [];
$db = FronkDB::singleton();
$res = $db->select("ContractFile", "*", "1=1 ORDER BY contract_id, `create`");
if($db->num_rows($res)) {
while($data = $db->fetch_object($res)) {
$items[] = new ContractFile($data);
}
}
return $items;
}
public static function getFirst() {
$db = FronkDB::singleton();
$where = self::getSqlFilter($filter);
$res = $db->select("ContractFile", "*", "$where ORDER BY contract_id, `create`");
if($db->num_rows($res)) {
$data = $db->fetch_object($res);
$item = new ContractFile($data);
if($item->id) {
return $item;
} else {
return null;
}
}
return null;
}
public static function search($filter) {
$items = [];
$db = FronkDB::singleton();
$where = self::getSqlFilter($filter);
$sql = "SELECT ContractFile.* FROM ContractFile
LEFT JOIN File ON (ContractFile.file_id = File.id)
WHERE $where
ORDER BY contract_id, `create`";
$res = $db->query($sql);
if($db->num_rows($res)) {
while($data = $db->fetch_object($res)) {
$items[] = new ContractFile($data);
}
}
return $items;
}
private static function getSqlFilter($filter) {
$where = "1=1 ";
if(array_key_exists("file_id", $filter)) {
$file_id = $filter['file_id'];
if(is_numeric($file_id)) {
$where .= " AND file_id=$file_id";
}
}
if(array_key_exists("contract_id", $filter)) {
$contract_id = $filter['contract_id'];
if(is_numeric($contract_id)) {
$where .= " AND contract_id=$contract_id";
}
}
//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("filename", $filter)) {
$filename = FronkDB::singleton()->escape($filter['filename']);
if($filename) {
$where .= " AND File.filename='$filename'";
}
}
if(array_key_exists("subfolder", $filter)) {
$subfolder = FronkDB::singleton()->escape($filter['subfolder']);
if($subfolder) {
$where .= " AND File.subfolder='$subfolder'";
}
}
//var_dump($filter, $where);exit;
return $where;
}
}

View File

@@ -1,6 +1,7 @@
<?php
class ContractconfigController extends mfBaseController {
public $hook_errors;
protected function init() {
$this->needlogin=true;
@@ -55,6 +56,12 @@ class ContractconfigController extends mfBaseController {
$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($r->itemvalues) || !count($r->itemvalues)) {
$this->layout()->setFlash("Keine Änderungen.","info");
$this->redirect("Contract");
@@ -62,13 +69,24 @@ class ContractconfigController extends mfBaseController {
$error_items = [];
$old_values = [];
foreach($r->itemvalues as $item_id => $itemvalue) {
//var_dump($item_id, $itemvalue); continue;
$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(!array_key_exists($item->name, $old_values)) {
$old_values[$item->name] = [];
}*/
$old_values[$item->name] = $item->getValue();
if(!$item->value->set($itemvalue)) {
$error_items[$item->id] = $item->name;
continue;
@@ -79,6 +97,7 @@ class ContractconfigController extends mfBaseController {
return $this->editAction();
}
}
//exit;
if(count($error_items)) {
$this->layout()->set("error_items", array_keys($error_items));
@@ -87,10 +106,75 @@ class ContractconfigController extends mfBaseController {
return $this->editAction();
}
// run custom productgroup hooks
if(!$this->runAfterSaveHooks($contract)) {
$errors = [];
foreach($this->hook_errors as $item_name => $item_errors) {
if(is_array($item_errors) && count($item_errors)) {
foreach($item_errors as $error_string) {
$errors[] = "[$item_name] $error_string";
}
//var_dump($old_values[$item_name]);
// on error restore old values
if(array_key_exists($item_name, $old_values)) {
$old_item = ContractconfigItemModel::getFirst(["name" => $item_name]);
$old_item->setContractId($contract_id);
$old_item->value->set($old_values[$item_name]);
$old_item->value->save();
//var_dump($old_item->value->json);exit;
}
}
}
//var_dump($errors);exit;
$this->layout()->setFlash(implode("<br />", $errors), "error");
$this->redirect("Contract", "view", ['id' => $contract_id]);
}
$this->layout()->setFlash("Konfiguration gespeichert", "success");
$this->redirect("Contract", "view", ['id' => $contract_id]);
}
private function runAfterSaveHooks(Contract $contract) {
if(!$contract || !$contract->id) {
return false;
}
$folderpath = APPDIR."/Contractconfig/hooks/";
$dir = opendir($folderpath);
while($filename = readdir($dir)) {
if(substr($filename, 0, 1) == ".") {
continue;
}
if($filename == "Contractconfig_Hook.php") continue;
if(substr($filename, -4) != ".php") continue;
$hook_type = basename($filename, ".php");
$classname = "Contractconfig_Hook_$hook_type";
$hook_class_filename = $folderpath.$filename;
require_once $hook_class_filename;
if(!class_exists($classname)) {
continue;
}
$hook = new $classname($contract);
if($hook->isResponsible()) {
$this->log->debug("Running {$classname}->afterSave() for Contract id ".$contract->id);
$hook->afterSave();
if($hook->errors) {
$this->hook_errors = $hook->errors;
return false;
}
}
}
return true;
}
}

View File

@@ -0,0 +1,99 @@
<?php
abstract class Contractconfig_Hook {
protected $log;
protected $required_product_attributes = [];
protected $contract;
protected $items;
protected $product;
protected $product_attributes = [];
protected $config_prefix;
protected $configitems = [];
public $errors = [];
abstract public function beforeSave();
abstract public function afterSave();
abstract public function beforeDelete();
abstract public function afterDelete();
public function __construct(Contract $contract) {
$this->log = mfLoghandler::singleton();
$this->contract = $contract;
if($contract->product) {
$this->product = $contract->product;
if(is_array($this->product->attributes) && count($this->product->attributes)) {
$this->product_attributes = $this->product->attributes;
}
}
$this->loadConfigItems();
if(method_exists($this, "init")) {
$this->init();
}
}
private function loadConfigItems() {
$m = [];
if(preg_match('/^Contractconfig_Hook_(.+)$/', get_class($this), $m)) {
if($m[1]) {
$this->config_prefix = strtolower($m[1]);
}
} else {
return false;
}
foreach($this->contract->configgroups as $configgroup) {
foreach($configgroup->items as $item) {
if(strpos($item->name, $this->config_prefix) === 0) {
$short_name = substr($item->name, strlen($this->config_prefix)+1);
//var_dump($short_name);
$this->configitems[$short_name] = $item;
}
}
}
return true;
}
public function isResponsible() {
if(!$this->contract) return false;
if(!$this->product) return false;
if(!$this->product_attributes) return false;
// only work on contracts with our producttech attributes
if(!$this->testMyProductAttributes()) {
return false;
}
return true;
}
private function testMyProductAttributes() {
if(!$this->product_attributes) return false;
//var_dump($this->product_attributes);exit;
//var_dump($this->required_product_attributes);exit;
foreach($this->required_product_attributes as $needed_attribute) {
// every needed attribute must exist in product
if(!array_key_exists($needed_attribute, $this->product_attributes)) {
return false;
}
}
return true;
}
}

View File

@@ -0,0 +1,168 @@
<?php
require_once __DIR__."/Contractconfig_Hook.php";
class Contractconfig_Hook_Voicenumberblock extends Contractconfig_Hook {
protected $required_product_attributes = ["needs_number"];
private $voip_routing;
private $create_numbers = [];
/*
* Checks to determine if class needs to work on contract.
*/
public function isResponsible() {
/*
* Test for standard checks
* (Only Producttech attributes for now)
*/
if(!parent::isResponsible()) {
return false;
}
// do additional checks
//$contract = $this->contract;
return true;
}
public function init() {
$this->errors["voicenumberblock_voicenumber"] = [];
// get voip routing for number
if(is_array($this->contract->configvalues)) {
// look in contract config
if(array_key_exists("voip_routing",$this->contract->configvalues) && $this->contract->configvalues['voip_routing']->value->string) {
$this->voip_routing = $this->contract->configvalues['voip_routing']->value->string;
} else {
// else take first value (default)
$typedata = $this->voip_routing = $this->contract->configvalues['voip_routing']->getTypedataArray();
$this->voip_routing = $typedata[0];
}
}
}
public function beforeSave() {
return $this->checkNewNumbers();
}
public function afterSave() {
$this->checkNewNumbers();
if(count($this->errors["voicenumberblock_voicenumber"])) {
return false;
}
foreach($this->create_numbers as $voicenumberblock_id => $numbers) {
foreach($numbers as $number){
$voicenumber = VoicenumberModel::getFirst(['number' => $number]);
if(!$voicenumber) {
$this->log->debug("creating voicenumber $number in block ".$voicenumberblock->prefix);
$voicenumber = VoicenumberModel::create([
'voicenumberblock_id' => $voicenumberblock_id,
"contract_id" => $this->contract->id,
'active' => 1,
'activated_date' => date('U'),
'routing' => $this->voip_routing,
'number' => $number,
'disabled' => 0
]);
if(!$voicenumber->save()) {
$this->errors["voicenumberblock_voicenumber"][] = "Error saving new number $number";
}
}
}
}
if(count($this->errors["voicenumberblock_voicenumber"])) {
return false;
}
return true;
}
/*
* TODO: Check if contract was canceled, then set lock and lock_reason to reserved
*/
public function checkNewNumbers() {
$this->log->debug(":: In Contractconfig_Hook_Voicenumberblock->afterSave()");
// check if number was saved
if(!array_key_exists("voicenumber", $this->configitems)) {
$this->log->debug("configitem voicenumber does not exists");
return true;
}
$item = $this->configitems['voicenumber'];
//var_dump($item);exit;
if($item->value->json) {
$numbers = json_decode($item->value->json);
}
if(!is_array($numbers) || !count($numbers)) {
return true;
}
foreach($numbers as $number) {
if(!$number) {
$this->log->debug("Keine nummer gespeichert");
continue;
}
$this->log->debug("Nummer: $number");
// check if Voicenumber exists
$voicenumberblock = Voicenumberblock::findBlock($number);
if(!$voicenumberblock) {
$this->errors["voicenumberblock_voicenumber"][] = "Ungültige Rufnummer $number: Kein aktiver Rufnummernblock gefunden";
continue;
}
if(!$voicenumberblock->isNumberInBlock($number)) {
$this->errors["voicenumberblock_voicenumber"][] = "Ungültige Rufnummer $number: Bitte Rufnummernlänge kontrollieren! Block erlaubt ".$voicenumberblock->first ." bis ".$voicenumberblock->last;
continue;
}
$voicenumber = VoicenumberModel::getFirst(['number' => $number]);
if($voicenumber) {
// check if number belongs to another contract
if($voicenumber->contract_id) {
if($voicenumber->contract_id == $this->contract->id) {
// belongs to our contract already => no changes needed
continue;
}
$this->errors["voicenumberblock_voicenumber"][] = "Ungültige Rufnummer $number: Rufnummer gehört zu bestehendem contract ".$voicenumber->contract_id;
continue;
}
// check if number is locked
if($voicenumber->disabled) {
$this->errors["voicenumberblock_voicenumber"][] = "Ungültige Rufnummer $number: Rufnummer ist gesperrt ".$voicenumber->contract_id;
continue;
}
// check if number was ported out
if($voicenumber->ported_out) {
$this->errors["voicenumberblock_voicenumber"][] = "Ungültige Rufnummer $number: Rufnummer wurde rausportiert ".$voicenumber->contract_id;
continue;
}
} else {
if(!array_key_exists($voicenumberblock->id, $this->create_numbers)) {
$this->create_numbers[$voicenumberblock->id] = [];
}
$this->create_numbers[$voicenumberblock->id][] = $number;
}
}
if(count($this->errors["voicenumberblock_voicenumber"])) {
return false;
}
return true;
}
public function beforeDelete() {
}
public function afterDelete() {
}
}

View File

@@ -18,6 +18,9 @@ class ContractconfigItem extends mfBaseModel {
return null;
}
if($this->multiple) {
return json_decode($value->json);
}
if($this->type == "int") {
return $value->int;
}

View File

@@ -30,9 +30,11 @@ class ContractconfigItemController extends mfBaseController {
}
$item_data['contractconfiggroup_id'] = $r->group_id;
$item_data['order'] = ($r->order && is_numeric($r->order)) ? $r->order : null;
$item_data['name'] = $r->name;
$item_data['displayname'] = $r->displayname;
$item_data['description'] = $r->description;
$item_data['multiple'] = ($r->multiple) ? 1 : 0;
$item_data['typedata'] = "";
$item_data['pattern'] = "";
@@ -53,7 +55,7 @@ class ContractconfigItemController extends mfBaseController {
$item_data['type'] = "decimal";
break;
default:
$this->layout()->setFlash("Ungültiger Datentyp!");
$this->layout()->setFlash("Ungültiger Datentyp!", "error");
$this->redirect("Contractconfiggroup");
}
@@ -68,7 +70,7 @@ class ContractconfigItemController extends mfBaseController {
$item_id = $item->save();
if(!$item_id) {
$this->layout()->setFlash("Fehler beim Speichern!");
$this->layout()->setFlash("Fehler beim Speichern!", "error");
$this->redirect("Contractconfiggroup");
}
@@ -78,5 +80,35 @@ class ContractconfigItemController extends mfBaseController {
}
protected function deleteAction() {
$r = $this->request;
$id = $r->id;
if(!is_numeric($id) || $id < 1) {
$this->layout()->setFlash("Config Element nicht gefunden!", "error");
$this->redirect("Contractconfiggroup");
}
$item = new ContractconfigItem($id);
if(!$item->id) {
$this->layout()->setFlash("Config Element nicht gefunden!", "error");
$this->redirect("Contractconfiggroup");
}
if(ContractconfigValueModel::getFirst(["item_id" => $id])) {
$this->layout()->setFlash("Config Element kann nicht gelöscht werden, das es in Verwendung ist!", "error");
$this->redirect("Contractconfiggroup");
}
if(!$item->delete()) {
$this->layout()->setFlash("Fehler beim Löschen!", "error");
$this->redirect("Contractconfiggroup");
}
$this->layout()->setFlash("Config Element erfolgreich gelöscht!", "success");
$this->redirect("Contractconfiggroup");
}
}

View File

@@ -4,6 +4,7 @@ class ContractconfigItemModel {
public $order;
public $contractconfiggroup_id;
public $type;
public $multiple;
public $name;
public $displayname;
public $description;
@@ -53,7 +54,7 @@ class ContractconfigItemModel {
}
public static function getFirst() {
public static function getFirst($filter) {
$db = FronkDB::singleton();
$where = self::getSqlFilter($filter);

View File

@@ -10,14 +10,29 @@ class ContractconfigValue extends mfBaseModel {
$me->loadMe();
$this->edit_by = $me->id;
if($new_value === null || strlen($new_value) == 0) {
if(!is_array($new_value) && ($new_value === null || strlen($new_value) == 0)) {
$this->int = null;
$this->number = null;
$this->string = null;
return true;
}
if($item->type == "int") {
if($item->multiple) {
if(!is_array($new_value)) {
$new_value = [$new_vale];
}
$json_array = [];
foreach($new_value as $v) {
if($v) {
$json_array[] = $v;
}
}
$this->json = json_encode($json_array);
} elseif($item->type == "int") {
if(!is_numeric($new_value)) return false;
$this->int = $new_value;
} elseif($item->type == "decimal") {

View File

@@ -0,0 +1,59 @@
<?php
class Contractjournal extends mfBaseModel {
private $contract;
private $contractfile;
private $creator;
private $editor;
public function getProperty($name) {
if($this->$name == null) {
if($name == "contractfile") {
if(!is_numeric($this->value)) return null;
$this->contractfile = new ContractFile($this->value);
return $this->contractfile;
}
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;
}
}

View File

@@ -0,0 +1,86 @@
<?php
class ContractjournalController 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;
//var_dump($r->get());exit;
$contract_id = $r->contract_id;
if(!is_numeric($contract_id) || $contract_id < 1) {
$this->layout()->setFlash("Contract nicht gefunden", "error");
$this->redirect("Contract");
}
$contract = new Contract($contract_id);
if(!$contract->id) {
$this->layout()->setFlash("Contract nicht gefunden", "error");
$this->redirect("Contract");
}
$journal_data = [];
$journal_data["contract_id"] = $contract_id;
$journal_data["text"] = ($r->text) ? $r->text : null;
$journal_data["type"] = "text";
if($r->type == "phone") $journal_data["type"] = "phone";
if($r->type == "file") $journal_data["type"] = "file";
if(in_array($r->type, ["text", "phone"])) {
if(!$journal_data['text']) {
$this->layout()->setFlash("Journaleintrag darf nicht leer sein", "error");
$this->redirect("Contract", "view", ['contract_id' => $contract_id]);
}
}
if($r->type == "file") {
try {
// returns File object or throws Exception on error
$file = mfUpload::handleFormUpload("journal_file");
} catch (Exception $ex) {
$this->layout()->setFlash("Fehler beim Dateiupload: ".$ex->getMessage(), "error");
$this->redirect("Contract", "view", ['contract_id' => $contract_id]);
}
$cf = ContractFileModel::create([
'contract_id' => $contract_id,
'file_id' => $file->id,
'name' => $file->name,
]);
$contractfile_id = $cf->save();
if(!$contractfile_id) {
$this->layout()->setFlash("Fehler beim Speichern der hochgeladenen Datei", "error");
$this->redirect("Contract", "view", ['contract_id' => $contract_id]);
}
$journal_data['type'] = "file";
$journal_data['value'] = $contractfile_id;
}
$journal = ContractjournalModel::create($journal_data);
$journal_id = $journal->save();
if(!$journal_id) {
$this->layout()->setFlash("Fehler beim Speichern des Journaleintrags", "error");
$this->redirect("Contract", "view", ['contract_id' => $contract_id]);
}
$this->layout()->setFlash("Journaleintrag erfolgreich gespeichert", "success");
$this->redirect("Contract", "view", ['contract_id' => $contract_id]);
}
}

View File

@@ -0,0 +1,128 @@
<?php
class ContractjournalModel {
public $contract_id;
public $type;
public $value;
public $text;
public $create_by = null;
public $edit_by = null;
public $create = null;
public $edit = null;
public static function create(Array $data) {
$model = new Contractjournal();
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("Contractjournal", "*", "1=1 ORDER BY contract_id,`create`");
if($db->num_rows($res)) {
while($data = $db->fetch_object($res)) {
$items[] = new Contractjournal($data);
}
}
return $items;
}
public static function getFirst($filter = false) {
$db = FronkDB::singleton();
$where = self::getSqlFilter($filter);
$res = $db->select("Contractjournal", "*", "$where ORDER BY contract_id,`create`");
if($db->num_rows($res)) {
$data = $db->fetch_object($res);
$item = new Contractjournal($data);
if($item->id) {
return $item;
} else {
return null;
}
}
return null;
}
public static function search($filter) {
$items = [];
$db = FronkDB::singleton();
$where = self::getSqlFilter($filter);
/*
$sql = "SELECT Contractjournal.* FROM Contractjournal
LEFT JOIN File ON (Contractjournal.file_id = File.id)
WHERE $where
ORDER BY order_id, name";
$res = $db->query($sql);
*/
$res = $db->select("Contractjournal", "*", $where);
if($db->num_rows($res)) {
while($data = $db->fetch_object($res)) {
$items[] = new Contractjournal($data);
}
}
return $items;
}
private static function getSqlFilter($filter) {
$where = "1=1 ";
if(array_key_exists("contract_id", $filter)) {
$contract_id = $filter['contract_id'];
if(is_numeric($contract_id)) {
$where .= " AND contract_id=$contract_id";
}
}
if(array_key_exists("order_id", $filter)) {
$order_id = $filter['order_id'];
if(is_numeric($order_id)) {
$where .= " AND order_id=$order_id";
}
}
if(array_key_exists("type", $filter)) {
$type = FronkDB::singleton()->escape($filter['type']);
if($type) {
$where .= " AND type='$type'";
}
}
if(array_key_exists("value", $filter)) {
$value = FronkDB::singleton()->escape($filter['value']);
if($value) {
$where .= " AND value='$value'";
}
}
//var_dump($filter, $where);exit;
return $where;
}
}

View File

@@ -11,8 +11,13 @@ class DashboardController extends mfBaseController {
}
protected function indexAction() {
if($this->me->is("preorderfront")) {
$this->redirect("Preorder");
}
$newss = NewsModel::getAll();
$this->layout()->set("newss", $newss);
}

View File

@@ -95,7 +95,7 @@ class DeviceController extends mfBaseController
$data = [];
$data['name'] = trim($r->name);
$data['devicetype_id'] = $r->devicetype_id;
if (trim($r->pop_id) == "0") {
if (trim($r->pop_id)=="0") {
$data['pop_id'] = NULL;
} else {
$data['pop_id'] = $r->pop_id;
@@ -181,6 +181,32 @@ class DeviceController extends mfBaseController
}
$this->redirect($returnUrl, $returnAction, $returnVariables, $returnAnker);
}
$returnUrl="Device";
$returnAction = "Index";
$returnVariables = array();
$returnAnker = "";
if ($this->request->returnto) {
if (strpos($this->request->returnto, "-") !== false) {
$urls = explode('-', $this->request->returnto);
$urlCounter = 0;
$returnUrlGen = "";
foreach ($urls as $url) {
if ($urlCounter > 0) {
$returnUrlGen .= "/";
}
$returnUrlGen .= ucfirst($url);
$urlCounter++;
}
$returnAction = "";
$returnVariables['id'] = $id;
$returnUrl = $returnUrlGen;
} else {
$returnUrl = ucfirst($this->request->returnto);
}
}
if ($mode == "edit") {
$this->layout()->setFlash("Device erfolgreich geändert", "success");
@@ -190,62 +216,4 @@ class DeviceController extends mfBaseController
$this->redirect($returnUrl, $returnAction, $returnVariables, $returnAnker);
}
protected function apiAction()
{
if (!$this->me->is(["Admin"])) {
$this->redirect("Dashboard");
}
$do = $this->request->do;
$format = $this->request->format;
$filename = $this->request->filename;
$id = $this->request->id;
$ip = $this->request->ip;
$data = [];
switch ($do) {
case "getconfig":
$return = $this->getConfig($id, $format, $filename);
break;
case "createconfig":
$return = $this->createConfig($ip);
break;
default:
$return = false;
}
}
private function getConfig($id, $format, $filename)
{
$configDownload = DeviceModel::getconifgdownload($id, $format);
//
// header('Content-Type: application/octet-stream');
header('Content-Type: text/plain');
header('Content-disposition: attachment; filename="' . $filename . '"');
echo $configDownload;
exit;
}
private function createConfig($ip)
{
$r = $this->request;
$id = $r->id;
$createConfig = DeviceModel::configcreate($ip);
if ($createConfig->success==="true")
{
$this->layout()->setFlash("Backup wurde erfolgreich erstellt", "success");
}
else
{
$this->layout()->setFlash("Backup konnte nicht erstellt werden. <b>Fehler</b>: ".$createConfig->error, "error");
}
$returnUrl = "Device";
$returnAction = "Detail";
$returnVariables['id'] = $id;
return $this->redirect($returnUrl, $returnAction, $returnVariables, $returnAnker);
}
}

View File

@@ -108,8 +108,8 @@ class DeviceModel
$db = FronkDB::singleton();
$where = self::getSqlFilter($filter);
$res = $db->select("Device", "*", "$where ORDER BY name");
if ($db->num_rows($res)) {
while ($data = $db->fetch_object($res)) {
if($db->num_rows($res)) {
while($data = $db->fetch_object($res)) {
$items[] = new Device($data);
}
}
@@ -121,9 +121,9 @@ class DeviceModel
$where = "1=1 ";
//var_dump($filter);exit;
if (array_key_exists("pop_id", $filter)) {
if(array_key_exists("pop_id", $filter)) {
$popid = $filter['pop_id'];
if (is_numeric($popid)) {
if(is_numeric($popid)) {
$where .= " AND pop_id=$popid";
}
}

View File

@@ -227,6 +227,38 @@ class Order extends mfBaseModel {
}
}
public function sendExtBillNbeInfoEmail() {
// TODO template rendern auslagern nach Emailtempate klasse
$tpl = new Layout();
$tpl->setTemplate("Emailtemplates/order/exernal_product_nbe_billing");
$tpl->set("order", $this);
$body = $tpl->render();
$values = $tpl->getReturnedValue();
//var_dump($values); echo "<pre class='text-monospace'>".$body."</pre>"; exit;
$subject = $values['subject'];
$from = $values['from_email'];
$from_name = $values['from_email_name'];
$to = TT_INTERNAL_BILLING_EMAIL_TO;
if(!$subject || !$from || !$from_name || !$to) {
$this->log->warn("Billing NBE Email not sent. (subject: '$subject', from: '$from', from_email: '$from_name', to: '$to')");
return false;
} else {
$email = new Emailnotification();
$email->setSubject($subject);
$email->setBody($body);
$email->setFrom($from, $from_name);
$email->setTo($to);
$email->setHeader("X-".MFAPPNAME."-oid", $this->id);
$email->send();
return true;
}
}
public function sendFileuploadEmail(OrderFile $file) {
$filetype = $file->name;

View File

@@ -364,9 +364,11 @@ class OrderController extends mfBaseController {
// TODO: filter by network permissions
$this->layout()->setTemplate("Order/Form");
$products = [];
if($this->me->is("Admin")) {
//$this->layout()->set("addresses", AddressModel::search(['parents_only' => 1]));
$this->layout()->set("products", ProductModel::getAll());
//$this->layout()->set("products", ProductModel::getActive());
$products = ProductModel::getActive();
$this->layout()->set("terminations", TerminationModel::getAll());
} else {
// get all salespartner addresses of my networks
@@ -396,13 +398,25 @@ class OrderController extends mfBaseController {
// get products assigned to my networks
$products = [];
foreach(ProductNetworkModel::search(["network_id" => $network_ids]) as $pn) {
if(!array_key_exists($pn->product_id, $products))
if(!$pn->product->active) continue;
if(!array_key_exists($pn->product_id, $products)) {
$products[$pn->product_id] = $pn->product;
}
}
$this->layout()->set("products", $products);
}
$order = $this->layout()->get("order");
if($order) {
foreach($order->products as $op) {
if(!$op->product->active) {
$products[$op->product_id] = $op->product;
}
}
}
$this->layout()->set("products", $products);
if($this->request->filter) {
$this->layout()->set("filter", $this->request->filter);
}
@@ -811,6 +825,8 @@ class OrderController extends mfBaseController {
$ext_products = false;
$int_products = false;
$ext_products_nbe = 0;
//var_dump($r->products);exit;
// validate and add products
if(is_array($r->products) && count($r->products)) {
@@ -849,7 +865,7 @@ class OrderController extends mfBaseController {
} else {
$product_data["price_nne"] = $prod->price_nne;
}
if($this->me->is("Admin") && $p["price_nbe"]) {
if($this->me->is("Admin") && strlen($p["price_nbe"])) {
$product_data["price_nbe"] = Layout::commaToDot($p["price_nbe"]);
} else {
$product_data["price_nbe"] = $prod->price_nbe;
@@ -894,6 +910,7 @@ class OrderController extends mfBaseController {
if($prod->external) {
$ext_products = true;
$ext_product_owner_id = $prod->external_id;
$ext_products_nbe += $product_data["price_nbe"];
} else {
$int_products = true;
@@ -1006,6 +1023,13 @@ class OrderController extends mfBaseController {
if(!$order->sendExtBillinfoEmail(new Address($ext_product_owner_id))) {
$this->layout()->setFlash("Beim Senden der externen Billing Benachrichtigung ist ein Fehler aufgetreten.", "warning");
}
if($ext_products_nbe) {
// only send nbe mail if there is nbe
if(!$order->sendExtBillNbeInfoEmail(new Address($ext_product_owner_id))) {
//$this->layout()->setFlash("Beim Senden der internen Billing NBE Benachrichtigung ist ein Fehler aufgetreten.", "warning");
}
}
}
if($int_products) {
@@ -1015,7 +1039,7 @@ class OrderController extends mfBaseController {
}
if($int_products && $ext_products) {
$this->layout()->setFlash("Eigene und Fremdprodukte gefunden, nur interne Billing Benachrichtigung verschickt.", "warning");
//$this->layout()->setFlash("Eigene und Fremdprodukte gefunden, nur interne Billing Benachrichtigung verschickt.", "warning");
}
}

View File

@@ -8,6 +8,7 @@ class Preorder extends mfBaseModel {
private $building;
private $adb_hausnummer;
private $adb_wohneinheit;
private $attribute = [];
public function afterLoad() {
@@ -48,6 +49,7 @@ class Preorder extends mfBaseModel {
$a = [];
$a['code'] = strtoupper($this->ucode);
$a['oaid'] = $this->oaid;
$a['extref'] = $this->extref;
$a['status'] = $this->getProperty("status")->getApiArray();
$a['connectionType'] = $this->connection_type;
$a['connectionCount'] = ($this->connection_count) ? (int)$this->connection_count : 1;
@@ -119,6 +121,11 @@ class Preorder extends mfBaseModel {
}
}
$a['created'] = date("c", $this->create);
$a['created_ts'] = (int)$this->create;
$a['updated'] = date("c", $this->edit);
$a['updated_ts'] = (int)$this->edit;
return $a;
}
@@ -178,6 +185,14 @@ class Preorder extends mfBaseModel {
}
if($name == "attribute") {
if(!$this->attributes) {
return null;
}
$this->attribute = json_decode($this->attributes, true);
return $this->attribute;
}
if($name == "creator") {
$user = mfValuecache::singleton()->get("Worker-id-".$this->create_by);
if($user) {

View File

@@ -9,7 +9,7 @@ class PreorderController extends mfBaseController {
$this->me = $me;
$this->layout()->set("me",$me);
if(!$me->is(["Admin", "netowner", "salespartner"])) {
if(!$me->is(["Admin", "netowner", "salespartner", "preorderfront"])) {
$this->redirect("Dashboard");
}
}
@@ -24,7 +24,6 @@ class PreorderController extends mfBaseController {
$this->layout->set("filter", $rfilter);
$where = "";
$filter = $this->getPreparedFilter($rfilter);
// pagination defaults
@@ -37,7 +36,6 @@ class PreorderController extends mfBaseController {
$pagination['start'] = intval($this->request->s);
}
$preorder_filter = $filter;
$my_campaigns = [];
$my_campaign_ids = [];
@@ -49,7 +47,16 @@ class PreorderController extends mfBaseController {
}
$this->layout()->set("my_campaigns", PreordercampaignModel::getAll());
} else {
$my_networks = $this->me->myNetworks(["netowner", "salespartner"]);
if($this->me->is("preorderfront")) {
$pns = json_decode($this->me->getFlag("preorder_networks"));
foreach($pns as $pn_id) {
$my_networks[] = new Network($pn_id);
}
//var_dump($my_networks);exit;
} else {
$my_networks = $this->me->myNetworks(["netowner", "salespartner"]);
}
//var_dump($my_networks);exit;
foreach($my_networks as $network) {
@@ -101,14 +108,19 @@ class PreorderController extends mfBaseController {
$new_filter['add-where'] = "";
if(array_key_exists("address", $filter)) {
if(array_key_exists("address", $filter) && $filter["address"]) {
$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%')";
}
if(array_key_exists("kunde", $filter)) {
if(array_key_exists("hausnummer", $filter) && $filter["hausnummer"]) {
$hausnummer = $this->db()->escape($filter['hausnummer']);
$new_filter['hausnummer'] = $hausnummer;
}
if(array_key_exists("kunde", $filter) && $filter["kunde"]) {
$kunde = $this->db()->escape($filter['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['add-where'] .= " AND (company like '%$kunde%' OR firstname like '%$kunde%' OR lastname like '%$kunde%' OR concat(firstname, ' ', lastname) like '%$kunde%' OR concat(lastname, ' ', firstname) like '%$kunde%' OR street like '%$kunde%' OR zip like '%$kunde%' OR city like '%$kunde%')";
}
@@ -126,6 +138,9 @@ class PreorderController extends mfBaseController {
}
}
if(array_key_exists("attributes", $filter) && count($filter['attributes'])) {
}
if(is_array($filter) && count($filter)) {
foreach($filter as $name => $value) {
@@ -155,6 +170,7 @@ class PreorderController extends mfBaseController {
$products = [];
foreach(ProductNetworkModel::search(["network_id" => $campaign->network_id]) as $pn) {
if(!$pn->product->active) continue;
if(!array_key_exists($pn->product_id, $products)) {
if(is_array($pn->product->attributes) && !array_key_exists("presales", $pn->product->attributes)) {
$products[$pn->product_id] = $pn->product;
@@ -585,4 +601,186 @@ class PreorderController extends mfBaseController {
}
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']);
$preorder_filter = $filter;
/*if(!array_key_exists("netzgebiet_id", $preorder_filter)) {
$preorder_filter['netzgebiet_id'] = $netzgebiet_ids;
}*/
$campaign_ids = [];
foreach(PreordercampaignModel::search(["netzgebiet_id" => $netzgebiet_ids]) as $campaign) {
if(!in_array($campaign->id, $campaign_ids)) {
$campaign_ids[] = $campaign->id;
}
}
if(array_key_exists("preordercampaign_id", $filter) && in_array($filter['preordercampaign_id'], $campaign_ids)) {
$preorder_filter["preordercampaign_id"] = $filter['preordercampaign_id'];
} else {
$preorder_filter["preordercampaign_id"] = $campaign_ids;
}
$preorder_filter['<status_code'] = 800;
//var_dump($filter, $preorder_filter);exit;
// Get mysqli resource from Model, so layout can output data as it's retrieved
// Works around lousy performance and horrendous memory usage
$res = PreorderModel::search($preorder_filter, [], true);
$this->layout()->setTemplate("Preorder/export.csv");
$this->layout()->set("res", $res);
}
protected function apiAction() {
if(!$this->me->is(["Admin","netowner","salespartner"])) {
$this->redirect("Dashboard");
}
$do = $this->request->do;
$data = [];
switch($do) {
case "saveAttribute":
$return = $this->saveAttributeApi();
break;
case "getFilteredPreorders":
$return = $this->getFilteredPreordersApi();
break;
default:
$return = false;
}
if(!is_array($return) || !count($return)) {
$data = ["status" => "error"];
$this->returnJson($data);
}
$data['status'] = "OK";
$data['result'] = $return;
$this->returnJson($data);
}
private function getFilteredPreordersApi() {
$preorders = [];
$filter = [];
if(is_array($this->request->filter)) {
$filter = $this->request->filter;
}
$filter = $this->getPreparedFilter($filter);
$my_campaign_ids = [];
if($this->me->is("Admin")) {
$my_networks = NetworkModel::getAll();
} else {
$my_networks = $this->me->myNetworks(['netowner','salespartner']);
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;
}
}
if(array_key_exists("preordercampaign_id", $filter)) {
if(!in_array($filter['preordercampaign_id'], $my_campaign_ids)) {
$filter['preordercampaign_id'] = $my_campaign_ids;
}
}
}
//var_dump($filter);exit;
$results = PreorderModel::search($filter);
foreach($results as $preorder) {
//$this->log->debug("building status: ".print_r($building->status,true));
$data = clone($preorder->data);
$data->id = $preorder->id;
$data->status_code = $preorder->status->code;
$data->adrcd = $preorder->adb_hausnummer->adrcd;
$data->extref = $preorder->adb_hausnummer->extref;
$data->adb_strasse = $preorder->adb_hausnummer->strasse->name;
$data->adb_hausnummer = $preorder->adb_hausnummer->hausnummer;
$data->adb_plz = $preorder->adb_hausnummer->plz->plz;
$data->adb_ort = $preorder->adb_hausnummer->ortschaft->name;
$data->adb_gemeinde = $preorder->adb_hausnummer->strasse->gemeinde->name;
$data->gps_lat = $preorder->adb_hausnummer->gps_lat;
$data->gps_long = $preorder->adb_hausnummer->gps_long;
$data->type_label = __($data->type, "preorder");
$data->connection_type_label = __($data->connection_type, "preorder");
$preorders[] = $data;
}
return ["preorders" => $preorders];
}
private function saveAttributeApi() {
$preorder_id = $this->request->id;
if(!is_numeric($preorder_id) || $preorder_id < 1) {
return false;
}
$preorder = new Preorder($preorder_id);
if(!$preorder->id) {
return false;
}
$attribute = $this->request->attribute;
if(!$attribute) {
return false;
}
$value = $this->request->value;
$attribs = $preorder->attribute;
if(!$attribs) {
$attribs = [];
}
$attribs[$attribute] = $value ? 1 : 0;
$preorder->attributes = json_encode($attribs);
if($preorder->save()) {
return ["id" => $preorder_id, "attribute" => $attribute, "update" => date("d.m.Y H:i", $preorder->edit)];
} else {
$this->returnJson(["status" => "error", "result" => ["id" => $preorder_id, "attribute" => $attribute]]);
}
}
}

View File

@@ -7,6 +7,7 @@ class PreorderModel {
public $adb_hausnummer_id;
public $adb_wohneinheit_id;
public $oaid;
public $extref;
public $address_district;
public $address_info;
public $building_id;
@@ -50,6 +51,7 @@ class PreorderModel {
public $shipping_address;
public $addon_services;
public $addon_data;
public $attributes;
public $submit_type;
public $submit_request;
@@ -215,6 +217,7 @@ class PreorderModel {
$where = self::getSqlFilter($filter);
$sql = "SELECT COUNT(*) as cnt 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
";
@@ -229,7 +232,7 @@ class PreorderModel {
return 0;
}
public static function search($filter, $limit = false) {
public static function search($filter, $limit = false, $returnDBRessource = false) {
$items = [];
$db = FronkDB::singleton();
@@ -254,6 +257,12 @@ class PreorderModel {
$res = $db->query($sql);
if($db->num_rows($res)) {
// hack for Preorder::exportAction
if($returnDBRessource) {
return $res;
}
while($data = $db->fetch_object($res)) {
$items[] = new Preorder($data);
}
@@ -413,6 +422,13 @@ class PreorderModel {
}
}
if(array_key_exists("extref", $filter)) {
$extref = FronkDB::singleton()->escape($filter['extref']);
if($extref) {
$where .= " AND tt_preorder.extref = '$extref'";
}
}
if(array_key_exists("gemeinde", $filter)) {
$gemeinde = FronkDB::singleton()->escape($filter['gemeinde']);
if($gemeinde) {
@@ -434,6 +450,29 @@ class PreorderModel {
}
}
if(array_key_exists("hausnummer", $filter)) {
$hausnummer = FronkDB::singleton()->escape($filter['hausnummer']);
if($hausnummer) {
$where .= " AND adb_hausnummer.hausnummer like '%$hausnummer%'";
}
}
if(array_key_exists("attributes", $filter)) {
$attributes = FronkDB::singleton()->escape($filter['attributes']);
if(is_array($attributes) && count($attributes)) {
if(array_key_exists("bep_specified", $attributes)) {
if($attributes['bep_specified']) {
$where .= " AND JSON_EXTRACT(attributes, \"$.bep_specified\") = 1";
}
}
if(array_key_exists("inhouse_cabling_supplied", $attributes)) {
if($attributes['inhouse_cabling_supplied']) {
$where .= " AND JSON_EXTRACT(attributes, \"$.inhouse_cabling_supplied\") = 1";
}
}
}
}
// custom where clause
if(array_key_exists("add-where", $filter)) {
$where .= " ".$filter['add-where'];

View File

@@ -54,9 +54,9 @@ class Preordercampaign extends mfBaseModel {
$activation_products = [];
$reorder_products = [];
$provisions = ProductModel::search(["attributename" => "presales", "attributevalue" => "provision"]);
$activations = ProductModel::search(["attributename" => "presales", "attributevalue" => "activation"]);
$reorders = ProductModel::search(["attributename" => "presales", "attributevalue" => "reorder"]);
$provisions = ProductModel::search(["active" => 1, "attributename" => "presales", "attributevalue" => "provision"]);
$activations = ProductModel::search(["active" => 1, "attributename" => "presales", "attributevalue" => "activation"]);
$reorders = ProductModel::search(["active" => 1, "attributename" => "presales", "attributevalue" => "reorder"]);
foreach($provisions as $p) {
if(ProductNetworkModel::search(['product_id' => $p->id, "network_id" => $this->network_id])) {

View File

@@ -1,6 +1,7 @@
<?php
class Product extends mfBaseModel {
private $owner;
private $productgroup;
private $producttech;
private $sla;
@@ -45,6 +46,12 @@ class Product extends mfBaseModel {
public function getProperty($name) {
if($this->$name == null) {
if($name == "owner") {
if(!$this->external_id) return null;
$this->owner = new Address($this->external_id);
return $this->owner;
}
if($name == "networks") {
$this->networks = [];
$productNetworks = ProductNetworkModel::search(['product_id' => $this->id]);

View File

@@ -19,16 +19,23 @@ class ProductController extends mfBaseController {
$this->redirect("Dashboard");
}
if($this->request->resetFilter) {
unset($_SESSION[MFAPPNAME.'-Product-filter']);
}
$filter = [];
if(is_array($this->request->filter)) {
$filter = $this->request->filter;
$_SESSION[MFAPPNAME.'-Product-filter'] = $filter;
} else {
if(array_key_exists(MFAPPNAME.'-Product-filter', $_SESSION) && count($_SESSION[MFAPPNAME.'-Product-filter'])) {
$filter = $_SESSION[MFAPPNAME.'-Product-filter'];
}
}
$this->layout->set("filter", $filter);
$filter = $this->getPreparedFilter($filter);
if($filter) {
$filter = $this->getPreparedFilter($filter);
}
// pagination defaults
$pagination = [];
@@ -55,6 +62,15 @@ class ProductController extends mfBaseController {
unset($filter['name']);
}
if(array_key_exists("active", $filter)) {
if($filter['active'] != "all") {
$new_filter['active'] = $filter['active'];
}
unset($filter['active']);
} else {
$new_filter['active'] = 1;
}
foreach($filter as $name => $value) {
$new_filter[$name] = $value;
}
@@ -128,7 +144,11 @@ class ProductController extends mfBaseController {
}
$data['external_id'] = $r->external_id;
}
//var_dump($data);exit;
$data['active'] = 1;
if(!$r->active) {
$data['active'] = 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;
@@ -229,7 +249,12 @@ class ProductController extends mfBaseController {
}
$this->layout()->setFlash("Produkt erfolgreich gespeichert.", "success");
$this->redirect("Product", "Edit", ['id' => $new_id]);
if($r->return == "index") {
$this->redirect("Product");
} else {
$this->redirect("Product", "Edit", ['id' => $new_id]);
}
}
protected function deleteAction() {
@@ -310,14 +335,14 @@ class ProductController extends mfBaseController {
$products = [];
if(is_numeric($search)) {
$pnumbers = ProductModel::search(["id" => $search]);
$pnumbers = ProductModel::search(["active" => 1, "id" => $search]);
if($pnumbers) {
$products = array_merge($products, $pnumbers);
}
}
$products = array_merge($products, ProductModel::search(["name%" => $search]));
$products = array_merge($products, ProductModel::search(["active" => 1, "name%" => $search]));
if(!is_array($products) && !count($products)) {
return false;

View File

@@ -75,6 +75,21 @@ class ProductModel {
}
public static function getActive() {
$items = [];
$db = FronkDB::singleton();
$res = $db->select("Product", "*", "active = 1 ORDER BY name,producttech_id");
if($db->num_rows($res)) {
while($data = $db->fetch_object($res)) {
$items[] = new Product($data);
}
}
return $items;
}
public static function getFirst() {
$db = FronkDB::singleton();
@@ -162,6 +177,15 @@ class ProductModel {
}
}
if(array_key_exists("active", $filter)) {
$active = $filter['active'];
if($active) {
$where .= " AND Product.`active` = 1";
} else {
$where .= " AND Product.`active` = 0";
}
}
if(array_key_exists("productgroup_id", $filter)) {
$productgroup_id = $filter['productgroup_id'];
if(is_numeric($productgroup_id)) {
@@ -204,6 +228,15 @@ class ProductModel {
}
}
if(array_key_exists("external_id", $filter)) {
$external_id = $filter['external_id'];
if(is_numeric($external_id)) {
$where .= " AND external_id=$external_id";
} elseif(is_array($external_id) && count($external_id)) {
$where .= " AND Product.external_id IN (". implode(",", $external_id).")";
}
}
if(array_key_exists("external", $filter)) {
$external = $filter['external'];
if(is_numeric($external)) {

View File

@@ -178,7 +178,22 @@ class UserController extends mfBaseController {
$user->permissions->technician = "false";
}
if($r->preorderfront == "true") {
$user->permissions->preorderfront = "true";
} else {
$user->permissions->preorderfront = "false";
}
$user->permissions->save();
// save networks
$pn = $user->getFlag("preorder_networks");
if($r->preorderfront == "true" && is_array($r->preorder_networks) && count($r->preorder_networks)) {
$pn->value(json_encode($r->preorder_networks));
$pn->save();
} else {
$pn->delete();
}
}
$this->layout()->setFlash("Benutzer gespeichert.", "success");

View File

@@ -7,19 +7,12 @@ class Voicenumber extends mfBaseModel {
public function loadFromBlock(Voicenumberblock $block) {
$this->voicenumberblock_id = $block->id;
$this->countrycode = $block->countrycode;
$this->areacode = $block->areacode;
$this->number_prepend_zero = $block->number_prepend_zero;
//$this->countrycode = $block->countrycode;
//$this->areacode = $block->areacode;
//$this->number_prepend_zero = $block->number_prepend_zero;
return true;
}
public function getFullNumber() {
$number = $this->countrycode.$this->areacode.$this->number;
return $number;
}
public function beforeSave() {
if($this->ported_from && $this->port_in_date) {
$this->ported_in = 1;
@@ -32,9 +25,11 @@ class Voicenumber extends mfBaseModel {
} else {
$this->ported_out = 0;
}
if($this->active == 1 && !$this->_old_data->active) {
$this->activated_date = date("U");
//var_dump($this);exit;
if(is_array($this->_old_data) && count($this->_old_data)) {
if($this->active == 1 && !$this->_old_data->active) {
$this->activated_date = date("U");
}
}
}

View File

@@ -47,7 +47,6 @@ class VoicenumberController extends mfBaseController {
$number->number = $num;
$mode = "add";
}
//var_dump($number);exit;
$this->layout()->setTemplate("Voicenumber/Form");
$this->layout()->set("number", $number);
@@ -57,7 +56,7 @@ class VoicenumberController extends mfBaseController {
protected function saveAction() {
$r = $this->request;
//var_dump($r);
//var_dump($r);exit;
$block_id = $r->block_id;
if(!is_numeric($block_id) || !$block_id) {
$this->layout()->setFlash("Rufnummer nicht gefunden1", "error");
@@ -96,7 +95,7 @@ class VoicenumberController extends mfBaseController {
$number_data = [];
$number_data['contract_id'] = $r->contract_id;
$number_data['contract_id'] = ($r->contract_id) ? $r->contract_id : null;
if($r->active === "1") {
$number_data['active'] = 1;
} else {
@@ -141,10 +140,15 @@ class VoicenumberController extends mfBaseController {
$number_data['disabled_reason'] = "reserved";
}
} else {
$number_data['disabled'] = 0;
$number_data['disabled_reason'] = null;
}
if($r->enable_on_date) {
$number_data['enable_on_date'] = self::dateToTimestamp($r->enable_on_date);
} else {
$number_data['enable_on_date'] = null;
}
$number_data['comment'] = $r->comment;
$number_data['edit_by'] = $this->me->id;

View File

@@ -1,12 +1,23 @@
<?php
class VoicenumberModel {
public $name;
public $voicenumberblock_id;
public $orderproduct_id;
public $contract_id;
public $active;
public $activated_date;
public $routing;
public $number;
public $countrycode;
public $areacode;
public $first;
public $last;
public $number_prepend_zero;
public $ported_from;
public $ported_to;
public $port_in_date;
public $port_out_date;
public $ported_in;
public $ported_out;
public $disabled;
public $disabled_reason;
public $enable_on_date;
public $comment;
public $create_by;
@@ -146,21 +157,9 @@ class VoicenumberModel {
}
if(array_key_exists("number", $filter)) {
$add_zero = false;
$number = $filter['number'];
mfLoghandler::singleton()->debug($number);
if(substr($number,0, 1) === "0") {
$add_zero = true;
$number = substr($number, 1);
}
if(is_numeric($number)) {
$where .= " AND number = $number";
if($add_zero) {
$where .= " AND number_prepend_zero = 1";
}
$number = $db->escape($filter['number']);
if($number) {
$where .= " AND number = '$number'";
}
}

View File

@@ -5,46 +5,36 @@ class Voicenumberblock extends mfBaseModel {
private $number_first;
private $number_last;
private $base;
private $short_prefix;
private $short_first;
private $short_last;
private $files;
private $numbers;
private function getFullNumber($last = false) {
if($last) {
$number = $this->countrycode.$this->areacode.$this->getLast();
} else {
$number = $this->countrycode.$this->areacode.$this->getFirst();
}
return $number;
}
public function getFirst() {
if($this->number_prepend_zero) {
return "0".$this->first;
}
return $this->first;
}
public function getLast() {
if($this->number_prepend_zero) {
return "0".$this->last;
}
return $this->last;
}
public function getBaseNumber() {
$base = floor($this->first / pow(10, ceil(log10($this->last - $this->first))));
if($this->number_prepend_zero) {
return "0".$base;
}
return $base;
}
public function isNumberInBlock($number) {
return ($number >= $this->first && $number <= $this->last);
}
public static function findBlock($number) {
// resolve number from right to left to find fitting block
$minLength = 4;
$try = $number;
while(strlen($try) >= $minLength) {
$block = VoicenumberblockModel::getFirst(['prefix' => $try]);
if($block) {
break;
}
$try = substr($try, 0, strlen($try)-1);
}
if(!$block) {
return false;
}
return $block;
}
public function getProperty($name) {
if($this->$name == null) {
@@ -58,16 +48,17 @@ class Voicenumberblock extends mfBaseModel {
return $this->numbers;
}
if($name == "number_first") {
return $this->getFullNumber();
if($name == "short_prefix") {
$this->short_prefix = substr($this->prefix, strlen($this->countrycode.$this->areacode));
return $this->short_prefix;
}
if($name == "number_last") {
return $this->getFullNumber(true);
if($name == "short_first") {
$this->short_first = substr($this->first, strlen($this->countrycode.$this->areacode));
return $this->short_first;
}
if($name == "base") {
return $this->getBaseNumber();
if($name == "short_last") {
$this->short_last = substr($this->last, strlen($this->countrycode.$this->areacode));
return $this->short_last;
}
$classname = ucfirst($name);

View File

@@ -4,9 +4,9 @@ class VoicenumberblockModel {
public $name;
public $countrycode;
public $areacode;
public $prefix;
public $first;
public $last;
public $number_prepend_zero;
public $comment;
public $create_by;
@@ -52,7 +52,7 @@ class VoicenumberblockModel {
}
public static function getFirst() {
public static function getFirst($filter = false) {
$db = FronkDB::singleton();
$where = self::getSqlFilter($filter);
@@ -137,57 +137,32 @@ class VoicenumberblockModel {
}
}
if(array_key_exists("first", $filter)) {
$add_zero = false;
$first = $filter['first'];
mfLoghandler::singleton()->debug($first);
if(substr($first,0, 1) === "0") {
$add_zero = true;
$first = substr($first, 1);
if(array_key_exists("prefix", $filter)) {
$prefix = $filter['prefix'];
if(is_numeric($prefix)) {
$where .= " AND prefix = '$prefix'";
}
}
if(array_key_exists("first", $filter)) {
$first = $filter['first'];
if(is_numeric($first)) {
$where .= " AND first like '%$first%'";
if($add_zero) {
$where .= " AND number_prepend_zero = 1";
}
$where .= " AND first = '$first'";
}
}
if(array_key_exists("last", $filter)) {
$add_zero = false;
$last = $filter['last'];
mfLoghandler::singleton()->debug($last);
if(substr($last,0, 1) === "0") {
$add_zero = true;
$last = substr($last, 1);
}
if(is_numeric($last)) {
$where .= " AND last like '%$last%'";
$where .= " AND last = '$last'";
}
}
if(array_key_exists("number", $filter)) {
$add_zero = false;
$number = $filter['number'];
mfLoghandler::singleton()->debug($number);
if(substr($number,0, 1) === "0") {
$add_zero = true;
$number = substr($number, 1);
}
if(is_numeric($number)) {
$where .= " AND first <= $number AND last >= $number";
if($add_zero) {
$where .= " AND number_prepend_zero = 1";
}
}
}

View File

@@ -0,0 +1,67 @@
<?php
class WorkerFlag {
private $db;
private $id;
private $worker_id = null;
private $name = null;
private $value = null;
private $user = null;
public function __construct($worker_id, $name) {
$this->db = new FronkDB();
$user = new User($worker_id);
$this->user = $user;
$name = $this->db->escape($name);
$this->name = $name;
$res = $this->db->select("WorkerFlag", "*", "worker_id=".$this->user->id." AND name='$name'");
if($this->db->num_rows($res)) {
$data = $this->db->fetch_object($res);
$this->id = $data->id;
$this->value = $data->value;
}
}
public function value($value = null) {
if($value !== null) {
$this->value = $value;
}
return $this->value;
}
public function save() {
$id = $this->id;
$values['worker_id'] = $this->user->id;
$values['name'] = $this->name;
$values['value'] = $this->value;
$values['edit_by'] = $this->user->id;
$values['edit'] = date('U');
if($id) {
// update
$this->db->update("WorkerFlag", $values, "id=$id");
} else {
// insert
$values['create_by'] = $this->user->id;
$values['create'] = date('U');
$id = $this->db->insert("WorkerFlag", $values);
$this->id = $id;
}
}
public function delete() {
if($this->id) {
$this->db->delete("WorkerFlag", "id=".$this->id, 1);
}
return true;
}
public function __toString() {
return (string) $this->value;
}
}

View File

@@ -4,6 +4,7 @@ class WorkerPermission extends mfBaseModel {
public $isAdmin = false;
public $isTicketadmin = false;
public $isTechnician = false;
public $isPreorderfront = false;
public function loadByUserId($userid) {
$res = $this->db->select($this->table,"*","worker_id=$userid");
@@ -29,6 +30,9 @@ class WorkerPermission extends mfBaseModel {
if($this->technician == 'true') {
$this->isTechnician = true;
}
if($this->preorderfront == 'true') {
$this->isPreorderfront= true;
}
}
}

View File

@@ -44,6 +44,12 @@ $l['preorder.provision'] = "Vorsorgeanschluss";
$l['preorder.order'] = "Vollanschluss";
$l['preorder.reorder'] = "Nachbestellung";
$l['preorder.single-dwelling'] = "Einfahmilienhaus";
$l['preorder.multi-dwelling'] = "Mehrfamilienhaus";
$l['preorder.apartment-building'] = "Mehrparteienhaus";
$l['preorder.apartment'] = "Wohneinheit in Mehrparteienhaus";
$l['preorder.business'] = "Gewerbebetrieb";
$l['contract.link'] = "Verknüpfung";
$l['contract.upgrade'] = "Upgrade";
$l['contract.downgrade'] = "Downgrade";

View File

@@ -413,11 +413,11 @@ class mfBaseApicontroller {
if(!is_array($this->routes) || !count($this->routes)) {
return false;
}
//var_dump($params);exit;
$params = trim($params, "/");
$m = [];
if(preg_match('/\.(\w+)$/', $params, $m)) {
if(preg_match('/\.(csv|json|html|txt)$/', $params, $m)) {
if($m[1]) {
$format = strtolower($m[1]);
$params = preg_replace("/\.$format$/", "", $params);
@@ -453,7 +453,7 @@ class mfBaseApicontroller {
continue;
} else {
if($rp != $req_parts[$i]) {
continue 2; // break out of this loop and continue outer foreach
continue 2; // break out of this loop and continue outer foreach (try next route)
}
}
}

View File

@@ -12,8 +12,8 @@ class mfBaseController {
private $mfLayout;
private $mfMenu;
private $mfUser;
private $mod;
private $action;
protected $mod;
protected $action;
public function __construct($params = NULL) {
// load logging facility
@@ -235,6 +235,8 @@ class mfBaseController {
$url.="#$anker";
}
$url = preg_replace('#^/+#', "/", $url);
$log->debug("Redirecting to $url");
header("Location: $url");
exit;

View File

@@ -36,6 +36,13 @@ class mfLayout {
public function set($name, $value) {
$this->tvars[$name] = $value;
}
public function get($name) {
if(array_key_exists($name, $this->tvars)) {
return $this->tvars[$name];
}
return null;
}
public function setPackage($package) {
$this->package = $package;

View File

@@ -46,6 +46,58 @@ class mfUpload {
}
}
static public function handleFormUpload($uplName, $filename = false, $subfolder = false, $savepath = MFUPLOAD_FILE_SAVE_PATH) {
if(!isset($_FILES) || !array_key_exists($uplName, $_FILES)) {
throw new Exception("Uploaded file not found");
}
if($_FILES['OrderFileUpload']['error']) {
throw new Exception("Error receiving file");
}
$upload_error = false;
$savepath = preg_replace('#/+$#', "", $savepath); // remove trailing slash
if($subfolder) {
$subfolder = preg_replace('#^/+#', "", $subfolder); // remove leading slash
$subfolder = preg_replace('#/+$#', "", $subfolder); // remove trailing slash
$savepath .= "/$subfolder";
}
$upload = new mfUpload($uplName);
$upload->setSavepath($savepath);
if(!$upload->getSize()) {
throw new Exception("Datei darf nicht leer sein");
}
if(substr(strtolower($upload->getFilename()), -3, 3) == "pdf" && !$upload->validatePDF()) {
throw new Exception("PDF-Validierung fehlgeschlagen");
}
try {
$upload->save();
} catch (Exception $ex) {
throw $ex;
}
$file_data = [];
$file_data['name'] = ($filename) ? $filename : $upload->getOriginalFilename();
$file_data['filename'] = ($filename) ? $filename : $upload->getOriginalFilename();
$file_data['subfolder'] = $subfolder;
$file_data['store_filename'] = $upload->getFilename();
$file_data['orig_filename'] = $upload->getOriginalFilename();
$file = FileModel::create($file_data);
$file_id = $file->save();
if(!$file_id) {
unlink($upload->getSavepath()."/".$upload->getFilename());
throw new Exception("Datei konnte nicht angelegt werden");
}
return $file;
}
public function getSavepath() {
return $this->savepath;
}

View File

@@ -28,4 +28,16 @@ class mfValuecache {
public function getCache() {
return $this->cache;
}
public function getMfObject($objectname, $id) {
$object = $this->get("mfObjectmodel-$objectname-".$id);
if(!$object) {
$object = new $objectname($id);
if($object->id) {
$this->set("mfObjectmodel-$objectname-".$id, $object);
}
}
return $object;
}
}

View File

@@ -32,10 +32,6 @@
width: 50px;
}
.edit-width-large {
width: 100px;
}
.order-date-pill {
margin: 2px;
white-space: nowrap;
@@ -43,41 +39,4 @@
.font-weight-500 {
font-weight: 500;
}
.history-ico {
color: #007bff;
cursor: pointer;
}
.history-ico:hover {
color: #006875;
}
.code-ico {
cursor: pointer;
font-size: 25px;
margin-top: 7px;
margin-left: 10px;
}
.spinner-ico {
margin-left: 5px;
}
.filestore-history {
background-color: #33ff0021 !important;
}
.filestore-history-td {
padding: 0 0px 0 10px !important;
box-shadow: unset;
}
.filestore-history-td:hover {
box-shadow: unset !important;
}
.filestore-history-tr:hover{
color: unset !important;
background-color: #fff !important;
}

View File

@@ -24,6 +24,19 @@
text-align:left;
}
.table-striped tbody tr.active:nth-of-type(odd) {
background-color: #e0f5e0;
}
.table-striped tbody tr.active:nth-of-type(even) {
background-color: #f0fff0;
}
.table-hover tbody tr.active:hover {
color: #212529;
background-color: #dbf0db;
}
.btn-primary {
color: #fff;
background-color: #0d6efd;
@@ -71,6 +84,25 @@ h1, h2, h3, h4, h5, h6 {
border-color: #f0f0f0;
box-shadow: 3px 3px 2px #a0a0a0;
}
.card.border-top-primary {
border-top: 2px solid #007bff;
}
.card.border-top-danger {
border-top: 2px solid #f1556c;
}
.card.border-top-success {
border-top: 2px solid #25b343;
}
.card.border-top-warning {
border-top: 2px solid #f7b84b;
}
.card.border-top-info {
border-top: 2px solid #4b88e4;
}
/*
.card-header.underline-danger {
border-bottom: 2px solid #f1556c;
}*/
#topnav {
box-shadow: 2px 2px 1px #a0a0a0;

View File

@@ -13,7 +13,7 @@ tags:
- name: addressdb
description: Abfrage von GWR-Daten
- name: preorder
description: Informationen zum Netzgebiet und Speichern von Vorbestellungen
description: Abfragen und Operationen zu Vorbestellungen
paths:
/addressdb/getClusters:
get:
@@ -482,6 +482,10 @@ paths:
---
Parameter `extref`: Providereigener Identifikationsstring. Wird unverändert gespeichert und kann statt `code` in `GET /preorder` und `DELETE /preorder` angegeben werden. **Darf nicht mit Dateiendung wie z.B. `.json`, `.csv` enden, da diese als Ausgabeformat interpretiert werden können**
---
Parameter `additionalData`: **(Optional)** Object für zusätzliche individuelle Daten, die in der Vorbestellung gespeichert werden. Wird in `GET /preorder` retourniert.
operationId: submitPreorder
@@ -514,6 +518,13 @@ paths:
type: string
description: Code für Statusabfrage
example: A1B2C3D4
oaid:
type: string
description: OAID
example: AT-9999-abcdef01
extref:
type: string
description: Providereigener Identifikationsstring. Wird unverändert gespeichert und kann statt `code` in `GET /preorder` und `DELETE /preorder` angegeben werden. **Darf nicht mit Dateiendung wie z.B. `.json`, `.csv` enden, da diese als Ausgabeformat interpretiert werden können**
additionalData:
type: object
description: Benutzerdefiniertes Objekt. Wird unverändert gespeichert und in `GET /preorder` wieder ausgegeben
@@ -525,7 +536,24 @@ paths:
value: test
- key: another Key
value: more value
created:
type: string
format: date-time
description: Zeitpunkt der Anlage der Bestellung in ISO 8601 Format
example: "2023-02-01T00:00:00+01:00"
created_ts:
type: int
description: Zeitpunkt der Anlage der Bestellung in Sekunden seit der Unix Epoche
example: 1675206000
updated:
type: string
format: date-time
description: Zeitpunkt der letzen Bearbeitung der Bestellung in ISO 8601 Format
example: "2023-02-01T00:00:00+01:00"
updated_ts:
type: int
description: Zeitpunkt der letzten Bearbeitung der Bestellung in Sekunden seit der Unix Epoche
example: 1675206000
'400':
description: |
Bad Request
@@ -537,6 +565,66 @@ paths:
description: Vorbestellung für diese Wohneinheit bereits vorhanden
'404':
description: Adresse oder Wohneinheit nicht gefunden
/preorder/open:
get:
tags:
- preorder
summary:
Liste offener Vorbestellungen
description: Gibt Liste aller offener Vorbestellungen aus, Optional gefiltert nach Zeitpunkt der letzten Bearbeitung
parameters:
- name: ts
in: query
description: |
Optional: Timestamp. Wenn gesetzt, werden Nur Bestellungen zurückgeliefert, welche ab diesem Zeitpunkt geändert wurden.
Format: String in ISO 8601 Format oder Integer in Sekunden seit der Unix Epoche
required: false
schema:
oneOf:
- $ref: "#/components/schemas/timestampString"
- $ref: "#/components/schemas/timestampInt"
responses:
'200':
description: |
Successful operation
Mögliche Werte für Rückgabewert `status`:
| code | text | description |
|------|------|-------------|
| 10 | new | Neu |
| 110 | Underground construction planning | Tiefbau in Planung |
| 120 | Underground construction planning finished | Tiefbau Planung abgeschlossen |
| 130 | Underground construction work assigned | Bauauftrag zugeteilt |
| 140 | Conduit at property border | Rohr an Grundstücksgrenze |
| 200 | Conduit in building | Rohr im Gebäude |
| 210 | Fiber planning | Leitungsplan in Arbeit |
| 220 | Fiber planning finished | Leitungsplan abgeschlossen |
| 230 | Fiber installation work assigned | Bauauftrag zugeteilt |
| 235 | Fiber on property line | Faser an Grundstücksgrenze |
| 240 | Fiber in building | Faser im Gebäude |
| 245 | OTO intalled | Anschlussbox installiert |
| 250 | ONT ready | ONT vorbereitet |
| 260 | ONT picked up or shipped | ONT abgeholt oder versandt |
| 300 | ONT installed | ONT in Betrieb |
| 500 | Finished | Fertiggestellt |
| 899 | Cancelled | Storniert/Gekündigt |
content:
application/json:
schema:
type: object
properties:
status:
type: string
description: Status string
example: OK
result:
type: array
items:
$ref: '#/components/schemas/preorderStatusDetail'
'401':
description: Unauthorized
/preorder/{code}:
get:
tags:
@@ -547,7 +635,7 @@ paths:
parameters:
- name: code
in: path
description: code der Vorbestellung oder OAID der Wohneinheit
description: Automatisch generierter **code** der Vorbestellung, **OAID** der Wohneinheit oder providereigene ID (**extref**)
required: true
schema:
type: string
@@ -569,7 +657,9 @@ paths:
| 210 | Fiber planning | Leitungsplan in Arbeit |
| 220 | Fiber planning finished | Leitungsplan abgeschlossen |
| 230 | Fiber installation work assigned | Bauauftrag zugeteilt |
| 235 | Fiber on property line | Faser an Grundstücksgrenze |
| 240 | Fiber in building | Faser im Gebäude |
| 245 | OTO intalled | Anschlussbox installiert |
| 250 | ONT ready | ONT vorbereitet |
| 260 | ONT picked up or shipped | ONT abgeholt oder versandt |
| 300 | ONT installed | ONT in Betrieb |
@@ -599,7 +689,7 @@ paths:
parameters:
- name: code
in: path
description: code der Vorbestellung oder OAID der Wohneinheit
description: Automatisch generierter **code** der Vorbestellung, **OAID** der Wohneinheit oder providereigene ID (**extref**)
required: true
schema:
type: string
@@ -630,6 +720,13 @@ paths:
description: Bestellung nicht gefunden oder bereits storniert
components:
schemas:
timestampString:
type: string
format: date-time
description: ISO 8601 Timestamp
timestampInt:
type: int
description: Timestamp in seconds of the Unix Epoch
Zips:
type: array
items:
@@ -950,6 +1047,9 @@ components:
preorderRequest:
type: object
properties:
extref:
type: string
description: Providereigener Identifikationsstring. Wird unverändert gespeichert und kann statt `code` in `GET /preorder` und `DELETE /preorder` angegeben werden. **Darf nicht mit Dateiendung wie z.B. `.json`, `.csv` enden, da diese als Ausgabeformat interpretiert werden können**
preorderType:
type: string
enum: [interest, provision, order]
@@ -1203,6 +1303,9 @@ components:
type: string
description: Open Access ID der Wohneinheit
example: AT-9999-abcdef01.001
extref:
type: string
description: Providereigener Identifikationsstring. Wird unverändert gespeichert und kann statt `code` in `GET /preorder` und `DELETE /preorder` angegeben werden. **Darf nicht mit Dateiendung wie z.B. `.json`, `.csv` enden, da diese als Ausgabeformat interpretiert werden können**
status:
type: object
properties:
@@ -1305,7 +1408,24 @@ components:
value: test
- key: another Key
value: more value
created:
type: string
format: date-time
description: Zeitpunkt der Anlage der Bestellung in ISO 8601 Format
example: "2023-02-01T00:00:00+01:00"
created_ts:
type: int
description: Zeitpunkt der Anlage der Bestellung in Sekunden seit der Unix Epoche
example: 1675206000
updated:
type: string
format: date-time
description: Zeitpunkt der letzen Bearbeitung der Bestellung in ISO 8601 Format
example: "2023-02-01T00:00:00+01:00"
updated_ts:
type: int
description: Zeitpunkt der letzten Bearbeitung der Bestellung in Sekunden seit der Unix Epoche
example: 1675206000
securitySchemes:
api_key_header:
type: apiKey

View File

@@ -0,0 +1,288 @@
#!/usr/bin/php
<?php
//require 'vendor/autoload.php';
require("../../../config/config.php");
define('FRONKDB_SQLDEBUG',false);
error_reporting(E_ALL & ~(E_NOTICE | E_STRICT | E_DEPRECATED));
require_once(LIBDIR."/mvcfronk/mfRouter/mfRouter.php");
require_once(LIBDIR."/mvcfronk/mfBase/mfBaseModel.php");
require_once(LIBDIR."/mvcfronk/mfBase/mfBaseController.php");
$netzgebiet_name_main = "Liezen";
$freigabe_default = json_encode(["interest", "provision", "order", "reorder"]);
$me = new User(1);
$folder = __DIR__."/import/";
$csvname = "SDIBuilding__Locations__FTTx_premstaetten_2023-03-07.csv";
$filename = $folder.$csvname;
$db = FronkDB::singleton(ADDRESSDB_DBHOST, ADDRESSDB_DBUSER, ADDRESSDB_DBPASS, ADDRESSDB_DBNAME);
$log = mfLoghandler::singleton();
$input = fopen($filename, "r");
$h_extrefs = [];
$l = 0;
$u = 0;
while($csv = fgetcsv($input, 0, ";")) {
$l++;
if($l == 1) continue;
$hausnummer = false;
if(!trim($csv[0])) {
continue;
}
$hausnummer_extref = trim($csv[64]);
$adrcd_subcd = trim($csv[46]);
$netzgebiet_extref = trim($csv[54]);
$grund_nr = trim($csv[73]);
//gps_long, gps_lat
//$rollout_time = trim($csv[17]);
//$rollout_info = trim($csv[18]);
//$freigabe = trim($csv[19])
$unit_count = trim($csv[78]);
$gdaeigenschaft = trim($csv[66]);
$fcp_name = trim($csv[49]);
$execution_state = trim($csv[8]);
$btype = trim($csv[30]);
if(!$netzgebiet_extref) {
continue;
}
$netzgebiet = ADBNetzgebietModel::getFirst(["extref" => $netzgebiet_extref]);
if(!$netzgebiet) {
echo "netzgebiet not found\n";
exit;
}
if($execution_state == "Canceled") {
continue;
}
if($btype == "Greenfield") {
continue;
}
$adrcd = false;
if($adrcd_subcd) {
$adrparts = explode("-", $adrcd_subcd);
$adrcd = $adrparts[0];
}
$gem_name = trim($csv[59]);
$plz_string = trim($csv[88]);
$ort_name = trim($csv[31]);
$strasse_hausnummer = trim($csv[22]);
$strasse_name = "";
$hausnummer_name = "";
$m = [];
if(preg_match('/^(.+)\s+(\d+[a-z0-9\/&#._-]*)(.+)?/i', $strasse_hausnummer, $m)) {
$strasse_name = trim($m[1]);
$hausnummer_name = trim($m[2]);
if(array_key_exists(3, $m)) {
$addresszusatz = trim($m[3]);
}
}
/*
$adrcd = trim($csv[0]);
$gem_kz = trim($csv[2]);
$gem_name = trim($csv[3]);
$ort_kz = trim($csv[5]);
$plz_string = trim($csv[4]);
$ort_name = trim($csv[6]);
$skz = trim($csv[7]);
$strasse_name = trim($csv[8]);
$hausnummer_string = trim($csv[9]);
$hausnummer_extref = trim($csv[0]);
if(in_array($hausnummer_extref, $h_extrefs)) {
die("Hausnummer extref doppelt! $hausnummer_extref\n");
}
$h_extrefs[] = $hausnummer_extref;
*/
//$lat = str_replace(",",".",trim($csv[7]));
//$long = str_replace(",",".",trim($csv[8]));
if(!$adrcd) {
continue;
}
if(!is_numeric($adrcd)) {
echo "Invalid adrcd ($adrcd)\n";
continue;
}
if(!$hausnummer_extref) {
die("!!! Keine Hausnummer Extref\n");
}
if($hausnummer_extref == "25012262") {
$unit_count = 45;
}
if($hausnummer_extref == "25012676") {
continue;
}
if($hausnummer_extref == "25012153" || $hausnummer_extref == "25012155" || $hausnummer_extref == "25012157") {
continue;
}
if($hausnummer_extref == "25012159") {
$unit_count = 61;
}
if($hausnummer_extref == "25010649") {
continue;
}
if($hausnummer_extref == "25010723" || $hausnummer_extref == "25010816") {
continue;
}
$existing_hausnummer = ADBHausnummerModel::getFirst(["extref" => $hausnummer_extref]);
if(!$existing_hausnummer) {
$existing_hausnummer = ADBHausnummerModel::getFirst(["adrcd" => $adrcd]);
}
if(!$existing_hausnummer) {
//echo "$hausnummer_extref not found $strasse_name $hausnummer_name\n";
//continue;
// find hausnummer
//echo "$strasse_name $hausnummer_name\n";
if($strasse_name == "Toepferring") $strasse_name = "Töpferring";
if($strasse_name == "Foehrenweg") $strasse_name = "Föhrenweg";
$strasse_name = $db->escape($strasse_name);
$hausnummer_name = $db->escape($hausnummer_name);
$strasse_search = [$strasse_name];
if(strpos($strasse_name, ' ') !== false) $strasse_search[] = str_replace(' ', '-', $strasse_name);
if(strpos($strasse_name, '-') !== false) $strasse_search[] = str_replace('-', ' ', $strasse_name);
if(strpos($strasse_name, '.') !== false) $strasse_search[] = str_replace('.', '. ', $strasse_name);
if(strpos($strasse_name, '.') !== false) $strasse_search[] = str_replace('.', '.-', $strasse_name);
if(strpos($strasse_name, '. ') !== false) $strasse_search[] = str_replace('. ', '.', $strasse_name);
if(strpos($strasse_name, '. ') !== false) $strasse_search[] = str_replace('. ', '.-', $strasse_name);
if(strpos($strasse_name, '.') !== false) $strasse_search[] = str_replace('.-', '.', $strasse_name);
if(strpos($strasse_name, '.') !== false) $strasse_search[] = str_replace('.-', '. ', $strasse_name);
foreach($strasse_search as $search) {
if(strpos($search, 'ß') !== false) $strasse_search[] = str_replace('ß', 'ss', $search);
if(strpos($search, 'ä') !== false) $strasse_search[] = str_replace('ä', 'ae', $search);
if(strpos($search, 'ö') !== false) $strasse_search[] = str_replace('ö', 'oe', $search);
if(strpos($search, 'ü') !== false) $strasse_search[] = str_replace('ü', 'ue', $search);
if(strpos($search, 'ss') !== false) $strasse_search[] = str_replace('ss', 'ß', $search);
if(strpos($search, 'ae') !== false) $strasse_search[] = str_replace('ae', 'ä', $search);
if(strpos($search, 'oe') !== false) $strasse_search[] = str_replace('oe', 'ö', $search);
if(strpos($search, 'ue') !== false) $strasse_search[] = str_replace('ue', 'ü', $search);
}
$sql = "SELECT * FROM view_hausnummer WHERE gemeinde_id = 1 AND strasse IN ('". implode("', '", $strasse_search)."') AND hausnummer='$hausnummer_name'";
$res = $db->query($sql);
if($db->num_rows($res)) {
$data = $db->fetch_object($res);
$existing_hausnummer = new ADBHausnummer($data->hausnummer_id);
$existing_hausnummer->netzgebiet_id = $netzgebiet->id;
if(!$existing_hausnummer->adrcd) {
$existing_hausnummer->adrcd = $adrcd;
}
$existing_hausnummer->extref = $hausnummer_extref;
$existing_hausnummer->grund_nr = $grund_nr;
$existing_hausnummer->gdaeigenschaft = $gdaeigenschaft;
$existing_hausnummer->rimo_fcp_name = $fcp_name;
if(!$existing_hausnummer->oaid) {
$existing_hausnummer->oaid = $existing_hausnummer->getNewOAID();
}
$existing_hausnummer->save();
} else {
echo "Address not found (straße: $strasse_name, hausnummer: $hausnummer_name, adrcd: $adrcd, extref: $hausnummer_extref, unit_count: $unit_count)\n";
}
} else {
// found hausnummer
$existing_hausnummer->netzgebiet_id = $netzgebiet->id;
if(!$existing_hausnummer->adrcd) {
$existing_hausnummer->adrcd = $adrcd;
}
$existing_hausnummer->extref = $hausnummer_extref;
$existing_hausnummer->grund_nr = $grund_nr;
$existing_hausnummer->gdaeigenschaft = $gdaeigenschaft;
$existing_hausnummer->rimo_fcp_name = $fcp_name;
if(!$existing_hausnummer->oaid) {
$existing_hausnummer->oaid = $existing_hausnummer->getNewOAID();
}
$existing_hausnummer->save();
}
continue;
// add new units
$existing_units_count = ADBWohneinheitModel::count(['hausnummer_id' => $existing_hausnummer->id]);
if($existing_units_count != $unit_count) {
/*if(($existing_units_count - $unit_count) > 1) {
echo "========================================================================\n";
echo "=============== [".$existing_hausnummer->id."] Need to delete ".($existing_units_count - $unit_count)." units\n";
echo "========================================================================\n";
}*/
if($existing_units_count < $unit_count) {
echo "=============== Adding ".($unit_count - $existing_units_count)." units\n";
$new_units_count = $unit_count - $existing_units_count;
$last_unit_num = 0;
foreach(ADBWohneinheitModel::search(['hausnummer_id' => $existing_hausnummer->id]) as $tmp_unit) {
if($tmp_unit->num > $last_unit_num) {
$last_unit_num = $tmp_unit->num;
}
}
// create wohneinheiten
for($i = 1; $i <= $new_units_count; $i++) {
$num = $last_unit_num + $i;
//echo "$existing_units_count create wohneinheit $num\n";
$unit_data = [
'hausnummer_id' => $existing_hausnummer->id,
'num' => $num,
];
$wohneinheit = ADBWohneinheitModel::create($unit_data);
$wohneinheit_id = $wohneinheit->save();
if(!$wohneinheit_id) {
die("Cannot save Wohneinheit\n");
}
$wohneinheit->oaid = $wohneinheit->getNewOAID();
if(!$wohneinheit->oaid) {
die("Error generating OAID for wohneinheit ".$wohneinheit->id);
}
//var_dump($wohneinheit);
$wohneinheit->save();
$w++;
}
}
}
//echo "$hausnummer_extref: $adrcd, $netzgebiet_extref, $grund_nr, $unit_count, $gdaeigenschaft\n";
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,251 @@
#!/usr/bin/php
<?php
//require 'vendor/autoload.php';
require("../../../config/config.php");
define('FRONKDB_SQLDEBUG',false);
error_reporting(E_ALL & ~(E_NOTICE | E_STRICT | E_DEPRECATED));
require_once(LIBDIR."/mvcfronk/mfRouter/mfRouter.php");
require_once(LIBDIR."/mvcfronk/mfBase/mfBaseModel.php");
require_once(LIBDIR."/mvcfronk/mfBase/mfBaseController.php");
$freigabe_default = json_encode(["interest", "provision", "order", "reorder"]);
$me = new User(1);
$folder = __DIR__."/import/";
$csvname = "GWR_Lieboch_gesamt.csv";
$filename = $folder.$csvname;
$db = FronkDB::singleton(ADDRESSDB_DBHOST, ADDRESSDB_DBUSER, ADDRESSDB_DBPASS, ADDRESSDB_DBNAME);
$log = mfLoghandler::singleton();
$input = fopen($filename, "r");
$h_extrefs = [];
$gem_kz = "";
$gem_name = "";
$ort_kz = "";
$plz_name = "";
$ort_name = "";
$strasse_hausnummer = "";
$strasse_building = "";
$strasse_name = "";
$strasse = "";
$addresszusatz = "";
$adrcd = "";
$hausnummer_name = "";
$hausnummer_extref = "";
// netzgebiet Lieboch
$netzgebiet = new ADBNetzgebiet(30);
$l = 0;
$u = 0;
$i = 0;
while($csv = fgetcsv($input, 0, ",")) {
$i++;
if($i == 1) continue;
//var_dump($csv);exit;
if(trim($csv[0])) {
$gem_kz = trim($csv[0]);
$gem_name = trim($csv[1]);
$ort_kz = "14994";
$plz_name = "8501";
$ort_name = "Lieboch";
$strasse_hausnummer = trim($csv[4]);
//$strasse_name = trim($csv[13]);
$adrcd = trim($csv[8]);
$hausnummer_extref = trim($csv[12]);
//echo "strasse: $strasse\n";
//echo "strasse_building: $strasse_building\n";
$strasse_name = "";
$hausnummer_name = "";
$addresszusatz = "";
//echo $strasse_hausnummer."\n";
if(preg_match('/^(.+)\s+(\d+[a-z0-9\/&#._-]*)/i', $strasse_hausnummer, $m)) {
$strasse_name = trim($m[1]);
$hausnummer_name = trim($m[2]);
if(array_key_exists(3, $m)) {
$addresszusatz = trim($m[3]);
}
}
//echo "$strasse_name $hausnummer_name\n";
}
if(!$strasse_name || !$hausnummer_name) {
echo "no strasse_name ($strasse_name) or hausnummer_name ($hausnummer_name)\n";
continue;
}
$strasse_we = trim($csv[13]);
//$nutzung = trim($csv[8]);
$we_num = trim($csv[17]);
if(!$strasse_we) {
echo "Adresse Wohneinheit fehlt.\n";
continue;
}
//echo "strasse_we: $strasse_we\n";
if($strasse_hausnummer == $strasse_we) {
$addresszusatz = "";
} else {
$addresszusatz = preg_replace('/^'.$strasse_hausnummer.'\s+/', "", $strasse_we);
}
$hausnummer_zusatz = ADBWohneinheit::parseHausnummerZusatz($addresszusatz);
//var_dump($hausnummer_zusatz);
echo "Gemeinde: $gem_name | PLZ: $plz_name | Ort: $ort_name | Strasse: $strasse_name | Hausnummer: $hausnummer_name | Zusatz: ";
foreach($hausnummer_zusatz as $key => $value) {
if($value) {
if($key == "zusatz") {
echo $value;
continue;
}
echo ucfirst($key)." ".$value;
}
}
echo "\n";
//continue;
$gemeinde = ADBGemeindeModel::getFirst(['kennziffer' => $gem_kz]);
if(!$gemeinde) {
die("Gemeinde $gem_kz nicht gefunden\n");
/*$gemeinde = new ADBGemeinde();
$gemeinde->kennziffer = $gem_kz;
$gemeinde->code = $gem_kz;
$gemeinde->name = $gem_name;
$gemeinde_id = $gemeinde->save();
if(!$gemeinde_id) {
}*/
}
$ort = ADBOrtschaftModel::getFirst(['kennziffer' => $ort_kz]);
if(!$ort) {
die("Ortschaft $ort_kz nicht gefunden\n");
/*$ort = new ADBOrtschaft();
$ort->gemeinde_id = $gemeinde->id;
$ort->kennziffer = $ort_kz;
$ort->name = $ort_name;
$ort->plz = $plz_name;
$ort_id = $ort->save();
if(!$ort_id) {
die("Error creating Ortschaft $ort_kz $ort_name!\n");
}*/
}
$plz = ADBPlzModel::getFirst(['plz' => $plz_name]);
if(!$plz) {
die("PLZ $plz_name nicht gefunden\n");
/*$plz = new ADBPlz();
$plz->plz = $plz_name;
$plz->plzstring = $plz_name;
$plz_id = $plz->save();
if(!$plz) {
die("Error creating Plz $plz_name!\n");
}*/
}
//var_dump($plz);exit;
$strasse = ADBStrasseModel::getFirst(['gemeinde_id' => $gemeinde->id, 'name' => $strasse_name]);
if(!$strasse) {
die("Strasse $strasse_name nicht gefunden\n");
/*$strasse = new ADBStrasse();
$strasse->ortschaft_id = $ort->id;
$strasse->gemeinde_id = $gemeinde->id;
$strasse->name = $strasse_name;
$strasse_id = $strasse->save();
if(!$strasse_id) {
die("error creating Strasse $strasse_name (gemeinde ".$gemeinde->id.", ort ".$ort->id.")");
}*/
}
//var_dump($strasse);exit;
$hausnummer = ADBHausnummerModel::getFirst(['adrcd' => $adrcd]);
if(!$hausnummer) {
$hausnummer = ADBHausnummerModel::getFirst(['strasse_id' => $strasse->id, 'hausnummer' => $hausnummer_name]);
}
if(!$hausnummer) {
$hausnummer = new ADBHausnummer();
$hausnummer->adrcd = $adrcd;
$hausnummer->plz_id = $plz->id;
$hausnummer->strasse_id = $strasse->id;
$hausnummer->ortschaft_id = $ort->id;
$hausnummer->hausnummer = $hausnummer_name;
}
$hausnummer->netzgebiet_id = $netzgebiet->id;
$hausnummer->extref = $hausnummer_extref;
$hausnummer->freigabe = $freigabe_default;
$hausnummer_id = $hausnummer->save();
if(!$hausnummer_id) {
die("error creating Hausnummer $strasse_name $hausnummer_name\n");
}
$hausnummer->oaid = $hausnummer->getNewOAID();
if(!$hausnummer->save()) {
die("Cannot save oaid $strasse_name $hausnummer_name\n");
}
//var_dump($hausnummer);exit;
$we_search = [
'hausnummer_id' => $hausnummer->id,
'num' => $we_num,
'block' => $hausnummer_zusatz['block'],
'stiege' => $hausnummer_zusatz['stiege'],
'stock' => $hausnummer_zusatz['stock'],
'tuer' => $hausnummer_zusatz['tuer'],
'zusatz' => $hausnummer_zusatz['zusatz'],
];
$wohneinheit = ADBWohneinheitModel::getFirst($we_search);
if(!$wohneinheit) {
$wohneinheit = new ADBWohneinheit();
$wohneinheit->hausnummer_id = $hausnummer->id;
$wohneinheit->num = $we_num;
$wohneinheit->block = ($hausnummer_zusatz['block']) ? $hausnummer_zusatz['block'] : null;
$wohneinheit->stiege = ($hausnummer_zusatz['stiege']) ? $hausnummer_zusatz['stiege'] : null;
$wohneinheit->stock = ($hausnummer_zusatz['stock']) ? $hausnummer_zusatz['stock'] : null;
$wohneinheit->tuer = ($hausnummer_zusatz['tuer']) ? $hausnummer_zusatz['tuer'] : null;
$wohneinheit->zusatz = ($hausnummer_zusatz['zusatz']) ? $hausnummer_zusatz['zusatz'] : null;
//$wohneinheit->nutzung = $nutzung;
$wohneinheit_id = $wohneinheit->save();
if(!$wohneinheit_id) {
die("error creating Wohneinheit $strasse_name $hausnummer_name ".implode(", ", $hausnummer_zusatz));
}
$wohneinheit->oaid = $wohneinheit->getNewOAID();
if(!$wohneinheit->save()) {
die("cannot save oaid $strasse_name $hausnummer_name\n" . print_r($wohneinheit,true));
}
} else {
echo "XXXX wohneinheit gibts schon: $strasse_name $hausnummer_name ".implode(", ", $hausnummer_zusatz)."\n\n";
}
/*if($i > 10) {
exit;
}*/
}

View File

@@ -0,0 +1,329 @@
#!/usr/bin/php
<?php
//require 'vendor/autoload.php';
require("../../../config/config.php");
define('FRONKDB_SQLDEBUG',false);
error_reporting(E_ALL & ~(E_NOTICE | E_STRICT | E_DEPRECATED));
require_once(LIBDIR."/mvcfronk/mfRouter/mfRouter.php");
require_once(LIBDIR."/mvcfronk/mfBase/mfBaseModel.php");
require_once(LIBDIR."/mvcfronk/mfBase/mfBaseController.php");
$netzgebiet_name_main = "Liezen";
$freigabe_default = json_encode(["order", "reorder"]);
$me = new User(1);
$folder = __DIR__."/import/";
$csvname = "Adressendatensatz_Update-RMLI_2023-03-02.csv";
$filename = $folder.$csvname;
$db = FronkDB::singleton(ADDRESSDB_DBHOST, ADDRESSDB_DBUSER, ADDRESSDB_DBPASS, ADDRESSDB_DBNAME);
$log = mfLoghandler::singleton();
$input = fopen($filename, "r");
$h_extrefs = [];
$l = 0;
$u = 0;
while($csv = fgetcsv($input, 0, ",")) {
$l++;
if($l == 1) continue;
$hausnummer = false;
if(!trim($csv[0])) {
continue;
}
$hausnummer_id = trim($csv[0]);
$hausnummer_extref = trim($csv[1]);
$adrcd = trim($csv[2]);
$oaid = trim($csv[3]);
$netzgebiet_extref = trim($csv[4]);
$netzgebiet_name = trim($csv[5]);
$gkz = trim($csv[6]);
$gem_name = trim($csv[7]);
$okz = trim($csv[8]);
$ort_name = trim($csv[9]);
$plz_string = trim($csv[10]);
$skz = trim($csv[11]);
$strasse_name = trim($csv[12]);
$hausnummer_string = trim($csv[13]);
$grund_nr = trim($csv[14]);
//gps_long, gps_lat
$rollout_time = trim($csv[17]);
$rollout_info = trim($csv[18]);
//$freigabe = trim($csv[19])
$unit_count = trim($csv[20]);
$gdaeigenschaft = trim($csv[21]);
$meridian = trim($csv[22]);
$rw = trim($csv[23]);
$hw = trim($csv[24]);
/*
$adrcd = trim($csv[0]);
$gem_kz = trim($csv[2]);
$gem_name = trim($csv[3]);
$ort_kz = trim($csv[5]);
$plz_string = trim($csv[4]);
$ort_name = trim($csv[6]);
$skz = trim($csv[7]);
$strasse_name = trim($csv[8]);
$hausnummer_string = trim($csv[9]);
$hausnummer_extref = trim($csv[0]);
if(in_array($hausnummer_extref, $h_extrefs)) {
die("Hausnummer extref doppelt! $hausnummer_extref\n");
}
$h_extrefs[] = $hausnummer_extref;
*/
//$lat = str_replace(",",".",trim($csv[7]));
//$long = str_replace(",",".",trim($csv[8]));
if(!is_numeric($adrcd) || !is_numeric($hausnummer_id)) {
die("Invalid adrcd or hausnummer_id\n");
}
if(!strlen($hausnummer_string) || !strlen($strasse_name)) {
die("!! Hausnummer oder Strasse leer (adrcd $adrcd)\n");
}
if(!$gem_name || !$plz_string || !$ort_name || !$strasse_name) {
die("!! Konnte Adresse nicht parsen\n");
}
if(!$hausnummer_extref) {
die("!!! Keine Hausnummer Extref\n");
}
if(!$netzgebiet_extref) {
die("!!! Keine Netzgebiet Extref\n");
}
$existing_hausnummer = new ADBHausnummer($hausnummer_id);
if(!$existing_hausnummer->id) {
echo "$hausnummer_id not found\n";
continue;
}
//continue;
$updates = [];
if($existing_hausnummer->netzgebiet->extref != $netzgebiet_extref) {
echo "$hausnummer_id: netzgebiet '".$existing_hausnummer->netzgebiet->name."' => '$netzgebiet_name'\n";
$updates[] = "netzgebiet";
}
if($existing_hausnummer->strasse->name != $strasse_name) {
echo "$hausnummer_id: strasse '".$existing_hausnummer->strasse->name."' => '$strasse_name'\n";
$updates[] = "strasse";
}
if($existing_hausnummer->strasse->gemeinde->name != $gem_name) {
echo "$hausnummer_id: gemeinde '".$existing_hausnummer->strasse->gemeinde->name."' => '$gem_name'\n";
$updates[] = "gemeinde";
}
if($existing_hausnummer->hausnummer != $hausnummer_string) {
echo "$hausnummer_id: hausnummer '".$existing_hausnummer->hausnummer."' => '$hausnummer_string'\n";
$updates[] = "hausnummer";
}
if($existing_hausnummer->ortschaft->name != $ort_name) {
echo "$hausnummer_id: ortschaft '".$existing_hausnummer->ortschaft->name."' => '$ort_name'\n";
$updates[] = "ortschaft";
}
if($existing_hausnummer->plz->plz != $plz_string) {
echo "$hausnummer_id: plz '".$existing_hausnummer->plz->plz."' => '$plz_string'\n";
$updates[] = "plz";
}
if($existing_hausnummer->rollout != $rollout_time) {
echo "$hausnummer_id: rollout '".$existing_hausnummer->rollout."' => '$rollout_time'\n";
$updates[] = "rollout";
}
if($existing_hausnummer->rollout_info != $rollout_info) {
echo "$hausnummer_id: rollout_info '".$existing_hausnummer->rollout_info."' => '$rollout_info'\n";
$updates[] = "rollout_info";
}
if($existing_hausnummer->unit_count != $unit_count) {
echo "$hausnummer_id: unit_count '".$existing_hausnummer->unit_count."' => '$unit_count'\n";
$updates[] = "unit_count";
}
if($existing_hausnummer->gdaeigenschaft != $gdaeigenschaft) {
echo "$hausnummer_id: gdaeigenschaft '".$existing_hausnummer->gdaeigenschaft."' => '$gdaeigenschaft'\n";
$updates[] = "gdaeigenschaft";
}
if($existing_hausnummer->meridian != $meridian) {
echo "$hausnummer_id: meridian '".$existing_hausnummer->meridian."' => '$meridian'\n";
$updates[] = "meridian";
}
if($existing_hausnummer->rw != $rw) {
echo "$hausnummer_id: rw '".$existing_hausnummer->rw."' => '$rw'\n";
$updates[] = "rw";
}
if($existing_hausnummer->hw != $hw) {
echo "$hausnummer_id: hw '".$existing_hausnummer->hw."' => '$hw'\n";
$updates[] = "hw";
}
//continue;
if(!count($updates)) {
continue;
}
if(in_array("netzgebiet", $updates)) {
$netzgebiet = ADBNetzgebietModel::getFirst(['extref' => $netzgebiet_extref]);
if(!$netzgebiet) {
die("$hausnummer_id: Netzgebiet ($netzgebiet_extref: $netzgebiet_name) nicht gefunden\n");
}
$existing_hausnummer->netzgebiet_id = $netzgebiet->id;
echo "$hausnummer_id: Updating Netzgebiet to ".$netzgebiet->id."\n";
//$existing_hausnummer->save();
}
if(in_array("gdaeigenschaft", $updates)) {
$existing_hausnummer->gdaeigenschaft = $gdaeigenschaft;
}
if(in_array("meridian", $updates)) {
$existing_hausnummer->meridian = $meridian;
}
if(in_array("rw", $updates)) {
if(is_numeric($rw)) {
$existing_hausnummer->rw = $rw;
}
}
if(in_array("hw", $updates)) {
if(is_numeric($hw)) {
$existing_hausnummer->hw = $hw;
}
}
if(in_array("rollout", $updates) || in_array("rollout_info", $updates)) {
$new_rollout = false;
$new_rollout_info = false;
$freigabe = $freigabe_default;
if(is_numeric($rollout_time)) {
$new_rollout = $rollout_time;
$new_rollout_info = null;
$freigabe = $freigabe_default;
} elseif($rollout_time == "2024/2025") {
$new_rollout = null;
$new_rollout_info = "2024/2025";
$freigabe = json_encode(['reorder']);
} elseif($rollout_info == "2099") {
$new_rollout = null;
$new_rollout_info = "2099";
$freigabe = json_encode(['reorder']);
} else {
$new_rollout = null;
$new_rollout_info = "unscheduled";
$freigabe = json_encode([]);
}
$existing_hausnummer->rollout = $new_rollout;
$existing_hausnummer->rollout_info = $new_rollout_info;
$existing_hausnummer->freigabe = $freigabe;
echo "$hausnummer_id: updating rollout/info/freigabe to $new_rollout / $new_rollout_info / $freigabe\n";
//$existing_hausnummer->save();
}
$preorder = PreorderModel::getFirst(["adb_hausnummer_id" => $existing_hausnummer->id]);
if($preorder) {
echo "========================================================================\n";
echo "========================================================================\n";
echo "=============== [Hausnummer id: ".$existing_hausnummer->id."] Existing Preorder!! (".$preorder->id.")";
echo "========================================================================\n";
echo "========================================================================\n";
}
$existing_hausnummer->save();
$u++;
// update GemeindeNetzgebiet if needed
$netzgebiet = new ADBNetzgebiet($existing_hausnummer->netzgebiet_id);
$gemeinde = new ADBGemeinde($existing_hausnummer->strasse->gemeinde_id);
checkGemeindeNetzgebiet($gemeinde, $netzgebiet);
// add new units
$existing_units_count = ADBWohneinheitModel::count(['hausnummer_id' => $existing_hausnummer->id]);
if($existing_units_count != $unit_count) {
if($existing_units_count > $unit_count) {
echo "========================================================================\n";
echo "=============== [".$existing_hausnummer->id."] Need to delete ".($existing_units_count - $unit_count)." units\n";
echo "========================================================================\n";
}
if($existing_units_count < $unit_count) {
echo "=============== Adding ".($unit_count - $existing_units_count)." units\n";
$new_units_count = $unit_count - $existing_units_count;
$last_unit_num = 0;
foreach(ADBWohneinheitModel::search(['hausnummer_id' => $existing_hausnummer->id]) as $tmp_unit) {
if($tmp_unit->num > $last_unit_num) {
$last_unit_num = $tmp_unit->num;
}
}
// create wohneinheiten
for($i = 1; $i <= $new_units_count; $i++) {
$num = $last_unit_num + $i;
//echo "$existing_units_count create wohneinheit $num\n";
$unit_data = [
'hausnummer_id' => $existing_hausnummer->id,
'num' => $num,
];
$wohneinheit = ADBWohneinheitModel::create($unit_data);
$wohneinheit_id = $wohneinheit->save();
if(!$wohneinheit_id) {
die("Cannot save Wohneinheit\n");
}
$wohneinheit->oaid = $wohneinheit->getNewOAID();
if(!$wohneinheit->oaid) {
die("Error generating OAID for wohneinheit ".$wohneinheit->id);
}
var_dump($wohneinheit);
$wohneinheit->save();
$w++;
}
}
}
echo "=================================\n";
}
echo "$l lines processed, $u updated\n";
function checkGemeindeNetzgebiet($gemeinde, $netzgebiet) {
global $db;
$sql = "SELECT * FROM GemeindeNetzgebiet WHERE gemeinde_id=".$gemeinde->id." AND netzgebiet_id=".$netzgebiet->id;
$res = $db->query($sql);
if($db->num_rows($res)) {
return true;
}
$sql = "INSERT INTO GemeindeNetzgebiet (gemeinde_id, netzgebiet_id, `create`, `edit`) VALUES (".$gemeinde->id.", ".$netzgebiet->id.", UNIX_TIMESTAMP(), UNIX_TIMESTAMP())";
if(!$db->query($sql)) {
die("SQL Query failed: $sql\n ".$db->getLastError());
}
echo "updated GemeindeNetzgebiet\n";
return true;
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,26 @@
#!/usr/bin/php
<?php
//require 'vendor/autoload.php';
require("../../../config/config.php");
define('FRONKDB_SQLDEBUG',false);
error_reporting(E_ALL & ~(E_NOTICE | E_STRICT | E_DEPRECATED));
require_once(LIBDIR."/mvcfronk/mfRouter/mfRouter.php");
require_once(LIBDIR."/mvcfronk/mfBase/mfBaseModel.php");
require_once(LIBDIR."/mvcfronk/mfBase/mfBaseController.php");
$netzgebiet_name_main = "Liezen";
$freigabe_default = json_encode(["interest", "provision", "order", "reorder"]);
$me = new User(1);
$log = mfLoghandler::singleton();
$premstaetten_netzgebiete = [];
foreach(PreorderModel::search([]) as $preorder) {
}

View File

@@ -0,0 +1,288 @@
#!/usr/bin/php
<?php
//require 'vendor/autoload.php';
require("../../../config/config.php");
define('FRONKDB_SQLDEBUG',false);
error_reporting(E_ALL & ~(E_NOTICE | E_STRICT | E_DEPRECATED));
require_once(LIBDIR."/mvcfronk/mfRouter/mfRouter.php");
require_once(LIBDIR."/mvcfronk/mfBase/mfBaseModel.php");
require_once(LIBDIR."/mvcfronk/mfBase/mfBaseController.php");
$netzgebiet_name_main = "Liezen";
$freigabe_default = json_encode(["interest", "provision", "order", "reorder"]);
$me = new User(1);
$folder = __DIR__."/import/";
$csvname = "SDIBuilding__Locations__FTTx_premstaetten_2023-03-07.csv";
$filename = $folder.$csvname;
$db = FronkDB::singleton(ADDRESSDB_DBHOST, ADDRESSDB_DBUSER, ADDRESSDB_DBPASS, ADDRESSDB_DBNAME);
$log = mfLoghandler::singleton();
$input = fopen($filename, "r");
$h_extrefs = [];
$l = 0;
$u = 0;
while($csv = fgetcsv($input, 0, ";")) {
$l++;
if($l == 1) continue;
$hausnummer = false;
if(!trim($csv[0])) {
continue;
}
$hausnummer_extref = trim($csv[64]);
$adrcd_subcd = trim($csv[46]);
$netzgebiet_extref = trim($csv[54]);
$grund_nr = trim($csv[73]);
//gps_long, gps_lat
//$rollout_time = trim($csv[17]);
//$rollout_info = trim($csv[18]);
//$freigabe = trim($csv[19])
$unit_count = trim($csv[78]);
$gdaeigenschaft = trim($csv[66]);
$fcp_name = trim($csv[49]);
$execution_state = trim($csv[8]);
$btype = trim($csv[30]);
if(!$netzgebiet_extref) {
continue;
}
$netzgebiet = ADBNetzgebietModel::getFirst(["extref" => $netzgebiet_extref]);
if(!$netzgebiet) {
echo "netzgebiet not found\n";
exit;
}
if($execution_state == "Canceled") {
continue;
}
if($btype == "Greenfield") {
continue;
}
$adrcd = false;
if($adrcd_subcd) {
$adrparts = explode("-", $adrcd_subcd);
$adrcd = $adrparts[0];
}
$gem_name = trim($csv[59]);
$plz_string = trim($csv[88]);
$ort_name = trim($csv[31]);
$strasse_hausnummer = trim($csv[22]);
$strasse_name = "";
$hausnummer_name = "";
$m = [];
if(preg_match('/^(.+)\s+(\d+[a-z0-9\/&#._-]*)(.+)?/i', $strasse_hausnummer, $m)) {
$strasse_name = trim($m[1]);
$hausnummer_name = trim($m[2]);
if(array_key_exists(3, $m)) {
$addresszusatz = trim($m[3]);
}
}
/*
$adrcd = trim($csv[0]);
$gem_kz = trim($csv[2]);
$gem_name = trim($csv[3]);
$ort_kz = trim($csv[5]);
$plz_string = trim($csv[4]);
$ort_name = trim($csv[6]);
$skz = trim($csv[7]);
$strasse_name = trim($csv[8]);
$hausnummer_string = trim($csv[9]);
$hausnummer_extref = trim($csv[0]);
if(in_array($hausnummer_extref, $h_extrefs)) {
die("Hausnummer extref doppelt! $hausnummer_extref\n");
}
$h_extrefs[] = $hausnummer_extref;
*/
//$lat = str_replace(",",".",trim($csv[7]));
//$long = str_replace(",",".",trim($csv[8]));
if(!$adrcd) {
continue;
}
if(!is_numeric($adrcd)) {
echo "Invalid adrcd ($adrcd)\n";
continue;
}
if(!$hausnummer_extref) {
die("!!! Keine Hausnummer Extref\n");
}
if($hausnummer_extref == "25012262") {
$unit_count = 45;
}
if($hausnummer_extref == "25012676") {
continue;
}
if($hausnummer_extref == "25012153" || $hausnummer_extref == "25012155" || $hausnummer_extref == "25012157") {
continue;
}
if($hausnummer_extref == "25012159") {
$unit_count = 61;
}
if($hausnummer_extref == "25010649") {
continue;
}
if($hausnummer_extref == "25010723" || $hausnummer_extref == "25010816") {
continue;
}
$existing_hausnummer = ADBHausnummerModel::getFirst(["extref" => $hausnummer_extref]);
if(!$existing_hausnummer) {
$existing_hausnummer = ADBHausnummerModel::getFirst(["adrcd" => $adrcd]);
}
if(!$existing_hausnummer) {
//echo "$hausnummer_extref not found $strasse_name $hausnummer_name\n";
//continue;
// find hausnummer
//echo "$strasse_name $hausnummer_name\n";
if($strasse_name == "Toepferring") $strasse_name = "Töpferring";
if($strasse_name == "Foehrenweg") $strasse_name = "Föhrenweg";
$strasse_name = $db->escape($strasse_name);
$hausnummer_name = $db->escape($hausnummer_name);
$strasse_search = [$strasse_name];
if(strpos($strasse_name, ' ') !== false) $strasse_search[] = str_replace(' ', '-', $strasse_name);
if(strpos($strasse_name, '-') !== false) $strasse_search[] = str_replace('-', ' ', $strasse_name);
if(strpos($strasse_name, '.') !== false) $strasse_search[] = str_replace('.', '. ', $strasse_name);
if(strpos($strasse_name, '.') !== false) $strasse_search[] = str_replace('.', '.-', $strasse_name);
if(strpos($strasse_name, '. ') !== false) $strasse_search[] = str_replace('. ', '.', $strasse_name);
if(strpos($strasse_name, '. ') !== false) $strasse_search[] = str_replace('. ', '.-', $strasse_name);
if(strpos($strasse_name, '.') !== false) $strasse_search[] = str_replace('.-', '.', $strasse_name);
if(strpos($strasse_name, '.') !== false) $strasse_search[] = str_replace('.-', '. ', $strasse_name);
foreach($strasse_search as $search) {
if(strpos($search, 'ß') !== false) $strasse_search[] = str_replace('ß', 'ss', $search);
if(strpos($search, 'ä') !== false) $strasse_search[] = str_replace('ä', 'ae', $search);
if(strpos($search, 'ö') !== false) $strasse_search[] = str_replace('ö', 'oe', $search);
if(strpos($search, 'ü') !== false) $strasse_search[] = str_replace('ü', 'ue', $search);
if(strpos($search, 'ss') !== false) $strasse_search[] = str_replace('ss', 'ß', $search);
if(strpos($search, 'ae') !== false) $strasse_search[] = str_replace('ae', 'ä', $search);
if(strpos($search, 'oe') !== false) $strasse_search[] = str_replace('oe', 'ö', $search);
if(strpos($search, 'ue') !== false) $strasse_search[] = str_replace('ue', 'ü', $search);
}
$sql = "SELECT * FROM view_hausnummer WHERE gemeinde_id = 1 AND strasse IN ('". implode("', '", $strasse_search)."') AND hausnummer='$hausnummer_name'";
$res = $db->query($sql);
if($db->num_rows($res)) {
$data = $db->fetch_object($res);
$existing_hausnummer = new ADBHausnummer($data->hausnummer_id);
$existing_hausnummer->netzgebiet_id = $netzgebiet->id;
if(!$existing_hausnummer->adrcd) {
$existing_hausnummer->adrcd = $adrcd;
}
$existing_hausnummer->extref = $hausnummer_extref;
$existing_hausnummer->grund_nr = $grund_nr;
$existing_hausnummer->gdaeigenschaft = $gdaeigenschaft;
$existing_hausnummer->rimo_fcp_name = $fcp_name;
if(!$existing_hausnummer->oaid) {
$existing_hausnummer->oaid = $existing_hausnummer->getNewOAID();
}
$existing_hausnummer->save();
} else {
echo "Address not found (straße: $strasse_name, hausnummer: $hausnummer_name, adrcd: $adrcd, extref: $hausnummer_extref, unit_count: $unit_count)\n";
}
} else {
// found hausnummer
$existing_hausnummer->netzgebiet_id = $netzgebiet->id;
if(!$existing_hausnummer->adrcd) {
$existing_hausnummer->adrcd = $adrcd;
}
$existing_hausnummer->extref = $hausnummer_extref;
$existing_hausnummer->grund_nr = $grund_nr;
$existing_hausnummer->gdaeigenschaft = $gdaeigenschaft;
$existing_hausnummer->rimo_fcp_name = $fcp_name;
if(!$existing_hausnummer->oaid) {
$existing_hausnummer->oaid = $existing_hausnummer->getNewOAID();
}
$existing_hausnummer->save();
}
continue;
// add new units
$existing_units_count = ADBWohneinheitModel::count(['hausnummer_id' => $existing_hausnummer->id]);
if($existing_units_count != $unit_count) {
/*if(($existing_units_count - $unit_count) > 1) {
echo "========================================================================\n";
echo "=============== [".$existing_hausnummer->id."] Need to delete ".($existing_units_count - $unit_count)." units\n";
echo "========================================================================\n";
}*/
if($existing_units_count < $unit_count) {
echo "=============== Adding ".($unit_count - $existing_units_count)." units\n";
$new_units_count = $unit_count - $existing_units_count;
$last_unit_num = 0;
foreach(ADBWohneinheitModel::search(['hausnummer_id' => $existing_hausnummer->id]) as $tmp_unit) {
if($tmp_unit->num > $last_unit_num) {
$last_unit_num = $tmp_unit->num;
}
}
// create wohneinheiten
for($i = 1; $i <= $new_units_count; $i++) {
$num = $last_unit_num + $i;
//echo "$existing_units_count create wohneinheit $num\n";
$unit_data = [
'hausnummer_id' => $existing_hausnummer->id,
'num' => $num,
];
$wohneinheit = ADBWohneinheitModel::create($unit_data);
$wohneinheit_id = $wohneinheit->save();
if(!$wohneinheit_id) {
die("Cannot save Wohneinheit\n");
}
$wohneinheit->oaid = $wohneinheit->getNewOAID();
if(!$wohneinheit->oaid) {
die("Error generating OAID for wohneinheit ".$wohneinheit->id);
}
//var_dump($wohneinheit);
$wohneinheit->save();
$w++;
}
}
}
//echo "$hausnummer_extref: $adrcd, $netzgebiet_extref, $grund_nr, $unit_count, $gdaeigenschaft\n";
}

View File

@@ -1,2 +0,0 @@
*
!.gitignore

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

37
scripts/test.php Normal file
View File

@@ -0,0 +1,37 @@
#!/usr/bin/php
<?php
//require 'vendor/autoload.php';
require("../config/config.php");
define('FRONKDB_SQLDEBUG',false);
error_reporting(E_ALL & ~(E_NOTICE | E_STRICT | E_DEPRECATED));
require_once(LIBDIR."/mvcfronk/mfRouter/mfRouter.php");
require_once(LIBDIR."/mvcfronk/mfBase/mfBaseModel.php");
require_once(LIBDIR."/mvcfronk/mfBase/mfBaseController.php");
$me = new User(1);
define("INTERNAL_USER_ID", $me->id);
define("INTERNAL_USER_USERNAME", $me->username);
$contract = new Contract(22);
require_once(APPDIR."Contractconfig/hooks/Contractconfig_Hook.php");
require_once(APPDIR."Contractconfig/hooks/Voicenumberblock.php");
$hook = new Contractconfig_Hook_Voicenumberblock($contract);
if(!$hook->isResponsible()) {
echo "is responsible: no\n";
exit;
} else {
$hook->afterSave();
}
if($hook->errors) {
echo "Fehler beim speichern: \n";
foreach($hook->errors as $error) {
echo $error."\n";
}
exit;
}
echo "All done.\n";