✏️ 正在编辑: VisitaRota.php
路径:
/srv/systems_dir/yuppiecred-lidernegocios/application/models/VisitaRota.php
提示:
您可以编辑任何文件(包括二进制文件),但请注意不当修改可能导致文件损坏。
<?php class Model_VisitaRota { private $_id; private $_corretorId; private $_rotaId; private $_cidade; private $_uf; private $_resumo; private $_data; public function getId() { return $this->_id; } public function getCorretorId() { return $this->_corretorId; } public function getRotaId() { return $this->_rotaId; } public function setRotaId($rotaId) { $this->_rotaId = $rotaId; } public function setId($id) { $this->_id = $id; } public function setCorretorId($corretorId) { $this->_corretorId = $corretorId; } public function getCidade() { return $this->_cidade; } public function getUf() { return $this->_uf; } public function getResumo() { return $this->_resumo; } public function getData() { return $this->_data; } public function setCidade($cidade) { $this->_cidade = $cidade; } public function setUf($uf) { $this->_uf = $uf; } public function setResumo($resumo) { $this->_resumo = $resumo; } public function setData($data) { if( !empty($data) ){ try { $newData = new Zend_Date($data, Zend_Date::DATES, 'pt'); $data = $newData->toString('yyyy-MM-dd'); } catch ( Zend_Date_Exception $e ) { echo $e->getMessage(); $data = null; } } else { $data = null; } $this->_data = $data; } 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 exibir($id){ $dbtable = new Model_DbTable_VisitaRota(); return $dbtable->fetchRow("id = " . $id); } public function exibirVisitaByLancamento($id){ $dbtable = new Model_DbTable_VisitaRota(); $select = $dbtable->getAdapter()->select(); $select->from(array( 'visita' => 'tb_visitas_rota' ), ['id', 'cidade', 'uf', 'data', 'resumo']) ->joinLeft(array( "corretor" => "tb_corretores" ), "visita.corretor_id = corretor.id", array( 'corretor' => 'nome' )) ->where("visita.rota_id = " . $id); return $dbtable->getAdapter()->fetchAll($select); } public function salvar(Model_VisitaRota $lancamentoCorretor) { $dbtable = new Model_DbTable_VisitaRota(); $data = $lancamentoCorretor->_toArray(); return $dbtable->insert($data); } public function excluir($id) { if( $id > 0 ){ $dbtable = new Model_DbTable_VisitaRota(); $result = $dbtable->delete("id = " . $id); return $result; } return null; } public function _toArray() { $dbtable = new Model_DbTable_VisitaRota(); $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; } }
💾 保存文件
← 返回文件管理器