Ejemplo n.º 1
0
 protected function getmultiaddForm()
 {
     if ($this->form === Null) {
         $form_xml = new Zend_Config_Xml(Zend_Registry::get("config")->system->path->base . "/modules/default/forms/extensionsMulti.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->virtual, "virtual"), "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;
 }
Ejemplo n.º 2
0
 /**
  * @return Snep_Form
  */
 protected function getForm()
 {
     $this->form = null;
     if ($this->form === Null) {
         $form_xml = new Zend_Config_Xml(Zend_Registry::get("config")->system->path->base . "/modules/default/forms/trunks.xml");
         $form = new Snep_Form();
         $form->addSubForm(new Snep_Form_SubForm($this->view->translate("Trunk"), $form_xml->trunks), "trunks");
         $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");
         $ip = new Snep_Form_SubForm(null, $form_xml->ip, "iax2");
         $iax = new Snep_Form_SubForm(null, $form_xml->iax2, "iax2");
         foreach ($iax as $_iax) {
             $ip->addElement($_iax);
         }
         $form->addSubForm($ip, "iax2");
         $form->addSubForm(new Snep_Form_SubForm(null, $form_xml->snepsip, "snepsip"), "snepsip");
         $snepsip = new Snep_Form_SubForm(null, $form_xml->snepsip, 'snepiax2');
         $snep_iax = new Snep_Form_SubForm(null, $form_xml->snepiax2, "snepiax2");
         foreach ($snepsip as $_snepsip) {
             $snep_iax->addElement($_snepsip);
         }
         $form->addSubForm($snep_iax, "snepiax2");
         $form->addSubForm(new Snep_Form_SubForm(null, $form_xml->virtual, "virtual"), "virtual");
         $subFormKhomp = new Snep_Form_SubForm(null, $form_xml->khomp, "khomp");
         // Informações de placas khomp
         $khomp_info = new PBX_Khomp_Info();
         $khomp_boards = array();
         if ($khomp_info->hasWorkingBoards()) {
             foreach ($khomp_info->boardInfo() as $board) {
                 if (!preg_match("/FXS/", $board['model'])) {
                     $khomp_boards["b" . $board['id']] = "{$board['id']} - " . $this->view->translate("Board") . " {$board['model']}";
                     $id = "b" . $board['id'];
                     if (preg_match("/E1/", $board['model'])) {
                         for ($i = 0; $i < $board['links']; $i++) {
                             $khomp_boards["b" . $board['id'] . "l{$i}"] = $board['model'] . " - " . $this->view->translate("Link") . " {$i}";
                         }
                     } else {
                         for ($i = 0; $i < $board['channels']; $i++) {
                             $khomp_boards["b" . $board['id'] . "c{$i}"] = $board['model'] . " - " . $this->view->translate("Channel") . " {$i}";
                         }
                     }
                 }
             }
             $subFormKhomp->getElement('board')->setMultiOptions($khomp_boards);
         }
         if (count($khomp_boards) == 0) {
             $subFormKhomp->removeElement('board');
             $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;
 }