コード例 #1
0
 public function formsAction()
 {
     // Define o título da página, é mostrado automaticamente na view.
     $this->view->breadcrumb = $this->view->translate("Exemplo » Formulários");
     // Parse do arquivo formulário.
     $xml = new Zend_Config_Xml(Zend_Registry::get("config")->system->path->base . "/modules/example/forms/example.xml");
     // Cria objeto Snep_Form
     $form = new Snep_Form($xml);
     // Pega determinado elemento do Form
     $campo4 = $form->getElement('campo04');
     // Seta as opções do elemento dinamicamente.
     $campo4->setMultiOptions(array(1 => 'teste1', 2 => 'teste2', 3 => 'teste3'));
     // Chama método setButton(), que inclue a barra de botões padrão do SNEP.
     $form->setButton();
     // Verifica se existe dados sendo enviados via $_POST
     // Se for verdadeiro, é porqyue o formulário foi submetido.
     if ($this->_request->getPost()) {
         // Chama método isValid() é confronta os dados submetidos pelo formulário.
         $isValid = $form->isValid($_POST);
         if ($isValid) {
             $this->view->message = $this->view->translate("Dados recebidos") . "!";
             $this->view->dados = $_POST;
         }
     }
     // Envia o objeto Snep_Form para a View
     $this->view->form = $form;
 }
コード例 #2
0
 protected function getForm()
 {
     // Create object Snep_Form
     $form = new Snep_Form();
     // Set form action
     $form->setAction($this->getFrontController()->getBaseUrl() . '/ranking-report/index');
     $form_xml = new Zend_Config_Xml('./modules/default/forms/ranking_report.xml');
     $config = Zend_Registry::get('config');
     $period = new Snep_Form_SubForm($this->view->translate("Period"), $form_xml->period);
     $locale = Snep_Locale::getInstance()->getLocale();
     $now = Zend_Date::now();
     if ($locale == 'en_US') {
         $now = $now->toString('YYYY-MM-dd HH:mm');
     } else {
         $now = $now->toString('dd/MM/YYYY HH:mm');
     }
     $yesterday = Zend_Date::now()->subDate(1);
     $initDay = $period->getElement('init_day');
     $initDay->setValue($now);
     $tillDay = $period->getElement('till_day');
     $tillDay->setValue($now);
     $form->addSubForm($period, "period");
     $rank = new Snep_Form_SubForm($this->view->translate("Ranking Options"), $form_xml->rank);
     $selectNumView = $rank->getElement('view');
     for ($index = 1; $index <= 30; $index++) {
         $selectNumView->addMultiOption($index, $index);
     }
     $form->addSubForm($rank, "rank");
     $form->getElement('submit')->setLabel($this->view->translate("Show Report"));
     $form->removeElement("cancel");
     return $form;
 }
コード例 #3
0
 protected function getForm()
 {
     // Create object Snep_Form
     $form = new Snep_Form();
     // Set form action
     $form->setAction($this->getFrontController()->getBaseUrl() . '/services-report/index');
     $form_xml = new Zend_Config_Xml('./modules/default/forms/services_report.xml');
     $config = Zend_Registry::get('config');
     $period = new Snep_Form_SubForm($this->view->translate("Period"), $form_xml->period);
     $validatorDate = new Zend_Validate_Date(Zend_Locale_Format::getDateFormat(Zend_Registry::get('Zend_Locale')));
     $locale = Snep_Locale::getInstance()->getLocale();
     $now = Zend_Date::now();
     if ($locale == 'en_US') {
         $now = $now->toString('YYYY-MM-dd HH:mm');
     } else {
         $now = $now->toString('dd/MM/YYYY HH:mm');
     }
     $yesterday = Zend_Date::now()->subDate(1);
     $initDay = $period->getElement('init_day');
     $initDay->setValue($now);
     //$initDay->addValidator($validatorDate);
     $tillDay = $period->getElement('till_day');
     $tillDay->setValue($now);
     //$tillDay->addValidator($validatorDate);
     $form->addSubForm($period, "period");
     $exten = new Snep_Form_SubForm($this->view->translate("Extensions"), $form_xml->exten);
     $groupLib = new Snep_GruposRamais();
     $groupsTmp = $groupLib->getAll();
     $groupsData = array();
     foreach ($groupsTmp as $key => $group) {
         switch ($group['name']) {
             case 'administrator':
                 $groupsData[$this->view->translate('Administrators')] = $group['name'];
                 break;
             case 'users':
                 $groupsData[$this->view->translate('Users')] = $group['name'];
                 break;
             case 'all':
                 $groupsData[$this->view->translate('All')] = $group['name'];
                 break;
             default:
                 $groupsData[$group['name']] = $group['name'];
         }
     }
     $selectGroup = $exten->getElement('group_select');
     $selectGroup->addMultiOption(null, '----');
     foreach ($groupsData as $key => $value) {
         $selectGroup->addMultiOption($value, $key);
     }
     $selectGroup->setAttrib('onSelect', "enableField('exten-group_select', 'exten-exten_select');");
     $form->addSubForm($exten, "exten");
     $service = new Snep_Form_SubForm($this->view->translate("Services"), $form_xml->service);
     $form->addSubForm($service, "service");
     $form->getElement('submit')->setLabel($this->view->translate("Show Report"));
     $form->removeElement("cancel");
     return $form;
 }
コード例 #4
0
 protected function getForm()
 {
     if ($this->form === Null) {
         $form_xml = new Zend_Config_Xml(Zend_Registry::get("config")->system->path->base . "/modules/default/forms/expression_alias.xml");
         $form = new Snep_Form($form_xml);
         $exprField = new Snep_Form_Element_Html("expression-alias/elements/expr.phtml", "expr", false);
         $exprField->setLabel($this->view->translate("Expressions"));
         $exprField->setOrder(1);
         $form->addElement($exprField);
         $this->form = $form;
     }
     return $this->form;
 }
コード例 #5
0
ファイル: LogsController.php プロジェクト: rootzig/SNEP
 public function indexAction()
 {
     $this->view->breadcrumb = Snep_Breadcrumb::renderPath(array($this->view->translate("Status"), $this->view->translate("System Logs")));
     $config = Zend_Registry::get('config');
     include $config->system->path->base . "/inspectors/Permissions.php";
     $test = new Permissions();
     $response = $test->getTests();
     $form = new Snep_Form(new Zend_Config_Xml('./modules/default/forms/logs.xml', 'general', true));
     $form->setAction($this->getFrontController()->getBaseUrl() . '/logs/view');
     $locale = Snep_Locale::getInstance()->getLocale();
     $now = Zend_Date::now();
     if ($locale == 'en_US') {
         $now = $now->toString('YYYY-MM-dd HH:mm');
     } else {
         $now = $now->toString('dd/MM/YYYY HH:mm');
     }
     $initDay = $form->getElement('init_day');
     $initDay->setValue($now);
     $endDay = $form->getElement('end_day');
     $endDay->setValue($now);
     $status = $form->getElement('status');
     $status->setValue('ALL');
     $realtime = $form->getElement('real_time');
     $realtime->setValue('no');
     $submit = $form->getElement("submit");
     $submit->setLabel("Log Search");
     $this->initLogFile();
     $this->view->form = $form;
 }
