예제 #1
0
 /**
  * Retorna a lista de Profile para o Formulário
  * 
  * @param string $formName
  * @return array
  */
 public function getListProfile($formName)
 {
     $listProfile = array();
     $_profile = new Profile_DataView_ObjectView_MapperView();
     $session = Zend_Auth::getInstance()->getStorage()->read();
     $login = '';
     if ($session !== null) {
         $login = $session->getLogin();
         $_where = new ZendT_Db_Where();
         $_where->addFilter('login', $login);
         $_where->addFilter('objeto', $formName);
         $_where->addFilter('tipo', 'F');
         $_where->addFilter('publico', 'N');
         $_profile->findAll($_where, array('id', 'nome'), array('2'));
         while ($_profile->fetch()) {
             $key = $_profile->getId()->get();
             $value = $_profile->getNome()->get();
             $listProfile[$key] = $value;
         }
     }
     $_where = new ZendT_Db_Where();
     $_where->addFilter('objeto', $formName);
     $_where->addFilter('tipo', 'F');
     $_where->addFilter('publico', 'S');
     $_profile->findAll($_where, array('id', 'nome'), array('2'));
     while ($_profile->fetch()) {
         $key = $_profile->getId()->get();
         $value = $_profile->getNome()->get();
         $listProfile[$key] = $value;
     }
     return $listProfile;
 }
예제 #2
0
파일: Mapper.php 프로젝트: rtsantos/mais
 protected function _afterSave()
 {
     parent::_afterSave();
     $oldHierarquia = $this->getHierarquia(true)->toPhp();
     $idResp = $this->getIdPessoaResp(true)->toPhp();
     if ($idResp) {
         $_mapper = new Ca_Model_Pessoa_Mapper();
         $_mapper->setId($idResp)->retrieve();
         $hirarquia = $_mapper->getHierarquia(true)->toPhp() . '.' . $this->getId()->toPhp();
     } else {
         $hirarquia = $this->getId()->toPhp();
     }
     $hierarquiaComp = substr($hirarquia, 0, strlen($oldHierarquia));
     if ($hierarquiaComp && $oldHierarquia == $hierarquiaComp && $hierarquiaComp != $this->getId()->toPhp()) {
         //throw new ZendT_Exception_Alert(_i18n('Não é possível associar a empresa responvável para este registro, devido a infringir a hierarquia!'));
     }
     if ($oldHierarquia != $hirarquia) {
         $data = array();
         $data['hierarquia'] = $hirarquia;
         $this->getModel()->getAdapter()->update($this->getModel()->getName(), $data, 'id = ' . $this->getId()->toPhp());
     }
     $this->setHierarquia($hirarquia);
     if ($this->_action == 'update' && $oldHierarquia && $oldHierarquia != $hirarquia) {
         $_where = new ZendT_Db_Where();
         $_where->addFilter($this->getModel()->getName() . '.hierarquia', $oldHierarquia, '?%');
         $_where->addFilter($this->getModel()->getName() . '.id', $this->getId(), '!=');
         $_mapper = new Ca_DataView_Pessoa_MapperView();
         $_mapper->findAll($_where, '*');
         while ($_mapper->fetch()) {
             $_mapper->update();
         }
     }
 }
예제 #3
0
파일: Mapper.php 프로젝트: rtsantos/mais
 protected function _afterSave()
 {
     parent::_afterSave();
     if ($this->_action == 'update') {
         $_where = new ZendT_Db_Where();
         $_where->addFilter($this->getModel()->getName() . '.hierarquia', $this->_oldHierarquia, '?%');
         $_where->addFilter($this->getModel()->getName() . '.id', $this->getId(), '!=');
         $_mapper = new Auth_DataView_Conta_MapperView();
         $_mapper->findAll($_where, '*');
         while ($_mapper->fetch()) {
             $_mapper->update();
         }
         $idPai = $this->getIdPapelPai(true)->toPhp();
         if ($this->_idPaiOld && $this->_idPaiOld != $idPai) {
             $_relation = new Auth_Model_ContaRel_Mapper();
             $_relation->setIdPapel($this->getId())->setIdPapelRel($this->_idPaiOld)->retrieve();
             if ($idPai) {
                 $_relation->setIdPapelRel($idPai)->update();
             } else {
                 $_relation->delete();
             }
         }
     } elseif ($this->_action == 'insert') {
         $_relation = new Auth_Model_ContaRel_Mapper();
         $_relation->setIdPapel($this->getId())->setIdPapelRel($this->getId())->setStatus('A')->insert();
         if ($this->getIdPapelPai(true)->toPhp()) {
             $_relation->newRow()->setIdPapel($this->getId())->setIdPapelRel($this->getIdPapelPai())->setStatus('A')->insert();
         }
     }
 }
예제 #4
0
파일: Table.php 프로젝트: rtsantos/mais
 public function getWhereSeekerSearch($value, $field = '')
 {
     $where = new ZendT_Db_Where('AND');
     $result = array();
     $result['column'] = '';
     $result['operation'] = '';
     $result['mapper'] = $this->getMapperName();
     if (count($this->_primary) == 1) {
         if (is_numeric($value)) {
             $result['column'] = $this->_name . "." . $this->_primary[0];
             $result['operation'] = '=';
         }
     }
     if ($result['column'] == '') {
         $result['column'] = $this->_name . "." . $this->_search;
         $result['operation'] = '=';
         $idEmpresa = Auth_Session_User::getInstance()->getIdEmpresa();
         $_veiculo = new Frota_Model_Veiculo_Mapper();
         $_veiculo->setPlaca($value)->setIdEmpresa($idEmpresa);
         if (!$_veiculo->exists()) {
             $_veiculo->setPlaca($value)->setDescricao($_veiculo->getPlaca())->setIdEmpresa($idEmpresa)->insert();
         }
     }
     if ($value) {
         $where->addFilter($result['column'], $value, $result['operation'], $result['mapper']);
     }
     return $where;
 }
예제 #5
0
파일: Elements.php 프로젝트: rtsantos/mais
 public function getIdCliente()
 {
     $where = new ZendT_Db_Where();
     $where->addFilter('ca_pessoa.papel_cliente', 1);
     $_element = parent::getIdCliente();
     $_element->setWhere($where);
     return $_element;
 }
