Exemplo n.º 1
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;
 }
Exemplo n.º 2
0
 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;
 }
Exemplo n.º 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;
 }
Exemplo n.º 4
0
 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;
 }
Exemplo n.º 5
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;
 }
Exemplo n.º 6
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;
 }
Exemplo n.º 7
0
 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;
 }
Exemplo n.º 8
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;
 }
Exemplo n.º 9
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");
 }
Exemplo n.º 10
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;
 }
Exemplo n.º 11
0
 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;
 }
Exemplo n.º 12
0
 /**
  * Edit Queues
  */
 public function editAction()
 {
     $this->view->url = $this->getFrontController()->getBaseUrl() . '/' . $this->getRequest()->getControllerName();
     $db = Zend_Registry::get('db');
     $id = $this->_request->getParam("id");
     $this->view->breadcrumb = Snep_Breadcrumb::renderPath(array($this->view->translate("Manage"), $this->view->translate("Queues"), $this->view->translate("Edit {$id}")));
     $obj = new Snep_Queues_Manager();
     $select = $obj->select()->where("id_queue = ?", $id);
     $queue = $obj->fetchRow($select)->toArray();
     $sections = new Zend_Config_Ini('/etc/asterisk/snep/snep-musiconhold.conf');
     $_section = array_keys($sections->toArray());
     $section = array();
     foreach ($_section as $value) {
         $section[$value] = $value;
     }
     $files = '/var/lib/asterisk/sounds/';
     if (file_exists($files)) {
         $files = scandir($files);
         $sounds = array("" => "");
         foreach ($files as $i => $value) {
             if (substr($value, 0, 1) == '.') {
                 unset($files[$i]);
                 continue;
             }
             if (is_dir($files . '/' . $value)) {
                 unset($files[$i]);
                 continue;
             }
             $sounds[$value] = $value;
         }
     }
     Zend_Registry::set('cancel_url', $this->getFrontController()->getBaseUrl() . '/' . $this->getRequest()->getControllerName() . '/index');
     $form = new Snep_Form();
     $form->setAction($this->getFrontController()->getBaseUrl() . '/' . $this->getRequest()->getControllerName() . '/edit/id/' . $id);
     $essentialData = new Zend_Config_Xml('./modules/default/forms/queues.xml', 'essential', true);
     $essential = new Snep_Form_SubForm($this->view->translate("General Configuration"), $essentialData);
     $essential->getElement('name')->setValue($queue['name'])->setAttrib('readonly', true);
     $essential->getElement('musiconhold')->setMultiOptions($section)->setValue($queue['musiconhold']);
     $essential->getElement('timeout')->setValue($queue['timeout']);
     $essential->getElement('announce_frequency')->setValue($queue['announce_frequency']);
     $essential->getElement('retry')->setValue($queue['retry']);
     $essential->getElement('wrapuptime')->setValue($queue['wrapuptime']);
     $essential->getElement('maxlen')->setValue($queue['maxlen']);
     $essential->getElement('servicelevel')->setValue($queue['servicelevel']);
     $essential->getElement('strategy')->addMultiOptions(array('ringall' => $this->view->translate('For all agents available (ringall)'), 'roundrobin' => $this->view->translate('Search for a available agent (roundrobin)'), 'leastrecent' => $this->view->translate('For the agent idle for the most time (leastrecent)'), 'random' => $this->view->translate('Randomly (random)'), 'fewestcalls' => $this->view->translate('For the agent that answerd less calls (fewestcalls)'), 'rrmemory' => $this->view->translate('Equally (rrmemory)')))->setValue($queue['strategy']);
     $form->addSubForm($essential, "essential");
     $advancedData = new Zend_Config_Xml('./modules/default/forms/queues.xml', 'advanced', true);
     $advanced = new Snep_Form_SubForm($this->view->translate("Advanced Configuration"), $advancedData);
     $boolOptions = array(1 => $this->view->translate('Yes'), 0 => $this->view->translate('No'));
     $advanced->getElement('announce')->setMultiOptions($sounds)->setValue($queue['announce']);
     $advanced->getElement('context')->setValue($queue['context']);
     $advanced->getElement('queue_youarenext')->setMultiOptions($sounds)->setValue($queue['queue_youarenext']);
     $advanced->getElement('queue_thereare')->setMultiOptions($sounds)->setValue($queue['queue_thereare']);
     $advanced->getElement('queue_callswaiting')->setMultiOptions($sounds)->setValue($queue['queue_callswaiting']);
     $advanced->getElement('queue_thankyou')->setMultiOptions($sounds)->setValue($queue['queue_thankyou']);
     $advanced->getElement('joinempty')->setMultiOptions(array('yes' => $this->view->translate('Yes'), 'no' => $this->view->translate('No'), 'strict' => $this->view->translate('Restrict')))->setValue($queue['joinempty']);
     $advanced->getElement('leavewhenempty')->setMultiOptions($boolOptions)->setValue($queue['leavewhenempty']);
     $advanced->getElement('reportholdtime')->setMultiOptions($boolOptions)->setValue($queue['reportholdtime']);
     $advanced->getElement('memberdelay')->setValue($queue['memberdelay']);
     $advanced->getElement('weight')->setValue($queue['weight']);
     $advanced->getElement('autopause')->setValue($queue['autopause']);
     $advanced->getElement('autofill')->setValue($queue['autofill']);
     $id_queue = new Zend_Form_Element_Hidden('id_queue');
     $id_queue->setValue($queue['id_queue']);
     $advanced->addElement($id_queue);
     $form->addSubForm($advanced, "advanced");
     if ($this->_request->getPost()) {
         $dados = array('name' => $_POST['essential']['name'], 'musiconhold' => $_POST['essential']['musiconhold'], 'announce' => $_POST['advanced']['announce'], 'context' => $_POST['advanced']['context'], 'timeout' => $_POST['essential']['timeout'], 'queue_youarenext' => $_POST['advanced']['queue_youarenext'], 'queue_thereare' => $_POST['advanced']['queue_thereare'], 'queue_callswaiting' => $_POST['advanced']['queue_callswaiting'], 'queue_thankyou' => $_POST['advanced']['queue_thankyou'], 'announce_frequency' => $_POST['essential']['announce_frequency'], 'announce_round_seconds' => 0, 'retry' => $_POST['essential']['retry'], 'wrapuptime' => $_POST['essential']['wrapuptime'], 'maxlen' => $_POST['essential']['maxlen'], 'servicelevel' => $_POST['essential']['servicelevel'], 'strategy' => $_POST['essential']['strategy'], 'joinempty' => $_POST['advanced']['joinempty'], 'leavewhenempty' => $_POST['advanced']['leavewhenempty'], 'reportholdtime' => $_POST['advanced']['reportholdtime'], 'memberdelay' => $_POST['advanced']['memberdelay'], 'weight' => $_POST['advanced']['weight'], 'autopause' => $_POST['advanced']['autopause'], 'autofill' => $_POST['advanced']['autofill'], 'monitor_join' => NULL, 'monitor_format' => NULL, 'queue_holdtime' => NULL, 'queue_minutes' => NULL, 'queue_seconds' => NULL, 'queue_lessthan' => NULL, 'queue_reporthold' => NULL, 'announce_holdtime' => NULL, 'eventmemberstatus' => NULL, 'eventwhencalled' => NULL, 'timeoutrestart' => NULL, 'queue_name' => NULL, 'interface' => NULL);
         $form_isValid = $form->isValid($_POST);
         if ($form_isValid) {
             $obj = new Snep_Queues_Manager();
             $obj->update($dados, "id_queue = {$_POST['advanced']['id_queue']}");
             $this->_redirect($this->getRequest()->getControllerName());
         }
     }
     $this->view->form = $form;
 }
Exemplo n.º 13
0
 /**
  *  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;
     }
 }
Exemplo n.º 14
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;
 }
Exemplo n.º 15
0
 /**
  * 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;
 }