✏️ 正在编辑: Dependente.php
路径:
/srv/systems_dir/yuppiecred-lidernegocios/application/models/Dependente.php
提示:
您可以编辑任何文件(包括二进制文件),但请注意不当修改可能导致文件损坏。
<?php class Model_Dependente { private $_id; private $_fornecedorId; private $_nome; private $_tipo; private $_dataNascimento; private $_sexo; private $_obs; private $_valorPlanosaude; private $_irpf; public function getId() { return $this->_id; } public function setId($id) { $this->_id = $id; return $this; } public function getFornecedorId() { return $this->_fornecedorId; } public function setFornecedorId($fornecedorId) { $this->_fornecedorId = $fornecedorId; return $this; } public function getNome() { return $this->_nome; } public function getTipo() { return $this->_tipo; } public function getDataNascimento() { return $this->_dataNascimento; } public function setNome($nome) { $this->_nome = $nome; return $this; } public function setTipo($tipo) { $this->_tipo = $tipo; return $this; } public function setDataNascimento($dataNascimento) { if( !empty($dataNascimento) ){ try { $data = new Zend_Date($dataNascimento, Zend_Date::DATES, 'pt'); $dataNascimento = $data->toString('yyyy-MM-dd'); } catch ( Zend_Date_Exception $e ) { echo $e->getMessage(); $dataNascimento = null; } } else { $dataNascimento = null; } $this->_dataNascimento = $dataNascimento; } public function getSexo() { return $this->_sexo; } public function getObs() { return $this->_obs; } public function setSexo($sexo) { $this->_sexo = $sexo; return $this; } public function setObs($obs) { $this->_obs = $obs; return $this; } public function getValorPlanosaude() { return $this->_valorPlanosaude; } public function setValorPlanosaude($valorPlanoSaude) { $this->_valorPlanosaude = str_replace(array( '.', ',' ), array( '', '.' ), $valorPlanoSaude); return $this; } public function getIrpf() { return $this->_irpf; } public function setIrpf($irpf) { $this->_irpf = $irpf; return $this; } //</editor-fold> 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_Dependente(); $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_Dependente $dependente */ public function salvar(Model_Dependente $dependente) { $dbtable = new Model_DbTable_Dependente(); if( $dependente->getId() > 0 ){ $dbtable->update($dependente->_toArray(), "id = " . $dependente->getId()); return $dependente->getId(); } else { return $dbtable->insert($dependente->_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_Dependente(); return $dbtable->delete("id = " . $id); } return null; } public function listar($where = null, $order = null, $count = null, $offset = null) { $dbtable = new Model_DbTable_Dependente(); return $dbtable->fetchAll($where, $order, $count, $offset); } public function exibir($id) { $dbtable = new Model_DbTable_Dependente(); return $dbtable->fetchRow("id = " . $id); } public static function getDependentesIdade($funcionarioId) { $dbtable = new Model_DbTable_Dependente(); $select = $dbtable->select()->from('tb_dependentes', array('obs' => 'obs', 'fornecedor_id' => 'fornecedor_id', 'id' => 'id', 'irpf' => 'irpf', 'sexo' => 'sexo', 'tipo' => 'tipo', 'plano' => 'valor_planosaude', 'nome' => 'nome', 'idade' => "TIMESTAMPDIFF(YEAR, `data_nascimento`, CURDATE())" )) ->where("excluido <> '1'"); if( $funcionarioId != null ){ $select->where("fornecedor_id = {$funcionarioId}"); } $listaIdade = $dbtable->getAdapter()->fetchAll($select); return $listaIdade; } public static function getTotalPlanoDependentes($funcionarioId) { $dbtable = new Model_DbTable_Dependente(); $select = $dbtable->select()->from('tb_dependentes', array( 'total_plano' => 'SUM(valor_planosaude)' )) ->where("excluido <> '1'"); if( $funcionarioId != null ){ $select->where("fornecedor_id = {$funcionarioId}"); } $dados = $dbtable->getAdapter()->fetchRow($select); if( isset($dados['total_plano']) && $dados['total_plano'] != null ){ $total = $dados['total_plano']; } else { $total = 0; } return $total; } public static function getDependentesSalarioFamilia($funcionarioId) { $dbtable = new Model_DbTable_Dependente(); $select = $dbtable->select()->from('tb_dependentes', array( 'qtde' => "count(*)" )) ->where("TIMESTAMPDIFF( YEAR, `data_nascimento` , CURDATE( ) ) <=14") ->where("tipo = 'DEPENDENTE'") ->where("excluido <> '1'"); if( $funcionarioId != null ){ $select->where("fornecedor_id = {$funcionarioId}"); } $dados = $dbtable->getAdapter()->fetchRow($select); if( isset($dados['qtde']) && $dados['qtde'] != null ){ $qtde = $dados['qtde']; } else { $qtde = 0; } return $qtde; } public static function getDependentesDescontoIrpf($funcionarioId) { $dbtable = new Model_DbTable_Dependente(); $select = $dbtable->select()->from('tb_dependentes', array( 'qtde' => "count(*)" )) ->where("irpf = '1'") ->where("excluido <> '1'"); if( $funcionarioId != null ){ $select->where("fornecedor_id = {$funcionarioId}"); } $dados = $dbtable->getAdapter()->fetchRow($select); if( isset($dados['qtde']) && $dados['qtde'] != null ){ $qtde = $dados['qtde']; } else { $qtde = 0; } return $qtde; } }
💾 保存文件
← 返回文件管理器