/** * Defined by Zend_Validate_Interface * * Returns true if and only if $value contains a valid Eividencial namber message * * @param string $value * @return boolean */ public function isValid($value) { $this->_setValue($value); if (null === self::$_filter) { /** * @see Zend_Filter_Digits */ require_once 'Zend/Filter/Digits.php'; self::$_filter = new Zend_Filter_Digits(); } $valueFiltered = self::$_filter->filter($value); $length = strlen($valueFiltered); if ($length != 10) { $this->_error(self::LENGTH); return false; } $mod = 11; $sum = 0; $weights = array(6, 5, 7, 2, 3, 4, 5, 6, 7); preg_match_all("/\\d/", $valueFiltered, $digits); $valueFilteredArray = $digits[0]; foreach ($valueFilteredArray as $digit) { $weight = current($weights); $sum += $digit * $weight; next($weights); } if (($sum % $mod == 10 ? 0 : $sum % $mod) != $valueFilteredArray[$length - 1]) { $this->_error(self::CHECKSUM, $valueFiltered); return false; } return true; }
/** * Ensures that the filter follows expected behavior * * @return void */ public function testBasic() { $valuesExpected = array('abc123' => '123', 'abc 123' => '123', 'abcxyz' => '', 'AZ@#4.3' => '43'); foreach ($valuesExpected as $input => $output) { $this->assertEquals($output, $this->_filter->filter($input)); } }
/** * Ensures that the filter follows expected behavior * * @return void */ public function testBasic() { $valuesExpected = array('abc123' => '123', 'abc 123' => '123', 'abcxyz' => '', 'AZ@#4.3' => '43', '1.23' => '123', '0x9f' => '09'); foreach ($valuesExpected as $input => $output) { $this->assertEquals($output, $result = $this->_filter->filter($input), "Expected '{$input}' to filter to '{$output}', but received '{$result}' instead"); } }
/** * Defined by Zend_Validate_Interface * * Returns true if and only if $value only contains digit characters * * @param string $value * @return boolean */ public function isValid($value) { if (!is_string($value) && !is_int($value) && !is_float($value)) { $this->_error(self::INVALID); return false; } $this->_setValue((string) $value); if ('' === $this->_value) { $this->_error(self::STRING_EMPTY); return false; } if (null === self::$_filter) { require_once 'Zend/Filter/Digits.php'; self::$_filter = new Zend_Filter_Digits(); } if ($this->_value !== self::$_filter->filter($this->_value)) { $this->_error(self::NOT_DIGITS); return false; } return true; }
/** * Defined by Zend_Validate_Interface * * Returns true if and only if $value follows the Luhn algorithm (mod-10 checksum) * * @param string $value * @return boolean */ public function isValid($value) { $this->_setValue($value); if (null === self::$_filter) { /** * @see Zend_Filter_Digits */ // require_once 'Zend/Filter/Digits.php'; self::$_filter = new Zend_Filter_Digits(); } $valueFiltered = self::$_filter->filter($value); $length = strlen($valueFiltered); if ($length < 13 || $length > 19) { $this->_error(self::LENGTH); return false; } $sum = 0; $weight = 2; for ($i = $length - 2; $i >= 0; $i--) { $digit = $weight * $valueFiltered[$i]; $sum += floor($digit / 10) + $digit % 10; $weight = $weight % 2 + 1; } if ((10 - $sum % 10) % 10 != $valueFiltered[$length - 1]) { $this->_error(self::CHECKSUM, $valueFiltered); return false; } return true; }
public function filter($value) { $amount = explode('.', $value); if ($amount[0]) { $filter = new Zend_Filter_Digits(); $filteredAmount = $filter->filter($amount[0]); } if ($amount[1]) { $filteredDecimals = $filter->filter($amount[1]); $filteredAmount = $filteredAmount . "." . $filteredDecimals; $filteredAmount = round((double) $filteredAmount, 2); } return $filteredAmount; //return number_format((float)$filteredAmount, 2, '.', '');; }
public function numerosAction() { $v = new Zend_Filter_Digits(); $numero = '123oi321'; echo $v->filter($numero); exit; }
function indexAction() { //Zend_Session::namespaceUnset('cart'); $yourCart = new Zend_Session_Namespace('cart'); //$yourCart->count= ham_1($yourCart->count); $ssInfo = $yourCart->getIterator(); $filter = new Zend_Filter_Digits(); $id = $filter->filter($this->_arrParam['id']); if (count($yourCart->cart) == 0) { $cart[$id] = 1; $yourCart->cart = $cart; } else { //echo '<br>Trong gio hang da co san pham'; $tmp = $ssInfo['cart']; if (array_key_exists($id, $tmp) == true) { $tmp[$id] = $tmp[$id] + 1; } else { $tmp[$id] = 1; } $yourCart->cart = $tmp; } $base = new Zend_View(); $link = $base->baseUrl(); $url = $link . "/shoppingcart"; chuyen_trang($url); }
/** * Returns the result of filtering $value * * @param mixed $value * @throws \Zend_Filter_Exception If filtering $value is impossible * @return mixed */ public function filter($value) { $newValue = parent::filter($value); if (intval($newValue)) { return str_pad($newValue, 9, '0', STR_PAD_LEFT); } // Return as is when e.g. ********* or nothing return $value; }
public function isValid($value) { if (!is_string($value) && !is_int($value) && !is_float($value)) { $this->_error(self::INVALID); return false; } $this->_setValue((string) $value); if ('' === $this->_value) { $this->_error(self::STRING_EMPTY); return false; } if (null === self::$_filter) { self::$_filter = new \Life\Filter\Digits(); } if ($this->_value !== self::$_filter->filter($this->_value)) { $this->_error(self::NOT_DIGITS); return false; } return true; }
/** * Defined by Zend_Validate_Interface * * Returns true if and only if $value only contains digit characters * * @param string $value * @return boolean */ public function isValid($value) { $valueString = (string) $value; $this->_setValue($valueString); if ('' === $valueString) { $this->_error(self::STRING_EMPTY); return false; } if (null === self::$_filter) { /** * @see Zend_Filter_Digits */ require_once 'Zend/Filter/Digits.php'; self::$_filter = new Zend_Filter_Digits(); } if ($valueString !== self::$_filter->filter($valueString)) { $this->_error(self::NOT_DIGITS); return false; } return true; }
/** * Ensures that the filter follows expected behavior * * @return void */ public function testBasic() { if (self::$_unicodeEnabled && extension_loaded('mbstring')) { // Filter for the value with mbstring /** * The first element of $valuesExpected contains multibyte digit characters. * But , Zend_Filter_Digits is expected to return only singlebyte digits. * * The second contains multibyte or singebyte space, and also alphabet. * The third contains various multibyte characters. * The last contains only singlebyte digits. */ $valuesExpected = array('192八3四8' => '123', 'C 4.5B 6' => '456', '9壱8@7.6,5#4' => '987654', '789' => '789'); } else { // POSIX named classes are not supported, use alternative 0-9 match // Or filter for the value without mbstring $valuesExpected = array('abc123' => '123', 'abc 123' => '123', 'abcxyz' => '', 'AZ@#4.3' => '43', '1.23' => '123', '0x9f' => '09'); } foreach ($valuesExpected as $input => $output) { $this->assertEquals($output, $result = $this->_filter->filter($input), "Expected '{$input}' to filter to '{$output}', but received '{$result}' instead"); } }
private function aprovarUsuario() { // Atualiza Cadastro $iId = $this->_getParam('id'); $oCadastro = Administrativo_Model_Cadastro::getById($iId); $oCadastro->setStatus('1'); $oCadastro->persist(); $oFilterDigits = new Zend_Filter_Digits(); $oFilterTrim = new Zend_Filter_StringTrim(); // Cadastra Usuario $aDados = $this->_getAllParams(); $aUsuario['id_perfil'] = $oFilterDigits->filter($aDados['id_perfil']); $aUsuario['tipo'] = $oFilterDigits->filter($aDados['tipo']); $aUsuario['cnpj'] = $oFilterDigits->filter($aDados['cpfcnpj']); $aUsuario['login'] = $oFilterTrim->filter($aDados['login']); $aUsuario['senha'] = $oFilterTrim->filter($aDados['senha']); $aUsuario['nome'] = $oFilterTrim->filter($aDados['nome']); $aUsuario['email'] = $oFilterTrim->filter($aDados['email']); $aUsuario['fone'] = $oFilterDigits->filter($aDados['telefone']); $oUsuario = new Administrativo_Model_Usuario(); $oUsuario->persist($aUsuario); }
/** * Helper main function * @param $actionsHtml String HTML code showing the action buttons * @param $content String The content of this element * @param $dbId Int DB id of the object * @param $order Int order of this item in the DB * @param $params Array parameters (if any) * @return String HTML to be inserted in the view */ public function ContentFile($actionsHtml = '', $content = '', $dbId = 0, $order = 0, $params = array('level' => 1), $moduleName = 'adminpages', $pagstructureId = 0, $sharedInIds = '') { $eventsInfo = SafactivitylogOp::getAuthorNLastEditorForContent($dbId, $moduleName); $module = 'publicms'; $params2 = array('mode' => 'filids', 'layout' => 'none', 'viewl' => 'list', 'noviewswitch' => 'Y', 'ids' => $content); $this->view->flist = array(); $sql = ''; $fltr = new Zend_Filter_Digits(); if ($params2['mode'] == 'filids' && isset($params2['ids'])) { $ids = array(); foreach (explode(',', $params2['ids']) as $id) { $ids[] = $fltr->filter($id); } } if (is_array($params) && isset($params['type']) && $params['type'] == "categories") { // Load the files id based on their category $linkedFiles = new FilfoldersFilfiles(); $ids = array(); foreach (preg_split('/,/', $content) as $category) { $ids[] = $linkedFiles->getFilfilesLinkedTo($category); } } $this->view->viewl = 'list'; $this->view->noviewswitch = 'Y'; $oFile = new Filfiles(); $params2['flist'] = $oFile->getFileInfosByIdList($ids); $toret = '<li class="' . $params['addClass'] . ' sydney_editor_li" dbparams="' . $content . '" type="" editclass="files" dbid="' . $dbId . '" dborder="' . $order . '" data-content-type="file-block" pagstructureid="' . $pagstructureId . '" sharedinids="' . $sharedInIds . '"> ' . $actionsHtml . ' <div class="content"> ' . $this->view->partial('file/filelist.phtml', $module, $params2) . ' </div> <p class="lastUpdatedContent sydney_editor_p">' . $eventsInfo['firstEvent'] . '<br />' . $eventsInfo['lastEvent'] . '</p> </li>'; return $toret; }
/** * Defined by Zend_Validate_Interface * * Returns true if and only if $value follows the Luhn algorithm (mod-10 checksum) * * @param string $value * @return boolean */ public function isValid($value) { $this->_setValue($value); $filterDigits = new Zend_Filter_Digits(); $valueFiltered = $filterDigits->filter($value); $length = strlen($valueFiltered); if ($length < 13 || $length > 19) { $this->_error(self::LENGTH); return false; } $sum = 0; $weight = 2; for ($i = $length - 2; $i >= 0; $i--) { $digit = $weight * $valueFiltered[$i]; $sum += floor($digit / 10) + $digit % 10; $weight = $weight % 2 + 1; } if ((10 - $sum % 10) % 10 != $valueFiltered[$length - 1]) { $this->_error(self::CHECKSUM, $valueFiltered); return false; } return true; }
/** * Defined by Zend_Validate_Interface * * Returns true if and only if $value follows the Luhn algorithm (mod-10 checksum) * * @param string $value * @return boolean */ public function isValid($value) { $this->_messages = array(); $filterDigits = new Zend_Filter_Digits(); $valueFiltered = $filterDigits->filter($value); $length = strlen($valueFiltered); if ($length < 13 || $length > 19) { $this->_messages[] = "'{$value}' must contain between 13 and 19 digits"; return false; } $sum = 0; $weight = 2; for ($i = $length - 2; $i >= 0; $i--) { $digit = $weight * $valueFiltered[$i]; $sum += floor($digit / 10) + $digit % 10; $weight = $weight % 2 + 1; } if ((10 - $sum % 10) % 10 != $valueFiltered[$length - 1]) { $this->_messages[] = "Luhn algorithm (mod-10 checksum) failed on '{$valueFiltered}'"; return false; } return true; }
private function appendQuery(\Doctrine\ORM\QueryBuilder $queryBuilder, \Core_Dto_Search $dto) { //Filtro por Interessado if ($dto->getSqPessoaSgdoce()) { $queryBuilder->andWhere('vwca.sqPessoaInteressada like :sqPessoaSgdoce')->setParameter('sqPessoaSgdoce', '%' . $dto->getSqPessoaSgdoce() . '%'); } //Filtro por Cpf, Cnpj e Passaport if ($dto->getNuCpfCnpjPassaporte()) { $filter = new \Zend_Filter_Digits(); $queryBuilder->andWhere('vwca.nuCpfCnpjPassaporteOrigem = :nuCpfCnpjPassaporte')->setParameter('nuCpfCnpjPassaporte', $filter->filter($dto->getNuCpfCnpjPassaporte())); } //Filtro pelo tipo de documento if ($dto->getSqTipoDocumento()) { $queryBuilder->andWhere('vwca.sqTipoDocumento = :sqTipoDocumento')->setParameter('sqTipoDocumento', $dto->getSqTipoDocumento()); } if ($dto->getSqPessoaFuncao()) { $queryBuilder->andWhere('vwca.sqPessoaSgdoceOrigem = :sqPessoaSgdoceOrigem ')->setParameter('sqPessoaSgdoceOrigem', $dto->getSqPessoaFuncao()); } $this->appendQuery2($queryBuilder, $dto); }
/** * Monta a tela para emissão do RPS * * @return void */ public function indexAction() { try { $aDados = $this->getRequest()->getParams(); $oContribuinte = $this->_session->contribuinte; $this->view->empresa_nao_prestadora = FALSE; $this->view->empresa_nao_emissora_nfse = FALSE; $this->view->bloqueado_msg = FALSE; $oForm = $this->formNota(NULL, $oContribuinte); // Verifica se o contribuinte tem permissão para emitir nfse/rps if ($oContribuinte->getTipoEmissao() != Contribuinte_Model_ContribuinteAbstract::TIPO_EMISSAO_NOTA) { $this->view->empresa_nao_emissora_nfse = TRUE; return; } // Verifica se a empresa é prestadora de serviços $aServicos = Contribuinte_Model_Servico::getByIm($oContribuinte->getInscricaoMunicipal()); if ($aServicos == NULL || empty($aServicos)) { $this->view->empresa_nao_prestadora = TRUE; return; } // Verifica o prazo de emissão de documentos e retorna as mensagens de erro self::mensagemPrazoEmissao(); // Configura o formulário $oForm->preenche($aDados); $oForm->setListaServicos($aServicos); $this->view->form = $oForm; // Validadores $oValidaData = new Zend_Validate_Date(array('format' => 'yyyy-MM-dd')); // Bloqueia a emissão se possuir declarações sem movimento if (isset($aDados['dt_nota']) && $oValidaData->isValid($aDados['dt_nota'])) { $oDataSimples = new DateTime($aDados['dt_nota']); $aDeclaracaoSemMovimento = Contribuinte_Model_Competencia::getDeclaracaoSemMovimentoPorContribuintes($oContribuinte->getInscricaoMunicipal(), $oDataSimples->format('Y'), $oDataSimples->format('m')); if (count($aDeclaracaoSemMovimento) > 0) { $sMensagemErro = 'Não é possível emitir um documento nesta data, pois a competência foi declarada como '; $sMensagemErro .= 'sem movimento.<br>Entre em contato com o setor de arrecadação da prefeitura.'; $this->view->messages[] = array('error' => $sMensagemErro); return; } } // Trata o post do formulário if ($this->getRequest()->isPost()) { $oNota = new Contribuinte_Model_Nota(); // Valida os dados informados no formulário if (!$oForm->isValid($aDados)) { $this->view->form = $oForm; $this->view->messages[] = array('error' => $this->translate->_('Preencha os dados corretamente.')); } else { if ($oNota::existeRps($oContribuinte, $aDados['n_rps'], $aDados['tipo_nota'])) { $this->view->form = $oForm; $this->view->messages[] = array('error' => $this->translate->_('Já existe um RPS com esta numeração.')); } else { $oAidof = new Administrativo_Model_Aidof(); $iInscricaoMunicipal = $oContribuinte->getInscricaoMunicipal(); /* * Verifica se a numeração do AIDOF é válida */ $lVerificaNumeracao = $oAidof->verificarNumeracaoValidaParaEmissaoDocumento($iInscricaoMunicipal, $aDados['n_rps'], $aDados['tipo_nota']); if (!$lVerificaNumeracao) { $sMensagem = 'A numeração do RPS não confere com os AIDOFs liberados.'; $this->view->messages[] = array('error' => $this->translate->_($sMensagem)); return; } // Remove chaves inválidas unset($aDados['enviar'], $aDados['action'], $aDados['controller'], $aDados['module'], $aDados['estado']); // Filtro para retornar somente numeros $aFilterDigits = new Zend_Filter_Digits(); $aDados['p_im'] = $oContribuinte->getInscricaoMunicipal(); $aDados['grupo_nota'] = Contribuinte_Model_Nota::GRUPO_NOTA_RPS; $aDados['t_cnpjcpf'] = $aFilterDigits->filter($aDados['t_cnpjcpf']); $aDados['t_cep'] = $aFilterDigits->filter($aDados['t_cep']); $aDados['t_telefone'] = $aFilterDigits->filter($aDados['t_telefone']); $aDados['id_contribuinte'] = $oContribuinte->getIdUsuarioContribuinte(); $aDados['id_usuario'] = $this->usuarioLogado->getId(); if (!$oNota->persist($aDados)) { $this->view->form = $oForm; $this->view->messages[] = array('error' => $this->translate->_('Houver um erro ao tentar emitir a nota.')); return NULL; } $this->view->messages[] = array('success' => $this->translate->_('Nota emitida com sucesso.')); $this->_redirector->gotoSimple('dadosnota', 'nota', NULL, array('id' => $oNota->getId(), 'tipo_nota' => 'rps')); } } } } catch (Exception $oError) { $this->view->messages[] = array('error' => $oError->getMessage()); return; } }
/** * Returns only the digits in value. This differs from getInt(). * * @deprecated since 0.8.0 * @param mixed $value * @return string */ public static function getDigits($value) { require_once 'Zend/Filter/Digits.php'; $filter = new Zend_Filter_Digits(); return $filter->filter($value); }
public static function billTypeIsInternal($bill_type_id) { $db = Zend_Db_Table::getDefaultAdapter(); $bill_type_id = Zend_Filter_Digits::filter($bill_type_id); return $db->fetchOne('SELECT inactive FROM project_bill_types WHERE bill_type = ?', $bill_type_id); }
/** * Show the images from dynamic path with the following dimensions : $request->dw, $request->dh * Or if not notified, $dimensionWidth = 500 * * Example : /adminfiles/file/thumb/id/1/ts/2 * where ts is the thumb size mode * amd id is the ID of the file to get */ public function showimgAction() { $filter = new Zend_Filter_Digits(); $dimensionWidth = 500; $dimensionHeight = null; $request = $this->getRequest(); if (isset($request->id) && preg_match('/^[0-9]{1,30}$/', $request->id)) { $elementId = $filter->filter($request->id); if (isset($request->dw)) { $dimensionWidth = $filter->filter($request->dw); } if (isset($request->dh)) { $dimensionHeight = $filter->filter($request->dh); } $fileModel = new Filfiles(); $where = 'id = ' . $elementId . ' AND safinstances_id = ' . $this->safinstancesId; $ro = $fileModel->fetchAll($where); if (count($ro) == 1) { $file = $ro[0]; //Définition dynamique du fullpath $fileType = $file->type; $fullpath = Sydney_Tools_Paths::getAppdataPath() . '/adminfiles/' . $fileType . '/' . $file->filename; $fileTypeInstance = Sydney_Medias_Filetypesfactory::createfiletype($fullpath); if (isset($request->pdfpg) && $request->pdfpg > 1) { $fileTypeInstance->pageid = intval($request->pdfpg) - 1; } if (!$fileTypeInstance->showImg($dimensionWidth, $dimensionHeight)) { print 'Image can not be processed'; } } else { print 'You do not have access to this information'; } } else { print 'Something is missing...'; } $this->render('index'); }
/** * Metódo que realiza a persistencia de DESTINO * @param Object $entity * @param Object $dto * @return Object */ protected function _salvaDestino($entity, $dto) { $filter = new \Zend_Filter_Digits(); switch ($dto->getDestinoInterno()) { case 'externo': $stProcedencia = FALSE; break; case 'interno': $stProcedencia = TRUE; break; default: $stProcedencia = NULL; break; } $sqPessoaDestino = $this->recuperaSqPessoaDto($dto); // $cpfCnpjPassaport = $this->retornaRegistro($dto); if ($dto->getSqTipoPessoaDestino()) { $sqTipoPessoa = $dto->getSqTipoPessoaDestino(); } else { $sqTipoPessoa = $dto->getSqTipoPessoaDestinoIcmbio(); } if ($dto->getSqPessoa_autocomplete()) { $noPessoaDestino = $dto->getSqPessoa_autocomplete(); } else { $noPessoaDestino = $dto->getSqPessoaIcmbioDestino_autocomplete(); } $sqPessoaEncaminhado = null; if ($dto->getSqPessoaEncaminhado()) { $sqPessoaEncaminhado = $dto->getSqPessoaEncaminhado(); $noPessoaEncaminhado = $dto->getSqPessoaEncaminhado_autocomplete(); } else { if ($dto->getSqPessoaEncaminhadoExterno()) { $sqPessoaEncaminhado = $dto->getSqPessoaEncaminhadoExterno(); $noPessoaEncaminhado = $dto->getSqPessoaEncaminhadoExterno_autocomplete(); } } if ($sqPessoaDestino != 0) { $data['sqPessoaCorporativo'] = $sqPessoaDestino; $dtoPessoaSearch = \Core_Dto::factoryFromData($data, 'search'); $cpfCnpjPassaport = $this->getServiceLocator()->getService('VwPessoa')->returnCpfCnpjPassaporte($dtoPessoaSearch); $cpfCnpjPassaport = $filter->filter($cpfCnpjPassaport); } // verificando se existe Pessoa cadastrada no PessoaSgdoce $entPessoaSgdoce = $this->searchPessoaSgdoce($sqPessoaDestino); // Se nao existir registro na base de PessoaSgdoce, verifica se é PF ou PJ e recupera as informacoes // na base Corporativo e realiza o cadastro na base de PessoaSgdoce if (!count($entPessoaSgdoce)) { // Não existindo registro em PessoaSgdoce, faz cadastro na mesma $entPessoaSgdoce = $this->addPessoaSgdoce($sqPessoaDestino, $noPessoaDestino, $cpfCnpjPassaport); $entPessoaSgdoce->setNuCpfCnpjPassaporte($cpfCnpjPassaport); // retorna o numero do registro $criteriaTipoPessoa = array('sqTipoPessoa' => $sqTipoPessoa); $entPessoaSgdoce->setSqTipoPessoa($this->_getRepository('app:VwTipoPessoa')->findOneBy($criteriaTipoPessoa)); $this->getEntityManager()->persist($entPessoaSgdoce); $this->getEntityManager()->flush($entPessoaSgdoce); } // cadastrando PessoaArtefato $entityPessoaArtefato = $this->cadastrarPessoaArtefato($entity, $entPessoaSgdoce, \Core_Configuration::getSgdocePessoaFuncaoDestinatario()); if ($sqPessoaEncaminhado) { // verificando se existe PessoaEncaminhado cadastrada no PessoaSgdoce $entPessoaEncaminhado = $this->searchPessoaSgdoce($sqPessoaEncaminhado); if (!count($entPessoaEncaminhado)) { $data['sqPessoaCorporativo'] = $sqPessoaEncaminhado; $dtoPessoaSearch = \Core_Dto::factoryFromData($data, 'search'); $cpfCnpjPassaport = $this->getServiceLocator()->getService('VwPessoa')->returnCpfCnpjPassaporte($dtoPessoaSearch); $cpfCnpjPassaport = $filter->filter($cpfCnpjPassaport); // Não existindo registro em PessoaSgdoce, faz cadastro na mesma $entPessoaEncaminhado = $this->addPessoaSgdoce($sqPessoaEncaminhado, $noPessoaEncaminhado, $cpfCnpjPassaport); // retorna o numero do registro $criteriaTipoPessoa = array('sqTipoPessoa' => $sqTipoPessoa); $entPessoaEncaminhado->setSqTipoPessoa($this->_getRepository('app:VwTipoPessoa')->findOneBy($criteriaTipoPessoa)); $this->getEntityManager()->persist($entPessoaEncaminhado); $this->getEntityManager()->flush($entPessoaEncaminhado); } // setando valores $entityPessoaArtefato->setSqPessoaEncaminhado($entPessoaEncaminhado); } else { $entityPessoaArtefato->setSqPessoaEncaminhado(NULL); } $entityPessoaArtefato->setNoCargoEncaminhado($dto->getNoCargoEncaminhado()); $entityPessoaArtefato->setStProcedencia($stProcedencia); // persistindo informacoes $this->getEntityManager()->persist($entityPessoaArtefato); $this->getEntityManager()->flush($entityPessoaArtefato); }
/** * Busca o documento por CPF/CNPJ do Prestador e Número do RPS * * @param string $sPrestadorCnpjCpf * @param string $sNumeroRps * @return array|Contribuinte_Model_Nota|null * @throws Exception */ public static function getByPrestadorAndNumeroRps($sPrestadorCnpjCpf, $sNumeroRps) { if (empty($sPrestadorCnpjCpf)) { throw new Exception('Informe o CPF/CNPJ do Prestador.'); } if (empty($sNumeroRps)) { throw new Exception('Informe o Número do RPS.'); } $oEntityManager = parent::getEm(); $oZendFilter = new Zend_Filter_Digits(); $sPrestadorCnpjCpf = $oZendFilter->filter($sPrestadorCnpjCpf); $oRepositorio = $oEntityManager->getRepository(static::$entityName); $aResultado = $oRepositorio->findBy(array('p_cnpjcpf' => $sPrestadorCnpjCpf, 'n_rps' => $sNumeroRps)); if (count($aResultado) == 0) { return NULL; } if (count($aResultado) == 1) { return new Contribuinte_Model_Nota($aResultado[0]); } $aRetorno = array(); foreach ($aResultado as $oResultado) { $aRetorno[] = new Contribuinte_Model_Nota($oResultado); } return $aRetorno; }
/** * Valida el lugar de la emergencia */ public function ajax_valida_lugar_emergencia() { header('Content-type: application/json'); $retorno = array("correcto" => false); $params = $this->input->post(null, true); $filter = new Zend_Filter_Digits(); $metros = $filter->filter($params["metros"]); if ($metros == "") { $retorno["error"] = array("metros" => "Debe ingresar un valor numerico"); } else { $data = array("eme_radio" => $metros, "eme_c_utm_lat" => $params["lat"], "eme_c_utm_lng" => $params["lon"]); //$this->_emergencia_model->update($data, $emergencia->eme_ia_id); $retorno = array("correcto" => true, "error" => array("metros" => "")); } echo json_encode($retorno); }
/** * Show the images from dynamic path with the following dimensions : $request->dw, $request->dh * Or if not notified, $dimensionWidth = 500 * * Example : /publicms/file/showimg/dw/400/id/5951/fn/5951.png * where ts is the thumb size mode * amd id is the ID of the file to get * * @todo TODO check the access rights to the images here! */ public function showimgAction() { $this->initFileHeaders(); $filter = new Zend_Filter_Digits(); $dimensionWidth = 500; $dimensionHeight = null; $request = $this->getRequest(); if (isset($request->id) && preg_match('/^[0-9]{1,30}$/', $request->id)) { $fileId = $filter->filter($request->id); if (isset($request->dw)) { $dimensionWidth = $filter->filter($request->dw); } if (isset($request->dh)) { $dimensionHeight = $filter->filter($request->dh); } $fileModel = new Filfiles(); $where = 'id = ' . $fileId . ' AND safinstances_id = ' . $this->safinstancesId; $result = $fileModel->fetchAll($where); if (count($result) == 1) { $file = $result[0]; $fileType = $file->type; $fullpath = Sydney_Tools_Paths::getAppdataPath() . '/adminfiles/' . $fileType . '/' . $file->filename; $fileTypeInstance = Sydney_Medias_Filetypesfactory::createfiletype($fullpath); if (!$fileTypeInstance->showImg($dimensionWidth, $dimensionHeight)) { } } else { } } else { } $this->render('index'); }
/** * @param type $entity * @param type $dto * @param type $objArtProDto */ public function postSave($entity, $dto = null, $objArtProDto = null) { $retorno = false; $this->getEntityManager()->beginTransaction(); $sqPessoaCorporativo = \Core_Integration_Sica_User::getPersonId(); try { // salva o artefato_processo $objArtProDto->setSqArtefato($entity); $this->saveArtefatoProcesso($objArtProDto); $arrPesArtDto = array('entity' => 'Sgdoce\\Model\\Entity\\PessoaArtefato', 'mapping' => array('sqPessoaFuncao' => 'Sgdoce\\Model\\Entity\\PessoaFuncao', 'sqPessoaSgdoce' => 'Sgdoce\\Model\\Entity\\PessoaSgdoce', 'sqArtefato' => 'Sgdoce\\Model\\Entity\\Artefato')); $sqPessoaSgdoce = $this->_getRepository('app:PessoaSgdoce')->findBySqPessoaCorporativo($sqPessoaCorporativo); if (empty($sqPessoaSgdoce)) { $filter = new \Zend_Filter_Digits(); $data['sqPessoaCorporativo'] = $this->_getRepository('app:VwPessoa')->find($sqPessoaCorporativo); $dtoPessoaSearch = \Core_Dto::factoryFromData($data, 'search'); $cpfCnpjPassaportUnfiltered = $this->getServiceLocator()->getService('VwPessoa')->returnCpfCnpjPassaporte($dtoPessoaSearch); $cpfCnpjPassaport = $filter->filter($cpfCnpjPassaportUnfiltered); $noPessoaCorporativo = $data['sqPessoaCorporativo']->getNoPessoa(); $this->addPessoaSgdoce($sqPessoaCorporativo, $noPessoaCorporativo, $cpfCnpjPassaport); $sqPessoaSgdoce = $this->_getRepository('app:PessoaSgdoce')->findBySqPessoaCorporativo($sqPessoaCorporativo); } $arrParams = array(); $arrParams['sqArtefato'] = $entity->getSqArtefato(); $arrParams['sqPessoaFuncao'] = \Core_Configuration::getSgdocePessoaFuncaoAutor(); $arrParams['sqPessoaSgdoce'] = $sqPessoaSgdoce[0]->getSqPessoaSgdoce(); $objPessoArtefato = $this->getServiceLocator()->getService('PessoaArtefato')->findBy($arrParams); if (!count($objPessoArtefato)) { $objPessoaArtefatoDto = \Core_Dto::factoryFromData($arrParams, 'entity', $arrPesArtDto); $this->getServiceLocator()->getService('PessoaArtefato')->savePessoaArtefato($objPessoaArtefatoDto); } $this->_salvaOrigem($entity, $dto); // SALVA GRAU DE ACESSO. if ($dto->getSqGrauAcesso()) { $grauAcesso = $this->getEntityManager()->getPartialReference('app:GrauAcesso', $dto->getSqGrauAcesso()); $this->getServiceLocator()->getService('GrauAcessoArtefato')->saveGrauAcessoArtefato($entity, $grauAcesso); } /* * ##### VOLUME ##### * * só é postado no create * */ if ($dto->getDataVolume()) { $dataIntessado = $dto->getDataVolume(); $sqPessoaAbertura = \Core_Integration_Sica_User::getPersonId(); $sqUnidadeOrgAbertura = \Core_Integration_Sica_User::getUserUnit(); foreach ($dataIntessado->getApi() as $method) { $line = $dataIntessado->{$method}(); if (!(int) $line->getNuVolume()) { throw new \Core_Exception_ServiceLayer('Volume não informado.'); } $nuFolhaFinal = (int) $line->getNuFolhaFinal(); $dtEncerramento = null; if (!empty($nuFolhaFinal)) { $dtEncerramento = \Zend_Date::now(); } else { $nuFolhaFinal = null; } $add = $this->getServiceLocator()->getService('ProcessoVolume')->addVolume(array('nuVolume' => (int) $line->getNuVolume(), 'nuFolhaInicial' => (int) $line->getNuFolhaInicial(), 'nuFolhaFinal' => $nuFolhaFinal, 'sqArtefato' => $entity->getSqArtefato(), 'sqPessoa' => $sqPessoaAbertura, 'sqUnidadeOrg' => $sqUnidadeOrgAbertura, 'dtAbertura' => \Zend_Date::now(), 'dtEncerramento' => $dtEncerramento)); if (!$add) { throw new \Core_Exception_ServiceLayer('Erro ao adicionar volume.'); } } } /* * ##### INTERESSADO ##### * * só é postado no create, em caso de edit os interessados são * manutenidos no proprio formulario * */ if ($dto->getDataInteressado()) { $dataIntessado = $dto->getDataInteressado(); foreach ($dataIntessado->getApi() as $method) { $line = $dataIntessado->{$method}(); //metodo foi copiado e adaptado de Artefato_PessoaController::addInteressadoAction() $add = $this->getServiceLocator()->getService('Documento')->addInteressado(array('noPessoa' => $line->getNoPessoa(), 'unidFuncionario' => $line->getUnidFuncionario(), 'sqPessoaCorporativo' => $line->getSqPessoaCorporativo(), 'sqTipoPessoa' => $line->getSqTipoPessoa(), 'sqPessoaFuncao' => $line->getSqPessoaFuncao(), 'sqArtefato' => $entity->getSqArtefato())); if (!$add) { throw new \Core_Exception_ServiceLayer($line->getNoPessoa() . ' já é um interessado deste processo.'); } } } /* * ##### REFERÊNCIA (VINCULO) ##### * * só é postado no create, em caso de edit os vinculos são * manutenidos no proprio formulario * */ if ($dto->getDataVinculo()) { //só é postado no create $dataVinculo = $dto->getDataVinculo(); foreach ($dataVinculo->getApi() as $method) { $gridLine = $dataVinculo->{$method}(); //metodo foi copiado e adaptado de Artefato_DocumentoController::addDocumentoEletronicoAction() $add = $this->getServiceLocator()->getService('Documento')->addVinculo(array('nuDigital' => $gridLine->getNuDigital(), 'nuArtefatoVinculacao' => $gridLine->getNuArtefatoVinculacao(), 'sqTipoArtefato' => $gridLine->getSqTipoArtefato(), 'sqArtefato' => $entity->getSqArtefato(), 'tipoVinculo' => \Core_Configuration::getSgdoceTipoVinculoArtefatoReferencia(), 'inOriginal' => $gridLine->getInOriginal())); if (!$add) { $msg = "A digital <b>{$gridLine->getNuDigital()}</b> já esta vinculada a este documento"; if ($gridLine->getSqTipoArtefato() == \Core_Configuration::getSgdoceTipoArtefatoProcesso()) { $msg = "O processo <b>{$gridLine->getNuArtefatoVinculacao()}</b> já esta vinculado a este processo."; } throw new \Core_Exception_ServiceLayer($msg); } } } // #HistoricoArtefato::save(); $dtAcao = new \Zend_Date(\Zend_Date::now()); $sqOcorrencia = 0; if ($this->_firstTramite) { $sqOcorrencia = \Core_Configuration::getSgdoceSqOcorrenciaCadastrar(); $message = "Processo cadastrado com sucesso"; $strHMessage = sprintf(\Core_Registry::getMessage()->translate('MH007'), \Core_Integration_Sica_User::getUserName(), $dtAcao->get(\Zend_Date::DATETIME_MEDIUM)); } else { $sqOcorrencia = \Core_Configuration::getSgdoceSqOcorrenciaAlterar(); $message = "Processo alterado com sucesso"; if ($dto->getIsAutuacao()) { $message = "Processo autuado com sucesso!"; } $strHMessage = sprintf(\Core_Registry::getMessage()->translate('MH008'), \Core_Integration_Sica_User::getUserName(), $dtAcao->get(\Zend_Date::DATETIME_MEDIUM)); } $this->getServiceLocator()->getService('HistoricoArtefato')->registrar($entity->getSqArtefato(), $sqOcorrencia, $strHMessage); if ($this->_firstTramite) { $this->getServiceLocator()->getService('TramiteArtefato')->insertFirstTramite($entity->getSqArtefato()); } $this->getMessaging()->addSuccessMessage($message, "User"); $retorno = $this->getEntityManager()->commit(); } catch (\Exception $objException) { $this->getEntityManager()->rollback(); $this->getMessaging()->addErrorMessage("[" . $objException->getCode() . "] " . $objException->getMessage(), "User"); $retorno = $objException; } $this->getMessaging()->dispatchPackets(); return $retorno; }
/** * @param type $entity * @param type $dto * @param type $objArtProDto */ public function postSave($entity, $dto = null, $objArtProDto = null) { $retorno = false; $this->getEntityManager()->beginTransaction(); $sqPessoaCorporativo = \Core_Integration_Sica_User::getPersonId(); try { // salva o artefato_processo $objArtProDto->setSqArtefato($entity); $this->saveArtefatoProcesso($objArtProDto); $arrPesArtDto = array('entity' => 'Sgdoce\\Model\\Entity\\PessoaArtefato', 'mapping' => array('sqPessoaFuncao' => 'Sgdoce\\Model\\Entity\\PessoaFuncao', 'sqPessoaSgdoce' => 'Sgdoce\\Model\\Entity\\PessoaSgdoce', 'sqArtefato' => 'Sgdoce\\Model\\Entity\\Artefato')); $sqPessoaSgdoce = $this->_getRepository('app:PessoaSgdoce')->findBySqPessoaCorporativo($sqPessoaCorporativo); if (empty($sqPessoaSgdoce)) { $filter = new \Zend_Filter_Digits(); $data['sqPessoaCorporativo'] = $this->_getRepository('app:VwPessoa')->find($sqPessoaCorporativo); $dtoPessoaSearch = \Core_Dto::factoryFromData($data, 'search'); $cpfCnpjPassaportUnfiltered = $this->getServiceLocator()->getService('VwPessoa')->returnCpfCnpjPassaporte($dtoPessoaSearch); $cpfCnpjPassaport = $filter->filter($cpfCnpjPassaportUnfiltered); $noPessoaCorporativo = $data['sqPessoaCorporativo']->getNoPessoa(); $this->addPessoaSgdoce($sqPessoaCorporativo, $noPessoaCorporativo, $cpfCnpjPassaport); $sqPessoaSgdoce = $this->_getRepository('app:PessoaSgdoce')->findBySqPessoaCorporativo($sqPessoaCorporativo); } $arrParams = array(); $arrParams['sqArtefato'] = $entity->getSqArtefato(); $arrParams['sqPessoaFuncao'] = \Core_Configuration::getSgdocePessoaFuncaoAutor(); $arrParams['sqPessoaSgdoce'] = $sqPessoaSgdoce[0]->getSqPessoaSgdoce(); $objPessoArtefato = $this->getServiceLocator()->getService('PessoaArtefato')->findBy($arrParams); if (!count($objPessoArtefato)) { $objPessoaArtefatoDto = \Core_Dto::factoryFromData($arrParams, 'entity', $arrPesArtDto); $this->getServiceLocator()->getService('PessoaArtefato')->savePessoaArtefato($objPessoaArtefatoDto); } // Autor $this->_arInconsistencia[3] = 't'; $this->_salvaOrigem($entity, $dto); $this->_arInconsistencia[0] = 't'; // SALVA GRAU DE ACESSO. if ($dto->getSqGrauAcesso()) { $grauAcesso = $this->getEntityManager()->getPartialReference('app:GrauAcesso', $dto->getSqGrauAcesso()); $this->getServiceLocator()->getService('GrauAcessoArtefato')->saveGrauAcessoArtefato($entity, $grauAcesso); } /* * ##### VOLUME ##### * * só é postado no create * */ if ($dto->getDataVolume()) { $dataIntessado = $dto->getDataVolume(); $sqPessoaAbertura = \Core_Integration_Sica_User::getPersonId(); $sqUnidadeOrgAbertura = \Core_Integration_Sica_User::getUserUnit(); foreach ($dataIntessado->getApi() as $method) { $line = $dataIntessado->{$method}(); if (!(int) $line->getNuVolume()) { throw new \Core_Exception_ServiceLayer('Volume não informado.'); } $nuFolhaFinal = (int) $line->getNuFolhaFinal(); $dtEncerramento = null; if (!empty($nuFolhaFinal)) { $dtEncerramento = \Zend_Date::now(); } else { $nuFolhaFinal = null; } $add = $this->getServiceLocator()->getService('ProcessoVolume')->addVolume(array('nuVolume' => (int) $line->getNuVolume(), 'nuFolhaInicial' => (int) $line->getNuFolhaInicial(), 'nuFolhaFinal' => $nuFolhaFinal, 'sqArtefato' => $entity->getSqArtefato(), 'sqPessoa' => $sqPessoaAbertura, 'sqUnidadeOrg' => $sqUnidadeOrgAbertura, 'dtAbertura' => \Zend_Date::now(), 'dtEncerramento' => $dtEncerramento)); if (!$add) { throw new \Core_Exception_ServiceLayer('Erro ao adicionar volume.'); } } } /* * ##### INTERESSADO ##### * * só é postado no create, em caso de edit os interessados são * manutenidos no proprio formulario * */ if ($dto->getDataInteressado()) { $dataIntessado = $dto->getDataInteressado(); foreach ($dataIntessado->getApi() as $method) { $line = $dataIntessado->{$method}(); //metodo foi copiado e adaptado de Artefato_PessoaController::addInteressadoAction() $add = $this->getServiceLocator()->getService('Documento')->addInteressado(array('noPessoa' => $line->getNoPessoa(), 'unidFuncionario' => $line->getUnidFuncionario(), 'sqPessoaCorporativo' => $line->getSqPessoaCorporativo(), 'sqTipoPessoa' => $line->getSqTipoPessoa(), 'sqPessoaFuncao' => $line->getSqPessoaFuncao(), 'sqArtefato' => $entity->getSqArtefato())); if (!$add) { throw new \Core_Exception_ServiceLayer($line->getNoPessoa() . ' já é um interessado deste processo.'); } $this->_arInconsistencia[2] = 't'; } } else { $dtoInteressado = \Core_Dto::factoryFromData(array('sqArtefato' => $entity->getSqArtefato()), 'search'); $nuInteressados = $this->getServiceLocator()->getService('PessoaInterassadaArtefato')->countInteressadosArtefato($dtoInteressado); if ($nuInteressados['nu_interessados'] > 0) { $this->_arInconsistencia[2] = 't'; } else { throw new \Core_Exception_ServiceLayer(\Core_Registry::getMessage()->translate('MN176')); } } /* * ##### REFERÊNCIA (VINCULO) ##### * * só é postado no create, em caso de edit os vinculos são * manutenidos no proprio formulario * */ if ($dto->getDataVinculo()) { //só é postado no create $dataVinculo = $dto->getDataVinculo(); foreach ($dataVinculo->getApi() as $method) { $gridLine = $dataVinculo->{$method}(); //metodo foi copiado e adaptado de Artefato_DocumentoController::addDocumentoEletronicoAction() $add = $this->getServiceLocator()->getService('Documento')->addVinculo(array('nuDigital' => $gridLine->getNuDigital(), 'nuArtefatoVinculacao' => $gridLine->getNuArtefatoVinculacao(), 'sqTipoArtefato' => $gridLine->getSqTipoArtefato(), 'sqArtefato' => $entity->getSqArtefato(), 'tipoVinculo' => \Core_Configuration::getSgdoceTipoVinculoArtefatoReferencia(), 'inOriginal' => $gridLine->getInOriginal())); if (!$add) { $msg = "A digital <b>{$gridLine->getNuDigital()}</b> já esta vinculada a este documento"; if ($gridLine->getSqTipoArtefato() == \Core_Configuration::getSgdoceTipoArtefatoProcesso()) { $msg = "O processo <b>{$gridLine->getNuArtefatoVinculacao()}</b> já esta vinculado a este processo."; } throw new \Core_Exception_ServiceLayer($msg); } } } // #HistoricoArtefato::save(); $dtAcao = new \Zend_Date(\Zend_Date::now()); #Datas default $this->_arInconsistencia[5] = 't'; # Se estiver tudo corrigido, insere tramite se tiver que inserir. # existe um parametro no form que indica se o tramite deve ser inserido # pois o documento já poderá estar na area de trabalho da pessoa (neste caso nao insere) if (!in_array('f', $this->_arInconsistencia) && $dto->getPersistTramite()) { $this->getServiceLocator()->getService('VinculoMigracao')->setArtefatoCorrigido($entity->getSqArtefato()); } else { $this->_arInconsistencia[6] = 't'; } $arInconsistencia = implode(",", $this->_arInconsistencia); $arInconsistencia = "{" . $arInconsistencia . "}"; $entity->setArInconsistencia($arInconsistencia); // persistindo informacao $this->getEntityManager()->persist($entity); $this->getEntityManager()->flush($entity); // #HistoricoArtefato::save(); $strMessage = $this->getServiceLocator()->getService('HistoricoArtefato')->getMessage('MH022'); $this->getServiceLocator()->getService('HistoricoArtefato')->registrar($entity->getSqArtefato(), \Core_Configuration::getSgdoceSqOcorrenciaCorrigirMigracao(), $strMessage); $retorno = $this->getEntityManager()->commit(); } catch (\Exception $objException) { $this->getEntityManager()->rollback(); $this->getMessaging()->addErrorMessage("[" . $objException->getCode() . "] " . $objException->getMessage(), "User"); $retorno = $objException; } $this->getMessaging()->dispatchPackets(); return $retorno; }
/** * Seta os dados para gravar a entidade * @param array $aDados dados para definir os dados da entidade */ public function setDadosEventual(array $aDados) { $oFiltro = new Zend_Filter_Digits(); if (!empty($aDados['id_perfil'])) { $this->setPerfil(Administrativo_Model_Perfil::getById($aDados['id_perfil'])); } if (!empty($aDados['cnpjcpf'])) { $this->setCpfcnpj($oFiltro->filter($aDados['cnpjcpf'])); } if (!empty($aDados['nome'])) { $this->setNome($aDados['nome']); } if (!empty($aDados['nome_fantasia'])) { $this->setNomeFantasia($aDados['nome_fantasia']); } if (!empty($aDados['cep'])) { $this->setCep($oFiltro->filter($aDados['cep'])); } if (!empty($aDados['estado'])) { $this->setEstado($aDados['estado']); } if (!empty($aDados['cidade'])) { $this->setCidade($aDados['cidade']); } if (!empty($aDados['bairro'])) { $this->setBairro($aDados['bairro']); } if (!empty($aDados['cod_bairro'])) { $this->setCodBairro($aDados['cod_bairro']); } if (!empty($aDados['endereco'])) { $this->setEndereco($aDados['endereco']); } if (!empty($aDados['cod_endereco'])) { $this->setCodEndereco($aDados['cod_endereco']); } if (!empty($aDados['numero'])) { $this->setNumero($aDados['numero']); } if (!empty($aDados['complemento'])) { $this->setComplemento($aDados['complemento']); } if (!empty($aDados['telefone'])) { $this->setTelefone($oFiltro->filter($aDados['telefone'])); } if (!empty($aDados['email'])) { $this->setEmail($aDados['email']); } if (!empty($aDados['hash'])) { $this->setHash($aDados['hash']); } if (!empty($aDados['tipo_liberacao'])) { $this->setTipoLiberacao($aDados['tipo_liberacao']); } if (!empty($aDados['data_cadastro'])) { $this->setDataCadastro($aDados['data_cadastro']); } else { $this->setDataCadastro(new DateTime()); } return true; }
/** * Extracts phone area code and returns phone number, with area code as key of the returned array * @author Ricardo Martins <*****@*****.**> * @param string $phone * @return array */ private function _extractPhone($phone) { $digits = new Zend_Filter_Digits(); $phone = $digits->filter($phone); //se começar com zero, pula o primeiro digito if (substr($phone, 0, 1) == '0') { $phone = substr($phone, 1, strlen($phone)); } $originalPhone = $phone; $phone = preg_replace('/^(\\d{2})(\\d{7,9})$/', '$1-$2', $phone); if (is_array($phone) && count($phone) == 2) { list($area, $number) = explode('-', $phone); return array('area' => $area, 'number' => $number); } return array('area' => (string) substr($originalPhone, 0, 2), 'number' => (string) substr($originalPhone, 2, 9)); }
/** * */ protected function _getImageFromRequest() { $fltr = new Zend_Filter_Digits(); $re = $this->getRequest(); if (isset($re->id) && preg_match('/^[0-9]{1,30}$/', $re->id)) { $elid = $fltr->filter($re->id); $mdb = new Filfiles(); $where = 'id = ' . $elid . ' AND safinstances_id = ' . $this->safinstancesId; $r = $mdb->fetchAll($where); if (count($r) == 1) { return $r[0]; } else { return false; } } else { return false; } }