Beispiel #1
0
 /**
  * @return Snep_Form
  */
 protected function getForm()
 {
     if ($this->form === Null) {
         Zend_Registry::set('cancel_url', $this->getFrontController()->getBaseUrl() . '/' . $this->getRequest()->getControllerName() . '/index');
         $form_xml = new Zend_Config_Xml(Zend_Registry::get("config")->system->path->base . "/modules/default/forms/extensions.xml");
         $form = new Snep_Form();
         $form->addSubForm(new Snep_Form_SubForm($this->view->translate("Extension"), $form_xml->extension), "extension");
         $form->addSubForm(new Snep_Form_SubForm($this->view->translate("Interface Technology"), $form_xml->technology), "technology");
         $form->addSubForm(new Snep_Form_SubForm(null, $form_xml->ip, "sip"), "sip");
         $form->addSubForm(new Snep_Form_SubForm(null, $form_xml->ip, "iax2"), "iax2");
         $form->addSubForm(new Snep_Form_SubForm(null, $form_xml->manual, "manual"), "manual");
         $subFormVirtual = new Snep_Form_SubForm(null, $form_xml->virtual, "virtual");
         $trunks = new PBX_Trunks();
         if ($trunks->fetchAll() == null) {
             $subFormVirtual->removeElement('virtual');
             $subFormVirtual->addElement(new Snep_Form_Element_Html("extensions/trunk_error.phtml", "err", false, null, "virtual"));
         }
         $form->addSubForm($subFormVirtual, "virtual");
         $subFormKhomp = new Snep_Form_SubForm(null, $form_xml->khomp, "khomp");
         $selectFill = $subFormKhomp->getElement('board');
         $selectFill->addMultiOption(null, ' ');
         // Monta informações para placas khomp
         $boardList = array();
         $khompInfo = new PBX_Khomp_Info();
         if ($khompInfo->hasWorkingBoards()) {
             foreach ($khompInfo->boardInfo() as $board) {
                 if (preg_match("/FXS/", $board['model'])) {
                     $channels = range(0, $board['channels']);
                     $selectFill->addMultiOption($board['id'], $board['id']);
                     $boardList[$board['id']] = $channels;
                 }
             }
             $subFormKhomp->getElement('channel')->setRegisterInArrayValidator(false);
             $boardTmp = Zend_Json_Encoder::encode($boardList);
             $this->boardData = $boardTmp;
         } else {
             $subFormKhomp->removeElement('board');
             $subFormKhomp->removeElement('channel');
             $subFormKhomp->addElement(new Snep_Form_Element_Html("extensions/khomp_error.phtml", "err", false, null, "khomp"));
         }
         $form->addSubForm($subFormKhomp, "khomp");
         $form->addSubForm(new Snep_Form_SubForm($this->view->translate("Advanced"), $form_xml->advanced), "advanced");
         $this->form = $form;
     }
     return $this->form;
 }