Fixed Voicenumber and Updated Voiceplan

This commit is contained in:
Frank Schubert
2023-11-14 20:15:06 +01:00
parent 003ab67145
commit cc4a751407
20 changed files with 232 additions and 662 deletions
@@ -4,6 +4,16 @@ class Voiceplanzone extends mfBaseModel {
private $destinations;
private $voiceplan;
public $cloned_destinations = [];
public function getDestinationCountOrPrefix() {
$destinations = $this->getProperty("destinations");
if(count($destinations) == 1) {
return "+".$destinations[0]->prefix;
}
return count($destinations);
}
public function getProperty($name) {
if($this->$name == null) {
@@ -30,4 +40,32 @@ class Voiceplanzone extends mfBaseModel {
return $this->$name;
}
public function __clone() {
$me = new User;
$me->loadMe();
$old_id = $this->id;
$this->id = null;
$this->destinations = null;
$this->voiceplan = null;
// cleanup data
$this->create_by = $me->id;
$this->edit_by = $me->id;
$this->create = null;
$this->edit = null;
$this->saved = 0;
$this->mode = "new";
$this->_old_data = new StdClass();
// clone all destinations
$this->cloned_destinations = [];
foreach(VoiceplandestinationModel::search(['voiceplanzone_id' => $old_id]) as $old_destination) {
$this->cloned_destinations[] = clone($old_destination);
}
$this->log->debug("Cloned Voiceplanzone $old_id");
}
}