✏️ 正在编辑: Historico.php
路径:
/srv/systems_dir/yuppiecred/application/models/Historico.php
提示:
您可以编辑任何文件(包括二进制文件),但请注意不当修改可能导致文件损坏。
<?php class Model_Historico { private $_id; private $_fornecedorId; private $_tipo; private $_obs; private $_dataInicial; private $_dataFinal; 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 setTipo($tipo) { $this->_tipo = $tipo; return $this; } public function getObs() { return $this->_obs; } public function setObs($obs) { $this->_obs = $obs; return $this; } public function getDataInicial() { return $this->_dataInicial; } public function getDataFinal() { return $this->_dataFinal; } public function setDataInicial($dataInicial) { if( !empty($dataInicial) ){ try { $data = new Zend_Date($dataInicial, Zend_Date::DATES, 'pt'); $dataInicial = $data->toString('yyyy-MM-dd'); } catch ( Zend_Date_Exception $e ) { echo $e->getMessage(); $dataInicial = null; } } else { $dataInicial = null; } $this->_dataInicial = $dataInicial; } public function setDataFinal($dataFinal) { if( !empty($dataFinal) ){ try { $data = new Zend_Date($dataFinal, Zend_Date::DATES, 'pt'); $dataFinal = $data->toString('yyyy-MM-dd'); } catch ( Zend_Date_Exception $e ) { echo $e->getMessage(); $dataFinal = null; } } else { $dataFinal = null; } $this->_dataFinal = $dataFinal; } //</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_Historico(); $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_Historico $historico */ public function salvar(Model_Historico $historico) { $dbtable = new Model_DbTable_Historico(); if( $historico->getId() > 0 ){ $dbtable->update($historico->_toArray(), "id = " . $historico->getId()); return $historico->getId(); } else { return $dbtable->insert($historico->_toArray()); } } public function excluir($id) { if( $id > 0 ){ $dbtable = new Model_DbTable_Historico(); return $dbtable->delete("id = " . $id); } return null; } public function listar($where = null, $order = null, $count = null, $offset = null) { $dbtable = new Model_DbTable_Historico(); return $dbtable->fetchAll($where, $order, $count, $offset); } public function exibir($id) { $dbtable = new Model_DbTable_Historico(); return $dbtable->fetchRow("id = " . $id); } }
💾 保存文件
← 返回文件管理器