<?php

namespace Drupal\restaurant_bookings\Form\Ajax;

use Drupal\Core\Form\FormBase;
use Drupal\Core\Form\FormStateInterface;
use Drupal\restaurant\Form\AppForm;
use Drupal\restaurant\Bookings\Booking;
use Drupal\restaurant\Form\MultipartForm;
use Drupal\restaurant_bookings\Form\Elements\BookingTimes;
use Drupal\restaurant_bookings\Form\FormElements;

class Calendar extends MultipartForm {

  /**
   * Returns a unique string identifying the form.
   *
   * The returned ID should be a unique string that can be a valid PHP function
   * name, since it's used in hook implementation names such as
   * hook_form_FORM_ID_alter().
   *
   * @return string
   *   The unique string identifying the form.
   */
  public function getFormId()
  {
    return 'calendar_div';
  }

  public function buildForm(array $form, FormStateInterface $form_state)
  {
    if ($this->getSetting('requirelogin')) {

      if (! \Drupal::currentUser()->isAuthenticated()) {
          header("HTTP/1.1 401 Unauthorized");
          exit;
      }
    }

    $form['#cache']['max-age'] = 0;

    $timestamp = (! $this->hasParam('timestamp')) ? time() : $this->getParam('timestamp');
    $this->getSession()->set('date', $timestamp);

    $form = FormElements::HtmlCalendar($form, $timestamp);


	return $form;

  }

  public function submitForm(array &$form, FormStateInterface $form_state){}

}
