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; }
/** * Returns the singleton instance of this class. * * @return Snep_Locale */ public static function getInstance() { if (!isset(self::$instance)) { self::$instance = new self(); } return self::$instance; }
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; }
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; }
public function indexAction() { $this->view->breadcrumb = $this->view->translate("SNEP Installer"); //$this->view->next = $this->view->url(array("controller"=>"installer", "action"=>"diagnostic"), null, true); $objInspector = new Snep_Inspector('Permissions'); $inspect = $objInspector->getInspects(); $this->view->error = $inspect['Permissions']; $form = new Snep_Form(); $form_xml = new Zend_Config_Xml('./modules/default/formssetup.conf.xml'); $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()); if ($this->getRequest()->isPost()) { $form_isValid = $form->isValid($_POST); $configFile = APPLICATION_PATH . "/includes/setup.conf"; $config = new Zend_Config_Ini($configFile, null, true); $config->system->locale = $_POST['locale']['locale']; $config->system->timezone = $_POST['locale']['timezone']; $config->system->language = $_POST['locale']['language']; if ($form_isValid) { $writer = new Zend_Config_Writer_Ini(array('config' => $config, 'filename' => $configFile)); $writer->write(); $this->_redirect('installer/diagnostic/'); } } $submit_button = $form->getElement('submit'); $submit_button->setLabel('Iniciar a Instalar'); if ($this->view->error['error']) { $submit_button->setAttrib('disabled', true); } $this->view->form = $form->addSubForm($locale_form, "locale"); }
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; }
public function setLabel($label) { $this->label = Snep_Locale::getInstance()->getZendTranslate()->translate($label); }
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; }
protected function startLocale() { // Preciso melhorar isso $locale = Snep_Locale::getInstance(); Zend_Registry::set("i18n", $locale->getZendTranslate()); }
protected function _initLocale() { $locale = Snep_Locale::getInstance(); Zend_Registry::set("i18n", $locale->getZendTranslate()); }