added support for numbers with leading zero
This commit is contained in:
@@ -113,10 +113,9 @@
|
||||
|
||||
<table class="table table-striped table-hover">
|
||||
<tr>
|
||||
<th>ID</th>
|
||||
<th>Name</th>
|
||||
<th>Country Code</th>
|
||||
<th>Area Code</th>
|
||||
<th>Landeskennzahl</th>
|
||||
<th>Ortskennzahl</th>
|
||||
<th>Anfang</th>
|
||||
<th>Ende</th>
|
||||
<th>Kommentar</th>
|
||||
@@ -124,12 +123,11 @@
|
||||
</tr>
|
||||
<?php foreach($blocks as $block): ?>
|
||||
<tr>
|
||||
<td><?=$block->id?></td>
|
||||
<td><?=$block->name?></td>
|
||||
<td><?=$block->countrycode?></td>
|
||||
<td><?=$block->areacode?></td>
|
||||
<td><?=$block->first?></td>
|
||||
<td><?=$block->last?></td>
|
||||
<td><?=$block->getFirst()?></td>
|
||||
<td><?=$block->getLast()?></td>
|
||||
<td><?=$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>
|
||||
|
||||
@@ -9,15 +9,29 @@ class Voicenumberblock extends mfBaseModel {
|
||||
|
||||
private function getFullNumber($last = false) {
|
||||
if($last) {
|
||||
$number = $this->countrycode.$this->areacode.$this->last;
|
||||
$number = $this->countrycode.$this->areacode.$this->getLast();
|
||||
} else {
|
||||
$number = $this->countrycode.$this->areacode.$this->first;
|
||||
$number = $this->countrycode.$this->areacode.$this->getFirst();
|
||||
}
|
||||
|
||||
return $number;
|
||||
|
||||
}
|
||||
|
||||
public function getFirst() {
|
||||
if($this->number_add_zero) {
|
||||
return "0".$this->first;
|
||||
}
|
||||
return $this->first;
|
||||
}
|
||||
|
||||
public function getLast() {
|
||||
if($this->number_add_zero) {
|
||||
return "0".$this->last;
|
||||
}
|
||||
return $this->last;
|
||||
}
|
||||
|
||||
|
||||
public function getProperty($name) {
|
||||
if($this->$name == null) {
|
||||
|
||||
|
||||
@@ -97,8 +97,15 @@ class VoicenumberblockController extends mfBaseController {
|
||||
$data['name'] = $r->name;
|
||||
$data['countrycode'] = $r->countrycode;
|
||||
$data['areacode'] = $r->areacode;
|
||||
|
||||
if(substr($r->first,0,1) === "0") {
|
||||
$data['number_add_zero'] = 1;
|
||||
} else {
|
||||
$data['number_add_zero'] = 0;
|
||||
}
|
||||
$data['first'] = $r->first;
|
||||
$data['last'] = $r->last;
|
||||
|
||||
$data['comment'] = $r->comment;
|
||||
$data['edit_by'] = $this->me->id;
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@ class VoicenumberblockModel {
|
||||
public $areacode;
|
||||
public $first;
|
||||
public $last;
|
||||
public $number_add_zero;
|
||||
public $comment;
|
||||
|
||||
public $create_by;
|
||||
@@ -89,6 +90,7 @@ class VoicenumberblockModel {
|
||||
$db = FronkDB::singleton();
|
||||
|
||||
$where = self::getSqlFilter($filter);
|
||||
mfLoghandler::singleton()->debug($where);
|
||||
//mfLoghandler::singleton()->log->debug($where);
|
||||
$res = $db->select("Voicenumberblock", "*", "$where ORDER BY countrycode, areacode, first, last");
|
||||
if($db->num_rows($res)) {
|
||||
@@ -123,23 +125,56 @@ class VoicenumberblockModel {
|
||||
}
|
||||
|
||||
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_add_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%'";
|
||||
$where .= " AND last like '%$last%'";
|
||||
}
|
||||
}
|
||||
|
||||
if(array_key_exists("number", $filter)) {
|
||||
$add_zero = false;
|
||||
$number = $filter['number'];
|
||||
|
||||
mfLoghandler::singleton()->debug($number);
|
||||
|
||||
if(substr($number,0, 1) === "0") {
|
||||
$add_zero = true;
|
||||
$number = substr($number, 1);
|
||||
}
|
||||
if(is_numeric($number)) {
|
||||
$where .= " AND first <= $number AND last >= $number";
|
||||
|
||||
if($add_zero) {
|
||||
$where .= " AND number_add_zero = 1";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user