Lançado Adianti Framework 7.6!
Clique aqui para saber mais
Paginação Mongodb com adianti Estou desenvolvendo um código com o mongodb. E eu não estou conseguindo fazer a paginação. Já tentei algumas pesquisas, mas não deu muito certo. Segue abaixo meu código: Mongodb versão 5 ...
LS
Paginação Mongodb com adianti  

Estou desenvolvendo um código com o mongodb. E eu não estou conseguindo fazer a paginação. Já tentei algumas pesquisas, mas não deu muito certo.

Segue abaixo meu código:

Mongodb versão 5

  1. <?php
  2. /**
  3.  * TelaCPFNomeList Listing
  4.  * @author  <your name here>
  5.  */
  6. class TelaCPFNomeList extends TPage
  7. {
  8.     protected $form;     // registration form
  9.     protected $datagrid// listing
  10.     protected $pageNavigation;
  11.     protected $formgrid;
  12.     protected $deleteButton;
  13.     protected $transformCallback;
  14.     
  15.     private $properties;
  16.     /**
  17.      * Class constructor
  18.      * Creates the page, the form and the listing
  19.      */
  20.     public function __construct()
  21.     {
  22.         parent::__construct();
  23.         try
  24.         {
  25.             // creates the form
  26.             $this->form = new BootstrapFormBuilder('form_search_TelaCPFNome');
  27.             $this->form->setFormTitle('Lista CPF E Nome MongoDB');        
  28.             // create the form fields
  29.             $nome = new TEntry('nome');
  30.             $nome->forceUpperCase(); 
  31.             $nome->setMaxLength(100);
  32.             
  33.             $cpf = new TEntry('cpf');
  34.             $cpf->setMask('999.999.999-99');
  35.             $cpf->addValidation(('Regex Format'), new TRequiredValidator);
  36.             $inativa = new TCombo('inativa');
  37.             $inativa->addItems(array( 'f' => ('Ativo'), 't' => ('Inativo')));
  38.             $nome->setSize('100%');
  39.             $cpf->setSize('100%');
  40.             $inativa->setSize('100%');
  41.             // add the fields
  42.             $row $this->form->addFields( [new TLabel('CPF''''14px''b''100%'), $cpf] );
  43.             $row->layout = ['col-sm-4','col-sm-4','col-sm-4'];
  44.             $row $this->form->addFields( [new TLabel('Nome''''14px''b''100%'),$nome] );
  45.             $row->layout = ['col-sm-8''col-sm-4'];
  46.             $row $this->form->addFields( [new TLabel('Situação''''14px''b''100%'),$inativa] );
  47.             $row->layout = ['col-sm-4''col-sm-4''col-sm-4'];
  48.       
  49.             // keep the form filled during navigation with session data
  50.             $this->form->setDataTSession::getValue(__CLASS__.'_filter_data') );
  51.             
  52.              // add the search form actions
  53.             $this->form->addAction(_t('New'),  new TAction(array('TelaCPFNomeForm''onEdit')), 'fa:plus')->class 'btn btn-sm btn-success';
  54.             $this->form->addAction(_t('Find'), new TAction(array($this'onSearch')), 'fa:search')->class 'btn btn-sm btn-primary';
  55.             $this->form->addAction(_t('Clear'),  new TAction(array($this'onClear')), 'fa:eraser')->class 'btn btn-sm btn-warning';
  56.             
  57.             // creates a Datagrid
  58.             $this->datagrid = new BootstrapDatagridWrapper(new TDataGrid);
  59.             $this->datagrid->datatable 'true';
  60.             $this->datagrid->style 'width: 100%';
  61.             $this->datagrid->setHeight(320);
  62.             
  63.             // creates the datagrid columns
  64.             //$column_id = new TDataGridColumn('id', 'ID', 'center');
  65.             $column_cpf = new TDataGridColumn('cpf''CPF''center');
  66.             $column_nome = new TDataGridColumn('nome''Nome''center');
  67.             $column_inativa = new TDataGridColumn('inativa'_t('Status'), 'center');
  68.             $column_inativa->setTransformer(function($value$object$row) {
  69.                 $class = ($value==false) ? 'success' 'danger';
  70.                 $label = ($value==false) ? 'Ativo' 'Inativo';
  71.                 $div = new TElement('span');
  72.                 $div->class="label label-{$class}";
  73.                 $div->style="text-shadow:none; font-size:12px; font-weight:lighter";
  74.                 $div->add($label);
  75.                 return $div;
  76.             });
  77.             // add the columns to the DataGrid
  78.             //$this->datagrid->addColumn($column_id);
  79.             $this->datagrid->addColumn($column_cpf);
  80.             $this->datagrid->addColumn($column_nome);
  81.             $this->datagrid->addColumn($column_inativa);
  82.             $this->datagrid->disableDefaultClick();
  83.             // create EDIT action
  84.             $action_edit = new TDataGridAction(array('TelaCPFNomeForm''onEdit'));
  85.             $action_edit->setButtonClass('btn btn-default');
  86.             $action_edit->setLabel(_t('Edit'));
  87.             $action_edit->setImage('far:edit blue fa-lg');
  88.             $action_edit->setField('id');
  89.             $this->datagrid->addAction($action_edit);
  90.             
  91.             // create DELETE action
  92.             $action_del = new TDataGridAction(array($this'onDelete'));
  93.             $action_del->setButtonClass('btn btn-default');
  94.             $action_del->setLabel(_t('Delete'));
  95.             $action_del->setImage('fa:trash red fa-lg');
  96.             $action_del->setField('id');
  97.             $this->datagrid->addAction($action_del);
  98.                     
  99.             // create the datagrid model
  100.             $this->datagrid->createModel();
  101.             
  102.             // create the page navigation
  103.             $this->pageNavigation = new TPageNavigation;
  104.             $this->pageNavigation->enableCounters();
  105.             $this->pageNavigation->setAction(new TAction(array($this'onReload')));
  106.             $this->pageNavigation->setWidth($this->datagrid->getWidth());
  107.             
  108.             $panel = new TPanelGroup;
  109.             $panel->add($this->datagrid);
  110.             $panel->addFooter($this->pageNavigation);
  111.             // vertical box container
  112.             $container = new TVBox;
  113.             $container->style 'width: 100%';
  114.             $container->add(new TXMLBreadCrumb('menu.xml''TelaCPFNomeList'));
  115.             $container->add($this->form);
  116.             $container->add($panel);
  117.             
  118.             parent::add($container);
  119.         }
  120.         catch (Exception $e)
  121.         {
  122.             new TMessage('error'$e->getMessage());    
  123.         }
  124.     }
  125.     
  126.     function onClear()
  127.     {
  128.         // get the search form data
  129.         $data $this->form->getData();
  130.         TSession::setValue(__CLASS__.'_filter_data'NULL);
  131.         TSession::setValue(__CLASS__.'_filters'NULL);
  132.         
  133.         $data->cpf   '';
  134.         $data->nome   '';
  135.         $data->inativa '';
  136.         
  137.         // fill the form with data again
  138.         $this->form->setData($data);
  139.         
  140.         $param = array();
  141.         $param['offset']     = 0;
  142.         $param['first_page'] = 1;
  143.         $this->onReload($param);
  144.     }
  145.     
  146.     /**
  147.      * Register the filter in the session
  148.      */
  149.     public function onSearch($param NULL)
  150.     {
  151.         // get the search form data
  152.         $data $this->form->getData();
  153.         
  154.         // clear session filters
  155.         TSession::setValue(__CLASS__.'_filter_data'NULL);
  156.         TSession::setValue(__CLASS__.'_filters'NULL);
  157.         
  158.         $filters = array();
  159.         if ((isset($data->cpf) AND ($data->cpf != NULL))   ||
  160.             (isset($data->nome) AND ($data->nome != NULL)) ||
  161.             (isset($data->inativa)  AND ($data->inativa != NULL)))
  162.         {
  163.             $data->nome mb_strtoupper($data->nome'UTF-8');
  164.             $cpf json_decode(json_encode($data->cpftrue), true);                    
  165.             $nome json_decode(json_encode($data->nometrue), true);                     
  166.             $inativa json_decode(json_encode($data->inativatrue), true);  
  167.             $cpf = new MongoDB\BSON\Regex("^$cpf.*$"'i');
  168.             $nome = new MongoDB\BSON\Regex("^$nome.*$"'i');
  169.             $filters = array("cpf" =>  $cpf"nome" => $nome"inativa" => boolval($inativa));
  170.         }
  171.           
  172.         // fill the form with data again
  173.         $this->form->setData($data);
  174.         TSession::setValue(__CLASS__.'_filter_data'$data);
  175.         TSession::setValue(__CLASS__.'_filters'$filters);
  176.         
  177.         // keep the search data in the session
  178.         TSession::setValue('TelaCPFNome_filter_data'$data);
  179.         
  180.         $param=array();
  181.         $param['offset']    =0;
  182.         $param['first_page']=1;
  183.         $this->onReload($param);
  184.     }
  185.     
  186.     /**
  187.      * Load the datagrid with data
  188.      */
  189.     public function onReload($param NULL)
  190.     {
  191.         try
  192.         {
  193.             // This path should point to Composer's autoloader
  194.             require '../../../../vendor/autoload.php';
  195.             
  196.             // default order
  197.             $limit 10;
  198.             $offset 0;
  199.            
  200.             // default order
  201.             if (empty($param['order']))
  202.             {
  203.                 $param['order'] = '_id';
  204.                 $param['direction'] = 'desc';
  205.             }
  206.             $param['limit'] = isset($limit) ? $limit NULL;
  207.             $limit $param['limit'];
  208.             if (isset($param['offset']) AND $param['offset'])
  209.             {
  210.                 $offset = (int) $param['offset'];
  211.             }
  212.             /*
  213.                 if ($param['page']=="" || $param['page']=="1")
  214.                 {
  215.                     $param['first_page']=1;
  216.                 }
  217.                 else
  218.                 {
  219.                     $param['first_page']=($param['page']*10)-10;
  220.                 }
  221.                 $options=[
  222.                     'limit' => $limit,
  223.                     'skip' => $param['first_page'],
  224.                     'sort' => ["_id" => -1],
  225.                 ];
  226.             */
  227.             
  228.             $options = [
  229.                 'skip'=>  $offset,
  230.                 'limit'=> $limit,
  231.                 'sort' => ["_id" => -1],
  232.             ];
  233.             $filters = [];
  234.             if(TSession::getValue(__CLASS__.'_filters'))
  235.             {
  236.                 $filters json_decode(json_encode(TSession::getValue(__CLASS__.'_filters'), true), true);
  237.             }
  238.             echo "<pre>";
  239.             print_r($param);
  240.             echo "</pre>";
  241.             $this->datagrid->clear();
  242.             $manager = new MongoDB\Driver\Manager('mongodb://localhost:27017');
  243.             $readPreference = new MongoDB\Driver\ReadPreference(MongoDB\Driver\ReadPreference::RP_PRIMARY);
  244.             $query = new MongoDB\Driver\Query($filters$options);   
  245.             $cursor $manager->executeQuery('bancoTeste.cadastro_cpf_nome'$query$readPreference);
  246.             
  247.             $objects json_decode(json_encode($cursor->toArray(),true), true);
  248.             if ($objects)
  249.             {
  250.                 foreach ($objects as $key => $object
  251.                 {
  252.                     $newObject = new stdClass;
  253.                     $newObject->id $object['_id']['$oid'];
  254.                     $newObject->cpf $object['cpf'];
  255.                     $newObject->nome $object['nome'];
  256.                     $newObject->inativa $object['inativa'];
  257.                 
  258.                     // add the object inside the datagrid
  259.                     $this->datagrid->addItem($newObject);
  260.                 }
  261.             }
  262.             
  263.             if (is_callable($this->transformCallback))
  264.             {
  265.                 call_user_func($this->transformCallback$objects$param);
  266.             }
  267.             
  268.             $param['limit']  = NULL;
  269.             $param['order']  = NULL;
  270.             $param['offset'] = NULL;
  271.             $param['group']  = NULL;
  272.             $count count($objects);
  273.             
  274.             $this->pageNavigation->setCount($count); // count of records
  275.             $this->pageNavigation->setProperties($param); // order, page
  276.             $this->pageNavigation->setLimit($limit); // limit
  277.             
  278.             $this->loaded true;   
  279.         }
  280.         catch (Exception $e// in case of exception
  281.         {
  282.             // shows the exception error message
  283.             new TMessage('error'$e->getMessage());
  284.             // undo all pending operations
  285.             TTransaction::rollback();
  286.         }
  287.     }
  288.     
  289.     /**
  290.      * Ask before deletion
  291.      */
  292.     public function onDelete($param)
  293.     {
  294.         // define the delete action
  295.         $action = new TAction(array($this'Delete'));
  296.         $action->setParameters($param); // pass the key parameter ahead
  297.         
  298.         // shows a dialog to the user
  299.         new TQuestion(AdiantiCoreTranslator::translate('Do you really want to delete ?'), $action);
  300.     }
  301.     
  302.     /**
  303.      * Delete a record
  304.      */
  305.     public function Delete($param)
  306.     {
  307.         try
  308.         {
  309.             $id $param['id']; // get the parameter $key
  310.             // This path should point to Composer's autoloader
  311.             require '../../../../vendor/autoload.php';
  312.             //connect to mongodb
  313.             $conexaoMongo = new MongoDB\Client('mongodb://localhost:27017');
  314.             $banco $conexaoMongo->bancoTeste;
  315.             $cadastro $banco->cadastro_cpf_nome;
  316.             $cadastro->deleteOne( array( '_id' => new MongoDB\BSON\ObjectId ($id)) );
  317.             $this->onReload$param ); // reload the listing
  318.             new TMessage('info'AdiantiCoreTranslator::translate('Record deleted')); // success message
  319.             
  320.             TApplication::loadPage('TelaCPFNomeList''');
  321.         }
  322.         catch (Exception $e// in case of exception
  323.         {
  324.             new TMessage('error'$e->getMessage()); // shows the exception error message
  325.             TTransaction::rollback(); // undo all pending operations
  326.         }
  327.     }
  328.     
  329.     public function show()
  330.     {
  331.         // check if the datagrid is already loaded
  332.         if (!$this->loaded AND (!isset($_GET['method']) OR !(in_array($_GET['method'],  array('onReload''onSearch''onClear')))) )
  333.         {
  334.             if (func_num_args() > 0)
  335.             {
  336.                 $this->onReloadfunc_get_arg(0) );
  337.             }
  338.             else
  339.             {
  340.                 $this->onReload();
  341.             }
  342.         }
  343.         parent::show();
  344.     }
  345.     function showMessage()
  346.     {
  347.         new TMessage('info'AdiantiCoreTranslator::translate('Record saved'));
  348.         $this->onReload();
  349.     }
  350. }
  351.  ?>


  1. <?php
  2. /**
  3.  * TelaCPFNomeForm Form
  4.  * @author  <your name here>
  5.  */
  6. class TelaCPFNomeForm extends TPage
  7. {
  8.     protected $form// form
  9.     
  10.     /**
  11.      * Form constructor
  12.      * @param $param Request
  13.      */
  14.     public function __construct()
  15.     {
  16.         parent::__construct();
  17.         try
  18.         {            
  19.             // creates the form
  20.             $this->form = new BootstrapFormBuilder('form_TelaCPFNome');
  21.             
  22.             // define the form title
  23.             $this->form->setFormTitle('Cadastro CPF E Nome MongoDB');
  24.             // create the form fields
  25.             $id = new THidden('id');
  26.             $id->setEditable(false);
  27.             $this->form->addFields( [$id]);
  28.             $nome = new TEntry('nome');
  29.             $nome->forceUpperCase(); 
  30.             $nome->setMaxLength(100);
  31.             $nome->addValidation(('Name'), new TRequiredValidator);
  32.             $cpf = new TEntry('cpf');
  33.             $cpf->setMask('999.999.999-99');
  34.             $cpf->addValidation(('Regex Format'), new TRequiredValidator);
  35.             //descrever o local físico do arquivo
  36.             $inativa = new TRadioGroup('inativa');
  37.             $inativa->setLayout('horizontal');
  38.             $inativa->setUseButton();
  39.             $inativa->addItems(['f' => 'Ativo''t' => 'Inativo']);
  40.             $nome->setSize('100%');
  41.             $cpf->setSize('100%');
  42.             $inativa->setSize('100%');
  43.             // add the fields
  44.             $row $this->form->addFields( [new TLabel('CPF''''14px''b''100%'), $cpf] );
  45.             $row->layout = ['col-sm-4','col-sm-4','col-sm-4'];
  46.             $row $this->form->addFields( [new TLabel('Nome''''14px''b''100%'), $nome] );
  47.             $row->layout = ['col-sm-9','col-sm-3'];
  48.             $row $this->form->addFields( [new TLabel('Situação''''14px''b''100%'), $inativa] );
  49.             $row->layout = ['col-sm-4','col-sm-4','col-sm-4'];
  50.             
  51.             // create the form actions
  52.             $this->form->addAction(_t('Save'), new TAction(array($this'onSave')), 'fa:save')->class 'btn btn-sm btn-success';
  53.             $this->form->addAction(_t('Back'),new TAction(array('TelaCPFNomeList''onReload')),'fa:arrow-circle-left')->class 'btn btn-sm btn-info';
  54.             // vertical box container
  55.             $container = new TVBox;
  56.             $container->style 'width: 100%';
  57.             $container->add(new TXMLBreadCrumb('menu.xml''TelaCPFNomeList'));
  58.             $container->add($this->form);
  59.             
  60.             parent::add($container);
  61.         }
  62.         catch (Exception $e)
  63.         {
  64.             new TMessage('error'$e->getMessage());
  65.         }
  66.     }
  67.     /**
  68.      * Save form data
  69.      * @param $param Request
  70.      */
  71.     public function onSave()
  72.     {
  73.         require '../../../../vendor/autoload.php';
  74.         try
  75.         {
  76.             //connect to mongodb
  77.             $conexaoMongo = new MongoDB\Client('mongodb://localhost:27017');
  78.            
  79.             $data $this->form->getData(); // get form data as array
  80.             $this->form->validate(); // validate form data
  81.             $banco $conexaoMongo->bancoTeste;
  82.             $cadastro $banco->cadastro_cpf_nome;
  83.             if ($cadastro instanceof \MongoDB\Collection)
  84.             {
  85.                 $valorInativa $data->inativa == 'f' FALSE TRUE
  86.                 $nome mb_strtoupper($data->nome'UTF-8');
  87.                 $documento = ['_id' => new MongoDB\BSON\ObjectId(), "cpf" => $data->cpf"nome" => $nome"inativa" => $valorInativa"data_cadastro" => new MongoDB\BSON\UTCDateTime()];
  88.                 if (strlen(trim(TSession::getValue('mongoID')))>0)
  89.                 {
  90.                     //require('mongodb://localhost:27017').MongoDB\BSON\ObjectId;
  91.                     $id = new MongoDB\BSON\ObjectId(TSession::getValue('mongoID')); 
  92.                    
  93.                     $cadastro->replaceOne(['_id' => $id], ['_id' => $id"cpf" => $data->cpf"nome" => $nome"inativa" => $valorInativa"data_cadastro" => new MongoDB\BSON\UTCDateTime()], ['upsert' => true]);
  94.                 }
  95.                 else
  96.                 {
  97.                     $cadastro->insertOne($documento);
  98.                 }
  99.                 TApplication::loadPage('TelaCPFNomeList''showMessage');           
  100.             } 
  101.         }
  102.         catch (Exception $e)
  103.         {
  104.             new TMessage('error'$e->getMessage()); // shows the exception error message
  105.             TTransaction::rollback(); // undo all pending operations
  106.         }
  107.     }
  108.     /**
  109.      * Load object to form data
  110.      * @param $param Request
  111.      */
  112.     public function onEdit$param )
  113.     {   
  114.         TSession::setValue('mongoID'NULL);
  115.         try
  116.         {
  117.             if (isset($param['id']))
  118.             {
  119.                 // This path should point to Composer's autoloader
  120.                 require '../../../../vendor/autoload.php';
  121.                 //connect to mongodb
  122.                 $conexaoMongo = new MongoDB\Client('mongodb://localhost:27017');
  123.                 $id $param['id'];  
  124.                 TSession::setValue('mongoID'$id);
  125.                 
  126.                 $banco $conexaoMongo->bancoTeste;
  127.                 $cadastro $banco->cadastro_cpf_nome;
  128.                 $data =  $cadastro->findOne(array('_id' => new  MongoDB\BSON\ObjectID($id)));
  129.                 $data->inativa = !$data->inativa 'f' 't';
  130.                 $this->form->setData($data); // fill the form
  131.             }
  132.         }
  133.         catch (Exception $e// in case of exception
  134.         {
  135.             new TMessage('error'$e->getMessage()); // shows the exception error message
  136.             TTransaction::rollback(); // undo all pending operations
  137.         }
  138.     }
  139. }
  140. ?>

Pacotão Dominando o Adianti Framework 7
O material mais completo de treinamento do Framework.
Curso em vídeo aulas + Livro completo + Códigos fontes do projeto ERPHouse.
Conteúdo Atualizado! Versão 7.4


Dominando o Adianti 7 Quero me inscrever agora!

Comentários (7)


RJ

Eu ainda não juntei o Adianti com MongoDB, porém já fiz alguns trabalhos com FormDin (um framework primo do Adianti) com MongoDB. O que vou te falar é apenas da paginação do MongoBD, depois vc terá juntar com o grid do Adianti para pegar o numero da pagina

Vc vai usar o parâmetros skip e limit

https://www.mongodb.com/docs/php-library/v1.12/reference/method/MongoDBCollectio

Editado 04/07/2022 (há 1 ano) - Ver alterações
LS

Eu já estou usando o limit e o skip meu caro. Vou olhar o seu link
LS

Você viu meu código? pode postar algum seu com esse outro framework?
PD

Lucas,

Dê um var_dump no $options, pra ver se ele está montando do jeito certo antes de ser passado para a API.

Outra dica, não deixe os dados de conexão direto no código ('mongodb://localhost:27017')
Prefira manter em arquivo de configuração em app/config, seja em .INI ou .PHP (melhor)

Ex...:

app/config/mongo.php
  1. <?php
  2. return [
  3.     'host' => '127.0.0.1'
  4. ]
  5. ?>


E no código (controller):
  1. <?php
  2. $ini = require 'app/config/mongo.php';
  3. ?>


Att,
LS

certo Pablo.

aqui o print da variável $param

Array
(
[class] => TelaCPFNomeList
[method] => onReload
[offset] => 0
[limit] => 10
[direction] => desc
[page] => 1
[first_page] => 1
[order] => _id
)

eu comparei com outros exemplos com o banco sendo relacional e retornam a mesma coisa.
LS

Bom dia alguém encontrou uma solução para o problema? Ainda não consegui resolver.
LS

Bom dia pessoal.

Estava sem tempo para postar. Mas já consegui resolver o problema.

No onReload eu chamei eu rodo uma segunda query para contar os registros. Fiz algumas poucas alterações também.

  1. <?php
  2. /**
  3.  * TelaCPFNomeForm Form
  4.  * @author  <your name here>
  5.  */
  6. class TelaCPFNomeForm extends TPage
  7. {
  8.     protected $form// form
  9.     private   $ini;
  10.     /**
  11.      * Form constructor
  12.      * @param $param Request
  13.      */
  14.     public function __construct()
  15.     {
  16.         $this->ini = require 'app/config/mongo.php';
  17.         parent::__construct();
  18.         try
  19.         {            
  20.             // creates the form
  21.             $this->form = new BootstrapFormBuilder('form_TelaCPFNome');
  22.             
  23.             // define the form title
  24.             $this->form->setFormTitle('Cadastro CPF E Nome MongoDB');
  25.             // create the form fields
  26.             $id = new THidden('id');
  27.             $id->setEditable(false);
  28.             $this->form->addFields( [$id]);
  29.             $nome = new TEntry('nome');
  30.             $nome->forceUpperCase(); 
  31.             $nome->setMaxLength(100);
  32.             $nome->addValidation(('Name'), new TRequiredValidator);
  33.             $cpf = new TEntry('cpf');
  34.             $cpf->setMask('999.999.999-99');
  35.             $cpf->addValidation(('Regex Format'), new TRequiredValidator);
  36.             //descrever o local físico do arquivo
  37.             $inativa = new TRadioGroup('inativa');
  38.             $inativa->setLayout('horizontal');
  39.             $inativa->setUseButton();
  40.             $inativa->addItems(['f' => 'Ativo''t' => 'Inativo']);
  41.             $nome->setSize('100%');
  42.             $cpf->setSize('100%');
  43.             $inativa->setSize('100%');
  44.             // add the fields
  45.             $row $this->form->addFields( [new TLabel('CPF''''14px''b''100%'), $cpf] );
  46.             $row->layout = ['col-sm-4','col-sm-4','col-sm-4'];
  47.             $row $this->form->addFields( [new TLabel('Nome''''14px''b''100%'), $nome] );
  48.             $row->layout = ['col-sm-9','col-sm-3'];
  49.             $row $this->form->addFields( [new TLabel('Situação''''14px''b''100%'), $inativa] );
  50.             $row->layout = ['col-sm-4','col-sm-4','col-sm-4'];
  51.             
  52.             // create the form actions
  53.             $this->form->addAction(_t('Save'), new TAction(array($this'onSave')), 'fa:save')->class 'btn btn-sm btn-success';
  54.             $this->form->addAction(_t('Back'),new TAction(array('TelaCPFNomeList''onReload')),'fa:arrow-circle-left')->class 'btn btn-sm btn-info';
  55.             // vertical box container
  56.             $container = new TVBox;
  57.             $container->style 'width: 100%';
  58.             $container->add(new TXMLBreadCrumb('menu.xml''TelaCPFNomeList'));
  59.             $container->add($this->form);
  60.             
  61.             parent::add($container);
  62.         }
  63.         catch (Exception $e)
  64.         {
  65.             new TMessage('error'$e->getMessage());
  66.         }
  67.     }
  68.     /**
  69.      * Save form data
  70.      * @param $param Request
  71.      */
  72.     public function onSave()
  73.     {
  74.         // This path should point to Composer's autoloader
  75.         //require_once __DIR__ . '/vendor/autoload.php';
  76.         //require '../../../../vendor/autoload.php';
  77.         try
  78.         {
  79.             //connect to mongodb
  80.             $conexaoMongo = new MongoDB\Client($this->ini['host']);
  81.            
  82.             $data $this->form->getData(); // get form data as array
  83.             $this->form->validate(); // validate form data
  84.             $banco $conexaoMongo->bancoTeste;
  85.             $cadastro $banco->cadastro_cpf_nome;
  86.             if ($cadastro instanceof \MongoDB\Collection)
  87.             {
  88.                 $valorInativa $data->inativa == 'f' FALSE TRUE
  89.                 $nome mb_strtoupper($data->nome'UTF-8');
  90.                 /*
  91.                     https://imasters.com.br/back-end/mecanismos-de-busca-de-php-com-mongodb
  92.                     inclui tags para tornar a pesquisa mais rápida
  93.                     The simplest way is, by using explode:
  94.                     $parts = explode(" ", $name);
  95.                     After you have the parts, pop the last one as $lastname:
  96.                     $lastname = array_pop($parts);
  97.                     Finally, implode back the rest of the array as your $firstname:
  98.                     $firstname = implode(" ", $parts);
  99.                     https://www.luiztools.com.br/post/como-criar-um-mecanismo-de-busca/
  100.                     https://stackoverflow.com/questions/13637145/split-text-string-into-first-and-last-name-in-php
  101.                     $parts = explode(" ", $nome);
  102.                     $firstname = implode(" ", $parts);
  103.                     $lastname = array_pop($parts);
  104.                     $documento = ['_id' => new MongoDB\BSON\ObjectId(), "cpf" => $data->cpf, "nome" => $nome, "inativa" => $valorInativa, "tags":[$data->cpf, $firstname, $lastname]];
  105.                 */
  106.                 $documento = ['_id' => new MongoDB\BSON\ObjectId(), "cpf" => $data->cpf"nome" => $nome"inativa" => $valorInativa"data_cadastro" => new MongoDB\BSON\UTCDateTime()];
  107.                 if (strlen(trim($data->id))>0)
  108.                 {
  109.                     //require($this->ini['host']).MongoDB\BSON\ObjectId;
  110.                     $id = new MongoDB\BSON\ObjectId($data->id); 
  111.                    
  112.                     /*
  113.                         replaceOne replace the entire document, while updateOne allows for update an specific field of the document 
  114.                         
  115.                         replaceOne() replaces the first matching document in the collection that matches the filter, using the replacement document.
  116.                         upsert
  117.                         If upsert: true and no documents match the filter, db.collection.replaceOne() creates a new document based on the replacement document.
  118.                         db.collection.replaceOne(
  119.                            <filter>,
  120.                            <replacement>,
  121.                            {
  122.                              upsert: <boolean>,
  123.                              writeConcern: <document>,
  124.                              collation: <document>,
  125.                              hint: <document|string>                   
  126.                            }
  127.                         db.collection.replaceOne() with upsert: true can be run on an existing collection or a non-existing collection. If run on a non-existing collection, the operation creates the collection.
  128.                     */
  129.                     $cadastro->replaceOne(['_id' => $id], ['_id' => $id"cpf" => $data->cpf"nome" => $nome"inativa" => $valorInativa"data_cadastro" => new MongoDB\BSON\UTCDateTime()], ['upsert' => true]);
  130.                 }
  131.                 else
  132.                 {
  133.                     $cadastro->insertOne($documento);
  134.                 }
  135.                 TApplication::loadPage('TelaCPFNomeList''showMessage');           
  136.             } 
  137.         }
  138.         catch (Exception $e)
  139.         {
  140.             new TMessage('error'$e->getMessage()); // shows the exception error message
  141.             TTransaction::rollback(); // undo all pending operations
  142.         }
  143.     }
  144.     /**
  145.      * Load object to form data
  146.      * @param $param Request
  147.      */
  148.     public function onEdit$param )
  149.     {   
  150.         //TSession::setValue('mongoID', NULL);
  151.         try
  152.         {
  153.             if (isset($param['id']))
  154.             {
  155.                 // This path should point to Composer's autoloader
  156.                 //require '../../../../vendor/autoload.php';
  157.                 //connect to mongodb
  158.                 $conexaoMongo = new MongoDB\Client($this->ini['host']);
  159.                 $id $param['id'];  
  160.                 //TSession::setValue('mongoID', $id);
  161.                 
  162.                 $banco $conexaoMongo->bancoTeste;
  163.                 $cadastro $banco->cadastro_cpf_nome;
  164.                 $data =  $cadastro->findOne(array('_id' => new  MongoDB\BSON\ObjectID($id)));
  165.                 $data->id $id;
  166.                 $data->inativa = !$data->inativa 'f' 't';
  167.                 $this->form->setData($data); // fill the form
  168.             }
  169.         }
  170.         catch (Exception $e// in case of exception
  171.         {
  172.             new TMessage('error'$e->getMessage()); // shows the exception error message
  173.             TTransaction::rollback(); // undo all pending operations
  174.         }
  175.     }
  176. }
  177. ?>


  1. <?php
  2. /**
  3.  * TelaCPFNomeList Listing
  4.  * @author  <your name here>
  5.  */
  6. class TelaCPFNomeList extends TPage
  7. {
  8.     protected $form;     // registration form
  9.     protected $datagrid// listing
  10.     protected $pageNavigation;
  11.     protected $formgrid;
  12.     protected $deleteButton;
  13.     protected $transformCallback;
  14.     private   $ini;
  15.     private   $properties;
  16.     /**
  17.      * Class constructor
  18.      * Creates the page, the form and the listing
  19.      */
  20.     public function __construct()
  21.     {
  22.         $this->ini = require 'app/config/mongo.php';
  23.         parent::__construct();
  24.         try
  25.         {
  26.             // creates the form
  27.             $this->form = new BootstrapFormBuilder('form_search_TelaCPFNome');
  28.             $this->form->setFormTitle('Lista CPF E Nome MongoDB');   
  29.             $id = new TEntry('id');
  30.             
  31.             // create the form fields
  32.             $nome = new TEntry('nome');
  33.             $nome->forceUpperCase(); 
  34.             $nome->setMaxLength(100);
  35.             
  36.             $cpf = new TEntry('cpf');
  37.             $cpf->setMask('999.999.999-99');
  38.             $cpf->addValidation(('Regex Format'), new TRequiredValidator);
  39.             $inativa = new TCombo('inativa');
  40.             $inativa->addItems(array( => ('Ativo'), => ('Inativo')));
  41.             $id->setSize('100%');
  42.             $nome->setSize('100%');
  43.             $cpf->setSize('100%');
  44.             $inativa->setSize('100%');
  45.             // add the fields
  46.             $row $this->form->addFields( [new TLabel('ID''''14px''b''100%'), $id] );
  47.             $row->layout = ['col-sm-4','col-sm-4','col-sm-4'];
  48.             $row $this->form->addFields( [new TLabel('CPF''''14px''b''100%'), $cpf] );
  49.             $row->layout = ['col-sm-4','col-sm-4','col-sm-4'];
  50.             $row $this->form->addFields( [new TLabel('Nome''''14px''b''100%'),$nome] );
  51.             $row->layout = ['col-sm-8''col-sm-4'];
  52.             $row $this->form->addFields( [new TLabel('Situação''''14px''b''100%'),$inativa] );
  53.             $row->layout = ['col-sm-4''col-sm-4''col-sm-4'];
  54.       
  55.             // keep the form filled during navigation with session data
  56.             $this->form->setDataTSession::getValue(__CLASS__.'_filter_data') );
  57.             
  58.              // add the search form actions
  59.             $this->form->addAction(_t('New'),  new TAction(array('TelaCPFNomeForm''onEdit')), 'fa:plus')->class 'btn btn-sm btn-success';
  60.             $this->form->addAction(_t('Find'), new TAction(array($this'onSearch')), 'fa:search')->class 'btn btn-sm btn-primary';
  61.             $this->form->addAction(_t('Clear'),  new TAction(array($this'onClear')), 'fa:eraser')->class 'btn btn-sm btn-warning';
  62.             
  63.             // creates a Datagrid
  64.             $this->datagrid = new BootstrapDatagridWrapper(new TDataGrid);
  65.             $this->datagrid->datatable 'true';
  66.             $this->datagrid->style 'width: 100%';
  67.             $this->datagrid->setHeight(320);
  68.             
  69.             // creates the datagrid columns
  70.             $column_id = new TDataGridColumn('id''ID''center');
  71.             $column_cpf = new TDataGridColumn('cpf''CPF''center');
  72.             $column_nome = new TDataGridColumn('nome''Nome''center');
  73.             $column_inativa = new TDataGridColumn('inativa'_t('Status'), 'center');
  74.             $column_inativa->setTransformer(function($value$object$row) {
  75.                 $class = ($value==false) ? 'success' 'danger';
  76.                 $label = ($value==false) ? 'Ativo' 'Inativo';
  77.                 $div = new TElement('span');
  78.                 $div->class="label label-{$class}";
  79.                 $div->style="text-shadow:none; font-size:12px; font-weight:lighter";
  80.                 $div->add($label);
  81.                 return $div;
  82.             });
  83.             // add the columns to the DataGrid
  84.             $this->datagrid->addColumn($column_id);
  85.             $this->datagrid->addColumn($column_cpf);
  86.             $this->datagrid->addColumn($column_nome);
  87.             $this->datagrid->addColumn($column_inativa);
  88.             $this->datagrid->disableDefaultClick();
  89.             // create EDIT action
  90.             $action_edit = new TDataGridAction(array('TelaCPFNomeForm''onEdit'));
  91.             $action_edit->setButtonClass('btn btn-default');
  92.             $action_edit->setLabel(_t('Edit'));
  93.             $action_edit->setImage('far:edit blue fa-lg');
  94.             $action_edit->setField('id');
  95.             $this->datagrid->addAction($action_edit);
  96.             
  97.             // create DELETE action
  98.             $action_del = new TDataGridAction(array($this'onDelete'));
  99.             $action_del->setButtonClass('btn btn-default');
  100.             $action_del->setLabel(_t('Delete'));
  101.             $action_del->setImage('fa:trash red fa-lg');
  102.             $action_del->setField('id');
  103.             $this->datagrid->addAction($action_del);
  104.                     
  105.             // create the datagrid model
  106.             $this->datagrid->createModel();
  107.             
  108.             // create the page navigation
  109.             $this->pageNavigation = new TPageNavigation;
  110.             $this->pageNavigation->enableCounters();
  111.             $this->pageNavigation->setAction(new TAction(array($this'onReload')));
  112.             $this->pageNavigation->setWidth($this->datagrid->getWidth());
  113.             
  114.             $panel = new TPanelGroup;
  115.             $panel->add($this->datagrid);
  116.             $panel->addFooter($this->pageNavigation);
  117.             // vertical box container
  118.             $container = new TVBox;
  119.             $container->style 'width: 100%';
  120.             $container->add(new TXMLBreadCrumb('menu.xml''TelaCPFNomeList'));
  121.             $container->add($this->form);
  122.             $container->add($panel);
  123.             
  124.             parent::add($container);
  125.         }
  126.         catch (Exception $e)
  127.         {
  128.             new TMessage('error'$e->getMessage());    
  129.         }
  130.     }
  131.     
  132.     function onClear()
  133.     {
  134.         // get the search form data
  135.         $data $this->form->getData();
  136.         TSession::setValue(__CLASS__.'_filter_data'NULL);
  137.         TSession::setValue(__CLASS__.'_filters'NULL);
  138.         
  139.         $data->id   '';
  140.         $data->cpf   '';
  141.         $data->nome   '';
  142.         $data->inativa '';
  143.         
  144.         // fill the form with data again
  145.         $this->form->setData($data);
  146.         
  147.         $param = array();
  148.         $param['offset']     = 0;
  149.         $param['first_page'] = 1;
  150.         $this->onReload($param);
  151.     }
  152.     
  153.     /**
  154.      * Register the filter in the session
  155.      */
  156.     public function onSearch($param NULL)
  157.     {
  158.         // get the search form data
  159.         $data $this->form->getData();
  160.         
  161.         // clear session filters
  162.         TSession::setValue(__CLASS__.'_filter_data'NULL);
  163.         TSession::setValue(__CLASS__.'_filters'NULL);
  164.         
  165.         $filters = array();
  166.         if (isset($data->id) AND ($data->id != NULL))
  167.         {
  168.             $id = new \MongoDB\BSON\ObjectId($data->id);
  169.             $filters['_id'] = $id;  
  170.             /*
  171.                 Find By _id
  172.                 $mongo = new \MongoDB\Driver\Manager('mongodb://root:root@192.168.0.127/db');
  173.                 $id           = new \MongoDB\BSON\ObjectId("588c78ce02ac660426003d87");
  174.                 $filter      = ['_id' => $id];
  175.                 $options = [];
  176.                 $query = new \MongoDB\Driver\Query($filter, $options);
  177.                 $rows   = $mongo->executeQuery('db.collectionName', $query);
  178.                 foreach ($rows as $document) {
  179.                   pr($document);
  180.                 }
  181.                 
  182.                 https://www.php.net/manual/en/class.mongodb-driver-query.php
  183.             */
  184.         }
  185.         if (isset($data->cpf) AND ($data->cpf != NULL))
  186.         {
  187.             $cpf = new MongoDB\BSON\Regex("^$data->cpf.*$"'i');
  188.             $filters['cpf'] = $cpf
  189.         }
  190.         if (isset($data->nome) AND ($data->nome != NULL))
  191.         {
  192.             $data->nome mb_strtoupper($data->nome'UTF-8');
  193.             $nome = new MongoDB\BSON\Regex("^$data->nome.*$"'i');
  194.             $filters['nome'] = $nome
  195.         }
  196.         if (isset($data->inativa) AND ($data->inativa != NULL))
  197.         {
  198.             $filters['inativa'] = boolval($data->inativa);
  199.         }
  200.               
  201.         /*
  202.             Mongo DB 5.0
  203.             There is no like in mongo,You can use regex Here in this case you dont require regex,you can get your result using simple find query,Date stored in mongodb is in ISO formate,So first convert your date to ISO date and then find for eg
  204.             var convertDate = "11/11/2016";
  205.             convertDate  = new Date(11/11/2016);
  206.             db.getCollection('TableName').find({date : convertDate})
  207.             Or if you want like in mongo use this
  208.             1)Search directly
  209.             db.getCollection('TableName').find({date : {$regex : "11/11/2016"}})
  210.             2) Create a text index on date and then search
  211.             db.getCollection('TableName').find({$text:{$search:"11/11/2016"}})
  212.             https://stackoverflow.com/questions/40541617/how-do-i-query-in-mongo-db-using-like-operator
  213.             transform stdclass to array 
  214.             json_decode(json_encode($value), true)
  215.             https://stackoverflow.com/questions/18576762/php-stdclass-to-array
  216.         
  217.             array("inativa" => json_decode(json_encode($data->inativa), true)boolval($data->inativa))
  218.             https://www.php.net/manual/en/mongodb-bson-regex.construct.php
  219.             
  220.             $nome = new MongoDB\BSON\Regex("^$nome", 'i');
  221.             https://arctype.com/blog/sql-phone-number/
  222.             https://stackoverflow.com/questions/28712248/difference-between-mongodb-and-mongoose
  223.             https://studio3t.com/knowledge-base/articles/mongodb-find-method/
  224.             https://stackoverflow.com/questions/45705786/mongoclient-class-vs-mongodb-driver-manager-class
  225.             
  226.             $filters = array('$or' => array(array("cpf" => $cpf), array("nome" => $nome), array("inativa" => boolval($inativa))));
  227.         */
  228.         // fill the form with data again
  229.         $this->form->setData($data);
  230.         TSession::setValue(__CLASS__.'_filter_data'$data);
  231.         TSession::setValue(__CLASS__.'_filters'$filters);
  232.         
  233.         // keep the search data in the session
  234.         
  235.         $param=array();
  236.         $param['offset']    =0;
  237.         $param['first_page']=1;
  238.         $this->onReload($param);
  239.     }
  240.     
  241.     /**
  242.      * Load the datagrid with data
  243.      */
  244.     public function onReload($param NULL)
  245.     {
  246.         try
  247.         {
  248.             // This path should point to Composer's autoloader
  249.             //require '../../../../vendor/autoload.php';
  250.             /*https://www.php.net/manual/en/mongodb-driver-manager.executequery.php
  251.               https://www.mongodb.com/docs/manual/reference/method/Session.startTransaction/
  252.               https://www.php.net/manual/en/class.mongodb-driver-manager.php
  253.             */
  254.             
  255.             // default order
  256.             $limit 10;
  257.             //https://stackoverflow.com/questions/35147845/how-does-sorting-work-in-the-new-mongodb-pecl-extension
  258.             // default order
  259.             /*if (empty($param['order']))
  260.             {
  261.                 $param['order'] = '_id';
  262.                 $param['direction'] = 'desc';
  263.             }*/
  264.             $param['limit'] = isset($limit) ? $limit NULL;
  265.             $param['page']   = isset($param['page'])   ? $param['page']   : 1;
  266.             $param['offset']   = isset($param['offset'])   ? $param['offset']   : 0;
  267.             //$param['offset'] = ($param['page']=="" || $param['page']=="1") ? 0 : ($param['page']*10)-10;
  268.             /*
  269.                 $options = [
  270.                     'skip'=>  $offset,
  271.                     'limit'=> $limit,
  272.                     'sort' => ["_id" => -1],
  273.                 ];
  274.             */
  275.             
  276.             /* Return the documents in descending order of _id by the timestamp 
  277.                 This will sort your collection in descending order based on the date of insertion
  278.                 https://stackoverflow.com/questions/13847766/how-to-sort-a-collection-by-date-in-mongodb
  279.             */
  280.             /* Only return the following fields in the matching documents */
  281.             $options = [
  282.                 'skip'   => $param['offset'],
  283.                 'limit'  => $param['limit'],
  284.                 'sort'   => ["_id" => -1]
  285.             ];
  286.             $filters = [];
  287.             if(TSession::getValue(__CLASS__.'_filters'))
  288.             {
  289.                 $filters TSession::getValue(__CLASS__.'_filters');
  290.                 /*foreach ($filters as $key => $filter)
  291.                 {
  292.                     $filter = json_decode(json_encode($filter), true);
  293.                     if ($key == 'nome')
  294.                     {
  295.                         $filter = ['$regex' => $filter];
  296.                     }
  297.                     if ($key == 'inativa')
  298.                     {
  299.                         $filter = boolval($filter);
  300.                     }
  301.                     $newArray[] = array($key => $filter);
  302.                     $filters = array('$or' => $newArray);
  303.                 }
  304.                 $filtros = array();
  305.                 foreach ($filters as $key => $filter)
  306.                 {
  307.                     $filtros = array('$and' => array(array("{$key}" => $filter)));
  308.                     $filtros = array('$or' => array(array("{$key}" => $filter)));
  309.                     $filtros = array("{$key}" => array('$in' => array($filter)));
  310.                     $filtros[$key] = $filter;
  311.                     $filtros = array();
  312.                     $filters = array_merge($filtros, $filters);
  313.                 }*/
  314.                 $filters = array('$and' => array(array($filters)));
  315.                
  316.             }
  317.             $this->datagrid->clear();
  318.             $manager = new MongoDB\Driver\Manager($this->ini['host']);
  319.             $readPreference = new MongoDB\Driver\ReadPreference(MongoDB\Driver\ReadPreference::RP_PRIMARY);
  320.             $query = new MongoDB\Driver\Query($filters$options);   
  321.             $cursor $manager->executeQuery('bancoTeste.cadastro_cpf_nome'$query$readPreference);
  322.             //carrega todos os objetos para contagem
  323.             $queryCount = new MongoDB\Driver\Query($filters);   
  324.             $cursorCount $manager->executeQuery('bancoTeste.cadastro_cpf_nome'$queryCount$readPreference);
  325.             $objectsCount json_decode(json_encode($cursorCount->toArray(),true), true);
  326.             //https://stackoverflow.com/questions/36726069/how-to-get-cursor-result-count-using-the-mongodb-php-extension
  327.             /*
  328.                 https://www.mongodb.com/community/forums/t/proper-way-to-get-a-php-array-from-aggregate-or-convert-a-mongodb-driver-cursor-to-array/8192
  329.                 This converts the BSON documents to an array instead of an std object in a single line.
  330.                 I tryed to convert to stdclass but it returned an empty array
  331.             */
  332.             $objects json_decode(json_encode($cursor->toArray(),true), true);
  333.             if ($objects)
  334.             {
  335.                 foreach ($objects as $key => $object
  336.                 {
  337.                     $newObject = new stdClass;
  338.                     $newObject->id $object['_id']['$oid'];
  339.                     $newObject->cpf $object['cpf'];
  340.                     $newObject->nome $object['nome'];
  341.                     $newObject->inativa $object['inativa'];
  342.                 
  343.                     // add the object inside the datagrid
  344.                     $this->datagrid->addItem($newObject);
  345.                 }
  346.             }
  347.             
  348.             if (is_callable($this->transformCallback))
  349.             {
  350.                 call_user_func($this->transformCallback$objects$param);
  351.             }
  352.             
  353.             $param['limit']  = NULL;
  354.             $param['order']  = NULL;
  355.             $param['offset'] = NULL;
  356.             $param['group']  = NULL;
  357.             $count count($objectsCount);
  358.             //$count = $cursor->count($filters, $options);
  359.             
  360.             $this->pageNavigation->setCount($count); // count of records
  361.             $this->pageNavigation->setProperties($param); // order, page
  362.             $this->pageNavigation->setLimit($limit); // limit
  363.             
  364.             $this->loaded true;   
  365.         }
  366.         catch (Exception $e// in case of exception
  367.         {
  368.             // shows the exception error message
  369.             new TMessage('error'$e->getMessage());
  370.             // undo all pending operations
  371.             TTransaction::rollback();
  372.         }
  373.     }
  374.     
  375.     /**
  376.      * Ask before deletion
  377.      */
  378.     public function onDelete($param)
  379.     {
  380.         // define the delete action
  381.         $action = new TAction(array($this'Delete'));
  382.         $action->setParameters($param); // pass the key parameter ahead
  383.         
  384.         // shows a dialog to the user
  385.         new TQuestion(AdiantiCoreTranslator::translate('Do you really want to delete ?'), $action);
  386.     }
  387.     
  388.     /**
  389.      * Delete a record
  390.      */
  391.     public function Delete($param)
  392.     {
  393.         try
  394.         {
  395.             $id $param['id']; // get the parameter $key
  396.             // This path should point to Composer's autoloader
  397.             //require '../../../../vendor/autoload.php';
  398.             //connect to mongodb
  399.             $conexaoMongo = new MongoDB\Client($this->ini['host']);
  400.             $banco $conexaoMongo->bancoTeste;
  401.             $cadastro $banco->cadastro_cpf_nome;
  402.             $cadastro->deleteOne( array( '_id' => new MongoDB\BSON\ObjectId ($id)) );
  403.             $this->onReload$param ); // reload the listing
  404.             new TMessage('info'AdiantiCoreTranslator::translate('Record deleted')); // success message
  405.             
  406.             TApplication::loadPage('TelaCPFNomeList''');
  407.         }
  408.         catch (Exception $e// in case of exception
  409.         {
  410.             new TMessage('error'$e->getMessage()); // shows the exception error message
  411.             TTransaction::rollback(); // undo all pending operations
  412.         }
  413.     }
  414.     
  415.     public function show()
  416.     {
  417.         // check if the datagrid is already loaded
  418.         if (!$this->loaded AND (!isset($_GET['method']) OR !(in_array($_GET['method'],  array('onReload''onSearch''onClear')))) )
  419.         {
  420.             if (func_num_args() > 0)
  421.             {
  422.                 $this->onReloadfunc_get_arg(0) );
  423.             }
  424.             else
  425.             {
  426.                 $this->onReload();
  427.             }
  428.         }
  429.         parent::show();
  430.     }
  431.     function showMessage()
  432.     {
  433.         new TMessage('info'AdiantiCoreTranslator::translate('Record saved'));
  434.         $this->onReload();
  435.     }
  436. }
  437. ?>


</your></document></document></boolean></replacement></filter></your>