Files
thetool/Layout/default/Order/Index.php
2021-09-20 11:34:21 +02:00

289 lines
17 KiB
PHP

<?php include(realpath(dirname(__FILE__)."/../")."/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")?>">the-tool</a></li>
<li class="breadcrumb-item active">Bestellungen</li>
</ol>
</div>
<h4 class="page-title">Bestellungen</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("Order")?>">
<div class="row">
<div class="col-1">
<label class="form-label" for="filter_network_id">Netzgebiet</label>
<select name="filter[network_id]" id="filter_network_id" class="form-control">
<option></option>
<?php foreach($mynetworks as $fnet): ?>
<option value="<?=$fnet->id?>" <?=($filter['network_id'] == $fnet->id) ? "selected='selected'" : ""?>><?=$fnet->name?></option>
<?php endforeach; ?>
</select>
</div>
<div class="col-1">
<label class="form-label" for="filter_building_networksection_id">Bauabschnitt</label>
<select name="filter[building_networksection_id]" id="filter_building_networksection_id" class="form-control">
<option></option>
<?php foreach($mynetworks as $fnet): ?>
<?php if(is_array($fnet->sections) && count($fnet->sections)): ?>
<optgroup label="<?=$fnet->name?>">
<?php foreach($fnet->sections as $section): ?>
<option value="<?=$section->id?>" <?=($filter['building_networksection_id'] == $section->id) ? "selected='selected'" : ""?>><?=$section->name?></option>
<?php endforeach; ?>
</optgroup>
<?php endif; ?>
<?php endforeach; ?>
</select>
</div>
<div class="col-2">
<label class="form-label" for="filter_status_id">Anschlussstatus</label>
<select name="filter[termination_status]" id="filter_building_status_id" class="form-control">
<option></option>
<option value="pipework_needed" <?=($filter['termination_status'] == "pipework_needed") ? "selected='selected'" : ""?>>Tiefbau ausständig</option>
<option value="building_connected" <?=($filter['termination_status'] == "building_connected") ? "selected='selected'" : ""?>>Tiefbau erledigt</option>
<option value="term_connected" <?=($filter['termination_status'] == "term_connected") ? "selected='selected'" : ""?>>Anschluss passiv erschlossen</option>
</select>
</div>
<div class="col-1">
<label class="form-label" for="filter_building_code">Objekt ID</label>
<input type="text" class="form-control" name="filter[building_code]" id="filter_building_code" value="<?=$filter['building_code']?>" />
</div>
<div class="col-2">
<label class="form-label" for="filter_building_street">Straße</label>
<input type="text" class="form-control" name="filter[building_street]" id="filter_building_street" value="<?=$filter['building_street']?>" />
</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("Order")?>">Filter zurücksetzen</a>
</div>
</div>
</form>
</div>
</div>
<?php if(is_array($lonelyOrders) && count($lonelyOrders)): ?>
<div class="card">
<div class="card-body mb-3">
<div class="float-left">
<h4 class="header-title">Bestellungen ohne Produkte</h4>
</div>
<table class="table table-striped table-hover">
<tr>
<th></th>
<th>Kunde</th>
<th>Adresse</th>
<th>Bestelldatum</th>
<th>Zuletzt bearbeitet</th>
<th>Bearbeitet von</th>
<th></th>
</tr>
<?php foreach($lonelyOrders as $order): ?>
<tr>
<td><?=$order->id?></td>
<td>
<?=nl2br($order->owner->getCompanyOrName())?>
<?=($order->owner->spin) ? "<br /><span class='text-pink'>".$order->owner->spin."</span>" : ""?>
</td>
<td>
<?=$order->owner->street?><br />
<?=$order->owner->zip?> <?=$order->owner->city?>
</td>
<td class="text-monospace"><?=date("d.m.Y", $order->order_date)?></td>
<td class="text-monospace"><?=date("d.m.Y", $order->edit)?></td>
<td class="text-monospace"><?=$order->editor->name?></td>
<td style="text-align: left; letter-spacing: 4px; font-size: 1.1em;">
<a href="<?=self::getUrl("Order", "downloadServicePin", ["id" => $order->id])?>"><i class="fas fa-file-alt" title="Service PIN als PDF herunterladen"></i></a>
<a href="<?=self::getUrl("Order", "sendServicePin", ["id" => $order->id])?>" onclick="if(!confirm('Soll der Service-PIN an den Vertragsinhaber gesendet werden?')) return false;"><i class="fas fa-paper-plane" title="Service PIN als PDF per Email an Vertragsinhaber"></i></a>
<a href="<?=self::getUrl("Order", "edit", ["id" => $order->id])?>"><i class="far fa-edit" title="Bearbeiten"></i></a>
<a href="<?=self::getUrl("Order", "delete", ["id" => $order->id])?>" onclick="if(!confirm('Bestellung wirklich löschen?')) return false;" class="text-danger" title="Löschen"><i class="fas fa-trash"></i></a>
</td>
</tr>
<?php endforeach; ?>
</table>
</div>
</div>
<?php endif; ?>
<div class="card">
<div class="card-body mb-3">
<div class="float-left">
<h4 class="header-title">Liste aller Bestellungen</h4>
</div>
<div class="float-right">
<a class="btn btn-primary mb-2" href="<?=self::getUrl("Order", "add")?>"><i class="fas fa-plus"></i> Neue Bestellung anlegen</a>
</div>
<?php if($pagination['maxItems'] > $pagination['count']): ?>
<nav>
<ul class="pagination justify-content-center mb-1">
<li class="page-item <?=($pagination['start'] - $pagination['count'] < 0) ? "disabled" : ""?>">
<a class="page-link" href="<?=$this->getUrl($Mod, "Index", ["filter" => $filter])?>" tabindex="-1">Erste</a>
</li>
<li class="page-item <?=($pagination['start'] - $pagination['count'] < 0) ? "disabled" : ""?>">
<a class="page-link" href="<?=$this->getUrl($Mod,"Index",['s' => $pagination['start'] - $pagination['count'], "filter" => $filter])?>" tabindex="-1">Zurück</a>
</li>
<?php for($i = 0; $i < ($pagination['maxItems'] / $pagination['count']); $i++): ?>
<li class="page-item <?=($pagination['start'] == $i*$pagination['count']) ? "disabled font-weight-bold" : ""?>"><a class="page-link" href="<?=$this->getUrl($Mod,"Index",['s' => $i*$pagination['count'], "filter" => $filter])?>"><?=$i+1?></a></li>
<?php endfor; ?>
<li class="page-item <?=($pagination['maxItems'] / ($pagination['start'] + $pagination['count']) < 1) ? "disabled" : ""?>">
<a class="page-link" href="<?=$this->getUrl($Mod,"Index",['s' => $pagination['start'] + $pagination['count'], "filter" => $filter])?>">Vor</a>
</li>
<li class="page-item <?=($pagination['maxItems'] / ($pagination['start'] + $pagination['count']) < 1) ? "disabled" : ""?>">
<a class="page-link" href="<?=$this->getUrl($Mod,"Index",['s' => ($pagination['maxItems'] - $pagination['maxItems'] % $pagination['count']), "filter" => $filter])?>">Letzte</a>
</li>
</ul>
</nav>
<?php endif; ?>
<div class="pagination justify-content-center">
<?php if($pagination['maxItems']): ?>
Bestellungen <?=$pagination['start']+1?> bis <?=($pagination['start'] + $pagination['count'] > $pagination['maxItems']) ? $pagination['maxItems'] : $pagination['start'] + $pagination['count']?> von <?=$pagination['maxItems']?>
<?php else: ?>
Keine Bestellungen gefunden
<?php endif; ?>
</div>
<table class="table table-striped table-hover">
<tr>
<th></th>
<th></th>
<th>Kunde</th>
<th>Adresse</th>
<th>Anschlussadresse</th>
<th>Bestelldatum</th>
<th>Zuletzt bearbeitet</th>
<th>Bearbeitet von</th>
<th></th>
</tr>
<?php foreach($orders as $order): ?>
<tr>
<td><?=$order->id?></td>
<td>
<?php if(is_array($order->terminations) && count($order->terminations)): ?>
<?php if($order->terminations[0]->status->code >= TT_TERMSTATUS_CONNECTED): ?>
<span class="status connected" title="Anschluss connected">CON</span>
<?php elseif($order->terminations[0]->building->status->code >= TT_BUILDINGSTATUS_CONNECTED): ?>
<a href="<?=self::getUrl("Linework", "Index", ["filter" => ["code" => $order->terminations[0]->code, "status_id" => ""]])?>" target="_blank"><span class="status building-connected" title="Tiefbau erledigt">B-C</span></a>
<?php else: ?>
<a href="<?=self::getUrl("Pipework", "Index", ["filter" => ["code" => $order->terminations[0]->building->code, "status_id" => ""]])?>" target="_blank"><span class="status not-connected" title="Tiefbau ausständig">BNC</span></a>
<?php endif; ?>
<?php endif; ?>
<?php
$voip = false;
$hw = false;
if(count($order->products)) {
foreach($order->products as $product) {
if(is_array($product->product->attributes) && count($product->product->attributes)) {
if(array_key_exists("hw_only", $product->product->attributes)) {
if($product->product->attributes["hw_only"]->value) {
$hw = true;
}
}
if(array_key_exists("voip_chan", $product->product->attributes)) {
if($product->product->attributes["voip_chan"]->value) {
$voip = true;
}
}
if($hw && $voip_chan) {
break;
}
}
}
}
?>
<?=($hw) ? "<i class='fas fa-shopping-bag text-info ml-1' title='Zusatzprodukt vorhanden'></i>" : ""?>
<?=($voip) ? "<i class='fas fa-phone text-info ml-1' title='Voice Produkt vorhanden'></i>" : ""?>
</td>
<td>
<?=nl2br($order->owner->getCompanyOrName())?>
<?=($order->owner->spin) ? "<br /><span class='text-pink'>".$order->owner->spin."</span>" : ""?>
</td>
<td>
<?=$order->owner->street?><br />
<?=$order->owner->zip?> <?=$order->owner->city?>
</td>
<td>
<?php if(is_array($order->terminations) && count($order->terminations)): ?>
<?=$order->terminations[0]->building->street?><?=($order->terminations[0]->name) ? " ".$order->terminations[0]->name : ""?><br />
<?=$order->terminations[0]->building->zip?> <?=$order->terminations[0]->building->city?>
<?php endif; ?>
</td>
<td class="text-monospace"><?=date("d.m.Y", $order->order_date)?></td>
<td class="text-monospace"><?=date("d.m.Y", $order->edit)?></td>
<td class="text-monospace"><?=$order->editor->name?></td>
<td style="text-align: left; letter-spacing: 4px; font-size: 1.1em;">
<a href="<?=self::getUrl("Order", "downloadServicePin", ["id" => $order->id])?>"><i class="fas fa-file-alt" title="Service PIN als PDF herunterladen"></i></a>
<a href="<?=self::getUrl("Order", "sendServicePin", ["id" => $order->id])?>" onclick="if(!confirm('Soll der Service-PIN an den Vertragsinhaber gesendet werden?')) return false;"><i class="fas fa-paper-plane" title="Service PIN als PDF per Email an Vertragsinhaber"></i></a>
<a href="<?=self::getUrl("Order", "edit", ["id" => $order->id])?>"><i class="far fa-edit" title="Bearbeiten"></i></a>
<a href="<?=self::getUrl("Order", "delete", ["id" => $order->id])?>" onclick="if(!confirm('Bestellung wirklich löschen?')) return false;" class="text-danger" title="Löschen"><i class="fas fa-trash"></i></a>
</td>
</tr>
<?php endforeach; ?>
</table>
<?php if($pagination['maxItems'] > $pagination['count']): ?>
<nav>
<ul class="pagination justify-content-center mb-1">
<li class="page-item <?=($pagination['start'] - $pagination['count'] < 0) ? "disabled" : ""?>">
<a class="page-link" href="<?=$this->getUrl($Mod, "Index", ["filter" => $filter])?>" tabindex="-1">Erste</a>
</li>
<li class="page-item <?=($pagination['start'] - $pagination['count'] < 0) ? "disabled" : ""?>">
<a class="page-link" href="<?=$this->getUrl($Mod,"Index",['s' => $pagination['start'] - $pagination['count'], "filter" => $filter])?>" tabindex="-1">Zurück</a>
</li>
<?php for($i = 0; $i < ($pagination['maxItems'] / $pagination['count']); $i++): ?>
<li class="page-item <?=($pagination['start'] == $i*$pagination['count']) ? "disabled font-weight-bold" : ""?>"><a class="page-link" href="<?=$this->getUrl($Mod,"Index",['s' => $i*$pagination['count'], "filter" => $filter])?>"><?=$i+1?></a></li>
<?php endfor; ?>
<li class="page-item <?=($pagination['maxItems'] / ($pagination['start'] + $pagination['count']) < 1) ? "disabled" : ""?>">
<a class="page-link" href="<?=$this->getUrl($Mod,"Index",['s' => $pagination['start'] + $pagination['count'], "filter" => $filter])?>">Vor</a>
</li>
<li class="page-item <?=($pagination['maxItems'] / ($pagination['start'] + $pagination['count']) < 1) ? "disabled" : ""?>">
<a class="page-link" href="<?=$this->getUrl($Mod,"Index",['s' => ($pagination['maxItems'] - $pagination['maxItems'] % $pagination['count']), "filter" => $filter])?>">Letzte</a>
</li>
</ul>
</nav>
<?php endif; ?>
<div class="pagination justify-content-center">
<?php if($pagination['maxItems']): ?>
Bestellungen <?=$pagination['start']+1?> bis <?=($pagination['start'] + $pagination['count'] > $pagination['maxItems']) ? $pagination['maxItems'] : $pagination['start'] + $pagination['count']?> von <?=$pagination['maxItems']?>
<?php else: ?>
Keine Bestellungen gefunden
<?php endif; ?>
</div>
</div>
</div>
</div>
</div>
<?php include(realpath(dirname(__FILE__)."/../")."/footer.php"); ?>