Skip to content

Instantly share code, notes, and snippets.

@fayqLs
Last active April 20, 2024 00:21
Show Gist options
  • Save fayqLs/764112155e58529aa3ecdbfbcdae669d to your computer and use it in GitHub Desktop.
Save fayqLs/764112155e58529aa3ecdbfbcdae669d to your computer and use it in GitHub Desktop.
CRIAR FILTRO DOS REGISTROS PELA UNIDADE LOGADA NO DATAGRID
<?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