Added voicenumber list to Voicenumberblock

This commit is contained in:
Frank Schubert
2022-01-11 23:01:28 +01:00
parent a9b51281f9
commit f2a33a02ef
4 changed files with 75 additions and 54 deletions

View File

@@ -55,7 +55,7 @@
<div class="form-group row">
<label class="col-lg-2 col-form-label" for="first">Erste Nummer *</label>
<div class="col-lg-10">
<input type="text" class="form-control" name="first" id="first" value="<?=$block->getFirst()?>" />
<input type="text" class="form-control" name="first" id="first" value="<?=($block->id) ? $block->getFirst() : ""?>" />
<small>4080010</small>
</div>
</div>
@@ -63,7 +63,7 @@
<div class="form-group row">
<label class="col-lg-2 col-form-label" for="last">Letzte Nummer *</label>
<div class="col-lg-10">
<input type="text" class="form-control" name="last" id="last" value="<?=$block->getLast()?>" />
<input type="text" class="form-control" name="last" id="last" value="<?=($block->id) ? $block->getLast() : ""?>" />
<small>4080099</small>
</div>
</div>

View File

@@ -123,19 +123,25 @@
<th></th>
</tr>
<?php foreach($blocks as $block): ?>
<tr>
<td><?=$block->name?></td>
<td><?=$block->countrycode?></td>
<td><?=$block->areacode?></td>
<td><?=$block->base?></td>
<td><?=$block->getFirst()?></td>
<td><?=$block->getLast()?></td>
<td><?=$block->comment?></td>
<tr class="building-list-tr" id="block-<?=$block->id?>">
<td onclick="toggleBlock(<?=$block->id?>)"><?=$block->name?></td>
<td onclick="toggleBlock(<?=$block->id?>)"><?=$block->countrycode?></td>
<td onclick="toggleBlock(<?=$block->id?>)"><?=$block->areacode?></td>
<td onclick="toggleBlock(<?=$block->id?>)"><?=$block->base?></td>
<td onclick="toggleBlock(<?=$block->id?>)"><?=$block->getFirst()?></td>
<td onclick="toggleBlock(<?=$block->id?>)"><?=$block->getLast()?></td>
<td onclick="toggleBlock(<?=$block->id?>)"><?=$block->comment?></td>
<td style="text-align: left; letter-spacing: 4px; font-size: 1.1em;">
<a href="<?=self::getUrl("Voicenumberblock", "edit", ["id" => $block->id])?>"><i class="far fa-edit" title="Bearbeiten"></i></a>
<a href="<?=self::getUrl("Voicenumberblock", "delete", ["id" => $block->id])?>" onclick="if(!confirm('Rufnummernblock wirklich löschen?')) return false;" class="text-danger" title="Löschen"><i class="fas fa-trash"></i></a>
</td>
</tr>
<tr id="block-detail-<?=$block->id?>" style="display:none; background-color:#fff">
<td colspan="8">
<?php include(realpath(dirname(__FILE__)."/include")."/block-detail.php"); ?>
</td>
</tr>
<tr style="display:none;"></tr>
<?php endforeach; ?>
</table>
@@ -175,4 +181,16 @@
</div>
</div>
<script type="text/javascript">
function toggleBlock(id) {
$('#block-detail-' + id).toggle();
if($('#block-detail-' + id).is(":hidden")) {
$('#block-' + id).removeClass("table-info");
$('#block-' + id).removeClass("text-info");
} else {
$('#block-' + id).addClass("text-info");
$('#block-' + id).addClass("table-info");
}
}
</script>
<?php include(realpath(dirname(__FILE__)."/../")."/footer.php"); ?>

View File

@@ -0,0 +1,44 @@
<?php
/** @var Voicenumberblock $block */
?>
<div class="card">
<div class="card-body">
<h4 class="header-title">Rufnummern <?=$block->countrycode?><?=$block->areacode?><?=$block->getFirst()?> - <?=$block->countrycode?><?=$block->areacode?><?=$block->getLast()?></h4>
<table class="table table-striped table-sm">
<tr>
<th>Nummer</th>
<th>Aktiv</th>
<th>Routing</th>
<th>Portierungsstatus</th>
<th>Sperre</th>
<th>Entsperrung</th>
</tr>
<?php $i = 0; foreach(range($block->getFirst(), $block->getLast()) as $number): ?>
<?php $num = null; $num = VoicenumberModel::getFirst(['voicenumberblock_id' => $block_id, 'number' => ($block->number_prepend_zero) ? "0$number" : $number]) ?>
<tr>
<td><?=$block->countrycode?> <?=$block->areacode?> <?=($block->number_prepend_zero) ? "0" : ""?><?=$number?></td>
<td>
<?php if($num->active): ?>
<span class="text-success"><i class="fas fa-check"></i></span>
<small class="text-monospace">(seit <?=($num->id) ? date("d.m.Y H:i:s", $num->activated_date) : ""?>)</small>
<?php else: ?>
<span class="text-danger"><i class="fas fa-times"></i></span>
<?php endif; ?>
</td>
<td><?=$num->routing?></td>
<td>
<?php if($num->ported_out): ?>
Exportiert
<small class="text-monospace">(<?=($num->id) ? date("d.m.Y H:i:s", $num->port_out_date) : ""?>)</small>
<?php else: ?>
Lokal
<?php endif; ?>
</td>
<td><?=$num->disabled_reason?></td>
<td><?=($num->id && $num->enable_on_date) ? date("d.m.Y", $num->enable_on_date) : ""?></td>
</tr>
<?php $i++; if($i >= 100) break; ?>
<?php endforeach; ?>
</table>
</div>
</div>

View File

@@ -52,10 +52,11 @@ class VoicenumberModel {
}
public static function getFirst() {
public static function getFirst($filter = null) {
$db = FronkDB::singleton();
$where = self::getSqlFilter($filter);
mfLoghandler::singleton()->debug($where);
$res = $db->select("Voicenumber", "*", "$where ORDER BY voicenumberblock_id, number");
if($db->num_rows($res)) {
$data = $db->fetch_object($res);
@@ -137,41 +138,6 @@ class VoicenumberModel {
}
}
if(array_key_exists("first", $filter)) {
$add_zero = false;
$first = $filter['first'];
mfLoghandler::singleton()->debug($first);
if(substr($first,0, 1) === "0") {
$add_zero = true;
$first = substr($first, 1);
}
if(is_numeric($first)) {
$where .= " AND first like '%$first%'";
if($add_zero) {
$where .= " AND number_prepend_zero = 1";
}
}
}
if(array_key_exists("last", $filter)) {
$add_zero = false;
$last = $filter['last'];
mfLoghandler::singleton()->debug($last);
if(substr($last,0, 1) === "0") {
$add_zero = true;
$last = substr($last, 1);
}
if(is_numeric($last)) {
$where .= " AND last like '%$last%'";
}
}
if(array_key_exists("number", $filter)) {
$add_zero = false;
$number = $filter['number'];
@@ -183,7 +149,7 @@ class VoicenumberModel {
$number = substr($number, 1);
}
if(is_numeric($number)) {
$where .= " AND first <= $number AND last >= $number";
$where .= " AND number = $number";
if($add_zero) {
$where .= " AND number_prepend_zero = 1";
@@ -191,13 +157,6 @@ class VoicenumberModel {
}
}
if(array_key_exists("name", $filter)) {
$name = $db->escape($filter['name']);
if($name) {
$where .= " AND name like '%$name%'";
}
}
if(array_key_exists("comment", $filter)) {
$comment = $db->escape($filter['comment']);
if($comment) {