From dfb33e198984682c867ba8b536d46ffc39a98a49 Mon Sep 17 00:00:00 2001 From: Frank Schubert Date: Tue, 21 Dec 2021 22:59:29 +0100 Subject: [PATCH] Added number base --- Layout/default/Voicenumberblock/Index.php | 2 ++ application/Voicenumber/Voicenumber.php | 5 +++++ application/Voicenumber/VoicenumberModel.php | 8 ++++++++ application/Voicenumberblock/Voicenumberblock.php | 13 +++++++++++++ 4 files changed, 28 insertions(+) create mode 100644 application/Voicenumber/Voicenumber.php create mode 100644 application/Voicenumber/VoicenumberModel.php diff --git a/Layout/default/Voicenumberblock/Index.php b/Layout/default/Voicenumberblock/Index.php index 9f9f8da97..3a9a834ad 100644 --- a/Layout/default/Voicenumberblock/Index.php +++ b/Layout/default/Voicenumberblock/Index.php @@ -116,6 +116,7 @@ Name Landeskennzahl Ortskennzahl + Nummernbasis Anfang Ende Kommentar @@ -126,6 +127,7 @@ name?> countrycode?> areacode?> + base?> getFirst()?> getLast()?> comment?> diff --git a/application/Voicenumber/Voicenumber.php b/application/Voicenumber/Voicenumber.php new file mode 100644 index 000000000..a78066748 --- /dev/null +++ b/application/Voicenumber/Voicenumber.php @@ -0,0 +1,5 @@ +last; } + public function getBaseNumber() { + $base = floor($this->first / pow(10, ceil(log10($this->last - $this->first)))); + + if($this->number_prepend_zero) { + return "0".$base; + } + return $base; + } public function getProperty($name) { if($this->$name == null) { @@ -53,6 +62,10 @@ class Voicenumberblock extends mfBaseModel { return $this->getFullNumber(true); } + if($name == "base") { + return $this->getBaseNumber(); + } + $classname = ucfirst($name); $idfield = $name."_id"; $this->$name = new $classname($this->$idfield);