Files
thetool/Layout/default/Product/Index.php
2024-02-21 15:40:59 +01:00

189 lines
10 KiB
PHP

<?php
$pagination_baseurl = $this->getUrl($Mod,"Index");
$pagination_baseurl_params = ["filter" => $filter];
$pagination_entity_name = "Produkte";
?>
<?php include(realpath(dirname(__FILE__)."/../../$mfLayoutPackage")."/header.php"); ?>
<!-- start page title -->
<div class="row">
<div class="col-12">
<div class="page-title-box">
<div class="page-title-right">
<ol class="breadcrumb m-0">
<li class="breadcrumb-item"><a href="<?=self::getUrl("Dashboard")?>"><?=MFAPPNAME_SLUG?></a></li>
<li class="breadcrumb-item active">Produkte</li>
</ol>
</div>
<h4 class="page-title">Produkte</h4>
</div>
</div>
</div>
<!-- end page title -->
<div class="row">
<div class="col-lg-12">
<div class="card">
<div class="card-body mb-3">
<h4 class="header-title mb-3">Filter</h4>
<form method="get" action="<?=self::getUrl("Product")?>">
<div class="row">
<div class="col-2">
<label class="form-label" for="filter_network_id">Produktgruppen</label>
<select name="filter[productgroup_id][]" id="filter_productgroup_id" class="form-control select2" multiple="multiple">
<option></option>
<?php foreach(ProductgroupModel::getAll() as $group): ?>
<option value="<?=$group->id?>" <?=(is_array($filter) && array_key_exists('productgroup_id', $filter) && in_array($group->id, $filter['productgroup_id'])) ? "selected='selected'" : ""?>><?=$group->name?></option>
<?php endforeach; ?>
</select>
</div>
<div class="col-2">
<label class="form-label" for="filter_producttech_id">Technologien</label>
<select name="filter[producttech_id][]" id="filter_producttech_id" class="form-control select2" multiple="multiple">
<option></option>
<?php foreach(ProducttechModel::getAll() as $tech): ?>
<option value="<?=$tech->id?>" <?=(is_array($filter) && array_key_exists('producttech_id', $filter) && in_array($tech->id, $filter['producttech_id'])) ? "selected='selected'" : ""?>><?=$tech->name?></option>
<?php endforeach; ?>
</select>
</div>
<div class="col-2">
<label class="form-label" for="filter_sla_id">SLA</label>
<select name="filter[sla_id]" id="filter_sla_id" class="form-control">
<option></option>
<?php foreach(SlaModel::getAll() as $sla): ?>
<option value="<?=$sla->id?>" <?=(is_array($filter) && array_key_exists('sla_id', $filter) && $filter['sla_id'] == $sla->id) ? "selected='selected'" : ""?>><?=$sla->name?></option>
<?php endforeach; ?>
</select>
</div>
<div class="col-2">
<label class="form-label" for="filter_external_id">Produktbesitzer</label>
<select class="select2 form-control" name="filter[external_id]" id="filter_external_id">
<option></option>
<?php foreach(AddressModel::search(['addresstype' => ['productowner']]) as $owner): ?>
<option value="<?=$owner->id?>" <?=(is_array($filter) && array_key_exists('external_id', $filter) && $filter['external_id'] == $owner->id) ? "selected='selected'" : ""?>><?=$owner->getCompanyOrName()?></option>
<?php endforeach; ?>
</select>
</div>
<div class="col-1">
<label class="form-label" for="filter_external">Externe Produkte</label>
<select name="filter[external]" id="filter_external" class="form-control">
<option></option>
<option value="1" <?=(is_array($filter) && array_key_exists('external', $filter) && $filter['external']) ? "selected='selected'" : ""?>>Anzeigen</option>
<option value="0" <?=(is_array($filter) && array_key_exists('external', $filter) && !$filter['external']) ? "selected='selected'" : ""?>>Ausblenden</option>
</select>
</div>
<div class="col-1">
<label class="form-label" for="filter_name">Name</label>
<input type="text" class="form-control" name="filter[name]" id="filter_name" value="<?=$filter['name']?>" />
</div>
<div class="col-1">
<label class="form-label" for="filter_customer_type">Kundentyp</label>
<select name="filter[customer_type]" id="filter_customer_type" class="form-control">
<option></option>
<option value="business" <?=(is_array($filter) && array_key_exists('customer_type', $filter) && $filter['customer_type'] == "business") ? "selected='selected'" : ""?>>Business</option>
<option value="residential" <?=(is_array($filter) && array_key_exists('customer_type', $filter) && $filter['customer_type'] == "residential") ? "selected='selected'" : ""?>>Residential</option>
</select>
</div>
<div class="col-1">
<label class="form-label" for="filter_active">Status</label>
<select name="filter[active]" id="filter_active" class="form-control">
<option value="1" <?=(is_array($filter) && array_key_exists('active', $filter) && $filter['active']) ? "selected='selected'" : ""?>>Aktiviert</option>
<option value="0" <?=(is_array($filter) && array_key_exists('active', $filter) && !$filter['active']) ? "selected='selected'" : ""?>>Deaktiviert</option>
<option value="all" <?=(is_array($filter) && array_key_exists('active', $filter) && $filter['active'] == "all") ? "selected='selected'" : ""?>>Alle anzeigen</option>
</select>
</div>
</div>
<div class="row mt-2">
<div class="col">
<button type="submit" class="btn btn-primary">Filter anwenden</button>
<a class="btn btn-secondary" href="<?=self::getUrl("Product", "", ["resetFilter" => 1])?>">Filter zurücksetzen</a>
</div>
<!--<div class="col">
<button class="btn btn-info" type="button" onclick="refreshMap()"><i class="far fa-map"></i> Auf Karte anzeigen</button>
</div>-->
</div>
</form>
</div>
</div>
<div class="card">
<div class="card-body mb-3">
<div class="float-left">
<h4 class="header-title">Liste aller Produkte</h4>
</div>
<div class="float-right">
<a class="btn btn-primary mb-2" href="<?=self::getUrl("Product", "add")?>"><i class="fas fa-plus"></i> Neues Produkt anlegen</a>
</div>
<?php include(realpath(dirname(__FILE__)."/../")."/tpl/pagination.php"); ?>
<?php include(realpath(dirname(__FILE__)."/../")."/tpl/pagination-summary.php"); ?>
<table class="table table-striped table-hover">
<tr>
<th>Netzgebiete</th>
<th>Gruppe</th>
<th>Name</th>
<th>Technologie</th>
<th>Kundentyp</th>
<th>Verkaufspreis</th>
<th>Verr. Periode</th>
<th>SLA</th>
<th>IVT ID</th>
<th></th>
</tr>
<?php foreach($products as $product): ?>
<tr>
<td><?=(count($product->networks)) ? array_shift($product->networks)->name . ((count($product->networks) > 1) ? ", ..." : "") : ""?></td>
<td><?=$product->productgroup->name?></td>
<td><?=$product->name?></td>
<td><?=$product->producttech->name?><?=(is_array($product->attributes) && array_key_exists(TT_ATTRIB_RTRTECHCODE_NAME, $product->attributes)) ? " (".$product->attributes[TT_ATTRIB_RTRTECHCODE_NAME]->value.")" : "" ?></td>
<td><?=__($product->producttech->customer_type)?></td>
<td><?=$product->price?></td>
<td><?=(12 / $product->billing_period)?>x Jährlich</td>
<td><?=$product->sla->name?></td>
<td><?=$product->ivt_id?></td>
<td style="text-align: left; letter-spacing: 4px; font-size: 1.1em;">
<a href="<?=self::getUrl("Product", "edit", ["id" => $product->id])?>"><i class="far fa-edit" title="Produkt Bearbeiten"></i></a>
<a href="<?=self::getUrl("Product", "copy", ["id" => $product->id])?>"><i class="far fa-clone" title="Kopie erstellen"></i></a>
<a href="<?=self::getUrl("Product", "delete", ["id" => $product->id])?>" class="text-danger" onclick="if(!confirm('Berechtigungen wirklich löschen?')) return false;" title="Produkt Löschen"><i class="fas fa-trash"></i></a>
</td>
</tr>
<?php endforeach; ?>
</table>
<?php include(realpath(dirname(__FILE__)."/../")."/tpl/pagination-summary.php"); ?>
<?php include(realpath(dirname(__FILE__)."/../")."/tpl/pagination.php"); ?>
</div>
</div>
</div>
</div>
<script type="text/javascript">
$("#filter_productgroup_id").select2({closeOnSelect: false});
$("#filter_producttech_id").select2({closeOnSelect: false});
$("#filter_external_id").change(function() {
console.log($("#filter_external_id").val());
if($("#filter_external_id").val()) {
$("#filter_external").val(1);
}
});
</script>
<?php include(realpath(dirname(__FILE__)."/../../$mfLayoutPackage")."/footer.php"); ?>