コード例 #6
0
 private function getForm()
 {
     $config = Zend_Registry::get('config');
     $db = Zend_Registry::get('db');
     $form = new Snep_Form();
     $form->setAction($this->getFrontController()->getBaseUrl() . '/calls-report/');
     $form->setName('create');
     $form_xml = new Zend_Config_Xml('./modules/default/forms/calls_report.xml');
     // --- Subsection - Periods
     $period = new Snep_Form_SubForm($this->view->translate("Period"), $form_xml->period);
     $locale = Snep_Locale::getInstance()->getLocale();
     $now = Zend_Date::now();
     if ($locale == 'en_US') {
         $now = $now->toString('YYYY-MM-dd HH:mm');
     } else {
         $now = $now->toString('dd/MM/YYYY HH:mm');
     }
     $initDay = $period->getElement('initDay');
     $initDay->setValue($now);
     $finalDay = $period->getElement('finalDay');
     $finalDay->setValue($now);
     $order = $period->getElement('order');
     $order->setValue('data');
     $form->addSubForm($period, "period");
     // Populate groups
     $groupLib = new Snep_GruposRamais();
     $groupsTmp = $groupLib->getAll();
     $groupsData = array();
     foreach ($groupsTmp as $key => $group) {
         switch ($group['name']) {
             case 'administrator':
                 $groupsData[$this->view->translate('Administrators')] = $group['name'];
                 break;
             case 'users':
                 $groupsData[$this->view->translate('Users')] = $group['name'];
                 break;
             case 'all':
                 $groupsData[$this->view->translate('All')] = $group['name'];
                 break;
             default:
                 $groupsData[$group['name']] = $group['name'];
         }
     }
     // --- Subsection -- Source
     $source = new Snep_Form_SubForm($this->view->translate("Source"), $form_xml->source);
     $sourceElement = $source->getElement('selectSrc');
     $sourceElement->addMultiOption(null, '');
     $sourceElement->setAttrib('onChange', 'blockFields($(this).id, $(this).value);');
     $srcType = $source->getElement('srctype');
     $srcType->setValue('src1');
     $form->addSubForm($source, "source");
     // --- Subsection -- Destination
     $destination = new Snep_Form_SubForm($this->view->translate("Destination"), $form_xml->destination);
     $destinationElement = $destination->getElement('selectDst');
     $destinationElement->addMultiOption(null, '');
     $destinationElement->setAttrib('onChange', 'blockFields($(this).id, $(this).value);');
     $dstType = $destination->getElement('dsttype');
     $dstType->setValue('dst1');
     $form->addSubForm($destination, "destination");
     foreach ($groupsData as $key => $value) {
         $sourceElement->addMultiOption($value, $key);
         $destinationElement->addMultiOption($value, $key);
     }
     // --- Subsection - Calls related options
     $calls = new Snep_Form_SubForm($this->view->translate("Calls"), $form_xml->calls);
     // List Cost Centers and populate select
     $select = $db->select()->from(array('cc' => 'ccustos'))->order('codigo');
     $costs = $db->query($select)->fetchAll();
     $costsElement = $calls->getElement('costs_center');
     foreach ($costs as $cost) {
         $costsElement->addMultiOption($cost['codigo'], $cost['tipo'] . ' : ' . $cost['codigo'] . ' - ' . $cost['nome']);
     }
     $calls->getElement('status')->setValue('ALL');
     $calls->getElement('type')->setValue('T');
     $form->addSubForm($calls, "calls");
     // --- Subsection - Other options
     $other = new Snep_Form_SubForm($this->view->translate("Other Options"), $form_xml->others);
     //$other->getElement('graph_type')->setValue('bars');
     $other->getElement('report_type')->setValue('analytical');
     $form->addSubForm($other, "others");
     $form->getElement('submit')->setLabel($this->view->translate("Show Report"));
     $form->removeElement('cancel');
     /*
               $form->addElement(new Zend_Form_Element_Submit("submit_graph",
               array("label" => $this->view->translate("Exibir Gráfico"))
               ));
               $buttonCsv = new Zend_Form_Element_Submit("submit_csv", array("label" => $this->view->translate("Exportar CSV")));
      $buttonCsv->setOrder(5004);
      $buttonCsv->addDecorator(array("closetd" => 'HtmlTag'), array('tag' => 'td', 'closeOnly' => true, 'placement' => Zend_Form_Decorator_Abstract::APPEND));
               $buttonCsv->addDecorator(array("closetr" => 'HtmlTag'), array('tag' => 'tr', 'closeOnly' => true, 'placement' => Zend_Form_Decorator_Abstract::APPEND));
      $form->addElement($buttonCsv);
     */
     return $form;
 }
コード例 #7
0
 /**
  * Migrate contacts to other Contact Group
  */
 public function migrationAction()
 {
     $this->view->breadcrumb = Snep_Breadcrumb::renderPath(array($this->view->translate("Manage"), $this->view->translate("Contact Group"), $this->view->translate("Migrate Contacts")));
     $id = $this->_request->getParam('id');
     $groupAll = new Snep_ContactGroups_Manager();
     $_allGroups = $groupAll->fetchAll();
     foreach ($_allGroups as $group) {
         if ($group['id_contact_group'] != $id) {
             $allGroups[$group['id_contact_group']] = $group['ds_name'];
         }
     }
     Zend_Registry::set('cancel_url', $this->getFrontController()->getBaseUrl() . '/' . $this->getRequest()->getControllerName() . '/index');
     $form = new Snep_Form(new Zend_Config_Xml("modules/default/forms/contact_groups_migration.xml"));
     $form->setAction($this->getFrontController()->getBaseUrl() . '/contact-groups/migration/stage/2');
     if (isset($allGroups)) {
         $form->getElement('group')->setMultiOptions($allGroups);
         $form->getElement('option')->setMultiOptions(array('migrate' => 'migrate contacts to group', 'remove' => 'remove all'))->setValue('migrate');
     } else {
         $form->removeElement('group');
         $form->getElement('option')->setMultiOptions(array('remove' => 'remove all'));
     }
     $this->view->message = $this->view->translate("The excluded group has associated contacts.");
     $form->getElement('id')->setValue($id);
     $stage = $this->_request->getParam('stage');
     if (isset($stage['stage']) && $id) {
         if ($_POST['option'] == 'migrate') {
             $obj = new Snep_Contacts_Manager();
             $select = $obj->select()->where('id_contact_group = ?', $id);
             $contacts = $obj->fetchAll($select)->toarray();
             $idGroup = $_POST['group'];
             $dadosUpdate = array('id_contact_group' => $idGroup);
             foreach ($contacts as $contactselect) {
                 $idContact = $contactselect['id_contact'];
                 $obj->update($dadosUpdate, "id_contact = {$idContact}");
             }
             $groupAll->delete("id_contact_group ={$id}");
         } elseif ($_POST['option'] == 'remove') {
             $obj = new Snep_Contacts_Manager();
             $select = $obj->select()->where('id_contact_group = ?', $id);
             $contacts = $obj->fetchAll($select)->toArray();
             foreach ($contacts as $contact) {
                 $idContact = $contact['id_contact'];
                 $obj->delete("id_contact = {$idContact}");
             }
             $groupAll->delete("id_contact_group ={$id}");
         }
         $this->_redirect($this->getRequest()->getControllerName());
     }
     $this->view->form = $form;
 }
