/
var
/
www
/
html
/
restaurants
/
src
/
Controller
/
Upload File
HOME
<?php namespace App\Controller; use App\Controller\Controller; // use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\Routing\Annotation\Route; use Sensio\Bundle\FrameworkExtraBundle\Configuration\Security; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpFoundation\JsonResponse; use App\Entity\Item; use App\Entity\Groups; use App\Entity\Category; use App\Entity\Orders; use App\Entity\Activity; use App\Entity\Subscription; class DefaultController extends Controller { /** * @Route("/", name="homepage") **/ public function indexAction(Request $request) { return $this->redirectToRoute('app_login'); // return $this->render('Default/index.html.twig'); } /** * @Route("/howto", name="howto") **/ public function howTo() { return $this->render('Default/howto.html.twig'); } /** * @Route("/positems", name="positems") */ public function posItemsAction(Request $request) { $user = $this->getUser()->getId(); $products = $this->getDoctrine() ->getRepository(Item::class)->findPointOfSale($user); $response = new JsonResponse(); $response->setData($products); return $response; } /** * Get all items from database and push to template * @Route("/all", name="get_all") * @return Response */ public function allAction() { $user = $this->getUser(); $cats = $this->getDoctrine()->getRepository(Groups::class)->findAll(); $items = $this->getDoctrine()->getRepository(Item::class)->findAll(); $response = new JsonResponse(); $response->setData($cats); return $response; } /** * @Route("/drinks", name="drinks") */ public function drinksAction(Request $request) { $user = $this->getUser(); // $products = "Mike"; $products = $this->getDoctrine() ->getRepository(Item::class)->findPointOfSaleDrinks(); $response = new JsonResponse(); $response->setData(json_encode($products)); // // set a HTTP response header $response->headers->set('Content-Type', 'application/json'); return $response; // return $this->render('Default/index.html.twig', array('title' => 'EPOS', 'product' => $products)); } /** * @Route("/pos", name="pos") */ public function posAction(Request $request) { $user = $this->getUser()->getId(); $lastOrder = $this->getDoctrine() ->getRepository(Orders::class)->findLastOrder($user); return $this->render('POS/index.html.twig', array('title' => 'EPOS')); } /** * @Route("/pos/drinks", name="posDrinks") */ public function posDrinksAction() { $waiter = $this->getDoctrine() ->getRepository(Staff::class)->findBy(array('role' => 'Waiter')); $table = $this->getDoctrine() ->getRepository(Tables::class)->findAll(); $lastOrder = $this->getDoctrine() ->getRepository(Orders::class)->findLastOrder(); return $this->render('POS/index.html.twig', array('title' => 'EPOS', 'waiter' => $waiter, 'table' => $table)); } }