✏️ 正在编辑: EsteiraContrato.php
路径:
/srv/systems_dir/yuppiecred/application/models/EsteiraContrato.php
提示:
您可以编辑任何文件(包括二进制文件),但请注意不当修改可能导致文件损坏。
<?php class Model_EsteiraContrato { private $_id; private $_cpfCorretor; private $_cpfCliente; private $_nomeCliente; private $_banco; private $_valor; private $_anexo; private $_aprovado; private $_numeroProposta; private $_digitador; function get_numeroProposta() { return $this->_numeroProposta; } function set_numeroProposta($_numeroProposta) { $this->_numeroProposta = $_numeroProposta; } function get_aprovado() { return $this->_aprovado; } function set_aprovado($_aprovado) { $this->_aprovado = $_aprovado; } function get_cpfCorretor() { return $this->_cpfCorretor; } function get_cpfCliente() { return $this->_cpfCliente; } function get_nomeCliente() { return $this->_nomeCliente; } function get_banco() { return $this->_banco; } function get_valor() { return $this->_valor; } function get_anexo() { return $this->_anexo; } function set_cpfCorretor($_cpfCorretor) { $this->_cpfCorretor = $_cpfCorretor; } function set_cpfCliente($_cpfCliente) { $this->_cpfCliente = $_cpfCliente; } function set_nomeCliente($_nomeCliente) { $this->_nomeCliente = $_nomeCliente; } function set_banco($_banco) { $this->_banco = $_banco; } function set_valor($_valor) { $this->_valor = str_replace(array( '.', ',' ), array( '', '.' ), $_valor); $this->_valor = $_valor; } function set_anexo($_anexo) { $this->_anexo = $_anexo; } function get_digitador() { return $this->_digitador; } function set_digitador($_digitador) { $this->_digitador= $_digitador; } 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_Banco(); $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; } public function importarContratosEsteira(array $values) { $result = null; if (count($values) > 0) { $model = new Core_EsteiraContrato_Planilha(); $result = $model->importar($values); } return $result; } public function listar($fields = null, $order = null) { $params = array(); $where = null; if( isset($fields['numero_proposta']) && !empty($fields['numero_proposta']) ){ $params[] = "numero_proposta LIKE '%" . $fields['numero_proposta'] . "%'"; } if( isset($fields['data_cadastro']) && !empty($fields['data_cadastro']) ){ $date = new Zend_Date($fields['data_cadastro']); $cadastro = $date->get('YYYY-MM-dd'); $params[] = "tb_esteira_contratos.data_cadastro LIKE '%$cadastro%'"; } if( isset($fields['cpf_cliente']) && !empty($fields['cpf_cliente']) ){ $params[] = "cpf_cliente LIKE '%" . String_Refatorar::soNumeros($fields['cpf_cliente']) . "%'"; } if( isset($fields['cpf_corretor']) && !empty($fields['cpf_corretor']) ){ $params[] = "cpf_corretor LIKE '%" . String_Refatorar::soNumeros($fields['cpf_corretor']) . "%'"; } if( isset($fields['aprovado']) && !empty($fields['aprovado']) ){ if ($fields['aprovado'] == 1) { $params[] = "aprovado = 1"; }elseif ($fields['aprovado'] == 0) { $params[] = "aprovado = 0"; }elseif ($fields['aprovado'] == 3) { $params[] = "anexo IS NOT NULL"; } } if( isset($fields['aprovado']) && !empty($fields['aprovado']) ){ if ($fields['aprovado'] == 1) { $params[] = "aprovado = 1"; }elseif ($fields['aprovado'] == 2) { $params[] = "aprovado = 0"; }elseif ($fields['aprovado'] == 3) { $params[] = "anexo IS NOT NULL"; } } if (isset($fields['aprovado_negado']) && !empty($fields['aprovado_negado'])) { $params[] = "aprovado IS NULL AND anexo IS NULL"; } if (isset($fields['nome_corretor']) && !empty($fields['nome_corretor'])) { $params[] = "corretores.nome LIKE '%" . $fields['nome_corretor'] . "%'"; } if (isset($fields['digitador']) && !empty($fields['digitador'])) { $params[] = "digitador LIKE '%" . $fields['digitador'] . "%'"; } if( count($params) > 0 ) $where = implode(' AND ', $params); $dbtable = new Model_DbTable_EsteiraContrato(); return $dbtable->fetchAll($where, $order); } public function salvarAnexos(array $anexos) { if (count($anexos) == 0) { throw new Core_Exception('Nenhum anexo enviado'); } foreach ($anexos as $key => $anexo) { $fields = [ 'anexo' => $anexo ]; Upload::save((new Zend_File_Transfer_Adapter_Http()), $fields, 'propostas'); $key = String_Refatorar::soNumeros($key); (new Model_DbTable_EsteiraContrato())->update([ 'anexo' => $fields['anexo'] ], 'id = ' . $key); } } public function excluir($id) { if( $id > 0 ){ $dbtable = new Model_DbTable_EsteiraContrato(); $result = $dbtable->delete("id = " . $id); return $result; } return null; } }
💾 保存文件
← 返回文件管理器