<?php

namespace Drupal\restaurant_bookings\Form\Ajax;

use Drupal\restaurant_bookings\Form;
//use Drupal\restaurant\Form;
use Drupal\Core\Form\FormBase;
use Drupal\Core\Form\FormStateInterface;
use Drupal\restaurant\Form\AppForm;
use Drupal\restaurant\Bookings\Booking;
use Symfony\Component\HttpFoundation\Session\Session;
use Drupal\restaurant\Form\MultipartForm;

use Drupal\restaurant_bookings\Form\FormElements;
use Drupal\restaurant\Form\Heading;


/**
* BOOKINGS FORM STEP 1
*/
class FormFront extends AppForm
{
  /**
   * 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 'form_ajax_front';
  }

  public function buildForm(array $form, FormStateInterface $form_state)
  {

    if ($this->getSetting('requirelogin')) {

      if (! \Drupal::currentUser()->isAuthenticated()) {
        $this->addMessage($this->t('Login required to make a booking'), 'error')->http_redirect('/user/login');
      }
    }

    /*$form['top'] = array(
    	'#type' => 'markup',
    	'#markup' => '<div id="bookings-div"></div>'
    ); */

    $this->getSession()->set('guests', 2);
    $this->getSession()->set('date', time());

    $form = FormElements::Front($form, $this->getSession()->get('date'), $this->getSession()->get('guests'), $this->inAdminPath());
	return $form;

    //$form['#action'] = '/somepath';

    //mydump ($form);


    return $form;

  }

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

  }

}
