/** * Add Sound File */ public function addAction() { $this->view->breadcrumb = Snep_Breadcrumb::renderPath(array($this->view->translate("Sound Files"), $this->view->translate("Add"))); $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('Select the file'))->addValidator(new Zend_Validate_File_Extension(array('wav', 'gsm')))->removeDecorator('DtDdWrapper')->setIgnore(true)->setRequired(true); $form->addElement($file); $form->removeElement('filename'); if ($this->_request->getPost()) { $form_isValid = $form->isValid($_POST); $dados = $this->_request->getParams(); if ($form_isValid) { $description = $_POST['description']; $gsmConvert = $_POST['gsm']; $type = 'AST'; $invalid = array('â', 'ã', 'á', 'à', 'ẽ', 'é', 'è', 'ê', 'í', 'ì', 'ó', 'õ', 'ò', 'ú', 'ù', 'ç', " ", '@', '!'); $valid = array('a', 'a', 'a', 'a', 'e', 'e', 'e', 'e', 'i', 'i', 'o', 'o', 'o', 'u', 'u', 'c', "_", '_', '_'); $originalName = str_replace($invalid, $valid, $_FILES['file']['name']); $uploadName = $_FILES['file']['tmp_name']; $path_sound = Zend_Registry::get('config')->system->path->asterisk->sounds; $arq_tmp = $path_sound . "/tmp/" . $originalName; $arq_dst = $path_sound . "/" . $originalName; $arq_bkp = $path_sound . "/backup/" . $originalName; $arq_orig = $path_sound . "/pt_BR/" . $originalName; $exist = Snep_SoundFiles_Manager::get($originalName); if ($exist) { $form->getElement('file')->addError($this->view->translate('File already exists')); $form_isValid = false; } else { if (!move_uploaded_file($uploadName, $arq_tmp)) { throw new ErrorException($this->view->translate("Unable to move file")); } if ($_POST['gsm']) { $fileNe = $path_sound . '/' . basename($arq_dst, '.wav') . '.gsm'; exec("sox {$arq_tmp} -r 8000 {$fileNe}"); $originalName = basename($originalName, '.wav') . ".gsm"; } else { exec("sox {$arq_tmp} -r 8000 -c 1 -e signed-integer -b 16 {$arq_dst}"); } if (file_exists($arq_dst) || file_exists($fileNe)) { Snep_SoundFiles_Manager::add(array('arquivo' => $originalName, 'descricao' => $description, 'tipo' => 'AST')); $this->_redirect($this->getRequest()->getControllerName()); } else { $this->view->error = array('error' => 1, 'message' => $this->view->translate('Invalid Format')); } } } } $this->view->form = $form; }
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; }
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 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; }
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; }
/** * 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; }