src/Controller/User/DefaultController.php line 35

Open in your IDE?
  1. <?php
  2. namespace App\Controller\User;
  3. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  4. use Symfony\Component\Routing\Annotation\Route;
  5. use App\Services\GainpfEmpHelper;
  6. use App\Services\LoanFunctions;
  7. use Symfony\Component\HttpFoundation\Request;
  8. use Symfony\Component\HttpFoundation\Response;
  9. use App\Entity;
  10. use Symfony\Component\HttpFoundation\JsonResponse;
  11. //use Security\AppSecurity\Security\Keys\SecuredLoginKeys;
  12. use App\Security\Keys\SecuredLoginKeys;
  13. use App\Interfaces\AuditableControllerInterface;
  14. use Symfony\Component\HttpFoundation\Session\Session;
  15. use App\Form;
  16. use Symfony\Component\Form\FormError;
  17. use Symfony\Component\Form\FormEvents;
  18. use Symfony\Component\Form\FormEvent;
  19. use Doctrine\ORM\EntityRepository;
  20. class DefaultController extends AbstractController implements \App\Interfaces\AuditableControllerInterface
  21. {
  22.     private $GainpfEmpHelper;
  23.     public function __construct(GainpfEmpHelper $GainpfEmpHelper,LoanFunctions $LoanFunctions)
  24.     {
  25.         $this->GainpfEmpHelper $GainpfEmpHelper;
  26.         $this->LoanFunctions $LoanFunctions;
  27.     }  
  28.     /**
  29.         * @Route("/", name="_index")
  30.     */
  31.     public function indexAction()
  32.     {  
  33.         return $this->redirect($this->generateUrl('app_home'));
  34.         //return $this->render('User/Default/index.html.twig');
  35.         $user $this->container->get('security.token_storage')->getToken()->getUser();
  36.         $paoid $this->GainpfEmpHelper->getPao()->getId();
  37.         $objEntityManager $this->getDoctrine()->getManager();
  38.         $level $this->GainpfEmpHelper->getLevelCode();
  39.         $passwordStatus $this->GainpfEmpHelper->getUserPasswordStatus();
  40.           if ($passwordStatus == 0) {
  41.             return $this->redirectToRoute("change_password_forced");
  42.         }
  43.         if (!$level) {
  44.         $paocdWithotPfno $this->GainpfEmpHelper->getPaocdWithotPfno();
  45.             if($paocdWithotPfno){
  46.                 $error[] = array('info' => 'danger''data' => 'Your department id not yet set. Please update it from principal login');
  47.                 return $this->render('bene_dashboard/pages/dash_bene_error.html.twig', array('data' => $error));
  48.             } else{
  49.                 return $this->render('Dashboard/error.html.twig');
  50.             }
  51.         } else {
  52.             $level $level->getId();
  53.         }
  54.         if ($user->hasRole('ROLE_PAO_ADMIN')) {
  55.             $query $objEntityManager->getRepository('App:MasterGainpfPao')->findOneBy(array('id' => $paoid));
  56.             $paoName $query->getPaoDescrption();
  57.             return $this->render('Dashboard/admin.html.twig', array('paoName' => $paoName));
  58.         } elseif ($user->hasRole('ROLE_PAO_EMPLOYEE') || $user->hasRole('ROLE_OFFICE_ADMIN') || $user->hasRole('ROLE_OFFICE_EO_EMP') || $user->hasRole('ROLE_RO_USER')) {
  59.             $userDetails $this->GainpfEmpHelper->getUserDetails();
  60.             return $this->render('bene_dashboard/employee_dashboard_page.html.twig', array('userDetails' => $userDetails));
  61.         } else if ($user->hasRole('ROLE_INST_EMP')) {
  62.             return $this->redirectToRoute("beneficiary_home");
  63.         } elseif ($user->hasRole('ROLE_OFFICE_EO_ADMIN') || $user->hasRole('ROLE_RO_ADMIN')) {
  64.             $userDetails $this->GainpfEmpHelper->getUserDetails();
  65.             return $this->render('Dashboard/aeoadmin.html.twig', array('userDetails' => $userDetails));
  66.         } elseif ($user->hasRole('ROLE_OFFICE_EO_EMP')) {
  67.             return $this->render('Dashboard/aeoemp.html.twig');
  68.         } elseif ($user->hasRole('ROLE_INST_ADMIN')) {
  69.             $userDetails $this->GainpfEmpHelper->getUserDetails();
  70.             return $this->render('Dashboard/employeeInst.html.twig', array('userDetails' => $userDetails));
  71.         } elseif ($user->hasRole('ROLE_GOVT_HM')) {
  72.             $userDetails $this->GainpfEmpHelper->getUserDetails();
  73.             return $this->render('bene_dashboard/employee_dashboard_page.html.twig', array('userDetails' => $userDetails));
  74.         } elseif ($user->hasRole('ROLE_FINANCE')) {
  75.             $userDetails $this->GainpfEmpHelper->getUserDetails();
  76.             return $this->render('bene_dashboard/employee_dashboard_page.html.twig', array('userDetails' => $userDetails));
  77.         } elseif ($user->hasRole('ROLE_OFFICE_EMP')) {
  78.             $type = array();
  79.             $type[0] = 0;
  80.             $type[1] = $paoid;
  81.             $em $this->getDoctrine()->getManager();
  82.             $officeId $this->GainpfEmpHelper->getOffice()->getId();
  83.             $em $this->getDoctrine()->getManager();
  84.             $userDetails $this->GainpfEmpHelper->getUserDetails();
  85.             $level $this->GainpfEmpHelper->getLevel()->getLevelCode()->getId();
  86.             $office $this->GainpfEmpHelper->getOffice()->getId();
  87.             $paoId $this->GainpfEmpHelper->getPao();
  88.             //-------------Dashboard requirements-----------------------
  89.             $statistics $em->getRepository('App:Statistics\Statistics')->findOneBy(['level' => $level'officeId' => $office]);
  90.             if ($statistics) {
  91.                 $data = array();
  92.                 $jsonDecodedContent json_decode($statistics->getContent());
  93.                 $data['Pending Loans'] = ['count' => $jsonDecodedContent->pending_loan'icon' => 'fa-file-text''bg' => 'bg-aqua''url' => 'pendingLoans_arrears'];
  94.                 $data['Sanctioned Loans'] = ['count' => $jsonDecodedContent->sanctioned'icon' => 'fa-check''bg' => 'bg-red''url' => 'paoadmin_DDOSanctiondist'];
  95.                 $data['Pending Credit'] = ['count' => $jsonDecodedContent->pending_credit'icon' => 'fa-file-text''bg' => 'bg-green''url' => 'credit_data_pending_acceptance'];
  96.                 $data['Pending Debit'] = ['count' => $jsonDecodedContent->pending_debit'icon' => 'fa-file-text''bg' => 'bg-blue''url' => 'debit_data_pending_acceptance'];
  97.                 $data['Credit data to be verified'] = ['count' => $jsonDecodedContent->not_ver_credit'icon' => 'fa fa-tasks''bg' => 'bg-aqua''url' => 'credit_data_pending_verification'];
  98.                 $data['Debit data to be verified'] = ['count' => $jsonDecodedContent->not_ver_debit'icon' => 'fa fa-tasks''bg' => 'bg-green''url' => 'debit_data_pending_verification'];
  99.                 $seatObj $em->getRepository('App:GainpfSeatPanel')->findByEmpId($userDetails);
  100.                 if ($seatObj) {
  101.                     $seat = array();
  102.                     foreach ($seatObj as $soffices) {
  103.                         $seat[] = $soffices->getSeatId()->getId();
  104.                     }
  105.                 } else {
  106.                     $seat '';
  107.                 }
  108.                 if ($seat != '') {
  109.                     $offices $em->getRepository('App:MasterGainpfoffice')->getOfficesForCreditData($seat$office);
  110.                     foreach ($offices as $office) {
  111.                         //  $OfficeWithCode['All'] = '--All--';
  112.                         $OfficeWithCode[$office['id']] = $office['officeCd'] . '-' $office['officeName'];
  113.                     }
  114.                     $a[] = array_keys($OfficeWithCode);
  115.                     foreach (array_shift($a) as $one) {
  116.                         $b[] = $one;
  117.                     }
  118.                     $summaryCredit $em->getRepository('App:GainpfCreditbillsSummaryTemp')->getSummaryAllDash($paoId$b);
  119.                     $data['Credit data to be verified in Seat'] = ['count' => $summaryCredit'icon' => 'fa fa-tasks''bg' => 'bg-green''url' => 'credit_data_pending_verification_seat'];
  120.                     $summaryDebit $em->getRepository('App:GainpfDebitbillSummary')->getSummaryAllDash($paoId$b);
  121.                     $data['Debit data to be verified in Seat'] = ['count' => $summaryDebit'icon' => 'fa fa-tasks''bg' => 'bg-red''url' => 'debit_data_pending_verification_seat'];
  122.                 }
  123.             } else {
  124.                 return $this->render('bene_dashboard/employee_dashboard_page.html.twig', array('userDetails' => $userDetails));
  125.             }
  126.             //-----------------------------------------------------------
  127.             return $this->render('bene_dashboard/employee_clone_page.html.twig', array('userDetails' => $userDetails'data' => $data));
  128.         }
  129.     }
  130.     /**
  131.      * @Route("portal/paoadmin/reportList/", name="creditDebit_listing1")
  132.      */
  133.     public function reportListAction()
  134.     {
  135.         $em $this->getDoctrine()->getManager();
  136.         for ($i 8$i <= 19$i++) {
  137.             //            $year[$i] = $em->getRepository('AppBundle:GainpfCreditbills')->getDistYear($i);
  138.             $bills[$i] = $em->getRepository('App:GainpfCreditbills')->getBillsNew($i);
  139.         }
  140.         return $this->render('Default/creditDebitReport.html.twig', array('bills' => $bills));
  141.     }
  142. }