src/Controller/NobleController.php line 103

Open in your IDE?
  1. <?php
  2. namespace App\Controller;
  3. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  4. use Symfony\Component\HttpFoundation\Response;
  5. use Symfony\Component\HttpFoundation\Request;
  6. use Symfony\Component\HttpFoundation\JsonResponse;
  7. use Symfony\Component\Routing\Annotation\Route;
  8. use Symfony\Component\HttpFoundation\Session\Session;
  9. use App\Entity\Contact;
  10. use App\Entity\PushCause;
  11. class NobleController extends AbstractController
  12. {
  13.     /**
  14.      * @Route("/", name="sajong_ecom_index")
  15.      */
  16.     public function index(Request $request)
  17.     {
  18.         $em $this->getDoctrine()->getManager();
  19.         $session $request->getSession();
  20.         if(!empty($session->get('mycity'))) {
  21.           $city $em->getRepository('App\Entity\City')->findOneByName($session->get('mycity'));
  22.           $brands $em->getRepository('App\Entity\Brand')->findBy(['city'=>$city->getId(), 'status'=>1], ['access'=>'DESC']);
  23.         }
  24.         else {
  25.           $brands $em->getRepository('App\Entity\Brand')->findBy(['status'=>1], ['access'=>'DESC']);
  26.         }
  27.         return $this->render('ecom/index.html.twig', array('brands'=> $brands));
  28.     }
  29.     
  30.     /**
  31.      * @Route("/selectcity/{city}", name="sajong_ecom_city_select")
  32.      */
  33.     public function selectcity(Request $request$city)
  34.     {
  35.         $em $this->getDoctrine()->getManager();
  36.         $session $request->getSession();
  37.         $session->set('mycity'$city);
  38.         return new JsonResponse(array('success'=>'City selected successfully'));
  39.     }
  40.     
  41.     /**
  42.      * @Route("/city/{city}", name="sajong_ecom_city_brands")
  43.      */
  44.     public function citybrands(Request $request$city)
  45.     {
  46.         $em $this->getDoctrine()->getManager();
  47.         $session $request->getSession();
  48.         $session->set('mycity'$city);
  49.         $city $em->getRepository('App\Entity\City')->findOneByName($session->get('mycity'));
  50.         $brands $em->getRepository('App\Entity\Brand')->findBy(['city'=>$city->getId(), 'status'=>1], ['access'=>'DESC']);
  51.         return $this->render('ecom/citybrands.html.twig', array('brands'=> $brands));
  52.     }
  53.     
  54.     /**
  55.      * @Route("/brand/{brand}", name="sajong_ecom_brand_categories")
  56.      */
  57.     public function brandcategories(Request $request$brand)
  58.     {
  59.         $em $this->getDoctrine()->getManager();
  60.         $session $request->getSession();
  61.         $brandid explode("_"$brand);
  62.         //$categories = $em->getRepository('App\Entity\Style')->findBy(['brand'=>$brandid[count($brandid)-1], 'status'=>1]);
  63.         return $this->render('ecom/brandcategories.html.twig', array('categories'=> $brandid));
  64.     }
  65.     
  66.     /**
  67.      * @Route("/about", name="sajong_ecom_about")
  68.      */
  69.     public function about()
  70.     {
  71.         return $this->render('ecom/about.html.twig');
  72.     }
  73.     
  74.     /**
  75.      * @Route("/faq", name="sajong_ecom_faq")
  76.      */
  77.     public function faq()
  78.     {
  79.         $em $this->getDoctrine()->getManager();
  80.         $faq_categories $em->getRepository('App\Entity\FaqCategory')->findByStatus(1);
  81.         $faq = array();
  82.         foreach ($faq_categories as $fc) {
  83.           $faq[$fc->getId()] = $em->getRepository('App\Entity\Faq')->findBy(['category'=>$fc->getId(), 'status'=>1]);
  84.         }
  85.         return $this->render('ecom/faq.html.twig', ['faq_categories'=>$faq_categories'faqs'=>$faq]);
  86.     }
  87.     
  88.     /**
  89.      * @Route("/blogs", name="sajong_ecom_blogs")
  90.      */
  91.     public function blogs()
  92.     {
  93.         return $this->render('ecom/blogs.html.twig');
  94.     }
  95.     
  96.     /**
  97.      * @Route("/contact", name="sajong_ecom_contact")
  98.      */
  99.     public function contact()
  100.     {
  101.         return $this->render('ecom/contact.html.twig');
  102.     }
  103.     
  104.     /**
  105.      * @Route("/nn/save/contact", name="sajong_ecom_save_contact")
  106.      */
  107.     public function savecontact(Request $request)
  108.     {
  109.       if($this->isCsrfTokenValid('contact_form'$request->get('form_token'))) {
  110.         $em $this->getDoctrine()->getManager();
  111.         $contact = new Contact();
  112.         $contact->setCreated(new \DateTime()); 
  113.         $this->addFlash('success''Thank you for contacting us. We will get in touch with you shortly.');
  114.         $contact->setName($request->get('name')); 
  115.         $contact->setEmail($request->get('email')); 
  116.         $contact->setPhone($request->get('phone')); 
  117.         $contact->setTitle($request->get('subject')); 
  118.         $contact->setDescription($request->get('description')); 
  119.         $contact->setNotes(''); 
  120.         $contact->setUid(0); 
  121.         $contact->setAttachments(''); 
  122.         $contact->setStage('Initiated'); 
  123.         $contact->setUpdated(new \DateTime()); 
  124.         $contact->setStatus(1); 
  125.         $em->persist($contact);
  126.         $em->flush();
  127.       }
  128.       else {
  129.         $this->addFlash('success''Your token is expired. Please try again.');
  130.       }
  131.       return $this->redirect($this->generateUrl('sajong_ecom_contact'));
  132.     }
  133.     
  134.     /**
  135.      * @Route("/admin/contacts", name="sajong_ecom_admin_contacts")
  136.      */
  137.     public function admincontacts()
  138.     {
  139.         return $this->render('admin/contacts.html.twig');
  140.     }
  141.     
  142.     /**
  143.      * @Route("/admin/nn/save/contact", name="sajong_ecom_admin_save_contact")
  144.      */
  145.     public function adminsavecontact(Request $request)
  146.     {
  147.         $em $this->getDoctrine()->getManager();
  148.         if(!empty($request->get('contactid'))) {
  149.             $contact $em->getRepository('App\Entity\Contact')->find($request->get('contactid'));
  150.             $this->addFlash('success''Contact updated successfully');
  151.         }
  152.         else {
  153.             $contact = new Contact();
  154.             $contact->setCreated(new \DateTime()); 
  155.             $this->addFlash('success''Contact added successfully');
  156.         }
  157.         $contact->setEmail($request->get('email')); 
  158.         $contact->setPhone($request->get('phone')); 
  159.         $contact->setTitle($request->get('title')); 
  160.         $contact->setDescription($request->get('description')); 
  161.         $contact->setNotes($request->get('notes')); 
  162.         $contact->setUid(0); 
  163.         $contact->setAttachments($request->get('attachments')); 
  164.         $contact->setStage($request->get('stage')); 
  165.         $contact->setUpdated(new \DateTime()); 
  166.         $contact->setStatus($request->get('status')); 
  167.         $em->persist($contact);
  168.         $em->flush();
  169.         return $this->redirect($this->generateUrl('sajong_ecom_list_contact'));
  170.     }
  171.     
  172.     /**
  173.      * @Route("/inquiry", name="sajong_ecom_inquiry")
  174.      */
  175.     public function inquiry()
  176.     {
  177.         return $this->render('ecom/inquiry.html.twig');
  178.     }
  179.     
  180.     /**
  181.      * @Route("/rules", name="sajong_ecom_rules")
  182.      */
  183.     public function rules()
  184.     {
  185.         return $this->render('ecom/rules.html.twig');
  186.     }
  187.     
  188.     /**
  189.      * @Route("/privacy", name="sajong_ecom_privacy")
  190.      */
  191.     public function privacy()
  192.     {
  193.         return $this->render('ecom/privacy.html.twig');
  194.     }
  195.     
  196.     /**
  197.      * @Route("/terms", name="sajong_ecom_terms")
  198.      */
  199.     public function terms()
  200.     {
  201.         return $this->render('ecom/terms.html.twig');
  202.     }
  203.     
  204.     /**
  205.      * @Route("/disclosure", name="sajong_ecom_disclosure")
  206.      */
  207.     public function disclosure()
  208.     {
  209.         return $this->render('ecom/disclosure.html.twig');
  210.     }
  211.     
  212.     /**
  213.      * @Route("/ajax/department/{institute}", name="sajong_ecom_ajax_department")
  214.      */
  215.     public function ajaxdepartment($institute)
  216.     {
  217.         $em $this->getDoctrine()->getManager();
  218.         $department $em->getRepository('App\Entity\Department')->findByInstituteId($institute);
  219.         $results = array();
  220.         foreach($department as $d) {
  221.             $results[] = array('label' => $d->getName(), 'value' => $d->getName(), 'id'=> $d->getId()); 
  222.         }
  223.         return new JsonResponse($results);
  224.     }
  225. }