new network model and mfBaseModelV2
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
<?php include(realpath(dirname(__FILE__) . "/../../$mfLayoutPackage") . "/header.php"); ?>
|
<?php include(realpath(dirname(__FILE__) . "/../../$mfLayoutPackage") . "/header.php"); ?>
|
||||||
<?php //var_dump($project);exit; ?>
|
<?php if (!isset($project)) $project = null; ?>
|
||||||
|
<?php $prefillAdbNetzgebietId = $_GET['adb_netzgebiet_id'] ?? null; ?>
|
||||||
<!-- start page title -->
|
<!-- start page title -->
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-12">
|
<div class="col-12">
|
||||||
@@ -27,7 +28,7 @@
|
|||||||
</h4>
|
</h4>
|
||||||
|
|
||||||
<form class="form-horizontal" method="post" action="<?= self::getUrl("ConstructionConsentProject", "save") ?>">
|
<form class="form-horizontal" method="post" action="<?= self::getUrl("ConstructionConsentProject", "save") ?>">
|
||||||
<input type="hidden" name="id" value="<?=isset($project) ? $project->id : ""?>"/>
|
<input type="hidden" name="id" value="<?=$project ? $project->id : ""?>"/>
|
||||||
|
|
||||||
<div class="card">
|
<div class="card">
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
@@ -36,21 +37,21 @@
|
|||||||
<div class="form-group row">
|
<div class="form-group row">
|
||||||
<label class="col-lg-2 col-form-label" for="name">Projektname *</label>
|
<label class="col-lg-2 col-form-label" for="name">Projektname *</label>
|
||||||
<div class="col-lg-10">
|
<div class="col-lg-10">
|
||||||
<input type="text" class="form-control" name="name" id="name" value="<?=$project->name?>" />
|
<input type="text" class="form-control" name="name" id="name" value="<?=$project ? $project->name : ""?>" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="form-group row">
|
<div class="form-group row">
|
||||||
<label class="col-lg-2 col-form-label" for="email">Emailadresse *</label>
|
<label class="col-lg-2 col-form-label" for="email">Emailadresse *</label>
|
||||||
<div class="col-lg-10">
|
<div class="col-lg-10">
|
||||||
<input type="text" class="form-control" name="email" id="email" value="<?=$project->email?>" />
|
<input type="text" class="form-control" name="email" id="email" value="<?=$project ? $project->email : ""?>" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="form-group row">
|
<div class="form-group row">
|
||||||
<label class="col-lg-2 col-form-label" for="phone">Telefonnummer *</label>
|
<label class="col-lg-2 col-form-label" for="phone">Telefonnummer *</label>
|
||||||
<div class="col-lg-10">
|
<div class="col-lg-10">
|
||||||
<input type="text" class="form-control" name="phone" id="phone" value="<?=$project->phone?>" />
|
<input type="text" class="form-control" name="phone" id="phone" value="<?=$project ? $project->phone : ""?>" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -58,8 +59,9 @@
|
|||||||
<label class="col-lg-2 col-form-label" for="adb_network_id">Netzgebiete *</label>
|
<label class="col-lg-2 col-form-label" for="adb_network_id">Netzgebiete *</label>
|
||||||
<div class="col-lg-10">
|
<div class="col-lg-10">
|
||||||
<select class="form-control select2" name="adb_netzgebiet_id[]" id="adb_netzgebiet_id" multiple="multiple">
|
<select class="form-control select2" name="adb_netzgebiet_id[]" id="adb_netzgebiet_id" multiple="multiple">
|
||||||
|
<?php $projectAdbNetworks = ($project && is_array($project->adb_networks)) ? $project->adb_networks : []; ?>
|
||||||
<?php foreach(ADBNetzgebietModel::getAll() as $net): ?>
|
<?php foreach(ADBNetzgebietModel::getAll() as $net): ?>
|
||||||
<option value="<?=$net->id?>" <?=(is_array($project->adb_networks) && array_key_exists($net->id, $project->adb_networks)) ? "selected='selected'" : ""?> ><?=$net->name?></option>
|
<option value="<?=$net->id?>" <?=(array_key_exists($net->id, $projectAdbNetworks) || $prefillAdbNetzgebietId == $net->id) ? "selected='selected'" : ""?> ><?=$net->name?></option>
|
||||||
<?php endforeach; ?>
|
<?php endforeach; ?>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
@@ -70,21 +72,21 @@
|
|||||||
<div class="form-group row">
|
<div class="form-group row">
|
||||||
<label class="col-lg-2 col-form-label" for="sender_name">Absendername *</label>
|
<label class="col-lg-2 col-form-label" for="sender_name">Absendername *</label>
|
||||||
<div class="col-lg-10">
|
<div class="col-lg-10">
|
||||||
<input type="text" class="form-control" name="sender_name" id="sender_name" value="<?=$project->sender_name?>" />
|
<input type="text" class="form-control" name="sender_name" id="sender_name" value="<?=$project ? $project->sender_name : ""?>" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="form-group row">
|
<div class="form-group row">
|
||||||
<label class="col-lg-2 col-form-label" for="sender_email">Absender Emailadresse *</label>
|
<label class="col-lg-2 col-form-label" for="sender_email">Absender Emailadresse *</label>
|
||||||
<div class="col-lg-10">
|
<div class="col-lg-10">
|
||||||
<input type="text" class="form-control" name="sender_email" id="sender_email" value="<?=$project->sender_email?>" />
|
<input type="text" class="form-control" name="sender_email" id="sender_email" value="<?=$project ? $project->sender_email : ""?>" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="form-group row">
|
<div class="form-group row">
|
||||||
<label class="col-lg-2 col-form-label" for="sender_reply_to">Antworten an (Reply To)</label>
|
<label class="col-lg-2 col-form-label" for="sender_reply_to">Antworten an (Reply To)</label>
|
||||||
<div class="col-lg-10">
|
<div class="col-lg-10">
|
||||||
<input type="text" class="form-control" name="sender_reply_to" id="sender_reply_toender_email" value="<?=$project->sender_reply_to?>" />
|
<input type="text" class="form-control" name="sender_reply_to" id="sender_reply_toender_email" value="<?=$project ? $project->sender_reply_to : ""?>" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -96,8 +98,9 @@
|
|||||||
<label class="col-lg-2 col-form-label" for="sender_reply_to">Berechtigte Firmen</label>
|
<label class="col-lg-2 col-form-label" for="sender_reply_to">Berechtigte Firmen</label>
|
||||||
<div class="col-lg-10">
|
<div class="col-lg-10">
|
||||||
<select class="form-control select2" name="address_id[]" id="adb_hausnummer_id" multiple="multiple">
|
<select class="form-control select2" name="address_id[]" id="adb_hausnummer_id" multiple="multiple">
|
||||||
|
<?php $projectAddresses = ($project && is_array($project->addresses)) ? $project->addresses : []; ?>
|
||||||
<?php foreach(AddressModel::search(["addresstype" => TT_NETWORK_ROLES_WITH_OWNER]) as $address): ?>
|
<?php foreach(AddressModel::search(["addresstype" => TT_NETWORK_ROLES_WITH_OWNER]) as $address): ?>
|
||||||
<option value="<?=$address->id?>" <?=(array_key_exists($address->id, $project->addresses)) ? "selected='selected'" : ""?>><?=$address->getCompanyOrName()?><?=($address->customer_number) ? " (".$address->customer_number.")" : ""?></option>
|
<option value="<?=$address->id?>" <?=(array_key_exists($address->id, $projectAddresses)) ? "selected='selected'" : ""?>><?=$address->getCompanyOrName()?><?=($address->customer_number) ? " (".$address->customer_number.")" : ""?></option>
|
||||||
<?php endforeach; ?>
|
<?php endforeach; ?>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
@@ -108,7 +111,7 @@
|
|||||||
<div class="form-group row">
|
<div class="form-group row">
|
||||||
<label class="col-lg-2 col-form-label" for="note">Interne Notiz</label>
|
<label class="col-lg-2 col-form-label" for="note">Interne Notiz</label>
|
||||||
<div class="col-lg-10">
|
<div class="col-lg-10">
|
||||||
<textarea id="note" class="form-control" name="note" rows="5"><?=$project->note?></textarea>
|
<textarea id="note" class="form-control" name="note" rows="5"><?=$project ? $project->note : ""?></textarea>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
<?php include(realpath(dirname(__FILE__)."/../../$mfLayoutPackage")."/header.php"); ?>
|
<?php include(realpath(dirname(__FILE__)."/../../$mfLayoutPackage")."/header.php"); ?>
|
||||||
|
<?php if (!isset($network)) $network = null; ?>
|
||||||
|
<?php $prefillAdbNetzgebietId = $_GET['adb_netzgebiet_id'] ?? null; ?>
|
||||||
|
|
||||||
<!-- start page title -->
|
<!-- start page title -->
|
||||||
<div class="row">
|
<div class="row">
|
||||||
@@ -8,7 +10,7 @@
|
|||||||
<ol class="breadcrumb m-0">
|
<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("Dashboard")?>"><?=MFAPPNAME_SLUG?></a></li>
|
||||||
<li class="breadcrumb-item"><a href="<?=self::getUrl("Network")?>">Netzgebiete</a></li>
|
<li class="breadcrumb-item"><a href="<?=self::getUrl("Network")?>">Netzgebiete</a></li>
|
||||||
<li class="breadcrumb-item active"><?=($network->id) ? "bearbeiten" : "Neu" ?></li>
|
<li class="breadcrumb-item active"><?=($network && $network->id) ? "bearbeiten" : "Neu" ?></li>
|
||||||
</ol>
|
</ol>
|
||||||
</div>
|
</div>
|
||||||
<h4 class="page-title">Netzgebiete</h4>
|
<h4 class="page-title">Netzgebiete</h4>
|
||||||
@@ -22,18 +24,18 @@
|
|||||||
|
|
||||||
<div class="card">
|
<div class="card">
|
||||||
<div class="card-body bg-">
|
<div class="card-body bg-">
|
||||||
<h4 class="header-title mb-2"><?=($network->id) ? "Netzbereich bearbeiten" : "Neuer Netzbereich"?></h4>
|
<h4 class="header-title mb-2"><?=($network && $network->id) ? "Netzbereich bearbeiten" : "Neuer Netzbereich"?></h4>
|
||||||
|
|
||||||
<form class="form-horizontal" method="post" action="<?=self::getUrl("Network", "save")?>">
|
<form class="form-horizontal" method="post" action="<?=self::getUrl("Network", "save")?>">
|
||||||
<div class="card">
|
<div class="card">
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
|
|
||||||
<input type="hidden" name="id" value="<?=$network->id?>" />
|
<input type="hidden" name="id" value="<?=$network ? $network->id : ""?>" />
|
||||||
|
|
||||||
<div class="form-group row">
|
<div class="form-group row">
|
||||||
<label class="col-lg-2 col-form-label" for="name">Name</label>
|
<label class="col-lg-2 col-form-label" for="name">Name</label>
|
||||||
<div class="col-lg-10">
|
<div class="col-lg-10">
|
||||||
<input type="text" class="form-control" name="name" id="name" value="<?=$network->name?>">
|
<input type="text" class="form-control" name="name" id="name" value="<?=$network ? $network->name : ""?>">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -43,7 +45,7 @@
|
|||||||
<select class="select2 form-control " name="owner_id" id="owner_id">
|
<select class="select2 form-control " name="owner_id" id="owner_id">
|
||||||
<option></option>
|
<option></option>
|
||||||
<?php foreach($owners as $owner): ?>
|
<?php foreach($owners as $owner): ?>
|
||||||
<option value="<?=$owner->id?>" <?=($network->owner_id == $owner->id) ? "selected='selected'" : ""?>><?=($owner->getCompanyOrName())?></option>
|
<option value="<?=$owner->id?>" <?=($network && $network->owner_id == $owner->id) ? "selected='selected'" : ""?>><?=($owner->getCompanyOrName())?></option>
|
||||||
<?php endforeach; ?>
|
<?php endforeach; ?>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
@@ -54,9 +56,9 @@
|
|||||||
<div class="col-lg-10">
|
<div class="col-lg-10">
|
||||||
<select class="form-control" name="sytemowner_action_status" id="sytemowner_action_status">
|
<select class="form-control" name="sytemowner_action_status" id="sytemowner_action_status">
|
||||||
<option></option>
|
<option></option>
|
||||||
<option value="pipework_needed" <?=($network->sytemowner_action_status == "pipework_needed") ? "selected='selected'" : ""?>>Tiefbau ausständig</option>
|
<option value="pipework_needed" <?=($network && $network->sytemowner_action_status == "pipework_needed") ? "selected='selected'" : ""?>>Tiefbau ausständig</option>
|
||||||
<option value="building_connected" <?=($network->sytemowner_action_status == "building_connected") ? "selected='selected'" : ""?>>Tiefbau erledigt</option>
|
<option value="building_connected" <?=($network && $network->sytemowner_action_status == "building_connected") ? "selected='selected'" : ""?>>Tiefbau erledigt</option>
|
||||||
<option value="term_connected" <?=($network->sytemowner_action_status == "term_connected") ? "selected='selected'" : ""?>>Anschluss passiv erschlossen</option>
|
<option value="term_connected" <?=($network && $network->sytemowner_action_status == "term_connected") ? "selected='selected'" : ""?>>Anschluss passiv erschlossen</option>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -69,7 +71,7 @@
|
|||||||
<select class="select2 form-control " name="adb_netzgebiet_id" id="adb_netzgebiet_id">
|
<select class="select2 form-control " name="adb_netzgebiet_id" id="adb_netzgebiet_id">
|
||||||
<option></option>
|
<option></option>
|
||||||
<?php foreach(ADBNetzgebietModel::getAll() as $adbn): ?>
|
<?php foreach(ADBNetzgebietModel::getAll() as $adbn): ?>
|
||||||
<option value="<?=$adbn->id?>" <?=($network->adb_netzgebiet_id == $adbn->id) ? "selected='selected'" : ""?>><?=$adbn->name?></option>
|
<option value="<?=$adbn->id?>" <?=(($network && $network->adb_netzgebiet_id == $adbn->id) || $prefillAdbNetzgebietId == $adbn->id) ? "selected='selected'" : ""?>><?=$adbn->name?></option>
|
||||||
<?php endforeach; ?>
|
<?php endforeach; ?>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
@@ -81,7 +83,7 @@
|
|||||||
<label class="col-lg-2 col-form-label" for="opsystem"></label>
|
<label class="col-lg-2 col-form-label" for="opsystem"></label>
|
||||||
<div class="col-lg-10">
|
<div class="col-lg-10">
|
||||||
<label class="form-check-label">
|
<label class="form-check-label">
|
||||||
<input type="checkbox" name="opsystem" class="form-check-input" value="snopp" id="opsystem" <?=($network->opsystem == "snopp") ? "checked='checked'" : ""?> />
|
<input type="checkbox" name="opsystem" class="form-check-input" value="snopp" id="opsystem" <?=($network && $network->opsystem == "snopp") ? "checked='checked'" : ""?> />
|
||||||
Für Betrieb in SNOPP freischalten
|
Für Betrieb in SNOPP freischalten
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
@@ -96,7 +98,7 @@
|
|||||||
<div class="form-group row">
|
<div class="form-group row">
|
||||||
<label class="col-lg-2 col-form-label" for="note">Interne Notiz</label>
|
<label class="col-lg-2 col-form-label" for="note">Interne Notiz</label>
|
||||||
<div class="col-lg-10">
|
<div class="col-lg-10">
|
||||||
<textarea id="note" class="form-control" name="note" rows="5"><?=$network->note?></textarea>
|
<textarea id="note" class="form-control" name="note" rows="5"><?=$network ? $network->note : ""?></textarea>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
<?php include(realpath(dirname(__FILE__) . "/../../$mfLayoutPackage") . "/header.php"); ?>
|
<?php include(realpath(dirname(__FILE__) . "/../../$mfLayoutPackage") . "/header.php"); ?>
|
||||||
|
<?php if (!isset($campaign)) $campaign = null; ?>
|
||||||
|
<?php $prefillNetworkId = $_GET['network_id'] ?? null; ?>
|
||||||
<!-- start page title -->
|
<!-- start page title -->
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-12">
|
<div class="col-12">
|
||||||
@@ -28,7 +30,7 @@
|
|||||||
|
|
||||||
<form class="form-horizontal" method="post"
|
<form class="form-horizontal" method="post"
|
||||||
action="<?= self::getUrl("Preordercampaign", "save") ?>">
|
action="<?= self::getUrl("Preordercampaign", "save") ?>">
|
||||||
<input type="hidden" name="id" value="<?= $campaign->id ?>"/>
|
<input type="hidden" name="id" value="<?= $campaign ? $campaign->id : "" ?>"/>
|
||||||
|
|
||||||
<div class="card">
|
<div class="card">
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
@@ -39,7 +41,7 @@
|
|||||||
<select class="select2 form-control " name="network_id" id="network_id">
|
<select class="select2 form-control " name="network_id" id="network_id">
|
||||||
<option></option>
|
<option></option>
|
||||||
<?php foreach ($networks as $network): ?>
|
<?php foreach ($networks as $network): ?>
|
||||||
<option value="<?= $network->id ?>" <?= ($campaign->network_id == $network->id) ? "selected='selected'" : "" ?>><?= ($network->name) ?></option>
|
<option value="<?= $network->id ?>" <?= (($campaign && $campaign->network_id == $network->id) || $prefillNetworkId == $network->id) ? "selected='selected'" : "" ?>><?= ($network->name) ?></option>
|
||||||
<?php endforeach; ?>
|
<?php endforeach; ?>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
@@ -49,7 +51,7 @@
|
|||||||
<label class="col-lg-2 col-form-label" for="name">Name *</label>
|
<label class="col-lg-2 col-form-label" for="name">Name *</label>
|
||||||
<div class="col-lg-10">
|
<div class="col-lg-10">
|
||||||
<input type="text" class="form-control" name="name" id="name"
|
<input type="text" class="form-control" name="name" id="name"
|
||||||
value="<?= $campaign->name ?>"/>
|
value="<?= $campaign ? $campaign->name : "" ?>"/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -57,7 +59,7 @@
|
|||||||
<label class="col-lg-2 col-form-label" for="description">Info</label>
|
<label class="col-lg-2 col-form-label" for="description">Info</label>
|
||||||
<div class="col-lg-10">
|
<div class="col-lg-10">
|
||||||
<textarea class="form-control" style="height:120px;"
|
<textarea class="form-control" style="height:120px;"
|
||||||
name="description"><?= $campaign->description ?></textarea>
|
name="description"><?= $campaign ? $campaign->description : "" ?></textarea>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -65,7 +67,7 @@
|
|||||||
<label class="col-lg-2 col-form-label" for="area">Gebiet *</label>
|
<label class="col-lg-2 col-form-label" for="area">Gebiet *</label>
|
||||||
<div class="col-lg-10">
|
<div class="col-lg-10">
|
||||||
<input type="text" class="form-control" name="area" id="area"
|
<input type="text" class="form-control" name="area" id="area"
|
||||||
value="<?= $campaign->area ?>"/>
|
value="<?= $campaign ? $campaign->area : "" ?>"/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -73,7 +75,7 @@
|
|||||||
<label class="col-lg-2 col-form-label" for="homes_total">Homes gesamt *</label>
|
<label class="col-lg-2 col-form-label" for="homes_total">Homes gesamt *</label>
|
||||||
<div class="col-lg-10">
|
<div class="col-lg-10">
|
||||||
<input type="text" class="form-control" name="homes_total" id="homes_total"
|
<input type="text" class="form-control" name="homes_total" id="homes_total"
|
||||||
value="<?= $campaign->homes_total ?>"/>
|
value="<?= $campaign ? $campaign->homes_total : "" ?>"/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -81,7 +83,7 @@
|
|||||||
<label class="col-lg-2 col-form-label" for="from">Von</label>
|
<label class="col-lg-2 col-form-label" for="from">Von</label>
|
||||||
<div class="col-lg-10">
|
<div class="col-lg-10">
|
||||||
<input type="text" class="form-control datepicker" name="from" id="from"
|
<input type="text" class="form-control datepicker" name="from" id="from"
|
||||||
value="<?= ($campaign->from) ? date('d.m.Y', $campaign->from) : "" ?>"/>
|
value="<?= ($campaign && $campaign->from) ? date('d.m.Y', $campaign->from) : "" ?>"/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -89,7 +91,7 @@
|
|||||||
<label class="col-lg-2 col-form-label" for="to">Bis</label>
|
<label class="col-lg-2 col-form-label" for="to">Bis</label>
|
||||||
<div class="col-lg-10">
|
<div class="col-lg-10">
|
||||||
<input type="text" class="form-control datepicker" name="to" id="to"
|
<input type="text" class="form-control datepicker" name="to" id="to"
|
||||||
value="<?= ($campaign->to) ? date('d.m.Y', $campaign->to) : "" ?>"/>
|
value="<?= ($campaign && $campaign->to) ? date('d.m.Y', $campaign->to) : "" ?>"/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -100,30 +102,31 @@
|
|||||||
<div class="col-lg-10">
|
<div class="col-lg-10">
|
||||||
<select class="form-control" name="product_type" id="product_type"
|
<select class="form-control" name="product_type" id="product_type"
|
||||||
data-placeholder="Bitte auswählen ...">
|
data-placeholder="Bitte auswählen ...">
|
||||||
<option value="all" <?= ($campaign->product_type == "all") ? "selected='selected'" : "" ?>>
|
<option value="all" <?= ($campaign && $campaign->product_type == "all") ? "selected='selected'" : "" ?>>
|
||||||
Alle Produkte im Netzgebiet
|
Alle Produkte im Netzgebiet
|
||||||
</option>
|
</option>
|
||||||
<option value="no_setup" <?= ($campaign->product_type == "no_setup") ? "selected='selected'" : "" ?>>
|
<option value="no_setup" <?= ($campaign && $campaign->product_type == "no_setup") ? "selected='selected'" : "" ?>>
|
||||||
Alle Produkte im Netzgebiet, ohne Herstellungsprodukt
|
Alle Produkte im Netzgebiet, ohne Herstellungsprodukt
|
||||||
</option>
|
</option>
|
||||||
<option value="setup_only" <?= ($campaign->product_type == "setup_only") ? "selected='selected'" : "" ?>>
|
<option value="setup_only" <?= ($campaign && $campaign->product_type == "setup_only") ? "selected='selected'" : "" ?>>
|
||||||
Nur Anschlussbestellung, keine Produkte
|
Nur Anschlussbestellung, keine Produkte
|
||||||
</option>
|
</option>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<?php $campaignTypes = ($campaign && is_array($campaign->types)) ? $campaign->types : []; ?>
|
||||||
<div class="form-group row">
|
<div class="form-group row">
|
||||||
<label class="col-lg-2 col-form-label" for="types">Erlaubte Vorbestellungstypen
|
<label class="col-lg-2 col-form-label" for="types">Erlaubte Vorbestellungstypen
|
||||||
*</label>
|
*</label>
|
||||||
<div class="col-lg-10">
|
<div class="col-lg-10">
|
||||||
<select class="select2 form-control select2-multiple" name="types[]" id="types"
|
<select class="select2 form-control select2-multiple" name="types[]" id="types"
|
||||||
multiple="multiple" data-placeholder="Bitte auswählen ...">
|
multiple="multiple" data-placeholder="Bitte auswählen ...">
|
||||||
<option value="interest" <?= (is_array($campaign->types) && array_key_exists("interest", $campaign->types)) ? "selected='selected'" : "" ?>><?= __("interest", "preorder") ?></option>
|
<option value="interest" <?= array_key_exists("interest", $campaignTypes) ? "selected='selected'" : "" ?>><?= __("interest", "preorder") ?></option>
|
||||||
<option value="provision" <?= (is_array($campaign->types) && array_key_exists("provision", $campaign->types)) ? "selected='selected'" : "" ?>><?= __("provision", "preorder") ?></option>
|
<option value="provision" <?= array_key_exists("provision", $campaignTypes) ? "selected='selected'" : "" ?>><?= __("provision", "preorder") ?></option>
|
||||||
<option value="order" <?= (is_array($campaign->types) && array_key_exists("order", $campaign->types)) ? "selected='selected'" : "" ?>><?= __("order", "preorder") ?></option>
|
<option value="order" <?= array_key_exists("order", $campaignTypes) ? "selected='selected'" : "" ?>><?= __("order", "preorder") ?></option>
|
||||||
<option value="reorder" <?= (is_array($campaign->types) && array_key_exists("reorder", $campaign->types)) ? "selected='selected'" : "" ?>><?= __("reorder", "preorder") ?></option>
|
<option value="reorder" <?= array_key_exists("reorder", $campaignTypes) ? "selected='selected'" : "" ?>><?= __("reorder", "preorder") ?></option>
|
||||||
<option value="legacytransfer" <?= (is_array($campaign->types) && array_key_exists("legacytransfer", $campaign->types)) ? "selected='selected'" : "" ?>><?= __("legacytransfer", "preorder") ?></option>
|
<option value="legacytransfer" <?= array_key_exists("legacytransfer", $campaignTypes) ? "selected='selected'" : "" ?>><?= __("legacytransfer", "preorder") ?></option>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -134,16 +137,16 @@
|
|||||||
<div class="col-lg-10">
|
<div class="col-lg-10">
|
||||||
<select class="form-control" name="fulfillment" id="fulfillment"
|
<select class="form-control" name="fulfillment" id="fulfillment"
|
||||||
data-placeholder="Bitte auswählen ...">
|
data-placeholder="Bitte auswählen ...">
|
||||||
<option value="thetool" <?= ($campaign->fulfillment == "thetool") ? "selected='selected'" : "" ?>>
|
<option value="thetool" <?= ($campaign && $campaign->fulfillment == "thetool") ? "selected='selected'" : "" ?>>
|
||||||
thetool
|
thetool
|
||||||
</option>
|
</option>
|
||||||
<option value="rimo" <?= ($campaign->fulfillment == "rimo") ? "selected='selected'" : "" ?>>
|
<option value="rimo" <?= ($campaign && $campaign->fulfillment == "rimo") ? "selected='selected'" : "" ?>>
|
||||||
RIMO
|
RIMO
|
||||||
</option>
|
</option>
|
||||||
<option value="citycom_oan" <?= ($campaign->fulfillment == "citycom_oan") ? "selected='selected'" : "" ?>>
|
<option value="citycom_oan" <?= ($campaign && $campaign->fulfillment == "citycom_oan") ? "selected='selected'" : "" ?>>
|
||||||
Citycom OAN
|
Citycom OAN
|
||||||
</option>
|
</option>
|
||||||
<option value="thirdparty" <?= ($campaign->fulfillment == "thirdparty") ? "selected='selected'" : "" ?>>
|
<option value="thirdparty" <?= ($campaign && $campaign->fulfillment == "thirdparty") ? "selected='selected'" : "" ?>>
|
||||||
Drittsystem
|
Drittsystem
|
||||||
</option>
|
</option>
|
||||||
</select>
|
</select>
|
||||||
@@ -155,13 +158,13 @@
|
|||||||
<div class="col-lg-10">
|
<div class="col-lg-10">
|
||||||
<select class="form-control" name="oaid_origin" id="oaid_origin"
|
<select class="form-control" name="oaid_origin" id="oaid_origin"
|
||||||
data-placeholder="Bitte auswählen ...">
|
data-placeholder="Bitte auswählen ...">
|
||||||
<option value="thetool" <?= ($campaign->oaid_origin == "thetool") ? "selected='selected'" : "" ?>>
|
<option value="thetool" <?= ($campaign && $campaign->oaid_origin == "thetool") ? "selected='selected'" : "" ?>>
|
||||||
thetool
|
thetool
|
||||||
</option>
|
</option>
|
||||||
<option value="ofaa" <?= ($campaign->oaid_origin == "ofaa") ? "selected='selected'" : "" ?>>
|
<option value="ofaa" <?= ($campaign && $campaign->oaid_origin == "ofaa") ? "selected='selected'" : "" ?>>
|
||||||
OFAA
|
OFAA
|
||||||
</option>
|
</option>
|
||||||
<option value="other" <?= ($campaign->oaid_origin == "other") ? "selected='selected'" : "" ?>>
|
<option value="other" <?= ($campaign && $campaign->oaid_origin == "other") ? "selected='selected'" : "" ?>>
|
||||||
Andere (importieren, aber nicht verarbeiten)
|
Andere (importieren, aber nicht verarbeiten)
|
||||||
</option>
|
</option>
|
||||||
</select>
|
</select>
|
||||||
@@ -171,6 +174,10 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<?php $campaignSalesclusters = ($campaign && is_array($campaign->salesclusters)) ? $campaign->salesclusters : []; ?>
|
||||||
|
<?php $campaignAllFcpNames = ($campaign && is_array($campaign->all_fcp_names)) ? $campaign->all_fcp_names : []; ?>
|
||||||
|
<?php $campaignBannedFcps = ($campaign && is_array($campaign->banned_fcps)) ? $campaign->banned_fcps : []; ?>
|
||||||
|
<?php $campaignRequiredFields = ($campaign && is_array($campaign->required_fields)) ? $campaign->required_fields : []; ?>
|
||||||
<div class="card">
|
<div class="card">
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
|
|
||||||
@@ -182,7 +189,7 @@
|
|||||||
name="adb_netzgebiet_ids[]" id="adb_netzgebiet_ids" multiple="multiple"
|
name="adb_netzgebiet_ids[]" id="adb_netzgebiet_ids" multiple="multiple"
|
||||||
data-placeholder="Salescluster ...">
|
data-placeholder="Salescluster ...">
|
||||||
<?php foreach (ADBNetzgebietModel::getAll() as $salescluster): ?>
|
<?php foreach (ADBNetzgebietModel::getAll() as $salescluster): ?>
|
||||||
<option value="<?= $salescluster->id ?>" <?= (is_array($campaign->salesclusters) && array_key_exists($salescluster->id, $campaign->salesclusters)) ? "selected='selected'" : "" ?>><?= $salescluster->name ?></option>
|
<option value="<?= $salescluster->id ?>" <?= array_key_exists($salescluster->id, $campaignSalesclusters) ? "selected='selected'" : "" ?>><?= $salescluster->name ?></option>
|
||||||
<?php endforeach; ?>
|
<?php endforeach; ?>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
@@ -195,8 +202,8 @@
|
|||||||
<select class="select2 form-control select2-multiple bg-danger"
|
<select class="select2 form-control select2-multiple bg-danger"
|
||||||
name="banned_rimo_fcp[]" id="banned_rimo_fcp" multiple="multiple"
|
name="banned_rimo_fcp[]" id="banned_rimo_fcp" multiple="multiple"
|
||||||
data-placeholder="FCPs ...">
|
data-placeholder="FCPs ...">
|
||||||
<?php foreach ($campaign->all_fcp_names as $fcp_name): ?>
|
<?php foreach ($campaignAllFcpNames as $fcp_name): ?>
|
||||||
<option value="<?= $fcp_name ?>" <?= (is_array($campaign->banned_fcps) && in_array($fcp_name, $campaign->banned_fcps)) ? "selected='selected'" : "" ?>><?= $fcp_name ?></option>
|
<option value="<?= $fcp_name ?>" <?= in_array($fcp_name, $campaignBannedFcps) ? "selected='selected'" : "" ?>><?= $fcp_name ?></option>
|
||||||
<?php endforeach; ?>
|
<?php endforeach; ?>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
@@ -208,7 +215,7 @@
|
|||||||
<div class="col-lg-10">
|
<div class="col-lg-10">
|
||||||
<select class="select2 form-control select2-multiple" name="required_fields[]"
|
<select class="select2 form-control select2-multiple" name="required_fields[]"
|
||||||
id="required_fields" multiple="multiple" data-placeholder="Felder ...">
|
id="required_fields" multiple="multiple" data-placeholder="Felder ...">
|
||||||
<option value="contact_type" <?= (is_array($campaign->required_fields) && in_array("contact_type", $campaign->required_fields)) ? "selected='selected'" : "" ?>>
|
<option value="contact_type" <?= in_array("contact_type", $campaignRequiredFields) ? "selected='selected'" : "" ?>>
|
||||||
Kontakttyp (Besitzer/Bewohner)
|
Kontakttyp (Besitzer/Bewohner)
|
||||||
</option>
|
</option>
|
||||||
</select>
|
</select>
|
||||||
@@ -221,10 +228,10 @@
|
|||||||
Ort:</label>
|
Ort:</label>
|
||||||
<div class="col-lg-10">
|
<div class="col-lg-10">
|
||||||
<select class="form-control" name="district_is_city" id="district_is_city">
|
<select class="form-control" name="district_is_city" id="district_is_city">
|
||||||
<option value="0" <?= (!$campaign->district_is_city) ? "selected='selected'" : "" ?>>
|
<option value="0" <?= (!$campaign || !$campaign->district_is_city) ? "selected='selected'" : "" ?>>
|
||||||
Nein
|
Nein
|
||||||
</option>
|
</option>
|
||||||
<option value="1" <?= ($campaign->district_is_city) ? "selected='selected'" : "" ?>>
|
<option value="1" <?= ($campaign && $campaign->district_is_city) ? "selected='selected'" : "" ?>>
|
||||||
Ja
|
Ja
|
||||||
</option>
|
</option>
|
||||||
</select>
|
</select>
|
||||||
@@ -238,10 +245,10 @@
|
|||||||
<div class="col-lg-10">
|
<div class="col-lg-10">
|
||||||
<select class="form-control" name="hausnummer_add_zusatz"
|
<select class="form-control" name="hausnummer_add_zusatz"
|
||||||
id="hausnummer_add_zusatz">
|
id="hausnummer_add_zusatz">
|
||||||
<option value="0" <?= (!$campaign->hausnummer_add_zusatz) ? "selected='selected'" : "" ?>>
|
<option value="0" <?= (!$campaign || !$campaign->hausnummer_add_zusatz) ? "selected='selected'" : "" ?>>
|
||||||
Nein
|
Nein
|
||||||
</option>
|
</option>
|
||||||
<option value="1" <?= ($campaign->hausnummer_add_zusatz) ? "selected='selected'" : "" ?>>
|
<option value="1" <?= ($campaign && $campaign->hausnummer_add_zusatz) ? "selected='selected'" : "" ?>>
|
||||||
Ja
|
Ja
|
||||||
</option>
|
</option>
|
||||||
</select>
|
</select>
|
||||||
@@ -253,10 +260,10 @@
|
|||||||
pro Wohneinheit (API):</label>
|
pro Wohneinheit (API):</label>
|
||||||
<div class="col-lg-10">
|
<div class="col-lg-10">
|
||||||
<select class="form-control" name="exist_is_error" id="exist_is_error">
|
<select class="form-control" name="exist_is_error" id="exist_is_error">
|
||||||
<option value="0" <?= (!$campaign->exist_is_error) ? "selected='selected'" : "" ?>>
|
<option value="0" <?= (!$campaign || !$campaign->exist_is_error) ? "selected='selected'" : "" ?>>
|
||||||
Mehr als eine
|
Mehr als eine
|
||||||
</option>
|
</option>
|
||||||
<option value="1" <?= ($campaign->exist_is_error) ? "selected='selected'" : "" ?>>
|
<option value="1" <?= ($campaign && $campaign->exist_is_error) ? "selected='selected'" : "" ?>>
|
||||||
Maximal eine
|
Maximal eine
|
||||||
</option>
|
</option>
|
||||||
</select>
|
</select>
|
||||||
@@ -270,7 +277,7 @@
|
|||||||
<label class="col-lg-2 col-form-label" for="cifurl">CIF Url</label>
|
<label class="col-lg-2 col-form-label" for="cifurl">CIF Url</label>
|
||||||
<div class="col-lg-10">
|
<div class="col-lg-10">
|
||||||
<input type="text" class="form-control" name="cifurl" id="cifurl"
|
<input type="text" class="form-control" name="cifurl" id="cifurl"
|
||||||
value="<?= $campaign->cifurl ?>"/>
|
value="<?= $campaign ? $campaign->cifurl : "" ?>"/>
|
||||||
<small>
|
<small>
|
||||||
Customer Installation Feedback (für QR-Code bei Status 145).<br/>
|
Customer Installation Feedback (für QR-Code bei Status 145).<br/>
|
||||||
Templatevariable <code>{{CIFTOKEN}}</code> wird mit echtem Cif Token ersetzt<br/>
|
Templatevariable <code>{{CIFTOKEN}}</code> wird mit echtem Cif Token ersetzt<br/>
|
||||||
@@ -284,7 +291,7 @@
|
|||||||
for="cifcableurl">Kabelnachbestell-Url</label>
|
for="cifcableurl">Kabelnachbestell-Url</label>
|
||||||
<div class="col-lg-10">
|
<div class="col-lg-10">
|
||||||
<input type="text" class="form-control" name="cifcableurl" id="cifcableurl"
|
<input type="text" class="form-control" name="cifcableurl" id="cifcableurl"
|
||||||
value="<?= $campaign->cifcableurl ?>"/>
|
value="<?= $campaign ? $campaign->cifcableurl : "" ?>"/>
|
||||||
<small>Für Begleitschreiben - Status 145</small>
|
<small>Für Begleitschreiben - Status 145</small>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -335,13 +342,15 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<?php $campaignActiveOperators = ($campaign && is_array($campaign->active_operators)) ? $campaign->active_operators : []; ?>
|
||||||
|
<?php $campaignPassiveOperators = ($campaign && is_array($campaign->passive_operators)) ? $campaign->passive_operators : []; ?>
|
||||||
<div class="card bg-light">
|
<div class="card bg-light">
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
<h4>Netzbetreiber</h4>
|
<h4>Netzbetreiber</h4>
|
||||||
<div class="card">
|
<div class="card">
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
<h4>Aktivnetzbetreiber</h4>
|
<h4>Aktivnetzbetreiber</h4>
|
||||||
<?php foreach ($campaign->active_operators as $aop): ?>
|
<?php foreach ($campaignActiveOperators as $aop): ?>
|
||||||
<div class="form-group row">
|
<div class="form-group row">
|
||||||
<label class="col-lg-2 col-form-label"
|
<label class="col-lg-2 col-form-label"
|
||||||
for="active_operators_<?= $aop->id ?>"></label>
|
for="active_operators_<?= $aop->id ?>"></label>
|
||||||
@@ -415,7 +424,7 @@
|
|||||||
id="passive_operators" multiple="multiple"
|
id="passive_operators" multiple="multiple"
|
||||||
data-placeholder="Netzbetreiber wählen ...">
|
data-placeholder="Netzbetreiber wählen ...">
|
||||||
<?php foreach (AddressModel::search(['addresstype' => ["netowner", "salespartner"]]) as $operator): ?>
|
<?php foreach (AddressModel::search(['addresstype' => ["netowner", "salespartner"]]) as $operator): ?>
|
||||||
<option value="<?= $operator->id ?>" <?= (is_array($campaign->passive_operators) && array_key_exists($operator->id, $campaign->passive_operators)) ? "selected='selected'" : "" ?>><?= $operator->getCompanyOrName() ?></option>
|
<option value="<?= $operator->id ?>" <?= array_key_exists($operator->id, $campaignPassiveOperators) ? "selected='selected'" : "" ?>><?= $operator->getCompanyOrName() ?></option>
|
||||||
<?php endforeach; ?>
|
<?php endforeach; ?>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
@@ -433,7 +442,7 @@
|
|||||||
<div class="form-group row">
|
<div class="form-group row">
|
||||||
<label class="col-lg-2 col-form-label" for="">Netzinhaber FIBU Kostenstelle</label>
|
<label class="col-lg-2 col-form-label" for="">Netzinhaber FIBU Kostenstelle</label>
|
||||||
<div class="col-lg-10">
|
<div class="col-lg-10">
|
||||||
<input type="text" class="form-control" name="netowner_fibu_cost_code" value="<?=$campaign->netowner_fibu_cost_code?>" />
|
<input type="text" class="form-control" name="netowner_fibu_cost_code" value="<?=$campaign ? $campaign->netowner_fibu_cost_code : ""?>" />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
@@ -611,8 +620,9 @@
|
|||||||
<select class="select2 form-control select2-multiple"
|
<select class="select2 form-control select2-multiple"
|
||||||
name="apiusers[]" id="apiusers" multiple="multiple"
|
name="apiusers[]" id="apiusers" multiple="multiple"
|
||||||
data-placeholder="Benutzer auswählen ...">
|
data-placeholder="Benutzer auswählen ...">
|
||||||
|
<?php $campaignApiUsers = ($campaign && is_array($campaign->apiusers)) ? $campaign->apiusers : []; ?>
|
||||||
<?php foreach (UserModel::search(['apikey' => true]) as $user): ?>
|
<?php foreach (UserModel::search(['apikey' => true]) as $user): ?>
|
||||||
<option value="<?= $user->id ?>" <?= (is_array($campaign->apiusers) && array_key_exists($user->id, $campaign->apiusers)) ? "selected='selected'" : "" ?>><?= $user->username ?>
|
<option value="<?= $user->id ?>" <?= array_key_exists($user->id, $campaignApiUsers) ? "selected='selected'" : "" ?>><?= $user->username ?>
|
||||||
(<?= $user->name ?>)
|
(<?= $user->name ?>)
|
||||||
</option>
|
</option>
|
||||||
<?php endforeach; ?>
|
<?php endforeach; ?>
|
||||||
@@ -626,7 +636,7 @@
|
|||||||
Hostnamen</label>
|
Hostnamen</label>
|
||||||
<div class="col-lg-10">
|
<div class="col-lg-10">
|
||||||
<textarea class="form-control"
|
<textarea class="form-control"
|
||||||
name="corsorigins"><?= ($campaign->corsorigins) ? implode("\n", $campaign->corsorigins) : "" ?></textarea>
|
name="corsorigins"><?= ($campaign && $campaign->corsorigins) ? implode("\n", $campaign->corsorigins) : "" ?></textarea>
|
||||||
<small>Hostname der Website, mit oder ohne Protokoll
|
<small>Hostname der Website, mit oder ohne Protokoll
|
||||||
(<em>https://</em>); *. als Wildcard erlaubt
|
(<em>https://</em>); *. als Wildcard erlaubt
|
||||||
(<em>*.domain.com</em>); ein Eintrag pro Zeile</small>
|
(<em>*.domain.com</em>); ein Eintrag pro Zeile</small>
|
||||||
@@ -642,7 +652,7 @@
|
|||||||
<label class="col-lg-2 col-form-label" for="note">Interne Notiz</label>
|
<label class="col-lg-2 col-form-label" for="note">Interne Notiz</label>
|
||||||
<div class="col-lg-10">
|
<div class="col-lg-10">
|
||||||
<textarea class="form-control" style="height:120px;" name="note"
|
<textarea class="form-control" style="height:120px;" name="note"
|
||||||
id="note"><?= $campaign->note ?></textarea>
|
id="note"><?= $campaign ? $campaign->note : "" ?></textarea>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -754,8 +764,8 @@
|
|||||||
<script>
|
<script>
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
// Initialize with existing data
|
// Initialize with existing data
|
||||||
let iframeOrigins = <?= $campaign->iframe_origins ?? '[]'; ?>;
|
let iframeOrigins = <?= ($campaign && $campaign->iframe_origins) ? $campaign->iframe_origins : '[]'; ?>;
|
||||||
let iframeConsents = <?= $campaign->iframe_consents ?? '{}'; ?>;
|
let iframeConsents = <?= ($campaign && $campaign->iframe_consents) ? $campaign->iframe_consents : '{}'; ?>;
|
||||||
|
|
||||||
console.log(iframeConsents);
|
console.log(iframeConsents);
|
||||||
|
|
||||||
|
|||||||
@@ -1,78 +1,124 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
class ADBNetzgebiet extends mfBaseModel {
|
require_once LIBDIR . '/mfBaseModelV2/mfBaseModelV2.php';
|
||||||
private $gemeinden;
|
|
||||||
private $json_options;
|
|
||||||
|
|
||||||
protected function init() {
|
class ADBNetzgebietRelations {
|
||||||
$this->db = FronkDB::singleton(ADDRESSDB_DBHOST, ADDRESSDB_DBUSER, ADDRESSDB_DBPASS, ADDRESSDB_DBNAME);
|
/** @var array{id: int, name: string}[] */
|
||||||
$this->table = "Netzgebiet";
|
public array $networks = [];
|
||||||
|
/** @var array{id: int, name: string}[] */
|
||||||
|
public array $campaigns = [];
|
||||||
|
/** @var array{id: int, name: string}[] */
|
||||||
|
public array $consentProjects = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function loadByExtref($extref) {
|
/**
|
||||||
$extref = $this->db->escape(trim($extref));
|
* @property-read ADBGemeinde[] $gemeinden
|
||||||
if(!$extref) {
|
* @property-read ADBNetzgebietRelations $relations
|
||||||
return false;
|
*/
|
||||||
}
|
class ADBNetzgebiet extends mfBaseModelV2 {
|
||||||
|
|
||||||
$res = $this->db->select("Netzgebiet", "*", "extref='$extref'");
|
protected static string $__tableName = 'Netzgebiet';
|
||||||
if(!$this->db->num_rows($res)) {
|
protected static string $__primaryKey = 'id';
|
||||||
return false;
|
|
||||||
}
|
|
||||||
$data = $this->db->fetch_object($res);
|
|
||||||
$this->load($data);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getOption($opt) {
|
protected static ?array $__databaseConfig = [
|
||||||
$options = $this->getOptions();
|
'host' => ADDRESSDB_DBHOST,
|
||||||
if(!$options) return null;
|
'user' => ADDRESSDB_DBUSER,
|
||||||
if(property_exists($options, $opt)) {
|
'pass' => ADDRESSDB_DBPASS,
|
||||||
return $options->$opt;
|
'name' => ADDRESSDB_DBNAME
|
||||||
}
|
];
|
||||||
return null;
|
|
||||||
|
|
||||||
}
|
protected static array $__journalFieldMap = [
|
||||||
|
'name' => 'Name', 'extref' => 'ExtRef', 'rimo_id' => 'RIMO ID',
|
||||||
|
'source' => 'Source', 'source_id' => 'Source ID', 'borderpoly' => 'Border Polygon',
|
||||||
|
'freigabe' => 'Freigaben', 'options' => 'Options', 'create' => 'Erstellt', 'edit' => 'Bearbeitet',
|
||||||
|
];
|
||||||
|
|
||||||
public function getOptions() {
|
public int $id;
|
||||||
if(!$this->options) {
|
public ?string $name = null;
|
||||||
return false;
|
public ?string $extref = null;
|
||||||
}
|
public ?string $rimo_id = null;
|
||||||
$opts = json_decode($this->options);
|
public ?string $source = null;
|
||||||
if(json_last_error() != JSON_ERROR_NONE) {
|
public ?string $source_id = null;
|
||||||
return null;
|
public ?string $borderpoly = null;
|
||||||
}
|
public ?string $freigabe = '["interest", "provision", "order", "reorder"]';
|
||||||
return $opts;
|
public ?string $options = '{"create_address_parts": 0, "update_freigabe": 1, "update_address": 1, "hausnummer_dont_overwrite_netzgebiet": 0, "create_preorder": 0, "preorder_only_oaid": 0, "wo_ignore_status": 0, "delete_units": 0, "mph_min_homes_tool_automatic_count": 3, "unit_create_oaid": 0}';
|
||||||
}
|
public int $create;
|
||||||
|
public int $edit;
|
||||||
|
|
||||||
public function getProperty($name) {
|
private ?array $__gemeinden = null;
|
||||||
if($this->$name == null) {
|
private ?ADBNetzgebietRelations $__relations = null;
|
||||||
|
|
||||||
if($name == "gemeinden") {
|
public function __get(string $name) {
|
||||||
$gemeinden = [];
|
if ($name === 'gemeinden') {
|
||||||
|
if ($this->__gemeinden === null) {
|
||||||
|
$this->__gemeinden = [];
|
||||||
foreach (ADBGemeindeNetzgebietModel::search(["netzgebiet_id" => $this->id]) as $gem_netz) {
|
foreach (ADBGemeindeNetzgebietModel::search(["netzgebiet_id" => $this->id]) as $gem_netz) {
|
||||||
$g = $gem_netz->gemeinde;
|
$g = $gem_netz->gemeinde;
|
||||||
if(!$g || array_key_exists($g->gemeinde_id, $gemeinden)) continue;
|
if (!$g || array_key_exists($g->id, $this->__gemeinden)) continue;
|
||||||
//var_dump($g);exit;
|
$this->__gemeinden[$g->id] = $g;
|
||||||
$gemeinden[$g->id] = $g;
|
|
||||||
}
|
}
|
||||||
if(count($gemeinden)) {
|
|
||||||
$this->gemeinden = $gemeinden;
|
|
||||||
}
|
}
|
||||||
return $this->gemeinden;
|
return $this->__gemeinden;
|
||||||
}
|
}
|
||||||
|
|
||||||
$classname = ucfirst($name);
|
if ($name === 'relations') {
|
||||||
$idfield = $name."_id";
|
return $this->__relations ??= $this->loadRelations();
|
||||||
$this->$name = new $classname($this->$idfield);
|
}
|
||||||
|
|
||||||
if($this->$name->id) {
|
|
||||||
return $this->$name;
|
|
||||||
} else {
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function loadByExtref(string $extref): bool {
|
||||||
|
$extref = trim($extref);
|
||||||
|
if (empty($extref)) return false;
|
||||||
|
|
||||||
|
$found = static::getFirst(['=extref' => $extref]);
|
||||||
|
if ($found) {
|
||||||
|
foreach (get_object_vars($found) as $key => $value) {
|
||||||
|
if (property_exists($this, $key) && !str_starts_with($key, '__')) {
|
||||||
|
$this->$key = $value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->$name;
|
public function getOption(string $opt): mixed {
|
||||||
|
$options = $this->getOptions();
|
||||||
|
return $options && property_exists($options, $opt) ? $options->$opt : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getOptions(): ?object {
|
||||||
|
if (empty($this->options)) return null;
|
||||||
|
$opts = json_decode($this->options);
|
||||||
|
return json_last_error() === JSON_ERROR_NONE ? $opts : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getFreigabe(): array {
|
||||||
|
if (empty($this->freigabe)) return [];
|
||||||
|
$freigabe = json_decode($this->freigabe, true);
|
||||||
|
return json_last_error() === JSON_ERROR_NONE ? $freigabe : [];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function loadRelations(): ADBNetzgebietRelations {
|
||||||
|
$rel = new ADBNetzgebietRelations();
|
||||||
|
|
||||||
|
$networks = NetworkModel::search(['adb_netzgebiet_id' => $this->id]);
|
||||||
|
foreach ($networks as $network) {
|
||||||
|
$rel->networks[] = ['id' => $network->id, 'name' => $network->name];
|
||||||
|
}
|
||||||
|
|
||||||
|
$networkIds = array_column($rel->networks, 'id');
|
||||||
|
if (!empty($networkIds)) {
|
||||||
|
$campaigns = PreordercampaignModel::search(['network_id' => $networkIds]);
|
||||||
|
foreach ($campaigns as $campaign) {
|
||||||
|
$rel->campaigns[] = ['id' => $campaign->id, 'name' => $campaign->name];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$rel->consentProjects = ConstructionConsentProject::getByAdbNetzgebietId($this->id);
|
||||||
|
|
||||||
|
return $rel;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
137
application/ADBNetzgebiet/ADBNetzgebietController.php
Normal file
137
application/ADBNetzgebiet/ADBNetzgebietController.php
Normal file
@@ -0,0 +1,137 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
class ADBNetzgebietController extends mfBaseController {
|
||||||
|
|
||||||
|
public User $me;
|
||||||
|
private array $postData = [];
|
||||||
|
|
||||||
|
protected function init(): void {
|
||||||
|
$this->needlogin = true;
|
||||||
|
$this->me = new User();
|
||||||
|
$this->me->loadMe();
|
||||||
|
$this->layout()->set("me", $this->me);
|
||||||
|
|
||||||
|
if (!$this->me->is("Admin")) {
|
||||||
|
$this->redirect("Dashboard");
|
||||||
|
}
|
||||||
|
|
||||||
|
$rawInput = file_get_contents('php://input');
|
||||||
|
if ($rawInput) $this->postData = json_decode($rawInput, true) ?? [];
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function indexAction(): void {
|
||||||
|
Helper::renderVue3($this, $this->mod, "Netzgebietverwaltung", [
|
||||||
|
"GET_URL" => $this::getUrl("ADBNetzgebiet/getNetzgebiete"),
|
||||||
|
"SAVE_URL" => $this::getUrl("ADBNetzgebiet/save"),
|
||||||
|
"HISTORY_URL" => $this::getUrl("ADBNetzgebiet/getHistory"),
|
||||||
|
"NETWORK_URL" => $this::getUrl("Network/Index"),
|
||||||
|
"NETWORK_CREATE_URL" => $this::getUrl("Network/add"),
|
||||||
|
"CAMPAIGN_URL" => $this::getUrl("Preordercampaign/edit"),
|
||||||
|
"CAMPAIGN_CREATE_URL" => $this::getUrl("Preordercampaign/add"),
|
||||||
|
"CONSENT_URL" => $this::getUrl("ConstructionConsentProject/edit"),
|
||||||
|
"CONSENT_CREATE_URL" => $this::getUrl("ConstructionConsentProject/add"),
|
||||||
|
"HIDE_PAGE_TITLE" => true,
|
||||||
|
"USER_ID" => $this->me->id,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function getNetzgebieteAction(): void {
|
||||||
|
$filter = [];
|
||||||
|
if (!empty($_GET['name'])) $filter['name'] = $_GET['name'];
|
||||||
|
if (!empty($_GET['extref'])) $filter['extref'] = $_GET['extref'];
|
||||||
|
if (!empty($_GET['source'])) $filter['=source'] = $_GET['source'];
|
||||||
|
if (!empty($_GET['source_id'])) $filter['source_id'] = $_GET['source_id'];
|
||||||
|
|
||||||
|
$allNetzgebiete = ADBNetzgebiet::getAll($filter, null, 0, ['column' => 'name', 'dir' => 'ASC']);
|
||||||
|
|
||||||
|
$response = [];
|
||||||
|
foreach ($allNetzgebiete as $netzgebiet) {
|
||||||
|
$response[] = [
|
||||||
|
'netzgebiet' => $netzgebiet->toArray(),
|
||||||
|
'related' => [
|
||||||
|
'networks' => $netzgebiet->relations->networks,
|
||||||
|
'campaigns' => $netzgebiet->relations->campaigns,
|
||||||
|
'consent_projects' => $netzgebiet->relations->consentProjects
|
||||||
|
]
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
self::returnJson(['success' => true, 'data' => $response, 'total' => count($response)]);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function saveAction(): void {
|
||||||
|
$data = $this->postData;
|
||||||
|
if (empty($data)) { self::sendError("No data received."); return; }
|
||||||
|
|
||||||
|
$isNew = empty($data['id']);
|
||||||
|
$model = $isNew ? new ADBNetzgebiet() : ADBNetzgebiet::get($data['id']);
|
||||||
|
if (!$model) { self::sendError("Netzgebiet not found."); return; }
|
||||||
|
|
||||||
|
if (isset($data['name'])) $model->name = trim($data['name']) ?: null;
|
||||||
|
if (array_key_exists('extref', $data)) $model->extref = trim($data['extref']) ?: null;
|
||||||
|
if (array_key_exists('rimo_id', $data)) $model->rimo_id = trim($data['rimo_id']) ?: null;
|
||||||
|
if (isset($data['source'])) $model->source = $data['source'] ?: null;
|
||||||
|
if (array_key_exists('source_id', $data)) $model->source_id = trim($data['source_id']) ?: null;
|
||||||
|
if (array_key_exists('borderpoly', $data)) $model->borderpoly = $data['borderpoly'] ?: null;
|
||||||
|
|
||||||
|
if (isset($data['freigabe'])) {
|
||||||
|
$model->freigabe = is_array($data['freigabe'])
|
||||||
|
? json_encode(array_values($data['freigabe']))
|
||||||
|
: $data['freigabe'];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($data['options'])) {
|
||||||
|
if (is_array($data['options'])) {
|
||||||
|
$options = $data['options'];
|
||||||
|
if (isset($options['mph_min_homes_tool_automatic_count'])) {
|
||||||
|
$options['mph_min_homes_tool_automatic_count'] = (int)$options['mph_min_homes_tool_automatic_count'];
|
||||||
|
}
|
||||||
|
$boolFields = ['create_address_parts', 'update_freigabe', 'update_address',
|
||||||
|
'hausnummer_dont_overwrite_netzgebiet', 'create_preorder', 'preorder_only_oaid',
|
||||||
|
'wo_ignore_status', 'delete_units', 'unit_create_oaid'];
|
||||||
|
foreach ($boolFields as $field) {
|
||||||
|
if (isset($options[$field])) $options[$field] = $options[$field] ? 1 : 0;
|
||||||
|
}
|
||||||
|
$model->options = json_encode($options);
|
||||||
|
} else {
|
||||||
|
$model->options = $data['options'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!$model->save()) { self::sendError("Failed to save Netzgebiet."); return; }
|
||||||
|
|
||||||
|
self::returnJson([
|
||||||
|
'success' => true,
|
||||||
|
'message' => $isNew ? 'Netzgebiet created.' : 'Netzgebiet saved.',
|
||||||
|
'id' => $model->getId()
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function getHistoryAction(): void {
|
||||||
|
$id = $_GET['id'] ?? $this->postData['id'] ?? null;
|
||||||
|
if (empty($id)) { self::sendError("ID required."); return; }
|
||||||
|
|
||||||
|
$model = ADBNetzgebiet::get($id);
|
||||||
|
if (!$model) { self::sendError("Netzgebiet not found."); return; }
|
||||||
|
|
||||||
|
$history = $model->getJournalHistory();
|
||||||
|
$userIds = array_unique(array_filter(array_column($history, 'user_id')));
|
||||||
|
$users = [];
|
||||||
|
|
||||||
|
foreach ($userIds as $userId) {
|
||||||
|
$user = new User($userId);
|
||||||
|
if ($user->id) $users[$user->id] = $user->name ?? 'User #' . $user->id;
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($history as $entry) {
|
||||||
|
$entry->user_name = $users[$entry->user_id] ?? 'System';
|
||||||
|
}
|
||||||
|
|
||||||
|
self::returnJson(['success' => true, 'data' => $history]);
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: Implement RIMO API check
|
||||||
|
protected function checkRimoSourceIdAction(): void {
|
||||||
|
self::returnJson(['success' => false, 'message' => "RIMO API check not available."]);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,188 +1,4 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
class ADBNetzgebietModel {
|
/** @deprecated Use ADBNetzgebiet directly */
|
||||||
public $name;
|
class ADBNetzgebietModel extends ADBNetzgebiet {}
|
||||||
public $extref;
|
|
||||||
public $source;
|
|
||||||
public $source_id;
|
|
||||||
public $rimo_id;
|
|
||||||
public $freigabe;
|
|
||||||
|
|
||||||
public $create = null;
|
|
||||||
public $edit = null;
|
|
||||||
|
|
||||||
public static function create(Array $data) {
|
|
||||||
$model = new ADBNetzgebiet();
|
|
||||||
|
|
||||||
foreach($data as $field => $value) {
|
|
||||||
if(property_exists(get_called_class(), $field)) {
|
|
||||||
$model ->$field = $value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$me = mfValuecache::singleton()->get("me");
|
|
||||||
if(!$me) {
|
|
||||||
$me = new User();
|
|
||||||
$me->loadMe();
|
|
||||||
mfValuecache::singleton()->set("me", $me);
|
|
||||||
}
|
|
||||||
/*
|
|
||||||
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 getFirst($filter) {
|
|
||||||
$db = FronkDB::singleton(ADDRESSDB_DBHOST, ADDRESSDB_DBUSER, ADDRESSDB_DBPASS, ADDRESSDB_DBNAME);
|
|
||||||
|
|
||||||
$where = self::getSqlFilter($filter);
|
|
||||||
$res = $db->select("Netzgebiet", "*", "$where ORDER BY name LIMIT 1");
|
|
||||||
if($db->num_rows($res)) {
|
|
||||||
$data = $db->fetch_object($res);
|
|
||||||
$item = new ADBNetzgebiet($data);
|
|
||||||
if($item->id) {
|
|
||||||
return $item;
|
|
||||||
} else {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function getAll($indexed_by_id = false) {
|
|
||||||
$items = [];
|
|
||||||
|
|
||||||
$db = FronkDB::singleton(ADDRESSDB_DBHOST, ADDRESSDB_DBUSER, ADDRESSDB_DBPASS, ADDRESSDB_DBNAME);
|
|
||||||
|
|
||||||
$res = $db->select("Netzgebiet", "*", "1=1 ORDER BY name");
|
|
||||||
if($db->num_rows($res)) {
|
|
||||||
while($data = $db->fetch_object($res)) {
|
|
||||||
if($indexed_by_id) {
|
|
||||||
$items[$data->id] = new ADBNetzgebiet($data);
|
|
||||||
} else {
|
|
||||||
$items[] = new ADBNetzgebiet($data);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return $items;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public static function count($filter) {
|
|
||||||
$db = FronkDB::singleton(ADDRESSDB_DBHOST, ADDRESSDB_DBUSER, ADDRESSDB_DBPASS, ADDRESSDB_DBNAME);
|
|
||||||
|
|
||||||
$where = self::getSqlFilter($filter);
|
|
||||||
$sql = "SELECT COUNT(*) as cnt FROM Netzgebiet
|
|
||||||
WHERE $where
|
|
||||||
";
|
|
||||||
|
|
||||||
$res = $db->query($sql);
|
|
||||||
if($db->num_rows($res)) {
|
|
||||||
$data = $db->fetch_object($res);
|
|
||||||
return $data->cnt;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function search($filter, $limit = false) {
|
|
||||||
$items = [];
|
|
||||||
$db = FronkDB::singleton(ADDRESSDB_DBHOST, ADDRESSDB_DBUSER, ADDRESSDB_DBPASS, ADDRESSDB_DBNAME);
|
|
||||||
|
|
||||||
$where = self::getSqlFilter($filter);
|
|
||||||
$sql = "SELECT Netzgebiet.* FROM Netzgebiet
|
|
||||||
WHERE $where
|
|
||||||
ORDER BY name";
|
|
||||||
|
|
||||||
mfLoghandler::singleton()->debug($sql);
|
|
||||||
if(is_array($limit) && count($limit)) {
|
|
||||||
if(is_numeric($limit['start']) && is_numeric($limit['count'])) {
|
|
||||||
$sql .= " LIMIT ".$limit['start'].", ".$limit['count'];
|
|
||||||
} elseif(is_numeric($limit['count'])) {
|
|
||||||
$sql .= " LIMIT ".$limit['count'];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$res = $db->query($sql);
|
|
||||||
if($db->num_rows($res)) {
|
|
||||||
while($data = $db->fetch_object($res)) {
|
|
||||||
$items[] = new ADBNetzgebiet($data);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return $items;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static function getSqlFilter($filter) {
|
|
||||||
$where = "1=1 ";
|
|
||||||
|
|
||||||
if(array_key_exists("netzgebiet_id", $filter)) {
|
|
||||||
$netzgebiet_id = $filter['netzgebiet_id'];
|
|
||||||
if(is_numeric($netzgebiet_id)) {
|
|
||||||
$where .= " AND Netzgebiet.id=$netzgebiet_id";
|
|
||||||
} elseif(is_array($netzgebiet_id) && count($netzgebiet_id)) {
|
|
||||||
$where .= " AND Netzgebiet.id IN (". implode(",", $netzgebiet_id).")";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(array_key_exists("name", $filter)) {
|
|
||||||
$name = FronkDB::singleton()->escape($filter['name']);
|
|
||||||
if($name) {
|
|
||||||
$where .= " AND Netzgebiet.`name` = '$name'";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(array_key_exists("name%", $filter)) {
|
|
||||||
$name = FronkDB::singleton()->escape($filter['name%']);
|
|
||||||
if($name) {
|
|
||||||
$where .= " AND Netzgebiet.`name` LIKE '$name%'";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(array_key_exists("extref", $filter)) {
|
|
||||||
$extref = FronkDB::singleton()->escape($filter['extref']);
|
|
||||||
if($extref) {
|
|
||||||
$where .= " AND Netzgebiet.`extref` = '$extref'";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(array_key_exists("rimo_id", $filter)) {
|
|
||||||
$rimo_id = FronkDB::singleton()->escape($filter['rimo_id']);
|
|
||||||
if($rimo_id) {
|
|
||||||
$where .= " AND Netzgebiet.`rimo_id` LIKE '%$rimo_id%'";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(array_key_exists("source_id", $filter)) {
|
|
||||||
$source_id = FronkDB::singleton()->escape($filter['source_id']);
|
|
||||||
if($source_id) {
|
|
||||||
$where .= " AND Netzgebiet.`source_id` LIKE '%$source_id%'";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(array_key_exists("source", $filter)) {
|
|
||||||
$source = FronkDB::singleton()->escape($filter['source']);
|
|
||||||
if($source) {
|
|
||||||
$where .= " AND Netzgebiet.`source` = '$source'";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(array_key_exists("borderpoly", $filter)) {
|
|
||||||
$borderpoly = $filter['borderpoly'];
|
|
||||||
if($borderpoly === true) {
|
|
||||||
$where .= " AND Netzgebiet.`borderpoly` IS NOT NULL";
|
|
||||||
} elseif($borderpoly === false || $borderpoly === null) {
|
|
||||||
$where .= " AND (Netzgebiet.`borderpoly` IS NULL OR Netzgebiet.`borderpoly` = '')";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//var_dump($filter, $where);exit;
|
|
||||||
return $where;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -238,6 +238,20 @@ class ConstructionConsentProject extends mfBaseModel {
|
|||||||
return $where;
|
return $where;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array{id: int, name: string}[]
|
||||||
|
*/
|
||||||
|
public static function getByAdbNetzgebietId(int $adbNetzgebietId): array {
|
||||||
|
$db = FronkDB::singleton();
|
||||||
|
$id = $db->escape($adbNetzgebietId);
|
||||||
|
$res = $db->query(
|
||||||
|
"SELECT ccp.id, ccp.name FROM `ConstructionConsentProject` ccp
|
||||||
|
JOIN `ConstructionConsentNetwork` ccn ON ccp.id = ccn.constructionconsentproject_id
|
||||||
|
WHERE ccn.adb_netzgebiet_id = '{$id}'"
|
||||||
|
);
|
||||||
|
return $db->fetch_all_assoc($res) ?? [];
|
||||||
|
}
|
||||||
|
|
||||||
public static function hasFaultyOwnerEntries(int $projectId): bool {
|
public static function hasFaultyOwnerEntries(int $projectId): bool {
|
||||||
if (empty($projectId)) return false;
|
if (empty($projectId)) return false;
|
||||||
|
|
||||||
|
|||||||
34
db/migrations/20251214150000_create_journal_table.php
Normal file
34
db/migrations/20251214150000_create_journal_table.php
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
<?php
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
use Phinx\Migration\AbstractMigration;
|
||||||
|
|
||||||
|
final class CreateJournalTable extends AbstractMigration
|
||||||
|
{
|
||||||
|
public function up(): void
|
||||||
|
{
|
||||||
|
if ($this->getEnvironment() == "thetool") {
|
||||||
|
$this->table('Journal')
|
||||||
|
->addColumn('user_id', 'integer', ['null' => true, 'signed' => false])
|
||||||
|
->addColumn('model', 'string', ['limit' => 255, 'null' => false])
|
||||||
|
->addColumn('record_id', 'integer', ['null' => false])
|
||||||
|
->addColumn('action', 'enum', ['values' => ['create', 'update', 'delete'], 'null' => false])
|
||||||
|
->addColumn('field', 'string', ['limit' => 255, 'null' => true])
|
||||||
|
->addColumn('old_value', 'text', ['null' => true])
|
||||||
|
->addColumn('new_value', 'text', ['null' => true])
|
||||||
|
->addColumn('timestamp', 'timestamp', ['default' => 'CURRENT_TIMESTAMP'])
|
||||||
|
->addIndex(['model', 'record_id'], ['name' => 'idx_model_record'])
|
||||||
|
->addIndex(['user_id'], ['name' => 'idx_user'])
|
||||||
|
->addIndex(['action'], ['name' => 'idx_action'])
|
||||||
|
->addIndex(['timestamp'], ['name' => 'idx_timestamp'])
|
||||||
|
->create();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
if ($this->getEnvironment() == "thetool") {
|
||||||
|
$this->table('Journal')->drop()->save();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
155
lib/mfBaseModelV2/README.md
Normal file
155
lib/mfBaseModelV2/README.md
Normal file
@@ -0,0 +1,155 @@
|
|||||||
|
# mfBaseModelV2
|
||||||
|
|
||||||
|
Modern PHP 8+ base model with typed properties and automatic journaling.
|
||||||
|
|
||||||
|
## Basic Usage
|
||||||
|
|
||||||
|
```php
|
||||||
|
class ADBNetzgebiet extends mfBaseModelV2 {
|
||||||
|
protected static string $__tableName = 'Netzgebiet';
|
||||||
|
protected static string $__primaryKey = 'id'; // default
|
||||||
|
|
||||||
|
public int $id;
|
||||||
|
public ?string $name = null;
|
||||||
|
public ?string $extref = null;
|
||||||
|
public int $create;
|
||||||
|
public int $edit;
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
## Custom Database
|
||||||
|
|
||||||
|
```php
|
||||||
|
protected static ?array $__databaseConfig = [
|
||||||
|
'host' => ADDRESSDB_DBHOST,
|
||||||
|
'user' => ADDRESSDB_DBUSER,
|
||||||
|
'pass' => ADDRESSDB_DBPASS,
|
||||||
|
'name' => ADDRESSDB_DBNAME
|
||||||
|
];
|
||||||
|
```
|
||||||
|
|
||||||
|
## Static Methods
|
||||||
|
|
||||||
|
```php
|
||||||
|
$model = MyModel::get(123); // by ID, returns ?static
|
||||||
|
$model = MyModel::getFirst(['name' => 'foo']); // first match
|
||||||
|
$all = MyModel::getAll($filter, $limit, $offset, $order);
|
||||||
|
$all = MyModel::search($filter); // alias for getAll
|
||||||
|
$count = MyModel::count($filter);
|
||||||
|
```
|
||||||
|
|
||||||
|
## Filter Operators
|
||||||
|
|
||||||
|
| Prefix | SQL | Example |
|
||||||
|
|--------|-----|---------|
|
||||||
|
| (none) | LIKE %...% | `['name' => 'foo']` |
|
||||||
|
| `=` | = exact | `['=name' => 'foo']` |
|
||||||
|
| `!` | != / NOT IN | `['!status' => 'deleted']` |
|
||||||
|
| `>` `<` `>=` `<=` | comparison | `['>create' => $timestamp]` |
|
||||||
|
|
||||||
|
**Special values:**
|
||||||
|
```php
|
||||||
|
['status' => null] // IS NULL
|
||||||
|
['!status' => null] // IS NOT NULL
|
||||||
|
['id' => [1, 2, 3]] // IN (1, 2, 3)
|
||||||
|
['!id' => [1, 2, 3]] // NOT IN (1, 2, 3)
|
||||||
|
```
|
||||||
|
|
||||||
|
## Ordering
|
||||||
|
|
||||||
|
```php
|
||||||
|
MyModel::getAll([], null, 0, ['column' => 'name', 'dir' => 'ASC']);
|
||||||
|
```
|
||||||
|
|
||||||
|
## Instance Methods
|
||||||
|
|
||||||
|
```php
|
||||||
|
$model->save(); // insert or update
|
||||||
|
$model->delete();
|
||||||
|
$model->isLoaded();
|
||||||
|
$model->getId();
|
||||||
|
$model->toArray();
|
||||||
|
$model->toJson();
|
||||||
|
$model->getJournalHistory(); // returns change history
|
||||||
|
```
|
||||||
|
|
||||||
|
## Hooks
|
||||||
|
|
||||||
|
```php
|
||||||
|
public function validate(): array {
|
||||||
|
$errors = [];
|
||||||
|
if (empty($this->name)) $errors[] = 'Name required';
|
||||||
|
return $errors; // empty = valid
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function beforeSave(bool $isInsert): bool {
|
||||||
|
return true; // false cancels save
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function afterSave(bool $isInsert, array $changes): void {
|
||||||
|
// $changes = ['field' => ['old' => x, 'new' => y]]
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
## Journaling
|
||||||
|
|
||||||
|
Automatic change tracking to `Journal` table. Configure field labels:
|
||||||
|
|
||||||
|
```php
|
||||||
|
protected static array $__journalFieldMap = [
|
||||||
|
'name' => 'Name',
|
||||||
|
'extref' => 'External Reference',
|
||||||
|
];
|
||||||
|
```
|
||||||
|
|
||||||
|
Disable per model:
|
||||||
|
```php
|
||||||
|
protected static bool $__enableJournaling = false;
|
||||||
|
```
|
||||||
|
|
||||||
|
## Auto-timestamps
|
||||||
|
|
||||||
|
If properties exist, they're set automatically on save:
|
||||||
|
- `create`, `create_by` - on insert
|
||||||
|
- `edit`, `edit_by` - on insert/update
|
||||||
|
|
||||||
|
## Magic Properties with Intellisense
|
||||||
|
|
||||||
|
Use `@property-read` for lazy-loaded relations:
|
||||||
|
|
||||||
|
```php
|
||||||
|
/**
|
||||||
|
* @property-read ADBNetzgebietRelations $relations
|
||||||
|
*/
|
||||||
|
class ADBNetzgebiet extends mfBaseModelV2 {
|
||||||
|
private ?ADBNetzgebietRelations $__relations = null;
|
||||||
|
|
||||||
|
public function __get(string $name) {
|
||||||
|
if ($name === 'relations') {
|
||||||
|
return $this->__relations ??= $this->loadRelations();
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function loadRelations(): ADBNetzgebietRelations {
|
||||||
|
// ...
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
Typed relation class for IDE support:
|
||||||
|
|
||||||
|
```php
|
||||||
|
class ADBNetzgebietRelations {
|
||||||
|
/** @var array{id: int, name: string}[] */
|
||||||
|
public array $networks = [];
|
||||||
|
/** @var array{id: int, name: string}[] */
|
||||||
|
public array $campaigns = [];
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
Usage with full autocomplete:
|
||||||
|
```php
|
||||||
|
$model = ADBNetzgebiet::get(1);
|
||||||
|
$model->relations->networks; // IDE knows this is array{id: int, name: string}[]
|
||||||
|
```
|
||||||
373
lib/mfBaseModelV2/mfBaseModelV2.php
Normal file
373
lib/mfBaseModelV2/mfBaseModelV2.php
Normal file
@@ -0,0 +1,373 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Modern base model with typed properties and automatic journaling.
|
||||||
|
*
|
||||||
|
* Filter operators: =exact, !not, >, <, >=, <=
|
||||||
|
* Array values become IN/NOT IN clauses, null checks IS NULL/IS NOT NULL
|
||||||
|
*/
|
||||||
|
abstract class mfBaseModelV2 {
|
||||||
|
|
||||||
|
protected static string $__tableName = '';
|
||||||
|
protected static string $__primaryKey = 'id';
|
||||||
|
protected static ?array $__databaseConfig = null;
|
||||||
|
protected static array $__journalFieldMap = [];
|
||||||
|
protected static bool $__enableJournaling = true;
|
||||||
|
|
||||||
|
private static array $__db_instances = [];
|
||||||
|
protected ?FronkDB $__db = null;
|
||||||
|
protected ?mfLoghandler $__log = null;
|
||||||
|
private ?stdClass $__originalData = null;
|
||||||
|
private bool $__isLoaded = false;
|
||||||
|
|
||||||
|
public function __construct(int|string $id = null) {
|
||||||
|
static::__init_db();
|
||||||
|
$this->__db = self::$__db_instances[static::class];
|
||||||
|
$this->__log = mfLoghandler::singleton();
|
||||||
|
$this->__originalData = new stdClass();
|
||||||
|
|
||||||
|
if ($id !== null) $this->__load($id);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected static function __init_db(): void {
|
||||||
|
if (isset(self::$__db_instances[static::class])) return;
|
||||||
|
|
||||||
|
if (empty(static::$__tableName)) {
|
||||||
|
throw new Exception('$__tableName must be set in ' . get_called_class());
|
||||||
|
}
|
||||||
|
|
||||||
|
self::$__db_instances[static::class] = static::$__databaseConfig !== null
|
||||||
|
? FronkDB::singleton(
|
||||||
|
static::$__databaseConfig['host'],
|
||||||
|
static::$__databaseConfig['user'],
|
||||||
|
static::$__databaseConfig['pass'],
|
||||||
|
static::$__databaseConfig['name']
|
||||||
|
)
|
||||||
|
: FronkDB::singleton();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected static function __getDb(): FronkDB {
|
||||||
|
static::__init_db();
|
||||||
|
return self::$__db_instances[static::class];
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function get(int|string $id): ?static {
|
||||||
|
static::__init_db();
|
||||||
|
$model = new static();
|
||||||
|
return $model->__load($id) ? $model : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getFirst(array $filter = [], array $order = []): ?static {
|
||||||
|
$results = static::getAll($filter, 1, 0, $order);
|
||||||
|
return $results[0] ?? null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getAll(array $filter = [], int $limit = null, int $offset = 0, array $order = []): array {
|
||||||
|
static::__init_db();
|
||||||
|
$db = self::$__db_instances[static::class];
|
||||||
|
$table = static::$__tableName;
|
||||||
|
$whereSql = static::__buildFilterSql($filter);
|
||||||
|
|
||||||
|
$orderSql = "";
|
||||||
|
if (!empty($order['column'])) {
|
||||||
|
$dir = (strtoupper($order['dir'] ?? '') === 'DESC') ? 'DESC' : 'ASC';
|
||||||
|
$orderSql = "ORDER BY `" . $db->escape($order['column']) . "` $dir";
|
||||||
|
}
|
||||||
|
|
||||||
|
$limitSql = $limit !== null ? "LIMIT " . (int)$offset . ", " . (int)$limit : "";
|
||||||
|
$res = $db->query("SELECT * FROM `$table` $whereSql $orderSql $limitSql");
|
||||||
|
|
||||||
|
$items = [];
|
||||||
|
if ($db->num_rows($res)) {
|
||||||
|
while ($data = $db->fetch_object($res)) {
|
||||||
|
$model = new static();
|
||||||
|
$model->__populate($data);
|
||||||
|
$model->__isLoaded = true;
|
||||||
|
$items[] = $model;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $items;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function search(array $filter = [], int $limit = null, int $offset = 0, array $order = []): array {
|
||||||
|
return static::getAll($filter, $limit, $offset, $order);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function count(array $filter = []): int {
|
||||||
|
static::__init_db();
|
||||||
|
$db = self::$__db_instances[static::class];
|
||||||
|
$whereSql = static::__buildFilterSql($filter);
|
||||||
|
$res = $db->query("SELECT COUNT(*) as cnt FROM `" . static::$__tableName . "` $whereSql");
|
||||||
|
return $db->num_rows($res) ? (int)$db->fetch_object($res)->cnt : 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function isLoaded(): bool { return $this->__isLoaded; }
|
||||||
|
|
||||||
|
public function getId(): int|string|null {
|
||||||
|
return $this->{static::$__primaryKey} ?? null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function save(): bool {
|
||||||
|
try {
|
||||||
|
$isInsert = !$this->__isLoaded;
|
||||||
|
$userId = $this->__getUserId();
|
||||||
|
$now = time();
|
||||||
|
|
||||||
|
if (property_exists($this, 'edit')) $this->edit = $now;
|
||||||
|
if (property_exists($this, 'edit_by')) $this->edit_by = $userId;
|
||||||
|
|
||||||
|
if ($isInsert) {
|
||||||
|
if (property_exists($this, 'create')) $this->create = $now;
|
||||||
|
if (property_exists($this, 'create_by')) $this->create_by = $userId;
|
||||||
|
}
|
||||||
|
|
||||||
|
$errors = $this->validate();
|
||||||
|
if (!empty($errors)) {
|
||||||
|
$this->__log->warn('Validation failed: ' . implode(', ', $errors));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!$this->beforeSave($isInsert)) return false;
|
||||||
|
|
||||||
|
$data = $this->__getPublicData();
|
||||||
|
$changes = $this->__getChangedFields($data);
|
||||||
|
$pk = static::$__primaryKey;
|
||||||
|
|
||||||
|
if (!$isInsert && empty($changes)) return true;
|
||||||
|
|
||||||
|
if ($isInsert) {
|
||||||
|
if (array_key_exists($pk, $data) && $data[$pk] === null) unset($data[$pk]);
|
||||||
|
if (!$this->__db->insert(static::$__tableName, $data)) {
|
||||||
|
throw new Exception("INSERT failed: " . $this->__db->getLastError());
|
||||||
|
}
|
||||||
|
$this->{$pk} = $this->__db->insert_id;
|
||||||
|
$this->__isLoaded = true;
|
||||||
|
} else {
|
||||||
|
$pkValue = $this->{$pk};
|
||||||
|
$updateData = [];
|
||||||
|
foreach ($changes as $field => $change) $updateData[$field] = $change['new'];
|
||||||
|
|
||||||
|
if (!empty($updateData)) {
|
||||||
|
if (!$this->__db->update(static::$__tableName, $updateData, "`$pk` = '" . $this->__db->escape($pkValue) . "'")) {
|
||||||
|
throw new Exception("UPDATE failed: " . $this->__db->getLastError());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->__originalData = (object)$this->__getPublicData();
|
||||||
|
$this->afterSave($isInsert, $changes);
|
||||||
|
|
||||||
|
if (static::$__enableJournaling) $this->__writeToJournal($changes, $isInsert);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
} catch (Exception $e) {
|
||||||
|
$this->__log->error("mfBaseModelV2 save() error: " . $e->getMessage());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function delete(): bool {
|
||||||
|
if (!$this->__isLoaded) return false;
|
||||||
|
|
||||||
|
$pk = static::$__primaryKey;
|
||||||
|
$pkValue = $this->{$pk};
|
||||||
|
|
||||||
|
if ($this->__db->delete(static::$__tableName, "`$pk` = '" . $this->__db->escape($pkValue) . "'")) {
|
||||||
|
if (static::$__enableJournaling) $this->__writeToJournal([], false, true);
|
||||||
|
$this->__isLoaded = false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getJournalHistory(): array {
|
||||||
|
$journalDb = FronkDB::singleton();
|
||||||
|
$pkValue = $this->{static::$__primaryKey} ?? null;
|
||||||
|
if ($pkValue === null) return [];
|
||||||
|
|
||||||
|
$modelName = $journalDb->escape(get_called_class());
|
||||||
|
$recordId = $journalDb->escape($pkValue);
|
||||||
|
|
||||||
|
$res = $journalDb->query("SELECT * FROM `Journal` WHERE `model` = '$modelName' AND `record_id` = '$recordId' ORDER BY `timestamp` DESC");
|
||||||
|
$history = [];
|
||||||
|
|
||||||
|
if ($journalDb->num_rows($res)) {
|
||||||
|
while ($row = $journalDb->fetch_object($res)) {
|
||||||
|
if ($row->field && isset(static::$__journalFieldMap[$row->field])) {
|
||||||
|
$row->field_readable = static::$__journalFieldMap[$row->field];
|
||||||
|
}
|
||||||
|
$history[] = $row;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $history;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function toArray(): array { return $this->__getPublicData(); }
|
||||||
|
public function toJson(): string { return json_encode($this->toArray()); }
|
||||||
|
|
||||||
|
// Hooks
|
||||||
|
public function validate(): array { return []; }
|
||||||
|
protected function beforeSave(bool $isInsert): bool { return true; }
|
||||||
|
protected function afterSave(bool $isInsert, array $changes): void {}
|
||||||
|
|
||||||
|
// Internal methods
|
||||||
|
private function __load(int|string $id): bool {
|
||||||
|
$pk = static::$__primaryKey;
|
||||||
|
$res = $this->__db->select(static::$__tableName, "*", "`$pk` = '" . $this->__db->escape($id) . "' LIMIT 1");
|
||||||
|
|
||||||
|
if ($this->__db->num_rows($res)) {
|
||||||
|
$this->__populate($this->__db->fetch_object($res));
|
||||||
|
$this->__isLoaded = true;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function __populate(stdClass $data): void {
|
||||||
|
$reflector = new ReflectionClass($this);
|
||||||
|
foreach ($reflector->getProperties(ReflectionProperty::IS_PUBLIC) as $prop) {
|
||||||
|
$name = $prop->getName();
|
||||||
|
if (!property_exists($data, $name)) continue;
|
||||||
|
|
||||||
|
$type = $prop->getType()?->getName();
|
||||||
|
$value = $data->{$name};
|
||||||
|
|
||||||
|
$this->{$name} = $value === null ? null : match ($type) {
|
||||||
|
'int' => (int)$value,
|
||||||
|
'float' => (float)$value,
|
||||||
|
'bool' => (bool)$value,
|
||||||
|
'string' => (string)$value,
|
||||||
|
default => $value,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
$this->__originalData = (object)$this->__getPublicData();
|
||||||
|
}
|
||||||
|
|
||||||
|
private function __getPublicData(): array {
|
||||||
|
$data = [];
|
||||||
|
$reflector = new ReflectionClass($this);
|
||||||
|
foreach ($reflector->getProperties(ReflectionProperty::IS_PUBLIC) as $prop) {
|
||||||
|
$name = $prop->getName();
|
||||||
|
$data[$name] = $prop->isInitialized($this)
|
||||||
|
? $this->{$name}
|
||||||
|
: ($prop->hasDefaultValue() ? $prop->getDefaultValue() : null);
|
||||||
|
}
|
||||||
|
return $data;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function __getChangedFields(array $currentData): array {
|
||||||
|
$changes = [];
|
||||||
|
if (!$this->__isLoaded || !$this->__originalData) {
|
||||||
|
foreach ($currentData as $key => $value) $changes[$key] = ['old' => null, 'new' => $value];
|
||||||
|
return $changes;
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($currentData as $key => $value) {
|
||||||
|
if (!property_exists($this->__originalData, $key) || $this->__originalData->{$key} != $value) {
|
||||||
|
$changes[$key] = ['old' => $this->__originalData->{$key} ?? null, 'new' => $value];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $changes;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function __writeToJournal(array $changes, bool $isInsert, bool $isDelete = false): void {
|
||||||
|
try {
|
||||||
|
$journalDb = FronkDB::singleton();
|
||||||
|
$baseData = [
|
||||||
|
'user_id' => $this->__getUserId(),
|
||||||
|
'model' => get_called_class(),
|
||||||
|
'record_id' => $this->{static::$__primaryKey},
|
||||||
|
];
|
||||||
|
|
||||||
|
if ($isDelete) {
|
||||||
|
$journalDb->insert('Journal', $baseData + ['action' => 'delete']);
|
||||||
|
} elseif ($isInsert) {
|
||||||
|
$journalDb->insert('Journal', $baseData + ['action' => 'create']);
|
||||||
|
} else {
|
||||||
|
foreach ($changes as $field => $change) {
|
||||||
|
$journalDb->insert('Journal', $baseData + [
|
||||||
|
'action' => 'update',
|
||||||
|
'field' => $field,
|
||||||
|
'old_value' => is_array($change['old']) || is_object($change['old']) ? json_encode($change['old']) : $change['old'],
|
||||||
|
'new_value' => is_array($change['new']) || is_object($change['new']) ? json_encode($change['new']) : $change['new'],
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (Exception $e) {
|
||||||
|
$this->__log->error("Journal write failed: " . $e->getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private function __getUserId(): ?int {
|
||||||
|
try {
|
||||||
|
$me = new User();
|
||||||
|
$me->loadMe();
|
||||||
|
return $me->id ?? null;
|
||||||
|
} catch (Exception) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Builds WHERE clause from filter array.
|
||||||
|
* Operators: =exact, !not, >, <, >=, <=
|
||||||
|
* Arrays become IN/NOT IN, null becomes IS NULL/IS NOT NULL
|
||||||
|
*/
|
||||||
|
private static function __buildFilterSql(array $filter): string {
|
||||||
|
$whereClauses = ["1=1"];
|
||||||
|
$db = self::$__db_instances[static::class];
|
||||||
|
$reflector = new ReflectionClass(static::class);
|
||||||
|
|
||||||
|
foreach ($filter as $key => $value) {
|
||||||
|
$column = $key;
|
||||||
|
$operator = '=';
|
||||||
|
$forceExact = false;
|
||||||
|
|
||||||
|
// Parse operator from key prefix
|
||||||
|
if (str_starts_with($key, '>=')) { $operator = '>='; $column = substr($key, 2); }
|
||||||
|
elseif (str_starts_with($key, '<=')) { $operator = '<='; $column = substr($key, 2); }
|
||||||
|
elseif (str_starts_with($key, '!')) { $operator = '!='; $column = substr($key, 1); }
|
||||||
|
elseif (str_starts_with($key, '>')) { $operator = '>'; $column = substr($key, 1); }
|
||||||
|
elseif (str_starts_with($key, '<')) { $operator = '<'; $column = substr($key, 1); }
|
||||||
|
elseif (str_starts_with($key, '=')) { $operator = '='; $column = substr($key, 1); $forceExact = true; }
|
||||||
|
|
||||||
|
if (!$reflector->hasProperty($column)) {
|
||||||
|
mfLoghandler::singleton()->warn("Filter: Unknown property '$column' on " . static::class);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// NULL handling
|
||||||
|
if ($value === null) {
|
||||||
|
$whereClauses[] = "`$column` " . ($operator === '!=' ? 'IS NOT NULL' : 'IS NULL');
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Array = IN/NOT IN
|
||||||
|
if (is_array($value)) {
|
||||||
|
$op = ($operator === '!=') ? 'NOT IN' : 'IN';
|
||||||
|
if (empty($value)) {
|
||||||
|
$whereClauses[] = ($op === 'IN') ? "0=1" : "1=1";
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
$escaped = array_map(fn($v) => "'" . $db->escape($v) . "'", $value);
|
||||||
|
$whereClauses[] = "`$column` $op (" . implode(',', $escaped) . ")";
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// String lazy search vs exact/numeric
|
||||||
|
$prop = $reflector->getProperty($column);
|
||||||
|
$type = $prop->getType()?->getName() ?? 'string';
|
||||||
|
|
||||||
|
if ($type === 'string' && $operator === '=' && !$forceExact) {
|
||||||
|
foreach (explode(' ', (string)$value) as $term) {
|
||||||
|
if (empty($term)) continue;
|
||||||
|
$whereClauses[] = "`$column` LIKE '%" . $db->escape($term) . "%'";
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$whereClauses[] = "`$column` $operator '" . $db->escape($value) . "'";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return "WHERE " . implode(" AND ", $whereClauses);
|
||||||
|
}
|
||||||
|
}
|
||||||
530
public/js/pages/ADBNetzgebiet/ADBNetzgebiet.css
Normal file
530
public/js/pages/ADBNetzgebiet/ADBNetzgebiet.css
Normal file
@@ -0,0 +1,530 @@
|
|||||||
|
/**
|
||||||
|
* ADBNetzgebiet - Netzgebietverwaltung Styles
|
||||||
|
* Optimized for ~1720px width (50% of 21:9 1440p)
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* ===== Container ===== */
|
||||||
|
.tt-scope.netzgebiet-container {
|
||||||
|
background: transparent;
|
||||||
|
color: var(--tt-text);
|
||||||
|
display: grid;
|
||||||
|
gap: 16px;
|
||||||
|
max-width: 90vw;
|
||||||
|
margin: 24px auto 0;
|
||||||
|
padding: 20px 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tt-scope.netzgebiet-container .card {
|
||||||
|
margin: 0;
|
||||||
|
border-radius: var(--tt-radius, 10px);
|
||||||
|
border: none;
|
||||||
|
box-shadow: var(--tt-shadow, 0 8px 24px rgba(0, 83, 132, .08));
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ===== Header ===== */
|
||||||
|
.tt-scope.netzgebiet-container .pane-header {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: space-between;
|
||||||
|
gap: 12px;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
background: linear-gradient(135deg, #f8fbff 0%, #f0f7fd 100%);
|
||||||
|
padding: 16px 20px;
|
||||||
|
margin: -14px -14px 14px -14px;
|
||||||
|
border-radius: var(--tt-radius, 10px) var(--tt-radius, 10px) 0 0;
|
||||||
|
border-bottom: 2px solid #e3f0f8;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tt-scope.netzgebiet-container .pane-header .title {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 12px;
|
||||||
|
font-weight: 800;
|
||||||
|
letter-spacing: .4px;
|
||||||
|
font-size: 22px;
|
||||||
|
user-select: none;
|
||||||
|
color: var(--tt-accent, #005384);
|
||||||
|
text-shadow: 0 1px 2px rgba(0,83,132,.1);
|
||||||
|
}
|
||||||
|
|
||||||
|
.tt-scope.netzgebiet-container .logo-dot {
|
||||||
|
width: 14px;
|
||||||
|
height: 14px;
|
||||||
|
border-radius: 50%;
|
||||||
|
background: radial-gradient(circle at 30% 30%, #37d26b, #0f9d58 70%);
|
||||||
|
box-shadow: 0 0 0 3px rgba(15,157,88,.15);
|
||||||
|
display: inline-block;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tt-scope.netzgebiet-container .content-divider {
|
||||||
|
border: none;
|
||||||
|
height: 1px;
|
||||||
|
background-color: var(--tt-border);
|
||||||
|
margin: 16px 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ===== Filter Bar ===== */
|
||||||
|
.tt-scope.netzgebiet-container .filter-bar {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
padding: 14px 20px;
|
||||||
|
background: #f8fafc;
|
||||||
|
border-bottom: 1px solid var(--tt-border);
|
||||||
|
}
|
||||||
|
|
||||||
|
.tt-scope.netzgebiet-container .filter-center {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 10px;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
justify-content: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tt-scope.netzgebiet-container .filter-main { width: 200px; }
|
||||||
|
.tt-scope.netzgebiet-container .filter-md { width: 140px; }
|
||||||
|
.tt-scope.netzgebiet-container .filter-sm { width: 120px; }
|
||||||
|
|
||||||
|
.tt-scope.netzgebiet-container .filter-bar .ri,
|
||||||
|
.tt-scope.netzgebiet-container .filter-bar select {
|
||||||
|
height: 34px;
|
||||||
|
font-size: 13px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tt-scope.netzgebiet-container .filter-bar .ri {
|
||||||
|
padding: 6px 10px 6px 34px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tt-scope.netzgebiet-container .filter-bar .select select {
|
||||||
|
padding: 6px 28px 6px 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tt-scope.netzgebiet-container .filter-bar .input-icon {
|
||||||
|
font-size: 13px;
|
||||||
|
left: 11px;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ===== Table Container ===== */
|
||||||
|
.tt-scope .table-container {
|
||||||
|
overflow-x: auto;
|
||||||
|
overflow-y: auto;
|
||||||
|
max-height: calc(100vh - 200px);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ===== Table ===== */
|
||||||
|
.tt-scope .netzgebiet-table {
|
||||||
|
width: 100%;
|
||||||
|
min-width: 900px;
|
||||||
|
table-layout: fixed;
|
||||||
|
border-collapse: collapse;
|
||||||
|
font-size: 13px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tt-scope .netzgebiet-table th,
|
||||||
|
.tt-scope .netzgebiet-table td {
|
||||||
|
padding: 10px 12px;
|
||||||
|
vertical-align: top;
|
||||||
|
border-bottom: 1px solid #eef1f5;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tt-scope .netzgebiet-table thead th {
|
||||||
|
position: sticky;
|
||||||
|
top: 0;
|
||||||
|
background: #f6f9fc;
|
||||||
|
font-size: 11px;
|
||||||
|
font-weight: 600;
|
||||||
|
text-transform: uppercase;
|
||||||
|
letter-spacing: 0.03em;
|
||||||
|
color: #667085;
|
||||||
|
z-index: 10;
|
||||||
|
vertical-align: middle;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tt-scope .netzgebiet-table tbody tr:hover {
|
||||||
|
background: #fafbfc;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Column Widths - optimized for 1720px */
|
||||||
|
.tt-scope .col-name { width: 20%; }
|
||||||
|
.tt-scope .col-source { width: 14%; }
|
||||||
|
.tt-scope .col-freigabe { width: 10%; }
|
||||||
|
.tt-scope .col-network { width: 18%; }
|
||||||
|
.tt-scope .col-campaign { width: 16%; }
|
||||||
|
.tt-scope .col-consent { width: 16%; }
|
||||||
|
.tt-scope .col-actions { width: 6%; text-align: right; }
|
||||||
|
|
||||||
|
/* ===== Name Cell ===== */
|
||||||
|
.tt-scope .name-link {
|
||||||
|
font-weight: 600;
|
||||||
|
color: var(--tt-accent);
|
||||||
|
}
|
||||||
|
|
||||||
|
.tt-scope .name-link:hover {
|
||||||
|
text-decoration: underline;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tt-scope .sub-text {
|
||||||
|
font-size: 11px;
|
||||||
|
color: var(--tt-muted);
|
||||||
|
margin-top: 2px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tt-scope .truncate {
|
||||||
|
white-space: nowrap;
|
||||||
|
overflow: hidden;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
max-width: 100%;
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ===== Source Badge ===== */
|
||||||
|
.tt-scope .source-badge {
|
||||||
|
display: inline-block;
|
||||||
|
font-size: 11px;
|
||||||
|
font-weight: 600;
|
||||||
|
padding: 3px 8px;
|
||||||
|
border-radius: 4px;
|
||||||
|
background: #e8f0f6;
|
||||||
|
color: #3a5a70;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ===== Freigabe Badges ===== */
|
||||||
|
.tt-scope .freigabe-badges {
|
||||||
|
display: flex;
|
||||||
|
gap: 4px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tt-scope .freigabe-badge {
|
||||||
|
width: 20px;
|
||||||
|
height: 20px;
|
||||||
|
display: inline-flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
font-size: 10px;
|
||||||
|
font-weight: 700;
|
||||||
|
border-radius: 4px;
|
||||||
|
color: #fff;
|
||||||
|
cursor: default;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tt-scope .freigabe-badge.f-interest { background: #1565c0; }
|
||||||
|
.tt-scope .freigabe-badge.f-provision { background: #e65100; }
|
||||||
|
.tt-scope .freigabe-badge.f-order { background: #2e7d32; }
|
||||||
|
.tt-scope .freigabe-badge.f-reorder { background: #7b1fa2; }
|
||||||
|
|
||||||
|
/* ===== Related Links ===== */
|
||||||
|
.tt-scope .related-link {
|
||||||
|
display: block;
|
||||||
|
font-size: 12px;
|
||||||
|
color: var(--tt-accent);
|
||||||
|
text-decoration: none;
|
||||||
|
white-space: nowrap;
|
||||||
|
overflow: hidden;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
max-width: 100%;
|
||||||
|
line-height: 1.5;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tt-scope .related-link:hover {
|
||||||
|
text-decoration: underline;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tt-scope .more-badge {
|
||||||
|
display: inline-block;
|
||||||
|
font-size: 10px;
|
||||||
|
font-weight: 600;
|
||||||
|
padding: 1px 5px;
|
||||||
|
border-radius: 3px;
|
||||||
|
background: var(--tt-accent);
|
||||||
|
color: #fff;
|
||||||
|
margin-left: 4px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tt-scope .create-link {
|
||||||
|
display: inline-flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 4px;
|
||||||
|
font-size: 12px;
|
||||||
|
color: var(--tt-muted);
|
||||||
|
text-decoration: none;
|
||||||
|
opacity: 0.7;
|
||||||
|
transition: opacity 0.15s, color 0.15s;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tt-scope .create-link:hover {
|
||||||
|
opacity: 1;
|
||||||
|
color: var(--tt-accent);
|
||||||
|
}
|
||||||
|
|
||||||
|
.tt-scope .create-link i {
|
||||||
|
font-size: 11px;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ===== Action Buttons ===== */
|
||||||
|
.tt-scope .col-actions {
|
||||||
|
white-space: nowrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tt-scope .col-actions .icon-btn {
|
||||||
|
padding: 5px 7px;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ===== Pagination Bar ===== */
|
||||||
|
.tt-scope .pagination-bar {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: space-between;
|
||||||
|
padding: 10px 20px;
|
||||||
|
background: #f8fafc;
|
||||||
|
border-top: 1px solid var(--tt-border);
|
||||||
|
font-size: 13px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tt-scope .pagination-info {
|
||||||
|
color: var(--tt-muted);
|
||||||
|
}
|
||||||
|
|
||||||
|
.tt-scope .pagination-controls {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tt-scope .page-size-select {
|
||||||
|
height: 30px;
|
||||||
|
font-size: 12px;
|
||||||
|
padding: 4px 24px 4px 8px;
|
||||||
|
border-radius: 6px;
|
||||||
|
border: 1px solid var(--tt-border);
|
||||||
|
background: #fff;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tt-scope .page-indicator {
|
||||||
|
font-size: 12px;
|
||||||
|
color: var(--tt-muted);
|
||||||
|
min-width: 60px;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ===== Table Placeholder ===== */
|
||||||
|
.tt-scope .table-placeholder {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
gap: 10px;
|
||||||
|
padding: 60px 20px;
|
||||||
|
color: var(--tt-muted);
|
||||||
|
font-size: 14px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tt-scope .table-placeholder.compact {
|
||||||
|
padding: 30px 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tt-scope .table-placeholder i {
|
||||||
|
font-size: 28px;
|
||||||
|
color: var(--tt-brand-blue);
|
||||||
|
opacity: 0.5;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ===== Modal Form ===== */
|
||||||
|
.tt-scope .modal-form {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tt-scope .form-grid {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: repeat(3, 1fr);
|
||||||
|
gap: 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tt-scope .form-grid .field {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 6px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tt-scope .form-grid .span-2 {
|
||||||
|
grid-column: span 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tt-scope .form-grid label,
|
||||||
|
.tt-scope .form-section label:not(.checkbox-field) {
|
||||||
|
font-size: 11px;
|
||||||
|
font-weight: 600;
|
||||||
|
color: var(--tt-muted);
|
||||||
|
text-transform: uppercase;
|
||||||
|
letter-spacing: 0.03em;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tt-scope .form-section {
|
||||||
|
border-top: 1px solid var(--tt-border);
|
||||||
|
padding-top: 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tt-scope .section-label {
|
||||||
|
display: block;
|
||||||
|
font-size: 13px;
|
||||||
|
font-weight: 700;
|
||||||
|
margin-bottom: 12px;
|
||||||
|
color: var(--tt-text);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ===== Checkbox Fields ===== */
|
||||||
|
.tt-scope .checkbox-row {
|
||||||
|
display: flex;
|
||||||
|
gap: 20px;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tt-scope .checkbox-field {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 8px;
|
||||||
|
cursor: pointer;
|
||||||
|
font-size: 13px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tt-scope .checkbox-field input[type="checkbox"] {
|
||||||
|
width: 16px;
|
||||||
|
height: 16px;
|
||||||
|
accent-color: var(--tt-brand-blue);
|
||||||
|
}
|
||||||
|
|
||||||
|
.tt-scope .options-grid {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: repeat(3, 1fr);
|
||||||
|
gap: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ===== History ===== */
|
||||||
|
.tt-scope .history-container {
|
||||||
|
max-height: 60vh;
|
||||||
|
overflow-y: auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tt-scope .history-list {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 4px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tt-scope .history-entry {
|
||||||
|
display: flex;
|
||||||
|
gap: 10px;
|
||||||
|
padding: 8px 12px;
|
||||||
|
background: #fff;
|
||||||
|
border-radius: 6px;
|
||||||
|
border: 1px solid var(--tt-border);
|
||||||
|
border-left-width: 3px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tt-scope .history-entry.action-update { border-left-color: #f59f0b; }
|
||||||
|
.tt-scope .history-entry.action-create { border-left-color: var(--tt-ok); }
|
||||||
|
.tt-scope .history-entry.action-delete { border-left-color: var(--tt-bad); }
|
||||||
|
|
||||||
|
.tt-scope .history-icon {
|
||||||
|
font-size: 12px;
|
||||||
|
width: 18px;
|
||||||
|
text-align: center;
|
||||||
|
padding-top: 1px;
|
||||||
|
color: var(--tt-muted);
|
||||||
|
}
|
||||||
|
|
||||||
|
.tt-scope .history-entry.action-update .history-icon { color: #f59f0b; }
|
||||||
|
.tt-scope .history-entry.action-create .history-icon { color: var(--tt-ok); }
|
||||||
|
.tt-scope .history-entry.action-delete .history-icon { color: var(--tt-bad); }
|
||||||
|
|
||||||
|
.tt-scope .history-content {
|
||||||
|
flex: 1;
|
||||||
|
min-width: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tt-scope .history-header {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 8px;
|
||||||
|
font-size: 12px;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tt-scope .history-header strong {
|
||||||
|
font-weight: 600;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tt-scope .history-header .field-label {
|
||||||
|
background: #f1f3f5;
|
||||||
|
padding: 1px 6px;
|
||||||
|
border-radius: 3px;
|
||||||
|
font-family: var(--tt-mono);
|
||||||
|
font-size: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tt-scope .history-meta {
|
||||||
|
margin-left: auto;
|
||||||
|
font-size: 10px;
|
||||||
|
color: var(--tt-muted);
|
||||||
|
}
|
||||||
|
|
||||||
|
.tt-scope .history-diff {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 8px;
|
||||||
|
margin-top: 4px;
|
||||||
|
font-size: 11px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tt-scope .history-diff i {
|
||||||
|
color: var(--tt-muted);
|
||||||
|
font-size: 9px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tt-scope .history-diff .diff-old,
|
||||||
|
.tt-scope .history-diff .diff-new {
|
||||||
|
display: inline-block;
|
||||||
|
padding: 2px 8px;
|
||||||
|
border-radius: 3px;
|
||||||
|
font-family: var(--tt-mono);
|
||||||
|
max-width: 320px;
|
||||||
|
overflow: hidden;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
white-space: nowrap;
|
||||||
|
transition: all 0.15s ease;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tt-scope .history-diff .diff-old.expandable,
|
||||||
|
.tt-scope .history-diff .diff-new.expandable {
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tt-scope .history-diff .diff-old.expandable:hover,
|
||||||
|
.tt-scope .history-diff .diff-new.expandable:hover {
|
||||||
|
filter: brightness(0.97);
|
||||||
|
}
|
||||||
|
|
||||||
|
.tt-scope .history-diff .diff-old.expanded,
|
||||||
|
.tt-scope .history-diff .diff-new.expanded {
|
||||||
|
max-width: 400px;
|
||||||
|
white-space: normal;
|
||||||
|
word-break: break-word;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tt-scope .history-diff .diff-old {
|
||||||
|
background: #fff5f5;
|
||||||
|
color: #c92a2a;
|
||||||
|
border: 1px solid #ffc9c9;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tt-scope .history-diff .diff-new {
|
||||||
|
background: #eaf7ef;
|
||||||
|
color: #15803d;
|
||||||
|
border: 1px solid #c9e6d8;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ===== Utilities ===== */
|
||||||
|
.tt-scope .mono { font-family: var(--tt-mono); }
|
||||||
|
.tt-scope .muted { color: var(--tt-muted); }
|
||||||
|
.tt-scope .mt-3 { margin-top: 12px; }
|
||||||
489
public/js/pages/ADBNetzgebiet/ADBNetzgebiet.js
Normal file
489
public/js/pages/ADBNetzgebiet/ADBNetzgebiet.js
Normal file
@@ -0,0 +1,489 @@
|
|||||||
|
/**
|
||||||
|
* ADBNetzgebiet - Netzgebietverwaltung (Vue 3 + TT-Core)
|
||||||
|
*/
|
||||||
|
|
||||||
|
const ADBNetzgebiet = {
|
||||||
|
name: 'ADBNetzgebiet',
|
||||||
|
template: `
|
||||||
|
<div class="tt-scope netzgebiet-container">
|
||||||
|
<section class="card card-in">
|
||||||
|
<!-- Header -->
|
||||||
|
<div class="pane-header">
|
||||||
|
<div class="title">
|
||||||
|
<span class="logo-dot"></span>
|
||||||
|
<span>Netzgebietverwaltung</span>
|
||||||
|
</div>
|
||||||
|
<button class="primary-btn" @click="openCreateModal">
|
||||||
|
<i class="fa-duotone fa-plus"></i> Neues Netzgebiet
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
<hr class="content-divider" />
|
||||||
|
|
||||||
|
<!-- Filter Bar -->
|
||||||
|
<div class="filter-bar">
|
||||||
|
<div class="filter-center">
|
||||||
|
<div class="input-wrap filter-main">
|
||||||
|
<i class="fa-duotone fa-magnifying-glass input-icon"></i>
|
||||||
|
<input class="ri" v-model.trim="filters.name" placeholder="Name suchen..." @input="debouncedFilter">
|
||||||
|
</div>
|
||||||
|
<div class="input-wrap filter-md">
|
||||||
|
<i class="fa-duotone fa-key input-icon"></i>
|
||||||
|
<input class="ri" v-model.trim="filters.extref" placeholder="ExtRef..." @input="debouncedFilter">
|
||||||
|
</div>
|
||||||
|
<div class="select filter-sm">
|
||||||
|
<select v-model="filters.source" @change="applyFilter">
|
||||||
|
<option value="">Alle Quellen</option>
|
||||||
|
<option v-for="source in availableSources" :key="source" :value="source">{{ source }}</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
<div class="select filter-sm">
|
||||||
|
<select v-model="filters.hasNetwork" @change="applyFilter">
|
||||||
|
<option value="">Netzwerk</option>
|
||||||
|
<option value="yes">Mit Netzwerk</option>
|
||||||
|
<option value="no">Ohne Netzwerk</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
<div class="select filter-sm">
|
||||||
|
<select v-model="filters.hasCampaign" @change="applyFilter">
|
||||||
|
<option value="">Kampagne</option>
|
||||||
|
<option value="yes">Mit Kampagne</option>
|
||||||
|
<option value="no">Ohne Kampagne</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
<div class="select filter-sm">
|
||||||
|
<select v-model="filters.hasConsent" @change="applyFilter">
|
||||||
|
<option value="">Zustimmung</option>
|
||||||
|
<option value="yes">Mit Zustimmung</option>
|
||||||
|
<option value="no">Ohne Zustimmung</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
<button v-if="hasActiveFilters" class="icon-btn" @click="clearFilters" title="Filter zurücksetzen">
|
||||||
|
<i class="fa-duotone fa-xmark"></i>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Data Table -->
|
||||||
|
<div class="table-container">
|
||||||
|
<table class="tt-table netzgebiet-table" v-if="!isLoading && paginatedItems.length">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th class="col-name">Name / ExtRef</th>
|
||||||
|
<th class="col-source">Quelle</th>
|
||||||
|
<th class="col-freigabe">Freigaben</th>
|
||||||
|
<th class="col-network">Netzwerk</th>
|
||||||
|
<th class="col-campaign">Kampagne</th>
|
||||||
|
<th class="col-consent">Zustimmung</th>
|
||||||
|
<th class="col-actions"></th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<tr v-for="item in paginatedItems" :key="item.netzgebiet.id">
|
||||||
|
<td class="col-name">
|
||||||
|
<a class="link name-link" href="#" @click.prevent="openEditModal(item)">{{ item.netzgebiet.name || '(Ohne Name)' }}</a>
|
||||||
|
<div v-if="item.netzgebiet.extref" class="sub-text mono">{{ item.netzgebiet.extref }}</div>
|
||||||
|
</td>
|
||||||
|
<td class="col-source">
|
||||||
|
<span class="source-badge">{{ item.netzgebiet.source || '—' }}</span>
|
||||||
|
<div v-if="item.netzgebiet.source_id" class="sub-text mono truncate" :title="item.netzgebiet.source_id">{{ item.netzgebiet.source_id }}</div>
|
||||||
|
</td>
|
||||||
|
<td class="col-freigabe">
|
||||||
|
<div class="freigabe-badges">
|
||||||
|
<span v-for="f in parsedFreigabe(item.netzgebiet.freigabe)" :key="f" class="freigabe-badge" :class="'f-' + f" :title="freigabeLabels[f]">{{ f.charAt(0).toUpperCase() }}</span>
|
||||||
|
<span v-if="!parsedFreigabe(item.netzgebiet.freigabe).length" class="muted">—</span>
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
<td class="col-network">
|
||||||
|
<template v-if="item.related.networks.length">
|
||||||
|
<a v-for="net in item.related.networks.slice(0, 2)" :key="net.id"
|
||||||
|
:href="window.TT_CONFIG.NETWORK_URL + '?id=' + net.id"
|
||||||
|
target="_blank" class="related-link">
|
||||||
|
{{ net.name }}
|
||||||
|
</a>
|
||||||
|
<span v-if="item.related.networks.length > 2" class="more-badge">+{{ item.related.networks.length - 2 }}</span>
|
||||||
|
</template>
|
||||||
|
<a v-else :href="window.TT_CONFIG.NETWORK_CREATE_URL + '?adb_netzgebiet_id=' + item.netzgebiet.id" class="create-link" title="Netzwerk erstellen">
|
||||||
|
<i class="fa-duotone fa-plus-circle"></i> Erstellen
|
||||||
|
</a>
|
||||||
|
</td>
|
||||||
|
<td class="col-campaign">
|
||||||
|
<template v-if="item.related.campaigns.length">
|
||||||
|
<a v-for="camp in item.related.campaigns.slice(0, 1)" :key="camp.id"
|
||||||
|
:href="window.TT_CONFIG.CAMPAIGN_URL + '?id=' + camp.id"
|
||||||
|
target="_blank" class="related-link">
|
||||||
|
{{ camp.name }}
|
||||||
|
</a>
|
||||||
|
<span v-if="item.related.campaigns.length > 1" class="more-badge">+{{ item.related.campaigns.length - 1 }}</span>
|
||||||
|
</template>
|
||||||
|
<a v-else-if="item.related.networks.length" :href="window.TT_CONFIG.CAMPAIGN_CREATE_URL + '?network_id=' + item.related.networks[0].id" class="create-link" title="Kampagne erstellen">
|
||||||
|
<i class="fa-duotone fa-plus-circle"></i> Erstellen
|
||||||
|
</a>
|
||||||
|
<span v-else class="muted">—</span>
|
||||||
|
</td>
|
||||||
|
<td class="col-consent">
|
||||||
|
<template v-if="item.related.consent_projects.length">
|
||||||
|
<a v-for="cons in item.related.consent_projects.slice(0, 1)" :key="cons.id"
|
||||||
|
:href="window.TT_CONFIG.CONSENT_URL + '?id=' + cons.id"
|
||||||
|
target="_blank" class="related-link">
|
||||||
|
{{ cons.name }}
|
||||||
|
</a>
|
||||||
|
<span v-if="item.related.consent_projects.length > 1" class="more-badge">+{{ item.related.consent_projects.length - 1 }}</span>
|
||||||
|
</template>
|
||||||
|
<a v-else :href="window.TT_CONFIG.CONSENT_CREATE_URL + '?adb_netzgebiet_id=' + item.netzgebiet.id" class="create-link" title="Zustimmungsprojekt erstellen">
|
||||||
|
<i class="fa-duotone fa-plus-circle"></i> Erstellen
|
||||||
|
</a>
|
||||||
|
</td>
|
||||||
|
<td class="col-actions">
|
||||||
|
<button class="icon-btn" @click.prevent="openEditModal(item)" title="Bearbeiten"><i class="fa-duotone fa-pen"></i></button>
|
||||||
|
<button class="icon-btn" @click.prevent="openHistoryModal(item)" title="Verlauf"><i class="fa-duotone fa-clock-rotate-left"></i></button>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
<!-- Loading State -->
|
||||||
|
<div v-if="isLoading" class="table-placeholder">
|
||||||
|
<i class="fa-duotone fa-spinner fa-spin"></i>
|
||||||
|
<span>Lade Netzgebiete...</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Empty State -->
|
||||||
|
<div v-if="!isLoading && !filteredNetzgebiete.length" class="table-placeholder">
|
||||||
|
<i class="fa-duotone fa-database"></i>
|
||||||
|
<span>Keine Netzgebiete gefunden.</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Pagination -->
|
||||||
|
<div class="pagination-bar" v-if="!isLoading && filteredNetzgebiete.length">
|
||||||
|
<div class="pagination-info">
|
||||||
|
{{ paginationStart }}–{{ paginationEnd }} von {{ filteredNetzgebiete.length }} Netzgebieten
|
||||||
|
</div>
|
||||||
|
<div class="pagination-controls">
|
||||||
|
<select v-model.number="pageSize" @change="currentPage = 1" class="page-size-select">
|
||||||
|
<option :value="25">25</option>
|
||||||
|
<option :value="50">50</option>
|
||||||
|
<option :value="100">100</option>
|
||||||
|
</select>
|
||||||
|
<button class="icon-btn" :disabled="currentPage <= 1" @click="currentPage--"><i class="fa-duotone fa-chevron-left"></i></button>
|
||||||
|
<span class="page-indicator">{{ currentPage }} / {{ totalPages }}</span>
|
||||||
|
<button class="icon-btn" :disabled="currentPage >= totalPages" @click="currentPage++"><i class="fa-duotone fa-chevron-right"></i></button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<!-- Edit/Create Modal -->
|
||||||
|
<tt-dialog :show="showEditModal" :title="editItem && editItem.id ? 'Netzgebiet bearbeiten' : 'Neues Netzgebiet'" size="wide" @close="showEditModal = false">
|
||||||
|
<div v-if="editItem" class="modal-form">
|
||||||
|
<div class="form-grid">
|
||||||
|
<div class="field span-2">
|
||||||
|
<label>Name *</label>
|
||||||
|
<input class="ri" v-model="editItem.name" placeholder="Name des Netzgebiets">
|
||||||
|
</div>
|
||||||
|
<div class="field">
|
||||||
|
<label>Externe Referenz</label>
|
||||||
|
<input class="ri" v-model="editItem.extref" placeholder="ExtRef">
|
||||||
|
</div>
|
||||||
|
<div class="field">
|
||||||
|
<label>Quelle</label>
|
||||||
|
<div class="select">
|
||||||
|
<select v-model="editItem.source">
|
||||||
|
<option value="">Bitte wählen...</option>
|
||||||
|
<option value="rimo-rest-api">rimo-rest-api</option>
|
||||||
|
<option value="csv">csv</option>
|
||||||
|
<option value="csv-rimo">csv-rimo</option>
|
||||||
|
<option value="manual">manual</option>
|
||||||
|
<option value="xinon_qgis">xinon_qgis</option>
|
||||||
|
<option value="citycom-oan-api">citycom-oan-api</option>
|
||||||
|
<option value="test">test</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="field">
|
||||||
|
<label>Source ID</label>
|
||||||
|
<input class="ri" v-model="editItem.source_id" placeholder="Source ID">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-section">
|
||||||
|
<label class="section-label">Freigaben</label>
|
||||||
|
<div class="checkbox-row">
|
||||||
|
<label v-for="f in freigabeOptions" :key="f.key" class="checkbox-field">
|
||||||
|
<input type="checkbox" v-model="editItem.freigabe[f.key]">
|
||||||
|
<span>{{ f.label }}</span>
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-section">
|
||||||
|
<label class="section-label">Optionen</label>
|
||||||
|
<div class="options-grid">
|
||||||
|
<label v-for="opt in optionsConfig" :key="opt.key" class="checkbox-field" :title="opt.tooltip">
|
||||||
|
<input type="checkbox" v-model="editItem.options[opt.key]" :true-value="1" :false-value="0">
|
||||||
|
<span>{{ opt.label }}</span>
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
<div class="form-grid mt-3">
|
||||||
|
<div class="field">
|
||||||
|
<label>MPH Min Homes (Auto-Zählung)</label>
|
||||||
|
<input class="ri" type="number" v-model.number="editItem.options.mph_min_homes_tool_automatic_count" min="0">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<template #footer>
|
||||||
|
<button class="ghost-btn" @click="showEditModal = false" :disabled="isSaving">Abbrechen</button>
|
||||||
|
<button class="primary-btn" @click="saveNetzgebiet" :disabled="isSaving || !editItem?.name">
|
||||||
|
<span v-if="!isSaving">Speichern</span>
|
||||||
|
<span v-else class="btn-loader"></span>
|
||||||
|
</button>
|
||||||
|
</template>
|
||||||
|
</tt-dialog>
|
||||||
|
|
||||||
|
<!-- History Modal -->
|
||||||
|
<tt-dialog :show="showHistoryModal" :title="historyTitle" size="wide" @close="showHistoryModal = false">
|
||||||
|
<div class="history-container">
|
||||||
|
<div v-if="historyLoading" class="table-placeholder compact">
|
||||||
|
<i class="fa-duotone fa-spinner fa-spin"></i>
|
||||||
|
</div>
|
||||||
|
<div v-else-if="!filteredHistory.length" class="table-placeholder compact">
|
||||||
|
<i class="fa-duotone fa-clock-rotate-left"></i>
|
||||||
|
<span>Kein Verlauf vorhanden.</span>
|
||||||
|
</div>
|
||||||
|
<div v-else class="history-list">
|
||||||
|
<div v-for="entry in filteredHistory" :key="entry.id" class="history-entry" :class="'action-' + entry.action">
|
||||||
|
<div class="history-icon">
|
||||||
|
<i v-if="entry.action === 'update'" class="fa-duotone fa-pen-to-square"></i>
|
||||||
|
<i v-else-if="entry.action === 'create'" class="fa-duotone fa-plus-circle"></i>
|
||||||
|
<i v-else-if="entry.action === 'delete'" class="fa-duotone fa-trash-can"></i>
|
||||||
|
</div>
|
||||||
|
<div class="history-content">
|
||||||
|
<div class="history-header">
|
||||||
|
<strong>{{ translateAction(entry.action) }}</strong>
|
||||||
|
<span v-if="entry.action === 'update'" class="field-label">{{ translateField(entry.field) }}</span>
|
||||||
|
<span class="history-meta">{{ entry.user_name || 'System' }} · {{ formatTimestamp(entry.timestamp) }}</span>
|
||||||
|
</div>
|
||||||
|
<div v-if="entry.action === 'update'" class="history-diff">
|
||||||
|
<span class="diff-old" :class="{ expandable: isLongValue(entry.field, entry.old_value), expanded: expandedIds[entry.id + '_old'] }" @click="toggleExpand(entry.id + '_old')">{{ formatValue(entry.field, entry.old_value) }}</span>
|
||||||
|
<i class="fa-duotone fa-arrow-right"></i>
|
||||||
|
<span class="diff-new" :class="{ expandable: isLongValue(entry.field, entry.new_value), expanded: expandedIds[entry.id + '_new'] }" @click="toggleExpand(entry.id + '_new')">{{ formatValue(entry.field, entry.new_value) }}</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</tt-dialog>
|
||||||
|
</div>
|
||||||
|
`,
|
||||||
|
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
window: window,
|
||||||
|
isLoading: true,
|
||||||
|
isSaving: false,
|
||||||
|
netzgebiete: [],
|
||||||
|
currentPage: 1,
|
||||||
|
pageSize: 50,
|
||||||
|
filters: { name: '', extref: '', source: '', hasNetwork: '', hasCampaign: '', hasConsent: '' },
|
||||||
|
filterDebounce: null,
|
||||||
|
showEditModal: false,
|
||||||
|
editItem: null,
|
||||||
|
showHistoryModal: false,
|
||||||
|
historyLoading: false,
|
||||||
|
historyItems: [],
|
||||||
|
historyTitle: 'Verlauf',
|
||||||
|
expandedIds: {},
|
||||||
|
freigabeLabels: { interest: 'Interest', provision: 'Provision', order: 'Order', reorder: 'Reorder' },
|
||||||
|
freigabeOptions: [
|
||||||
|
{ key: 'interest', label: 'Interest' },
|
||||||
|
{ key: 'provision', label: 'Provision' },
|
||||||
|
{ key: 'order', label: 'Order' },
|
||||||
|
{ key: 'reorder', label: 'Reorder' }
|
||||||
|
],
|
||||||
|
optionsConfig: [
|
||||||
|
{ key: 'create_address_parts', label: 'create_address_parts', tooltip: 'Neue Straßen/PLZ/Ort anlegen' },
|
||||||
|
{ key: 'update_freigabe', label: 'update_freigabe', tooltip: 'Setzt Freigabe auf Basis Netzgebiet' },
|
||||||
|
{ key: 'update_address', label: 'update_address', tooltip: 'Straßennamen ändern' },
|
||||||
|
{ key: 'hausnummer_dont_overwrite_netzgebiet', label: 'dont_overwrite_netzgebiet', tooltip: 'Netzgebiete nicht überschreiben' },
|
||||||
|
{ key: 'create_preorder', label: 'create_preorder', tooltip: 'Bestellungen erstellen (SBIDI)' },
|
||||||
|
{ key: 'preorder_only_oaid', label: 'preorder_only_oaid', tooltip: 'SBIDI OAID aus RIMO' },
|
||||||
|
{ key: 'wo_ignore_status', label: 'wo_ignore_status', tooltip: 'Status ignorieren' },
|
||||||
|
{ key: 'delete_units', label: 'delete_units', tooltip: 'Homes löschen die nicht in RIMO sind' },
|
||||||
|
{ key: 'unit_create_oaid', label: 'unit_create_oaid', tooltip: 'OAID bei Unit erstellen' }
|
||||||
|
],
|
||||||
|
defaultOptions: {
|
||||||
|
create_address_parts: 0, update_freigabe: 1, update_address: 1,
|
||||||
|
hausnummer_dont_overwrite_netzgebiet: 0, create_preorder: 0,
|
||||||
|
preorder_only_oaid: 0, wo_ignore_status: 0, delete_units: 0,
|
||||||
|
mph_min_homes_tool_automatic_count: 3, unit_create_oaid: 0
|
||||||
|
}
|
||||||
|
};
|
||||||
|
},
|
||||||
|
|
||||||
|
computed: {
|
||||||
|
availableSources() {
|
||||||
|
const sources = new Set();
|
||||||
|
this.netzgebiete.forEach(item => {
|
||||||
|
if (item.netzgebiet?.source) sources.add(item.netzgebiet.source);
|
||||||
|
});
|
||||||
|
return Array.from(sources).sort();
|
||||||
|
},
|
||||||
|
hasActiveFilters() {
|
||||||
|
return Object.values(this.filters).some(v => v);
|
||||||
|
},
|
||||||
|
filteredNetzgebiete() {
|
||||||
|
return this.netzgebiete.filter(item => {
|
||||||
|
const n = item.netzgebiet;
|
||||||
|
if (!n) return false;
|
||||||
|
if (this.filters.name && !n.name?.toLowerCase().includes(this.filters.name.toLowerCase())) return false;
|
||||||
|
if (this.filters.extref && !n.extref?.toLowerCase().includes(this.filters.extref.toLowerCase())) return false;
|
||||||
|
if (this.filters.source && n.source !== this.filters.source) return false;
|
||||||
|
const hasNetwork = item.related?.networks?.length > 0;
|
||||||
|
const hasCampaign = item.related?.campaigns?.length > 0;
|
||||||
|
const hasConsent = item.related?.consent_projects?.length > 0;
|
||||||
|
if (this.filters.hasNetwork === 'yes' && !hasNetwork) return false;
|
||||||
|
if (this.filters.hasNetwork === 'no' && hasNetwork) return false;
|
||||||
|
if (this.filters.hasCampaign === 'yes' && !hasCampaign) return false;
|
||||||
|
if (this.filters.hasCampaign === 'no' && hasCampaign) return false;
|
||||||
|
if (this.filters.hasConsent === 'yes' && !hasConsent) return false;
|
||||||
|
if (this.filters.hasConsent === 'no' && hasConsent) return false;
|
||||||
|
return true;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
totalPages() { return Math.ceil(this.filteredNetzgebiete.length / this.pageSize) || 1; },
|
||||||
|
paginatedItems() {
|
||||||
|
const start = (this.currentPage - 1) * this.pageSize;
|
||||||
|
return this.filteredNetzgebiete.slice(start, start + this.pageSize);
|
||||||
|
},
|
||||||
|
paginationStart() { return this.filteredNetzgebiete.length ? (this.currentPage - 1) * this.pageSize + 1 : 0; },
|
||||||
|
paginationEnd() { return Math.min(this.currentPage * this.pageSize, this.filteredNetzgebiete.length); },
|
||||||
|
filteredHistory() {
|
||||||
|
return this.historyItems.filter(e => !['edit', 'create'].includes(e.field));
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
watch: {
|
||||||
|
filteredNetzgebiete() { if (this.currentPage > this.totalPages) this.currentPage = 1; }
|
||||||
|
},
|
||||||
|
|
||||||
|
async mounted() { await this.fetchNetzgebiete(); },
|
||||||
|
|
||||||
|
methods: {
|
||||||
|
debouncedFilter() {
|
||||||
|
clearTimeout(this.filterDebounce);
|
||||||
|
this.filterDebounce = setTimeout(() => this.currentPage = 1, 300);
|
||||||
|
},
|
||||||
|
applyFilter() { this.currentPage = 1; },
|
||||||
|
clearFilters() {
|
||||||
|
this.filters = { name: '', extref: '', source: '', hasNetwork: '', hasCampaign: '', hasConsent: '' };
|
||||||
|
this.currentPage = 1;
|
||||||
|
},
|
||||||
|
async fetchNetzgebiete() {
|
||||||
|
this.isLoading = true;
|
||||||
|
try {
|
||||||
|
const response = await axios.get(window.TT_CONFIG.GET_URL);
|
||||||
|
this.netzgebiete = response.data.success ? (response.data.data || []) : (response.data || []);
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Fehler:', error);
|
||||||
|
window.notify?.('error', 'Netzgebiete konnten nicht geladen werden.');
|
||||||
|
} finally {
|
||||||
|
this.isLoading = false;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
parsedFreigabe(json) {
|
||||||
|
try { return JSON.parse(json || '[]') || []; }
|
||||||
|
catch { return []; }
|
||||||
|
},
|
||||||
|
openCreateModal() {
|
||||||
|
this.editItem = {
|
||||||
|
id: null, name: '', extref: '', source: '', source_id: '',
|
||||||
|
freigabe: { interest: true, provision: true, order: true, reorder: true },
|
||||||
|
options: { ...this.defaultOptions }
|
||||||
|
};
|
||||||
|
this.showEditModal = true;
|
||||||
|
},
|
||||||
|
openEditModal(item) {
|
||||||
|
const n = item.netzgebiet;
|
||||||
|
let options = {};
|
||||||
|
try { options = JSON.parse(n.options || '{}'); } catch {}
|
||||||
|
let freigabeArr = [];
|
||||||
|
try { freigabeArr = JSON.parse(n.freigabe || '[]') || []; } catch {}
|
||||||
|
const freigabeObj = {};
|
||||||
|
['interest', 'provision', 'order', 'reorder'].forEach(f => freigabeObj[f] = freigabeArr.includes(f));
|
||||||
|
this.editItem = {
|
||||||
|
id: n.id, name: n.name || '', extref: n.extref || '',
|
||||||
|
source: n.source || '', source_id: n.source_id || '',
|
||||||
|
freigabe: freigabeObj,
|
||||||
|
options: { ...this.defaultOptions, ...options }
|
||||||
|
};
|
||||||
|
this.showEditModal = true;
|
||||||
|
},
|
||||||
|
async saveNetzgebiet() {
|
||||||
|
if (!this.editItem?.name) return;
|
||||||
|
this.isSaving = true;
|
||||||
|
const freigabeArray = Object.keys(this.editItem.freigabe).filter(k => this.editItem.freigabe[k]);
|
||||||
|
const payload = {
|
||||||
|
id: this.editItem.id, name: this.editItem.name, extref: this.editItem.extref,
|
||||||
|
source: this.editItem.source, source_id: this.editItem.source_id,
|
||||||
|
freigabe: freigabeArray, options: this.editItem.options
|
||||||
|
};
|
||||||
|
try {
|
||||||
|
const response = await axios.post(window.TT_CONFIG.SAVE_URL, payload);
|
||||||
|
if (response.data.success) {
|
||||||
|
window.notify?.('success', response.data.message);
|
||||||
|
this.showEditModal = false;
|
||||||
|
await this.fetchNetzgebiete();
|
||||||
|
} else {
|
||||||
|
window.notify?.('error', response.data.message || 'Fehler beim Speichern.');
|
||||||
|
}
|
||||||
|
} catch { window.notify?.('error', 'Netzwerkfehler.'); }
|
||||||
|
finally { this.isSaving = false; }
|
||||||
|
},
|
||||||
|
async openHistoryModal(item) {
|
||||||
|
this.historyTitle = `Verlauf: ${item.netzgebiet.name}`;
|
||||||
|
this.showHistoryModal = true;
|
||||||
|
this.historyLoading = true;
|
||||||
|
this.historyItems = [];
|
||||||
|
try {
|
||||||
|
const response = await axios.get(window.TT_CONFIG.HISTORY_URL + '?id=' + item.netzgebiet.id);
|
||||||
|
this.historyItems = response.data.success ? (response.data.data || []) : (response.data || []);
|
||||||
|
} catch { window.notify?.('error', 'Verlauf konnte nicht geladen werden.'); }
|
||||||
|
finally { this.historyLoading = false; }
|
||||||
|
},
|
||||||
|
translateAction(action) { return { create: 'Erstellt', update: 'Geändert', delete: 'Gelöscht' }[action] || action; },
|
||||||
|
translateField(field) {
|
||||||
|
return { name: 'Name', extref: 'ExtRef', source: 'Quelle', source_id: 'Source ID',
|
||||||
|
freigabe: 'Freigaben', options: 'Optionen', unit_counts: 'Einheiten' }[field] || field;
|
||||||
|
},
|
||||||
|
formatTimestamp(ts) {
|
||||||
|
if (!ts) return '—';
|
||||||
|
try { return new Date(ts.replace(' ', 'T')).toLocaleString('de-AT'); }
|
||||||
|
catch { return ts; }
|
||||||
|
},
|
||||||
|
formatValue(field, value) {
|
||||||
|
if (value === null || value === undefined || value === '') return '—';
|
||||||
|
if (['freigabe', 'options'].includes(field)) {
|
||||||
|
try {
|
||||||
|
const parsed = typeof value === 'string' ? JSON.parse(value) : value;
|
||||||
|
if (field === 'freigabe' && Array.isArray(parsed)) return parsed.join(', ') || '—';
|
||||||
|
if (field === 'options' && typeof parsed === 'object') {
|
||||||
|
const entries = Object.entries(parsed).filter(([,v]) => v !== 0 && v !== '0');
|
||||||
|
return entries.map(([k,v]) => `${k}: ${v}`).join(', ') || '—';
|
||||||
|
}
|
||||||
|
} catch {}
|
||||||
|
}
|
||||||
|
return String(value);
|
||||||
|
},
|
||||||
|
isLongValue(field, value) {
|
||||||
|
return this.formatValue(field, value).length > 40;
|
||||||
|
},
|
||||||
|
toggleExpand(id) {
|
||||||
|
this.expandedIds[id] = !this.expandedIds[id];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
if (window.VueApp) {
|
||||||
|
window.VueApp.component('a-d-b-netzgebiet', ADBNetzgebiet);
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user