✏️ 正在编辑: Prospecto.php
路径:
/srv/systems_dir/yuppiecred/application/models/Prospecto.php
提示:
您可以编辑任何文件(包括二进制文件),但请注意不当修改可能导致文件损坏。
<?php class Model_Prospecto extends Model_PessoaFisica { private $_empresaId; private $_obs; 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 __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_Prospecto(); $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_Prospecto $prospecto */ public function salvar(Model_Prospecto $prospecto) { $dbtable = new Model_DbTable_Prospecto(); if( $prospecto->getId() > 0 ){ $dbtable->update($prospecto->_toArray(), "id = " . $prospecto->getId()); return $prospecto->getId(); } else { return $dbtable->insert($prospecto->_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_Prospecto(); 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($fields = null, $order = "nome ASC") { $params = array(); $where = null; if( isset($fields['nome']) && !empty($fields['nome']) ){ $params[] = "nome LIKE '%" . $fields['nome'] . "%'"; } if( isset($fields['cpf']) && !empty($fields['cpf']) ){ $params[] = "cpf = '" . String_Refatorar::formatarCpf($fields['cpf']) . "'"; } if( $fields['tipo_registro'] > -1 ){ $params[] = "tipo_registro = " . $fields['tipo_registro']; } if( count($params) > 0 ) $where = implode( " AND ", $params); $dbtable = new Model_DbTable_Prospecto(); 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_Prospecto(); return $dbtable->fetchRow("id = " . $id); } /** * Verifica se o registro passado por parâmetro existe * @param string $cpf * @return array|null */ public function existe($cpf) { $dbtable = new Model_DbTable_Prospecto(); return $dbtable->fetchRow("cpf = '" . String_Refatorar::formatarCpf($cpf) . "'"); } }
💾 保存文件
← 返回文件管理器