✏️ 正在编辑: StatusResolucao.php
路径:
/srv/systems_dir/yuppiecred-bkp/application/models/StatusResolucao.php
提示:
您可以编辑任何文件(包括二进制文件),但请注意不当修改可能导致文件损坏。
<?php class Model_StatusResolucao { private $_id; private $_descricao; private $_codigo; private $_parentId; public function getId() { return $this->_id; } public function setId($id) { $this->_id = $id; } public function getDescricao() { return $this->_descricao; } public function setDescricao($descricao) { $this->_descricao = $descricao; } public function getCodigo() { return $this->_codigo; } public function setCodigo($codigo) { $this->_codigo = $codigo; } public function getParentId() { return $this->_parentId; } public function setParentId($parentId) { $this->_parentId = $parentId; } public function __construct($options = null) { if( is_array($options) ){ $this->setOptions($options); } } public function setOptions(array $options) { $methods = get_class_methods($this); foreach ( $options as $key => $value ) { $explode = explode("_", $key); $methodName = ''; foreach ( $explode as $v ) { $methodName .= ucfirst($v); } $key = $methodName != '' ? $methodName : $key; $method = 'set' . ucfirst($key); if( in_array($method, $methods) ){ $this->$method($value); } } return $this; } public function _toArray() { $dbtable = new Model_DbTable_Tipos(); $info = $dbtable->info(); $methods = get_class_methods($this); $data = array(); foreach ( $info['cols'] as $key ) { $col = $key; $explode = explode('_', $key); $methodName = ''; foreach ( $explode as $v ) { $methodName .= ucfirst($v); } $key = $methodName != '' ? $methodName : $key; $method = 'get' . ucfirst($key); if( in_array($method, $methods) ){ $data[$col] = $this->$method(); } } $data['tipo'] = 'STATUS_RESOLUCAO'; return $data; } /** * Insere ou altera o registro passado por parâmetro * @param Model_StatusResolucao $statusResolucao */ public function salvar(Model_StatusResolucao $statusResolucao) { $dbtable = new Model_DbTable_Tipos(); $data = $statusResolucao->_toArray(); if( $statusResolucao->getId() > 0 ){ $dbtable->update($data, 'id = ' . $statusResolucao->getId()); return $statusResolucao->getId(); } else { if( isset($data['descricao']) && !empty($data['descricao']) ){ $data['codigo'] = ($this->getUltimoCodigo() + 1); return $dbtable->insert($data); } } return null; } /** * Exclui o registro passado por parâmetro * @param int $id * @return int The number of rows deleted */ public function excluir($id) { if( $id > 0 ){ $dbtable = new Model_DbTable_Tipos(); return $dbtable->delete("id = " . $id); } return null; } /** * Retorna uma lista * @param string $where * @param string $order * @param int $count * @param int $offset * @return array */ public function listar($where = null, $order = 'descricao ASC', $count = null, $offset = null) { $where = $where != null ? "tipo = 'STATUS_RESOLUCAO' AND " . $where : "tipo = 'STATUS_RESOLUCAO'"; $dbtable = new Model_DbTable_Tipos(); return $dbtable->fetchAll($where, $order, $count, $offset); } /** * Retorna um fetchRow do item passado por parâmetro * @param int $id * @return Zend_Db_Table_Row_Abstract | null */ public function exibir($id) { $dbtable = new Model_DbTable_Tipos(); return $dbtable->fetchRow("id = " . $id); } /** * Verifica se o registro passado por parâmetro existe * @param string $nome * @return array|null */ public function existe($nome) { $dbtable = new Model_DbTable_Tipos(); return $dbtable->fetchRow("tipo = 'STATUS_RESOLUCAO' " . "AND descricao = '" . $nome . "'"); } /** * Retorna o último código cadastrado * @return null */ public function getUltimoCodigo() { $dbtable = new Model_DbTable_Tipos(); $dados = $dbtable->fetchRow("tipo = 'STATUS_RESOLUCAO' " . "AND codigo IS NOT NULL", 'codigo DESC'); if( $dados['codigo'] > 0 ){ return $dados['codigo']; } return null; } public function getSituacoes() { $dbtable = new Model_DbTable_Tipos(); $values = $dbtable->fetchAll("tipo = 'STATUS_RESOLUCAO'"); $situacoes = array(); foreach ( $values as $value ) { $situacoes[$value['id']] = $value['descricao']; } return $situacoes; } }
💾 保存文件
← 返回文件管理器