コード例 #8
0
 /**
  * Método edit, editar item conforme id fornecido.
  */
 public function editAction()
 {
     // Define o título da página, é mostrado automaticamente na view.
     $this->view->breadcrumb = $this->view->translate("Exemplo » Editar");
     // Pega o id do item selecionado, passado via GET
     $id = $this->_request->getParam("id");
     // Chama método Example_Cadastro::get(), ele retorna os dados confome o id.
     $dados = Example_Manager::get($id);
     // Parse do arquivo formulário.
     $xml = new Zend_Config_Xml(Zend_Registry::get("config")->system->path->base . "/modules/example/forms/cadastro.xml");
     // Cria objeto Snep_Form
     $form = new Snep_Form($xml);
     // Preenche dados do formulário com dados vindos do banco.
     // Perceba que ele captura o elemento e ao mesmo tempo seta um valor para ele.
     $form->getElement('id')->setValue($dados['id']);
     $form->getElement('nome')->setValue($dados['nome']);
     // Chama método que insere a barra padrão.
     $form->setButton();
     // Verifica se existe dados sendo enviados via $_POST
     // Se for verdadeiro, é porqyue o formulário foi submetido.
     if ($this->_request->getPost()) {
         // Chama método isValid() é confronta os dados submetidos pelo formulário.
         $isValid = $form->isValid($_POST);
         // Caso tudo seja válido chama a classe (Model) para inserir o dado.
         if ($isValid) {
             // Chama método estático para atualizar o registro.
             Example_Manager::update($_POST);
             // Após remover ou nao dados redireciona para método index
             $this->_redirect($this->getRequest()->getModuleName() . '/' . $this->getRequest()->getControllerName());
         }
     }
     // Envia form para a view
     $this->view->form = $form;
 }
コード例 #9
0
 /**
  * Migrate extensions to other Extensions Group
  */
 public function migrationAction()
 {
     $this->view->breadcrumb = Snep_Breadcrumb::renderPath(array($this->view->translate("Manage"), $this->view->translate("Extension Groups"), $this->view->translate("Migrate Extension Group")));
     $id = $this->_request->getParam('id');
     $_allGroups = Snep_ExtensionsGroups_Manager::getAllGroup();
     foreach ($_allGroups as $group) {
         if ($group['name'] != $id) {
             $allGroups[$group['name']] = $group['name'];
         }
     }
     Zend_Registry::set('cancel_url', $this->getFrontController()->getBaseUrl() . '/' . $this->getRequest()->getControllerName() . '/index');
     $form = new Snep_Form();
     $form->setAction($this->getFrontController()->getBaseUrl() . '/' . $this->getRequest()->getControllerName() . '/migration/');
     if (isset($allGroups)) {
         $groupSelect = new Zend_Form_Element_Select('select');
         $groupSelect->setMultiOptions($allGroups);
         $groupSelect->setLabel($this->view->translate($this->view->translate("New Group")));
         $form->addElement($groupSelect);
         $this->view->message = $this->view->translate("This groups has extensions associated. Select another group for these extensions. ");
     } else {
         $groupName = new Zend_Form_Element_Text('new_group');
         $groupName->setLabel($this->view->translate($this->view->translate("New Group")));
         $form->addElement($groupName);
         $this->view->message = $this->view->translate("This is the only group and it has extensions associated. You can migrate these extensions to a new group.");
     }
     $id_exclude = new Zend_Form_Element_Hidden("id");
     $id_exclude->setValue($id);
     $form->addElement($id_exclude);
     if ($this->_request->getPost()) {
         if (isset($_POST['select'])) {
             $toGroup = $_POST['select'];
         } else {
             $new_group = array('group' => $_POST['new_group']);
             $toGroup = Snep_ExtensionsGroups_Manager::addGroup($new_group);
         }
         $extensions = Snep_ExtensionsGroups_Manager::getExtensionsOnlyGroup($id);
         foreach ($extensions as $extension) {
             Snep_ExtensionsGroups_Manager::addExtensionsGroup(array('extensions' => $extension['name'], 'group' => $toGroup));
         }
         Snep_ExtensionsGroups_Manager::delete($id);
         $this->_redirect($this->getRequest()->getControllerName());
     }
     $this->view->form = $form;
 }
コード例 #10
0
ファイル: UsersController.php プロジェクト: rootzig/SNEP
 public function editAction()
 {
     $this->view->breadcrumb = Snep_Breadcrumb::renderPath(array($this->view->translate("Manage"), $this->view->translate("Users"), $this->view->translate("Edit User")));
     $id = $this->_request->getParam("id");
     $obj = new Snep_User_Manager();
     $select = $obj->select()->where("id_user = ?", $id);
     $user = $obj->fetchRow($select)->toArray();
     $form = new Snep_Form(new Zend_Config_Xml('./modules/default/forms/user.xml'));
     $form->getElement('id')->setValue($user['id_user']);
     $form->getElement('ds_login')->setValue($user['ds_login']);
     $form->getElement('ds_mail')->setValue($user['ds_mail']);
     $form->getElement('fg_active')->setValue($user['fg_active']);
     if ($this->_request->getPost()) {
         $form_isValid = $form->isValid($_POST);
         if ($form_isValid) {
             $dados = array('ds_login' => $_POST['ds_login'], 'dt_lastlogin' => $user['dt_lastlogin'], 'ds_mail' => $_POST['ds_mail'], 'fg_active' => $_POST['fg_active'], 'id_profile' => null);
             if ($_POST['cd_password'] != '') {
                 $new_pass = md5($_POST['cd_password']);
                 if ($user['cd_password'] != $new_pass) {
                     $dados['cd_password'] = md5($_POST['cd_password']);
                 }
             }
             $obj->update($dados, "id_user = '******'");
             $this->_redirect($this->getRequest()->getControllerName());
         }
     }
     $this->view->form = $form;
 }
コード例 #11
0
ファイル: QueuesController.php プロジェクト: rootzig/SNEP
 /**
  * Set member queue
  * 
  */
 public function membersAction()
 {
     $queue = $this->_request->getParam("id");
     $this->view->breadcrumb = Snep_Breadcrumb::renderPath(array($this->view->translate("Manage"), $this->view->translate("Queues"), $this->view->translate("Members {$queue}")));
     $members = Snep_Queues_Manager::getMembers($queue);
     $mem = array();
     foreach ($members as $m) {
         $mem[$m['interface']] = $m['interface'];
     }
     $_allMembers = Snep_Queues_Manager::getAllMembers();
     $notMem = array();
     foreach ($_allMembers as $row) {
         $cd = explode(";", $row['canal']);
         foreach ($cd as $canal) {
             if (strlen($canal) > 0) {
                 if (!array_key_exists($canal, $mem)) {
                     $notMem[$canal] = $row['callerid'] . " ({$canal})({$row['group']})";
                 }
             }
         }
     }
     Zend_Registry::set('cancel_url', $this->getFrontController()->getBaseUrl() . '/' . $this->getRequest()->getControllerName() . '/index');
     $form = new Snep_Form();
     $this->view->objSelectBox = 'members';
     $form->setSelectBox($this->view->objSelectBox, $this->view->translate("Add Member"), $notMem, $mem);
     $queueId = new Zend_Form_Element_hidden('id');
     $queueId->setvalue($queue);
     $form->addElement($queueId);
     $this->view->form = $form;
     if ($this->_request->getPost()) {
         Snep_Queues_Manager::removeAllMembers($queue);
         if (isset($_POST['box_add'])) {
             foreach ($_POST['box_add'] as $add) {
                 Snep_Queues_Manager::insertMember($queue, $add);
             }
         }
         $this->_redirect($this->getRequest()->getControllerName() . '/');
     }
 }
