Fixed loading voip routing in voicenumber config hook
This commit is contained in:
@@ -116,8 +116,8 @@
|
||||
|
||||
<div class="col-md-4">
|
||||
<div class="form-group text-center">
|
||||
<label for="item_<?=$item->id?>_multiple">Mehrfach eintragbar</label>
|
||||
<input type="checkbox" class="form-control" id="item_<?=$item->id?>_multiple" name="multiple" value="1" <?=($item->multiple) ? "checked='checked'" : ""?> />
|
||||
<label for="item_new_<?=$item->id?>_multiple">Mehrfach eintragbar</label>
|
||||
<input type="checkbox" class="form-control" id="item_new_<?=$item->id?>_multiple" name="multiple" value="1" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -2,6 +2,9 @@
|
||||
|
||||
require_once __DIR__."/Contractconfig_Hook.php";
|
||||
|
||||
/*
|
||||
* Contractconfig Hooks for
|
||||
*/
|
||||
class Contractconfig_Hook_Voicenumberblock extends Contractconfig_Hook {
|
||||
protected $required_product_attributes = ["needs_number"];
|
||||
private $voip_routing;
|
||||
@@ -30,17 +33,23 @@ class Contractconfig_Hook_Voicenumberblock extends Contractconfig_Hook {
|
||||
|
||||
|
||||
// get voip routing for number
|
||||
$this->getVoipRouting();
|
||||
|
||||
}
|
||||
|
||||
private function getVoipRouting() {
|
||||
if(is_array($this->contract->configvalues)) {
|
||||
// look in contract config
|
||||
if(array_key_exists("voip_routing",$this->contract->configvalues) && $this->contract->configvalues['voip_routing']->value->string) {
|
||||
$this->voip_routing = $this->contract->configvalues['voip_routing']->value->string;
|
||||
} else {
|
||||
// else take first value (default)
|
||||
$typedata = $this->voip_routing = $this->contract->configvalues['voip_routing']->getTypedataArray();
|
||||
$typedata = $this->contract->configvalues['voip_routing']->getTypedataArray();
|
||||
$this->voip_routing = $typedata[0];
|
||||
}
|
||||
}
|
||||
|
||||
return $this->voip_routing;
|
||||
}
|
||||
|
||||
public function beforeSave() {
|
||||
@@ -49,6 +58,8 @@ class Contractconfig_Hook_Voicenumberblock extends Contractconfig_Hook {
|
||||
|
||||
public function afterSave() {
|
||||
$this->checkNewNumbers();
|
||||
// load voip routing again, in case it changed with the same config update
|
||||
$this->getVoipRouting();
|
||||
|
||||
if(count($this->errors["voicenumberblock_voicenumber"])) {
|
||||
return false;
|
||||
|
||||
Reference in New Issue
Block a user