예제 #6
0
 protected function _getWhere($postData)
 {
     $where = false;
     if (ZendT_Acl::getInstance()->restriction('restringe-empresa', 'auth')) {
         $where = new ZendT_Db_Where('AND');
         $where->addFilter('empresa.hierarquia', Auth_Session_User::getInstance()->getHierarquiaEmpresa(), '?%');
     }
     return $where;
 }
예제 #7
0
파일: Mapper.php 프로젝트: rtsantos/mais
 public function save($tableName = '', $operation = '', $key = '', $note = '')
 {
     if ($tableName && $operation && $key) {
         list($owner, $table) = explode(".", str_replace('"', '', $tableName));
         if (substr($table, 0, 4) != 'LOG_') {
             $_logTabela = new Log_Model_LogTabela_Mapper();
             $where = new ZendT_Db_Where();
             $where->addFilter('owner', $owner);
             $where->addFilter('nome', $table);
             $_logTabela->retrieve($where);
             if (!$_logTabela->getId()) {
                 $_logTabela->setOwner($owner);
                 $_logTabela->setNome($table);
                 $_logTabela->setTableName($table);
                 $_logTabela->insert();
             }
             $this->setIdLogTabela($_logTabela->getId());
             $_logObjeto = new Log_Model_LogObjeto_Mapper();
             $where = new ZendT_Db_Where();
             $where->addFilter('id_log_tabela', $_logTabela->getId());
             $_logObjeto->retrieve($where);
             if (!$_logObjeto->getId()) {
                 $_logObjeto->setNome($table);
                 $_logObjeto->setDescricao("LOG DE {$table}");
                 $_logObjeto->setStatus('A');
                 $_logObjeto->setIdLogTabela($_logTabela->getId());
                 $_logObjeto->insert();
             }
             $this->setIdLogObjeto($_logObjeto->getId());
         }
         if ($this->getIdLogTabela() && $this->getIdLogObjeto()) {
             if ($operation == 'insert') {
                 $codOperation = 'INC';
             } else {
                 if ($operation == 'update') {
                     $codOperation = 'ALT';
                 } else {
                     if ($operation == 'delete') {
                         $codOperation = 'EXC';
                     }
                 }
             }
             if ($codOperation) {
                 $this->setIdUsuario(Zend_Auth::getInstance()->getStorage()->read()->getId());
                 $this->setChave($key);
                 $this->setIdObjeto($key);
                 $this->setObservacao($note);
                 $db = $this->getModel()->getAdapter();
                 $sql = "begin\n                                        log_pkg.addlog(p_objeto     => {$db->quote($_logObjeto->getNome()->getValueToDb())},\n                                                       p_operac     => {$db->quote($codOperation)},\n                                                       p_id_objeto  => {$db->quote($this->getIdObjeto()->getValueToDb())},\n                                                       p_id_usuario => {$db->quote($this->getIdUsuario()->getValueToDb())},\n                                                       p_chave      => {$db->quote($this->getChave()->getValueToDb())},\n                                                       p_observacao => {$db->quote($this->getObservacao()->getValueToDb())},\n                                                       p_commit     => 'S',\n                                                       p_tabela     => {$db->quote($_logTabela->getNome()->getValueToDb())});\n                                    end;";
                 $stmt = $db->prepare($sql);
                 $stmt->execute();
             }
         }
     }
     return $this;
 }
예제 #8
0
 public function _getWhere($postData)
 {
     if (Zend_Controller_Front::getInstance()->getRequest()->getParam('autoselectFilter')) {
         return false;
     }
     $_where = new ZendT_Db_Where('OR');
     $_where->addFilterExists("(" . $this->_restritionSql() . ")");
     $_where->addFilter("cms_categoria.publico", "S");
     return $_where;
 }
예제 #9
0
 /**
  * Valida e remove os arquivos que estão com data de expiração vencida
  * 
  */
 public function validateFilesExpires()
 {
     $_where = new ZendT_Db_Where();
     $_where->addFilter('dt_expira', ZendT_Type_Date::nowDate(), '<=');
     $_arquivo = new Ged_DataView_Arquivo_Crud_MapperView();
     $_arquivo->findAll($_where);
     while ($_arquivo->fetch()) {
         $this->remove($_arquivo->getId()->toPhp());
     }
 }
예제 #10
0
파일: Table.php 프로젝트: rtsantos/mais
 /**
  *
  * @param int $processId
  * @param string $value 
  * @return ZendT_Workflow_Fase_Row;
  */
 public function getFase($processId, $value)
 {
     $where = new ZendT_Db_Where();
     $where->addFilter('id_wf_processo', $processId);
     $where->addFilter('valor', $value);
     $rows = $this->getRows($where);
     $fase = new ZendT_Workflow_Fase_Row();
     $fase->setDescription($rows[0]['descricao']);
     $fase->setNotification($rows[0]['proc_notif']);
     return $fase;
 }
예제 #11
0
파일: Mapper.php 프로젝트: rtsantos/mais
 /**
  * 
  * @return ZendT_Type_Number
  */
 public function save()
 {
     if ($this->getId(true)->toPhp()) {
         $where = new ZendT_Db_Where();
         $where->addFilter('image.img_docto.id', str_replace('.', '', $this->getId()->toPhp()));
         $this->update($where);
     } else {
         $this->insert();
     }
     return $this->getId();
 }
예제 #12
0
파일: Mapper.php 프로젝트: rtsantos/mais
 public function processLanc()
 {
     $_lancamentos = new Financeiro_DataView_Lancamento_MapperView();
     $_where = new ZendT_Db_Where();
     $_where->addFilter('fc_lancamento.dt_lanc', ZendT_Type_Date::nowDate(), '<=');
     if (Auth_Session_User::getInstance()->getIdEmpresa()) {
         $_where->addFilter('fc_lancamento.id_empresa', Auth_Session_User::getInstance()->getIdEmpresa());
     }
     $_where->addFilter('fc_lancamento.vlr_saldo', '', '=', '', true);
     $_lancamentos->findAll($_where);
     while ($_lancamentos->fetch()) {
         $_lancamentos->update();
     }
 }
