/
var
/
www
/
html
/
boaz2
/
src
/
Controller
/
Upload File
HOME
<?php namespace App\Controller; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route; use App\Entity\ReleaseOrder; class DefaultController extends AbstractController { // public function indexAction($name) // { // $message = \Swift_Message::newInstance() // ->setSubject('Hello Email') // ->setFrom('send@example.com') // ->setTo('recipient@example.com') // ->setBody( // $this->renderView( // // app/Resources/views/Emails/registration.html.twig // 'Emails/registration.html.twig', // array('name' => $name) // ), // 'text/html' // ) // /* // * If you also want to include a plaintext version of the message // ->addPart( // $this->renderView( // 'Emails/registration.txt.twig', // array('name' => $name) // ), // 'text/plain' // ) // */ // ; // $this->get('mailer')->send($message); // return $this->render(...); // } /** * @Route("/dashboard", name="dashboard") */ public function dashboard() { $user = $this->getUser(); if ($user->getRole() !== 'REP') { $date = date('m/d/Y'); $release = $this->getDoctrine()->getRepository(ReleaseOrder::class)->findTotalByDate($date, $date); $month = $this->getDoctrine()->getRepository(ReleaseOrder::class)->findTotalByDate(date('m-01-Y'), $date); return $this->render('users/admin.html.twig', ['title' => 'ADMIN', 'today' => $release, 'month' => $month]); }else { return $this->redirectToRoute('loading'); } } /** * @Route("/index", name="home") */ public function index() { $user = $this->getUser(); if ($user->getRole() !== 'REP') { $today = new \DateTime("today"); $now = new \DateTime(); $firstMonth = new \DateTime('first day of this month 00:00:00'); $firstYear = new \DateTime('first day of january this year 00:00:00'); $release = $this->getDoctrine()->getRepository(ReleaseOrder::class)->findTotalByDate($today, $now); $month = $this->getDoctrine()->getRepository(ReleaseOrder::class)->findTotalByTime($firstMonth, $now, $today); $year = $this->getDoctrine()->getRepository(ReleaseOrder::class)->findTotalByTime($firstYear, $now, $today); $ago = $this->getDoctrine()->getRepository(ReleaseOrder::class)->findTotalByProduct($firstMonth, $now, $today, $firstYear, 'AGO'); $pms = $this->getDoctrine()->getRepository(ReleaseOrder::class)->findTotalByProduct($firstMonth, $now, $today, $firstYear, 'PMS'); $dpk = $this->getDoctrine()->getRepository(ReleaseOrder::class)->findTotalByProduct($firstMonth, $now, $today, $firstYear, 'DPK'); return $this->render('users/admin.html.twig', ['title' => 'ADMIN', 'today' => $release, 'month' => $month, 'year' => $year, 'ago' => $ago, 'pms' => $pms, 'dpk' => $dpk]); }else { return $this->redirectToRoute('loading'); } } /** * @Route("/", name="redirect") */ public function redirectAction() { $user = $this->getUser(); if ($user) { return $this->redirectToRoute('home'); }else { return $this->redirectToRoute('login'); } } }