Added filter to Voiceplan
This commit is contained in:
@@ -64,6 +64,17 @@ class VoiceplanController extends mfBaseController {
|
||||
|
||||
$this->layout()->set("plan", $plan);
|
||||
|
||||
$filter = [];
|
||||
if(is_array($this->request->filter)) {
|
||||
$filter = $this->request->filter;
|
||||
}
|
||||
|
||||
$this->layout->set("filter", $filter);
|
||||
|
||||
if($filter) {
|
||||
$filter = $this->getPreparedViewFilter($filter);
|
||||
}
|
||||
|
||||
$pagination = [];
|
||||
$pagination['start'] = 0;
|
||||
$pagination['count'] = 20;
|
||||
@@ -73,14 +84,36 @@ class VoiceplanController extends mfBaseController {
|
||||
$pagination['start'] = intval($this->request->s);
|
||||
}
|
||||
|
||||
$pagination['maxItems'] = VoiceplanzoneModel::count(['voiceplan_id' => $id]);
|
||||
$zones = VoiceplanzoneModel::search(['voiceplan_id' => $id], $pagination);
|
||||
$zone_search = $filter;
|
||||
$zone_search['voiceplan_id'] = $id;
|
||||
|
||||
$pagination['maxItems'] = VoiceplanzoneModel::count($zone_search);
|
||||
$zones = VoiceplanzoneModel::search($zone_search, $pagination);
|
||||
$this->layout()->set("zones", $zones);
|
||||
|
||||
$this->layout()->set("pagination", $pagination);
|
||||
|
||||
}
|
||||
|
||||
private function getPreparedViewFilter($filter) {
|
||||
$new_filter = [];
|
||||
|
||||
if(array_key_exists("prefix", $filter) && $filter['prefix']) {
|
||||
$prefix = $filter['prefix'];
|
||||
if(substr($prefix, 0, 1) == "+") {
|
||||
$prefix = substr($prefix, 1)."%";
|
||||
}
|
||||
$new_filter['prefix'] = $prefix;
|
||||
unset($filter['prefix']);
|
||||
}
|
||||
|
||||
foreach($filter as $name => $value) {
|
||||
$new_filter[$name] = $value;
|
||||
}
|
||||
|
||||
return $new_filter;
|
||||
}
|
||||
|
||||
protected function addAction() {
|
||||
$this->layout()->setTemplate("Voiceplan/Form");
|
||||
|
||||
@@ -124,7 +157,7 @@ class VoiceplanController extends mfBaseController {
|
||||
$data = [];
|
||||
$data['name'] = $r->name;
|
||||
$data['description'] = $r->description;
|
||||
$data['price_multiplicator'] = ($r->price_multiplicator) ? $r->price_multiplicator : 1;
|
||||
$data['price_multiplicator'] = ($r->price_multiplicator) ? $r->price_multiplicator : null;
|
||||
|
||||
|
||||
if($r->increment) {
|
||||
|
||||
Reference in New Issue
Block a user