예제 #13
0
파일: Mapper.php 프로젝트: rtsantos/mais
 protected function _afterSave()
 {
     parent::_afterSave();
     if ($this->_action == 'update') {
         $_where = new ZendT_Db_Where();
         $_where->addFilter('recurso.hierarquia', $this->_oldHierarquia, '?%');
         $_where->addFilter('recurso.id', $this->getId(), '!=');
         $_mapper = new Auth_DataView_Recurso_MapperView();
         $_mapper->findAll($_where);
         while ($_mapper->fetch()) {
             $_mapper->update();
         }
     }
 }
예제 #14
0
파일: Table.php 프로젝트: rtsantos/mais
 /**
  *
  * @param type $mapperName 
  * @return ZendT_Workflow_Process_Row[]
  */
 public function getProcess($mapperName)
 {
     $where = new ZendT_Db_Where();
     $where->addFilter('nome_modelo', $mapperName);
     $rows = $this->getRows($where);
     $_process = array();
     $_iProcess = 0;
     foreach ($rows as $row) {
         $_process[$_iProcess] = new ZendT_Workflow_Process_Row();
         $_process[$_iProcess]->setDescription($row['descricao']);
         $_process[$_iProcess]->setColumn($row['coluna_filtro']);
         $_process[$_iProcess]->setId($row['id']);
         $_iProcess++;
     }
     return $_process;
 }
예제 #15
0
파일: Crud.php 프로젝트: rtsantos/mais
 /**
  *
  * @param type $mapper
  * @param type $id
  * @param type $filter
  * @param type $filters
  * @param type $filterOp
  * @return \ZendT_Db_Where 
  */
 private function _getWhere(&$mapper, $id, $filter, $filters, $filterOp)
 {
     $where = '';
     if ($id != '') {
         $mapper->setId($id);
         $where = $mapper->getWhere();
     } else {
         if (count($filters) > 0) {
             $where = new ZendT_Db_Where($filterOp);
             foreach ($filters as $filter) {
                 $where->addFilter($filter->field, $filter->value, $filter->operation, $filter->mapperName);
             }
         } elseif ($filter->field && $filter->value) {
             $where = new ZendT_Db_Where($filterOp);
             $where->addFilter($filter->field, $filter->value, $filter->operation, $filter->mapperName);
         }
     }
     return $where;
 }
예제 #16
0
파일: Job.php 프로젝트: rtsantos/mais
 public function run()
 {
     $_job = new Tools_DataView_Job_MapperView();
     $_where = new ZendT_Db_Where();
     $_where->addFilter('job.dh_pro_exec', ZendT_Type_Date::nowDateTime(), '<=');
     $_where->addFilter('job.dh_fim_exec', ZendT_Type_Date::nowDateTime(), '>=');
     $_where->addFilter('job.status', 'A');
     $_job->findAll($_where, '*');
     while ($_job->fetch()) {
         $_now = ZendT_Type_Date::nowDateTime();
         while ($_job->getDhProExec()->toPhp() <= $_now->toPhp()) {
             if ($_job->getTpFrequencia()->toPhp() == 'H') {
                 $_job->getDhProExec()->addHour($_job->getNumFrequencia()->toPhp());
             } else {
                 if ($_job->getTpFrequencia()->toPhp() == 'D') {
                     $_job->getDhProExec()->addDay($_job->getNumFrequencia()->toPhp());
                 } else {
                     if ($_job->getTpFrequencia()->toPhp() == 'M') {
                         $_job->getDhProExec()->addMonth($_job->getNumFrequencia()->toPhp());
                     }
                 }
             }
         }
         $_job->setStatus('E');
         $_job->update();
         try {
             if ($_job->getFormaExec()->toPhp() == 'C') {
                 $_adapter = new Tools_Interface_Job_Php();
             } else {
                 $_adapter = new Tools_Interface_Job_Http();
             }
             $_adapter->jobId = $_job->getId()->toPhp();
             $_th = new ZendT_Thread();
             $_th->start($_adapter, 'run');
         } catch (Exception $ex) {
             $message = 'Mensagem: ' . $ex->getMessage() . "\n";
             $message .= 'Erro: ' . $ex->getTraceAsString() . "\n";
             Tools_Model_LogErro_Mapper::log($_job->getProcedimento()->toPhp(), $message);
         }
     }
 }
예제 #17
0
파일: Mapper.php 프로젝트: rtsantos/mais
 public function setDefaultPrivilege($id, $idCopyFrom = '')
 {
     if ($id) {
         $_objectViewPriv = new Profile_DataView_ObjectViewPriv_MapperView();
         if (!$idCopyFrom) {
             $idInfo = $this->getIdPapelInformatica();
             if ($idInfo) {
                 $_objectViewPriv->setIdProfileObjectView($id)->setIdPapel($idInfo)->setTipo("O")->insert();
                 return true;
             }
         } else {
             $_where = new ZendT_Db_Where();
             $_where->addFilter("id_profile_object_view", $idCopyFrom);
             $_objectViewPriv->findAll($_where, "*");
             while ($_objectViewPriv->fetch()) {
                 $_objectViewPriv->setIdProfileObjectView($id)->insert();
             }
         }
     }
     return false;
 }
예제 #18
0
파일: Edit.php 프로젝트: rtsantos/mais
 /**
  * Carrega os elementos no formulário para serem renderizado
  * @return void
  */
 public function loadElements($action = 'insert')
 {
     parent::loadElements($action);
     $filterJson = Zend_Controller_Front::getInstance()->getRequest()->getParam('filter_json');
     if ($filterJson) {
         $where = ZendT_Db_Where::fromJson($filterJson);
         $filter = $where->getFilter('profile_job.id');
         $_mapper = new Profile_Model_Job_Mapper();
         $_mapper->setId($filter['value'])->retrive();
         $row = $_mapper->getData();
         $this->getElement('id_profile_job')->setValue($row);
     }
 }