コード例 #12
0
ファイル: ExtensionsController.php プロジェクト: rootzig/SNEP
 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;
 }
コード例 #13
0
ファイル: BillingController.php プロジェクト: rootzig/SNEP
 /**
  *  Add Queue
  */
 public function addAction()
 {
     $this->view->breadcrumb = Snep_Breadcrumb::renderPath(array($this->view->translate("Carrier"), $this->view->translate("Add")));
     $form = new Snep_Form(new Zend_Config_Xml("modules/default/forms/queues.xml"));
     $form->setAction($this->getFrontController()->getBaseUrl() . '/' . $this->getRequest()->getControllerName() . '/add');
     $this->view->url = $this->getFrontController()->getBaseUrl() . '/' . $this->getRequest()->getControllerName();
     $carrier = new Snep_Carrier_Manager();
     foreach ($carrier->fetchAll() as $_carrier) {
         $carriers[$_carrier['id_carrier']] = $_carrier['ds_name'];
     }
     $this->view->carriers = $carriers;
     $states['--'] = '--';
     $statesList = new Snep_State_Manager();
     foreach ($statesList->fetchAll() as $state) {
         $states[$state['id_state']] = $state['ds_name'];
     }
     $this->view->states = $states;
     $cities['--'] = '--';
     foreach (Snep_Billing_Manager::getCity('AC') as $city) {
         $cities[$city['name']] = $city['name'];
     }
     $this->view->cities = $cities;
     $dados = $this->_request->getParams();
     if ($this->_request->getPost()) {
         $form_isValid = true;
         $this->view->error = array();
         if (!preg_match('/[0-9]+$/', $dados['ddd']) || $dados['ddd'] == "") {
             $form_isValid = false;
             $this->view->error['ddd'] = $this->view->translate("City Code not numeric");
         }
         if (!preg_match('/[0-9]+$/', $dados['ddi']) || $dados['ddi'] == "") {
             $form_isValid = false;
             $this->view->error['ddi'] = $this->view->translate("Country Code not numeric");
         }
         if (!preg_match('/[0-9]+$/', $dados['prefixo']) || $dados['prefixo'] == "") {
             $form_isValid = true;
             $this->view->error['prefixo'] = $this->view->translate("Prefix not numeric");
         }
         if ($dados['operadora'] == "") {
             $form_isValid = false;
             $this->view->error['operadora'] = $this->view->translate("Carrier not selected ");
         }
         if ($form_isValid) {
             if ($_POST['ddd'] == "") {
                 $_POST['ddd'] = 0;
             }
             if ($_POST['ddi'] == "") {
                 $_POST['ddi'] = 0;
             }
             $billing = Snep_Billing_Manager::getPrefix($_POST);
             if ($billing) {
                 $form_isValid = false;
                 $this->view->message = $this->view->translate("This bill is already set");
             }
         }
         if ($form_isValid) {
             $xdados = array('data' => $_POST['data'], 'carrier' => $_POST['operadora'], 'country_code' => $_POST['ddi'], 'country' => $_POST['pais'], 'city_code' => $_POST['ddd'], 'city' => $_POST['cidade'], 'state' => $_POST['estado'], 'prefix' => $_POST['prefixo'], 'tbf' => $_POST['vfix'], 'tbc' => $_POST['vcel']);
             Snep_Billing_Manager::add($xdados);
             $this->_redirect($this->getRequest()->getControllerName());
         }
         $this->view->dados = isset($dados) ? $dados : null;
     }
 }
コード例 #14
0
ファイル: TrunksController.php プロジェクト: rootzig/SNEP
 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));
         }
     }
 }
コード例 #15
0
ファイル: SoundFilesController.php プロジェクト: rootzig/SNEP
 /**
  * Edit Carrier
  */
 public function editAction()
 {
     $this->view->breadcrumb = Snep_Breadcrumb::renderPath(array($this->view->translate("Sound Files"), $this->view->translate("Edit")));
     $file = $this->_request->getParam("file");
     $data = Snep_SoundFiles_Manager::get($file);
     $this->view->file = $data;
     $form = new Snep_Form(new Zend_Config_Xml("modules/default/forms/sound_files.xml"));
     $file = new Zend_Form_Element_File('file');
     $file->setLabel($this->view->translate('Sound Files'))->addValidator(new Zend_Validate_File_Extension(array('wav', 'gsm')))->removeDecorator('DtDdWrapper')->setIgnore(true);
     $form->addElement($file);
     $form->getElement('filename')->setValue($data['arquivo'])->setAttrib('readonly', true);
     $form->getElement('description')->setLabel($this->view->translate('Description'))->setValue($data['descricao'])->setRequired(true);
     if ($this->_request->getPost()) {
         $form_isValid = $form->isValid($_POST);
         $dados = $this->_request->getParams();
         if ($form_isValid) {
             if ($_FILES['file']['name'] != "" && $_FILES['file']['size'] > 0) {
                 $path_sound = Zend_Registry::get('config')->system->path->asterisk->sounds;
                 $filepath = Snep_SoundFiles_Manager::verifySoundFiles($_POST['filename'], true);
                 exec("mv {$filepath['fullpath']} {$path_sound}/backup/ ");
                 exec("mv  {$_FILES['file']['tmp_name']} {$filepath['fullpath']} ");
             }
             Snep_SoundFiles_Manager::edit($_POST);
             $this->_redirect($this->getRequest()->getControllerName());
         }
     }
     $this->view->form = $form;
 }
コード例 #16
0
ファイル: RouteController.php プロジェクト: rootzig/SNEP
 /**
  * Generate the form for routes
  *
  * @return Zend_Form
  */
 protected function getForm()
 {
     if ($this->form === Null) {
         $form_xml = new Zend_Config_Xml(Zend_Registry::get("config")->system->path->base . "/modules/default/forms/route.xml");
         $form = new Snep_Form($form_xml);
         $actions = PBX_Rule_Actions::getInstance();
         $installed_actions = array();
         foreach ($actions->getInstalledActions() as $action) {
             $action_instance = new $action();
             $installed_actions[$action] = $action_instance->getName();
         }
         asort($installed_actions);
         $this->view->actions = $installed_actions;
         $src = new Snep_Form_Element_Html("route/elements/src.phtml", "src", false);
         $src->setLabel($this->view->translate("Source"));
         $src->setOrder(1);
         $form->addElement($src);
         $dst = new Snep_Form_Element_Html("route/elements/dst.phtml", "dst", false);
         $dst->setLabel($this->view->translate("Destiny"));
         $dst->setOrder(2);
         $form->addElement($dst);
         $time = new Snep_Form_Element_Html("route/elements/time.phtml", "time", false);
         $time->setOrder(4);
         $time->setLabel($this->view->translate("Valid times"));
         $form->addElement($time);
         $form->addElement(new Snep_Form_Element_Html("route/elements/actions.phtml", "actions"));
         $this->form = $form;
         $groups = new Snep_GruposRamais();
         $groups = $groups->getAll();
         $group_list = "";
         foreach ($groups as $group) {
             $group_list .= "[\"{$group['name']}\", \"{$group['name']}\"],";
         }
         $group_list = "[" . trim($group_list, ",") . "]";
         $this->view->group_list = $group_list;
         $alias_list = "";
         foreach (PBX_ExpressionAliases::getInstance()->getAll() as $alias) {
             $alias_list .= "[\"{$alias['id']}\", \"{$alias['name']}\"],";
         }
         $alias_list = "[" . trim($alias_list, ",") . "]";
         $this->view->alias_list = $alias_list;
         $trunks = "";
         foreach (PBX_Trunks::getAll() as $trunk) {
             $trunks .= "[\"{$trunk->getId()}\", \"{$trunk->getName()}\"],";
         }
         $trunks = "[" . trim($trunks, ",") . "]";
         $this->view->trunk_list = $trunks;
         $cgroup_list = "";
         $cgroup_manager = new Snep_ContactGroups_Manager();
         foreach ($cgroup_manager->getAll() as $cgroup) {
             $cgroup_list .= "[\"{$cgroup['id']}\", \"{$cgroup['name']}\"],";
         }
         $cgroup_list = "[" . trim($cgroup_list, ",") . "]";
         $this->view->contact_groups_list = $cgroup_list;
     }
     return $this->form;
 }
