<?php
namespace App\Controller;
use JMS\DiExtraBundle\Annotation as DI;
//use JMS\Payment\CoreBundle\Entity\Payment;
//use JMS\Payment\CoreBundle\PluginController\Result;
//use JMS\Payment\CoreBundle\Plugin\Exception\ActionRequiredException;
//use JMS\Payment\CoreBundle\Plugin\Exception\Action\VisitUrl;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Request;
use Knp\Bundle\SnappyBundle\Snappy\Response\PdfResponse;
use Symfony\Component\HttpFoundation\Session\SessionInterface;
use Symfony\Component\Security\Http\Authentication\AuthenticationUtils;
use App\Repository\EventsRepository;
use App\Entity\Orders;
use App\Entity\OrderItems;
use App\Entity\OrderTickets;
use App\Entity\Events;
use App\Entity\EventDates;
use App\Entity\EventTickets;
use App\Entity\EventExtra;
use App\Entity\Sites;
use App\Entity\Language;
use App\Entity\Coupons;
use App\Entity\StatsUsers;
//use Yectep\PhpSpreadsheetBundle\Factory;
/**
* @Route("/",
* name="scan_base",
* condition="request.headers.get('Host') matches '/scan\./i'"
* )
*/
class ScanController extends Controller {
/**
* @Route("/", name = "scan_home")
*/
public function homeAction(Request $request) {
$domain = $request->headers->get('Host');
//return new JsonResponse(array("domain"=>$domain));
return $this->render("scan/index.html.twig",array("event"=>""));
}
/**
* @Route("/scan/list", name = "scan_list")
*/
public function listAction(Request $request) {
//$domain = $request->headers->get('Host');
//return new JsonResponse(array("domain"=>$domain));
}
/**
* @Route("/scan/login", name = "scan_login")
*/
public function loginAction(Request $request, AuthenticationUtils $authenticationUtils) {
//$username = $request->request->get('username');
$code = $request->request->get('code');
$manager = $this->getDoctrine()->getManager();
$repo = $manager->getRepository(StatsUsers::class);
$result = $repo->findOneByCode($code);
if(!($result instanceof StatsUsers)) {
return new JsonResponse(array("result"=>false,"message"=>"UNAUTHORIZED","level"=>"error"));
}
if(false === $result->getScanAccess()) {
return new JsonResponse(array("result"=>false,"message"=>"UNAUTHORIZED","level"=>"error"));
}
if(false === $result->getIsActive()) {
return new JsonResponse(array("result"=>false,"message"=>"UNAUTHORIZED","level"=>"error"));
}
// We have a user object and its active AND has scan access...
// However, if the user has no API key, its no use, so check for it!
if(false === ($api = $result->getApiKey())) {
return new JsonResponse(array("result"=>false,"message"=>"UNAUTHORIZED","level"=>"error"));
}
// We've also got an API key, now we're getting somewhere....
$responseData = array(
'key' => $api->getKey(),
'result' => true,
);
return new JsonResponse($responseData);
}
/**
* @Route("/scan/{event}", name = "scan_event")
*/
public function scanAction(Request $request, Events $event) {
$dates = $event->getDates();
return new JsonResponse(array(
'dates' => $dates->toArray()
));
}
/**
* @Route("/scan/{event}/{eventdate}", name = "scan_event_date")
*/
public function scanDateAction(Request $request, Events $event, EventDates $eventdate) {
return $this->render("scan/index.html.twig",array("event"=>$event,"eventdate"=>$eventdate));
}
/**
* @Route("/scan/logout", name = "scan_logout")
*/
public function logoutAction(Request $request) {
}
}