예제 #19
0
파일: Mapper.php 프로젝트: rtsantos/mais
 /**
  * 
  * @return int|ZendT_Type
  */
 public function save($updateIfExists = false)
 {
     $id = 0;
     $this->_beforeSave();
     $hashcode = $this->getHashcode();
     $where = new ZendT_Db_Where();
     $where->addFilter('img_arquivo.hashcode', $hashcode);
     if ($this->exists($where)) {
         if ($updateIfExists) {
             $this->update();
         }
         $id = $this->getId();
     } else {
         if ($this->getId(true)->toPhp()) {
             $id = $this->getId();
         } else {
             $this->insert();
             $id = $this->getId();
         }
     }
     $this->_afterSave();
     return $id;
 }
예제 #20
0
파일: Table.php 프로젝트: rtsantos/mais
 public function getWhereSeekerSearch($value, $field = '')
 {
     $where = new ZendT_Db_Where('AND');
     $result = array();
     $result['column'] = '';
     $result['operation'] = '';
     $result['mapper'] = $this->getMapperName();
     if (count($this->_primary) == 1) {
         if (is_numeric($value)) {
             $result['column'] = $this->_name . "." . $this->_primary[0];
             $result['operation'] = '=';
         }
     }
     if ($field == 'id') {
         $result['column'] = $this->_name . ".id";
         $result['operation'] = '=';
     }
     if ($result['column'] == '') {
         $_usuario = new Auth_DataView_Conta_MapperView();
         $where = new ZendT_Db_Where('AND');
         $where->addFilter('papel.descricao', $value, '?%', 'Auth_Model_Conta_Mapper');
         $data = $_usuario->getDataGrid($where, array());
         $row = $data->getRow();
         if ($row) {
             $result['column'] = $this->_name . ".descricao";
             $result['operation'] = '?%';
         } else {
             $result['column'] = $this->_name . "." . $this->_search;
             $result['operation'] = '?%';
         }
     }
     if ($value) {
         $where = new ZendT_Db_Where('AND');
         $where->addFilter($result['column'], $value, $result['operation'], $result['mapper']);
     }
     return $where;
 }
예제 #21
0
파일: Edit.php 프로젝트: rtsantos/mais
 /**
  * Carrega os elementos no formulário para serem renderizado
  * @return void
  */
 public function loadElements($action = 'insert')
 {
     parent::loadElements($action);
     $filterJson = Zend_Controller_Front::getInstance()->getRequest()->getParam('filter_json');
     if ($filterJson) {
         $where = ZendT_Db_Where::fromJson($filterJson);
         $filter = $where->getFilter('profile_object_view_priv.id_profile_object_view');
         $_mapper = new Profile_Model_ObjectView_Mapper();
         $_mapper->setId($filter['value'])->retrive();
         $row = $_mapper->getData();
         $this->getElement('id_profile_object_view')->setValue($row);
         $tipo = $filter = $where->getFilter('profile_object_view_priv.tipo');
         if ($tipo) {
             $this->getElement('tipo')->setValue($tipo);
             //->setDecorators(array(new ZendT_Form_Decorator_Hidden()));
         }
     }
 }
예제 #22
0
파일: Select.php 프로젝트: rtsantos/mais
 public function sqlBase()
 {
     $cmdWhere = '';
     $this->_binds = array();
     if ($this->_where instanceof ZendT_Db_Table_Select) {
         $cmdWhere = $this->_where->getSqlWhere();
         $this->_binds = $this->_where->getBinds();
     }
     $commands = $this->getCommands();
     $sql = 'SELECT ' . $commands['columns'];
     $sql .= '  FROM ' . $this->_table->getTableName() . ' "' . $this->_table->getTableAlias() . '" ';
     $sql .= ' ' . $commands['join'];
     $sql .= ' WHERE 1 = 1 ';
     $sql .= $cmdWhere;
     if ($this->_order) {
         $sql .= ' ORDER BY ' . $this->_order;
     }
     print $sql;
     return $sql;
 }
예제 #23
0
파일: Edit.php 프로젝트: rtsantos/mais
 /**
  * Carrega os elementos no formulário para serem renderizado
  * @return void
  */
 public function loadElements($action = 'insert', $newAction = '')
 {
     parent::loadElements($action);
     $this->setName($this->_formNome);
     if ($newAction) {
         $this->setAction(ZendT_Url::getUri(true) . "/" . $newAction);
     }
     $filterJson = Zend_Controller_Front::getInstance()->getRequest()->getParam('filter_json');
     if ($filterJson) {
         $where = ZendT_Db_Where::fromJson($filterJson);
         $filter = $where->getFilter('id');
         $_mapper = new Cms_Model_Conteudo_Mapper();
         $_mapper->setId($filter['value'][0])->retrive();
         $row = $_mapper->getData();
         unset($row['thumbnail']);
         unset($row['banner']);
         unset($row['arquivo']);
         $this->populate($row);
     }
     $this->loadButtons();
 }
예제 #24
0
 /**
  *
  * @param type $viewName 
  * @return array
  */
 public function getProfile($viewName)
 {
     $config = array();
     $row = false;
     $_profile = new Profile_DataView_User_MapperView();
     $session = Zend_Auth::getInstance()->getStorage()->read();
     $login = '';
     if ($session !== null) {
         $login = $session->getLogin();
     }
     $idProfile = Zend_Controller_Front::getInstance()->getParam('id_profile');
     if ($idProfile) {
         $_where = new ZendT_Db_Where();
         $_where->addFilter('id', $idProfile);
         $row = $_profile->retriveRow($_where);
     }
     if ($login && !$row) {
         $_where = new ZendT_Db_Where();
         $_where->addFilter('login', $login);
         $_where->addFilter('objeto', $viewName);
         $_where->addFilter('tipo', 'Grid');
         $_where->addFilter('padrao', 'S');
         $row = $_profile->retriveRow($_where);
     }
     if (!$row) {
         $login = '******';
         $_where = new ZendT_Db_Where();
         $_where->addFilter('login', $login);
         $_where->addFilter('objeto', $viewName);
         $_where->addFilter('tipo', 'Grid');
         $_where->addFilter('padrao', 'S');
         $row = $_profile->retriveRow($_where);
     }
     if (!$row) {
         $login = '******';
         $_where = new ZendT_Db_Where();
         $_where->addFilter('login', $login);
         $_where->addFilter('objeto', $viewName);
         $_where->addFilter('tipo', 'Grid');
         $_where->addFilter('padrao', 'S');
         $row = $_profile->retriveRow($_where);
     }
     if ($row) {
         $config = unserialize($row['config']->get());
         $config['grouds'] = ZendT_Sort::sortArray($config['grouds'], 'order');
     }
     return $config;
 }