コード例 #17
0
ファイル: InstallerController.php プロジェクト: rootzig/SNEP
 public function configureAction()
 {
     $objInspector = new Snep_Inspector('Permissions');
     $inspect = $objInspector->getInspects();
     $this->view->error = $inspect['Permissions'];
     $this->view->hideMenu = true;
     $this->view->breadcrumb = $this->view->translate("Installer » Configuration");
     $form_config = new Zend_Config_Xml("./modules/default/formsinstaller.xml");
     $form = new Snep_Form();
     $form->setAction($this->getFrontController()->getBaseUrl() . '/installer/configure');
     $asterisk_form = new Snep_Form_SubForm($this->view->translate("Asterisk Configuration"), $form_config->asterisk);
     $database_form = new Snep_Form_SubForm($this->view->translate("Database Configuration"), $form_config->database);
     $snep_form = new Snep_Form_SubForm($this->view->translate("Admin Password"), $form_config->snep);
     $form->addSubForm($database_form, "database");
     $form->addSubForm($asterisk_form, "asterisk");
     $form->addSubForm($snep_form, "snep");
     $submit_button = $form->getElement('submit');
     if ($this->view->error['error']) {
         $submit_button->setAttrib('disabled', true);
     }
     if ($this->getRequest()->isPost()) {
         $form_isValid = $form->isValid($_POST);
         $snep_data = $form->getValue("snep");
         if ($snep_data['password'] !== $snep_data['confirmpassword']) {
             $snep_form->getElement('confirmpassword')->addError($this->view->translate("The password confirmation is different from the original"));
             $form_isValid = false;
         }
         if (!$asterisk_form->isErrors()) {
             $asterisk_data = $form->getValue("asterisk");
             $asterisk = new Asterisk_AMI(null, $asterisk_data);
             try {
                 $asterisk->connect();
             } catch (Asterisk_Exception_Auth $ex) {
                 $asterisk_form->getElement('secret')->addError($this->view->translate("User and/or password rejected by Asterisk"));
                 $form_isValid = false;
             } catch (Asterisk_Exception_CantConnect $ex) {
                 $asterisk_form->getElement('server')->addError($this->view->translate("Unable to connect: %s", $ex->getMessage()));
                 $form_isValid = false;
             }
         }
         if (!$database_form->isErrors()) {
             $database_data = $form->getValue('database');
             $db = Zend_Db::factory('Pdo_Mysql', $database_data);
             try {
                 $db->getConnection();
             } catch (Zend_Db_Exception $ex) {
                 $database_form->getElement('hostname')->addError($this->view->translate("Unable to connect: %s", $ex->getMessage()));
                 $form_isValid = false;
             }
         }
         if ($form_isValid) {
             try {
                 $this->install($db);
             } catch (Exception $ex) {
                 $this->view->message = $ex->getMessage();
                 $this->renderScript("installer/error.phtml");
             }
             // Setando usuário do admin.
             $db->update("peers", array('password' => $snep_data['password']), "id = 1");
             // Gravando alterações no arquivo de configuração.
             $config_file = "./includes/setup.conf";
             $config = new Zend_Config_Ini($config_file, null, true);
             $config->ambiente->ip_sock = $_POST['asterisk']['server'];
             $config->ambiente->user_sock = $_POST['asterisk']['username'];
             $config->ambiente->pass_sock = $_POST['asterisk']['secret'];
             $config->ambiente->db->host = $_POST['database']['hostname'];
             $config->ambiente->db->username = $_POST['database']['username'];
             $config->ambiente->db->password = $_POST['database']['password'];
             $config->ambiente->db->dbname = $_POST['database']['dbname'];
             $writer = new Zend_Config_Writer_Ini(array('config' => $config, 'filename' => $config_file));
             // Grava arquivo.
             $writer->write();
             $this->_redirect("installer/installed");
         }
     }
     $this->view->form = $form;
 }
コード例 #18
0
ファイル: CarrierController.php プロジェクト: rootzig/SNEP
 /**
  * Edit Carrier
  */
 public function editAction()
 {
     $this->view->breadcrumb = Snep_Breadcrumb::renderPath(array($this->view->translate("Carrier"), $this->view->translate("Edit")));
     $this->view->objSelectBox = "carrier";
     $id = $this->_request->getParam("id");
     $xml = new Zend_Config_Xml("modules/default/forms/carrier.xml");
     $form = new Snep_Form($xml);
     $carriers = new Snep_Carrier_Manager();
     $carrier = $carriers->find($id)->current();
     // Popula lista de operadoras
     $carrierList = array();
     foreach ($carriers->fetchAll() as $carrierRow) {
         $carrierList[$carrierRow->id_carrier] = $carrierRow->ds_name;
     }
     $carrierElement = $form->getElement('name');
     $carrierElement->setMultiOptions($carrierList)->removeDecorator('DtDdWrapper')->setRegisterInArrayValidator(false);
     $name = $form->getElement('name');
     $name->setValue($carrier['id_carrier'])->setAttrib('disabled', 'disabled');
     $form->getElement('ta')->setValue($carrier['vl_start']);
     $form->getElement('tf')->setValue($carrier['vl_fractionation']);
     $_idleCostCenter = Snep_Carrier_Manager::getIdleCostCenter();
     $idleCostCenter = array();
     foreach ($_idleCostCenter as $idle) {
         $idleCostCenter[$idle['id_costcenter']] = $idle['id_costcenter'] . " : " . $idle['cd_type'] . " - " . $idle['ds_name'];
     }
     if (isset($id)) {
         $_selectedCostCenter = $carrier->findSnep_CostCenter_Manager();
         $selectedCostCenter = array();
         foreach ($_selectedCostCenter as $selected) {
             $selectedCostCenter[$selected['id_costcenter']] = $selected['id_costcenter'] . " : " . $selected['cd_type'] . " - " . $selected['ds_name'];
         }
     }
     $form->setSelectBox($this->view->objSelectBox, $this->view->translate('Cost Center'), $idleCostCenter, $selectedCostCenter);
     $formId = new Zend_Form_Element_Hidden('id');
     $formId->setValue($id);
     $form->addElement($formId);
     if ($this->_request->getPost()) {
         $form_isValid = $form->isValid($_POST);
         $dados = $this->_request->getParams();
         if ($form_isValid) {
             $dados['active'] = 1;
             $manager = new Snep_Carrier_Manager();
             $manager->save($id, $dados);
             $this->_redirect($this->getRequest()->getControllerName());
         }
     }
     $this->view->form = $form;
 }
