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

Curso Dominando o Adianti Framework

O material mais completo de treinamento do Framework.
Curso em vídeo aulas + Livro completo + Códigos fontes do projeto ERPHouse.
Conteúdo Atualizado!


Dominando o Adianti Framework 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 );
}
}