<?php

namespace Drupal\restaurant_settings\Controller;

use Drupal\restaurant\Controller\AppController;
use Drupal\restaurant\Date\Date;
use Drupal\restaurant_settings\Form\General;

class RestaurantSettingsController extends AppController
{

  public function __construct()
  {
    parent::__construct();
    $this->setPath('restaurant_settings' . DIRECTORY_SEPARATOR . 'HtmlScripts' . DIRECTORY_SEPARATOR);
  }

  public function index()
  {
    //return new \Symfony\Component\HttpFoundation\Response('<p>hello world</p>');
    return $this->render('index.phtml');
  }

  public function notes()
  {
      $this->view->notes = $this->conn->query("SELECT * FROM restaurant_requirements");
      return $this->render('notes.phtml');
  }

  public function deletenotes()
  {
      if ($this->hasParam('noteid')) {
          $this->conn->delete("restaurant_requirements")
          ->condition('id', $this->getParam('noteid'))
          ->execute();

          $this->addMessage("Requirement removed")->http_redirect('/admin/restaurant/settings/notes');
      }
  }

  public function general()
  {
    $form = \Drupal::formBuilder()->getForm('Drupal\restaurant_settings\Form\General');
    return $form;
    /*print drupal_render($form);
    mydump ($form);
    return $this->render('index.phtml');*/
  }

  public function tables()
  {
    $this->view->tables = $this->conn->query("SELECT * FROM restaurant_tables")->fetchAll();
    return $this->render('tables.phtml');
  }

}
