✏️ 正在编辑: ProtocoloPagamentoGerente.php
路径:
/srv/systems_dir/yuppiecred-bkp/application/models/ProtocoloPagamentoGerente.php
提示:
您可以编辑任何文件(包括二进制文件),但请注意不当修改可能导致文件损坏。
<?php class Model_ProtocoloPagamentoGerente { private $_id; private $_dataBaixa; //datahora da baixa private $_dataPagamento; private $_comentario; private $_desconto; private $_acrescimo; private $_gerenteId; public function getId() { return $this->_id; } public function setId($id) { $this->_id = $id; } public function getGerenteId() { return $this->_gerenteId; } public function setGerenteId($gerenteId) { $this->_gerenteId = $gerenteId; } public function getDataBaixa() { return $this->_dataBaixa; } public function setDataBaixa($dataBaixa) { $this->_dataBaixa = $dataBaixa; } public function getDataPagamento() { return $this->_dataPagamento; } public function setDataPagamento($dataPagamento) { if( !empty($dataPagamento) ){ try { $data = new Zend_Date($dataPagamento, Zend_Date::DATES, 'pt'); $dataPagamento = $data->toString('yyyy-MM-dd'); } catch ( Zend_Date_Exception $e ) { echo $e->getMessage(); $dataPagamento = null; } } else { $dataPagamento = null; } $this->_dataPagamento = $dataPagamento; } public function getComentario() { return $this->_comentario; } public function setComentario($comentario) { $this->_comentario = $comentario; } public function getDesconto() { return $this->_desconto; } public function setDesconto($desconto) { $this->_desconto = str_replace(array( '.', ',' ), array( '', '.' ), $desconto); } public function getAcrescimo() { return $this->_acrescimo; } public function setAcrescimo($acrescimo) { $this->_acrescimo = str_replace(array( '.', ',' ), array( '', '.' ), $acrescimo); } 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_ProtocoloPagamentoGerente(); $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_ProtocoloPagamentoGerente $protocolo */ public function salvar(Model_ProtocoloPagamentoGerente $protocolo) { $dbtable = new Model_DbTable_ProtocoloPagamentoGerente(); if( $protocolo->getId() > 0 ){ $dbtable->update($protocolo->_toArray(), "id = " . $protocolo->getId()); return $protocolo->getId(); } else { return $dbtable->insert($protocolo->_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_ProtocoloPagamentoGerente(); return $dbtable->excluirProtocolo($id); } return null; } /** * Retorna uma lista * @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_ProtocoloPagamentoGerente(); 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_ProtocoloPagamentoGerente(); return $dbtable->fetchRow("id = " . $id); } public function listarProtocolos($fields = null) { $dbtable = new Model_DbTable_ProtocoloPagamentoGerente(); $selectContratos = $dbtable->getAdapter()->select() ->from(array('contratos' => 'tb_contratos'), array('contratos.id', 'base_comissao_valor', 'comissao_corretor', 'comissao_empresa')) ->joinLeft('tb_bancos', 'tb_bancos.id = contratos.banco_id', array( 'margem' )) ->where('contratos.excluido <> 1') ->group('contratos.id'); $select = $dbtable->getAdapter()->select()->from(array( 'protocolos' => 'tb_protocolo_pagamento_gerente')) ->joinInner(array( 'protocolos_itens' => 'tb_protocolo_pagamento_gerente_itens'), 'protocolos.id = protocolos_itens.protocolo_id', array()) ->joinInner(array( 'gerentes' => 'tb_gerentes'), 'protocolos.gerente_id = gerentes.id', array('valor_comissao', 'gerente' => 'nome', 'banco', 'agencia', 'conta', 'titular', 'cpf_titular', 'tipo_conta')) ->joinInner(array( 'contratos' => $selectContratos), 'protocolos_itens.contrato_id = contratos.id', array( 'total_base_comissao' => 'SUM(contratos.base_comissao_valor)', 'comissao_corretor', 'comissao_empresa', 'margem' )) ->where('protocolos.excluido <> 1') ->group(array( 'protocolos.id' )); if (!empty($fields['data_pagamento_de']) && !empty($fields['data_pagamento_a'])) { $dataDe = new Zend_Date($fields['data_pagamento_de'], 'dd/MM/yyyy'); $dataA = new Zend_Date($fields['data_pagamento_a'], 'dd/MM/yyyy'); $select->where('protocolos.data_pagamento >= ?', $dataDe->get('yyyy-MM-dd')) ->where("protocolos.data_pagamento <= ?", $dataA->get('yyyy-MM-dd')); } if( isset($fields['gerente_id']) && !empty($fields['gerente_id']) ){ $select->where("protocolos.gerente_id = " . $fields['gerente_id']); } return $dbtable->getAdapter()->fetchAll($select); } public function listarProtocolosMesmoContrato($protocoloId, $contratoId = null){ $dbtable = new Model_DbTable_ProtocoloPagamentoGerente(); $select = $dbtable->getAdapter()->select() ->from(array('protocolos' => 'tb_protocolo_pagamento_gerente_itens'), array("*")) ->where("contrato_id IN (SELECT contrato_id FROM tb_protocolo_pagamento_gerente_itens WHERE protocolo_id = $protocoloId)") ->where("protocolo_id > $protocoloId"); if($contratoId){ $select->where("contrato_id = $contratoId"); } return $dbtable->getAdapter()->fetchRow($select); } public function getContratos($protocoloId){ $dbtable = new Model_DbTable_Contrato(); return $dbtable->fetchAllDependents(array( "protocolo_pagamento_gerente_id" => $protocoloId ), 'data_pagamento_corretor ASC'); } }
💾 保存文件
← 返回文件管理器