✏️ 正在编辑: Gerente.php
路径:
/srv/systems_dir/yuppiecred/application/models/Gerente.php
提示:
您可以编辑任何文件(包括二进制文件),但请注意不当修改可能导致文件损坏。
<?php class Model_Gerente extends Model_PessoaFisica { private $_empresaId; private $_apelido; private $_banco; private $_agencia; private $_conta; private $_tipoConta; //Corrente / Poupança private $_titular; private $_cpfTitular; private $_obs; private $_login; private $_senha; private $_valorComissao; private $_exibirRanking; private $_receberEmailCopia; public function getEmpresaId() { return $this->_empresaId; } public function setEmpresaId($empresaId) { $this->_empresaId = $empresaId; } public function getApelido() { return $this->_apelido; } public function setApelido($apelido) { $this->_apelido = $apelido; } public function getBanco() { return $this->_banco; } public function setBanco($banco) { $this->_banco = $banco; } public function getAgencia() { return $this->_agencia; } public function setAgencia($agencia) { $this->_agencia = $agencia; } public function getConta() { return $this->_conta; } public function setConta($conta) { $this->_conta = $conta; } public function getTipoConta() { return $this->_tipoConta; } public function setTipoConta($tipoConta) { $this->_tipoConta = $tipoConta; } public function getTitular() { return $this->_titular; } public function setTitular($titular) { $this->_titular = $titular; } public function getCpfTitular() { return $this->_cpfTitular; } public function setCpfTitular($cpfTitular) { $this->_cpfTitular = $cpfTitular; } public function getObs() { return $this->_obs; } public function setObs($obs) { $this->_obs = $obs; } public function getLogin() { return $this->_login; } public function setLogin($login) { $this->_login = $login; } public function getSenha() { return $this->_senha; } public function setSenha($senha) { $this->_senha = $senha; } public function getValorComissao() { return $this->_valorComissao; } public function setValorComissao($valorComissao) { $this->_valorComissao = str_replace(array( '.', ',' ), array( '', '.' ), $valorComissao); } public function getExibirRanking() { return $this->_exibirRanking; } public function setExibirRanking($exibirRanking) { $this->_exibirRanking = $exibirRanking; } public function getReceberEmailCopia() { return $this->_receberEmailCopia; } public function setReceberEmailCopia($receberEmailCopia) { $this->_receberEmailCopia = $receberEmailCopia; } 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_Gerente(); $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_Gerente $gerente */ public function salvar(Model_Gerente $gerente) { $dbtable = new Model_DbTable_Gerente(); if( $gerente->getId() > 0 ){ $dbtable->update($gerente->_toArray(), "id = " . $gerente->getId()); return $gerente->getId(); } else { return $dbtable->insert($gerente->_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_Gerente(); return $dbtable->delete("id = " . $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_Gerente(); 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) { $id = (int)$id; $dbtable = new Model_DbTable_Gerente(); return $dbtable->fetchRow("id = " . $id); } public function meuDesempenhoComercial($fields = array()) { $dataNow = new Zend_Date(); $result = array(); $fields['data_emissao_de'] = $dataNow->setDay(1)->get('dd/MM/yyyy'); $fields['data_emissao_a'] = $dataNow->now()->get('dd/MM/yyyy'); // $fields['status_proposta'] = '43'; if( isset($fields['gerente_rota_id']) && !empty($fields['gerente_rota_id']) ){ $fields['gerente_id'] = $fields['gerente_rota_id']; unset($fields['gerente_rota_id']); } $contrato = new Model_Contrato(); $producaoComercial = $contrato->getDesempenhoComercial($fields); if( $producaoComercial ){ $fields['gerente'] = true; $result = $this->_prepareProducaoComercial($producaoComercial, $fields); } return $result; } public function _prepareProducaoComercial($producaoComercial = array(), $fields = array()) { $producaoGerente = array(); $modelMeta = new Model_GerenteMeta(); $metaEmpresa = Model_Empresa::getMetaEmpresa(); foreach ( $producaoComercial as $registro ) { if( !isset($producaoGerente[$registro['gerente_id']]) ){ $producaoGerente[$registro['gerente_id']] = array( 'producao_ultimo_dia_util' => 0, 'total_producao' => 0, 'liberado_atual_gerente' => 0, 'producao_media_diaria' => 0, 'projecao_final_mes' => 0, 'percentual_empresa' => 0, 'nome' => null ); } $producaoUltimoDiaUtil = $this->_producaoUltimoDiaUtil($registro); $dt = new Zend_Date(); $qtdDiasConsulta = $dt->get(Zend_Date::DAY); $qtdDiasDoMes = $dt->get(Zend_Date::MONTH_DAYS); $mediaDiaria = $registro['base_comissao_empresa_total'] / $qtdDiasConsulta; $projecaoFinalMes = $mediaDiaria * $qtdDiasDoMes; $fields['data_inicial'] = Zend_Date::now()->get('dd/MM/yyyy'); $fields['data_final'] = Zend_Date::now()->get('dd/MM/yyyy'); $fields['gerente_id'] = $registro['gerente_id']; $totalMeta = $modelMeta->getProducaoFaixaValores($fields, null, $registro); if ($producaoGerente[$registro["gerente_id"]]['liberado_atual_gerente']== 0){ $producaoGerente[$registro["gerente_id"]]['liberado_atual_gerente'] = $this->_producaoAtual($registro); } $producaoGerente[$registro["gerente_id"]]['producao_ultimo_dia_util'] = $producaoUltimoDiaUtil; $producaoGerente[$registro["gerente_id"]]['total_producao'] += $registro['base_comissao_empresa_total']; $producaoGerente[$registro["gerente_id"]]['producao_media_diaria'] += $mediaDiaria; $producaoGerente[$registro["gerente_id"]]['projecao_final_mes'] += $projecaoFinalMes; $producaoGerente[$registro['gerente_id']]['meta'] = isset($totalMeta) ? $totalMeta['total_meta'] : 0; $producaoGerente[$registro['gerente_id']]['percentual_empresa'] += @($projecaoFinalMes * 100 / $metaEmpresa); $producaoGerente[$registro['gerente_id']]['nome'] = $registro['gerente']; } $util = new Core_Util(); $util->orderArrayMulti($producaoGerente, 'projecao_final_mes', 'desc'); return $producaoGerente; } public function _producaoUltimoDiaUtil(array $registro) { $dataNow = new Zend_Date(); $diaUtil = $dataNow->get(Zend_Date::WEEKDAY_NAME); $producaoUltDiaUtil = 0; switch ( $diaUtil ) { case 'seg': $ultimaDataUtil = $dataNow->subDay(3); break; case 'dom': $ultimaDataUtil = $dataNow->subDay(2); break; default: $ultimaDataUtil = $dataNow->subDay(1); break; } $contrato = new Model_Contrato(); $fields['data_liberacao_de'] = $ultimaDataUtil->get('dd/MM/yyyy'); $fields['data_liberacao_a'] = $ultimaDataUtil->get('dd/MM/yyyy'); $fields['gerente_comercial_id'] = $registro['gerente_id']; $statusId = Model_Contrato::findByNameStatus(array( "Operação Finalizada", "Pagamento Enviado", "REALIZADO", "REALIZADA" )); $fields['status_proposta'] = $statusId; $result = $contrato->getProducaoGerenteTotalizador($fields); if( $result ){ $producaoUltDiaUtil = $result['total_liquido']; } return $producaoUltDiaUtil; } public function _producaoAtual(array $registro) { $dataNow = new Zend_Date(); $producaoTotal = 0; $contrato = new Model_Contrato(); $fields['data_liberacao_de'] = $dataNow->setDay(1)->get('dd/MM/yyyy'); $fields['data_liberacao_a'] = $dataNow->now()->get('dd/MM/yyyy'); $fields['gerente_comercial_id'] = $registro['gerente_id']; $statusId = Model_Contrato::findByNameStatus(array( "Operação Finalizada", "Pagamento Enviado" )); $fields['status_proposta'] = $statusId; $result = $contrato->getProducaoGerenteTotalizador($fields); if( $result ){ $producaoTotal = $result['total_liquido']; } return $producaoTotal; } /** * Faz o reset do campo secret_gauth * @params int $id */ public function resetGauth(int $id) { if (!$id) { return; } return (new Model_DbTable_Gerente())->update(['secret_gauth' => null], "id = " . $id); } public function saveSecretGauth(string $secret, int $gerenteId) { if (empty($secret) || !$gerenteId) { return; } return (new Model_DbTable_Gerente())->update(['secret_gauth' => $secret], "id = " . $gerenteId); } }
💾 保存文件
← 返回文件管理器