✏️ 正在编辑: Cliente.php
路径:
/srv/systems_dir/yuppiecred-bkp/application/models/Cliente.php
提示:
您可以编辑任何文件(包括二进制文件),但请注意不当修改可能导致文件损坏。
<?php class Model_Cliente extends Model_PessoaFisica { private $_empresaId; private $_obs; private $_senhaContracheque; private $_anexoCpf; private $_anexoRg; private $_anexoContraCheque; private $_renda; private $_profissao; private $_anosServicos; private $_mesesServicos; private $_tipoComprovante; private $_orgaoPagador; private $_numeroDependentes; private $_compoeRenda; private $_tipoMoradia; private $_empresaBeneficiado; private $_matricula; private $_orgao; public function getEmpresaId() { return $this->_empresaId; } public function setEmpresaId($empresaId) { $this->_empresaId = $empresaId; } public function getObs() { return $this->_obs; } public function setObs($obs) { $this->_obs = $obs; } public function getSenhaContracheque() { return $this->_senhaContracheque; } public function setSenhaContracheque($senhaContracheque) { $this->_senhaContracheque = $senhaContracheque; } public function getAnexoCpf() { return $this->_anexoCpf; } public function getAnexoRg() { return $this->_anexoRg; } public function getAnexoContraCheque() { return $this->_anexoContraCheque; } public function setAnexoCpf($anexoCpf) { $this->_anexoCpf = $anexoCpf; } public function setAnexoRg($anexoRg) { $this->_anexoRg = $anexoRg; } public function setAnexoContraCheque($anexoContraCheque) { $this->_anexoContraCheque = $anexoContraCheque; } public function getRenda() { return $this->_renda; } public function setRenda($renda) { $rendaTratada = empty($renda) ? 0.0 : $renda; return $this->setFloat(trim($rendaTratada)); } public function __construct($options = null) { if( is_array($options) ){ $this->setOptions($options); } } public function getProfissao() { return $this->_profissao; } public function getAnosServicos() { return $this->_anosServicos; } public function getMesesServicos() { return $this->_mesesServicos; } public function getTipoComprovante() { return $this->_tipoComprovante; } public function getOrgaoPagador() { return $this->_orgaoPagador; } public function getNumeroDependentes() { return $this->_numeroDependentes; } public function getCompoeRenda() { return $this->_compoeRenda; } public function getTipoMoradia() { return $this->_tipoMoradia; } public function getEmpresaBeneficiado() { return $this->_empresaBeneficiado; } public function setProfissao($profissao) { $this->_profissao = $profissao; } public function setAnosServicos($anosServicos) { $this->_anosServicos = $anosServicos; } public function setMesesServicos($mesesServicos) { $this->_mesesServicos = $mesesServicos; } public function setTipoComprovante($tipoComprovante) { $this->_tipoComprovante = $tipoComprovante; } public function setOrgaoPagador($orgaoPagador) { $this->_orgaoPagador = $orgaoPagador; } public function setNumeroDependentes($numeroDependentes) { $this->_numeroDependentes = $numeroDependentes; } public function setCompoeRenda($compoeRenda) { $this->_compoeRenda = $compoeRenda; } public function setTipoMoradia($tipoMoradia) { $this->_tipoMoradia = $tipoMoradia; } public function setEmpresaBeneficiado($empresaBeneficiado) { $this->_empresaBeneficiado = $empresaBeneficiado; } public function getMatricula() { return $this->_matricula; } public function setMatricula($matricula): void { $this->_matricula = $matricula; } public function getOrgao() { return $this->_orgao; } public function setOrgao($orgao): void { $this->_orgao = $orgao; } 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_Cliente(); $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 corretor passado por parâmetro * @param Model_Cliente $cliente */ public function salvar(Model_Cliente $cliente) { $dbtable = new Model_DbTable_Cliente(); if( $cliente->getId() > 0 ){ $dbtable->update($cliente->_toArray(), "id = " . $cliente->getId()); return $cliente->getId(); } else { return $dbtable->insert($cliente->_toArray()); } } /** * Exclui o corretor 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_Cliente(); return $dbtable->delete("id = " . $id); } return null; } /** * Retorna uma lista de corretores * @param string $where * @param string $order * @param int $count * @param int $offset * @return array */ public function listar($where = null, $order = null, $count = null, $offset = null) { $dbtable = new Model_DbTable_Cliente(); 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_Cliente(); return $dbtable->fetchRow("id = " . $id); } /** * Verifica se o registro passado por parâmetro existe * @param string $cpf * @return Zend_Db_Table_Row_Abstract|null The row results per the * Zend_Db_Adapter fetch mode, or null if no row found. */ public function existe($cpf) { $dbtable = new Model_DbTable_Cliente(); return $dbtable->fetchRow("cpf = '" . String_Refatorar::formatarCpf($cpf) . "'"); } public function getContratos($fields, $order = "id ASC") { $params = array(); $where = null; if( isset($fields['cliente_id']) && $fields['cliente_id'] > 0 ){ $params[] = "cliente_id = " . $fields['cliente_id']; } if( count($params) > 0 ) $where = implode( " AND ", $params); $contrato = new Model_Contrato(); return $contrato->listar($where, $order); } public function getPropostas($fields, $order = "id ASC") { $proposta = new Model_Proposta(); return $proposta->listar($fields, $order); } public function getCpfs() { $dbtable = new Model_DbTable_Cliente(); $values = $dbtable->fetchAll(); $cpfs = array(); foreach( $values as $value ){ $cpfs[$value['id']] = $value['cpf']; } return $cpfs; } public function salvarAnexos(array $anexos, $clienteId) { $dbCliente = new Model_DbTable_Cliente(); $params = array(); if(count($anexos) > 0){ if(isset($anexos['anexo_cpf'])){ $params['anexo_cpf'] = $anexos['anexo_cpf']; } if(isset($anexos['anexo_rg'])){ $params['anexo_rg'] = $anexos['anexo_rg']; } if(isset($anexos['anexo_contra_cheque'])){ $params['anexo_contra_cheque'] = $anexos['anexo_contra_cheque']; } $result = $dbCliente->update($params, 'id = '. $clienteId); return $result; } return false; } public function getDadosUltimaProposta() : ?Zend_Db_Table_Row_Abstract { $proposta = new Model_DbTable_Proposta(); return $proposta->fetchRow(['cliente_id = ?' => $this->getId()], 'id DESC'); } public static function salvarClienteOportunidade($idClienteBase) { $dadosCliente = (new Model_DbTable_CallcenterBase())->fetchRow(['id = ?' => $idClienteBase])->toArray(); unset($dadosCliente['id']); $dadosCliente['empresa_id'] = Yuppie_Auth::getIdentity()->empresa_id; $cliente = new Model_Cliente($dadosCliente); $cliente->salvar($cliente); return $cliente->_toArray(); } public function getOrCreateByCpf() { $dadosCliente = $this->existe($this->getCpf()); $model = $this; if ($dadosCliente) { $model = new Model_Cliente(array_merge($dadosCliente->toArray(), array_filter($this->_toArray()))); } return $model->salvar($model); } }
💾 保存文件
← 返回文件管理器