✏️ 正在编辑: SolicitacaoPac.php
路径:
/srv/systems_dir/yuppiecred-lidernegocios/application/models/SolicitacaoPac.php
提示:
您可以编辑任何文件(包括二进制文件),但请注意不当修改可能导致文件损坏。
<?php class Model_SolicitacaoPac { private $_id; private $_corretorId; private $_nome; private $_endereco; private $_numero; private $_cidade; private $_bairro; private $_uf; private $_cep; private $_email; private $_celular; private $_fone; private $_qtdContratos; private $_codigoPac; private $_codigoRastreamento; public function getId() { return $this->_id; } public function getCorretorId() { return $this->_corretorId; } public function getNome() { return $this->_nome; } public function getEndereco() { return $this->_endereco; } public function getNumero() { return $this->_numero; } public function getCidade() { return $this->_cidade; } public function getBairro() { return $this->_bairro; } public function getUf() { return $this->_uf; } public function getCep() { return $this->_cep; } public function getEmail() { return $this->_email; } public function getCelular() { return $this->_celular; } public function getFone() { return $this->_fone; } public function getQtdContratos() { return $this->_qtdContratos; } public function setId($id) { $this->_id = $id; } public function setCorretorId($corretorId) { $this->_corretorId = $corretorId; } public function setNome($nome) { $this->_nome = $nome; } public function setEndereco($endereco) { $this->_endereco = $endereco; } public function setNumero($numero) { $this->_numero = $numero; } public function setCidade($cidade) { $this->_cidade = $cidade; } public function setBairro($bairro) { $this->_bairro = $bairro; } public function setUf($uf) { $this->_uf = $uf; } public function setCep($cep) { $this->_cep = $cep; } public function setEmail($email) { $this->_email = $email; } public function setCelular($celular) { $this->_celular = $celular; } public function setFone($fone) { $this->_fone = $fone; } public function setQtdContratos($qtdContratos) { $this->_qtdContratos = $qtdContratos; } public function getCodigoPac() { return $this->_codigoPac; } public function setCodigoPac($codigoPac) { $this->_codigoPac = $codigoPac; } public function getCodigoRastreamento() { return $this->_codigoRastreamento; } public function setCodigoRastreamento($codigoRastreamento) { $this->_codigoRastreamento = $codigoRastreamento; } 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_SolicitacaoPac(); $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(); } } return $data; } /** * Insere ou altera o registro passado por parâmetro * @param Model_SolicitacaoPac $solicitacaoPac */ public function salvar(Model_SolicitacaoPac $solicitacaoPac) { $dbtable = new Model_DbTable_SolicitacaoPac(); if( $solicitacaoPac->getId() > 0 ){ $dbtable->update($solicitacaoPac->_toArray(), "id = " . $solicitacaoPac->getId()); return $solicitacaoPac->getId(); } else { return $dbtable->insert($solicitacaoPac->_toArray()); } } /** * 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_SolicitacaoPac(); 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($fields, $order = 'id ASC') { $params = array( "excluido <> 1" ); $where = null; if( isset($fields['nome']) && !empty($fields['nome']) ){ $params[] = "nome LIKE '%" . $fields['nome'] . "%'"; } if( isset($fields['atendido']) && $fields['atendido'] >= "0" ){ $params[] = "atendido = " . $fields['atendido']; } if( isset($fields['corretor_id']) && !empty($fields['corretor_id']) ){ $params[] = "corretor_id = " . $fields['corretor_id']; } if( count($params) > 0 ){ $where = implode(" AND ", $params); } $dbtable = new Model_DbTable_SolicitacaoPac(); return $dbtable->fetchAll($where, $order); } /** * 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_SolicitacaoPac(); return $dbtable->fetchRow("id = " . $id); } public function getChamadoBySolicitacao($id) { $dbtable = new Model_DbTable_SolicitacaoPac(); $select = $dbtable->getAdapter()->select()->from(array( 'chamados' => 'tb_chamados' ), array( '' )) ->joinInner(array( 'solicitacao' => 'tb_solicitacao_pac' ), 'solicitacao.id = chamados.solicitacao_pac_id') ->joinInner(array( 'corretores' => 'tb_corretores' ), 'corretores.id = chamados.corretor_id', array( 'corretor' => 'corretores.nome' )) ->where('chamados.excluido <> 1 AND solicitacao.excluido <> 1') ->where("solicitacao.id = {$id}"); return $dbtable->getAdapter()->fetchRow($select, '', Zend_Db::FETCH_OBJ); } }
💾 保存文件
← 返回文件管理器