예제 #25
0
파일: Mapper.php 프로젝트: rtsantos/mais
 public function cancelar($idPedido = false)
 {
     if (!$idPedido) {
         $idPedido = $this->getIdPedido();
     }
     $_lancamento = new Financeiro_DataView_Lancamento_MapperView();
     $_where = new ZendT_Db_Where();
     $_where->addFilter('item_pedido.id_pedido', $idPedido);
     $_itemLanc = new Vendas_DataView_ItemLanc_MapperView();
     $_itemLanc->findAll($_where, '*');
     while ($_itemLanc->fetch()) {
         $_lancamento->setId($_itemLanc->getIdLancamento())->retrieve()->cancelar();
     }
     $_where = new ZendT_Db_Where();
     $_where->addFilter('pagto_pedido.id_pedido', $idPedido);
     $_pagtoLanc = new Vendas_DataView_PagtoLanc_MapperView();
     $_pagtoLanc->findAll($_where, '*');
     while ($_pagtoLanc->fetch()) {
         $_lancamento->setId($_pagtoLanc->getIdLancamento())->retrieve()->cancelar();
     }
     return true;
 }
예제 #26
0
 public function runAction()
 {
     $_job = new Profile_Model_Job_Mapper();
     $_job->setId($this->getRequest()->getParam('id'))->retrive()->setDhUltExec("SYSDATE")->update();
     $_view = new Profile_DataView_Job_Users();
     $where = new ZendT_Db_Where();
     $where->addFilter('profile_job.id', $this->getRequest()->getParam('id'));
     $where->addFilter('usuario.email', "", "!NULL");
     $data = $_view->recordset($where);
     while ($row = $data->getRow()) {
         try {
             $uri = $row['uri']->get();
             if ($uri == '') {
                 $uri = ZendT_Lib::convertObjectToUri($row['objeto']->get());
             }
             $uriOriginal = $uri . '/dynamic/profile/' . $row['id_profile']->get();
             $uri .= '/found/profile/' . $row['id_profile']->get() . '/no_location/1?' . $row['uri_token']->get();
             $client = new Zend_Http_Client($uri, array('timeout' => '80'));
             $response = $client->request();
             if ($response->getBody() == 'OK') {
                 $mail = new ZendT_Mail();
                 $mail->addTo($row['email_usuario']->get(), $row['nome_usuario']->get());
                 $mail->addFrom('*****@*****.**', 'Transportadora Americana');
                 $mail->setTitle($row['nome']->get());
                 $mail->setSubject($row['nome']->get());
                 $comment = $row['observacao']->get();
                 if (!$comment) {
                     $comment = $row['nome']->get();
                 }
                 $comment .= '<br><br>Para acessar o relatório clique <a href = "' . str_replace(array('/found/', '/no_location/1'), array('/dynamic/', ''), $uri) . '">aqui</a>';
                 $mail->setComment($comment);
                 $body = '<br>';
                 $user = array();
                 $user['id'] = $row['id_usuario']->get();
                 $user['role'] = $row['nome_papel']->get();
                 $listProfile = ZendT_Profile::listProfile($row['objeto']->get(), '', $user);
                 if (count($listProfile) > 0) {
                     $body .= '<style type="text/css">';
                     $body .= '    <!--';
                     $body .= '    td {';
                     $body .= '            font-family: Arial, Helvetica, sans-serif;';
                     $body .= '            font-size: 12px;';
                     $body .= '    }';
                     $body .= '    .TitleTable {';
                     $body .= '            font-weight: bold;';
                     $body .= '            border-bottom: 0px;';
                     $body .= '    }';
                     $body .= '    .viewTitle {';
                     $body .= '            background-color: #F9F9F9;';
                     $body .= '            font-weight: bold;';
                     $body .= '    }';
                     $body .= '    .viewTable {';
                     $body .= '            border:1px solid #CCCCCC;';
                     $body .= '    }';
                     $body .= '    -->';
                     $body .= '</style>';
                     $body .= '<table width="100%" border="0" cellpadding="5" cellspacing="0" class="viewTable">';
                     $body .= '	<tr >';
                     $body .= '		<td class="viewTitle">Visões Disponíveis</td>';
                     $body .= '	</tr>';
                     $body .= '	<tr>';
                     $body .= '		<td>';
                     $body .= '			<table width="100%" border="0" cellpadding="5" cellspacing="0">';
                     $body .= '				<tr>';
                     $body .= '					<td class="TitleTable">Tipo</td>';
                     $body .= '					<td class="TitleTable">Visão</td>';
                     $body .= '					<td class="TitleTable">Observação</td>';
                     $body .= '				</tr>';
                     foreach ($listProfile as $profile => $detailProfile) {
                         $uri = ZendT_Lib::convertObjectToUri($row['objeto']->get()) . '/found/profile/' . $profile . '?' . $row['uri_token']->get();
                         $body .= '				<tr>';
                         $body .= '					<td>' . $detailProfile['tipoDescricao'] . '</td>';
                         $body .= '					<td><a href = "' . str_replace('/found/', '/dynamic/', $uri) . '">' . $detailProfile['nome'] . '</a></td>';
                         $body .= '					<td>' . $detailProfile['observacao'] . '</td>';
                         $body .= '				</tr>';
                     }
                     $body .= '			</table>';
                     $body .= '		</td>';
                     $body .= '	</tr>';
                     $body .= '</table>';
                 }
                 $mail->setBody($body);
                 $mail->save();
             }
         } catch (Exception $ex) {
             $mail = new ZendT_Mail();
             /* $mail->addTo("*****@*****.**"); */
             $mail->addTo("*****@*****.**");
             $mail->addFrom('*****@*****.**', 'Transportadora Americana');
             $mail->setTitle('Erro no envio de e-mail pelo agendamento de tarefa');
             $mail->setSubject($mail->getTitle());
             $comment = $row['nome']->get() . '<br><br>Para acessar o relatório clique <a href = "' . $uriOriginal . '">aqui</a>';
             $mail->setComment($comment);
             $mail->setBody($ex->getMessage());
             $mail->save();
             /*echo 'Erro';
               exit;*/
         }
     }
     echo 'Processado';
     exit;
 }
