✏️ 正在编辑: Bordero.php
路径:
/srv/systems_dir/yuppiecred/application/models/Bordero.php
提示:
您可以编辑任何文件(包括二进制文件),但请注意不当修改可能导致文件损坏。
<?php class Model_Bordero { private $_id; private $_corretorId; private $_observacao; private $_status; private $_dataPrevia; private $_numCodBarras; private $_anexoBordero; private $_tipo; public function getId() { return $this->_id; } public function getObservacao() { return $this->_observacao; } public function getStatus() { return $this->_status; } public function setId($id) { $this->_id = $id; } public function setObservacao($observacao) { $this->_observacao = $observacao; } public function setStatus($status) { $this->_status = $status; } public function getDataPrevia() { return $this->_dataPrevia; } public function getNumCodBarras() { return $this->_numCodBarras; } public function setDataPrevia($dataPrevia) { $this->_dataPrevia = $dataPrevia; } public function setNumCodBarras($numCodBarras) { $this->_numCodBarras = $numCodBarras; } public function getCorretorId() { return $this->_corretorId; } public function setCorretorId($corretorId) { $this->_corretorId = $corretorId; } public function getAnexoBordero() { return $this->_anexoBordero; } public function setAnexoBordero($anexoBordero) { $this->_anexoBordero = $anexoBordero; } public function getTipo() { return $this->_tipo; } public function setTipo($tipo) { $this->_tipo = $tipo; } 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_Bordero(); $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_Bordero $bordero */ public function salvar(Model_Bordero $bordero) { $dbtable = new Model_DbTable_Bordero(); if( $bordero->getId() > 0 ){ $bordero = array_filter($bordero->_toArray()); $dbtable->update($bordero, "id = " . $bordero['id']); return $bordero['id']; } else { return $dbtable->insert($bordero->_toArray()); } } /** * 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_Bordero(); return $dbtable->fetchRow(["id = ?" => $id]); } /** * 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_Bordero; return $dbtable->delete("id = $id"); } return null; } public function getBorderos(array $fields) { $params = array(); $where = null; if( isset($fields['data_cadastro']) && !empty($fields['data_cadastro']) ){ try{ $date = new Zend_Date($fields['data_cadastro']); $cadastro = $date->get('YYYY-MM-dd'); } catch (Zend_Date_Exception $e){ return "Você deve passar uma data válida!"; } $params[] = "bordero.data_cadastro LIKE '%$cadastro%'"; } if( isset($fields['corretor_id']) && !empty($fields['corretor_id']) ){ $params[] = 'bordero.corretor_id = ' . $fields['corretor_id']; } if( isset($fields['numero']) && !empty($fields['numero']) ){ $fields['numero'] = addslashes($fields['numero']); $params[] = "bordero.id = '{$fields['numero']}'"; } if( isset($fields['num_cod_barras']) && !empty($fields['num_cod_barras']) ){ $fields['num_cod_barras'] = (int)addslashes($fields['num_cod_barras']); $params[] = "bordero.num_cod_barras LIKE '{$fields['num_cod_barras']}'"; } if( count($params) > 0 ){ $where = implode(' AND ', $params); } $dbtable = new Model_DbTable_Bordero(); $select = $dbtable->getAdapter()->select()->from(array( 'bordero' => 'tb_bordero' ), array( 'bordero.*' )); $select->joinLeft(array( 'corretor' => 'tb_corretores' ), 'bordero.corretor_id = corretor.id', array( 'nome_corretor' => 'nome', 'email_corretor' => 'email' )) ->where("bordero.excluido <> 1") ->where("bordero.tipo = 'normal'"); if( $where != null ){ $select->where($where); } return $dbtable->getAdapter()->fetchAll($select); } public function salvarAnexoBordero(array $anexos, $borderoId) { $dbBordero = new Model_DbTable_Bordero(); $paramsBordero = array(); if( count($anexos) > 0 ){ if( isset($anexos['anexo_bordero']) ){ $paramsBordero['anexo_bordero'] = $anexos['anexo_bordero']; } try { if( count($paramsBordero) > 0 ){ $result = $dbBordero->update($paramsBordero, 'id = ' . $borderoId); } return $result; } catch ( Zend_Exception $e ) { print_r($e->getMessage()); } } return false; } }
💾 保存文件
← 返回文件管理器