コード例 #19
0
ファイル: ParametersController.php プロジェクト: rootzig/SNEP
 public function indexAction()
 {
     // Title
     $this->view->breadcrumb = Snep_Breadcrumb::renderPath(array($this->view->translate("Configure"), $this->view->translate("Parameters")));
     // Get configuration properties from Zend_Registry
     $config = Zend_Registry::get('config');
     // Include Inpector class, for permission test
     include_once $config->system->path->base . "/inspectors/Permissions.php";
     $test = new Permissions();
     $response = $test->getTests();
     // Verify if there's any error, and if it's related to the setup.conf file
     if ($response['error'] && strpos($response['message'], "setup.conf") > 0) {
         // seta variavel verificada no template
         $this->view->error = $this->view->translate("The File includes/setup.conf does not have permission to be modified.");
     }
     // Create object Snep_Form
     $form = new Snep_Form();
     // Set form action
     $form->setAction($this->getFrontController()->getBaseUrl() . '/parameters/index');
     $form_xml = new Zend_Config_Xml('./modules/default/forms/setup.conf.xml');
     // Section General
     $general = new Snep_Form_SubForm($this->view->translate("General Configuration"), $form_xml->general);
     // Setting propoertie values
     $empName = $general->getElement('emp_nome');
     $empName->setValue($config->ambiente->emp_nome);
     $debug = $general->getElement('debug');
     $debug->setValue($config->system->debug);
     $ipSock = $general->getElement('ip_sock');
     $ipSock->setValue($config->ambiente->ip_sock);
     $userSock = $general->getElement('user_sock');
     $userSock->setValue($config->ambiente->user_sock);
     $passSock = $general->getElement('pass_sock');
     $passSock->setValue($config->ambiente->pass_sock);
     $email = $general->getElement('mail');
     $email->setValue($config->system->mail);
     $lineLimit = $general->getElement('linelimit');
     $lineLimit->setValue($config->ambiente->linelimit);
     $dstExceptions = $general->getElement('dst_exceptions');
     $dstExceptions->setValue($config->ambiente->dst_exceptions);
     $conferenceApp = $general->getElement('conference_app');
     $conferenceApp->setValue($config->ambiente->conference_app);
     $form->addSubForm($general, "general");
     $locale_form = new Snep_Form_SubForm($this->view->translate("Locale Configuration"), $form_xml->locale);
     $locale = Snep_Locale::getInstance()->getZendLocale();
     $locales = array();
     foreach ($locale->getTranslationList("territory", Snep_Locale::getInstance()->getLanguage(), 2) as $ccode => $country) {
         $locales[$country] = $locale->getLocaleToTerritory($ccode);
     }
     ksort($locales, SORT_LOCALE_STRING);
     foreach ($locales as $country => $ccode) {
         $locale_form->getElement("locale")->addMultiOption($ccode, $country);
     }
     $locale_form->getElement("locale")->setValue(Snep_Locale::getInstance()->getLocale());
     foreach ($locale->getTranslationList("territorytotimezone", Snep_Locale::getInstance()->getLanguage()) as $timezone => $territory) {
         $locale_form->getElement("timezone")->addMultiOption($timezone, $timezone);
     }
     $locale_form->getElement("timezone")->setValue(Snep_Locale::getInstance()->getTimezone());
     $languages = array();
     $languageElement = $locale_form->getElement("language");
     $available_languages = Snep_Locale::getInstance()->getAvailableLanguages();
     foreach ($locale->getTranslationList("language", Snep_Locale::getInstance()->getLanguage()) as $lcode => $language) {
         if (in_array($lcode, $available_languages)) {
             $languageElement->addMultiOption($lcode, ucfirst($language));
         }
     }
     $languageElement->setValue(Snep_Locale::getInstance()->getLanguage());
     $form->addSubForm($locale_form, "locale");
     // Section Recording
     $recording = new Snep_Form_SubForm($this->view->translate("Call Recording Configuration"), $form_xml->recording);
     // Setting propoertie values
     $application = $recording->getElement('application');
     $application->setValue($config->general->record->application);
     $flag = $recording->getElement('flag');
     $flag->setValue($config->general->record->flag);
     $recordMp3 = $recording->getElement('record_mp3');
     $recordMp3->setValue($config->general->record_mp3);
     $pathVoice = $recording->getElement('path_voz');
     $pathVoice->setValue($config->ambiente->path_voz);
     $pathVoiceBkp = $recording->getElement('path_voz_bkp');
     $pathVoiceBkp->setValue($config->ambiente->path_voz_bkp);
     $form->addSubForm($recording, "gravacao");
     // Section Trunks
     $trunks = new Snep_Form_SubForm($this->view->translate("Trunks Configuration"), $form_xml->trunks);
     // Setting propoertie values
     $qualControlValue = $trunks->getElement('valor_controle_qualidade');
     $qualControlValue->setValue($config->ambiente->valor_controle_qualidade);
     $form->addSubForm($trunks, "troncos");
     // Verify if the request is a post
     if ($this->_request->getPost()) {
         $formIsValid = $form->isValid($_POST);
         $formData = $this->getRequest()->getParams();
         // Specific verification for propertie path_voice
         if (!file_exists($formData['gravacao']['path_voz'])) {
             $recording->getElement('path_voz')->addError($this->view->translate("Invalid path"));
             $formIsValid = false;
         }
         //Validates form, then sets propertie values and records it on the configuration file
         if ($formIsValid) {
             $configFile = APPLICATION_PATH . "/includes/setup.conf";
             $config = new Zend_Config_Ini($configFile, null, true);
             $config->ambiente->emp_nome = $formData['general']['emp_nome'];
             $config->system->debug = $formData['general']['debug'];
             $config->system->language = $formData['locale']['language'];
             $config->system->locale = $formData['locale']['locale'];
             $config->system->timezone = $formData['locale']['timezone'];
             $config->ambiente->ip_sock = $formData['general']['ip_sock'];
             $config->ambiente->user_sock = $formData['general']['user_sock'];
             $config->ambiente->pass_sock = $formData['general']['pass_sock'];
             $config->system->mail = $formData['general']['mail'];
             $config->ambiente->linelimit = $formData['general']['linelimit'];
             $config->ambiente->dst_exceptions = $formData['general']['dst_exceptions'];
             $config->ambiente->conference_app = $formData['general']['conference_app'];
             $config->general->record->application = $formData['gravacao']['application'];
             $config->general->record->flag = $formData['gravacao']['flag'];
             $config->general->record_mp3 = $formData['gravacao']['record_mp3'];
             $config->ambiente->path_voz = $formData['gravacao']['path_voz'];
             $config->ambiente->path_voz_bkp = $formData['gravacao']['path_voz_bkp'];
             $config->ambiente->valor_controle_qualidade = $formData['troncos']['valor_controle_qualidade'];
             $writer = new Zend_Config_Writer_Ini(array('config' => $config, 'filename' => $configFile));
             // Write file
             $writer->write();
             $this->_redirect('parameters');
         }
     }
     $this->view->form = $form;
 }