예제 #27
0
파일: Mapper.php 프로젝트: rtsantos/mais
 public function _afterSave()
 {
     parent::_afterSave();
     if (count($this->_others['item_pedido']) > 0 && $this->_others['item_pedido']['id_produto']) {
         $_itemPedido = new Vendas_DataView_ItemPedido_MapperView();
         $_itemPedido->setIdPedido($this->getId())->setIdProduto($this->_others['item_pedido']['id_produto'])->setQtdItem($this->_others['item_pedido']['qtd_item']);
         if (!$_itemPedido->exists()) {
             $_itemPedido->insert();
         }
     }
     if (count($this->_others['pagamento']) > 0 && $this->_others['pagamento']['id_forma_pagto']) {
         $_pagamento = new Vendas_DataView_Pagamento_MapperView();
         $_pagamento->setIdPedido($this->getId())->setIdFormaPagto($this->_others['pagamento']['id_forma_pagto']);
         if (!$_pagamento->exists()) {
             $_pagamento->insert();
         }
     }
     if ($this->getStatus(true)->toPhp() == 'E') {
         $_pagtoLanc = new Vendas_DataView_PagtoLanc_MapperView();
         $_where = new ZendT_Db_Where();
         $_where->addFilter('pagto_pedido.id_pedido', $this->getId());
         $_pagtoLanc->findAll($_where);
         if (!$_pagtoLanc->fetch()) {
             $this->_pagamento->efetivar($this->getId());
         }
     }
     if ($this->getStatus(true)->toPhp() == 'C') {
         $_pagtoLanc = new Vendas_DataView_PagtoLanc_MapperView();
         $_where = new ZendT_Db_Where();
         $_where->addFilter('pagto_pedido.id_pedido', $this->getId());
         $_pagtoLanc->findAll($_where);
         if ($_pagtoLanc->fetch()) {
             $this->_pagamento->cancelar($this->getId());
         }
     }
 }
예제 #28
0
파일: Profile.php 프로젝트: rtsantos/mais
 public static function get($objectName, $type, $profile = '')
 {
     $_priv = new Profile_Model_ObjectViewPriv_Mapper();
     $sqlPriv = $_priv->getSqlPriv();
     $config = array();
     $row = false;
     $idUsuario = Auth_Session_User::getInstance()->getId();
     $idProfile = '';
     $_profile = new Profile_DataView_ObjectView_MapperView();
     $request = Zend_Controller_Front::getInstance()->getRequest();
     if (is_object($request)) {
         if (!$profile) {
             $profile = $request->getParam('profile');
         }
         $parentId = $request->getParam('profile_parent_id');
         $profileKey = $request->getParam('profile_key');
     }
     if ($parentId && is_numeric($parentId)) {
         $_profile->newRow()->setId($parentId)->retrieve();
         $chave = $_profile->getChave()->get();
         /**
          * 
          */
         $_where = new ZendT_Db_Where('AND');
         $_where->addFilter('profile_object_view.objeto', $objectName);
         $_where->addFilter('profile_object_view.chave', $chave);
         if (is_array($type)) {
             $_where->addFilter('profile_object_view.tipo', $type, 'in');
         } else {
             if ($type) {
                 $_where->addFilter('profile_object_view.tipo', $type);
             }
         }
         $_whereSec = new ZendT_Db_Where('OR');
         $_whereSec->addFilter('profile_object_view.id_usuario', $idUsuario);
         $_whereSec->addFilter('acesso_liberado', new Zend_Db_Expr($sqlPriv), 'EXISTS');
         $_whereGroup = new ZendT_Db_Where_Group();
         $_whereGroup->addWhere($_whereSec);
         $_whereGroup->addWhere($_where);
         $row = $_profile->retriveRow($_whereGroup);
         if ($row) {
             $profile = $row['id']->get();
         }
     }
     if (!$profile) {
         if ($profileKey) {
             $_where = new ZendT_Db_Where('AND');
             $_where->addFilter('profile_object_view.objeto', $objectName);
             $_where->addFilter('profile_object_view.chave', $profileKey);
             if (is_array($type)) {
                 $_where->addFilter('profile_object_view.tipo', $type, 'in');
             } else {
                 if ($type) {
                     $_where->addFilter('profile_object_view.tipo', $type);
                 }
             }
             $row = $_profile->retriveRow($_where);
             if ($row) {
                 $profile = $row['id']->get();
             }
         }
     }
     if ($profile) {
         if (!is_numeric($profile)) {
             $_where = new ZendT_Db_Where('AND');
             $_where->addFilter('profile_object_view.objeto', $objectName);
             $_where->addFilter('profile_object_view.chave', $profile, '=');
             $row = $_profile->retriveRow($_where);
             if ($row) {
                 $profile = $row['id']->get();
             }
         }
         $idProfile = $profile;
     }
     if (isset($_COOKIE['profile-' . $objectName . '-' . $type]) && $idProfile == '') {
         $idProfile = $_COOKIE['profile-' . $objectName . '-' . $type];
     }
     if (isset($_COOKIE['profile-' . $objectName]) && $idProfile == '') {
         $idProfile = $_COOKIE['profile-' . $objectName];
     }
     if (isset($_SESSION['profile-' . $objectName]) && $idProfile == '') {
         $idProfile = $_SESSION['profile-' . $objectName];
     }
     if ($idProfile) {
         $_where = new ZendT_Db_Where();
         $_where->addFilter('profile_object_view.id', $idProfile);
         $_whereSec = new ZendT_Db_Where('OR');
         $_whereSec->addFilter('profile_object_view.id_usuario', $idUsuario);
         $_whereSec->addFilter('acesso_liberado', new Zend_Db_Expr($sqlPriv), 'EXISTS');
         $_whereGroup = new ZendT_Db_Where_Group();
         $_whereGroup->addWhere($_whereSec);
         $_whereGroup->addWhere($_where);
         $row = $_profile->retriveRow($_whereGroup);
     }
     if ($idUsuario && !$row) {
         $_where = new ZendT_Db_Where('AND');
         $_where->addFilter('profile_object_view.objeto', $objectName);
         $_where->addFilter('profile_object_view.padrao', 'S');
         if (is_array($type)) {
             $_where->addFilter('profile_object_view.tipo', $type, 'in');
         } else {
             if ($type) {
                 $_where->addFilter('profile_object_view.tipo', $type);
             }
         }
         $_whereSec = new ZendT_Db_Where('OR');
         $_whereSec->addFilter('profile_object_view.id_usuario', $idUsuario);
         $_whereSec->addFilter('acesso_liberado', new Zend_Db_Expr($sqlPriv), 'EXISTS');
         $_whereGroup = new ZendT_Db_Where_Group();
         $_whereGroup->addWhere($_whereSec);
         $_whereGroup->addWhere($_where);
         $row = $_profile->retriveRow($_whereGroup);
     }
     if ($idUsuario && !$row) {
         $_where = new ZendT_Db_Where('AND');
         $_where->addFilter('profile_object_view.objeto', $objectName);
         if (is_array($type)) {
             $_where->addFilter('profile_object_view.tipo', $type, 'in');
         } else {
             if ($type) {
                 $_where->addFilter('profile_object_view.tipo', $type);
             }
         }
         $_whereSec = new ZendT_Db_Where('OR');
         $_whereSec->addFilter('profile_object_view.id_usuario', $idUsuario);
         $_whereSec->addFilter('acesso_liberado', new Zend_Db_Expr($sqlPriv), 'EXISTS');
         $_whereGroup = new ZendT_Db_Where_Group();
         $_whereGroup->addWhere($_whereSec);
         $_whereGroup->addWhere($_where);
         $row = $_profile->retrieveRow($_whereGroup);
     }
     if ($row) {
         $config = unserialize(html_entity_decode($row['config']->get()));
         $config['id'] = $row['id']->get();
         $config['tipo'] = $row['tipo']->toPhp();
         $config['title'] = $row['nome']->get();
     }
     return $config;
 }
