Lançado Adianti Framework 7.6!
Clique aqui para saber mais
Editar calendário a partir da list - Erro VIEW Pessoal, bom dia. Criei um agenda (form e view), até aí tudo 100%. Pensei em criar uma list e a partir dela editar informação no form do calendário. A list até chama a form mas dá um erro, e quando faço a alteração ele limpa o campos e mostra essa informação abaixo. Notice: Undefined index: view in C:xampphtdocsprojeto_postgresappcontrolAgendaAgendaSala1Form.php on line 158 ...
RA
Editar calendário a partir da list - Erro VIEW  
Pessoal, bom dia. Criei um agenda (form e view), até aí tudo 100%. Pensei em criar uma list e a partir dela editar informação no form do calendário. A list até chama a form mas dá um erro, e quando faço a alteração ele limpa o campos e mostra essa informação abaixo.

Notice: Undefined index: view in C:xampphtdocsprojeto_postgresappcontrolAgendaAgendaSala1Form.php on line 158

Informação:
O campo Paciente é obrigatório.
O campo Horário inicial é obrigatório.
O campo Horário final é obrigatório.

  1. <?php
  2. class AgendaSala1Form extends TWindow
  3. {
  4.     protected $form// form
  5.     private $formFields = [];
  6.     /**
  7.      * Form constructor
  8.      * @param $param Request
  9.      */
  10.     public function __construct$param )
  11.     {
  12.         parent::__construct();
  13.         parent::setSize(800null);
  14.         parent::setTitle('Lembrete');
  15.         parent::setProperty('class''window_modal');
  16.         
  17.         $this->form = new BootstrapFormBuilder('form_AgendaSala1');
  18.         $this->form->setFormTitle('Agenda Sala 1');
  19.         $view = new THidden('view');
  20.         $id = new TEntry('id');
  21.         $id_cadastro = new TDBUniqueSearch'id_cadastro''projeto''Cadastro''id''nome''nome asc'  );
  22.         $horario_inicial = new TDateTime('horario_inicial');
  23.         $horario_final = new TDateTime('horario_final');
  24.         $titulo = new TEntry('titulo');
  25.         $cor = new TColor('cor');
  26.         $observacao = new TText('observacao');
  27.         $id_cadastro->addValidation('Paciente', new TRequiredValidator()); 
  28.         $horario_inicial->addValidation('Horário inicial', new TRequiredValidator()); 
  29.         $horario_final->addValidation('Horário final', new TRequiredValidator()); 
  30.         $id->setEditable(false);
  31.         $id_cadastro->setMinLength(2);
  32.         $horario_final->setMask('dd/mm/yyyy hh:ii');
  33.         $horario_inicial->setMask('dd/mm/yyyy hh:ii');
  34.         $horario_final->setDatabaseMask('yyyy-mm-dd hh:ii');
  35.         $horario_inicial->setDatabaseMask('yyyy-mm-dd hh:ii');
  36.         $id->setSize(100);
  37.         $cor->setSize(100);
  38.         $titulo->setSize('72%');
  39.         $id_cadastro->setSize('76%');
  40.         $horario_final->setSize(150);
  41.         $horario_inicial->setSize(150);
  42.         $observacao->setSize('76%'68);
  43.         $id->setEditable(FALSE);
  44.         
  45.         $this->form->addFields([$view]);
  46.         $this->form->addFields([new TLabel('Id:')],[$id]);
  47.         $this->form->addFields([new TLabel('Paciente:''#ff0000')],[$id_cadastro]);
  48.         $this->form->addFields([new TLabel('Horário inicial:''#ff0000')],[$horario_inicial],[new TLabel('Horário final:''#ff0000')],[$horario_final]);
  49.         $this->form->addFields([new TLabel('Título:')],[$titulo],[new TLabel('Cor:')],[$cor]);
  50.         $this->form->addFields([new TLabel('Observação:')],[$observacao]);
  51.         // create the form actions
  52.         $this->form->addAction('Salvar', new TAction([$this'onSave']), 'fa:floppy-o')->addStyleClass('btn-primary');
  53.         $this->form->addAction('Limpar formulário', new TAction([$this'onClear']), 'fa:eraser #dd5a43');
  54.         $this->form->addAction('Excluir', new TAction([$this'onDelete']), 'fa:trash-o #dd5a43');
  55.         parent::add($this->form);
  56.     }
  57.     public function onSave($param null
  58.     {
  59.         try
  60.         {
  61.             TTransaction::open('projeto');
  62.             
  63.             $this->form->validate();
  64.             $data $this->form->getData();
  65.             
  66.             $object = new AgendaSala1(); 
  67.             $object->fromArray( (array) $data);
  68.             $object->store(); 
  69.             // get the generated {PRIMARY_KEY}
  70.             $data->id $object->id
  71.             $this->form->setData($data);
  72.             TTransaction::close();
  73.             
  74.             $action = new TAction(['AgendaSala1FormView''onReload']);
  75.             $action->setParameter('view'$data->view);
  76.             $action->setParameter('date'explode(' '$data->horario_inicial)[0]); 
  77.             new TMessage('info'AdiantiCoreTranslator::translate('Record saved'), $action);
  78.         }
  79.         catch (Exception $e)
  80.         {
  81.             new TMessage('error'$e->getMessage());
  82.             $this->form->setData$this->form->getData() );
  83.             TTransaction::rollback();
  84.         }
  85.     }
  86.     
  87.     public function onDelete($param null
  88.     {
  89.         if (isset($param['delete']) && $param['delete'] == 1)
  90.         {
  91.             try
  92.             {
  93.                 $key $param['id'];
  94.                 TTransaction::open('projeto');
  95.                 $object = new AgendaSala1($keyFALSE);
  96.                 $object->delete();
  97.                 TTransaction::close();
  98.                 
  99.                 $action = new TAction(array('AgendaSala1FormView''onReload'));
  100.                 $action->setParameter('view'$param['view']);
  101.                 $action->setParameter('date'explode(' '$param['horario_inicial'])[0]);
  102.                 // shows the success message
  103.                 new TMessage('info'AdiantiCoreTranslator::translate('Record deleted'), $action);
  104.             }
  105.             catch (Exception $e// in case of exception
  106.             {
  107.                 new TMessage('error'$e->getMessage());
  108.                 TTransaction::rollback();
  109.             }
  110.         }
  111.         else
  112.         {
  113.             // define the delete action
  114.             $action = new TAction(array($this'onDelete'));
  115.             $action->setParameters((array) $this->form->getData()); // pass the key paramsseter ahead
  116.             $action->setParameter('delete'1);
  117.             
  118.             // shows a dialog to the user
  119.             new TQuestion(AdiantiCoreTranslator::translate('Do you really want to delete ?'), $action);   
  120.         }
  121.     }
  122.     /**
  123.      * Clear form data
  124.      * @param $param Request
  125.      */
  126.     public function onClear$param )
  127.     {
  128.         $this->form->clear();
  129.     }  
  130.     public function onEdit$param )
  131.     {
  132.         try
  133.         {
  134.             if (isset($param['key']))
  135.             {
  136.                 $key $param['key'];  // get the parameter $key
  137.                 TTransaction::open('projeto'); // open a transaction
  138.                 $object = new AgendaSala1($key); // instantiates the Active Record 
  139.                 $object->view $param['view']; 
  140.                 $this->form->setData($object); // fill the form 
  141.                 TTransaction::close(); // close the transaction 
  142.             }
  143.             else
  144.             {
  145.                 $this->form->clear();
  146.             }
  147.         }
  148.         catch (Exception $e// in case of exception
  149.         {
  150.             new TMessage('error'$e->getMessage()); // shows the exception error message
  151.             TTransaction::rollback(); // undo all pending operations
  152.         }
  153.     }
  154.     
  155.     public function onStartEdit($param)
  156.     {
  157.         $this->form->clear();
  158.         
  159.         $data = new stdClass;
  160.         $data->view $param['view']; // calendar view
  161.         $data->cor '#3a87ad';
  162.         if ($param['date'])
  163.         {
  164.             if(strlen($param['date']) == '10')
  165.             {
  166.                 $param['date'].= ' 09:00';
  167.             }
  168.             
  169.             $data->horario_inicial str_replace('T'' '$param['date']);
  170.             $horario_final = new DateTime($data->horario_inicial);
  171.             $horario_final->add(new DateInterval('PT1H'));
  172.             $data->horario_final $horario_final->format('Y-m-d H:i:s');
  173.             $this->form->setData$data );
  174.         }
  175.     }
  176.     public static function onUpdateEvent($param)
  177.     {
  178.         try
  179.         {
  180.             if (isset($param['id']))
  181.             {
  182.                 // open a transaction with database 'samples'
  183.                 TTransaction::open('projeto');
  184.                 $object = new AgendaSala1($param['id']);
  185.                 $object->horario_inicial str_replace('T'' '$param['start_time']);
  186.                 $object->horario_final   str_replace('T'' '$param['end_time']);
  187.                 $object->store();
  188.                 // close the transaction
  189.                 TTransaction::close();
  190.             }
  191.         }
  192.         catch (Exception $e// in case of exception
  193.         {
  194.             new TMessage('error'$e->getMessage());
  195.             TTransaction::rollback();
  196.         }
  197.     }
  198. }?>


  1. <?php
  2. class AgendaSala1FormView extends TPage
  3. {
  4.     private $fc;
  5.     /**
  6.      * Page constructor
  7.      */
  8.     public function __construct()
  9.     {
  10.         parent::__construct();
  11.         
  12.         $this->fc = new TFullCalendar(date('Y-m-d'), 'month');
  13.         $this->fc->enableDays([1,2,3,4,5,6]);
  14.         $this->fc->setReloadAction(new TAction(array($this'getEvents')));
  15.         $this->fc->setDayClickAction(new TAction(array('AgendaSala1Form''onStartEdit')));
  16.         $this->fc->setEventClickAction(new TAction(array('AgendaSala1Form''onEdit')));
  17.         $this->fc->setEventUpdateAction(new TAction(array('AgendaSala1Form''onUpdateEvent')));
  18.         $this->fc->setTimeRange('07:00''19:00');
  19.         parent::add$this->fc );
  20.     }
  21.     /**
  22.      * Output events as an json
  23.      */
  24.     public static function getEvents($param=NULL)
  25.     {
  26.         $return = array();
  27.         try
  28.         {
  29.             TTransaction::open('projeto');
  30.             $events AgendaSala1::where('horario_inicial''>='$param['start'] . ' 00:00:00')
  31.                                 ->where('horario_final',   '<='$param['end']   . ' 23:59:59')
  32.                                 ->load();
  33.             if ($events)
  34.             {
  35.                 foreach ($events as $event)
  36.                 {
  37.                     $event_array $event->toArray();
  38.                     $event_array['start'] = str_replace' ''T'$event_array['horario_inicial']);
  39.                     $event_array['end']   = str_replace' ''T'$event_array['horario_final']);
  40.                     $event_array['color'] = $event_array['cor'];
  41.                     $event_array['title'] = $event_array['titulo'] . ' - ' $event->cadastro->nome;
  42.                     $return[] = $event_array;
  43.                 }
  44.             }
  45.             TTransaction::close();
  46.             echo json_encode($return);
  47.         }
  48.         catch (Exception $e)
  49.         {
  50.             new TMessage('error'$e->getMessage());
  51.         }
  52.     }
  53.     /**
  54.      * Reconfigure the calendar
  55.      */
  56.     public function onReload($param null)
  57.     {
  58.         if (isset($param['view']))
  59.         {
  60.             $this->fc->setCurrentView($param['view']);
  61.         }
  62.         if (isset($param['date']))
  63.         {
  64.             $this->fc->setCurrentDate($param['date']);
  65.         }
  66.     }
  67. }?>


  1. <?php
  2. /**
  3.  * AgendaSala1List Listing
  4.  * @author  <your name here>
  5.  */
  6. class AgendaSala1List extends TPage
  7. {
  8.     private $form// form
  9.     private $datagrid// listing
  10.     private $pageNavigation;
  11.     private $formgrid;
  12.     private $loaded;
  13.     private $deleteButton;
  14.     
  15.     /**
  16.      * Class constructor
  17.      * Creates the page, the form and the listing
  18.      */
  19.     public function __construct()
  20.     {
  21.         parent::__construct();
  22.         
  23.         // creates the form
  24.         $this->form = new BootstrapFormBuilder('form_AgendaSala1');
  25.         $this->form->setFormTitle('AgendaSala1');
  26.         
  27.         // create the form fields
  28.         $id = new TEntry('id');
  29.         $id_cadastro = new TDBUniqueSearch('id_cadastro''projeto''Cadastro''id''nome');
  30.         $horario_inicial = new TEntry('horario_inicial');
  31.         $horario_final = new TEntry('horario_final');
  32.         $titulo = new TEntry('titulo');
  33.         $cor = new TEntry('cor');
  34.         $observacao = new TEntry('observacao');
  35.         // add the fields
  36.         $this->form->addFields( [ new TLabel('Id') ], [ $id ] );
  37.         $this->form->addFields( [ new TLabel('Id Cadastro') ], [ $id_cadastro ] );
  38.         $this->form->addFields( [ new TLabel('Horario Inicial') ], [ $horario_inicial ] );
  39.         $this->form->addFields( [ new TLabel('Horario Final') ], [ $horario_final ] );
  40.         $this->form->addFields( [ new TLabel('Titulo') ], [ $titulo ] );
  41.         $this->form->addFields( [ new TLabel('Cor') ], [ $cor ] );
  42.         $this->form->addFields( [ new TLabel('Observacao') ], [ $observacao ] );
  43.         // set sizes
  44.         $id->setSize('100%');
  45.         $id_cadastro->setSize('100%');
  46.         $horario_inicial->setSize('100%');
  47.         $horario_final->setSize('100%');
  48.         $titulo->setSize('100%');
  49.         $cor->setSize('100%');
  50.         $observacao->setSize('100%');
  51.         
  52.         // keep the form filled during navigation with session data
  53.         $this->form->setDataTSession::getValue('AgendaSala1_filter_data') );
  54.         
  55.         // add the search form actions
  56.         $btn $this->form->addAction(_t('Find'), new TAction([$this'onSearch']), 'fa:search');
  57.         $btn->class 'btn btn-sm btn-primary';
  58.         $this->form->addActionLink(_t('New'), new TAction(['AgendaSala1Form''onEdit']), 'fa:plus green');
  59.         
  60.         // creates a Datagrid
  61.         $this->datagrid = new BootstrapDatagridWrapper(new TDataGrid);
  62.         $this->datagrid->style 'width: 100%';
  63.         $this->datagrid->datatable 'true';
  64.         // $this->datagrid->enablePopover('Popover', 'Hi <b> {name} </b>');
  65.         
  66.         // creates the datagrid columns
  67.         $column_id = new TDataGridColumn('id''Id''right');
  68.         $column_id_cadastro = new TDataGridColumn('id_cadastro''Id Cadastro''right');
  69.         $column_horario_inicial = new TDataGridColumn('horario_inicial''Horario Inicial''left');
  70.         $column_horario_final = new TDataGridColumn('horario_final''Horario Final''left');
  71.         $column_titulo = new TDataGridColumn('titulo''Titulo''left');
  72.         $column_cor = new TDataGridColumn('cor''Cor''left');
  73.         $column_observacao = new TDataGridColumn('observacao''Observacao''left');
  74.         // add the columns to the DataGrid
  75.         $this->datagrid->addColumn($column_id);
  76.         $this->datagrid->addColumn($column_id_cadastro);
  77.         $this->datagrid->addColumn($column_horario_inicial);
  78.         $this->datagrid->addColumn($column_horario_final);
  79.         $this->datagrid->addColumn($column_titulo);
  80.         $this->datagrid->addColumn($column_cor);
  81.         $this->datagrid->addColumn($column_observacao);
  82.         
  83.         // create EDIT action
  84.         $action_edit = new TDataGridAction(['AgendaSala1Form''onEdit']);
  85.         //$action_edit->setUseButton(TRUE);
  86.         //$action_edit->setButtonClass('btn btn-default');
  87.         $action_edit->setLabel(_t('Edit'));
  88.         $action_edit->setImage('fa:pencil-square-o blue fa-lg');
  89.         $action_edit->setField('id');
  90.         $this->datagrid->addAction($action_edit);
  91.         
  92.         // create DELETE action
  93.         $action_del = new TDataGridAction(array($this'onDelete'));
  94.         //$action_del->setUseButton(TRUE);
  95.         //$action_del->setButtonClass('btn btn-default');
  96.         $action_del->setLabel(_t('Delete'));
  97.         $action_del->setImage('fa:trash-o red fa-lg');
  98.         $action_del->setField('id');
  99.         $this->datagrid->addAction($action_del);
  100.         
  101.         // create the datagrid model
  102.         $this->datagrid->createModel();
  103.         
  104.         // creates the page navigation
  105.         $this->pageNavigation = new TPageNavigation;
  106.         $this->pageNavigation->setAction(new TAction([$this'onReload']));
  107.         $this->pageNavigation->setWidth($this->datagrid->getWidth());
  108.         
  109.         // vertical box container
  110.         $container = new TVBox;
  111.         $container->style 'width: 90%';
  112.         // $container->add(new TXMLBreadCrumb('menu.xml', __CLASS__));
  113.         $container->add($this->form);
  114.         $container->add(TPanelGroup::pack(''$this->datagrid$this->pageNavigation));
  115.         
  116.         parent::add($container);
  117.     }
  118.     
  119.     /**
  120.      * Inline record editing
  121.      * @param $param Array containing:
  122.      *              key: object ID value
  123.      *              field name: object attribute to be updated
  124.      *              value: new attribute content 
  125.      */
  126.     public function onInlineEdit($param)
  127.     {
  128.         try
  129.         {
  130.             // get the parameter $key
  131.             $field $param['field'];
  132.             $key   $param['key'];
  133.             $value $param['value'];
  134.             
  135.             TTransaction::open('projeto'); // open a transaction with database
  136.             $object = new AgendaSala1($key); // instantiates the Active Record
  137.             $object->{$field} = $value;
  138.             $object->store(); // update the object in the database
  139.             TTransaction::close(); // close the transaction
  140.             
  141.             $this->onReload($param); // reload the listing
  142.             new TMessage('info'"Record Updated");
  143.         }
  144.         catch (Exception $e// in case of exception
  145.         {
  146.             new TMessage('error'$e->getMessage()); // shows the exception error message
  147.             TTransaction::rollback(); // undo all pending operations
  148.         }
  149.     }
  150.     
  151.     /**
  152.      * Register the filter in the session
  153.      */
  154.     public function onSearch()
  155.     {
  156.         // get the search form data
  157.         $data $this->form->getData();
  158.         
  159.         // clear session filters
  160.         TSession::setValue('AgendaSala1List_filter_id',   NULL);
  161.         TSession::setValue('AgendaSala1List_filter_id_cadastro',   NULL);
  162.         TSession::setValue('AgendaSala1List_filter_horario_inicial',   NULL);
  163.         TSession::setValue('AgendaSala1List_filter_horario_final',   NULL);
  164.         TSession::setValue('AgendaSala1List_filter_titulo',   NULL);
  165.         TSession::setValue('AgendaSala1List_filter_cor',   NULL);
  166.         TSession::setValue('AgendaSala1List_filter_observacao',   NULL);
  167.         if (isset($data->id) AND ($data->id)) {
  168.             $filter = new TFilter('id''='"$data->id"); // create the filter
  169.             TSession::setValue('AgendaSala1List_filter_id',   $filter); // stores the filter in the session
  170.         }
  171.         if (isset($data->id_cadastro) AND ($data->id_cadastro)) {
  172.             $filter = new TFilter('id_cadastro''='"$data->id_cadastro"); // create the filter
  173.             TSession::setValue('AgendaSala1List_filter_id_cadastro',   $filter); // stores the filter in the session
  174.         }
  175.         if (isset($data->horario_inicial) AND ($data->horario_inicial)) {
  176.             $filter = new TFilter('horario_inicial''like'"%{$data->horario_inicial}%"); // create the filter
  177.             TSession::setValue('AgendaSala1List_filter_horario_inicial',   $filter); // stores the filter in the session
  178.         }
  179.         if (isset($data->horario_final) AND ($data->horario_final)) {
  180.             $filter = new TFilter('horario_final''like'"%{$data->horario_final}%"); // create the filter
  181.             TSession::setValue('AgendaSala1List_filter_horario_final',   $filter); // stores the filter in the session
  182.         }
  183.         if (isset($data->titulo) AND ($data->titulo)) {
  184.             $filter = new TFilter('titulo''like'"%{$data->titulo}%"); // create the filter
  185.             TSession::setValue('AgendaSala1List_filter_titulo',   $filter); // stores the filter in the session
  186.         }
  187.         if (isset($data->cor) AND ($data->cor)) {
  188.             $filter = new TFilter('cor''like'"%{$data->cor}%"); // create the filter
  189.             TSession::setValue('AgendaSala1List_filter_cor',   $filter); // stores the filter in the session
  190.         }
  191.         if (isset($data->observacao) AND ($data->observacao)) {
  192.             $filter = new TFilter('observacao''like'"%{$data->observacao}%"); // create the filter
  193.             TSession::setValue('AgendaSala1List_filter_observacao',   $filter); // stores the filter in the session
  194.         }
  195.         
  196.         // fill the form with data again
  197.         $this->form->setData($data);
  198.         
  199.         // keep the search data in the session
  200.         TSession::setValue('AgendaSala1_filter_data'$data);
  201.         
  202.         $param = array();
  203.         $param['offset']    =0;
  204.         $param['first_page']=1;
  205.         $this->onReload($param);
  206.     }
  207.     
  208.     /**
  209.      * Load the datagrid with data
  210.      */
  211.     public function onReload($param NULL)
  212.     { 
  213.         try
  214.         {
  215.             // open a transaction with database 'projeto'
  216.             TTransaction::open('projeto');
  217.             
  218.             // creates a repository for AgendaSala1
  219.             $repository = new TRepository('AgendaSala1');
  220.             $limit 10;
  221.             // creates a criteria
  222.             $criteria = new TCriteria;
  223.             
  224.             // default order
  225.             if (empty($param['order']))
  226.             {
  227.                 $param['order'] = 'id';
  228.                 $param['direction'] = 'asc';
  229.             }
  230.             $criteria->setProperties($param); // order, offset
  231.             $criteria->setProperty('limit'$limit);
  232.             
  233.             if (TSession::getValue('AgendaSala1List_filter_id')) {
  234.                 $criteria->add(TSession::getValue('AgendaSala1List_filter_id')); // add the session filter
  235.             }
  236.             if (TSession::getValue('AgendaSala1List_filter_id_cadastro')) {
  237.                 $criteria->add(TSession::getValue('AgendaSala1List_filter_id_cadastro')); // add the session filter
  238.             }
  239.             if (TSession::getValue('AgendaSala1List_filter_horario_inicial')) {
  240.                 $criteria->add(TSession::getValue('AgendaSala1List_filter_horario_inicial')); // add the session filter
  241.             }
  242.             if (TSession::getValue('AgendaSala1List_filter_horario_final')) {
  243.                 $criteria->add(TSession::getValue('AgendaSala1List_filter_horario_final')); // add the session filter
  244.             }
  245.             if (TSession::getValue('AgendaSala1List_filter_titulo')) {
  246.                 $criteria->add(TSession::getValue('AgendaSala1List_filter_titulo')); // add the session filter
  247.             }
  248.             if (TSession::getValue('AgendaSala1List_filter_cor')) {
  249.                 $criteria->add(TSession::getValue('AgendaSala1List_filter_cor')); // add the session filter
  250.             }
  251.             if (TSession::getValue('AgendaSala1List_filter_observacao')) {
  252.                 $criteria->add(TSession::getValue('AgendaSala1List_filter_observacao')); // add the session filter
  253.             }
  254.             
  255.             // load the objects according to criteria
  256.             $objects $repository->load($criteriaFALSE);
  257.             
  258.             if (is_callable($this->transformCallback))
  259.             {
  260.                 call_user_func($this->transformCallback$objects$param);
  261.             }
  262.             
  263.             $this->datagrid->clear();
  264.             if ($objects)
  265.             {
  266.                 // iterate the collection of active records
  267.                 foreach ($objects as $object)
  268.                 {
  269.                     // add the object inside the datagrid
  270.                     $this->datagrid->addItem($object);
  271.                 }
  272.             }
  273.             
  274.             // reset the criteria for record count
  275.             $criteria->resetProperties();
  276.             $count$repository->count($criteria);
  277.             
  278.             $this->pageNavigation->setCount($count); // count of records
  279.             $this->pageNavigation->setProperties($param); // order, page
  280.             $this->pageNavigation->setLimit($limit); // limit
  281.             
  282.             // close the transaction
  283.             TTransaction::close();
  284.             $this->loaded true;
  285.         }
  286.         catch (Exception $e// in case of exception
  287.         {
  288.             // shows the exception error message
  289.             new TMessage('error'$e->getMessage());
  290.             // undo all pending operations
  291.             TTransaction::rollback();
  292.         }
  293.     }
  294.     
  295.     /**
  296.      * Ask before deletion
  297.      */
  298.     public static function onDelete($param)
  299.     {
  300.         // define the delete action
  301.         $action = new TAction([__CLASS__'Delete']);
  302.         $action->setParameters($param); // pass the key parameter ahead
  303.         
  304.         // shows a dialog to the user
  305.         new TQuestion(TAdiantiCoreTranslator::translate('Do you really want to delete ?'), $action);
  306.     }
  307.     
  308.     /**
  309.      * Delete a record
  310.      */
  311.     public static function Delete($param)
  312.     {
  313.         try
  314.         {
  315.             $key=$param['key']; // get the parameter $key
  316.             TTransaction::open('projeto'); // open a transaction with database
  317.             $object = new AgendaSala1($keyFALSE); // instantiates the Active Record
  318.             $object->delete(); // deletes the object from the database
  319.             TTransaction::close(); // close the transaction
  320.             
  321.             $pos_action = new TAction([__CLASS__'onReload']);
  322.             new TMessage('info'TAdiantiCoreTranslator::translate('Record deleted'), $pos_action); // success message
  323.         }
  324.         catch (Exception $e// in case of exception
  325.         {
  326.             new TMessage('error'$e->getMessage()); // shows the exception error message
  327.             TTransaction::rollback(); // undo all pending operations
  328.         }
  329.     }
  330.     
  331.     
  332.     /**
  333.      * method show()
  334.      * Shows the page
  335.      */
  336.     public function show()
  337.     {
  338.         // check if the datagrid is already loaded
  339.         if (!$this->loaded AND (!isset($_GET['method']) OR !(in_array($_GET['method'],  array('onReload''onSearch')))) )
  340.         {
  341.             if (func_num_args() > 0)
  342.             {
  343.                 $this->onReloadfunc_get_arg(0) );
  344.             }
  345.             else
  346.             {
  347.                 $this->onReload();
  348.             }
  349.         }
  350.         parent::show();
  351.     }
  352. }?>


Curso completo Meu Negócio Pronto
Use para si, ou transforme em um negócio: Inclui aulas e códigos-fontes
Gestor de conteúdo (SITE) + Loja Virtual (E-Commerce) + Emissor de Notas para infoprodutos


Meu negócio pronto Quero me inscrever agora!

Comentários (3)


NR

Você está usando o mesmo nome para os formulários:
  1. <?php
  2. $this->form = new BootstrapFormBuilder('form_AgendaSala1');
  3. ?>

Sempre use nomes diferentes
RA

Nataniel, desculpe minha falta de informações, mas deixa ver se eu entendi.

Minha FORM está: $this->form = new BootstrapFormBuilder('form_AgendaSala1');
Minha LIST está: $this->form = new BootstrapFormBuilder('form_AgendaSala1');

Esses formulários foram criado pelo studio automaticamente. Eu preciso alterar no código?
NR

Sim, você precisa alterar o nome de um dos formulários:
  1. <?php
  2. //$this->form = new BootstrapFormBuilder('form_AgendaSala1'); 
  3. $this->form = new BootstrapFormBuilder('formlist_AgendaSala1'); 
  4. ?>

O que acontece é que a TWindow "abre" sobre um html já existente. Como os 2 formulários possuem o mesmo nome, ao executar uma ação provavelmente vai pegar as informações do primeiro form criado, que no caso é o form da tela escondida sob a TWindow.