Files
thetool/Layout/default/Address/Index.php
2024-11-05 12:16:10 +01:00

398 lines
23 KiB
PHP

<?php
$pagination_baseurl = $this->getUrl($Mod,"Index");
$pagination_baseurl_params = ["filter" => $filter];
$pagination_entity_name = "Adressen";
?>
<?php include(realpath(dirname(__FILE__)."/../../$mfLayoutPackage")."/header.php"); ?>
<!-- start page title -->
<div class="row">
<div class="col-12">
<div class="page-title-box">
<div class="page-title-right">
<ol class="breadcrumb m-0">
<li class="breadcrumb-item"><a href="<?=self::getUrl("Dashboard")?>"><?=MFAPPNAME_SLUG?></a></li>
<?php if(is_array($filter['addresstype']) && count($filter['addresstype'])): ?>
<li class="breadcrumb-item"><a href="<?=self::getUrl("Address")?>">Personen & Firmen</a></li>
<li class="breadcrumb-item active">
<?php foreach($filter['addresstype'] as $type) { $types[] = __($type); } ?>
<?=implode(", ", $types)?>
</li>
<?php else: ?>
<li class="breadcrumb-item active">Personen & Firmen</li>
<?php endif; ?>
</ol>
</div>
<h4 class="page-title">Personen & Firmen</h4>
</div>
</div>
</div>
<!-- end page title -->
<div class="row">
<div class="col-lg-12">
<?php if($me->can("Fibu")): ?>
<div class="card">
<div class="card-body">
<div class="row">
<div class="col">
<a href="#" class="ml-2 btn btn-outline-primary" onclick="startBmdExport(event, 'inc')"><i class="fas fa-down-from-dotted-line fa-fw"></i> Inkrementellen BMD-Export starten</a>
<?php if($last_bmd_export): ?><small>Letzter Export: <?=date("d.m.Y H:i", $last_bmd_export)?></small><?php endif; ?>
<a href="#" class="btn btn-outline-danger float-right" onclick="startBmdExport(event, 'full')"><i class="fas fa-down-from-line fa-fw"></i> Vollen BMD-Export starten</a>
<img src="img/ajax-loader.gif" class="float-right mr-2 hidden" id="bmd-export-loader" />
</div>
</div>
</div>
</div>
<?php endif; ?>
<div class="card">
<div class="card-body mb-3">
<h4 class="header-title mb-3"><i class="fad fa-filter fa-fw"></i> Filter</h4>
<form method="get" action="<?=self::getUrl("Address")?>">
<div class="row">
<?php if($me->is("Admin")): ?>
<div class="col-2">
<label class="form-label" for="filter_addresstype">Rolle</label>
<select name="filter[addresstype][]" id="filter_addresstype" class="form-control" multiple="multiple">
<option value="systemowner" <?=(array_key_exists("addresstype", $filter) && in_array("systemowner", $filter["addresstype"])) ? "selected='selected'" : ""?>><?=__("systemowner")?></option>
<option value="productowner" <?=(array_key_exists("addresstype", $filter) && in_array("productowner", $filter["addresstype"])) ? "selected='selected'" : ""?>><?=__("productowner")?></option>
<option value="netowner" <?=(array_key_exists("addresstype", $filter) && in_array("netowner", $filter["addresstype"])) ? "selected='selected'" : "netowner"?>><?=__("netowner")?></option>
<option value="salespartner" <?=(array_key_exists("addresstype", $filter) && in_array("salespartner", $filter["addresstype"])) ? "selected='selected'" : "salespartner"?>><?=__("salespartner")?></option>
<option value="pipeworker" <?=(array_key_exists("addresstype", $filter) && in_array("pipeworker", $filter["addresstype"])) ? "selected='selected'" : "pipeworker"?>><?=__("pipeworker")?></option>
<option value="lineworker" <?=(array_key_exists("addresstype", $filter) && in_array("lineworker", $filter["addresstype"])) ? "selected='selected'" : "lineworker"?>><?=__("lineworker")?></option>
<option value="pipeplanner" <?=(array_key_exists("addresstype", $filter) && in_array("pipeplanner", $filter["addresstype"])) ? "selected='selected'" : "pipeplanner"?>><?=__("pipeplanner")?></option>
<option value="lineplanner" <?=(array_key_exists("addresstype", $filter) && in_array("lineplanner", $filter["addresstype"])) ? "selected='selected'" : "lineplanner"?>><?=__("lineplanner")?></option>
<option value="netoperator" <?=(array_key_exists("addresstype", $filter) && in_array("netoperator", $filter["addresstype"])) ? "selected='selected'" : "netoperator"?>><?=__("netoperator")?></option>
<option value="support" <?=(array_key_exists("addresstype", $filter) && in_array("support", $filter["addresstype"])) ? "selected='selected'" : "support"?>><?=__("support")?></option>
<option value="billing" <?=(array_key_exists("addresstype", $filter) && in_array("billing", $filter["addresstype"])) ? "selected='selected'" : ""?>><?=__("billing")?></option>
<option value="employee" <?=(array_key_exists("addresstype", $filter) && in_array("employee", $filter["addresstype"])) ? "selected='selected'" : ""?>><?=__("employee")?></option>
<option value="customer" <?=(array_key_exists("addresstype", $filter) && in_array("customer", $filter["addresstype"])) ? "selected='selected'" : ""?>><?=__("customer")?></option>
<option value="supplier" <?=(array_key_exists("addresstype", $filter) && in_array("supplier", $filter["addresstype"])) ? "selected='selected'" : ""?>><?=__("supplier")?></option>
<option value="contact" <?=(array_key_exists("addresstype", $filter) && in_array("contact", $filter["addresstype"])) ? "selected='selected'" : ""?>><?=__("contact")?></option>
<option value="techcontact" <?=(array_key_exists("addresstype", $filter) && in_array("techcontact", $filter["addresstype"])) ? "selected='selected'" : ""?>><?=__("techcontact")?></option>
</select>
</div>
<?php endif; ?>
<div class="col-1">
<label class="form-label" for="filter_customer_number">Kundennummer</label>
<input type="text" class="form-control" name="filter[customer_number]" id="filter_customer_number" value="<?=(array_key_exists('customer_number', $filter)) ? $filter['customer_number'] : ""?>" />
</div>
<div class="col-1">
<label class="form-label" for="filter_spin">Service PIN</label>
<input type="text" class="form-control" name="filter[spin]" id="filter_spin" value="<?=(array_key_exists('spin', $filter)) ? $filter['spin'] : ""?>" />
</div>
<div class="col-1">
<label class="form-label" for="filter_fibu_account_number">FIBU Konto</label>
<input type="text" class="form-control" name="filter[fibu_account_number]" id="filter_fibu_account_number" value="<?=array_key_exists('fibu_account_number', $filter) ? $filter['fibu_account_number'] : ""?>" />
</div>
<div class="col-4">
<label class="form-label" for="filter_kunde">Kunde</label>
<input type="text" class="form-control" name="filter[kunde]" id="filter_kunde" value="<?=array_key_exists('kunde', $filter) ? $filter['kunde'] : ""?>" />
</div>
</div>
<div class="row mt-2">
<div class="col-2">
<label class="form-label" for="filter_street">Straße</label>
<input type="text" class="form-control" name="filter[street]" id="filter_street" value="<?=array_key_exists('street', $filter) ? $filter['street'] : ""?>" />
</div>
<div class="col-1">
<label class="form-label" for="filter_zip">PLZ</label>
<input type="text" class="form-control" name="filter[zip]" id="filter_zip" value="<?=array_key_exists('zip', $filter) ? $filter['zip'] : ""?>" />
</div>
<div class="col-1">
<label class="form-label" for="filter_city">Ort</label>
<input type="text" class="form-control" name="filter[city]" id="filter_city" value="<?=array_key_exists('city', $filter) ? $filter['city'] : ""?>" />
</div>
<div class="col-1">
<label class="form-label" for="filter_country">Land</label>
<input type="text" class="form-control" name="filter[country]" id="filter_country" value="<?=array_key_exists('country', $filter) ? $filter['country'] : ""?>" />
</div>
<div class="col-1">
<label class="form-label" for="filter_pfm">Telefon/Fax/Mobil</label>
<input type="text" class="form-control" name="filter[pfm]" id="filter_pfm" value="<?=array_key_exists('pfm', $filter) ? $filter['pfm'] : ""?>" />
</div>
<div class="col-1">
<label class="form-label" for="filter_email">Email</label>
<input type="text" class="form-control" name="filter[email]" id="filter_email" value="<?=array_key_exists('email', $filter) ? $filter['email'] : ""?>" />
</div>
<div class="col-1">
<label class="form-label" for="filter_note">Notiz</label>
<input type="text" class="form-control" name="filter[note]" id="filter_note" value="<?=array_key_exists('note', $filter) ? $filter['note'] : ""?>" />
</div>
<div class="col-1">
<label class="form-label" for="filter_type">Mandant</label>
<select class="form-control" name="filter[type]" id="filter_type">
<option value="<?=(array_key_exists('type', $filter) && $filter["type"] == "all") ? "selected='selected'" : ""?>">Alle</option>
<option value="xinon" <?=(array_key_exists('type', $filter) && $filter["type"] != "xinon") ? "" : "selected='selected'"?>>Xinon</option>
<option value="others" <?=(array_key_exists('type', $filter) && $filter["type"] == "others") ? "selected='selected'" : ""?>>Fremd</option>
</select>
</div>
</div>
<div class="row mt-2">
<div class="col">
<button type="submit" class="btn btn-primary"><i class="far fa-search fa-fw"></i> Filter anwenden</button>
<a class="btn btn-secondary" href="<?=self::getUrl("Address", "", ["resetFilter" => 1])?>"><i class="far fa-xmark fa-fw"></i> Filter zurücksetzen</a>
</div>
</div>
</form>
</div>
</div>
<div class="card">
<div class="card-body mb-3">
<div class="row">
<div class="col-12">
<div class="float-left">
<h4 class="header-title">Liste aller Personen & Firmen</h4>
</div>
<div class="float-right">
<a class="btn btn-primary" href="<?=self::getUrl("Address", "add")?>"><i class="fas fa-plus"></i> Neue Person/Firma anlegen</a>
</div>
</div>
</div>
<?php include(realpath(dirname(__FILE__)."/../")."/tpl/pagination.php"); ?>
<?php include(realpath(dirname(__FILE__)."/../")."/tpl/pagination-summary.php"); ?>
<table class="table table-striped table-hover">
<tr>
<th>Typ</th>
<th>Kundennummer</th>
<th>FIBU Konten</th>
<th>Firma</th>
<th>Name</th>
<th>Adresse</th>
<th>Telefon</th>
<th>Email</th>
<th></th>
</tr>
<?php foreach($addresses as $address): ?>
<tr>
<?php if(is_array($address->types) && count($address->types)):?>
<?php
$types = array_keys($address->types);
$l7d_types = [];
foreach($types as $type):
$l7d_types[] = __($type);
endforeach;
?>
<td title="<?=implode(", ", $l7d_types)?>">
<?=$l7d_types[0]?><?=(count($types) > 1) ? ", ..." : ""?>
</td>
<?php else: ?>
<td></td>
<?php endif; ?>
<td>
<a href="<?=self::getUrl("Address", "view", ["id" => $address->id, 's' => $pagination['start']])?>">
<?=$address->customer_number?>
<?=($address->spin) ? "<br /><span class='text-pink'>".$address->spin."</span>" : ""?>
</a>
</td>
<td>
<?php if($address->fibu_account_number): ?>
<span title="Verrechnungskonto"><?=$address->fibu_account_number?></span><?=($address->fibu_primary_account) ? " <i class='fas fa-check text-success' title='Primäres Verrechnungskonto'></i>" : ""?>
<?php endif; ?>
<?php if($address->fibu_supplier_number): ?>
<br /><span title="Lieferantenkonto"><?=$address->fibu_supplier_number?></span>
<?php endif; ?>
</td>
<td><a href="<?=self::getUrl("Address", "view", ["id" => $address->id, 's' => $pagination['start']])?>"><?=nl2br($address->company)?></a></td>
<td><a href="<?=self::getUrl("Address", "view", ["id" => $address->id, 's' => $pagination['start']])?>"><?=$address->getFullName()?></a></td>
<td>
<?=$address->street?><br />
<?=$address->zip?> <?=$address->city?>
</td>
<td><?=$address->phone?></td>
<td><?=$address->email?></td>
<td style="text-align: left; letter-spacing: 4px; font-size: 1.1em;">
<a href="<?=self::getUrl("User", "Index", ["filter" => ["address_id" => $address->id]])?>" title="Benutzer anzeigen"><i class="fas fa-users"></i></a>
<a href="<?=self::getUrl("Address", "view", ["id" => $address->id, 's' => $pagination['start']])?>"><i class="far fa-eyes" title="Anzeigen"></i></a>
<a href="#" onclick="openCreateTicketModal('<?=$address->getCompanyOrName()?>', '<?=$address->customer_number?>', '<?=$address->street . ', ' . $address->zip . ' ' . $address->city?>', '<?=$address->phone?>', '<?=$address->email?>', '<?=$address->spin?>')" title="Störungs-Ticket erstellen" class="text-warning"><i class="fas fa-exclamation-triangle"></i></a>
<a href="<?=self::getUrl("Address", "edit", ["id" => $address->id, 's' => $pagination['start']])?>"><i class="far fa-edit" title="Bearbeiten"></i></a>
<a href="<?=self::getUrl("Address", "delete", ["id" => $address->id, 's' => $pagination['start']])?>" onclick="if(!confirm('Person/Firma wirklich löschen?')) return false;" class="text-danger" title="Löschen"><i class="fas fa-trash"></i></a>
</td>
</tr>
<?php endforeach; ?>
</table>
<?php include(realpath(dirname(__FILE__)."/../")."/tpl/pagination.php"); ?>
<?php include(realpath(dirname(__FILE__)."/../")."/tpl/pagination-summary.php"); ?>
</div>
</div>
</div>
</div>
<!-- CREATE TICKET MODAL START -->
<!--add a bootstrap modal here and below add a new <script> which creates a form for self::getUrl("Address", "createTicket") with post parameters
string $subject, string $description, string $customer_name, string $customer_number, string $customer_address, string $customer_phone_number, string $customer_email, string $customer_service_ping
-->
<div class="modal" id="createTicketModal" tabindex="-1" role="dialog" aria-labelledby="createTicketModalLabel" aria-hidden="true">
<div class="modal-dialog modal-lg" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="createTicketModalLabel">Störungs-Ticket erstellen</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<div class="modal-body">
<form id="createTicketForm">
<div class="row">
<div class="col-6">
<label class="form-label required" for="subject">Betreff</label>
<input type="text" class="form-control" name="subject" id="subject" required="required" />
</div>
<div class="col-6">
<label class="form-label required" for="description">Beschreibung</label>
<textarea class="form-control" name="description" id="description" required="required"></textarea>
</div>
<div class="col-6">
<label class="form-label required" for="customer_name">Kundenname</label>
<input type="text" class="form-control" name="customer_name" id="customer_name" required="required" />
</div>
<div class="col-6">
<label class="form-label required" for="customer_number">Kundennummer</label>
<input type="text" class="form-control" name="customer_number" id="customer_number" required="required" />
</div>
<div class="col-6">
<label class="form-label required" for="customer_address">Kundenadresse</label>
<input type="text" class="form-control" name="customer_address" id="customer_address" required="required" />
</div>
<div class="col-6">
<label class="form-label required" for="customer_phone_number">Telefon</label>
<input type="text" class="form-control" name="customer_phone_number" id="customer_phone_number" required="required" />
</div>
<div class="col-6">
<label class="form-label required" for="customer_email">Email</label>
<input type="text" class="form-control" name="customer_email" id="customer_email" required="required" />
</div>
<div class="col-6">
<label class="form-label required" for="customer_service_pin">Service-Pin</label>
<input type="text" class="form-control" name="customer_service_pin" id="customer_service_pin" required="required" />
</div>
</div>
<!-- add submit and close button here-->
<div class="modal-footer">
<button type="submit" class="btn btn-primary">Ticket erstellen</button>
<button type="button" class="btn btn-secondary" data-dismiss="modal" @click="closeModal">Schließen</button>
</div>
</form>
</div>
<script>
const newTicketUrl = '<?=self::getUrl("Address", "createTicket")?>';
function openCreateTicketModal(customer_name, customer_number, customer_address, customer_phone_number, customer_email, customer_service_pin) {
$("#createTicketModal").modal("show");
$("#subject").val('');
$("#description").val('');
$("#customer_name").val(customer_name);
$("#customer_number").val(customer_number);
$("#customer_address").val(customer_address);
$("#customer_phone_number").val(customer_phone_number);
$("#customer_email").val(customer_email);
$("#customer_service_pin").val(customer_service_pin);
}
document.getElementById('createTicketForm').addEventListener('submit', submitNewTicket);
function submitNewTicket(e) {
e.preventDefault();
const data = {
subject: $("#subject").val(),
description: $("#description").val(),
customer_name: $("#customer_name").val(),
customer_number: $("#customer_number").val(),
customer_address: $("#customer_address").val(),
customer_phone_number: $("#customer_phone_number").val(),
customer_email: $("#customer_email").val(),
customer_service_pin: $("#customer_service_pin").val()
};
$.post(newTicketUrl, data, function(response) {
response = JSON.parse(response);
console.log(response);
if(response.id) {
window.open('https://project.xinon.at/projects/storungen-and-support/work_packages/' + response.id + '/activity', '_blank');
closeModal();
} else {
alert("Fehler beim Erstellen des Tickets.");
}
});
}
function closeModal() {
$("#createTicketModal").modal("hide");
// set all input fields to empty
$("#createTicketForm").trigger("reset");
}
</script>
<!-- CREATE TICKET MODAL END -->
<script type="text/javascript">
$("#filter_addresstype").select2({closeOnSelect: false});
function startBmdExport(e, type) {
e.preventDefault();
if(type == "inc") {
name = "inkrementellen";
url = "<?=self::getUrl("Address", "exportBmd")?>";
} else if(type == "full") {
name = "VOLLSTÄNDIGEN";
url = "<?=self::getUrl("Address", "exportBmd", ["type" => "full"])?>";
} else {
return false;
}
console.log(name);
if(!confirm("Wirklich " + name + " BMD-Export starten?")) {
return false;
}
$('button, input').prop('disabled', true);
$('a').removeAttr("href");
$("#bmd-export-loader").show();
window.location.href = url;
return false;
}
</script>
<?php include(realpath(dirname(__FILE__)."/../../$mfLayoutPackage")."/footer.php"); ?>