<?php

namespace Drupal\restaurant_bookings\Form\Ajax;

use Drupal\restaurant_bookings\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 Ajax 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 'ajax_front';
  }

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

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

      if (! \Drupal::currentUser()->isAuthenticated()) {
          header("HTTP/1.1 401 Unauthorized");
          exit;
      }
    } 
    
    return;
    
    $html = '<div id="bookings-left-col">left col';
    $html .= '</div>';
    
    	$html .= '<div id="bookings-right-col">';
    
    	 $form['padd1'] = array(
        '#type' => 'markup',
        '#markup' => '<div class="padd2">hello world'
    		);
			$form['left'] = array(
				'#type' => 'markup',
				'#markup' => $testing
			); 
    		$form['padd2'] = array(
        		'#type' => 'markup',
        		'#markup' => '</div>'
    		);
    
    
    $form['html'] = array(
        '#type' => 'markup',
        '#markup' => $html
    );
    
    return $form;
    
    
    

    $form['padd1'] = array(
        '#type' => 'markup',
        '#markup' => '<div class="padd2">'
    );
    $form = FormElements::Guests($form, array(), array('title' => 'Booking for <span id="guests">1</span> <span id="persons">person</span>'));
    $form['padd2'] = array(
        '#type' => 'markup',
        '#markup' => '</div>'
    );
    return $form;
    
    
    
    
    $top = '<div id="bookings-left-col">';
    $form['top'] = array(
        '#type' => 'markup',
        '#markup' => t($top)
    );
    
    $form['padd1'] = array(
        '#type' => 'markup',
        '#markup' => '<div class="padd2">'
    );
    $form = FormElements::Guests($form, array(), array('title' => 'Booking for <span id="guests">1</span> <span id="persons">person</span>'));
    $form['padd2'] = array(
        '#type' => 'markup',
        '#markup' => '</div>'
    );
    
    
    $form['htmlcalendar-wrap'] = array(
        '#type' => 'markup',
        '#markup' => '<div id="htmlcalendar-top">'
    );
    $form = FormElements::HtmlCalendar($form);
    $form['htmlcalendar-bottom'] = array(
        '#type' => 'markup',
        '#markup' => '</div>'
    );
    
    
    $leftcol = '</div><!-- end bookings-left-col -->';
    $form['left-col'] = array(
        '#type' => 'markup',
        '#markup' => t($leftcol)
    );
    
    $rightcol = '<div id="bookings-right-col" class="padd">';
    $form['rightcol'] = array(
        '#type' => 'markup',
        '#markup' => t($rightcol)
    );
    
    $bookings = new Booking($this->conn);
    $date = date('Y-m-d');
    $times = $bookings->getTimes($date, false);
    $bookings->filterTimes($times, $date, 2);
    
    $form = FormElements::BookingTimes($form, array('times' => $times, 'date' => $date), $this->inAdminPath());
    
    
    $rightend = '</div><!-- end bookings-right-col-->';
    $form['rightend'] = array(
        '#type' => 'markup',
        '#markup' => t($rightend)
    );

    return $form;

  }

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

  }

}