✏️ 正在编辑: Rota.php
路径:
/srv/systems_dir/yuppiecred/application/models/DbTable/Rota.php
提示:
您可以编辑任何文件(包括二进制文件),但请注意不当修改可能导致文件损坏。
<?php use Modules\Comercial\Dto\RotaDto; class Model_DbTable_Rota extends Core_DbTable { protected $_name = 'tb_rotas'; protected static $_viewName = 'vw_rotas'; protected $_dependentTables = array( 'Model_DbTable_Corretor' ); protected $_referenceMap = array( 'Gerente' => array( 'columns' => array( 'gerente_id' ), 'refTableClass' => 'Model_DbTable_GerenteRota', 'refColumns' => array( 'id' ) ) ); public static function getViewName() { return self::$_viewName; } public function fetchAll($where = null, $order = null, $count = null, $offset = null) { //verifica as permissoes $ns = new Zend_Session_Namespace(); $and = ""; if( Yuppie_Auth::getIdentity()->grupo == "Supervisor" ){ $rota = new Model_Rota(); $and .= " AND gerente_id = " . Yuppie_Auth::getIdentity()->id; }elseif( Yuppie_Auth::getIdentity()->grupo == "Gerente Regional" ){ $supervisor = new Model_GerenteRota(); $supervisores = $supervisor->listagem(array("gerente_id" => Yuppie_Auth::getIdentity()->id)); if(!empty($supervisores)){ $in = array(); foreach( $supervisores as $sup ){ $in[] = $sup['id']; } if( !$in ){ return; } $and .= " AND gerente_id in (" . implode(", ", $in) . ")"; } } if( ($where instanceof Zend_Db_Table_Select ) ){ $strWhere = "excluido<>1 " . $and; foreach ( $where->getPart(Zend_Db_Table_Select::WHERE) as $w ) { $strWhere .= " AND " . $w; } $where->where($strWhere . $and); } elseif( $where != null ){ $where = $where . " AND excluido<>1 " . $and; } else { $where = "excluido<>1 " . $and; } return parent::fetchAll($where, $order, $count, $offset); } /** * @param int $rota * @return array|null */ public function findById(int $rota): ?array { $sql = $this->getAdapter()->select() ->from( ['r' => $this->_name], [ 'rota' => 'r.id', 'empresa' => 'e.id' ] ) ->join(['gr' => 'tb_gerente_rota'], 'r.gerente_id = gr.id', []) ->join(['e' => 'tb_empresas'], 'gr.empresa_id = e.id', []) ->where('r.excluido <> 1') ->where('r.id = ?', $rota); return $this->fetchOrNull($sql, false); } }
💾 保存文件
← 返回文件管理器