コード例 #20
0
ファイル: ContactsController.php プロジェクト: rootzig/SNEP
 /**
  * Export contacts for CSV file.
  */
 public function exportAction()
 {
     $this->view->breadcrumb = Snep_Breadcrumb::renderPath(array($this->view->translate("Manage"), $this->view->translate("Contacts"), $this->view->translate("Export CSV")));
     if ($this->_request->getPost()) {
         $db = Zend_Registry::get('db');
         $select = $db->select()->from(array("n" => "contact"), array("n.id_contact as id", "n.ds_name as name", "n.ds_city as city", "n.ds_state as state", "n.ds_cep as cep", "n.ds_phone as phone", "n.ds_cell_phone as cellphone", "g.ds_name as group"))->join(array("g" => "contact_group"), 'n.id_contact_group = g.id_contact_group', array())->order('n.id_contact');
         if ($_POST['group'] != '0') {
             $select->where('g.id_contact_group = ?', $_POST['group']);
         }
         $stmt = $db->query($select);
         $contacts = $stmt->fetchAll();
         $headers = array('id_contact' => $this->view->translate('Code'), 'ds_nome' => $this->view->translate('Name'), 'ds_city' => $this->view->translate('City'), 'ds_state' => $this->view->translate('State'), 'ds_cep' => $this->view->translate('ZipCode'), 'ds_phone' => $this->view->translate('Phone'), 'ds_cell_phone' => $this->view->translate('Mobile'), 'id_contact_group' => $this->view->translate('Grupo'));
         if (count($contacts) > 0) {
             $csv = new Snep_Csv();
             $csv_data = $csv->generate($contacts, $headers);
             $this->_helper->layout->disableLayout();
             $this->_helper->viewRenderer->setNoRender();
             $dateNow = new Zend_Date();
             $fileName = $this->view->translate('Contacts_csv_') . $dateNow->toString($this->view->translate(" dd-MM-yyyy_hh'h'mm'm' ")) . '.csv';
             header('Content-type: application/octet-stream');
             header('Content-Disposition: attachment; filename="' . $fileName . '"');
             echo $csv_data;
         } else {
             $this->view->message = $this->view->translate('A Selecao nao retornou resultados');
         }
     } else {
         $this->view->message = $this->view->translate('Select a contact group to export.');
         $group = new Snep_ContactGroups_Manager();
         $_allGroups = $group->fetchAll();
         foreach ($_allGroups as $group) {
             $allGroups[$group['id_contact_group']] = $group['ds_name'];
         }
         $form = new Snep_Form();
         $select = new Zend_Form_Element_Select('group');
         $select->addMultiOption("0", "All");
         if (count($allGroups > 0)) {
             $select->addMultiOptions($allGroups);
         }
         $form->addElement($select);
         $this->view->form = $form;
         $this->renderScript("contacts/export.phtml");
     }
 }
コード例 #21
0
 public function editfileAction()
 {
     $fileName = $this->_request->getParam('file');
     $class = $this->_request->getParam('class');
     $className = Snep_SoundFiles_Manager::getClasse($class);
     $files = Snep_SoundFiles_Manager::getClassFiles($className);
     $_files = array('arquivo' => '', 'descricao' => '', 'tipo' => '', 'secao' => $class, 'full' => '');
     foreach ($files as $name => $file) {
         if ($name == $fileName) {
             if (isset($file['arquivo'])) {
                 $_files = $file;
             }
         }
     }
     $this->view->breadcrumb = Snep_Breadcrumb::renderPath(array($this->view->translate("Music on Hold Sessions"), $this->view->translate("Edit File"), $className));
     $form = new Snep_Form(new Zend_Config_Xml("modules/default/forms/sound_files.xml"));
     $form->setAction($this->getFrontController()->getBaseUrl() . '/' . $this->getRequest()->getControllerName() . "/editfile/file/{$fileName}/class/{$class}");
     $file = new Zend_Form_Element_File('file');
     $file->setLabel($this->view->translate('Sound File'))->addValidator(new Zend_Validate_File_Extension(array('wav', 'gsm')))->removeDecorator('DtDdWrapper')->setIgnore(true);
     $form->addElement($file);
     $form->getElement('description')->setValue($_files['descricao']);
     $section = new Zend_Form_Element_Hidden('section');
     $section->setValue($_files['secao']);
     $form->addElement($section);
     $originalName = new Zend_Form_Element_Hidden('originalName');
     $originalName->setValue($fileName);
     $form->addElement($originalName);
     $originalPath = new Zend_Form_Element_Hidden('originalPath');
     $originalPath->setValue($_files['full']);
     $form->addElement($originalPath);
     $form->removeElement('type');
     if ($this->_request->getPost()) {
         $class = Snep_SoundFiles_Manager::getClasse($_POST['section']);
         $form_isValid = $form->isValid($_POST);
         $dados = $this->_request->getParams();
         $invalid = array('â', 'ã', 'á', 'à', 'ẽ', 'é', 'è', 'ê', 'í', 'ì', 'ó', 'õ', 'ò', 'ú', 'ù', 'ç', " ", '@', '!');
         $valid = array('a', 'a', 'a', 'a', 'e', 'e', 'e', 'e', 'i', 'i', 'o', 'o', 'o', 'u', 'u', 'c', "_", '_', '_');
         if ($_FILES['file']['size'] > 0) {
             $oldName = $_POST['originalName'];
             $originalName = str_replace($invalid, $valid, $_FILES['file']['name']);
             $files = Snep_SoundFiles_Manager::get($originalName);
             if ($files) {
                 $file->addError($this->view->translate("The file already exists"));
                 $form_isValid = false;
             }
             if ($form_isValid) {
                 $uploadName = $_FILES['file']['tmp_name'];
                 $arq_tmp = $class['directory'] . "/tmp/" . $originalName;
                 $arq_dst = $class['directory'] . "/" . $originalName;
                 $arq_bkp = $class['directory'] . "/backup/" . $originalName;
                 $arq_orig = $class['directory'] . "/" . $originalName;
                 exec("mv {$uploadName} {$arq_tmp}");
                 $fileNe = basename($arq_dst, 'wav');
                 if ($_POST['gsm']) {
                     exec("sox {$arq_tmp} -r 8000 {$fileNe}.gsm");
                     $exists = file_exists($fileNe . "gsm");
                 } else {
                     exec("sox {$arq_tmp} -r 8000 -c 1 -e signed-integer -b 16 {$arq_dst}");
                     $exists = file_exists($arq_dst);
                 }
             }
             if ($exists) {
                 exec("rm -f {$_POST['originalPath']}");
                 Snep_SoundFiles_Manager::remove($oldName);
                 Snep_SoundFiles_Manager::add(array('arquivo' => $originalName, 'descricao' => $dados['description'], 'data' => new Zend_Db_Expr('NOW()'), 'tipo' => 'MOH', 'secao' => $dados['section']));
             }
         } else {
             $originalName = $_POST['originalName'];
             Snep_SoundFiles_Manager::editClassFile(array('arquivo' => $originalName, 'descricao' => $dados['description'], 'data' => new Zend_Db_Expr('NOW()'), 'tipo' => 'MOH', 'secao' => $dados['section']));
         }
         $this->_redirect($this->getRequest()->getControllerName() . "/file/class/{$className['name']}/");
     }
     $this->view->form = $form;
 }
