Overhauled Address linking

This commit is contained in:
Frank Schubert
2022-06-29 17:16:14 +02:00
parent bbfc6c6eb5
commit 2d09924372
12 changed files with 637 additions and 74 deletions

View File

@@ -1,4 +1,17 @@
<?php //var_dump($address->parent->types);exit;?>
<?php
$urlfilter = [];
if($s) {
$urlfilter['s'] = $s;
}
if($f) {
$urlfilter['f'] = $f;
}
if(is_array($filter) && count($filter)) {
$urlfilter["filter"] = $filter;
}
$posturl = self::getUrl("Address", "save", $urlfilter);
?>
<?php include(realpath(dirname(__FILE__)."/../../$mfLayoutPackage")."/header.php"); ?>
<!-- start page title -->
@@ -7,8 +20,11 @@
<div class="page-title-box">
<div class="page-title-right">
<ol class="breadcrumb m-0">
<li class="breadcrumb-item"><a href="javascript: void(0);"><?=MFAPPNAME_SLUG?></a></li>
<li class="breadcrumb-item"><a href="javascript: void(0);">Personen & Firmen</a></li>
<li class="breadcrumb-item"><a href="<?=self::getUrl("Dashboard")?>"><?=MFAPPNAME_SLUG?></a></li>
<li class="breadcrumb-item"><a href="<?=self::getUrl("Address")?>">Personen & Firmen</a></li>
<?php if($address->id): ?>
<li class="breadcrumb-item"><a href="<?=self::getUrl("Address", "View", ['id' => $address->id])?>"><?=$address->getCompanyOrName()?> [<?=$address->customer_number?>]</a></li>
<?php endif; ?>
<li class="breadcrumb-item active"><?=($address->id) ? "bearbeiten" : "Neu" ?></li>
</ol>
</div>
@@ -25,24 +41,12 @@
<div class="card-body">
<h4><?=($address->id) ? "Person/Firma bearbeiten" : "Neue Person/Firma"?></h4>
<form class="form-horizontal" method="post" name="addressForm" id="addressForm" action="<?=self::getUrl("Address", "save")?>">
<form class="form-horizontal" method="post" name="addressForm" id="addressForm" action="<?=$posturl?>">
<div class="card">
<div class="card-body">
<input type="hidden" name="id" value="<?=$address->id?>" />
<div class="form-group row">
<label class="col-lg-2 col-form-label" for="parent_id">Zugeordnet zu</label>
<div class="col-lg-10">
<select class="select2 form-control " name="parent_id" id="parent_id">
<option></option>
<?php foreach($parents as $parent): if($parent->id == $address->id) continue; ?>
<option value="<?=$parent->id?>" <?=($address->parent_id == $parent->id) ? "selected='selected'" : ""?>><?=($parent->company) ? $parent->company : $parent->getFullName()?></option>
<?php endforeach; ?>
</select>
</div>
</div>
<div class="form-group row">
<label class="col-lg-2 col-form-label" for="customer_number">Kundennummer</label>
<div class="col-lg-10">
@@ -156,23 +160,9 @@
<label class="col-lg-2 col-form-label" for="addresstypes">Rolle</label>
<div class="col-lg-10">
<select class="select2 form-control select2-multiple" name="addresstypes[]" id="addresstypes" multiple="multiple" data-placeholder="Choose ...">
<option value="systemowner" <?=(array_key_exists("systemowner", $address->types)) ? "selected='selected'" : ""?>><?=__("systemowner")?></option>
<option value="productowner" <?=(array_key_exists("productowner", $address->types)) ? "selected='selected'" : ""?>><?=__("productowner")?></option>
<option value="netowner" <?=(array_key_exists("netowner", $address->types)) ? "selected='selected'" : "netowner"?>><?=__("netowner")?></option>
<option value="salespartner" <?=(array_key_exists("salespartner", $address->types)) ? "selected='selected'" : "salespartner"?>><?=__("salespartner")?></option>
<option value="pipeworker" <?=(array_key_exists("pipeworker", $address->types)) ? "selected='selected'" : "pipeworker"?>><?=__("pipeworker")?></option>
<option value="lineworker" <?=(array_key_exists("lineworker", $address->types)) ? "selected='selected'" : "lineworker"?>><?=__("lineworker")?></option>
<option value="pipeplanner" <?=(array_key_exists("pipeplanner", $address->types)) ? "selected='selected'" : "pipeplanner"?>><?=__("pipeplanner")?></option>
<option value="lineplanner" <?=(array_key_exists("lineplanner", $address->types)) ? "selected='selected'" : "lineplanner"?>><?=__("lineplanner")?></option>
<option value="netoperator" <?=(array_key_exists("netoperator", $address->types)) ? "selected='selected'" : "netoperator"?>><?=__("netoperator")?></option>
<option value="support" <?=(array_key_exists("support", $address->types)) ? "selected='selected'" : "support"?>><?=__("support")?></option>
<option value="billing" <?=(array_key_exists("billing", $address->types)) ? "selected='selected'" : ""?>><?=__("billing")?></option>
<option value="employee" <?=(array_key_exists("employee", $address->types)) ? "selected='selected'" : ""?>><?=__("employee")?></option>
<option value="customer" <?=(array_key_exists("customer", $address->types)) ? "selected='selected'" : ""?>><?=__("customer")?></option>
<option value="supplier" <?=(array_key_exists("supplier", $address->types)) ? "selected='selected'" : ""?>><?=__("supplier")?></option>
<option value="contact" <?=(array_key_exists("contact", $address->types)) ? "selected='selected'" : ""?>><?=__("contact")?></option>
<option value="techcontact" <?=(array_key_exists("techcontact", $address->types)) ? "selected='selected'" : ""?>><?=__("techcontact")?></option>
<?php foreach(TT_ROLES as $role): ?>
<option value="<?=$role?>" <?=(array_key_exists($role, $address->types)) ? "selected='selected'" : ""?>><?=__($role)?></option>
<?php endforeach; ?>
</select>
</div>
</div>
@@ -256,11 +246,11 @@
</div>
</div>
<h4>Verknüpfte Adressen</h4>
<h4>Verknüpfungen</h4>
<div class="card">
<div class="card-body" id="link-container">
<table class="table table-striped table-sm">
<table class="table table-striped table-sm table-bordered">
<tr>
<th>Typ</th>
<th>Firma</th>
@@ -271,20 +261,20 @@
<th>Email</th>
<th></th>
</tr>
<?php foreach(['techcontact'] as $type): ?>
<?php foreach(TT_ADDRESS_LINK_TYPES as $type): ?>
<?php if(array_key_exists($type, $address->links)): ?>
<?php foreach($address->links[$type] as $addr): ?>
<?php foreach($address->links[$type] as $link): ?>
<tr>
<td class="font-weight-bold"><?=__($type)?></td>
<td><?=$addr->address->company?></td>
<td><?=$addr->address->firstname?></td>
<td><?=$addr->address->lastname?></td>
<td><?=$addr->address->phone?></td>
<td><?=$addr->address->mobile?></td>
<td><?=$addr->address->email?></td>
<td><a href="<?=self::getUrl("Address", "view", ["id" => $link->address_id])?>" target="_blank"><?=$link->address->company?></a></td>
<td><a href="<?=self::getUrl("Address", "view", ["id" => $link->address_id])?>" target="_blank"><?=$link->address->firstname?></a></td>
<td><a href="<?=self::getUrl("Address", "view", ["id" => $link->address_id])?>" target="_blank"><?=$link->address->lastname?></a></td>
<td><?=$link->address->phone?></td>
<td><?=$link->address->mobile?></td>
<td><?=$link->address->email?></td>
<td>
<a class="mr-2" href="<?=self::getUrl("Address", "edit", ["id" => $address->id])?>"><i class="far fa-edit" title="Bearbeiten"></i></a>
<a href="<?=self::getUrl("Address", "deleteLink", ["id" => $address->id])?>" onclick="if(!confirm('Verknüpgung wirklich löschen?')) return false;" class="text-danger" title="Verknüpfung löschen"><i class="fas fa-xmark-large"></i></a>
<a class="mr-2" href="<?=self::getUrl("Address", "view", ["id" => $link->address_id])?>" target="_blank"><i class="far fa-eyes" title="Anzeigen"></i></a>
<a href="<?=self::getUrl("Address", "deleteLink", ["id" => $link->id])?>" onclick="if(!confirm('Verknüpfung wirklich entfernen?')) return false;" class="text-danger" title="Verknüpfung entfernen"><i class="fas fa-xmark-large"></i></a>
</td>
</tr>
<?php endforeach; ?>
@@ -303,10 +293,12 @@
<div class="input-group mb-3">
<div class="input-group-prepend">
<select class="form-control" name="links[<?=$linknum?>][type]">
<option value="techcontact">Technischer Kontakt</option>
<?php foreach(TT_ADDRESS_LINK_TYPES as $type): ?>
<option value="<?=$type?>"><?=__($type)?></option>
<?php endforeach; ?>
</select>
</div>
<select class="form-control basicAutoComplete link-autocomplete" autocomplete="off" name="links[<?=$linknum?>][address_id]" id="links_<?=$linknum?>_address_id" data-linknum="<?=$linknum?>" data-url="<?=self::getUrl('Address','api')?>?do=findAddress&autocomplete=1&role=techcontact" placeholder="Name, Kundennummer, ID" data-noresults-text="Keine Suchergebnisse">
<select class="form-control basicAutoComplete link-autocomplete" autocomplete="off" name="links[<?=$linknum?>][address_id]" id="links_<?=$linknum?>_address_id" data-linknum="<?=$linknum?>" data-url="<?=self::getUrl('Address','api')?>?do=findAddress&autocomplete=1" placeholder="Name, Kundennummer, ID" data-noresults-text="Keine Suchergebnisse">
<option></option>
</select>
@@ -321,6 +313,25 @@
</div>
<?php if(is_array($address->linked_as) && count($address->linked_as)): ?>
<h4>Verknüpft als</h4>
<div class="card">
<div class="card-body" id="link-container">
<table class="table-sm table-striped">
<?php foreach(TT_ADDRESS_LINK_TYPES as $type): ?>
<?php if(array_key_exists($type, $address->linked_as)): ?>
<?php foreach($address->linked_as[$type] as $link): ?>
<tr>
<td><?=__($type)?> für:</td>
<td><a href="<?=self::getUrl("Address", "view", ['id' => $link->origin_address_id])?>" target="_blank"><?=$link->origin->getCompanyOrName()?><?=($link->origin->customer_number) ? " [".$link->origin->customer_number."]" : ""?></a></td>
</tr>
<?php endforeach; ?>
<?php endif; ?>
<?php endforeach; ?>
</table>
</div>
</div>
<?php endif; ?>
<div class="card">
<div class="card-body">
<div class="form-group row">
@@ -337,7 +348,9 @@
<div class="form-group row">
<label class="col-lg-2"></label>
<div class="col-lg-10">
<button type="submit" class="btn btn-primary">Speichern</button> <span id="error" class="hidden ml-2 alert alert-danger text-danger">Fehler: Ungültige IBAN</span>
<button type="submit" class="btn btn-primary mr-1">Speichern</button>
<button type="submit" name="return" value="index" class="btn btn-primary">Speichern und zur Übersicht</button>
<span id="error" class="hidden ml-2 alert alert-danger text-danger">Fehler: Ungültige IBAN</span>
</div>
</div>