✏️ 正在编辑: Parceiro.php
路径:
/srv/systems_dir/yuppiecred-bkp/application/models/Parceiro.php
提示:
您可以编辑任何文件(包括二进制文件),但请注意不当修改可能导致文件损坏。
<?php class Model_Parceiro extends Model_PessoaJuridica { private $_codigoPromotora; private $_host; private $_login; private $_senha; private $_obs; //<editor-fold> public function getCodigoPromotora() { return $this->_codigoPromotora; } public function setCodigoPromotora($codigoPromotora) { $this->_codigoPromotora = $codigoPromotora; } public function getHost() { return $this->_host; } public function setHost($host) { $this->_host = $host; } 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 getObs() { return $this->_obs; } public function setObs($obs) { $this->_obs = $obs; } //</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_Parceiro(); $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(); } } $data['tipo'] = "PARCEIRO"; return $data; } /** * Insere ou altera a empresa passada por parâmetro * @param Model_Parceiro $parceiro */ public function salvar(Model_Parceiro $parceiro) { $dbtable = new Model_DbTable_Parceiro(); if( $parceiro->getId() > 0 ){ $dbtable->update($parceiro->_toArray(), "id = " . $parceiro->getId()); return $parceiro->getId(); } else { return $dbtable->insert($parceiro->_toArray()); } } /** * Exclui a empresa passada por parâmetro * @param int $id * @return int The number of rows deleted */ public function excluir($id) { if( $id > 0 ){ $dbtable = new Model_DbTable_Parceiro(); return $dbtable->delete("id = " . $id); } return null; } /** * Retorna uma lista de empresas * @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['sincronizacao']) && !empty($fields['sincronizacao']) ){ $params[] = "codigo_promotora IS NOT NULL AND codigo_promotora <> ''"; } if( count($params) > 0 ) $where = implode( " AND ", $params); $dbtable = new Model_DbTable_Parceiro(); 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_Parceiro(); return $dbtable->fetchRow("id = " . $id); } public function getByCodigo($codigo) { $dbtable = new Model_DbTable_EmpresaFtp(); return $dbtable->fetchRow("codigo_promotora = '" . $codigo . "'"); } public function getSubestabelecidos() { $dbtable = new Model_DbTable_Empresa(); $values = $dbtable->fetchAll("tipo = 'PARCEIRO'"); $subs = array(); foreach( $values as $value ){ $subs[$value['id']] = $value['codigo_promotora']; } return $subs; } }
💾 保存文件
← 返回文件管理器