Lançado Adianti Framework 7.6!
Clique aqui para saber mais
FullCalendar exibe json na tela e não carrega calendário Conforme imagem abaixo ao invés de atualizar os dados ele apresenta os dados na tela. Estou utilizando setChangeAction para filtrar o profissional no banco de dados. Obrigado pela ajuda segue fonte abaixo: ...
AG
FullCalendar exibe json na tela e não carrega calendário  
Conforme imagem abaixo ao invés de atualizar os dados ele apresenta os dados na tela. Estou utilizando setChangeAction para filtrar o profissional no banco de dados.

Obrigado pela ajuda segue fonte abaixo:

  1. <?php
  2. /**
  3.  * AgendamentoView Form
  4.  * @author  <your name here>
  5.  */
  6. class AgendamentoView extends TPage
  7. {
  8.     private $fc;
  9.     
  10.     /**
  11.      * Page constructor
  12.      */
  13.     public function __construct()
  14.     {
  15.         parent::__construct();
  16.         
  17.         // creates the form
  18.         $this->form = new BootstrapFormBuilder('form_Agendamento');
  19.         $this->form->setFieldSizes('100%');        
  20.         
  21.         $options = ['register_state' => 'false'];
  22.         
  23.         $profissional_id = new TDBCombo('profissional_id''clinica''Profissional''id''profissional');
  24.         $profissional_id->setChangeAction(new TAction([$this'getEvents']));
  25.         $row $this->form->addFields( [ new TLabel('Profissional') , $profissional_id] );
  26.         $row->layout = ['col-sm-6'];        
  27.         
  28.         $this->fc = new TFullCalendar(date('Y-m-d'), 'month');
  29.         $this->fc->setReloadAction(new TAction(array($this'getEvents')));
  30.         $this->fc->setDayClickAction(new TAction(array('AgendamentoForm''onStartEdit'), $options));
  31.         $this->fc->setEventClickAction(new TAction(array('AgendamentoForm''onEdit'), $options));
  32.         $this->fc->setEventUpdateAction(new TAction(array('AgendamentoForm''onUpdateEvent'), $options));
  33.         
  34.         $this->fc->setOption('businessHours', [ [ 'dow' => [ 1234], 'start' => '08:00''end' => '18:00' ]]);
  35.         //$this->fc->setTimeRange('10:00', '18:00');
  36.         //$this->fc->disableDragging();
  37.         //$this->fc->disableResizing();
  38.         $this->fc->style 'width:100%';
  39.         
  40.         $this->form->addFields(array($this->fc));
  41.         $container = new TVBox;
  42.         $container->style 'width: 100%';
  43.         $container->add($this->form);
  44.         //$container->add($this->fc);
  45.         
  46.         parent::add$container );
  47.     }
  48.     
  49.     /**
  50.      * Output events as an json
  51.      */
  52.     public static function getEvents($param=NULL)
  53.     {  
  54.         TApplication::postData('form_Agendamento',__CLASS__,'onReload');     
  55.         $return = array();
  56.         try
  57.         {
  58.             TTransaction::open('clinica');   
  59.                        
  60.             $events Agendamento::where('profissional_id''='$param['key'])->load();
  61.                                                                       
  62.             if ($events)
  63.             {
  64.                 foreach ($events as $event)
  65.                 {
  66.                     //$event_array = $event->toArray();
  67.                     
  68.                     $event_array['id']     = $event->id;
  69.                     $event_array['start']  = str_replace' ''T'$event->horario_inicial );
  70.                     $event_array['end']    = str_replace' ''T'$event->horario_final );
  71.                     $event_array['color']  = '#3a87ad';
  72.                     //$event_array['id']     = $event_array['id'];
  73.                     //$event_array['start']  = str_replace( ' ', 'T', $event_array['horario_inicial'] );
  74.                     //$event_array['end']    = str_replace( ' ', 'T', $event_array['horario_final'] );
  75.                     //$event_array['color']  = '#3a87ad';
  76.                    
  77.                     //$event_array['start'] = str_replace( ' ', 'T', $event_array['horario_inicial']);
  78.                     //$event_array['end']   = str_replace( ' ', 'T', $event_array['horario_final']);
  79.                     
  80.                     $popover_content $event->render("<b>Title</b>: {id} <br> <b>Description</b>: {descricao}");
  81.                     //$event_array['title'] = TFullCalendar::renderPopover($event_array['id'], 'Popover title', $popover_content);
  82.                     $event_array['title'] = TFullCalendar::renderPopover($event->id'Popover title'$popover_content);
  83.                     //$event_array['title'] = $event_array['title'] . ' - ' . $event->nome_paciente;
  84.                                         
  85.                     $return[] = $event_array;
  86.                 }
  87.             }
  88.             TTransaction::close();
  89.             echo json_encode($return);
  90.         }
  91.         catch (Exception $e)
  92.         {
  93.             new TMessage('error'$e->getMessage());
  94.         }
  95.     }
  96.     
  97.     /**
  98.      * Reconfigure the callendar
  99.      */
  100.     public function onReload($param null)
  101.     {
  102.         $this->form->setData($this->form->getData());
  103.         if (isset($param['view']))
  104.         {
  105.             $this->fc->setCurrentView($param['view']);
  106.         }
  107.         
  108.         if (isset($param['date']))
  109.         {
  110.             $this->fc->setCurrentDate($param['date']);
  111.         }
  112.     }
  113. }

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 (4)


NR

Não chame a getEvents diretamente no evento change da combo. Crie uma outra função, faça os filtros e adicione-os à sessão. Nessa mesma função você pode chamar a onReload.

Dentro da getEvents verifique os dados da sessão para filtrar e retire a função postData.
AG

Ola Nataniel bom dia obrigado pela ajuda funcionou perfeitamente. Vi um post seu para chamar o onReload dentro de uma function static.

TApplication::loadPage(__CLASS__,'onReload');

Ai foi de boa.

Obrigado
RI

Boa noite Anderson!

Sou iniciante com o Adianti Studio, e pesquisando sobre o problema de calendário filtrando por usuário logado, ou pessoa específica encontrei o seu post.
É possível você postar o script dessa parte que vc enviou já com as correções sugeridas pelo colega?
Obrigado.
AG

/**
* Reconfigure the callendar
*/
public function onReload($param = null)
{
if (isset($param['view']))
{
$this->fc->setCurrentView($param['view']);
}

if (isset($param['date']))
{
$this->fc->setCurrentDate($param['date']);
}

if ( (TSession::getValue('profissional_id') != '') )
{
$data = new stdClass;
$data->profissional_id = TSession::getValue('profissional_id');
$this->form->setData( $data );
}
}