-
-
Save fayqLs/764112155e58529aa3ecdbfbcdae669d to your computer and use it in GitHub Desktop.
CRIAR FILTRO DOS REGISTROS PELA UNIDADE LOGADA NO DATAGRID
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
# VIA CONSTRUCT | |
$this->datagrid = new BootstrapDatagridWrapper($this->datagrid); | |
$this->filter_criteria = new TCriteria; | |
$unidade_id = TSession::getValue("userunitid"); | |
$this->filter_criteria->add(new TFilter('system_unit_id', '=', $unidade_id)); | |
# VIA ONRELOAD | |
public function onReload($param = NULL) | |
{ | |
try | |
{ | |
TTransaction::open(self::$database); | |
$repository = new TRepository(self::$activeRecord); | |
$criteria = clone $this->filter_criteria; | |
$criteria->setProperties($param); | |
$criteria->setProperty('limit', $this->limit); | |
if($filters = TSession::getValue(__CLASS__.'_filters')) | |
{ | |
foreach ($filters as $filter) | |
{ | |
$criteria->add($filter); | |
} | |
} | |
$unidade_id = TSession::getValue("userunitid"); | |
$criteria->add(new TFilter('system_unit_id', '=', $unidade_id)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment