示例#1
0
 /**
  * Import contacts from CSV file
  */
 public function importAction()
 {
     $this->view->breadcrumb = Snep_Breadcrumb::renderPath(array($this->view->translate("Manage"), $this->view->translate("Contacts"), $this->view->translate("Import CSV")));
     $this->view->message = $this->view->translate("The file must be separated by commas. Header is optional and columns can be associated in the next screen.");
     Zend_Registry::set('cancel_url', $this->getFrontController()->getBaseUrl() . '/' . $this->getRequest()->getControllerName() . '/index');
     $form = new Snep_Form();
     $form->addSubForm(new Snep_Form_SubForm(NULL, NULL, "file"), 'file');
     $form->setAction($this->getFrontController()->getBaseUrl() . '/' . $this->getRequest()->getControllerName() . '/csv/');
     $form->getSubForm('file')->addElement(new Zend_Form_Element_File('file'));
     $this->view->form = $form;
 }
示例#2
0
 protected function populateFromTrunk(Snep_Form $form, $trunk_id)
 {
     $db = Snep_Db::getInstance();
     $info = $db->query("select * from trunks where id='{$trunk_id}'")->fetch();
     $form->getSubForm("trunks")->getElement("callerid")->setValue($info['callerid']);
     $form->getSubForm("technology")->getElement("type")->setValue(strtolower($info['type']));
     foreach ($form->getSubForm("advanced")->getElements() as $element) {
         if (key_exists($element->getName(), $info)) {
             $element->setValue($info[$element->getName()]);
         }
     }
     foreach ($form->getSubForm(strtolower($info['type']))->getElements() as $element) {
         if (key_exists($element->getName(), $info)) {
             $element->setValue($info[$element->getName()]);
         }
     }
     if ($info['trunktype'] == "I") {
         $ip_info = $db->query("select * from peers where name='{$info['name']}'")->fetch();
         foreach ($form->getSubForm(strtolower($info['type']))->getElements() as $element) {
             if (key_exists($element->getName(), $ip_info)) {
                 $element->setValue($ip_info[$element->getName()]);
             }
         }
         if ($info['type'] == "SIP" || $info['type'] == "IAX2") {
             $form->getSubForm(strtolower($info['type']))->getElement("dialmethod")->setValue(strtolower($info['dialmethod']));
             $form->getSubForm(strtolower($info['type']))->getElement("peer_type")->setValue($ip_info['type']);
         }
     } else {
         if ($info['type'] == "KHOMP" && $form->getSubForm("khomp")->getElement("board") != NULL) {
             $form->getSubForm("khomp")->getElement("board")->setValue(substr($info['channel'], 6));
         }
     }
 }