✏️ 正在编辑: Tipos.php
路径:
/srv/systems_dir/yuppiecred/application/models/DbTable/Tipos.php
提示:
您可以编辑任何文件(包括二进制文件),但请注意不当修改可能导致文件损坏。
<?php class Model_DbTable_Tipos extends Core_DbTable { protected $_primary = 'id'; protected $_name = 'tb_tipos'; protected static $_viewName = 'vw_tipos'; protected $_dependentsTable = array( 'Model_DbTable_Lancamento', ); protected $_referenceMap = array( 'Parent' => array( 'columns' => array( 'parent_id' ), 'refTableClass' => 'Model_DbTable_Tipos', 'refColumns' => array( 'id' ) ), ); public static function getViewName() { return self::$_viewName; } public function insert(array $data) { $data['descricao'] = trim($data['descricao']); return parent::insert($data); } public function update(array $data, $where, $registerLog = true) { $dados = $this->fetchRow($where); if (!$dados) { return; } if ($dados->bloquear == 1) { //se for status deixa alterar apenas a flag bloqueado_alteracao if ($dados->tipo == "STATUS_PROPOSTA" && array_key_exists("bloqueado_alteracao", $data)) { $data = ['bloqueado_alteracao' => $data['bloqueado_alteracao']]; } else { throw new Core_Exception("Não é possível alterar/remover esse registro."); } } if (isset($data['descricao'])) { $data['descricao'] = trim($data['descricao']); } return parent::update($data, $where, $registerLog); } public static function statusResolucaoPorNome($nome) { $dbtable = new Model_DbTable_Tipos(); $dados = $dbtable->fetchRow("tipo = 'STATUS_RESOLUCAO' AND descricao = '" . $nome . "'"); if( $dados != null ){ return $dados->id; } } public function statusPorDescricao($descricao , $params = null) { $dbtable = new Model_DbTable_Tipos(); $select = $dbtable->getAdapter()->select()->from('tb_tipos') ->where('excluido = 0') ->where('descricao = ?', $descricao); if(isset($params['tipo']) && $params['tipo']){ $select->where('tipo = ?', $params['tipo']); } if(isset($params['desativar_cliente_callcenter']) && $params['desativar_cliente_callcenter']){ $select->where('desativar_cliente_callcenter = ?', $params['desativar_cliente_callcenter']); } return $dbtable->getAdapter()->fetchRow($select); } public static function getNaturezaComissao() { $dbtable = new Model_DbTable_Tipos(); return $dbtable->fetchAll("tipo LIKE 'NATUREZA_COMISSAO'", "descricao ASC"); } /** * Consulta sem o criterio de excluido propositalment * @return Select */ public function selectChamadosAssuntosSQL() { return $this->getAdapter()->select() ->from($this->_name) ->where("tipo = 'ASSUNTO_CHAMADOS'"); } public function selectChamadosAssuntos() { $select = $this->selectChamadosAssuntosSQL() ->where('excluido = 0'); return $this->getAdapter()->fetchAll($select); } public function selectMaiorCodigoAssunto() { $select = $this->selectChamadosAssuntosSQL() ->order('cast(codigo as unsigned integer) DESC'); $dados = $this->getAdapter()->fetchRow($select); if( $dados ){ return $dados['codigo']; } return null; } public function getAnexoContratoByDescricao(string $descricao) { return $this->fetchRow("tipo = 'ANEXO_CONTRATO' AND descricao = '$descricao'"); } public function getAnexoByTipo(int $tipo) { return $this->fetchRow(['id = ?' => $tipo]); } /** * @return array|null */ public function findCancelados(): ?array { $sql = $this->getAdapter()->select() ->from($this->_name) ->where("descricao like '%CANCEL%'") ->where("parent_id IS NULL OR parent_id = 0") ->where('excluido = 0'); return $this->getAdapter()->fetchCol($sql); } }
💾 保存文件
← 返回文件管理器