예제 #29
0
파일: View.php 프로젝트: rtsantos/mais
 public function getWhere($params = array())
 {
     if (count($this->_columns) == 0) {
         throw new ZendT_Exception_Error('Favor adicionar as colunas!');
     }
     if ($params['filter_json']) {
         if (!is_array($this->_profileDefault['value'])) {
             $this->_profileDefault['value'] = array();
         }
         $whereJson = ZendT_Db_Where::fromJson(stripslashes($params['filter_json']));
         foreach ($whereJson->getFilters() as $key => $val) {
             $valueFilter = $val['value'];
             if (is_array($valueFilter)) {
                 $valueFilter = implode(";", $valueFilter);
             }
             $this->_profileDefault['value'][$val['field']] = $val['operation'] . $valueFilter;
         }
     }
     if (is_array($this->_profileDefault['value'])) {
         foreach ($this->_profileDefault['value'] as $aliasColumn => $value) {
             if (isset($params[$aliasColumn]) && $params[$aliasColumn]) {
                 $value = $params[$aliasColumn];
             }
             if ($value) {
                 $arrayNull = array('NULO', 'NULL', 'VAZIO');
                 /* Alterar também em: library\ZendT\Db\Where.php */
                 if (!in_array(strtoupper($value), $arrayNull) && !in_array(strtoupper(substr($value, 1)), $arrayNull) && !in_array(strtoupper(substr($value, 2)), $arrayNull)) {
                     $value = $this->_parseValue($value, $this->_columns[$aliasColumn]['type']);
                 }
                 if (isset($this->_columns[$aliasColumn]['expression'])) {
                     $params['expression-' . $aliasColumn] = $value;
                 } else {
                     $params[$this->_columns[$aliasColumn]['aliasTable'] . '-' . $this->_columns[$aliasColumn]['columnName']] = $value;
                 }
             }
         }
     }
     if (count($params) > 0) {
         $columns = $this->getColumnsMapper();
         $where = ZendT_Db_Where::fromAutoFilter($params, $columns);
     } else {
         $where = false;
     }
     return $where;
 }