コード例 #22
0
 public function editAction()
 {
     $this->view->breadcrumb = Snep_Breadcrumb::renderPath(array($this->view->translate("Manage"), $this->view->translate("Pickup Groups"), $this->view->translate("Edit Pickup Group")));
     $id = $this->_request->getParam('group');
     $pickupgroupObj = new Snep_PickupGroups_Manager();
     Zend_Registry::set('cancel_url', $this->getFrontController()->getBaseUrl() . '/' . $this->getRequest()->getControllerName() . '/index');
     $form_xml = new Zend_Config_Xml("modules/default/forms/pickupGroup.xml");
     $form = new Snep_Form($form_xml->general);
     $form->setAction($this->getFrontController()->getBaseUrl() . '/' . $this->getRequest()->getControllerName() . "/edit/group/{$id}");
     $pickupgroup = $pickupgroupObj->fetchRow('id_pickupgroup = ' . $id);
     $name = $form->getElement('name')->setValue($pickupgroup->ds_name);
     $name = $form->getElement('name')->setLabel($this->view->translate("Name"));
     if ($this->_request->getPost()) {
         $form_isValid = $form->isValid($_POST);
         $dados = $this->_request->getParams();
         if ($form_isValid) {
             $pickupgroup->ds_name = $dados['name'];
             $pickupgroup->save();
             $this->_redirect($this->getRequest()->getControllerName());
         }
     }
     $this->view->form = $form;
     $this->renderScript("pickup-groups/add_edit.phtml");
 }
コード例 #23
0
ファイル: CnlController.php プロジェクト: rootzig/SNEP
 public function indexAction()
 {
     $this->view->breadcrumb = Snep_Breadcrumb::renderPath(array($this->view->translate("Configure"), $this->view->translate("CNL Update")));
     $config = Zend_Registry::get('config');
     $this->view->pathweb = $config->system->path->web;
     // verification procedure
     $db = Zend_Registry::get('db');
     $select = $db->select()->from('state');
     $stmt = $select->query();
     $result = $stmt->fetchAll();
     // insert state data
     if (count($result) < 26) {
         $brStates = array('AC' => 'Acre', 'AL' => 'Alagoas', 'AM' => 'Amazonas', 'AP' => 'Amapá', 'BA' => 'Bahia', 'CE' => 'Ceará', 'DF' => 'Distrito Federal', 'ES' => 'Espírito Santo', 'GO' => 'Goiás', 'MA' => 'Maranhão', 'MG' => 'Minas Gerais', 'MS' => 'Mato Grosso do Sul', 'MT' => 'Mato Grosso', 'PA' => 'Pará', 'PB' => 'Paraíba', 'PE' => 'Pernambuco', 'PI' => 'Piauí', 'PR' => 'Paraná', 'RJ' => 'Rio de Janeiro', 'RN' => 'Rio Grande do Norte', 'RO' => 'Rondônia', 'RR' => 'Roraima', 'RS' => 'Rio Grande do Sul', 'SC' => 'Santa Catarina', 'SE' => 'Sergipe', 'SP' => 'São Paulo', 'TO' => 'Tocantins');
         foreach ($brStates as $uf => $state) {
             $db->beginTransaction();
             try {
                 $_state = array('ds_code' => $uf, 'ds_name' => $state);
                 $db->insert('state', $_state);
                 $db->commit();
             } catch (Exception $ex) {
                 $db->rollBack();
                 throw $ex;
             }
         }
     }
     $form = new Snep_Form();
     $form->setAction($this->getFrontController()->getBaseUrl() . "/default/cnl/index");
     $this->view->formAction = $this->getFrontController()->getBaseUrl() . "/default/cnl/index";
     $element = new Zend_Form_Element_File('cnl');
     $element->setLabel($this->view->translate('CNL File'))->setDestination('/tmp/')->setRequired(true);
     $element->addValidator('Extension', false, array('bz2', 'json'));
     $element->removeDecorator('DtDdWrapper');
     $form->addElement($element, 'cnl');
     $form->getElement("submit")->setLabel($this->view->translate("Save"));
     $form->setAttrib('enctype', 'multipart/form-data');
     $this->view->valid = true;
     if ($this->_request->getPost()) {
         $form_isValid = $form->isValid($_POST);
         $this->view->valid = $form_isValid;
         if ($form_isValid) {
             $data = $_POST;
             $adapter = new Zend_File_Transfer_Adapter_Http();
             if ($adapter->isValid()) {
                 $adapter->receive();
                 $fileName = $adapter->getFileName();
                 $json = file_get_contents($fileName);
                 $cnl = Zend_Json_Decoder::decode($json, Zend_Json::TYPE_ARRAY);
                 $data = $cnl["operadoras"];
                 unset($cnl["operadoras"]);
                 $db->delete('city_code');
                 $db->delete('carrier_prefix');
                 $db->delete('city');
                 foreach ($data as $carrier => $id) {
                     Snep_Cnl::addOperadora($id, $carrier);
                 }
                 foreach ($cnl as $data => $id) {
                     foreach ($id as $state => $es) {
                         foreach ($es as $ddd => $d) {
                             foreach ($d as $city => $pre) {
                                 $stateId = Snep_Cnl::fetchStateId($state);
                                 $cityId = Snep_Cnl::addCidade($city);
                                 Snep_Cnl::addDDD($ddd, $stateId, $cityId);
                                 foreach ($pre as $prefix => $op) {
                                     Snep_Cnl::addPrefixo($prefix, $cityId, $op);
                                 }
                             }
                         }
                     }
                 }
                 $this->view->message = $this->view->translate('A lista de informações CNL foi atualizada com sucesso.');
             } else {
                 throw new ErrorException($this->view->translate("File format is not valid"));
             }
         }
     }
     $this->view->form = $form;
 }
コード例 #24
0
ファイル: CostCenterController.php プロジェクト: rootzig/SNEP
 /**
  * Edit Cost Center's
  */
 public function editAction()
 {
     $id = $this->_request->getParam('id');
     $this->view->breadcrumb = Snep_Breadcrumb::renderPath(array($this->view->translate("Manage"), $this->view->translate("Cost Center"), $this->view->translate("Edit")));
     $obj = new Snep_CostCenter_Manager();
     $select = $obj->select()->where('id_costcenter = ?', $id);
     $cost_center = $obj->fetchRow($select)->toArray();
     Zend_Registry::set('cancel_url', $this->getFrontController()->getBaseUrl() . '/' . $this->getRequest()->getControllerName() . '/index');
     $form = new Snep_Form(new Zend_Config_Xml("modules/default/forms/cost_center.xml"));
     $form->setAction($this->getFrontController()->getBaseUrl() . '/' . $this->getRequest()->getControllerName() . '/edit/id/' . $id);
     $idcc = new Zend_Form_Element_Hidden('id_costcenter');
     $idcc->setValue($cost_center['id_costcenter']);
     $form->getElement('id')->setValue($cost_center['cd_code'])->setAttrib('readonly', true);
     $form->getElement('name')->setValue($cost_center['ds_name']);
     $form->getElement('description')->setValue($cost_center['ds_description']);
     $form->getElement('type')->setValue($cost_center['cd_type']);
     $form->addElement($idcc);
     if ($this->_request->getPost()) {
         $_POST['id'] = trim($_POST['id']);
         $form_isValid = $form->isValid($_POST);
         $data = array('cd_code' => trim($_POST['id']), 'ds_name' => $_POST['name'], 'cd_type' => $_POST['type'], 'ds_description' => $_POST['description'], 'id_carrier' => null);
         if ($form_isValid) {
             $costCenter = new Snep_CostCenter_Manager();
             $costCenter->update($data, "id_costcenter = {$_POST['id_costcenter']}");
             $this->_redirect($this->getRequest()->getControllerName());
         }
     }
     $this->view->form = $form;
 }