예제 #30
0
파일: Dynamic.php 프로젝트: rtsantos/mais
 /**
  *
  * @return \ZendT_Db_Where 
  */
 public function getWhere($onlyValidParam = false)
 {
     $params = Zend_Controller_Front::getInstance()->getRequest()->getParams();
     $columnsMapper = $this->_mapper->getColumns()->toArray();
     $columns = $this->_mapper->getColumns()->getColumnsMapper();
     $columns->add('*', get_class($this->_mapper));
     $paramValid = array();
     $binds = array();
     /**
      * Verifica se no profile existe filtro padrão configurado 
      */
     $columnsFilters = $this->_options['cols-filter']['fields'];
     #var_dump($columnsMapper);die;
     foreach ($params as $key => $val) {
         if (!array_key_exists($key, $columnsFilters)) {
             if ($columnsMapper[$key]) {
                 $value = $params[$key];
                 if (isset($columnsMapper[$key]['listOptions'][$value])) {
                     $value = $columnsMapper[$key]['listOptions'][$value];
                 }
                 $columnsFilters[$key] = array('label' => $columnsMapper[$key]['label'], 'value' => $value);
             }
         }
     }
     #var_dump($columnsFilters);die;
     if (isset($columnsFilters)) {
         foreach ($columnsFilters as $columnName => $column) {
             /* echo $columnName;
                print_r($this->_options);
                exit; */
             if ($columnsMapper[$columnName]['expression']) {
                 $field = 'expression-' . $columnName;
             } else {
                 $field = str_replace('.', '-', $columnsMapper[$columnName]['column']);
             }
             $label = $columnsFilters[$columnName]['label'];
             if (!$label) {
                 $label = $columnsMapper[$columnName]['label'];
             }
             if ($params[$columnName . '-multiple']) {
                 $this->_params[$columnName] = $params[$columnName . '-multiple'];
                 $labelWhere[str_replace('-', '.', $field)] = $label;
                 $labelWhere[$columnName] = $label;
                 $params[$field] = $params[$columnName . '-multiple'];
                 $paramValid[$columnName] = true;
                 unset($params[$columnName . '-multiple']);
                 if (is_array($columnsMapper[$columnName]['bind'])) {
                     $binds[$columnName] = $columnsMapper[$columnName]['bind'];
                 }
                 continue;
             }
             if ($params[$columnName]) {
                 $this->_params[$columnName] = $params[$columnName];
                 $labelWhere[str_replace('-', '.', $field)] = $label;
                 $labelWhere[$columnName] = $label;
                 $params[$field] = $params[$columnName];
                 $paramValid[$columnName] = true;
                 if (is_array($columnsMapper[$columnName]['bind'])) {
                     $binds[$columnName] = $columnsMapper[$columnName]['bind'];
                 }
                 unset($params[$columnName]);
                 continue;
             }
             if (isset($params[$columnName . '-multiple'])) {
                 unset($params[$columnName . '-multiple']);
             }
             #if ($params[str_replace('.','-',$columnsMapper[$columnName]['column'])]){
             #    continue;
             #}
             $valueParse = $columnsFilters[$columnName]['value'];
             if (in_array($columnsMapper[$columnName]['type'], array('Date', 'DateTime'))) {
                 $values = array();
                 if (strpos($valueParse, ';')) {
                     $sep = ';';
                     $values = explode(';', $valueParse);
                 } else {
                     if (strpos($valueParse, ' ')) {
                         $sep = ' ';
                         $values = explode(' ', $valueParse);
                     } else {
                         if ($config['value'] != '') {
                             $sep = '';
                             $values = array($valueParse);
                         } else {
                             if ($valueParse) {
                                 $sep = '';
                                 $values = array($valueParse);
                             }
                         }
                     }
                 }
                 $valueParse = '';
                 foreach ($values as $value) {
                     $date = ZendT_Type_Date::parse($value, $columnsMapper[$columnName]['type']);
                     if ($valueParse) {
                         $valueParse .= $sep . str_replace(" ", "-", $date->get());
                     } else {
                         $valueParse = str_replace(" ", "-", $date->get());
                     }
                 }
             } else {
                 if (strtolower(substr($valueParse, 0, 5)) == 'logon') {
                     $levels = explode('.', $valueParse);
                     $_sessionValue = $_SESSION;
                     foreach ($levels as $level) {
                         $_sessionValue = $_sessionValue[$level];
                     }
                     $valueParse = $_sessionValue;
                 }
             }
             if ($valueParse) {
                 $labelWhere[str_replace('-', '.', $field)] = $label;
                 $labelWhere[$columnName] = $label;
                 $params[$field] = $valueParse;
                 $paramValid[$columnName] = true;
                 $this->_params[$columnName] = $valueParse;
                 if (is_array($columnsMapper[$columnName]['bind'])) {
                     $binds[$columnName] = $columnsMapper[$columnName]['bind'];
                 }
             }
         }
     }
     #
     foreach ($columnsMapper as $columnName => $column) {
         if ($column['required'] && !$paramValid[$columnName]) {
             throw new ZendT_Exception_Alert($column['required']);
         }
     }
     #var_dump($params);die;
     $where = ZendT_Db_Where::fromAutoFilter($params, $columns, null, $binds);
     if (method_exists($this->_mapper, 'setWhere')) {
         $this->_mapper->setWhere($where);
     }
     if (method_exists($this->_mapper, 'paramIsValid')) {
         $this->_mapper->paramIsValid($where);
     }
     if ($onlyValidParam) {
         return $where;
     }
     /**
      * Trata parâmetros a serem impressos no PDF e XLS
      */
     #print_r($labelWhere);
     if ($this->_options['printLabelFilters']) {
         $this->_labelFilters = $where->getFriendlyFilter($labelWhere);
         /**
          * Realiza a substituição dos ids pela descrição dos campos configurados na seeker
          */
         foreach ($this->_configColumns as $array => $field) {
             if (is_array($field['seeker'])) {
                 $newfield = $field['aliasTable'] . "." . $field['columnName'];
                 /*
                  * Monta uma lista dos ids a partir da label atual para aplicar filtro no banco
                  */
                 $value = $this->_labelFilters[$newfield]['value'];
                 $union = '';
                 if (strpos($value, ',') !== false) {
                     $values = explode(',', $value);
                     $union = ',';
                 } else {
                     $values = explode(' e ', $value);
                     $union = ' e ';
                 }
                 $value = implode(';', $values);
                 $_mapperView = new $field['seeker']['mapperView']();
                 $_whereLabel = $_mapperView->getColumns()->mountWhere('id', $value);
                 $data = $_mapperView->recordset($_whereLabel);
                 /**
                  * Define os campos que serão exibidos, conforme a quantidade de labels informada
                  */
                 $countLabels = 0;
                 $maxLabels = !$field['seeker']['maxLabels'] ? 1 : $field['seeker']['maxLabels'];
                 $fields = array();
                 foreach ($field['seeker']['fields'] as $_field => $_value) {
                     array_push($fields, $_field);
                     if (++$countLabels >= $maxLabels) {
                         break;
                     }
                 }
                 /**
                  * Monta uma nova label para exibir os campos definidos acima
                  */
                 $newLabel = '';
                 while ($row = $data->getRow()) {
                     if ($newLabel) {
                         $newLabel .= $union;
                     }
                     $labels = '';
                     for ($i = 0; $i < count($fields); $i++) {
                         if ($labels) {
                             $labels .= ' - ';
                         }
                         $labels .= $row[$fields[$i]]->get();
                     }
                     $newLabel .= $labels;
                 }
                 if ($newLabel) {
                     $this->_labelFilters[$newfield]['value'] = $newLabel;
                 }
                 #echo $newLabel;die;
             }
         }
     }
     return $where;
 }