src/ApplicationBundle/Controller/HumanResourceController.php line 3038

Open in your IDE?
  1. <?php
  2. namespace ApplicationBundle\Controller;
  3. use ApplicationBundle\ApplicationBundle;
  4. use ApplicationBundle\Constants\AccountsConstant;
  5. use ApplicationBundle\Constants\ConsultancyConstant;
  6. use ApplicationBundle\Constants\HumanResourceConstant;
  7. use ApplicationBundle\Constants\GeneralConstant;
  8. use ApplicationBundle\Constants\MeetingSchedulingConstant;
  9. use ApplicationBundle\Constants\InventoryConstant;
  10. use ApplicationBundle\Constants\UserConstants;
  11. use ApplicationBundle\Entity\AccCheck;
  12. use ApplicationBundle\Entity\AccCostCentre;
  13. use ApplicationBundle\Entity\AccSettings;
  14. use ApplicationBundle\Entity\AttendanceAmendment;
  15. use ApplicationBundle\Entity\CheckFormat;
  16. use ApplicationBundle\Entity\FiscalClosing;
  17. use ApplicationBundle\Entity\HolidayCalendar;
  18. use ApplicationBundle\Entity\HolidayCalendarDates;
  19. use ApplicationBundle\Entity\Questionnaire;
  20. use ApplicationBundle\Entity\Skill;
  21. use ApplicationBundle\Entity\ConsultancyTopic;
  22. use ApplicationBundle\Entity\EvaluationCategory;
  23. use ApplicationBundle\Entity\BonusPolicy;
  24. use ApplicationBundle\Entity\IncrementPolicy;
  25. use ApplicationBundle\Entity\JobRecruitment;
  26. use ApplicationBundle\Entity\EducationQualification;
  27. use ApplicationBundle\Entity\TrainingCourse;
  28. use ApplicationBundle\Entity\EmployeePerformanceEvolution;
  29. use ApplicationBundle\Helper\Generic;
  30. use ApplicationBundle\Modules\User\Users;
  31. use ApplicationBundle\Entity\Brs;
  32. //use Symfony\Bundle\FrameworkBundle\Console\Application;
  33. //use Symfony\Component\Console\Input\ArrayInput;
  34. //use Symfony\Component\Console\Output\NullOutput;
  35. use ApplicationBundle\Interfaces\SessionCheckInterface;
  36. use ApplicationBundle\Modules\Accounts\Accounts;
  37. use ApplicationBundle\Modules\FixedAsset\FixedAsset;
  38. use ApplicationBundle\Modules\Inventory\Inventory;
  39. use ApplicationBundle\Modules\Purchase\Purchase;
  40. use ApplicationBundle\Modules\Sales\Client;
  41. use ApplicationBundle\Modules\Sales\SalesOrderM;
  42. use ApplicationBundle\Modules\System\DeleteDocument;
  43. use ApplicationBundle\Modules\System\DocValidation;
  44. use ApplicationBundle\Modules\System\Email;
  45. use ApplicationBundle\Modules\System\MiscActions;
  46. use ApplicationBundle\Modules\User\Company;
  47. use ApplicationBundle\Modules\System\System;
  48. use ApplicationBundle\TimeService\EntityManagerFactory;
  49. use ApplicationBundle\Modules\System\ApprovalFunction;
  50. use CompanyGroupBundle\Entity\EntityApplicantDetails;
  51. use CompanyGroupBundle\Entity\EntityCreateBlog;
  52. use CompanyGroupBundle\Entity\EntityCreateDocument;
  53. use CompanyGroupBundle\Entity\EntityCreateTopic;
  54. use CompanyGroupBundle\Entity\EntityCountryConsultantRequirements;
  55. use CompanyGroupBundle\Entity\EntityFile;
  56. use CompanyGroupBundle\Entity\EntitySkill;
  57. use CompanyGroupBundle\Entity\PromoCode;
  58. use Symfony\Bundle\FrameworkBundle\Controller\Controller;
  59. use Symfony\Component\HttpFoundation\Request;
  60. use Symfony\Component\HttpFoundation\Response;
  61. use Symfony\Component\HttpFoundation\RedirectResponse;
  62. use Symfony\Component\HttpFoundation\StreamedResponse;
  63. use ApplicationBundle\Entity\AccTransactions;
  64. use ApplicationBundle\Entity\ApplicantDetails;
  65. use ApplicationBundle\Entity\Approval;
  66. use ApplicationBundle\Entity\Branch;
  67. use ApplicationBundle\Entity\Employee;
  68. use ApplicationBundle\Entity\EmployeeAttendance;
  69. use ApplicationBundle\Entity\EmployeeAttendanceLog;
  70. use ApplicationBundle\Entity\EmployeeDetails;
  71. use ApplicationBundle\Entity\EmployeeLeaveApplication;
  72. use ApplicationBundle\Entity\EmployeeLeaveDetails;
  73. use ApplicationBundle\Entity\EmployeeWorkplace;
  74. use ApplicationBundle\Entity\FixedAssetProduct;
  75. use ApplicationBundle\Entity\PayrollPolicy;
  76. use ApplicationBundle\Entity\Payslip;
  77. use ApplicationBundle\Entity\PurchaseOrder;
  78. use ApplicationBundle\Entity\Region;
  79. use ApplicationBundle\Entity\ResignApplication;
  80. use ApplicationBundle\Entity\SalarySegregationPolicy;
  81. use ApplicationBundle\Entity\SalesOrder;
  82. use ApplicationBundle\Entity\ScheduledMeeting;
  83. use ApplicationBundle\Entity\SysDepartment;
  84. use ApplicationBundle\Entity\SysDepartmentPosition;
  85. use ApplicationBundle\Entity\SysUser;
  86. use ApplicationBundle\Entity\WorkHourPolicy;
  87. use CompanyGroupBundle\Entity\EntityApplicantApplicationList;
  88. use ApplicationBundle\Modules\HumanResource\HumanResource;
  89. use CompanyGroupBundle\Modules\ApplicantM;
  90. use DateInterval;
  91. use DatePeriod;
  92. use Symfony\Component\HttpFoundation\JsonResponse;
  93. use Symfony\Component\HttpFoundation\ResponseHeaderBag;
  94. use Symfony\Component\Validator\Constraints\DateTime;
  95. use Ps\PdfBundle\Annotation\Pdf;
  96. use Doctrine\ORM\EntityManager;
  97. use Symfony\Component\Serializer\Encoder\JsonDecode;
  98. use Symfony\Component\Validator\Constraints\Json;
  99. use Google_Client;
  100. use Google_Service_Oauth2;
  101. class HumanResourceController extends GenericController implements SessionCheckInterface
  102. {
  103.     public function AddEmployeeAction(Request $data$id)
  104.     {
  105.         $em $this->getDoctrine()->getManager();
  106.         $skills $em->getRepository(Skill::class)->findAll();
  107.         $consultancyLevel HumanResourceConstant::$consultantLevel;
  108.         if ($id) {
  109.             if ($data->isMethod('GET')) {
  110.                 $Employee $this->getDoctrine()->getRepository(EmployeeDetails::class)->find($id);
  111.                 if (!$Employee) {
  112.                     $this->addFlash(
  113.                         'error',
  114.                         'Invalid User ID!'
  115.                     );
  116.                     return $this->redirectToRoute('add_employee');
  117.                 } else {
  118.                     $EmployeeRes HumanResource::TwigDataForAddEmployee($em$id);
  119.                     $Employee $EmployeeRes['employee'];
  120.                     $EmployeeMain $EmployeeRes['employeeMain'];
  121.                     $sysUserId $em->getRepository(Employee::class)->find($Employee->getId())->getUserId();
  122.                     $existingSysUser $sysUserId $em->getRepository(SysUser::class)->find($sysUserId) : [];
  123.                     $TwigData HumanResource::TwigDataForAddEmployee($em0);
  124.                     return $this->render(
  125.                         'ApplicationBundle:pages/human_resource/input_forms:add_employee.html.twig',
  126.                         array(
  127.                             'page_title' => 'Update Employee',
  128.                             'branches' => $TwigData['branches'],
  129.                             'heads' => Accounts::getLedgerHeadsWithParents($em),
  130.                             'departments' => $TwigData['departments'],
  131.                             'departmentPositions' => $TwigData['departmentPositions'],
  132.                             'regions' => $TwigData['regions'],
  133.                             'supervisors' => $TwigData['supervisors'],
  134.                             'sysUsers' => $TwigData['sysUser'],
  135.                             'EmploymentStatus' => $TwigData['EmploymentStatus'],
  136.                             'sex' => $TwigData['sex'],
  137.                             'BloodGroup' => $TwigData['BloodGroup'],
  138.                             'days' => $TwigData['days'],
  139.                             'employeeMain' => $EmployeeMain,
  140.                             'employee' => $Employee,
  141.                             'skills' => $skills,
  142.                             'existingSysUser' => $existingSysUser,
  143.                             'id' => $id,
  144.                             'default_route' => $EmployeeRes['defaultRoute'],
  145.                             'user_type' => $EmployeeRes['userType'],
  146.                             'user_type_data' => HumanResourceConstant::$userType,
  147.                             'AccountTypes' => $TwigData['AccountType'],
  148.                             'weekends' => explode(','$Employee->getWeeklyHoliday()),
  149.                             'consultancyLevel' => $consultancyLevel,
  150.                             'module_data_array' => $TwigData['module_data_array'],
  151.                             'HasUpdateMode' => true
  152.                         )
  153.                     );
  154.                 }
  155.             } else {
  156.                 $approveHash $data->request->get('approvalHash');
  157.                 $loginId $data->getSession()->get(UserConstants::USER_LOGIN_ID);
  158.                 $isSignatureOk DocValidation::isSignatureOk($em$loginId$approveHash);
  159.                 if ($isSignatureOk) {
  160.                     $CompanyId $this->getLoggedUserCompanyId($data);
  161.                     $isSuccess HumanResource::StoreDataForAddEmployee($em$data$id$CompanyId);
  162.                     if ($isSuccess) {
  163.                         // $EmployeeDetails = $em->getRepository(EmployeeDetails::class)->find($id);
  164.                         $Employee $em->getRepository(Employee::class)->find($id);
  165.                         $sysUserId $Employee->getUserId();
  166.                         $message $this->get('user_module')->updateUser(
  167.                             $sysUserId,
  168.                             $data->request->get('firstname') . " " $data->request->get('lastname'),
  169.                             $data->request->has('email') ? $data->request->get('email') : '_UNCHANGED_',
  170.                             $data->request->has('username') ? $data->request->get('username') : '_UNCHANGED_',
  171.                             $data->request->get('password'),
  172.                             1,
  173.                             $data->request->get('user_type'),
  174.                             $data->request->get('supervisor'),
  175.                             $data->request->get('default_route'),
  176.                             $data->request->get('branch'),
  177.                             $data->request->has('access_module') ? 0,
  178.                             $data->getSession()->get(UserConstants::USER_LOGIN_ID)
  179.                         );
  180.                         // $SysUserRepo = $em->getRepository(SysUser::class);
  181.                         // $SysUser = $SysUserRepo->findOneBy(array(
  182.                         //   'email' => $data->request->get('email')
  183.                         // ));
  184.                         // $isSuccess->setUserId($SysUser->getUserId());
  185.                         // $em->persist($isSuccess);
  186.                         // $em->flush();
  187.                         // $companyData = $message[2];
  188.                         // $emailmessage = (new \Swift_Message('Update to Entity'))
  189.                         //   ->setFrom('registration@entity.innobd.com')
  190.                         //   ->setTo($data->request->get('email'))
  191.                         //   ->setBody(
  192.                         //     $this->renderView(
  193.                         //       'ApplicationBundle:email/user:registration.html.twig',
  194.                         //       array(
  195.                         //         'name' => $data->request->get('name'),
  196.                         //         'companyData' => $companyData,
  197.                         //         'userName' => $data->request->get('email'),
  198.                         //         'password' => $data->request->get('password'),
  199.                         //       )
  200.                         //     ),
  201.                         //     'text/html'
  202.                         //   );
  203.                         // $this->get('mailer')->send($emailmessage);
  204.                         return $this->redirectToRoute('employee_list');
  205.                     }
  206.                 } else {
  207.                     $this->addFlash(
  208.                         'error',
  209.                         'Invalid Approval Hash!'
  210.                     );
  211.                     return $this->redirectToRoute('add_employee');
  212.                 }
  213.             }
  214.         } else {
  215.             if ($data->isMethod('GET')) {
  216.                 $TwigData HumanResource::TwigDataForAddEmployee($em0);
  217.                 return $this->render(
  218.                     'ApplicationBundle:pages/human_resource/input_forms:add_employee.html.twig',
  219.                     array(
  220.                         'page_title' => 'Add Employee',
  221.                         'heads' => Accounts::getLedgerHeadsWithParents($em),
  222.                         'branches' => $TwigData['branches'],
  223.                         'departments' => $TwigData['departments'],
  224.                         'departmentPositions' => $TwigData['departmentPositions'],
  225.                         'regions' => $TwigData['regions'],
  226.                         'supervisors' => $TwigData['supervisors'],
  227.                         'sysUsers' => $TwigData['sysUser'],
  228.                         'EmploymentStatus' => $TwigData['EmploymentStatus'],
  229.                         'sex' => $TwigData['sex'],
  230.                         'skills' => $skills,
  231.                         'consultancyLevel' => $consultancyLevel,
  232.                         'existingSysUser' => null,
  233.                         'BloodGroup' => $TwigData['BloodGroup'],
  234.                         'days' => $TwigData['days'],
  235.                         'AccountTypes' => $TwigData['AccountType'],
  236.                         'module_data_array' => $TwigData['module_data_array'],
  237.                         'user_type_data' => HumanResourceConstant::$userType,
  238.                         'HasUpdateMode' => false,
  239.                     )
  240.                 );
  241.             } else {
  242.                 $approveHash $data->request->get('approvalHash');
  243.                 $loginId $data->getSession()->get(UserConstants::USER_LOGIN_ID);
  244.                 $isSignatureOk DocValidation::isSignatureOk($em$loginId$approveHash);
  245.                 $isUserExist $em->getRepository(EmployeeDetails::class)
  246.                     ->findOneBy(array('email' => $data->request->get('email')));
  247.                 if ($isSignatureOk) {
  248.                     if ($isUserExist) {
  249.                         $this->addFlash(
  250.                             'error',
  251.                             'User Already Exist!'
  252.                         );
  253.                         return $this->redirectToRoute('add_employee');
  254.                     } else {
  255.                         $CompanyId $this->getLoggedUserCompanyId($data);
  256.                         $isSuccess HumanResource::StoreDataForAddEmployee($em$datafalse$CompanyId);
  257.                         if ($isSuccess) {
  258.                             if ($data->request->has('send_appointment')) {
  259.                                 $email $data->request->get('email');
  260.                                 $emailmessage = (new \Swift_Message("Appointment Letter - Honeybee IOT Inc"))
  261.                                     ->setFrom('registration@entity.innobd.com')
  262.                                     ->setTo($email)
  263.                                     ->setBody(
  264.                                         $this->renderView(
  265.                                             'ApplicationBundle:email/general:appointment_letter_test.html.twig',
  266.                                             array()
  267.                                         ),
  268.                                         'text/html'
  269.                                     );
  270.                                 $this->get('mailer')->send($emailmessage);
  271.                             }
  272.                             // Mailer function
  273.                             if ($data->get("send_mail") && empty($data->get('sys_user'))) {
  274.                                 $message $this->get('user_module')->addNewUser(
  275.                                     $data->request->get('firstname') . " " $data->request->get('lastname'),
  276.                                     $data->request->get('email'),
  277.                                     $data->request->get('username'),
  278.                                     $data->request->get('password'),
  279.                                     $data->request->get('desg'),
  280.                                     $this->getLoggedUserLoginId($data),
  281.                                     $data->request->get('company'),
  282.                                     $data->request->get('user_type'),
  283.                                     $data->request->get('companyIdList'),
  284.                                     $data->request->get('branch'),
  285.                                     $data->request->get('supervisor'),
  286.                                     $data->request->get('default_route'),
  287.                                     $data->request->has('access_module') ? 0
  288.                                 );
  289.                                 $SysUserRepo $em->getRepository(SysUser::class);
  290.                                 $SysUser $SysUserRepo->findOneBy(array(
  291.                                     'email' => $data->request->get('email')
  292.                                 ));
  293.                                 $isSuccess->setUserId($SysUser->getUserId());
  294.                                 $em->persist($isSuccess);
  295.                                 $em->flush();
  296.                                 $companyData $message[2];
  297.                                 if ($message[0] == 'success' && GeneralConstant::EMAIL_ENABLED == 1) {
  298.                                     $bodyHtml '';
  299.                                     $bodyTemplate 'ApplicationBundle:email/user:registration.html.twig';
  300.                                     $bodyData = array(
  301.                                         'name' => $data->request->get('name'),
  302.                                         'companyData' => $companyData,
  303.                                         'userName' => $data->request->get('username'),
  304.                                         'password' => $data->request->get('password'),
  305.                                     );
  306.                                     $attachments = [];
  307. //                    $upl_dir = $this->container->getParameter('kernel.root_dir') . '/../web/uploads/temp/' . 'ledger' . '.pdf'
  308.                                     $new_mail $this->get('mail_module');
  309.                                     $new_mail->sendMyMail(array(
  310.                                         'senderHash' => '_USER_MANAGEMENT_',
  311.                                         //                        'senderHash'=>'_CUSTOM_',
  312.                                         'forwardToMailAddress' => $data->request->get('email'),
  313.                                         'subject' => 'User Registration on HoneyBee Ecosystem under Entity ' $companyData->getName(),
  314.                                         'fileName' => '',
  315.                                         'attachments' => $attachments,
  316.                                         'toAddress' => $data->request->get('email'),
  317. //                        'fromAddress'=>'sales@entity.innobd.com',
  318. //                        'userName'=>'sales@entity.innobd.com',
  319. //                        'password'=>'Y41dh8g0112',
  320. //                        'smtpServer'=>'smtp.hostinger.com',
  321. //                        'smtpPort'=>587,
  322. //                        'emailBody'=>$bodyHtml,
  323.                                         'mailTemplate' => $bodyTemplate,
  324.                                         'templateData' => $bodyData,
  325.                                         'embedCompanyImage' => 1,
  326.                                         'companyId' => $data->request->get('company'),
  327.                                         'companyImagePath' => $companyData->getImage()
  328.                                     ));
  329. //                  $emailmessage = (new \Swift_Message('Registration to Entity'))
  330. //                    ->setFrom('registration@entity.innobd.com')
  331. //                    ->setTo($data->request->get('email'))
  332. //                    ->setBody(
  333. //                      $this->renderView(
  334. //                        'ApplicationBundle:email/user:registration.html.twig',
  335. //                        array(
  336. //                          'name' => $data->request->get('name'),
  337. //                          'companyData' => $companyData,
  338. //                          'userName' => $data->request->get('email'),
  339. //                          'password' => $data->request->get('password'),
  340. //                        )
  341. //                      ),
  342. //                      'text/html'
  343. //                    );
  344. //                  $this->get('mailer')->send($emailmessage);
  345.                                 }
  346.                             }
  347.                             // End Mailer function
  348.                             $this->addFlash(
  349.                                 'success',
  350.                                 'New Employee Successfully Added!'
  351.                             );
  352.                             return $this->redirectToRoute('employee_list');
  353.                         } else {
  354.                             $this->addFlash(
  355.                                 'error',
  356.                                 'Something Went Wrong!'
  357.                             );
  358.                             return $this->redirectToRoute('add_employee');
  359.                         }
  360.                     }
  361.                 } else {
  362.                     $this->addFlash(
  363.                         'error',
  364.                         'Invalid Approval Hash!'
  365.                     );
  366.                     return $this->redirectToRoute('add_employee');
  367.                 }
  368.             }
  369.         }
  370.     }
  371.     public function EmployeeListAction(Request $data)
  372.     {
  373.         $em $this->getDoctrine()->getManager();
  374.         $response HumanResource::twigDataForEmpList($em$data);
  375.         if ($data->isMethod('GET')) {
  376.             return $this->render("ApplicationBundle:pages/human_resource/list:list_employee.html.twig", array(
  377.                 'page_title' => 'Employee List',
  378.                 'employeeIds' => $response,
  379.             ));
  380.         }
  381.     }
  382.     public function OrganizationChartAction()
  383.     {
  384.         $em $this->getDoctrine()->getManager();
  385.         $Reponse HumanResource::TwigDataForOrgChart($em);
  386.         return $this->render('ApplicationBundle:pages/human_resource/views:org_chart.html.twig', array(
  387.             'page_title' => 'Organization Chart',
  388.             'supervisors' => $Reponse['TreantJsData'],
  389.             'alluser' => $Reponse['TreantJsInitUser']
  390.         ));
  391.     }
  392.     public function EmployeeListSelectizeAjaxAction(Request $request$str '_EMPTY_')
  393.     {
  394.         $em $this->getDoctrine()->getManager();
  395.         $companyId $this->getLoggedUserCompanyId($request);
  396.         $company_data Company::getCompanyData($em$companyId);
  397.         $data = [];
  398.         $html '';
  399.         $qryStrs explode(' '$str);
  400.         $qryStrAddedForSpacedName "";
  401.         if ($str == '_EMPTY_') {
  402.             $query "SELECT *
  403. from  employee  order by employee_id asc limit 10";
  404.         } else {
  405.             foreach ($qryStrs as $qryStr) {
  406.                 $qryStrAddedForSpacedName .= "or first_name like '%$qryStr%' or last_name like '%$qryStr%' ";
  407.             }
  408.             $query "SELECT  *
  409. from  employee  where" . (is_numeric($str) ? " employee_id =$str " " 1=0 ") . $qryStrAddedForSpacedName " or `name` like '%$str%' or employee_code like '%$str%' order by employee_id asc limit 10";
  410.         }
  411.         $stmt $em->getConnection()->prepare($query);
  412.         $stmt->execute();
  413.         $res $stmt->fetchAll();
  414. //    if(!empty($res)) {
  415.         foreach ($res as $i => $r) {
  416.             $res[$i]['id_padded'] = str_pad($r['employee_id'], 8'0'STR_PAD_LEFT);
  417.         }
  418. //    }
  419.         return new JsonResponse(
  420.             array(
  421.                 'success' => true,
  422.                 'data' => $res,
  423.             )
  424.         );
  425.     }
  426.     public function AttendanceAction(Request $data)
  427.     {
  428.         $em $this->getDoctrine()->getManager();
  429.         $workHourPolicy $em->getRepository('ApplicationBundle:WorkHourPolicy')->findAll();
  430.         $options = array(
  431.             'notification_enabled' => $this->container->getParameter('notification_enabled'),
  432.             'notification_server' => $this->container->getParameter('notification_server'),
  433.         );
  434.         if ($data->get('DataTable')) {
  435.             $response HumanResource::HandelAjaxRequestForManualAttendance($em$data);
  436.             return new JsonResponse($response);
  437.         }
  438.         if ($data->request->get('getAttendanceStatus')) {
  439.             $response HumanResource::getAttendanceStatus($em$data);
  440.             return new JsonResponse($response);
  441.         }
  442.         $session $data->getSession();
  443. //        if ($session->get('devAdminMode', 0) != 1 && $data->get('returnJson', 0) == 0)
  444. //            return $this->redirectToRoute('permission_denied_page');
  445.         // Auto attendance
  446.         if ($data->get('autoAttendance') && $data->request->has('position_array')) {
  447.             $empId $data->query->get('id');
  448.             $positionsArray $data->request->get('position_array', []);
  449.             if (is_string($positionsArray)) $positionsArray json_decode($positionsArraytrue);
  450.             if ($positionsArray == null$positionsArray = [];
  451.             $dataByAttId = [];
  452.             $workPlaceType '_UNSET_';
  453.             foreach ($positionsArray as $d) {
  454.                 $sysUserId 0;
  455.                 $userId 0;
  456.                 $empId 0;
  457.                 $dtTs 0;
  458.                 $timeZoneStr '+0000';
  459. //                $timeZoneStr = '+0600';
  460.                 if (isset($d['employeeId'])) $empId $d['employeeId'];
  461.                 if (isset($d['userId'])) $userId $d['userId'];
  462.                 if (isset($d['sysUserId'])) $sysUserId $d['sysUserId'];
  463.                 if (isset($d['tsMilSec'])) {
  464.                     $dtTs ceil(($d['tsMilSec']) / 1000);
  465.                 }
  466.                 if ($sysUserId == 0)
  467.                     $sysUserId $userId;
  468.                 if ($sysUserId == 0)
  469.                     $sysUserId $em->getRepository(Employee::class)
  470.                         ->findOneBy(['employeeId' => $empId])->getUserId();
  471.                 if ($dtTs == 0) {
  472.                     $currTsTime = new \DateTime();
  473.                     $dtTs $currTsTime->format('U');
  474.                 } else {
  475.                     $currTsTime = new \DateTime('@' $dtTs);
  476.                 }
  477.                 $currTsTime->setTimezone(new \DateTimeZone('UTC'));
  478.                 $attDate = new \DateTime($currTsTime->format('Y-m-d') . ' 00:00:00' $timeZoneStr);
  479.                 $EmployeeAttendance $this->getDoctrine()
  480.                     ->getRepository(EmployeeAttendance::class)
  481.                     ->findOneBy(array('employeeId' => $empId'date' => $attDate));
  482.                 if (!$EmployeeAttendance)
  483.                     $EmployeeAttendance = new EmployeeAttendance;
  484.                 $attendanceInfo HumanResource::StoreAttendance($em$empId$sysUserId$data$EmployeeAttendance$attDate$dtTs$timeZoneStr$d['markerId']);
  485.                 if ($d['markerId'] == HumanResourceConstant::ATTENDANCE_MARKER_CLOCK_IN) {
  486.                     if ($empId == 24)
  487.                         $workPlaceType '_HYBRID_';
  488.                     else
  489.                         $workPlaceType '_STATIC_';
  490.                 }
  491.                 if (!isset($dataByAttId[$attendanceInfo->getId()]))
  492.                     $dataByAttId[$attendanceInfo->getId()] = array(
  493.                         'attendanceInfo' => $attendanceInfo,
  494.                         'empId' => $empId,
  495.                         'lat' => 0,
  496.                         'lng' => 0,
  497.                         'address' => 0,
  498.                         'sysUserId' => $sysUserId,
  499.                         'companyId' => $data->getSession()->get(UserConstants::USER_COMPANY_ID),
  500.                         'appId' => $data->getSession()->get(UserConstants::USER_APP_ID),
  501.                         'positionArray' => []
  502.                     );
  503.                 $posData = array(
  504.                     'ts' => $dtTs,
  505.                     'lat' => $d['lat'],
  506.                     'lng' => $d['lng'],
  507.                     'marker' => $d['markerId'],
  508.                     'src' => 2,
  509.                 );
  510.                 $posDataArray = array(
  511.                     $dtTs,
  512.                     $d['lat'],
  513.                     $d['lng'],
  514.                     $d['markerId'],
  515.                     2
  516.                 );
  517.                 $dataByAttId[$attendanceInfo->getId()]['markerId'] = $d['markerId'];
  518.                 //this markerId will be calclulted and modified to check if user is in our out of office/workplace later
  519.                 $dataByAttId[$attendanceInfo->getId()]['attendanceInfo'] = $attendanceInfo;
  520.                 $dataByAttId[$attendanceInfo->getId()]['positionArray'][] = $posData;
  521.                 $dataByAttId[$attendanceInfo->getId()]['lat'] = $d['lat'];  //for last lat lng etc
  522.                 $dataByAttId[$attendanceInfo->getId()]['lng'] = $d['lng'];  //for last lat lng etc
  523.                 if (isset($d['address']))
  524.                     $dataByAttId[$attendanceInfo->getId()]['address'] = $d['address'];  //for last lat lng etc
  525. //                $dataByAttId[$attendanceInfo->getId()]['positionArray'][]=$posDataArray;
  526.             }
  527.             $response = array(
  528.                 'success' => true,
  529.             );
  530.             foreach ($dataByAttId as $attInfoId => $d) {
  531.                 $response HumanResource::setAttendanceLogFlutterApp($em,
  532.                     $d['empId'],
  533.                     $d['sysUserId'],
  534.                     $d['companyId'],
  535.                     $d['appId'],
  536.                     $data,
  537.                     $d['attendanceInfo'],
  538.                     $options,
  539.                     $d['positionArray'],
  540.                     $d['lat'],
  541.                     $d['lng'],
  542.                     $d['address'],
  543.                     $d['markerId']
  544.                 );
  545.             }
  546.             if ($data->request->get('requestFromMobile')) {
  547.                 $today = new \DateTime(date('y-m-d'));
  548.                 $repository $this->getDoctrine()->getRepository(EmployeeAttendance::class);
  549.                 $ActivitiesTemplate HumanResource::getCurrentStatusFromDb($repository$empId$today);
  550.                 return new JsonResponse(array(
  551.                     'success' => $response['success'] == true true false,
  552.                     'msg' => $response['success'] == true 'Employee activities successfully updated.' 'Action Failed',
  553.                     'workPlaceType' => $workPlaceType,
  554.                     'data' => $ActivitiesTemplate
  555.                 ));
  556.             }
  557.             return new JsonResponse(
  558.                 array(
  559.                     'success' => true,
  560.                     'msg' => 'Employee activities successfully updated.',
  561.                     'workPlaceType' => $workPlaceType,
  562.                 )
  563.             );
  564.         } else if ($data->get('autoAttendance')) {
  565.             $sysUserId 0;
  566.             $userId 0;
  567.             $empId 0;
  568.             $dtTs 0;
  569. //            $timeZoneStr = '+0600';
  570.             $timeZoneStr '+0000';
  571.             if ($data->request->get('requestFromMobile')) {
  572.                 $empId $data->request->get('employeeId');
  573.                 $userId $data->request->get('userId'0);
  574.                 $sysUserId $data->request->get('id'0);
  575. //        $empId = $em->getRepository(Employee::class)
  576. //            ->findOneBy(['userId' => $userId])->getEmployeeId();
  577.             } else {
  578.                 $empId $data->request->get('employeeId'0);
  579.                 $sysUserId $data->request->get('userId'0);
  580.             }
  581.             $dtTs $data->request->get('timeTs'0);
  582.             if ($sysUserId == 0)
  583.                 $sysUserId $userId;
  584.             if ($sysUserId == 0)
  585.                 $sysUserId $em->getRepository(Employee::class)
  586.                     ->findOneBy(['employeeId' => $empId])->getUserId();
  587.             if ($dtTs == 0) {
  588.                 $currTsTime = new \DateTime();
  589.                 $dtTs $currTsTime->format('U');
  590.             } else {
  591.                 $currTsTime = new \DateTime('@' $dtTs);
  592.             }
  593.             if ($sysUserId == 0)
  594.                 $sysUserId $userId;
  595.             if ($sysUserId == 0)
  596.                 $sysUserId $em->getRepository(Employee::class)
  597.                     ->findOneBy(['employeeId' => $empId])->getUserId();
  598.             $today = new \DateTime(date('y-m-d'));
  599.             $currTsTime->setTimezone(new \DateTimeZone('UTC'));
  600.             $attDate = new \DateTime($currTsTime->format('Y-m-d') . ' 00:00:00' $timeZoneStr);
  601.             $EmployeeAttendance $this->getDoctrine()
  602.                 ->getRepository(EmployeeAttendance::class)
  603.                 ->findOneBy(array('employeeId' => $empId'date' => $attDate));
  604.             if (!$EmployeeAttendance)
  605.                 $EmployeeAttendance = new EmployeeAttendance;
  606. //            return new JsonResponse(["success" => true, "data" => $ActivitiesTemplate]);
  607. //            $attendanceInfo = HumanResource::StoreAttendance($em, $empId, $sysUserId, $data, $EmployeeAttendance, $customTime);
  608.             $attendanceInfo HumanResource::StoreAttendance($em$empId$sysUserId$data$EmployeeAttendance$attDate$dtTs$timeZoneStrHumanResourceConstant::ATTENDANCE_MARKER_START_WORKING_FORCED);
  609.             if (!isset($dataByAttId[$attendanceInfo->getId()]))
  610.                 $dataByAttId[$attendanceInfo->getId()] = array(
  611.                     'attendanceInfo' => $attendanceInfo,
  612.                     'empId' => $empId,
  613.                     'lat' => 0,
  614.                     'lng' => 0,
  615.                     'address' => 0,
  616.                     'sysUserId' => $sysUserId,
  617.                     'companyId' => $data->getSession()->get(UserConstants::USER_COMPANY_ID),
  618.                     'appId' => $data->getSession()->get(UserConstants::USER_APP_ID),
  619.                     'positionArray' => []
  620.                 );
  621.             $posData = array(
  622.                 'ts' => $dtTs,
  623.                 'lat' => 0,
  624.                 'lng' => 0,
  625.                 'marker' => HumanResourceConstant::ATTENDANCE_MARKER_START_WORKING_FORCED,
  626.                 'src' => 1,
  627.             );
  628.             $posDataArray = array(
  629.                 $dtTs,
  630.                 0,
  631.                 0,
  632.                 HumanResourceConstant::ATTENDANCE_MARKER_START_WORKING_FORCED,
  633.                 1
  634.             );
  635.             $dataByAttId[$attendanceInfo->getId()]['markerId'] = HumanResourceConstant::ATTENDANCE_MARKER_START_WORKING_FORCED;
  636.             //this markerId will be calclulted and modified to check if user is in our out of office/workplace later
  637.             $dataByAttId[$attendanceInfo->getId()]['attendanceInfo'] = $attendanceInfo;
  638.             $dataByAttId[$attendanceInfo->getId()]['positionArray'][] = $posData;
  639.             $dataByAttId[$attendanceInfo->getId()]['lat'] = 0;  //for last lat lng etc
  640.             $dataByAttId[$attendanceInfo->getId()]['lng'] = 0;  //for last lat lng etc
  641.             if (isset($d['address']))
  642.                 $dataByAttId[$attendanceInfo->getId()]['address'] = '';  //for last lat lng etc
  643.             $response = array(
  644.                 'success' => true
  645.             );
  646.             foreach ($dataByAttId as $attInfoId => $d) {
  647.                 $response HumanResource::setAttendanceLogFlutterApp($em,
  648.                     $d['empId'],
  649.                     $d['sysUserId'],
  650.                     $d['companyId'],
  651.                     $d['appId'],
  652.                     $data,
  653.                     $d['attendanceInfo'],
  654.                     $options,
  655.                     $d['positionArray'],
  656.                     $d['lat'],
  657.                     $d['lng'],
  658.                     $d['address'],
  659.                     $d['markerId']
  660.                 );
  661.             }
  662.             if ($data->request->get('requestFromMobile')) {
  663.                 return new JsonResponse(array(
  664.                     'success' => $response['success'] == true true false,
  665.                     'msg' => $response['success'] == true 'Employee activities successfully updated.' 'Action Failed',
  666.                 ));
  667.             }
  668.             return new JsonResponse(
  669.                 array(
  670.                     'success' => true,
  671.                     'dtTs' => $dtTs,
  672.                     'attDate' => $attDate->format(DATE_RFC822),
  673.                     'currTsTime' => $currTsTime->format(DATE_RFC822),
  674.                     'msg' => 'Employee activities successfully updated.',
  675.                 )
  676.             );
  677. //
  678. //
  679. //            $response = HumanResource::setAttendanceLog($em, $empId, $sysUserId,
  680. //                $data->getSession()->get(UserConstants::USER_COMPANY_ID),
  681. //                $data->getSession()->get(UserConstants::USER_APP_ID),
  682. //                $data, $attendanceInfo, $options);
  683. //
  684. //            if ($data->request->get('requestFromMobile')) {
  685. //                return new JsonResponse($response);
  686. //            }
  687. //
  688. //            return new JsonResponse(
  689. //                array(
  690. //                    'success' => true,
  691. //                    'msg' => 'Employee activities successfully updated.'
  692. //                )
  693. //            );
  694.             // }
  695.             // else {
  696.             //   return new JsonResponse(
  697.             //     array(
  698.             //       'success' => false,
  699.             //       'msg' => "Invalid employee ID"
  700.             //     )
  701.             //   );
  702.             // }
  703.         } else {
  704.             if ($data->get('manualAttendance')) {
  705.                 return $this->render(
  706.                     'ApplicationBundle:pages/human_resource/input_forms:manual_attendance.html.twig',
  707.                     array(
  708.                         'page_title' => 'Manual Attendance',
  709.                         'workPolicy' => $workHourPolicy,
  710. //                        'workTime' => json_decode($workHourPolicy->getRepeatationData()),
  711. //                        'workTime' => json_decode($workHourPolicy->getRepeatationData()),
  712. //                        'workTime' => json_decode($workHourPolicy->getEmployeeTypeIds(),true),
  713.                     )
  714.                 );
  715.             }
  716.             // Show all matching employee list during ajax request
  717.             // Show current location according to id
  718.             if ($data->get('getCurrLocById')) {
  719.                 $Id $data->get("id");
  720.                 $options = array(
  721.                     'employeeId' => $Id,
  722.                     'entityDbaseName' => 'work_hour_policy',
  723.                     'entityDbaseIdField' => 'id',
  724.                     'entityDbaseEmployeeIdsField' => 'employeeIds',
  725.                     'entityDesignationIdsField' => 'designationIds',
  726.                     'entityDepartmentIdsField' => 'departmentIds',
  727.                     'entityEmployeeTypeIdsField' => 'employee_types',
  728.                     'limit' => 1,
  729.                     'single' => 1,
  730.                 );
  731.                 $workHourPolicyData HumanResource::getApplicableSettingsDataForEmployee($em$options);
  732.                 $today = new \DateTime(date('y-m-d'));
  733.                 $repository $this->getDoctrine()->getRepository(EmployeeAttendance::class);
  734.                 $ActivitiesTemplate HumanResource::getActivitiesTemplate($repository$Id$today);
  735.                 return new JsonResponse(["success" => true"workHourPolicyData" => $workHourPolicyData"template" => $ActivitiesTemplate]);
  736.             }
  737.         }
  738.     }
  739.     public function getCurrentStatusAction($id)
  740.     {
  741.         $today = new \DateTime(date('y-m-d'));
  742.         $repository $this->getDoctrine()->getRepository(EmployeeAttendance::class);
  743.         $ActivitiesTemplate HumanResource::getCurrentStatusFromDb($repository$id$today);
  744.         return new JsonResponse(["success" => true"data" => $ActivitiesTemplate]);
  745.     }
  746.     public function CurrentAttendanceAction(Request $data)
  747.     {
  748.         $em $this->getDoctrine()->getManager();
  749.         $options = array(
  750.             'notification_enabled' => $this->container->getParameter('notification_enabled'),
  751.             'notification_server' => $this->container->getParameter('notification_server'),
  752.         );
  753.         if ($data->get('DataTable')) {
  754.             $response HumanResource::HandelAjaxRequestForManualAttendance($em$data);
  755.             return new JsonResponse($response);
  756.         }
  757.         if ($data->request->get('getAttendanceStatus')) {
  758.             $response HumanResource::getAttendanceStatus($em$data);
  759.             return new JsonResponse($response);
  760.         }
  761.         // Auto attendance
  762.         if ($data->get('autoAttendance')) {
  763.             $empId $data->query->get('id');
  764.             $sysUserId 0;
  765.             if ($data->get('requestFromMobile')) {
  766.                 $sysUserId $data->request->get('id');
  767.                 $empId $em->getRepository(Employee::class)
  768.                     ->findOneBy(['userId' => $sysUserId])->getEmployeeId();
  769.             } else {
  770.                 $sysUserId $em->getRepository(Employee::class)
  771.                     ->findOneBy(['employeeId' => $empId])->getUserId();
  772.             }
  773.             $customTime $data->get('time');
  774.             $today = new \DateTime(date('y-m-d'));
  775.             $EmployeeAttendance $this->getDoctrine()
  776.                 ->getRepository(EmployeeAttendance::class)
  777.                 ->findOneBy(array('employeeId' => $empId'date' => $today));
  778.             if (!$EmployeeAttendance)
  779.                 $EmployeeAttendance = new EmployeeAttendance;
  780.             $attendanceInfo HumanResource::StoreAttendance($em$empId$sysUserId$data$EmployeeAttendance$customTime);
  781.             $response HumanResource::setAttendanceLog($em$empId$sysUserId,
  782.                 $data->getSession()->get(UserConstants::USER_COMPANY_ID),
  783.                 $data->getSession()->get(UserConstants::USER_APP_ID),
  784.                 $data$attendanceInfo$options);
  785.             if ($data->get('requestFromMobile')) {
  786.                 return new JsonResponse([$response]);
  787.             }
  788.             return new JsonResponse(
  789.                 array(
  790.                     'success' => true,
  791.                     'msg' => 'Employee activities successfully updated.'
  792.                 )
  793.             );
  794.             // }
  795.             // else {
  796.             //   return new JsonResponse(
  797.             //     array(
  798.             //       'success' => false,
  799.             //       'msg' => "Invalid employee ID"
  800.             //     )
  801.             //   );
  802.             // }
  803.         } else {
  804.             if ($data->get('manualAttendance')) {
  805.                 return $this->render(
  806.                     'ApplicationBundle:pages/human_resource/report:current_attendance.html.twig',
  807.                     array(
  808.                         'page_title' => 'Current Attendance Status',
  809.                     )
  810.                 );
  811.             }
  812.             // Show all matching employee list during ajax request
  813.             // Show current location according to id
  814.             if ($data->get('getCurrLocById')) {
  815.                 $Id $data->get("id");
  816.                 $today = new \DateTime(date('y-m-d'));
  817.                 $repository $this->getDoctrine()->getRepository(EmployeeAttendance::class);
  818.                 $ActivitiesTemplate HumanResource::getActivitiesTemplate($repository$Id$today);
  819.                 return new JsonResponse(["success" => true"template" => $ActivitiesTemplate]);
  820.             }
  821.         }
  822.     }
  823.     public function EmployeeLeaveAction(Request $data$id)
  824.     {
  825.         $em $this->getDoctrine()->getManager();
  826.         $request=$data;
  827.         if (!$id) {
  828.             if ($data->isMethod('GET')) {
  829.                 $EmpID $data->query->get('id');
  830.                 $LeaveType $data->query->get('leaveType');
  831.                 if ($data->query->has('id') && $data->query->has('leaveType')) {
  832.                     $response HumanResource::HandelAjaxRequestForLeaveApp($em$EmpID$LeaveType);
  833.                     return new JsonResponse($response);
  834.                 }
  835.                 if ($data->query->has('id')) {
  836.                     $Response HumanResource::HandelAjaxRequestForLeaveApp($em$EmpID);
  837.                     return new JsonResponse($Response);
  838.                 }
  839.                 $TemplateData HumanResource::TwigDataForLeaveApp($emFalse);
  840.                 return $this->render(
  841.                     'ApplicationBundle:pages/human_resource/input_forms:employee_leave.html.twig',
  842.                     array(
  843.                         'page_title' => $TemplateData['Title'],
  844.                         'EmployeeList' => $TemplateData['EmployeeList'],
  845.                         'DesignationList' => $TemplateData['DesignationList'],
  846.                         'HasUpdateMode' => false
  847.                     )
  848.                 );
  849.             } else {
  850.                 $CompanyId $this->getLoggedUserCompanyId($data);
  851.                 $Response HumanResource::StoreDataForLeaveApplication($em$id$datafalse$CompanyId);
  852.                 if ($Response['HasErr']) {
  853.                     $this->addFlash('error'$Response['msg']);
  854.                     if ($data->request->has('returnJson')) {
  855.                         return new JsonResponse(array(
  856.                             'success' => false,
  857.                             'errorStr' => $Response['msg'],
  858.                         ));
  859.                     } else {
  860.                         return $this->redirectToRoute('employee_leave');
  861.                     }
  862.                 }
  863.                 $applicationId $Response['applicationId'];
  864.                 $em_goc $this->getDoctrine()->getManager('company_group');
  865.                 $file_path_list=[];
  866.                 if($applicationId!=0) {
  867.                     if (!empty($request->files)) {
  868.                         MiscActions::RemoveFilesForEntityDoc($em_goc'EmployeeLeaveApplication'$applicationId);
  869.                         $storePath 'uploads/LeaveDoc/';
  870.                         $path "";
  871.                         $file_path "";
  872.                         $session $request->getSession();
  873.                         MiscActions::RemoveExpiredFiles($em_goc);
  874.                         foreach ($request->files as $uploadedFileGG) {
  875.                             //            if($uploadedFile->getImage())
  876.                             //                var_dump($uploadedFile->getFile());
  877.                             //                var_dump($uploadedFile);
  878.                             $tempD $uploadedFileGG;
  879.                             if (!is_array($uploadedFileGG)) {
  880.                                 $uploadedFileGG = array();
  881.                                 $uploadedFileGG[] = $tempD;
  882.                             }
  883.                             foreach ($uploadedFileGG as $uploadedFile) {
  884.                                 if ($uploadedFile != null) {
  885.                                     $extension $uploadedFile->guessExtension();
  886.                                     $size $uploadedFile->getSize();
  887.                                     $fileName 'LDOC_' $applicationId '_' . (md5(uniqid())) . '.' $uploadedFile->guessExtension();
  888.                                     $path $fileName;
  889.                                     $upl_dir $this->container->getParameter('kernel.root_dir') . '/../web/' $storePath;
  890.                                     if (!file_exists($upl_dir)) {
  891.                                         mkdir($upl_dir0777true);
  892.                                     }
  893.                                     if (file_exists($upl_dir '' $path)) {
  894.                                         chmod($upl_dir '' $path0755);
  895.                                         unlink($upl_dir '' $path);
  896.                                     }
  897.                                     $file $uploadedFile->move($upl_dir$path);
  898.                                     $expireNever 1;
  899.                                     $expireTs 0;
  900.                                     $EntityFile = new EntityFile();
  901.                                     $EntityFile->setPath($this->container->getParameter('kernel.root_dir') . '/../web/' $storePath $path);
  902.                                     $EntityFile->setMarker('_GEN_');
  903.                                     $EntityFile->setExtension($extension);
  904.                                     $EntityFile->setExpireTs($expireTs);
  905.                                     $EntityFile->setSize($size);
  906.                                     $EntityFile->setRelativePath($storePath $path);
  907.                                     $EntityFile->setEntityName('EmployeeLeaveApplication');
  908.                                     $EntityFile->setEntityBundle('EmployeeLeaveApplication');
  909.                                     $EntityFile->setEntityId($applicationId);
  910.                                     $EntityFile->setEntityIdField('employeeLeaveApplicationId');
  911.                                     $EntityFile->setModifyFieldSetter('setFiles');
  912.                                     $EntityFile->setDocIdForApplicant(0);
  913.                                     $EntityFile->setUserId($session->get(UserConstants::USER_ID0));
  914.                                     $EntityFile->setAppId($session->get(UserConstants::USER_APP_ID0));
  915.                                     $EntityFile->setEmployeeId($session->get(UserConstants::USER_EMPLOYEE_ID0));
  916.                                     $EntityFile->setUserType($session->get(UserConstants::USER_TYPE0));
  917.                                     $em_goc->persist($EntityFile);
  918.                                     $em_goc->flush();
  919.                                     $EntityFileId $EntityFile->getId();
  920.                                 }
  921.                                 if ($path != "")
  922.                                     $file_path_list[] = ($storePath $path);
  923.                             }
  924.                         }
  925.                         $g_path $this->container->getParameter('kernel.root_dir') . '/../web/' $storePath $path;
  926.                         $v $em->getRepository('ApplicationBundle:EmployeeLeaveApplication')->findOneBy(array(
  927.                             'employeeLeaveApplicationId' => $applicationId,
  928.                         ));
  929.                         if ($v) {
  930.                             $v->setFiles(implode(','$file_path_list));
  931.                             $em->flush();
  932.                         } else {
  933.                         }
  934.                     }
  935.                 }
  936.                 // $this->addFlash('success', 'Application submitted successfully!');
  937.                 // return $this->redirectToRoute('leave_application_list');
  938.                 if ($data->request->has('returnJson')) {
  939.                     return new JsonResponse(array(
  940.                         'success' => true,
  941.                     ));
  942.                 } else {
  943.                     return $this->redirectToRoute('view_employee_leave_application', array('id' => $applicationId));
  944.                 }
  945.             }
  946.         }
  947.         else {
  948.             if ($data->isMethod('GET')) {
  949.                 $ApplicationRepo $em->getRepository(EmployeeLeaveApplication::class);
  950.                 $OldData $ApplicationRepo->find(array('employeeLeaveApplicationId' => $id));
  951.                 $TemplateData HumanResource::TwigDataForLeaveApp($em$OldData);
  952.                 return $this->render(
  953.                     'ApplicationBundle:pages/human_resource/input_forms:employee_leave.html.twig',
  954.                     array(
  955.                         'page_title' => $TemplateData['Title'],
  956.                         'EmployeeList' => $TemplateData['EmployeeList'],
  957.                         'DesignationList' => $TemplateData['DesignationList'],
  958.                         'OldData' => $TemplateData['OldData'],
  959.                         'AvailableLeave' => $TemplateData['AvailableLeave'],
  960.                         'HasUpdateMode' => true
  961.                     )
  962.                 );
  963.             } else {
  964.                 $CompanyId $this->getLoggedUserCompanyId($data);
  965.                 $Response HumanResource::StoreDataForLeaveApplication($em$id$datatrue$CompanyId);
  966.                 if ($Response['HasErr']) {
  967.                     $this->addFlash('error'$Response['msg']);
  968.                     return $this->redirectToRoute('employee_leave');
  969.                 }
  970.                 $this->addFlash('success'"Application updated successfully!");
  971.                 return $this->redirectToRoute('leave_application_list');
  972.             }
  973.         }
  974.     }
  975.     public function ViewLeaveApplicationAction(Request $request$id)
  976.     {
  977.         $em $this->getDoctrine()->getManager();
  978.         if ($id) {
  979.             $TwigData HumanResource::TwigDataForViewLeaveApplication($em$request$id);
  980.             if ($TwigData['HasErr']) {
  981.                 return new JsonResponse(array(
  982.                     'success' => false,
  983.                     'msg' => $TwigData['Msg']
  984.                 ));
  985.             }
  986.             return $this->render(
  987.                 'ApplicationBundle:pages/human_resource/views:leave_application_view.html.twig',
  988.                 array(
  989.                     'page_title' => 'View Leave Application',
  990.                     'Applicant' => $TwigData['Applicant'],
  991.                     'Application' => $TwigData['Application'],
  992.                     'LeaveType' => $TwigData['LeaveType'],
  993.                     'LeaveCategory' => $TwigData['LeaveCategory'],
  994.                     'FrwdEmp' => $TwigData['FrwdEmp'],
  995.                     'ApplicantDesg' => $TwigData['ApplicantDesg'],
  996.                     'approval_status' => $TwigData['approval_status'],
  997.                     'approval_data' => $TwigData['approval_data'],
  998.                     'document_log' => $TwigData['document_log'],
  999.                     'auto_created' => 0,
  1000.                 )
  1001.             );
  1002.         }
  1003.         return new JsonResponse(array(
  1004.             'success' => false,
  1005.             'msg' => 'Wrong URL format! Please try with application ID'
  1006.         ));
  1007.     }
  1008.     public function PrintLeaveApplicationAction(Request $request$id)
  1009.     {
  1010.         if ($id) {
  1011.             $em $this->getDoctrine()->getManager();
  1012.             $company_data Company::getCompanyData($em1);
  1013.             $Application $em->getRepository(EmployeeLeaveApplication::class)->find($id);
  1014.             $Authorizations System::getSignatureListForDocumentPrint($emarray_flip(GeneralConstant::$Entity_list)['EmployeeLeaveApplication'], $id);
  1015.             $ApplicationCategory $Application->getLeaveCategory();
  1016.             $ApplicationType = ($ApplicationCategory!=&& $ApplicationCategory!= 2)?HumanResourceConstant::$LeaveType[$Application->getLeaveTypeId()]:'';
  1017.             $Applicant $em->getRepository(EmployeeDetails::class)
  1018.                 ->find($Application->getEmployeeId());
  1019.             return $this->render(
  1020.                 'ApplicationBundle:pages/human_resource/print:leave_application_print.html.twig',
  1021.                 array(
  1022.                     'page_title' => 'Print Leave Application',
  1023.                     'export' => 'pdf,print',
  1024.                     'company_name' => $company_data->getName(),
  1025.                     'company_data' => $company_data,
  1026.                     'company_address' => $company_data->getAddress(),
  1027.                     'company_image' => $company_data->getImage(),
  1028.                     'Application' => $Application,
  1029.                     'Applicant' => $Applicant,
  1030.                     'Authorizations' => $Authorizations,
  1031.                     'ApplicationType' => $ApplicationType,
  1032.                     'ApplicationCategory' => $ApplicationCategory,
  1033.                     'red' => 0
  1034.                 )
  1035.             );
  1036.         }
  1037.         return new JsonResponse(array(
  1038.             'success' => false,
  1039.             'msg' => 'Wrong URL format! Please try with application ID'
  1040.         ));
  1041.     }
  1042.     public function LeaveApplicationListAction(Request $request)
  1043.     {
  1044.         $em $this->getDoctrine()->getManager();
  1045.         $response HumanResource::GetEmployeeLeaveApplicationList($em$request);
  1046.         if ($request->isMethod('GET')) {
  1047.             return $this->render("ApplicationBundle:pages/human_resource/list:leave_application_list.html.twig", array(
  1048.                 'page_title' => 'Leave Application List',
  1049.                 'application_data' => $response,
  1050.             ));
  1051.         }
  1052.     }
  1053.     public function PayrollPolicySettingsAction(Request $request$id)
  1054.     {
  1055.         $em $this->getDoctrine()->getManager();
  1056.         $CompanyId $this->getLoggedUserCompanyId($request);
  1057.         if ($id) {
  1058.             if ($request->isMethod('GET')) {
  1059.                 $Row $em->getRepository(PayrollPolicy::class)->find($id);
  1060.                 if (!$Row) {
  1061.                     $this->addFlash('error''Invalid Payroll Policy Id');
  1062.                     return $this->redirectToRoute('payroll_policy_settings');
  1063.                 }
  1064.                 $TwigData HumanResource::GetPayrollPolicyTwigData($em);
  1065.                 $OldData HumanResource::GetPayrollPolicyTwigData($em$id);
  1066.                 return $this->render('ApplicationBundle:pages/human_resource/input_forms:payroll_policy_settings.html.twig', array(
  1067.                     'page_title' => 'Update Payroll Policy Settings',
  1068.                     'EmployeeIds' => $TwigData['EmployeeIds'],
  1069.                     'EmployeeType' => $TwigData['EmployeeType'],
  1070.                     'department' => $TwigData['department'],
  1071.                     'Designation' => $TwigData['Designation'],
  1072.                     'WorkingDays' => $TwigData['WorkingDays'],
  1073.                     'OldData' => $OldData['Row'],
  1074.                     'earningAspects' => HumanResourceConstant::$earningAspectsForPayrollPolicy,
  1075.                     'leaveTypes' => HumanResourceConstant::$LeaveTypeForPayrollPolicy,
  1076.                     'leaveTypesArray' => HumanResourceConstant::$LeaveTypeArrayForPayrollPolicy,
  1077.                     'deductionAspects' => HumanResourceConstant::$deductionAspects,
  1078.                     'deductionCondition' => json_decode($Row->getDeductionCondition(), true),
  1079.                     'HasUpdateMode' => true,
  1080.                 ));
  1081.             } else {
  1082.                 $Response HumanResource::StorePayrollPolicyData($em$id$CompanyId$request);
  1083.                 if ($Response['HasErr']) {
  1084.                     $this->addFlash('error'$Response['msg']);
  1085.                     return $this->redirectToRoute('payroll_policy_settings');
  1086.                 }
  1087.                 return $this->redirectToRoute('payroll_policy_settings');
  1088. //        if ($Response['isSuccess']) {
  1089. //          return new JsonResponse(array('success' => true, 'msg' => 'don\'t forget to redirect'));
  1090. //        }
  1091. //        return new JsonResponse(array('success' => false, 'msg' => 'Sorry something went wrong'));
  1092.             }
  1093.         } else {
  1094.             if ($request->isMethod('GET')) {
  1095.                 if ($request->query->get('GetDocHash')) {
  1096.                     $Dochash HumanResource::GenerateDocHashForPayrollSettings($em$request);
  1097.                     return new JsonResponse($Dochash);
  1098.                 }
  1099.                 $TwigData HumanResource::GetPayrollPolicyTwigData($em);
  1100.                 return $this->render(
  1101.                     'ApplicationBundle:pages/human_resource/input_forms:payroll_policy_settings.html.twig',
  1102.                     array(
  1103.                         'page_title' => 'Create Payroll Policy Settings',
  1104.                         'EmployeeIds' => $TwigData['EmployeeIds'],
  1105.                         'EmployeeType' => $TwigData['EmployeeType'],
  1106.                         'WorkingDays' => $TwigData['WorkingDays'],
  1107.                         'Designation' => $TwigData['Designation'],
  1108.                         'department' => $TwigData['department'],
  1109.                         'earningAspects' => HumanResourceConstant::$earningAspectsForPayrollPolicy,
  1110.                         'leaveTypes' => HumanResourceConstant::$LeaveTypeForPayrollPolicy,
  1111.                         'leaveTypesArray' => HumanResourceConstant::$LeaveTypeArrayForPayrollPolicy,
  1112.                         'deductionAspects' => HumanResourceConstant::$deductionAspects,
  1113.                         'HasUpdateMode' => false
  1114.                     )
  1115.                 );
  1116.             } else {
  1117.                 $Response HumanResource::StorePayrollPolicyData($em$id$CompanyId$request);
  1118.                 if ($Response['HasErr']) {
  1119.                     $this->addFlash('error'$Response['msg']);
  1120.                     return $this->redirectToRoute('payroll_policy_settings');
  1121.                 }
  1122.                 return $this->redirectToRoute('payroll_policy_settings');
  1123. //        return new JsonResponse(array("success" => true, 'msg' => 'Dont forget to redirect!'));
  1124.             }
  1125.         }
  1126.     }
  1127.     public function AttendanceReportAction(Request $request)
  1128.     {
  1129.         $em $this->getDoctrine()->getManager();
  1130.         $EmployeeIds $em->getRepository(EmployeeDetails::class)->findAll();
  1131.         $Departments $em->getRepository(SysDepartment::class)->findAll();
  1132.         $attendanceSource HumanResourceConstant::$attendanceSources;
  1133.         if ($request->isMethod('GET')) {
  1134.             return $this->render('ApplicationBundle:pages/human_resource/report:attendance_report.html.twig', array(
  1135.                 'page_title' => 'Attendance Report',
  1136.                 'employes' => $EmployeeIds,
  1137.                 'departments' => $Departments,
  1138.                 'isMethodGet' => true,
  1139.                 'from_date' => '',
  1140.                 'to_date' => '',
  1141.                 'report_for' => '',
  1142.                 'attendance' => [],
  1143.                 'Reports' => [],
  1144.                 'qry' => ''
  1145.             ));
  1146.         }
  1147.         $ReportData HumanResource::GenerateAttendanceReport($em$request,$request->request->get('considerCurrTsIfNoOut',0));
  1148.         if($request->request->get('returnJson',0)==1)
  1149.         {
  1150.            return new JsonResponse($ReportData);
  1151.         }
  1152.         $Qry "start_date=" $ReportData['from_date'] . '&' "end_date=" $ReportData['to_date'] . '&' "period_type=" $ReportData['period_type'] . '&' "show_all=" $ReportData['show_all'] . '&' "department=" $request->get('department') . '&' "employes=" implode(',', ($request->get('employes') ? $request->get('employes') : []));
  1153.         return $this->render('ApplicationBundle:pages/human_resource/report:attendance_report.html.twig', array(
  1154.             'page_title' => 'Attendance Report',
  1155.             'isMethodGet' => false,
  1156.             'departments' => $Departments,
  1157.             'employes' => $EmployeeIds,
  1158.             'attendanceSource' => $attendanceSource,
  1159.             'Reports' => $ReportData['Reports'],
  1160.             'from_date' => $ReportData['from_date'],
  1161.             'to_date' => $ReportData['to_date'],
  1162.             'report_for' => $ReportData['generated_for'],
  1163.             'attendance' => $ReportData['attendance'],
  1164.             'qry' => $Qry
  1165.         ));
  1166.     }
  1167.     public function PrintAttendanceReportAction(Request $request)
  1168.     {
  1169.         $em $this->getDoctrine()->getManager();
  1170.         $company_data Company::getCompanyData($em1);
  1171.         $ReportData HumanResource::GenerateAttendanceReport($em$request);
  1172.         return $this->render(
  1173.             'ApplicationBundle:pages/human_resource/print:print_attendance_report.html.twig',
  1174.             array(
  1175.                 'page_title' => 'Print Attendance Report',
  1176.                 'export' => 'pdf,print',
  1177.                 'company_name' => $company_data->getName(),
  1178.                 'company_data' => $company_data,
  1179.                 'company_address' => $company_data->getAddress(),
  1180.                 'company_image' => $company_data->getImage(),
  1181.                 'Reports' => $ReportData['Reports'],
  1182.                 'from_date' => $ReportData['from_date'],
  1183.                 'to_date' => $ReportData['to_date'],
  1184.                 'report_for' => $ReportData['generated_for'],
  1185.                 'attendance' => $ReportData['attendance'],
  1186.                 'red' => 0
  1187.             )
  1188.         );
  1189.     }
  1190.     public function DisburseSalaryAction(Request $request)
  1191.     {
  1192.         $em $this->getDoctrine()->getManager();
  1193.         $EmployeeIds $em->getRepository(EmployeeDetails::class)->findAll();
  1194.         $Departments $em->getRepository(SysDepartment::class)->findAll();
  1195.         $attendance $em->getRepository(EmployeeAttendanceLog::class)->findAll();
  1196.         if ($request->isMethod('GET')) {
  1197.             return $this->render('ApplicationBundle:pages/human_resource/report:disburse_salary.html.twig', array(
  1198.                 'page_title' => 'Disburse Salary',
  1199.                 'EmployeeIds' => $EmployeeIds,
  1200.                 'departments' => $Departments,
  1201.                 'attendance' => $attendance,
  1202.                 'from_date' => '',
  1203.                 'to_date' => '',
  1204.                 'Qry' => '',
  1205.                 'isMethodGet' => true
  1206.             ));
  1207.         }
  1208.         $SalaryReports HumanResource::BasicDeduction($em$request);
  1209. //        $SalaryReportsNew = HumanResource::calculateSalary($em,
  1210. //            array(
  1211. //                'startDate' => $request->get('salary_start_date', ''),
  1212. //                'endDate' => $request->get('salary_end_date', ''),
  1213. //                'timeZone' => $request->get('time_zone', '+0600'),
  1214. //                'employeeIds' => $request->get('employeeIds', []),
  1215. //                'departmentIds' => $request->get('department', []),
  1216. //                'allFlag' => $request->get('show_all', 0),
  1217. //
  1218. //            )
  1219. //        );
  1220.         $Qry "salary_till_date=" $SalaryReports[0]['to_date'] . '&' "show_all=" $request->get('show_all') . '&' "department=" $SalaryReports[0]['department_id'] . '&' "employeeIds=" implode(',', ($request->get('employeeIds') ? $request->get('employeeIds') : []));
  1221. //        if ($request->get('returnJson', 0) == 1) {
  1222.         if ($request->get('returnJson'0) == 1) {
  1223.             return new JsonResponse(array(
  1224.                 'SalaryReports' => $SalaryReports,
  1225.             ));
  1226.         } else {
  1227.             return $this->render('ApplicationBundle:pages/human_resource/report:disburse_salary.html.twig', array(
  1228.                 'page_title' => 'Disburse Salary',
  1229.                 'EmployeeIds' => $EmployeeIds,
  1230.                 'departments' => $Departments,
  1231.                 'SalaryReports' => $SalaryReports,
  1232.                 'for_month' => $SalaryReports[0]['for_month'],
  1233.                 'from_date' => $SalaryReports[0]['form_date'],
  1234.                 'to_date' => $SalaryReports[0]['to_date'],
  1235.                 'Qry' => $Qry,
  1236.                 'isMethodGet' => false
  1237.             ));
  1238.         }
  1239.     }
  1240.     public function PrintDisburseSalaryAction(Request $Req)
  1241.     {
  1242.         $em $this->getDoctrine()->getManager();
  1243.         $company_data Company::getCompanyData($em1);
  1244.         $SalaryReports HumanResource::BasicDeduction($em$Req);
  1245.         return $this->render(
  1246.             'ApplicationBundle:pages/human_resource/print:print_disburse_salary.html.twig',
  1247.             array(
  1248.                 'page_title' => 'Print Disburse Salary',
  1249.                 'export' => 'pdf,print',
  1250.                 'company_name' => $company_data->getName(),
  1251.                 'company_data' => $company_data,
  1252.                 'company_address' => $company_data->getAddress(),
  1253.                 'company_image' => $company_data->getImage(),
  1254.                 'SalaryReports' => $SalaryReports,
  1255.                 'for_month' => $SalaryReports[0]['for_month'],
  1256.                 'from_date' => $SalaryReports[0]['form_date'],
  1257.                 'to_date' => $SalaryReports[0]['to_date'],
  1258.                 'red' => 0
  1259.             )
  1260.         );
  1261.     }
  1262.     public function createJobRecruitmentAction(Request $request$id 0)
  1263.     {
  1264.         $data = [];
  1265.         $em_goc $this->getDoctrine()->getManager('company_group');
  1266.         $skillDetails $em_goc->getRepository(EntitySkill::class)->findAll();
  1267.         $em $this->getDoctrine()->getManager();
  1268.         $companyId $this->getLoggedUserCompanyId($request);
  1269.         if ($request->isMethod('POST')) {
  1270.             $em $this->getDoctrine()->getManager();
  1271.             $entity_id array_flip(GeneralConstant::$Entity_list)['JobRecruitment']; //change
  1272.             $dochash $request->request->get('docHash'); //change
  1273.             $loginId $request->getSession()->get(UserConstants::USER_LOGIN_ID);
  1274.             $approveRole $request->request->get('approvalRole');
  1275.             $approveHash $request->request->get('approvalHash');
  1276.             if (!DocValidation::isInsertable($em$entity_id$dochash,
  1277.                 $loginId$approveRole$approveHash$id)
  1278.             ) {
  1279.                 $this->addFlash(
  1280.                     'error',
  1281.                     'Sorry Could not insert Data.'
  1282.                 );
  1283.             } else {
  1284.                 $data $request->request;
  1285.                 $docId HumanResource::createJobRecruitment($em$loginId$id$data$companyId);
  1286.                 //now add Approval info
  1287.                 $approveRole $request->request->get('approvalRole');
  1288.                 $options = array(
  1289.                     'notification_enabled' => $this->container->getParameter('notification_enabled'),
  1290.                     'notification_server' => $this->container->getParameter('notification_server'),
  1291.                     'appId' => $request->getSession()->get(UserConstants::USER_APP_ID),
  1292.                     'url' => $this->generateUrl(
  1293.                         GeneralConstant::$Entity_list_details[array_flip(GeneralConstant::$Entity_list)['JobRecruitment']]
  1294.                         ['entity_view_route_path_name']
  1295.                     )
  1296.                 );
  1297.                 System::setApprovalInfo($this->getDoctrine()->getManager(), $options,
  1298.                     array_flip(GeneralConstant::$Entity_list)['JobRecruitment'],
  1299.                     $docId,
  1300.                     $request->getSession()->get(UserConstants::USER_LOGIN_ID)    //journal voucher
  1301.                 );
  1302.                 System::createEditSignatureHash($this->getDoctrine()->getManager(), array_flip(GeneralConstant::$Entity_list)['JobRecruitment'],
  1303.                     $docId,
  1304.                     $loginId,
  1305.                     $approveRole,
  1306.                     $request->request->get('approvalHash'));
  1307.                 $this->addFlash(
  1308.                     'success',
  1309.                     'New Recruitment Document Added.'
  1310.                 );
  1311.                 $url $this->generateUrl(
  1312.                     'view_job_recruitment'
  1313.                 );
  1314.                 return $this->redirect($url "/" $docId);
  1315.             }
  1316.         }
  1317.         if ($id == 0) {
  1318.         } else {
  1319.             $extDoc $em->getRepository('ApplicationBundle:JobRecruitment')->findOneBy(
  1320.                 array(
  1321.                     'jobRecruitmentId' => $id///material
  1322.                 )
  1323.             );
  1324.             //now if its not editable, redirect to view
  1325.             if ($extDoc) {
  1326.                 if ($extDoc->getEditFlag() != 1) {
  1327.                     $url $this->generateUrl(
  1328.                         'view_job_recruitment'
  1329.                     );
  1330.                     return $this->redirect($url "/" $id);
  1331.                 }
  1332.             }
  1333.         }
  1334.         $jobType HumanResourceConstant::$employeeType;
  1335.         //$skillDetails = $em->getRepository(Skill::class)->findAll();
  1336.         $educationDetails $em->getRepository('ApplicationBundle:EducationQualification')->findAll();
  1337.         $employeeIds $em->getRepository('ApplicationBundle:Employee')->findAll();
  1338.         $location HumanResourceConstant::$location;
  1339.         $salaryPer HumanResourceConstant::$salaryPer;
  1340.         $workExperience HumanResourceConstant::$workExperience;
  1341.         $jobOpeningStatus HumanResourceConstant::$jobOpeningStatus;
  1342.         $compatibility HumanResourceConstant::$compatibility;
  1343.         return $this->render('ApplicationBundle:pages/human_resource/input_forms:create_new_job_post.html.twig', [
  1344.             'page_title' => 'Create New Job Post',
  1345.             'jobType' => $jobType,
  1346.             'skillDetails' => $skillDetails,
  1347.             'educationDetails' => $educationDetails,
  1348.             'employeeIds' => $employeeIds,
  1349.             'location' => $location,
  1350.             'salaryPer' => $salaryPer,
  1351.             'workExperience' => $workExperience,
  1352.             'jobOpeningStatus' => $jobOpeningStatus,
  1353.             'compatibility' => $compatibility
  1354.         ]);
  1355.     }
  1356.     public function viewApplicantInfoAction(Request $request$id)
  1357.     {
  1358.         $em $this->getDoctrine()->getManager('company_group');
  1359.         //$session = $request->getSession();
  1360.         $consultantDetails $em->getRepository(EntityApplicantDetails::class)->find($id);
  1361.         $skillDetails $em->getRepository('CompanyGroupBundle:EntitySkill')->findAll();
  1362.         //$companyId = $this->getLoggedUserCompanyId($request);
  1363.         $gender HumanResourceConstant::$sex;
  1364.         $blood HumanResourceConstant::$BloodGroup;
  1365.         //$userId = $session->get(UserConstants::USER_ID);
  1366.         return $this->render('ApplicationBundle:pages/human_resource/views:view_applicant_info.html.twig', [
  1367.             'page_title' => 'Applicant Information',
  1368.             'gender' => $gender,
  1369.             'blood' => $blood,
  1370.             'consultantDetails' => $consultantDetails,
  1371.             'education' => json_decode($consultantDetails->getEducationData(), true),
  1372.             'workExperience' => json_decode($consultantDetails->getWorkExperienceData(), true),
  1373.             'certificate' => json_decode($consultantDetails->getCertificateData(), true),
  1374.             'courses' => json_decode($consultantDetails->getCoursesData(), true),
  1375.             'languages' => json_decode($consultantDetails->getLanguagesData(), true),
  1376.             'skillDetails' => $skillDetails
  1377.         ]);
  1378.     }
  1379.     public function ListJobRecruitmentAction()
  1380.     {
  1381.         $em $this->getDoctrine()->getManager();
  1382.         $jobRecruitmentList = [];
  1383.         $jobRecruitments $em->getRepository('ApplicationBundle:JobRecruitment')->findAll();
  1384.         foreach ($jobRecruitments as $jobRecruitment) {
  1385.             $jobData = array(
  1386.                 'jobRecruitmentId' => $jobRecruitment->getJobRecruitmentId(),
  1387.                 'title' => $jobRecruitment->getTitle(),
  1388.                 'date' => $jobRecruitment->getDate(),
  1389.                 'jobOpeningStatus' => $jobRecruitment->getJobOpeningStatus(),
  1390.                 'applicationOpeningDate' => $jobRecruitment->getApplicationOpeningDate(),
  1391.                 'applicationClosingDate' => $jobRecruitment->getApplicationClosingDate(),
  1392.             );
  1393.             $jobRecruitmentList[] = $jobData;
  1394.         }
  1395.         return $this->render('ApplicationBundle:pages/human_resource/list:job_recruitment_list.html.twig', [
  1396.             'page_title' => 'Job RecruitmentAction List',
  1397.             'jobRecruitments' => $jobRecruitmentList
  1398.         ]);
  1399.     }
  1400.     public function ViewJobRecruitmentAction(Request $request$id 0)
  1401.     {
  1402.         $em_goc $this->getDoctrine()->getManager('company_group');
  1403.         $skillDetails $em_goc->getRepository('CompanyGroupBundle:EntitySkill')->findAll();
  1404.         $em $this->getDoctrine()->getManager();
  1405.         $companyId $this->getLoggedUserCompanyId($request);
  1406.         $company_data Company::getCompanyData($em$companyId);
  1407. //        return new JsonResponse($encryptedDataArray);
  1408.         $location HumanResourceConstant::$location;
  1409.         $salaryPer HumanResourceConstant::$salaryPer;
  1410.         $workExperience HumanResourceConstant::$workExperience;
  1411.         $jobOpeningStatus HumanResourceConstant::$jobOpeningStatus;
  1412.         $compatibility HumanResourceConstant::$compatibility;
  1413.         $jobType HumanResourceConstant::$employeeType;
  1414.         $educationDetail $em->getRepository(EducationQualification::class)->findAll();
  1415.         $jobRecruitments $em->getRepository('ApplicationBundle:JobRecruitment')->find($id);
  1416.         $em_goc $this->getDoctrine()->getManager('company_group');
  1417.         $applicantApplicationList $em_goc->getRepository("CompanyGroupBundle:EntityApplicantApplicationList")->findBy(
  1418.             array(
  1419.                 'jobPostId' => $id,
  1420.                 'CompanyId' => $companyId,
  1421.                 'appId' => $company_data->getAppId()
  1422.             )
  1423.         );
  1424.         $applicantIdList = [];
  1425.         foreach ($applicantApplicationList as $dt) {
  1426.             $applicantIdList[] = $dt->getApplicantId();
  1427.         }
  1428.         $applicantList ApplicantM::getApplicantList($em_goc$applicantIdList);
  1429.         $Approval_data = [
  1430.             'exists' => 0,
  1431.             'approvalId' => 0,
  1432.             'roleType' => 0,
  1433.             'required' => 0,
  1434.             'acted' => 0,
  1435.             'entity' => array_flip(GeneralConstant::$Entity_list)['JobRecruitment'],
  1436.             'entityId' => $id,
  1437.         ];
  1438.         if (in_array($request->getSession()->get(UserConstants::USER_TYPE), [125]))
  1439.             $Approval_data System::checkIfApprovalExists(
  1440.                 $em,
  1441.                 array_flip(GeneralConstant::$Entity_list)['JobRecruitment'],
  1442.                 $id,
  1443.                 $request->getSession()->get(UserConstants::USER_LOGIN_ID)
  1444.             );
  1445.         return $this->render('ApplicationBundle:pages/human_resource/views:view_job_recruitment.html.twig', [
  1446.             'page_title' => 'View Job RecruitmentAction',
  1447.             'jobRecruitments' => $jobRecruitments,
  1448.             'applicantApplicationList' => $applicantApplicationList,
  1449.             'applicantList' => $applicantList,
  1450. //            'encryptedData' => $encryptedData,
  1451.             'skills' => json_decode($jobRecruitments->getskills()),
  1452.             'skillDetails' => $skillDetails,
  1453.             'education' => json_decode($jobRecruitments->getEducations()),
  1454.             'educationDetails' => $educationDetail,
  1455.             'location' => $location,
  1456.             'salaryPer' => $salaryPer,
  1457.             'workExperience' => $workExperience,
  1458.             'jobType' => $jobType,
  1459.             'compatibility' => $compatibility,
  1460.             'approval_status' => $jobRecruitments->getApproved(),
  1461.             'jobOpeningStatus' => $jobOpeningStatus,
  1462.             'approval_data' => $Approval_data,
  1463.             'auto_created' => $jobRecruitments->getAutocreated(),
  1464.             'document_log' => $jobRecruitments->getAutocreated() == System::getDocumentLog(
  1465.                 $em,
  1466.                 array_flip(GeneralConstant::$Entity_list)['JobRecruitment'],
  1467.                 $id,
  1468.                 $jobRecruitments->getCreatedLoginId(),
  1469.                 $jobRecruitments->getEditedLoginId()
  1470.             ) : []
  1471.         ]);
  1472.     }
  1473.     public function ViewApplicantScheduleAction(Request $request$id 0)
  1474.     {
  1475.         $em $this->getDoctrine()->getManager();
  1476.         $companyId $this->getLoggedUserCompanyId($request);
  1477.         $company_data Company::getCompanyData($em$companyId);
  1478.         $em_goc $this->getDoctrine()->getManager('company_group');
  1479.         $applicantApplicationList $em_goc->getRepository("CompanyGroupBundle:EntityApplicantApplicationList")->findBy(
  1480.             array(
  1481.                 'jobPostId' => $id,
  1482.                 'CompanyId' => $companyId,
  1483.                 'appId' => $company_data->getAppId()
  1484.             )
  1485.         );
  1486.         $applicantIdList = [];
  1487.         foreach ($applicantApplicationList as $dt) {
  1488.             $applicantIdList[] = $dt->getApplicantId();
  1489.         }
  1490.         $applicantList ApplicantM::getApplicantList($em_goc$applicantIdList);
  1491.         return $this->render('ApplicationBundle:pages/human_resource/views:view_applicant_scheduled.html.twig', [
  1492.             'page_title' => 'View Applicant Scheduled',
  1493.             'applicantApplicationList' => $applicantApplicationList,
  1494.             'applicantList' => $applicantList,
  1495.         ]);
  1496.     }
  1497.     public function ViewApplicantReportAction(Request $request$id 0)
  1498.     {
  1499.         $em $this->getDoctrine()->getManager();
  1500.         $companyId $this->getLoggedUserCompanyId($request);
  1501.         $company_data Company::getCompanyData($em$companyId);
  1502.         $em_goc $this->getDoctrine()->getManager('company_group');
  1503.         $applicantApplicationList $em_goc->getRepository("CompanyGroupBundle:EntityApplicantApplicationList")->findBy(
  1504.             array(
  1505.                 'jobPostId' => $id,
  1506.                 'CompanyId' => $companyId,
  1507.                 'appId' => $company_data->getAppId()
  1508.             )
  1509.         );
  1510.         $applicantIdList = [];
  1511.         foreach ($applicantApplicationList as $dt) {
  1512.             $applicantIdList[] = $dt->getApplicantId();
  1513.         }
  1514.         $applicantList ApplicantM::getApplicantList($em_goc$applicantIdList);
  1515.         return $this->render('ApplicationBundle:pages/human_resource/views:view_applicant_report.html.twig', [
  1516.             'page_title' => 'View Applicant Report',
  1517.             'applicantApplicationList' => $applicantApplicationList,
  1518.             'applicantList' => $applicantList,
  1519.         ]);
  1520.     }
  1521.     public function createEmployeePerformanceEvaluationAction(Request $request$id 0)
  1522.     {
  1523.         $data = [];
  1524.         $em $this->getDoctrine()->getManager();
  1525.         $companyId $this->getLoggedUserCompanyId($request);
  1526.         if ($request->isMethod('POST')) {
  1527.             $em $this->getDoctrine()->getManager();
  1528.             $entity_id array_flip(GeneralConstant::$Entity_list)['EmployeePerformanceEvolution']; //change
  1529.             $dochash $request->request->get('docHash'); //change
  1530.             $loginId $request->getSession()->get(UserConstants::USER_LOGIN_ID);
  1531.             $approveRole $request->request->get('approvalRole');
  1532.             $approveHash $request->request->get('approvalHash');
  1533.             if (!DocValidation::isInsertable($em$entity_id$dochash,
  1534.                 $loginId$approveRole$approveHash$id)
  1535.             ) {
  1536.                 $this->addFlash(
  1537.                     'error',
  1538.                     'Sorry Could not insert Data.'
  1539.                 );
  1540.             } else {
  1541.                 $data $request->request;
  1542.                 $docId HumanResource::createEmployeePerformanceEvaluation($em$loginId$id$data$companyId);
  1543.                 //now add Approval info
  1544.                 $approveRole $request->request->get('approvalRole');
  1545.                 $options = array(
  1546.                     'notification_enabled' => $this->container->getParameter('notification_enabled'),
  1547.                     'notification_server' => $this->container->getParameter('notification_server'),
  1548.                     'appId' => $request->getSession()->get(UserConstants::USER_APP_ID),
  1549.                     'url' => $this->generateUrl(
  1550.                         GeneralConstant::$Entity_list_details[array_flip(GeneralConstant::$Entity_list)['EmployeePerformanceEvolution']]
  1551.                         ['entity_view_route_path_name']
  1552.                     )
  1553.                 );
  1554.                 System::setApprovalInfo($this->getDoctrine()->getManager(), $options,
  1555.                     array_flip(GeneralConstant::$Entity_list)['JobRecruitment'],
  1556.                     $docId,
  1557.                     $request->getSession()->get(UserConstants::USER_LOGIN_ID)    //journal voucher
  1558.                 );
  1559.                 System::createEditSignatureHash($this->getDoctrine()->getManager(), array_flip(GeneralConstant::$Entity_list)['EmployeePerformanceEvolution'],
  1560.                     $docId,
  1561.                     $loginId,
  1562.                     $approveRole,
  1563.                     $request->request->get('approvalHash'));
  1564.                 $this->addFlash(
  1565.                     'success',
  1566.                     'New Recruitment Document Added.'
  1567.                 );
  1568.                 $url $this->generateUrl(
  1569.                     'view_employee_performance_evolution'
  1570.                 );
  1571.                 return $this->redirect($url "/" $docId);
  1572.             }
  1573.         }
  1574.         $skill $em->getRepository(Skill::class)->findAll();
  1575.         $educationDetail $em->getRepository(EducationQualification::class)->findAll();
  1576.         $employeeIds $em->getRepository(EmployeeDetails::class)->findAll();
  1577.         $employeeType HumanResourceConstant::$employeeType;
  1578.         $Designation $em->getRepository(SysDepartmentPosition::class)->findAll();
  1579.         $branch $em->getRepository(Branch::class)->findAll();
  1580.         $departments $em->getRepository(SysDepartment::class)->findAll();
  1581.         $department = [];
  1582.         foreach ($departments as $entry) {
  1583.             $department[$entry->getDepartmentId()] = array(
  1584.                 'id' => $entry->getDepartmentId(),
  1585.                 'name' => $entry->getDepartmentName(),
  1586.             );
  1587.         }
  1588.         return $this->render('ApplicationBundle:pages/human_resource/input_forms:employee_performance_evolution.html.twig',
  1589.             array(
  1590.                 'page_title' => 'Create Employee Performance Evaluation',
  1591.                 'employeeIds' => $employeeIds,
  1592.                 'employeeType' => $employeeType,
  1593.                 'Designation' => $Designation,
  1594.                 'branch' => $branch,
  1595.                 'department' => $department,
  1596.                 'skill' => $skill,
  1597.                 'educationDetail' => $educationDetail
  1598.             )
  1599.         );
  1600.     }
  1601.     public function ViewIndividualReviewAction()
  1602.     {
  1603.         return $this->render('ApplicationBundle:pages/human_resource/views:individual_review.html.twig',
  1604.             array(
  1605.                 'page_title' => 'Individual Performance View',
  1606.             )
  1607.         );
  1608.     }
  1609.     public function EmployeeListBySkillPerformanceAction()
  1610.     {
  1611.         $em $this->getDoctrine()->getManager();
  1612.         $employee $em->getRepository('ApplicationBundle:EmployeeDetails')->findAll();
  1613.         $skill $em->getRepository('ApplicationBundle:Skill')->findAll();
  1614.         return $this->render('ApplicationBundle:pages/human_resource/list:employee_performance_evolution_list.html.twig',
  1615.             array(
  1616.                 'page_title' => 'Employee Skill & Performance',
  1617.                 'employee' => $employee,
  1618.                 //'employeeSkill' => json_decode($employee->getSkill(),true),
  1619.                 'skill' => $skill,
  1620.             )
  1621.         );
  1622.     }
  1623.     public function setWorkPlaceAction(Request $req)
  1624.     {
  1625.         $em $this->getDoctrine()->getManager();
  1626.         $companyId $this->getLoggedUserCompanyId($req);
  1627. //        function getAddress($latitude, $longitude)
  1628. //        {
  1629. //            //google map api url
  1630. //            $url = "http://maps.google.com/maps/api/geocode/json?latlng=$latitude,$longitude";
  1631. //
  1632. //            // send http request
  1633. //            $geocode = file_get_contents($url);
  1634. //            $json = json_decode($geocode);
  1635. //            $address = $json->results[0]->formatted_address;
  1636. //            return $address;
  1637. //        }
  1638. //
  1639. //        $lat= 23.8623834; //latitude
  1640. //        $lng= 90.3979294; //longitude
  1641. //        $address= getAddress($lat,$lng);
  1642. //        if($address)
  1643. //        {
  1644. //            echo $address;
  1645. //        }
  1646. //        else
  1647. //        {
  1648. //            echo "Not found";
  1649. //        }
  1650.         if ($req->request->has('XHRreq')) {
  1651.             return new JsonResponse([HumanResource::HandelXHRreqForEmpWorkplace($em$req)]);
  1652.         }
  1653.         if ($req->isMethod('GET')) {
  1654.             $TwigData HumanResource::TwigDataForEmployeeWorkplace($em);
  1655.             return $this->render(
  1656.                 'ApplicationBundle:pages/human_resource/input_forms:set_workplace.html.twig',
  1657.                 [
  1658.                     'page_title' => 'Set Workplace',
  1659.                     'employeeIds' => $TwigData['employeeIds']
  1660.                 ]
  1661.             );
  1662.         }
  1663.         if ($req->isMethod('POST')) {
  1664.             $approveHash $req->request->get('approvalHash');
  1665.             $loginId $req->getSession()->get(UserConstants::USER_LOGIN_ID);
  1666.             $isSignatureOk DocValidation::isSignatureOk($em$loginId$approveHash);
  1667.             if ($isSignatureOk) {
  1668.                 $isSuccess HumanResource::CreateOrUpdateForEmpWorkplace($em$req$companyId);
  1669.                 if ($isSuccess) {
  1670.                     $this->addFlash(
  1671.                         'success',
  1672.                         'Workplace set!'
  1673.                     );
  1674.                     return $this->redirectToRoute('set_workplace');
  1675.                 }
  1676.             } else {
  1677.                 $this->addFlash(
  1678.                     'error',
  1679.                     'Invalid Approval Hash!'
  1680.                 );
  1681.                 return $this->redirectToRoute('set_workplace');
  1682.             }
  1683.         }
  1684.     }
  1685.     public function ViewMeetingAction(Request $req$action 0$id 0)
  1686.     {
  1687.         $em $this->getDoctrine()->getManager();
  1688.         $companyId $this->getLoggedUserCompanyId($req);
  1689.         if ($req->request->has('XHRreq')) {
  1690.             return new JsonResponse([HumanResource::HandelXHRreqForMeetingScheduling($em$req)]);
  1691.         }
  1692.         if ($action === 'view') {
  1693.             $response HumanResource::TwigDataForScheduledMeetingView($em$req$id);
  1694.             return $this->render(
  1695.                 'ApplicationBundle:pages/human_resource/views:scheduled_meeting_view.html.twig',
  1696.                 [
  1697.                     'page_title' => 'View Scheduled Meeting',
  1698.                     'duration' => $response['duration'],
  1699.                     'appId' => $response['appId'],
  1700.                     'publicView' => 0,
  1701.                     'meeting_data' => $response['meeting_data'],
  1702.                     'agenda_list' => $response['agenda_list'],
  1703.                     'id' => $req->query->get('view_meeting'),
  1704.                     'approval_data' => $response['approval_data'],
  1705.                     'document_log' => $response['document_log'],
  1706.                     'approval_status' => $response['approval_status'],
  1707.                     'created_by' => $response['created_by'],
  1708.                     'updated_at' => $response['updated_at'],
  1709.                     'auto_created' => 0,
  1710.                 ]
  1711.             );
  1712.         }
  1713.         if ($action === 'print') {
  1714.             $response HumanResource::TwigDataForScheduledMeetingView($em$req$id);
  1715. //      $id = $req->query->get('print_meeting');
  1716.             $em $this->getDoctrine()->getManager();
  1717.             $company_data Company::getCompanyData($em1);
  1718.             $Authorizations System::getSignatureListForDocumentPrint($emarray_flip(GeneralConstant::$Entity_list)['ScheduledMeeting'], $id);
  1719.             return $this->render(
  1720.                 'ApplicationBundle:pages/human_resource/print:scheduled_meeting_print.html.twig',
  1721.                 array(
  1722.                     'page_title' => 'View Scheduled Meeting',
  1723.                     'duration' => $response['duration'],
  1724.                     'meeting_data' => $response['meeting_data'],
  1725.                     'agenda_list' => $response['agenda_list'],
  1726.                     'export' => 'pdf,print',
  1727.                     'company_name' => $company_data->getName(),
  1728.                     'company_data' => $company_data,
  1729.                     'company_address' => $company_data->getAddress(),
  1730.                     'company_image' => $company_data->getImage(),
  1731.                     'Authorizations' => $Authorizations,
  1732.                     'red' => 0
  1733.                 )
  1734.             );
  1735.         }
  1736.     }
  1737.     public function UpdateMeetingMinutesAction(Request $req$action 0$id 0)
  1738.     {
  1739.         $em $this->getDoctrine()->getManager();
  1740.         $companyId $this->getLoggedUserCompanyId($req);
  1741.         $scheduleId $req->request->get('scheduleId');
  1742.         $minuteText $req->request->get('minuteText');
  1743.         $agendaKey $req->request->get('key');
  1744.         $scheduledMeeting $em->getRepository(ScheduledMeeting::class)
  1745.             ->find($scheduleId);
  1746.         $agendaList json_decode($scheduledMeeting->getAgendaList(), true);
  1747.         foreach ($agendaList as $key => $item) {
  1748.             if ($key == $agendaKey)
  1749.                 $agendaList[$key]['minutes'] = $minuteText;
  1750.         }
  1751.         $scheduledMeeting->setAgendaList(json_encode($agendaList));
  1752.         $em->flush();
  1753.         return new JsonResponse(array(
  1754.             'success' => true
  1755.         ));
  1756.     }
  1757.     public function SendMeetingUpdatesAction(Request $req$action 0$id 0)
  1758.     {
  1759.         $em $this->getDoctrine()->getManager();
  1760.         $companyId $this->getLoggedUserCompanyId($req);
  1761.         $session $req->getSession();
  1762.         $companyData Company::getCompanyData($em$companyId);
  1763.         $scheduleId $req->request->get('scheduleId');
  1764.         $minuteText $req->request->get('minuteText');
  1765.         $agendaKey $req->request->get('key');
  1766.         $scheduledMeeting $em->getRepository(ScheduledMeeting::class)
  1767.             ->find($scheduleId);
  1768.         $sendEmailInvitationTo json_decode($scheduledMeeting->getAllParticipantsNameEmail(), true);
  1769.         if ($sendEmailInvitationTo == null)
  1770.             $sendEmailInvitationTo = [];
  1771.         $agendaList json_decode($scheduledMeeting->getAgendaList(), true);
  1772.         if ($agendaList == null)
  1773.             $agendaList = [];
  1774.         $EmployeeList HumanResource::GetEmployeeList($em, []);
  1775.         $meetingType MeetingSchedulingConstant::$meetingType[$scheduledMeeting->getMeetingType()];
  1776.         foreach ($sendEmailInvitationTo as $key => $email) {
  1777.             $name ucWords(str_replace("_"" "$key));
  1778.             $bodyHtml '';
  1779.             $bodyTemplate 'ApplicationBundle:email/meeting_scheduling:scheduled_meeting_update.html.twig';
  1780.             $bodyData = array(
  1781.                 'name' => $name,
  1782.                 'gocId' => $session->get(UserConstants::USER_GOC_ID),
  1783.                 'appId' => $session->get(UserConstants::USER_APP_ID),
  1784.                 'email' => $email,
  1785.                 'meetingData' => $scheduledMeeting,
  1786.                 'meeting_type' => $meetingType,
  1787.                 'agenda_list' => $agendaList,
  1788.                 'companyData' => $companyData,
  1789.                 'employeeList' => $EmployeeList,
  1790.             );
  1791.             $attachments = [];
  1792.             $new_mail $this->get('mail_module');
  1793.             $new_mail->sendMyMail(array(
  1794.                 'senderHash' => '_MEETING_',
  1795.                 'forwardToMailAddress' => $email,
  1796.                 'subject' => "Meeting Updates Arranged By - " $companyData->getName() . " on " $scheduledMeeting->getTitle() . ". ",
  1797.                 'fileName' => '',
  1798.                 'attachments' => $attachments,
  1799.                 'toAddress' => $email,
  1800.                 'mailTemplate' => $bodyTemplate,
  1801.                 'templateData' => $bodyData,
  1802.                 'embedCompanyImage' => 1,
  1803.                 'companyId' => $companyId,
  1804.                 'companyImagePath' => $companyData->getImage()
  1805.             ));
  1806.         }
  1807.         return new JsonResponse(array(
  1808.             'success' => true
  1809.         ));
  1810.     }
  1811.     public function meetingSchedulingAction(Request $req$action 0)
  1812.     {
  1813.         $em $this->getDoctrine()->getManager();
  1814.         $companyId $this->getLoggedUserCompanyId($req);
  1815.         $session $req->getSession();
  1816.         if ($req->request->has('XHRreq')) {
  1817.             return new JsonResponse([HumanResource::HandelXHRreqForMeetingScheduling($em$req)]);
  1818.         }
  1819.         if ($action === 'list') {
  1820.             $response HumanResource::TwigDataForScheduledMeetingList($em, [0null]);
  1821.             return $this->render(
  1822.                 'ApplicationBundle:pages/human_resource/list:scheduled_meeting_list.html.twig',
  1823.                 [
  1824.                     'page_title' => 'Scheduled Meeting List',
  1825.                     'list' => $response
  1826.                 ]
  1827.             );
  1828.         }
  1829.         if ($req->isMethod('GET')) {
  1830.             $response HumanResource::twigDataForMeetingScheduling($em);
  1831.             return $this->render(
  1832.                 'ApplicationBundle:pages/human_resource/input_forms:meeting_scheduling.html.twig',
  1833.                 [
  1834.                     'page_title' => 'Schedule a Meeting',
  1835.                     'employeeIds' => $response['employeeIds'],
  1836.                     'branches' => $response['branches'],
  1837.                     'asset' => $response['asset'],
  1838.                     'rooms' => $response['rooms'],
  1839.                     'sales_orders' => $response['salesOrders'],
  1840.                     'purchase_orders' => $response['purchaseOrders'],
  1841.                     'meeting_types' => $response['meetingType'],
  1842.                 ]
  1843.             );
  1844.         }
  1845.         if ($req->isMethod('POST')) {
  1846.             $approveHash $req->request->get('approvalHash');
  1847.             $approveRole $req->request->get('approvalRole');
  1848.             $loginId $req->getSession()->get(UserConstants::USER_LOGIN_ID);
  1849.             $isSignatureOk DocValidation::isSignatureOk($em$loginId$approveHash);
  1850.             $companyData Company::getCompanyData($em$companyId);
  1851.             if ($isSignatureOk) {
  1852.                 $isSuccess HumanResource::createOrUpdateDataForMeetingScheduling($em$req);
  1853.                 if ($isSuccess) {
  1854.                     $options = array(
  1855.                         'notification_enabled' => $this->container->getParameter('notification_enabled'),
  1856.                         'notification_server' => $this->container->getParameter('notification_server'),
  1857.                         'appId' => $req->getSession()->get(UserConstants::USER_APP_ID),
  1858.                         'url' => $this->generateUrl(
  1859.                             GeneralConstant::$Entity_list_details[array_flip(GeneralConstant::$Entity_list)['ScheduledMeeting']]['entity_view_route_path_name']
  1860.                         )
  1861.                     );
  1862.                     $meetingId $isSuccess[1];
  1863.                     System::setApprovalInfo(
  1864.                         $this->getDoctrine()->getManager(),
  1865.                         $options,
  1866.                         array_flip(GeneralConstant::$Entity_list)['ScheduledMeeting'],
  1867.                         $meetingId,
  1868.                         $req->getSession()->get(UserConstants::USER_LOGIN_ID),
  1869.                         0//normal meeting
  1870.                         0,
  1871.                         $this->get('mail_module')
  1872.                     );
  1873.                     System::createEditSignatureHash(
  1874.                         $this->getDoctrine()->getManager(),
  1875.                         array_flip(GeneralConstant::$Entity_list)['ScheduledMeeting'],
  1876.                         $meetingId,
  1877.                         $loginId,
  1878.                         $approveRole,
  1879.                         $req->request->get('approvalHash')
  1880.                     );
  1881.                     $url $this->generateUrl(
  1882.                         'view_scheduled_meeting'
  1883.                     );
  1884.                     return $this->redirect($url "/" $meetingId);
  1885.                 } else {
  1886.                     return new JsonResponse(array(
  1887.                         'success' => false
  1888.                     ));
  1889.                 }
  1890.             } else {
  1891.                 $this->addFlash(
  1892.                     'error',
  1893.                     'Invalid Approval Hash!'
  1894.                 );
  1895.                 return $this->redirectToRoute('meeting_scheduling');
  1896.             }
  1897.         }
  1898.         return $this->redirectToRoute('meeting_scheduling');
  1899.     }
  1900.     public function CreateTrainingScheduleAction(Request $req$action 0)
  1901.     {
  1902.         $em $this->getDoctrine()->getManager();
  1903.         $companyId $this->getLoggedUserCompanyId($req);
  1904.         $session $req->getSession();
  1905.         if ($req->request->has('XHRreq')) {
  1906.             return new JsonResponse([HumanResource::HandelXHRreqForMeetingScheduling($em$req)]);
  1907.         }
  1908.         if ($action === 'list') {
  1909.             $response HumanResource::TwigDataForScheduledMeetingList($em, [1]);
  1910.             return $this->render(
  1911.                 'ApplicationBundle:pages/human_resource/list:scheduled_meeting_list.html.twig',
  1912.                 [
  1913.                     'page_title' => 'Training Schedule List',
  1914.                     'list' => $response
  1915.                 ]
  1916.             );
  1917.         }
  1918.         if ($req->isMethod('GET')) {
  1919.         }
  1920.         if ($req->isMethod('POST')) {
  1921.             $approveHash $req->request->get('approvalHash');
  1922.             $approveRole $req->request->get('approvalRole');
  1923.             $loginId $req->getSession()->get(UserConstants::USER_LOGIN_ID);
  1924.             $isSignatureOk DocValidation::isSignatureOk($em$loginId$approveHash);
  1925.             $companyData Company::getCompanyData($em$companyId);
  1926.             if ($isSignatureOk) {
  1927.                 $isSuccess HumanResource::createOrUpdateDataForMeetingScheduling($em$req);
  1928.                 if ($isSuccess) {
  1929.                     $options = array(
  1930.                         'notification_enabled' => $this->container->getParameter('notification_enabled'),
  1931.                         'notification_server' => $this->container->getParameter('notification_server'),
  1932.                         'appId' => $req->getSession()->get(UserConstants::USER_APP_ID),
  1933.                         'url' => $this->generateUrl(
  1934.                             GeneralConstant::$Entity_list_details[array_flip(GeneralConstant::$Entity_list)['ScheduledMeeting']]['entity_view_route_path_name']
  1935.                         )
  1936.                     );
  1937.                     $meetingId $isSuccess[1];
  1938.                     System::setApprovalInfo(
  1939.                         $this->getDoctrine()->getManager(),
  1940.                         $options,
  1941.                         array_flip(GeneralConstant::$Entity_list)['ScheduledMeeting'],
  1942.                         $meetingId,
  1943.                         $req->getSession()->get(UserConstants::USER_LOGIN_ID),
  1944.                         '',
  1945.                         0,
  1946.                         $this->get('mail_module')
  1947.                     );
  1948.                     System::createEditSignatureHash(
  1949.                         $this->getDoctrine()->getManager(),
  1950.                         array_flip(GeneralConstant::$Entity_list)['ScheduledMeeting'],
  1951.                         $meetingId,
  1952.                         $loginId,
  1953.                         $approveRole,
  1954.                         $req->request->get('approvalHash')
  1955.                     );
  1956.                     $url $this->generateUrl(
  1957.                         'view_scheduled_meeting'
  1958.                     );
  1959.                     return $this->redirect($url "/" $meetingId);
  1960.                 } else {
  1961.                     return new JsonResponse(array(
  1962.                         'success' => false
  1963.                     ));
  1964.                 }
  1965.             } else {
  1966.                 $this->addFlash(
  1967.                     'error',
  1968.                     'Invalid Approval Hash!'
  1969.                 );
  1970.                 return $this->redirectToRoute('create_training_schedule');
  1971.             }
  1972.         }
  1973.         $response HumanResource::twigDataForTrainingScheduling($em);
  1974.         return $this->render(
  1975.             'ApplicationBundle:pages/human_resource/input_forms:create_training_schedule.html.twig',
  1976.             [
  1977.                 'page_title' => 'Schedule a Training',
  1978.                 'employeeIds' => $response['employeeIds'],
  1979.                 'branches' => $response['branches'],
  1980.                 'asset' => $response['asset'],
  1981.                 'rooms' => $response['rooms'],
  1982.                 'courseList' => $response['courseList'],
  1983.                 'sales_orders' => $response['salesOrders'],
  1984.                 'purchase_orders' => $response['purchaseOrders'],
  1985.                 'meeting_types' => $response['meetingType'],
  1986.                 'skillList' => $response['skillList'],
  1987.             ]
  1988.         );
  1989.     }
  1990.     public function ScheduledTrainingListAction(Request $req$action 0)
  1991.     {
  1992.         $em $this->getDoctrine()->getManager();
  1993.         $companyId $this->getLoggedUserCompanyId($req);
  1994.         $session $req->getSession();
  1995.         $response HumanResource::TwigDataForScheduledMeetingList($em, [1]);
  1996.         return $this->render(
  1997.             'ApplicationBundle:pages/human_resource/list:scheduled_training_list.html.twig',
  1998.             [
  1999.                 'page_title' => 'Scheduled Trainings ',
  2000.                 'list' => $response
  2001.             ]
  2002.         );
  2003.     }
  2004.     public function ScheduledInterviewListAction(Request $req$action 0)
  2005.     {
  2006.         $em $this->getDoctrine()->getManager();
  2007.         $companyId $this->getLoggedUserCompanyId($req);
  2008.         $session $req->getSession();
  2009.         $response HumanResource::TwigDataForScheduledMeetingList($em, [2]);
  2010.         return $this->render(
  2011.             'ApplicationBundle:pages/human_resource/list:scheduled_interview_list.html.twig',
  2012.             [
  2013.                 'page_title' => 'Scheduled Interviews ',
  2014.                 'list' => $response
  2015.             ]
  2016.         );
  2017.     }
  2018.     public function GetFilteredQuestionsAction(Request $request$search '')
  2019.     {
  2020.         $em $this->getDoctrine()->getManager();
  2021.         $companyId $this->getLoggedUserCompanyId($request);
  2022.         if ($search == '' || $search == '_EMPTY_')
  2023.             $Query "SELECT  * FROM questionnaire WHERE 1 limit 10;";
  2024.         else
  2025.             $Query "SELECT  * FROM questionnaire WHERE question_text like '%$search%'  limit 10;";
  2026.         $stmt $em->getConnection()->prepare($Query);
  2027.         $stmt->execute();
  2028.         $queryResult $stmt->fetchAll();
  2029.         $parent_head_ids = [];
  2030.         $queryResultIndexed = [];
  2031.         foreach ($queryResult as $dt) {
  2032.             $queryResultIndexed[$dt['question_id']] = $dt;
  2033.         }
  2034.         return new JsonResponse(array(
  2035.             'data' => $queryResult,
  2036.             'queryResultIndexed' => $queryResultIndexed,
  2037.         ));
  2038.     }
  2039.     public function CreateTrainingCourseAction(Request $request$id 0)
  2040.     {
  2041.         $em $this->getDoctrine()->getManager();
  2042.         $companyId $this->getLoggedUserCompanyId($request);
  2043.         $skills $em->getRepository('ApplicationBundle:Skill')->findAll();
  2044.         $courses $em->getRepository('ApplicationBundle:TrainingCourse')->findAll();
  2045.         if ($request->isMethod('POST')) {
  2046.             $loginId $request->getSession()->get(UserConstants::USER_LOGIN_ID);
  2047.             $skill = new TrainingCourse;
  2048.             $skill->setTitle($request->request->get('name'));
  2049.             $skill->setCourseHash($request->request->get('coursehash'));
  2050.             $skill->setTrainingMaterialText($request->request->get('overview'));
  2051.             $skill->setTaggedSkillHashes(json_encode($request->request->get('skill')));
  2052.             $skill->setCompanyId($companyId);
  2053.             //$skill->setEditFlag(1); //editable usually
  2054.             $skill->setCreatedLoginId($request->getSession()->get(UserConstants::USER_LOGIN_ID));
  2055.             //$skill->setApproved(GeneralConstant::APPROVAL_STATUS_PENDING);
  2056.             //$skill->setAutocreated(0);
  2057.             $em->persist($skill);
  2058.             $em->flush();
  2059.         }
  2060.         return $this->render(
  2061.             'ApplicationBundle:pages/human_resource/input_forms:create_training_course.html.twig',
  2062.             [
  2063.                 'page_title' => 'Create Training Course',
  2064.                 'skills' => $skills,
  2065.                 'courses' => $courses
  2066.             ]
  2067.         );
  2068.     }
  2069.     public function CreateEmployeeExpenseAllowanceSettingsAction(Request $request$id 0)
  2070.     {
  2071.         $em $this->getDoctrine()->getManager();
  2072.         $companyId $this->getLoggedUserCompanyId($request);
  2073.         $extDocData = [];
  2074.         $extDetailsData = [];
  2075.         if ($request->isMethod('POST')) {
  2076.             //            Generic::debugMessage($_POST);
  2077.             $em $this->getDoctrine()->getManager();
  2078.             $entity_id array_flip(GeneralConstant::$Entity_list)['EmployeeExpenseAllowanceSettings']; //change
  2079.             $dochash $request->request->get('docHash'); //change
  2080.             $loginId $request->getSession()->get(UserConstants::USER_LOGIN_ID);
  2081.             $approveRole $request->request->get('approvalRole');
  2082.             $approveHash $request->request->get('approvalHash');
  2083.             if (!DocValidation::isInsertable(
  2084.                 $em,
  2085.                 $entity_id,
  2086.                 $dochash,
  2087.                 $loginId,
  2088.                 $approveRole,
  2089.                 $approveHash,
  2090.                 $id
  2091.             )
  2092.             ) {
  2093.                 $this->addFlash(
  2094.                     'error',
  2095.                     'Sorry Could not insert Data.'
  2096.                 );
  2097.             } else {
  2098.                 $funcname 'EmployeeExpenseAllowanceSettings';
  2099.                 DeleteDocument::$funcname($em$id0);
  2100.                 $docId HumanResource::CreateSalarySegregationPolicy($em$request$companyId0);
  2101.                 //now add Approval info
  2102.                 $loginId $request->getSession()->get(UserConstants::USER_LOGIN_ID);
  2103.                 $approveRole $request->request->get('approvalRole');
  2104.                 $options = array(
  2105.                     'notification_enabled' => $this->container->getParameter('notification_enabled'),
  2106.                     'notification_server' => $this->container->getParameter('notification_server'),
  2107.                     'appId' => $request->getSession()->get(UserConstants::USER_APP_ID),
  2108.                     'url' => $this->generateUrl(
  2109.                         GeneralConstant::$Entity_list_details[array_flip(GeneralConstant::$Entity_list)['EmployeeExpenseAllowanceSettings']]['entity_view_route_path_name']
  2110.                     )
  2111.                 );
  2112.                 System::setApprovalInfo(
  2113.                     $this->getDoctrine()->getManager(),
  2114.                     $options,
  2115.                     array_flip(GeneralConstant::$Entity_list)['EmployeeExpenseAllowanceSettings'],
  2116.                     $docId,
  2117.                     $request->getSession()->get(UserConstants::USER_LOGIN_ID)
  2118.                 );
  2119.                 System::createEditSignatureHash(
  2120.                     $this->getDoctrine()->getManager(),
  2121.                     array_flip(GeneralConstant::$Entity_list)['EmployeeExpenseAllowanceSettings'],
  2122.                     $docId,
  2123.                     $loginId,
  2124.                     $approveRole,
  2125.                     $request->request->get('approvalHash')
  2126.                 );
  2127.                 $doc_here $this->getDoctrine()
  2128.                     ->getRepository('ApplicationBundle:EmployeeExpenseAllowanceSettings')
  2129.                     ->findOneBy(
  2130.                         array(
  2131.                             'id' => $docId
  2132.                         )
  2133.                     );
  2134.                 //notify
  2135.                 $this->addFlash(
  2136.                     'success',
  2137.                     'Settings Successfully Updated.'
  2138.                 );
  2139.                 $url $this->generateUrl(
  2140.                     GeneralConstant::$Entity_list_details[array_flip(GeneralConstant::$Entity_list)['EmployeeExpenseAllowanceSettings']]['entity_view_route_path_name']
  2141.                 );
  2142.                 System::AddNewNotification(
  2143.                     $this->container->getParameter('notification_enabled'),
  2144.                     $this->container->getParameter('notification_server'),
  2145.                     $request->getSession()->get(UserConstants::USER_APP_ID),
  2146.                     $request->getSession()->get(UserConstants::USER_COMPANY_ID),
  2147.                     "Salary Segregation Policy : " $doc_here->getDocumentHash() . " Has Been Created And is Under Processing",
  2148.                     'pos',
  2149.                     System::getPositionIdsByDepartment($emGeneralConstant::HRM_DEPARTMENT),
  2150.                     'success',
  2151.                     //                    $url . "/" . $TransID,
  2152.                     $url "/" $docId,
  2153.                     "Journal"
  2154.                 );
  2155.                 return $this->redirect($url "/" $docId);
  2156.             }
  2157.         }
  2158.         //for edits
  2159.         if ($id == 0) {
  2160.         } else {
  2161.             $extDocData $em->getRepository('ApplicationBundle:EmployeeExpenseAllowanceSettings')->findOneBy(
  2162.                 array(
  2163.                     'id' => $id///material
  2164.                 )
  2165.             );
  2166.             //now if its not editable, redirect to view
  2167.             if ($extDocData) {
  2168.                 if ($extDocData->getEditFlag() != 1) {
  2169. //          $url = $this->generateUrl(
  2170. ////              'view_salary_segregation_policy'
  2171. //              'salary_segregation_policy'
  2172. //          );
  2173. //          return $this->redirect($url . "/" . $id);
  2174.                 } else {
  2175. //          $extVoucherDetailsData = Accounts::GetVoucherDataForEdit($em, $voucherId);
  2176. //          $extDetailsData = $em->getRepository('ApplicationBundle:SalarySegregationPolicy')->findOneBy(
  2177. //              array(
  2178. //                  'transactionId' => $id, ///material
  2179. //
  2180. //              )
  2181. //          );
  2182.                 }
  2183.             } else {
  2184.             }
  2185.         }
  2186.         $employeeIds $em->getRepository("ApplicationBundle:Employee")->findAll();
  2187.         $employeeType HumanResourceConstant::$employeeType;
  2188.         $employeeExpenseAllowanceTypes HumanResourceConstant::$employeeExpenseAllowanceTypes;
  2189.         $Designation $em->getRepository("ApplicationBundle:SysDepartmentPosition")->findAll();
  2190.         $branch $em->getRepository("ApplicationBundle:Branch")->findAll();
  2191.         $departments $em->getRepository("ApplicationBundle:SysDepartment")->findAll();
  2192.         $department = [];
  2193.         foreach ($departments as $entry) {
  2194.             $department[$entry->getDepartmentId()] = array(
  2195.                 'id' => $entry->getDepartmentId(),
  2196.                 'name' => $entry->getDepartmentName(),
  2197.             );
  2198.         }
  2199.         return $this->render(
  2200.             'ApplicationBundle:pages/human_resource/input_forms:create_employee_expense_allowance_settings.html.twig',
  2201.             [
  2202.                 'page_title' => 'Employee Expense Allowance Settings',
  2203.                 'employeeIds' => $employeeIds,
  2204.                 'extId' => $id,
  2205.                 'extDocData' => $extDocData,
  2206.                 'employeeType' => $employeeType,
  2207.                 'employeeExpenseAllowanceTypes' => $employeeExpenseAllowanceTypes,
  2208.                 'Designation' => $Designation,
  2209.                 'branch' => $branch,
  2210.                 'department' => $department,
  2211.             ]
  2212.         );
  2213.     }
  2214.     public function EmployeeExpenseAllowanceSettingsListAction(Request $request)
  2215.     {
  2216.         $em $this->getDoctrine()->getManager();
  2217.         $allowed_ids = [];
  2218.         $companyId $this->getLoggedUserCompanyId($request);
  2219.         $listData HumanResource::GetDataForEmployeeExpenseAllowanceSettingsListAction($em$request->isMethod('POST') ? 'POST' 'GET'$request->request$companyId);
  2220.         if ($request->isMethod('POST')) {
  2221.             if ($request->query->has('dataTableQry')) {
  2222.                 return new JsonResponse(
  2223.                     $listData
  2224.                 );
  2225.             }
  2226.         }
  2227.         return $this->render('ApplicationBundle:pages/human_resource/list:employee_expense_allowance_settings_list.html.twig',
  2228. //         return $this->render('ApplicationBundle:pages/dashboard:test_pix_invent.html.twig',
  2229.             array(
  2230.                 'page_title' => 'Expense Allowance Settings List',
  2231. //            'data' => SalesOrderM::GetClientList($em, [], $companyId),
  2232. //            'client_types' => Client::GetClientType($em, $companyId),
  2233. //            'region_list' => Client::RegionList($em, $companyId),
  2234. //            'geographical_region_list' => Client::GeographicalRegionList($em, $companyId)
  2235.             )
  2236.         );
  2237.     }
  2238.     public function salarySegAction(Request $request$id 0)
  2239.     {
  2240.         $em $this->getDoctrine()->getManager();
  2241.         $companyId $this->getLoggedUserCompanyId($request);
  2242.         $extDocData = [];
  2243.         $extDetailsData = [];
  2244.         if ($request->isMethod('POST')) {
  2245.             //            Generic::debugMessage($_POST);
  2246.             $em $this->getDoctrine()->getManager();
  2247.             $entity_id array_flip(GeneralConstant::$Entity_list)['SalarySegregationPolicy']; //change
  2248.             $dochash $request->request->get('docHash'); //change
  2249.             $loginId $request->getSession()->get(UserConstants::USER_LOGIN_ID);
  2250.             $approveRole $request->request->get('approvalRole');
  2251.             $approveHash $request->request->get('approvalHash');
  2252.             if (!DocValidation::isInsertable(
  2253.                 $em,
  2254.                 $entity_id,
  2255.                 $dochash,
  2256.                 $loginId,
  2257.                 $approveRole,
  2258.                 $approveHash,
  2259.                 $id
  2260.             )
  2261.             ) {
  2262.                 $this->addFlash(
  2263.                     'error',
  2264.                     'Sorry Couldnot insert Data.'
  2265.                 );
  2266.             } else {
  2267.                 $funcname 'SalarySegregationPolicy';
  2268.                 DeleteDocument::$funcname($em$id0);
  2269.                 $docId HumanResource::CreateSalarySegregationPolicy($em$request$companyId0);
  2270.                 //now add Approval info
  2271.                 $loginId $request->getSession()->get(UserConstants::USER_LOGIN_ID);
  2272.                 $approveRole $request->request->get('approvalRole');
  2273.                 $options = array(
  2274.                     'notification_enabled' => $this->container->getParameter('notification_enabled'),
  2275.                     'notification_server' => $this->container->getParameter('notification_server'),
  2276.                     'appId' => $request->getSession()->get(UserConstants::USER_APP_ID),
  2277.                     'url' => $this->generateUrl(
  2278.                         GeneralConstant::$Entity_list_details[array_flip(GeneralConstant::$Entity_list)['SalarySegregationPolicy']]['entity_view_route_path_name']
  2279.                     )
  2280.                 );
  2281.                 System::setApprovalInfo(
  2282.                     $this->getDoctrine()->getManager(),
  2283.                     $options,
  2284.                     array_flip(GeneralConstant::$Entity_list)['SalarySegregationPolicy'],
  2285.                     $docId,
  2286.                     $request->getSession()->get(UserConstants::USER_LOGIN_ID),
  2287.                     3    //journal voucher
  2288.                 );
  2289.                 System::createEditSignatureHash(
  2290.                     $this->getDoctrine()->getManager(),
  2291.                     array_flip(GeneralConstant::$Entity_list)['SalarySegregationPolicy'],
  2292.                     $docId,
  2293.                     $loginId,
  2294.                     $approveRole,
  2295.                     $request->request->get('approvalHash')
  2296.                 );
  2297.                 $doc_here $this->getDoctrine()
  2298.                     ->getRepository('ApplicationBundle:SalarySegregationPolicy')
  2299.                     ->findOneBy(
  2300.                         array(
  2301.                             'id' => $docId
  2302.                         )
  2303.                     );
  2304.                 //notify
  2305.                 $this->addFlash(
  2306.                     'success',
  2307.                     'Policy Successfully Updated.'
  2308.                 );
  2309.                 $url $this->generateUrl(
  2310.                     'salary_segregation_policy'
  2311.                 );
  2312.                 System::AddNewNotification(
  2313.                     $this->container->getParameter('notification_enabled'),
  2314.                     $this->container->getParameter('notification_server'),
  2315.                     $request->getSession()->get(UserConstants::USER_APP_ID),
  2316.                     $request->getSession()->get(UserConstants::USER_COMPANY_ID),
  2317.                     "Salary Segregation Policy : " $doc_here->getDocumentHash() . " Has Been Created And is Under Processing",
  2318.                     'pos',
  2319.                     System::getPositionIdsByDepartment($emGeneralConstant::HRM_DEPARTMENT),
  2320.                     'success',
  2321.                     //                    $url . "/" . $TransID,
  2322.                     $url "/" $docId,
  2323.                     "Journal"
  2324.                 );
  2325.                 return $this->redirect($url "/" $docId);
  2326.             }
  2327.         }
  2328.         //for edits
  2329.         if ($id == 0) {
  2330.         } else {
  2331.             $extDocData $em->getRepository('ApplicationBundle:SalarySegregationPolicy')->findOneBy(
  2332.                 array(
  2333.                     'id' => $id///material
  2334.                 )
  2335.             );
  2336.             //now if its not editable, redirect to view
  2337.             if ($extDocData) {
  2338.                 if ($extDocData->getEditFlag() != 1) {
  2339. //          $url = $this->generateUrl(
  2340. ////              'view_salary_segregation_policy'
  2341. //              'salary_segregation_policy'
  2342. //          );
  2343. //          return $this->redirect($url . "/" . $id);
  2344.                 } else {
  2345. //          $extVoucherDetailsData = Accounts::GetVoucherDataForEdit($em, $voucherId);
  2346. //          $extDetailsData = $em->getRepository('ApplicationBundle:SalarySegregationPolicy')->findOneBy(
  2347. //              array(
  2348. //                  'transactionId' => $id, ///material
  2349. //
  2350. //              )
  2351. //          );
  2352.                 }
  2353.             } else {
  2354.             }
  2355.         }
  2356.         $employeeIds $em->getRepository(EmployeeDetails::class)->findAll();
  2357.         $employeeType HumanResourceConstant::$employeeType;
  2358.         $Designation $em->getRepository(SysDepartmentPosition::class)->findAll();
  2359.         $branch $em->getRepository(Branch::class)->findAll();
  2360.         $departments $em->getRepository(SysDepartment::class)->findAll();
  2361.         $department = [];
  2362.         foreach ($departments as $entry) {
  2363.             $department[$entry->getDepartmentId()] = array(
  2364.                 'id' => $entry->getDepartmentId(),
  2365.                 'name' => $entry->getDepartmentName(),
  2366.             );
  2367.         }
  2368.         return $this->render(
  2369.             'ApplicationBundle:pages/human_resource/input_forms:salary_segregation_policy.html.twig',
  2370.             [
  2371.                 'page_title' => 'Salary Segregation Policy',
  2372.                 'employeeIds' => $employeeIds,
  2373.                 'extId' => $id,
  2374.                 'extDocData' => $extDocData,
  2375.                 'employeeType' => $employeeType,
  2376.                 'Designation' => $Designation,
  2377.                 'branch' => $branch,
  2378.                 'department' => $department,
  2379.             ]
  2380.         );
  2381.     }
  2382.     public function GetSalarySegregationDataForEmployeeEntryAction(Request $request)
  2383.     {
  2384.         $em $this->getDoctrine()->getManager();
  2385.         $companyId $this->getLoggedUserCompanyId($request);
  2386.         if ($request->request->has('salSagDataReq')) {
  2387.             $ajaxData HumanResource::handelXhrForSalSeg($em$request);
  2388.             return new JsonResponse($ajaxData);
  2389.         }
  2390.         return new JsonResponse(array('success' => false));
  2391.     }
  2392.     public function WorkHourPolicyAction(Request $req$id 0)
  2393.     {
  2394.         $em $this->getDoctrine()->getManager();
  2395.         $companyId $this->getLoggedUserCompanyId($req);
  2396.         $extData = [];
  2397.         if ($id != 0) {
  2398.             $extData $em->getRepository('ApplicationBundle:WorkHourPolicy')
  2399.                 ->findOneBy(
  2400.                     array(
  2401.                         'id' => $id
  2402.                     )
  2403.                 );
  2404.         }
  2405.         if ($req->isMethod('POST')) {
  2406.             $storeDataRes HumanResource::checkSignature($em$req);
  2407.             if ($storeDataRes['hasErr']) {
  2408.                 $msg $storeDataRes['msg'];
  2409.                 $this->addFlash(
  2410.                     'error',
  2411.                     $msg
  2412.                 );
  2413.                 return $this->redirectToRoute('work_hour_policy');
  2414.             } else {
  2415.                 HumanResource::storeDataForWhPolicy($em$req$companyId);
  2416.                 $this->addFlash(
  2417.                     'success',
  2418.                     'Policy Successfully Created!'
  2419.                 );
  2420.                 return $this->redirectToRoute('work_hour_policy');
  2421.             }
  2422.         }
  2423.         $twigData HumanResource::twigDataForWorkHourPolicy($em);
  2424.         $timeZonesArray = array();
  2425.         return $this->render(
  2426.             'ApplicationBundle:pages/human_resource/input_forms:work_hour_policy.html.twig',
  2427.             [
  2428.                 'page_title' => 'Work Hour Policy',
  2429.                 'extId' => $id,
  2430.                 'extData' => $extData,
  2431.                 'employeeIds' => $twigData['employeeIds'],
  2432.                 'employeeType' => $twigData['employeeType'],
  2433.                 'Designation' => $twigData['Designation'],
  2434.                 'branch' => $twigData['branch'],
  2435.                 'department' => $twigData['department'],
  2436.             ]
  2437.         );
  2438.     }
  2439.     public function WorkHourPolicyListAction(Request $request)
  2440.     {
  2441.         $em $this->getDoctrine()->getManager();
  2442.         $allowed_ids = [];
  2443.         $companyId $this->getLoggedUserCompanyId($request);
  2444.         $listData HumanResource::GetDataForWorkHourPolicyListAction($em$request->isMethod('POST') ? 'POST' 'GET'$request->request$companyId);
  2445.         if ($request->isMethod('POST')) {
  2446.             if ($request->query->has('dataTableQry')) {
  2447.                 return new JsonResponse(
  2448.                     $listData
  2449.                 );
  2450.             }
  2451.         }
  2452.         return $this->render('ApplicationBundle:pages/human_resource/list:work_hour_policy_list.html.twig',
  2453. //         return $this->render('ApplicationBundle:pages/dashboard:test_pix_invent.html.twig',
  2454.             array(
  2455.                 'page_title' => 'Work Hour Policy List',
  2456. //            'data' => SalesOrderM::GetClientList($em, [], $companyId),
  2457. //            'client_types' => Client::GetClientType($em, $companyId),
  2458. //            'region_list' => Client::RegionList($em, $companyId),
  2459. //            'geographical_region_list' => Client::GeographicalRegionList($em, $companyId)
  2460.             )
  2461.         );
  2462.     }
  2463.     public function WorkPlacePolicyListAction(Request $request)
  2464.     {
  2465.         $em $this->getDoctrine()->getManager();
  2466.         $workplacePolicyDetails $em->getRepository('ApplicationBundle:EmployeeWorkplace')->findAll();
  2467. //        $employee = $em->getRepository('ApplicationBundle:Employee')->findAll();
  2468.         return $this->render('ApplicationBundle:pages/human_resource/list:work_place_policy_list.html.twig', array(
  2469.             'page_title' => 'Work Place Policy List',
  2470.             'workplacePolicyDetails' => $workplacePolicyDetails,
  2471. //            'employee'=>$employee
  2472.         ));
  2473.     }
  2474.     public function workPlacePolicyAction(Request $data$id)
  2475.     {
  2476.         $em $this->getDoctrine()->getManager();
  2477.         $workPlacePolicy $em->getRepository('ApplicationBundle:EmployeeWorkplace')->find($id);
  2478.         $employee $em->getRepository(Employee::class)->findAll();
  2479.         $Approval_data System::checkIfApprovalExists(
  2480.             $em,
  2481.             array_flip(GeneralConstant::$Entity_list)['EmployeeWorkplace'],
  2482.             $id,
  2483.             $data->getSession()->get(UserConstants::USER_LOGIN_ID)
  2484.         );
  2485.         $ApprovalStatus GeneralConstant::$approvalStatus;
  2486.         return $this->render('ApplicationBundle:pages/human_resource/views:viewWorkPlacePolicy.html.twig', array(
  2487.             'page_title' => 'Work Place Policy  View',
  2488.             'workPlacePolicy' => $workPlacePolicy,
  2489.             'employee' => $employee,
  2490.             'approval_data' => $Approval_data,
  2491.             'approval_status' => $workPlacePolicy->getApproved(),
  2492.             'id' => $id,
  2493.         ));
  2494.     }
  2495.     public function SalarySegregationPolicyListAction(Request $request)
  2496.     {
  2497.         $em $this->getDoctrine()->getManager();
  2498.         $allowed_ids = [];
  2499.         $companyId $this->getLoggedUserCompanyId($request);
  2500.         $listData HumanResource::GetDataForSalarySegregationPolicyListAction($em$request->isMethod('POST') ? 'POST' 'GET'$request->request$companyId);
  2501.         if ($request->isMethod('POST')) {
  2502.             if ($request->query->has('dataTableQry')) {
  2503.                 return new JsonResponse(
  2504.                     $listData
  2505.                 );
  2506.             }
  2507.         }
  2508.         return $this->render('ApplicationBundle:pages/human_resource/list:salary_segregation_policy_list.html.twig',
  2509. //         return $this->render('ApplicationBundle:pages/dashboard:test_pix_invent.html.twig',
  2510.             array(
  2511.                 'page_title' => 'Salary Segregation Policy List',
  2512. //            'data' => SalesOrderM::GetClientList($em, [], $companyId),
  2513. //            'client_types' => Client::GetClientType($em, $companyId),
  2514. //            'region_list' => Client::RegionList($em, $companyId),
  2515. //            'geographical_region_list' => Client::GeographicalRegionList($em, $companyId)
  2516.             )
  2517.         );
  2518.     }
  2519.     public function HolidayCalendarListAction(Request $request)
  2520.     {
  2521.         $q $this->getDoctrine()
  2522.             ->getRepository('ApplicationBundle:HolidayCalendar')
  2523.             ->findBy(
  2524.                 array(
  2525. //                'status' => GeneralConstant::ACTIVE,
  2526.                     'CompanyId' => $this->getLoggedUserCompanyId($request)
  2527. //                    'approved' =>  GeneralConstant::APPROVED,
  2528.                 )
  2529.             );
  2530.         $stage_list = array(
  2531.             => 'Pending',
  2532.             => 'Pending',
  2533.             => 'Complete',
  2534.             => 'Partial',
  2535.         );
  2536.         $data = [];
  2537.         foreach ($q as $entry) {
  2538.             $data[] = array(
  2539. //          'doc_date' => $entry->getSalesReplacementDate(),
  2540.                 'id' => $entry->getHolidayCalendarId(),
  2541.                 'title' => $entry->getHoliDayTitle(),
  2542.                 'approval_status' => GeneralConstant::$approvalStatus[$entry->getApproved()],
  2543. //          'stage' => $stage_list[$entry->getStage()]
  2544.             );
  2545.         }
  2546.         return $this->render('ApplicationBundle:pages/human_resource/list:holiday_calendar_list.html.twig',
  2547.             array(
  2548.                 'page_title' => 'Holiday Calendar List',
  2549.                 'data' => $data
  2550.             )
  2551.         );
  2552.     }
  2553.     public function PayrollPolicyListAction(Request $request)
  2554.     {
  2555.         $em $this->getDoctrine()->getManager();
  2556.         $allowed_ids = [];
  2557.         $companyId $this->getLoggedUserCompanyId($request);
  2558.         $listData HumanResource::GetDataForPayrollPolicyListAction($em$request->isMethod('POST') ? 'POST' 'GET'$request->request$companyId);
  2559.         if ($request->isMethod('POST')) {
  2560.             if ($request->query->has('dataTableQry')) {
  2561.                 return new JsonResponse(
  2562.                     $listData
  2563.                 );
  2564.             }
  2565.         }
  2566.         return $this->render('ApplicationBundle:pages/human_resource/list:payroll_policy_list.html.twig',
  2567. //         return $this->render('ApplicationBundle:pages/dashboard:test_pix_invent.html.twig',
  2568.             array(
  2569.                 'page_title' => 'Payroll Policy List',
  2570. //            'data' => SalesOrderM::GetClientList($em, [], $companyId),
  2571. //            'client_types' => Client::GetClientType($em, $companyId),
  2572. //            'region_list' => Client::RegionList($em, $companyId),
  2573. //            'geographical_region_list' => Client::GeographicalRegionList($em, $companyId)
  2574.             )
  2575.         );
  2576.     }
  2577.     public function payslipAction(Request $req$action 0$id 0)
  2578.     {
  2579.         $em $this->getDoctrine()->getManager();
  2580.         $attendanceSource HumanResourceConstant::$attendanceSources;
  2581.         if ($action === 'list') {
  2582.             $response HumanResource::twigDataForPayslipList($em);
  2583.             $approval_status GeneralConstant::$approvalAction;
  2584.             return $this->render(
  2585.                 'ApplicationBundle:pages/human_resource/list:payslip_list.html.twig',
  2586.                 [
  2587.                     'page_title' => 'Payslip List',
  2588.                     'reports' => $response,
  2589.                     'approval_status' => $approval_status
  2590.                 ]
  2591.             );
  2592.         }
  2593.         if ($action === 'view') {
  2594.             $response HumanResource::twigDataForPayslipViewAndPrint($em$req$id);
  2595.             return $this->render(
  2596.                 'ApplicationBundle:pages/human_resource/views:payslip_view.html.twig',
  2597.                 [
  2598.                     'page_title' => 'View Payslip',
  2599.                     'approval_data' => $response['approval_data'],
  2600.                     'payslip' => $response['payslip'],
  2601.                     'document_log' => $response['document_log'],
  2602.                     'approval_status' => $response['approval_status'],
  2603.                     'created_by' => $response['created_by'],
  2604.                     'updated_at' => $response['updated_at'],
  2605.                     'employeeId' => $response['employeeId'],
  2606.                     'totalAttendance' => $response['totalPresent'],
  2607.                     'leaveList' => HumanResourceConstant::$LeaveType,
  2608.                     'AttReportData' => $response['AttReportData'],
  2609. //                    'attendanceLog' => $response['attendanceLog'],
  2610.                     'attendanceSource' => $attendanceSource,
  2611.                     'auto_created' => 0,
  2612.                 ]
  2613.             );
  2614.         }
  2615.         if ($action === 'print') {
  2616.             $em $this->getDoctrine()->getManager();
  2617.             $company_data Company::getCompanyData($em1);
  2618.             $Authorizations System::getSignatureListForDocumentPrint($emarray_flip(GeneralConstant::$Entity_list)['Payslip'], $id);
  2619.             $response HumanResource::twigDataForPayslipViewAndPrint($em$req$id);
  2620.             return $this->render(
  2621.                 'ApplicationBundle:pages/human_resource/print:payslip_print.html.twig',
  2622.                 array(
  2623.                     'page_title' => 'Print Payslip',
  2624.                     'export' => 'pdf,print',
  2625.                     'payslip' => $response['payslip'],
  2626.                     'company_name' => $company_data->getName(),
  2627.                     'company_data' => $company_data,
  2628.                     'company_address' => $company_data->getAddress(),
  2629.                     'company_image' => $company_data->getImage(),
  2630.                     'Authorizations' => $Authorizations,
  2631.                     'totalAttendance' => $response['totalPresent'],
  2632.                     'leaveList' => HumanResourceConstant::$LeaveType,
  2633.                     'AttReportData' => $response['AttReportData'],
  2634.                     'attendanceSource' => $attendanceSource,
  2635.                     'red' => 0
  2636.                 )
  2637.             );
  2638.         }
  2639.         if ($req->isMethod('POST')) {
  2640.             $sigRes HumanResource::checkSignature($em$req);
  2641.             if ($sigRes['hasErr']) {
  2642.                 $msg $sigRes['msg'];
  2643.                 return new JsonResponse(['success' => false'msg' => $msg]);
  2644.             }
  2645.             HumanResource::storeDataForPayslip($em$req);
  2646.             return new JsonResponse(['success' => true]);
  2647.         }
  2648.     }
  2649.     public function applicantInfoAction(Request $request$id)
  2650.     {
  2651.         $em $this->getDoctrine()->getManager('company_group');
  2652.         $session $request->getSession();
  2653.         $consultantDetails $em->getRepository(EntityApplicantDetails::class)->find($session->get(UserConstants::USER_ID));
  2654.         $skillDetails $em->getRepository(EntitySkill::class)->findAll();
  2655.         $companyId $this->getLoggedUserCompanyId($request);
  2656.         $gender HumanResourceConstant::$sex;
  2657.         $blood HumanResourceConstant::$BloodGroup;
  2658.         $userId $session->get(UserConstants::USER_ID);
  2659.         $encData $request->query->has('ref') ? $request->query->get('ref') : '';
  2660.         $education = array(
  2661.             'instituteName' => $request->get('instituteName'),
  2662.             'courseOfStudy' => $request->get('courseOfStudy'),
  2663.             'courseStartDate' => $request->get('courseStartDate'),
  2664.             'courseEndDate' => $request->get('courseEndDate'),
  2665.             'result' => $request->get('result'),
  2666.             'grade' => $request->get('grade'),
  2667.             'degree' => $request->get('degree'),
  2668.         );
  2669.         $workExperience = array(
  2670.             'title' => $request->get('title'),
  2671.             'companyName' => $request->get('companyName'),
  2672.             'jobStartDate' => $request->get('jobStartDate'),
  2673.             'jobEndDate' => $request->get('jobEndDate'),
  2674.             'description' => $request->get('description'),
  2675.         );
  2676.         $certificate = array(
  2677.             'certificatename' => $request->get('certificatename'),
  2678.             'issuedDate' => $request->get('issuedDate'),
  2679.         );
  2680.         $courses = array(
  2681.             'courseName' => $request->get('courseName'),
  2682.             'date' => $request->get('date'),
  2683.             'duration' => $request->get('duration')
  2684.         );
  2685.         $languages = array(
  2686.             'languageName' => $request->get('languageName'),
  2687.             'writtenSkill' => $request->get('writtenSkill'),
  2688.             'verbalSkill' => $request->get('verbalSkill'),
  2689.         );
  2690.         if ($request->isMethod('POST')) {
  2691.             if ($consultantDetails)
  2692.                 $consultant $consultantDetails;
  2693.             else
  2694.                 $consultant = new EntityApplicantDetails();
  2695.             $consultant->setApplicationText($request->request->get('applicationText'));
  2696.             $consultant->setFirstname($request->request->get('firstname'));
  2697.             $consultant->setLastname($request->request->get('lastname'));
  2698.             $consultant->setIsImgLegal($request->request->get('is_img_legal'));
  2699.             $consultant->setNid($request->request->get('nid'));
  2700.             $consultant->setDob(new \DateTime($request->get('dob')));
  2701.             $consultant->setSex($request->request->get('sex'));
  2702.             $consultant->setFather($request->request->get('father'));
  2703.             $consultant->setMother($request->request->get('mother'));
  2704.             $consultant->setBlood($request->request->get('blood'));
  2705.             $consultant->setPhone($request->request->get('phone'));
  2706.             $consultant->setCountry($request->request->get('country'));
  2707.             $consultant->setPostalCode($request->request->get('postalCode'));
  2708.             $consultant->setCurrAddr($request->request->get('curr_addr'));
  2709.             $consultant->setSkill(json_encode($request->request->get('skill')));
  2710.             $consultant->setEmergencyContactNumber($request->request->get('emm_contact'));
  2711.             $consultant->setCurrentEmployment($request->request->get('currentEmployment'));
  2712.             $consultant->setTin($request->request->get('tin'));
  2713.             $consultant->setEducationData(json_encode($education));
  2714.             $consultant->setWorkExperienceData(json_encode($workExperience));
  2715.             $consultant->setCertificateData(json_encode($certificate));
  2716.             $consultant->setCoursesData(json_encode($courses));
  2717.             $consultant->setLanguagesData(json_encode($languages));
  2718.             $consultant->setWorkExperienceYear($request->request->get('workExperienceYear'));
  2719.             //$consultant->setApplyForConsultant(1);
  2720.             $em->persist($consultant);
  2721.             $em->flush();
  2722.             $path "";
  2723.             $defaultProductImage '';
  2724.             $uploadedFile null;
  2725.             $upl_dir $this->container->getParameter('kernel.root_dir') . '/../web/uploads/applicantCv/';
  2726.             $uploadedFile $request->files->get('docUpload');
  2727.             if ($uploadedFile != null) {
  2728.                 $fileName 'cv' $consultantDetails->getApplicantId() . '.' $uploadedFile->guessExtension();
  2729.                 $path $fileName;
  2730. //            $upl_dir = $this->container->getParameter('kernel.root_dir') . '/../web/uploads/Products/';
  2731.                 if (!file_exists($upl_dir)) {
  2732.                     mkdir($upl_dir0777true);
  2733.                 }
  2734.                 $uploadedFile->move($upl_dir$path);
  2735.                 $defaultProductImage 'uploads/applicantCv/' $path;
  2736.                 $consultant->setDocImage($defaultProductImage);
  2737.                 $em->flush();
  2738.             }
  2739.             $this->addFlash(
  2740.                 'success',
  2741.                 'Data Updated.'
  2742.             );
  2743.             if ($encData != '') {
  2744.                 $url $this->generateUrl(
  2745.                     'applicant_job_recruitment_view'
  2746.                 );
  2747.                 return $this->redirect($url '?auto_apply=1&encData=' $encData);
  2748.             }
  2749.             $url $this->generateUrl(
  2750.                 'job_recruitment_list_applicant'
  2751.             );
  2752.             return $this->redirect($url);
  2753.         }
  2754.         return $this->render('ApplicationBundle:pages/human_resource/input_forms:applicant_info.html.twig', array(
  2755.             'page_title' => 'My Information ',
  2756.             'gender' => $gender,
  2757.             'blood' => $blood,
  2758.             'consultantDetails' => $consultantDetails,
  2759.             'education' => json_decode($consultantDetails->getEducationData(), true),
  2760.             'workExperience' => json_decode($consultantDetails->getWorkExperienceData(), true),
  2761.             'certificate' => json_decode($consultantDetails->getCertificateData(), true),
  2762.             'courses' => json_decode($consultantDetails->getCoursesData(), true),
  2763.             'languages' => json_decode($consultantDetails->getLanguagesData(), true),
  2764.             'skill' => json_decode($consultantDetails->getSkill(), true),
  2765.             'skillDetails' => $skillDetails
  2766.         ));
  2767. //        $em = $this->getDoctrine()->getManager('company_group');
  2768. //        $applicantRepo = $em->getRepository(EntityApplicantDetails::class);
  2769. //        $skillDetails = $em->getRepository(EntitySkill::class)->findAll();
  2770. //
  2771. //
  2772. //        if ($req->isMethod('POST')) {
  2773. //            $applicant = $applicantRepo->find($id);
  2774. //
  2775. //            if ($req->files->get('img')) {
  2776. //                $ImgName = HumanResource::StoreFiles($req->files->get('img'), 'Applicant');
  2777. //                $applicant->setImage($ImgName);
  2778. //            }
  2779. //
  2780. //            $applicant->setFirstname($req->request->get('firstname'));
  2781. //            $applicant->setLastname($req->request->get('lastname'));
  2782. //            $applicant->setIsImgLegal($req->request->get('is_img_legal'));
  2783. //            $applicant->setNid($req->request->get('nid'));
  2784. //            $applicant->setDob(HumanResource::StringToDate($req->request->get('dob')));
  2785. //            $applicant->setSex($req->request->get('sex'));
  2786. //            $applicant->setFather($req->request->get('father'));
  2787. //            $applicant->setMother($req->request->get('mother'));
  2788. //            $applicant->setSpouse($req->request->get('spouse'));
  2789. //            $applicant->setChild1($req->request->get('child_1'));
  2790. //            $applicant->setChild2($req->request->get('child_2'));
  2791. //            $applicant->setBlood($req->request->get('blood'));
  2792. //            $applicant->setPhone($req->request->get('phone'));
  2793. //            $applicant->setOAuthEmail($req->request->get('oauth_email'));
  2794. //            $applicant->setCurrAddr($req->request->get('curr_addr'));
  2795. //            $applicant->setPermAddr($req->request->get('perm_addr'));
  2796. //            $applicant->setEmmContact($req->request->get('emm_contact'));
  2797. //
  2798. //            $applicant->setInst1($req->request->get('inst1'));
  2799. //            $applicant->setYr1($req->request->get('yr1'));
  2800. //            $applicant->setDur1($req->request->get('dur1'));
  2801. //            $applicant->setInst2($req->request->get('inst2'));
  2802. //            $applicant->setYr2($req->request->get('yr2'));
  2803. //            $applicant->setDur2($req->request->get('dur2'));
  2804. //            $applicant->setInst3($req->request->get('inst3'));
  2805. //            $applicant->setYr3($req->request->get('yr3'));
  2806. //            $applicant->setDur3($req->request->get('dur3'));
  2807. //            $applicant->setEinst1($req->request->get('einst1'));
  2808. //            $applicant->setEyr1($req->request->get('eyr1'));
  2809. //            $applicant->setEdeg1($req->request->get('edeg1'));
  2810. //            $applicant->setEinst2($req->request->get('einst2'));
  2811. //            $applicant->setEyr2($req->request->get('eyr2'));
  2812. //            $applicant->setEdeg2($req->request->get('edeg2'));
  2813. //            $applicant->setEinst3($req->request->get('einst3'));
  2814. //            $applicant->setEyr3($req->request->get('eyr3'));
  2815. //            $applicant->setEdeg3($req->request->get('edeg3'));
  2816. //
  2817. //            $em->persist($applicant);
  2818. //            $em->flush();
  2819. //
  2820. //            return $this->render(
  2821. //                'ApplicationBundle:pages/human_resource/input_forms:applicant_info.html.twig',
  2822. //                [
  2823. //                    'page_title' => 'Applicant Info',
  2824. //                    'applicant_info' => $applicant,
  2825. //                    'blood' => HumanResourceConstant::$BloodGroup,
  2826. //                    'gender' => HumanResourceConstant::$sex,
  2827. //                    'skillDetails' => $skillDetails,
  2828. //                    'HasUpdateMode' => true,
  2829. //                ]
  2830. //            );
  2831. //        }
  2832. //
  2833. //        if ($id) {
  2834. //            $applicant = $applicantRepo->find($id);
  2835. //
  2836. //            return $this->render(
  2837. //                'ApplicationBundle:pages/human_resource/input_forms:applicant_info.html.twig',
  2838. //                [
  2839. //                    'page_title' => 'Applicant Info',
  2840. //                    'applicant_info' => $applicant,
  2841. //                    'blood' => HumanResourceConstant::$BloodGroup,
  2842. //                    'gender' => HumanResourceConstant::$sex,
  2843. //                    'skillDetails' => $skillDetails,
  2844. //                    'HasUpdateMode' => false,
  2845. //                ]
  2846. //            );
  2847. //        }
  2848. //
  2849. //        $google_client = new Google_Client();
  2850. //        $google_client->setClientId('916737688016-l2qfmb9p37cumudkaqpu8s7ndngq9una.apps.googleusercontent.com');
  2851. //        $google_client->setClientSecret('BEWpEBRvv3-hSoB4cGBrVB3z');
  2852. //        $google_client->setRedirectUri('http://localhost/applicant_info');
  2853. //        $google_client->addScope('email');
  2854. //        $google_client->addScope('profile');
  2855.     }
  2856.     public function applicantDashboardAction()
  2857.     {
  2858.         return new JsonResponse(['this is applicant dashboard']);
  2859.     }
  2860.     public function resignApplicationAction(Request $req$id)
  2861.     {
  2862.         $em $this->getDoctrine()->getManager();
  2863.         if ($req->request->has('xhrReq')) {
  2864.             $response HumanResource::HandelXhrForResignApplication($em$req);
  2865.             return new JsonResponse($response);
  2866.         }
  2867.         if ($req->isMethod('GET')) {
  2868.             $applicant $em->getRepository(EmployeeDetails::class)->findBy(['emp_status' => 1]);
  2869.             $resignReason HumanResourceConstant::$resignReason;
  2870.             return $this->render(
  2871.                 'ApplicationBundle:pages/human_resource/input_forms:resign_application.html.twig',
  2872.                 [
  2873.                     'page_title' => 'Resign Application',
  2874.                     'employeeIds' => $applicant,
  2875.                     'resignReasons' => $resignReason,
  2876.                     'HasUpdateMode' => false,
  2877.                 ]
  2878.             );
  2879.         }
  2880.         if ($req->isMethod('POST')) {
  2881.             $approveHash $req->request->get('approvalHash');
  2882.             $loginId $req->getSession()->get(UserConstants::USER_LOGIN_ID);
  2883.             $isSignatureOk DocValidation::isSignatureOk($em$loginId$approveHash);
  2884.             if ($isSignatureOk) {
  2885.                 $response HumanResource::storeResignApplicationData($em$req);
  2886.                 if ($response) {
  2887.                     return $this->redirectToRoute(
  2888.                         'view_resign_application',
  2889.                         array('id' => $response->getResignApplicationId()),
  2890.                         Response::HTTP_MOVED_PERMANENTLY
  2891.                     );
  2892.                 }
  2893.             } else {
  2894.                 $this->addFlash(
  2895.                     'error',
  2896.                     'Invalid Approval Hash!'
  2897.                 );
  2898.                 return $this->redirectToRoute('resign_application');
  2899.             }
  2900.         }
  2901.     }
  2902.     public function viewResignApplicationAction(Request $req$id 0)
  2903.     {
  2904.         $em $this->getDoctrine()->getManager();
  2905.         $response HumanResource::twigDataForResignApplicationView($em$req$id);
  2906.         return $this->render(
  2907.             'ApplicationBundle:pages/human_resource/views:resign_application_view.html.twig',
  2908.             [
  2909.                 'page_title' => 'View Resign Application',
  2910.                 'approval_data' => $response['approval_data'],
  2911.                 'application' => $response['application'],
  2912.                 'applicant' => $response['applicant'],
  2913.                 'document_log' => $response['document_log'],
  2914.                 'approval_status' => $response['approval_status'],
  2915.                 'created_by' => $response['created_by'],
  2916.                 'updated_at' => $response['updated_at'],
  2917.                 'auto_created' => 0,
  2918.             ]
  2919.         );
  2920.     }
  2921.     public function printResignApplicationAction(Request $req$id)
  2922.     {
  2923.         if ($id) {
  2924.             $em $this->getDoctrine()->getManager();
  2925.             $company_data Company::getCompanyData($em1);
  2926.             $authorizations System::getSignatureListForDocumentPrint($emarray_flip(GeneralConstant::$Entity_list)['ResignApplication'], $id);
  2927.             $response HumanResource::twigDataForResignApplicationView($em$req$id);
  2928.             return $this->render(
  2929.                 'ApplicationBundle:pages/human_resource/print:resign_application_print.html.twig',
  2930.                 array(
  2931.                     'page_title' => 'Print Resign Application',
  2932.                     'export' => 'pdf,print',
  2933.                     'company_name' => $company_data->getName(),
  2934.                     'company_data' => $company_data,
  2935.                     'company_address' => $company_data->getAddress(),
  2936.                     'company_image' => $company_data->getImage(),
  2937.                     'application' => $response['application'],
  2938.                     'applicant' => $response['applicant'],
  2939.                     'Authorizations' => $authorizations,
  2940.                     'red' => 0
  2941.                 )
  2942.             );
  2943.         }
  2944.         return new JsonResponse(array(
  2945.             'success' => false,
  2946.             'msg' => 'Wrong URL format! Please try with application ID'
  2947.         ));
  2948.     }
  2949.     public function listResignApplicationAction(Request $req)
  2950.     {
  2951.         $em $this->getDoctrine()->getManager();
  2952.         $response HumanResource::getResignApplicationList($em$req);
  2953.         return $this->render("ApplicationBundle:pages/human_resource/list:resign_application_list.html.twig", array(
  2954.             'page_title' => 'Leave Application List',
  2955.             'applications' => $response,
  2956.         ));
  2957.     }
  2958.     public function viewNocApprovalAction(Request $req$id)
  2959.     {
  2960.         $em $this->getDoctrine()->getManager();
  2961.         $response HumanResource::twigDataForNocView($em$req$id);
  2962.         return $this->render(
  2963.             'ApplicationBundle:pages/human_resource/views:noc_view.html.twig',
  2964.             [
  2965.                 'page_title' => 'View NOC',
  2966.                 'approval_data' => $response['approval_data'],
  2967.                 'noc_application' => $response['noc_application'],
  2968.                 'resign_application' => $response['resign_application'],
  2969.                 'applicant' => $response['applicant'],
  2970.                 'document_log' => $response['document_log'],
  2971.                 'approval_status' => $response['approval_status'],
  2972.                 'created_by' => $response['created_by'],
  2973.                 'updated_at' => $response['updated_at'],
  2974.                 'auto_created' => 0,
  2975.             ]
  2976.         );
  2977.     }
  2978.     public function printNocApprovalAction(Request $req$id)
  2979.     {
  2980.         $em $this->getDoctrine()->getManager();
  2981.         $company_data Company::getCompanyData($em1);
  2982.         $Authorizations System::getSignatureListForDocumentPrint($emarray_flip(GeneralConstant::$Entity_list)['NocApproval'], $id);
  2983.         $response HumanResource::twigDataForNocView($em$req$id);
  2984.         return $this->render(
  2985.             'ApplicationBundle:pages/human_resource/print:noc_print.html.twig',
  2986.             [
  2987.                 'page_title' => 'Print NOC',
  2988.                 'noc_application' => $response['noc_application'],
  2989.                 'resign_application' => $response['resign_application'],
  2990.                 'applicant' => $response['applicant'],
  2991.                 'export' => 'pdf,print',
  2992.                 'company_name' => $company_data->getName(),
  2993.                 'company_data' => $company_data,
  2994.                 'company_address' => $company_data->getAddress(),
  2995.                 'company_image' => $company_data->getImage(),
  2996.                 'Authorizations' => $Authorizations,
  2997.                 'red' => 0
  2998.             ]
  2999.         );
  3000.     }
  3001.     public function createHolidayAction(Request $request$id)
  3002.     {
  3003.         $em $this->getDoctrine()->getManager();
  3004.         $companyId $this->getLoggedUserCompanyId($request);
  3005.         if ($request->isMethod('POST')) {
  3006.             $entity_id array_flip(GeneralConstant::$Entity_list)['HolidayCalendar']; //change
  3007.             $dochash $request->request->get('doc_hash'); //change
  3008.             $loginId $request->getSession()->get(UserConstants::USER_LOGIN_ID);
  3009.             $approveRole $request->request->get('approvalRole');
  3010.             $approveHash $request->request->get('approvalHash');
  3011.             if (!DocValidation::isInsertable(
  3012.                 $em,
  3013.                 $entity_id,
  3014.                 $dochash,
  3015.                 $loginId,
  3016.                 $approveRole,
  3017.                 $approveHash,
  3018.                 $id
  3019.             )
  3020.             ) {
  3021.                 $this->addFlash(
  3022.                     'error',
  3023.                     'Sorry Couldnot insert Data.'
  3024.                 );
  3025.             } else {
  3026.                 $funcname 'HolidayCalendar';
  3027.                 $doc_id $id;
  3028.                 DeleteDocument::$funcname($em$doc_id0);
  3029.                 if ($id != 0)
  3030.                     $HolidayCalender $em->getRepository(HolidayCalendar::class)->find($id);
  3031.                 else
  3032.                     $HolidayCalender = new HolidayCalendar;
  3033.                 $HolidayCalender->setDocumentHash($request->request->get('doc_hash'));
  3034.                 $HolidayCalender->setHoliDayTitle($request->request->get('holidayCalendarTitle'));
  3035.                 $HolidayCalender->setEmployeeIds(json_encode($request->request->get('employee')));
  3036.                 $HolidayCalender->setEmployeeTypeIds(json_encode($request->request->get('emp_status')));
  3037.                 $HolidayCalender->setDesignationIds(json_encode($request->request->get('desg', [])));
  3038.                 $HolidayCalender->setDepartmentIds(json_encode($request->request->get('dept', [])));
  3039.                 $HolidayCalender->setBranchIds(json_encode($request->request->get('branch', [])));
  3040.                 $HolidayCalender->setLevelSelectionStr($request->get('levelSelectionStr'''));
  3041.                 $HolidayCalender->setLevels(json_encode(HumanResource::getLevelsFromLevelSelectionStr($request->get('levelSelectionStr'''))));
  3042.                 $HolidayCalender->setCompanyId($companyId);
  3043.                 $HolidayCalender->setTypeHash('HD');
  3044.                 $HolidayCalender->setEditFlag(1); //editable usually
  3045.                 $HolidayCalender->setPrefixHash($request->request->get('prefix'));
  3046.                 $HolidayCalender->setAssocHash($request->request->get('assoc'));
  3047.                 $HolidayCalender->setNumberHash($request->request->get('number_hash'));
  3048.                 $HolidayCalender->setCreatedLoginId($request->getSession()->get(UserConstants::USER_LOGIN_ID));
  3049.                 $HolidayCalender->setApproved(GeneralConstant::APPROVAL_STATUS_PENDING);
  3050.                 $HolidayCalender->setAutocreated(0);
  3051. //
  3052. //        $arr = [
  3053. //            'date' =>$request->request->get('start_date'),
  3054. //            'title' => $request->request->get('title'),
  3055. //        ];
  3056. //
  3057. //        $HolidayCalender->setData(json_encode($arr));
  3058.                 $em->persist($HolidayCalender);
  3059.                 $em->flush();
  3060.                 $indHolidays = [];
  3061.                 if ($request->request->has('start_date'))
  3062.                     $indHolidays $request->request->get('start_date');
  3063.                 foreach ($indHolidays as $ind => $dateRangeStr) {
  3064.                     $currRow $request->request->get('row')[$ind];//string
  3065.                     $holidayTitle $request->request->get('title')[$ind];//string
  3066.                     $currStartDate $request->request->get('start_date')[$ind];//string
  3067.                     $currEndDate $request->request->get('end_date')[$ind];//string
  3068.                     $HolidayDate = new HolidayCalendarDates();
  3069.                     $HolidayDate->setHolidayCalendarId($HolidayCalender->getHolidayCalendarId());
  3070.                     $HolidayDate->setDateRange($currStartDate '-' $currEndDate);//string
  3071.                     $HolidayDate->setStartDate(new \DateTime($currStartDate));//date
  3072.                     $HolidayDate->setEndDate(new \DateTime($currEndDate ' 23:59:59'));//date
  3073.                     $HolidayDate->setHolidayTitle($holidayTitle);
  3074. //          $HolidayDate->setIsVariableEachYearFlag($request->request->get('is_variable_each_year',null));
  3075.                     $HolidayDate->setIsVariableEachYearFlag($request->request->get('is_variable_each_year_' $currRownull));
  3076.                     $HolidayDate->setAllDayFlag($request->request->get('all_day_flag_' $currRow1));
  3077.                     $em->persist($HolidayDate);
  3078.                     $em->flush();
  3079.                 }
  3080.                 $options = [];
  3081.                 $entity array_flip(GeneralConstant::$Entity_list)['HolidayCalendar'];
  3082.                 $loginId $request->getSession()->get(UserConstants::USER_LOGIN_ID);
  3083.                 $approveRole $request->request->get('approvalRole');
  3084.                 System::setApprovalInfo(
  3085.                     $em,
  3086.                     $options,
  3087.                     $entity,
  3088.                     $HolidayCalender->getHolidayCalendarId(),
  3089.                     $request->getSession()->get(UserConstants::USER_LOGIN_ID)
  3090.                 );
  3091.                 System::createEditSignatureHash(
  3092.                     $em,
  3093.                     $entity,
  3094.                     $HolidayCalender->getHolidayCalendarId(),
  3095.                     $loginId,
  3096.                     $approveRole,
  3097.                     $request->request->get('approvalHash')
  3098.                 );
  3099.                 $url $this->generateUrl(
  3100.                     'view_holiday_calendar'
  3101.                 );
  3102.                 return $this->redirect($url "/" $HolidayCalender->getHolidayCalendarId());
  3103.             }
  3104.         }
  3105.         $em $this->getDoctrine()->getManager();
  3106.         $branches $em->getRepository(Branch::class)->findAll();
  3107.         $employee $em->getRepository(Employee::class)->findAll();
  3108.         $departments $em->getRepository(SysDepartment::class)->findAll();
  3109.         $departmentPositions $em->getRepository(SysDepartmentPosition::class)->findAll();
  3110.         $EmploymentStatus HumanResourceConstant::$employeeType;
  3111.         $em $this->getDoctrine()->getManager();
  3112.         $extDocData = [];
  3113.         if ($id != 0)
  3114.             $extDocData $em->getRepository(HolidayCalendar::class)->find($id);
  3115.         return $this->render(
  3116.             'ApplicationBundle:pages/human_resource/input_forms:create_holiday.html.twig',
  3117.             [
  3118.                 'page_title' => 'Create Holiday',
  3119.                 'branches' => $branches,
  3120.                 'id' => $id,
  3121.                 'extDocData' => $extDocData,
  3122.                 'departments' => $departments,
  3123.                 'departmentPositions' => $departmentPositions,
  3124.                 'employeeStatus' => $EmploymentStatus,
  3125.                 'employeeIds' => $employee,
  3126.                 'holidayCalendarList' => $em->getRepository('ApplicationBundle:HolidayCalendar')
  3127.                     ->findBy(array())
  3128.             ]
  3129.         );
  3130.     }
  3131.     public function HolidayViewAction(Request $request$id)
  3132.     {
  3133.         $em $this->getDoctrine()->getManager();
  3134.         $HolidaysCalendar $em->getRepository(HolidayCalendar::class)->find($id);
  3135.         $holidayCalendarDetails $em->getRepository('ApplicationBundle:HolidayCalendarDates')
  3136.             ->findBy(array(
  3137.                 'holidayCalendarId' => $id
  3138.             ));
  3139.         $Approval_data System::checkIfApprovalExists(
  3140.             $em,
  3141.             array_flip(GeneralConstant::$Entity_list)['HolidayCalendar'],
  3142.             $id,
  3143.             $request->getSession()->get(UserConstants::USER_LOGIN_ID)
  3144.         );
  3145.         return $this->render('ApplicationBundle:pages/human_resource/views:holidays_view.html.twig', array(
  3146.             'page_title' => 'View Holiday',
  3147.             'holidays' => $HolidaysCalendar,
  3148.             'holidayCalendarDetails' => $holidayCalendarDetails,
  3149.             'approval_status' => $HolidaysCalendar->getApproved(),
  3150.             'approval_data' => $Approval_data,
  3151.             'auto_created' => $HolidaysCalendar->getAutocreated(),
  3152.             'document_log' => $HolidaysCalendar->getAutocreated() == System::getDocumentLog(
  3153.                 $this->getDoctrine()->getManager(),
  3154.                 array_flip(GeneralConstant::$Entity_list)['HolidayCalendar'],
  3155.                 $id,
  3156.                 $HolidaysCalendar->getCreatedLoginId(),
  3157.                 $HolidaysCalendar->getEditedLoginId()
  3158.             ) : []
  3159.         ));
  3160.     }
  3161.     public function GetHolidayDetailsAction(Request $request$id)
  3162.     {
  3163.         $em $this->getDoctrine()->getManager();
  3164.         $holidayCalendar $em->getRepository('ApplicationBundle:HolidayCalendar')
  3165.             ->findOneBy(array(
  3166.                 'holidayCalendarId' => $id
  3167.             ));
  3168.         $holidayCalendarDetails $em->getRepository('ApplicationBundle:HolidayCalendarDates')
  3169.             ->findBy(array(
  3170.                 'holidayCalendarId' => $id
  3171.             ));
  3172.         $holidayList = [];
  3173.         foreach ($holidayCalendarDetails as $det) {
  3174.             $dateDet = array(
  3175.                 'title' => $det->getHolidayTitle(),
  3176.                 'startDate' => $det->getStartDate()->format('Y-m-d'),
  3177.                 'endDate' => $det->getEndDate()->format('Y-m-d'),
  3178.             );
  3179.             $holidayList[] = $dateDet;
  3180.         }
  3181.         return new JsonResponse(
  3182.             array(
  3183.                 'success' => true,
  3184.                 'holidayList' => $holidayList
  3185.             )
  3186.         );
  3187.     }
  3188.     public function GetHolidayListByEmployeeIdAction(Request $request$id)
  3189.     {
  3190.         $em $this->getDoctrine()->getManager();
  3191.         $options = [];
  3192.         $options['employeeId'] = $id;
  3193.         HumanResource::getFilteredHolidaysSingle($em$options);
  3194.         $holidayCalendar $em->getRepository('ApplicationBundle:HolidayCalendar')
  3195.             ->findOneBy(array(
  3196.                 'holidayCalendarId' => $id
  3197.             ));
  3198.         $holidayCalendarDetails $em->getRepository('ApplicationBundle:HolidayCalendarDates')
  3199.             ->findBy(array(
  3200.                 'holidayCalendarId' => $id
  3201.             ));
  3202.         $holidayList = [];
  3203.         foreach ($holidayCalendarDetails as $det) {
  3204.             $dateDet = array(
  3205.                 'title' => $det->getHolidayTitle(),
  3206.                 'startDate' => $det->getStartDate()->format('Y-m-d'),
  3207.                 'endDate' => $det->getEndDate()->format('Y-m-d'),
  3208.             );
  3209.             $holidayList[] = $dateDet;
  3210.         }
  3211.         return new JsonResponse(
  3212.             array(
  3213.                 'success' => true,
  3214.                 'holidayList' => $holidayList
  3215.             )
  3216.         );
  3217.     }
  3218.     public function createQuestionAction(Request $request)
  3219.     {
  3220.         $em $this->getDoctrine()->getManager();
  3221.         $em_goc $this->getDoctrine()->getManager('company_group');
  3222.         $companyId $this->getLoggedUserCompanyId($request);
  3223.         if ($request->isMethod('POST')) {
  3224.             $loginId $request->getSession()->get(UserConstants::USER_LOGIN_ID);
  3225.             $question = new Questionnaire();
  3226.             $question->setQuestionTitle($request->request->get('questionTitle'''));
  3227.             $question->setQuestionText($request->request->get('questionText'''));
  3228.             $question->setIsForPlanningItem($request->request->has('forPlanningItem') ? 0);
  3229.             $question->setIsForInterview($request->request->has('forInterview') ? 0);
  3230.             $question->setIsForMock($request->request->has('forMock') ? 0);
  3231.             $question->setIsForTraining($request->request->has('forTraining') ? 0);
  3232.             $question->setTaggedSkillHashes($request->request->get('skillHash'));
  3233.             $question->setCorrectAnswers(json_encode($request->request->get('correctAns')));
  3234.             $question->setCompanyId($companyId);
  3235.             $optionData = [];
  3236.             foreach ($request->request->get('optionText') as $key => $val) {
  3237.                 $option = array(
  3238.                     'index' => $request->request->get('optionIndex')[$key],
  3239.                     'text' => $val,
  3240.                 );
  3241.                 $optionData[] = $option;
  3242.             }
  3243.             $question->setOptions(json_encode($optionData));
  3244.             $question->setQuestionValueWeight(1);
  3245.             $question->setQuestionText($request->request->get('questionText'));
  3246.             $question->setUniqueHash('_NONE_');
  3247.             $question->setType($request->request->get('type'0));
  3248.             //$skill->setEditFlag(1); //editable usually
  3249.             $question->setCreatedLoginId($request->getSession()->get(UserConstants::USER_LOGIN_ID));
  3250.             //$skill->setApproved(GeneralConstant::APPROVAL_STATUS_PENDING);
  3251.             //$skill->setAutocreated(0);
  3252.             $em->persist($question);
  3253.             $em->flush();
  3254.             $questionId $question->getQuestionId();
  3255.             $file_path_list = [];
  3256.             if ($questionId != 0)
  3257.                 if (!empty($request->files)) {
  3258.                     MiscActions::RemoveFilesForEntityDoc($em_goc'Question'$questionId);
  3259.                     $storePath 'uploads/Questionnaire/';
  3260.                     $path "";
  3261.                     $file_path "";
  3262.                     $session $request->getSession();
  3263. //                    MiscActions::RemoveExpiredFiles($em_goc);
  3264.                     foreach ($request->files as $uploadedFileGG) {
  3265.                         //            if($uploadedFile->getImage())
  3266.                         //                var_dump($uploadedFile->getFile());
  3267.                         //                var_dump($uploadedFile);
  3268.                         $tempD $uploadedFileGG;
  3269.                         if (!is_array($uploadedFileGG)) {
  3270.                             $uploadedFileGG = array();
  3271.                             $uploadedFileGG[] = $tempD;
  3272.                         }
  3273.                         foreach ($uploadedFileGG as $uploadedFile) {
  3274.                             if ($uploadedFile != null) {
  3275.                                 $extension $uploadedFile->guessExtension();
  3276.                                 $size $uploadedFile->getSize();
  3277.                                 $fileName 'QUES_' $questionId '_' . (md5(uniqid())) . '.' $uploadedFile->guessExtension();
  3278.                                 $path $fileName;
  3279.                                 $upl_dir $this->container->getParameter('kernel.root_dir') . '/../web/' $storePath;
  3280.                                 if (!file_exists($upl_dir)) {
  3281.                                     mkdir($upl_dir0777true);
  3282.                                 }
  3283.                                 if (file_exists($upl_dir '' $path)) {
  3284.                                     chmod($upl_dir '' $path0755);
  3285.                                     unlink($upl_dir '' $path);
  3286.                                 }
  3287.                                 $file $uploadedFile->move($upl_dir$path);
  3288.                                 $expireNever 1;
  3289.                                 $expireTs 0;
  3290.                                 $EntityFile = new EntityFile();
  3291.                                 $EntityFile->setPath($this->container->getParameter('kernel.root_dir') . '/../web/' $storePath $path);
  3292.                                 $EntityFile->setMarker('_GEN_');
  3293.                                 $EntityFile->setExtension($extension);
  3294.                                 $EntityFile->setExpireTs($expireTs);
  3295.                                 $EntityFile->setSize($size);
  3296.                                 $EntityFile->setRelativePath($storePath $path);
  3297.                                 $EntityFile->setEntityName('Questionnaire');
  3298.                                 $EntityFile->setEntityBundle('ApplicationBundle');
  3299.                                 $EntityFile->setEntityId($questionId);
  3300.                                 $EntityFile->setEntityIdField('questionId');
  3301.                                 $EntityFile->setModifyFieldSetter('setFiles');
  3302.                                 $EntityFile->setDocIdForApplicant(0);
  3303.                                 $EntityFile->setUserId($session->get(UserConstants::USER_ID0));
  3304.                                 $EntityFile->setAppId($session->get(UserConstants::USER_APP_ID0));
  3305.                                 $EntityFile->setEmployeeId($session->get(UserConstants::USER_EMPLOYEE_ID0));
  3306.                                 $EntityFile->setUserType($session->get(UserConstants::USER_TYPE0));
  3307.                                 $em_goc->persist($EntityFile);
  3308.                                 $em_goc->flush();
  3309.                                 $EntityFileId $EntityFile->getId();
  3310.                             }
  3311.                             if ($path != "")
  3312.                                 $file_path_list[] = ($storePath $path);
  3313.                         }
  3314.                     }
  3315.                     $g_path $this->container->getParameter('kernel.root_dir') . '/../web/' $storePath $path;
  3316.                     $question->setFiles(implode(','$file_path_list));
  3317.                     $em->flush();
  3318.                 }
  3319.             if ($request->request->has('returnJson') || $request->query->has('returnJson')) {
  3320.                 if ($question)
  3321.                     return new JsonResponse(
  3322.                         array(
  3323.                             'id' => $questionId,
  3324.                             'value' => $questionId,
  3325.                             'question_id' => $questionId,
  3326.                             'text' => $question->getQuestionText(),
  3327.                             'question_text' => $question->getQuestionText(),
  3328.                             'question_title' => $question->getQuestionTitle(),
  3329.                             'files' => explode(','$question->getFiles()),
  3330.                             'options' => json_decode($question->getFiles(), true),
  3331.                             'answer_text' => '',
  3332.                             'success' => true
  3333.                         )
  3334.                     );
  3335.                 else
  3336.                     return new JsonResponse(
  3337.                         array(
  3338.                             'success' => false
  3339.                         )
  3340.                     );
  3341.             }
  3342.         }
  3343.         $skillDetails $em->getRepository(Skill::class)->findAll();
  3344.         $skillListObj = [];
  3345.         $skillListArray = [];
  3346.         foreach ($skillDetails as $skillDetail) {
  3347.             $dt = array(
  3348.                 'id' => $skillDetail->getSkillId(),
  3349.                 'name' => $skillDetail->getName(),
  3350.                 'hash' => $skillDetail->getUniqueHash(),
  3351.             );
  3352.             $skillListArray[] = $dt;
  3353.         }
  3354.         return $this->render('ApplicationBundle:pages/human_resource/input_forms:createQuestion.html.twig', array(
  3355.             'page_title' => 'Create Question',
  3356.             'skiillDetails' => $skillDetails,
  3357.             'skillListArray' => $skillListArray,
  3358.         ));
  3359.     }
  3360.     public function createSkillAction(Request $request)
  3361.     {
  3362.         $em $this->getDoctrine()->getManager();
  3363.         $companyId $this->getLoggedUserCompanyId($request);
  3364.         if ($request->isMethod('POST')) {
  3365.             $loginId $request->getSession()->get(UserConstants::USER_LOGIN_ID);
  3366.             $skill = new Skill;
  3367.             $skill->setName($request->request->get('skillName'));
  3368.             $skill->setParentId($request->request->get('parentName'));
  3369.             $skill->setUniqueHash($request->request->get('uniqueHash'));
  3370.             $skill->setCompanyId($companyId);
  3371.             //$skill->setEditFlag(1); //editable usually
  3372.             $skill->setCreatedLoginId($request->getSession()->get(UserConstants::USER_LOGIN_ID));
  3373.             //$skill->setApproved(GeneralConstant::APPROVAL_STATUS_PENDING);
  3374.             //$skill->setAutocreated(0);
  3375.             $em->persist($skill);
  3376.             $em->flush();
  3377.         }
  3378.         $skillDetails $em->getRepository(Skill::class)->findAll();
  3379.         return $this->render('ApplicationBundle:pages/human_resource/input_forms:createSkill.html.twig', array(
  3380.             'page_title' => 'Create Skill',
  3381.             'skiillDetails' => $skillDetails,
  3382.         ));
  3383.     }
  3384.     public function createEducationQualificationAction(Request $request)
  3385.     {
  3386.         $em $this->getDoctrine()->getManager();
  3387.         $companyId $this->getLoggedUserCompanyId($request);
  3388.         if ($request->isMethod('POST')) {
  3389.             $loginId $request->getSession()->get(UserConstants::USER_LOGIN_ID);
  3390.             $new = new EducationQualification;
  3391.             $new->setName($request->request->get('educationName'));
  3392.             $new->setParentId($request->request->get('parentName'));
  3393.             $new->setUniqueHash($request->request->get('uniqueHash'));
  3394.             $new->setCompanyId($companyId);
  3395.             //$skill->setEditFlag(1); //editable usually
  3396.             $new->setCreatedLoginId($request->getSession()->get(UserConstants::USER_LOGIN_ID));
  3397.             //$skill->setApproved(GeneralConstant::APPROVAL_STATUS_PENDING);
  3398.             //$skill->setAutocreated(0);
  3399.             $em->persist($new);
  3400.             $em->flush();
  3401.         }
  3402.         $educationDetails $em->getRepository(EducationQualification::class)->findAll();
  3403.         return $this->render('ApplicationBundle:pages/human_resource/input_forms:create_education.html.twig', array(
  3404.             'page_title' => 'Create Education',
  3405.             'educationDetails' => $educationDetails,
  3406.         ));
  3407.     }
  3408.     public function createEvaluationCategoryAction(Request $request$id 0)
  3409.     {
  3410.         $em $this->getDoctrine()->getManager();
  3411.         $companyId $this->getLoggedUserCompanyId($request);
  3412.         if ($request->isMethod('POST')) {
  3413.             $loginId $request->getSession()->get(UserConstants::USER_LOGIN_ID);
  3414.             $new = new EvaluationCategory;
  3415.             $new->setName($request->request->get('name'));
  3416.             $new->setBranch($request->request->get('branch'));
  3417.             $new->setSelectionType($request->request->get('selection_type'));
  3418.             $new->setEmployeeIds($request->request->get('selected_employeeIds'));
  3419.             $new->setEmployeeTypeIds($request->request->get('employee_types'));
  3420.             $new->setDesignationIds($request->request->get('designation'));
  3421.             $new->setDesignationIds($request->request->get('designation'));
  3422.             $new->setmark($request->request->get('mark'));
  3423.             $new->setSkills(json_encode($request->request->get('skill')));
  3424.             $new->setLevelSelectionStr($request->request->get('levelSelectionStr'));
  3425.             $new->setCompanyId($companyId);
  3426.             $new->setCreatedLoginId($request->getSession()->get(UserConstants::USER_LOGIN_ID));
  3427.             $em->persist($new);
  3428.             $em->flush();
  3429.         }
  3430.         $skill $em->getRepository(Skill::class)->findAll();
  3431.         $employeeIds $em->getRepository(EmployeeDetails::class)->findAll();
  3432.         $employeeType HumanResourceConstant::$employeeType;
  3433.         $Designation $em->getRepository(SysDepartmentPosition::class)->findAll();
  3434.         $branch $em->getRepository(Branch::class)->findAll();
  3435.         $departments $em->getRepository(SysDepartment::class)->findAll();
  3436.         $department = [];
  3437.         foreach ($departments as $entry) {
  3438.             $department[$entry->getDepartmentId()] = array(
  3439.                 'id' => $entry->getDepartmentId(),
  3440.                 'name' => $entry->getDepartmentName(),
  3441.             );
  3442.             return $this->render('ApplicationBundle:pages/human_resource/input_forms:create_evaluation_category.html.twig', array(
  3443.                 'page_title' => 'Create Evaluation Category',
  3444.                 'employeeIds' => $employeeIds,
  3445.                 'employeeType' => $employeeType,
  3446.                 'Designation' => $Designation,
  3447.                 'branch' => $branch,
  3448.                 'department' => $department,
  3449.                 'skill' => $skill,
  3450.             ));
  3451.         }
  3452.     }
  3453.     public function createWorkplaceHarassmentAction(Request $request$id 0)
  3454.     {
  3455.         $em $this->getDoctrine()->getManager();
  3456.         $employeeIds $em->getRepository(EmployeeDetails::class)->findAll();
  3457.         //$employeeType = HumanResourceConstant::$employeeType;
  3458.         $Designation $em->getRepository(SysDepartmentPosition::class)->findAll();
  3459.         $branches $em->getRepository(Branch::class)->findAll();
  3460.         $departments $em->getRepository(SysDepartment::class)->findAll();
  3461.         $harassmentType HumanResourceConstant::$harrasmentType;
  3462.         $department = [];
  3463.         foreach ($departments as $entry) {
  3464.             $department[$entry->getDepartmentId()] = array(
  3465.                 'id' => $entry->getDepartmentId(),
  3466.                 'name' => $entry->getDepartmentName(),
  3467.             );
  3468.         }
  3469.         return $this->render('ApplicationBundle:pages/human_resource/input_forms:create_workplace_harrasment.html.twig', array(
  3470.             'page_title' => 'Create Workplace Harrasment',
  3471.             'employeeIds' => $employeeIds,
  3472.             'branches' => $branches,
  3473.             'harassmentType' => $harassmentType,
  3474.             'departments' => $department,
  3475.             'designationIds' => $Designation
  3476.         ));
  3477.     }
  3478.     public function ViewHarasssmentComplainAction()
  3479.     {
  3480.         return $this->render('ApplicationBundle:pages/human_resource/views:view_harassment_compalin.html.twig', array(
  3481.             'page_title' => 'View Harassment Complain',
  3482.         ));
  3483.     }
  3484.     public function createWorkplaceViolenceAction(Request $request$id 0)
  3485.     {
  3486.         $em $this->getDoctrine()->getManager();
  3487.         $employeeIds $em->getRepository(EmployeeDetails::class)->findAll();
  3488.         //$employeeType = HumanResourceConstant::$employeeType;
  3489.         $Designation $em->getRepository(SysDepartmentPosition::class)->findAll();
  3490.         $branches $em->getRepository(Branch::class)->findAll();
  3491.         $departments $em->getRepository(SysDepartment::class)->findAll();
  3492.         $harassmentType HumanResourceConstant::$harrasmentType;
  3493.         $department = [];
  3494.         foreach ($departments as $entry) {
  3495.             $department[$entry->getDepartmentId()] = array(
  3496.                 'id' => $entry->getDepartmentId(),
  3497.                 'name' => $entry->getDepartmentName(),
  3498.             );
  3499.         }
  3500.         return $this->render('ApplicationBundle:pages/human_resource/input_forms:register_workplace_complaint.html.twig', array(
  3501.             'page_title' => 'Register Complaint',
  3502.             'employeeIds' => $employeeIds,
  3503.             'branches' => $branches,
  3504.             'harassmentType' => $harassmentType,
  3505.             'departments' => $department,
  3506.             'designationIds' => $Designation
  3507.         ));
  3508.     }
  3509.     public function createBonusPolicyAction(Request $request$id 0)
  3510.     {
  3511.         $em $this->getDoctrine()->getManager();
  3512.         $companyId $this->getLoggedUserCompanyId($request);
  3513.         $extDocData = [];
  3514.         $extDetailsData = [];
  3515.         if ($request->isMethod('POST')) {
  3516.             //            Generic::debugMessage($_POST);
  3517.             $em $this->getDoctrine()->getManager();
  3518.             $entity_id array_flip(GeneralConstant::$Entity_list)['BonusPolicy']; //change
  3519.             $dochash $request->request->get('docHash'); //change
  3520.             $loginId $request->getSession()->get(UserConstants::USER_LOGIN_ID);
  3521.             $approveRole $request->request->get('approvalRole');
  3522.             $approveHash $request->request->get('approvalHash');
  3523.             if (!DocValidation::isInsertable(
  3524.                 $em,
  3525.                 $entity_id,
  3526.                 $dochash,
  3527.                 $loginId,
  3528.                 $approveRole,
  3529.                 $approveHash,
  3530.                 $id
  3531.             )
  3532.             ) {
  3533.                 $this->addFlash(
  3534.                     'error',
  3535.                     'Sorry Couldnot insert Data.'
  3536.                 );
  3537.             } else {
  3538.                 $funcname 'BonusPolicy';
  3539.                 DeleteDocument::$funcname($em$id0);
  3540.                 $loginId $request->getSession()->get(UserConstants::USER_LOGIN_ID);
  3541.                 $docId HumanResource::createBonusPolicy($em$request$companyId$loginId0);
  3542.                 //now add Approval info
  3543.                 $approveRole $request->request->get('approvalRole');
  3544.                 $options = array(
  3545.                     'notification_enabled' => $this->container->getParameter('notification_enabled'),
  3546.                     'notification_server' => $this->container->getParameter('notification_server'),
  3547.                     'appId' => $request->getSession()->get(UserConstants::USER_APP_ID),
  3548.                     'url' => $this->generateUrl(
  3549.                         GeneralConstant::$Entity_list_details[array_flip(GeneralConstant::$Entity_list)['BonusPolicy']]['entity_view_route_path_name']
  3550.                     )
  3551.                 );
  3552.                 System::setApprovalInfo(
  3553.                     $this->getDoctrine()->getManager(),
  3554.                     $options,
  3555.                     array_flip(GeneralConstant::$Entity_list)['BonusPolicy'],
  3556.                     $docId,
  3557.                     $request->getSession()->get(UserConstants::USER_LOGIN_ID)
  3558.                 );
  3559.                 System::createEditSignatureHash(
  3560.                     $this->getDoctrine()->getManager(),
  3561.                     array_flip(GeneralConstant::$Entity_list)['BonusPolicy'],
  3562.                     $docId,
  3563.                     $loginId,
  3564.                     $approveRole,
  3565.                     $request->request->get('approvalHash')
  3566.                 );
  3567.                 $doc_here $this->getDoctrine()
  3568.                     ->getRepository('ApplicationBundle:BonusPolicy')
  3569.                     ->findOneBy(
  3570.                         array(
  3571.                             'id' => $docId
  3572.                         )
  3573.                     );
  3574.                 //notify
  3575.                 $this->addFlash(
  3576.                     'success',
  3577.                     'Policy Successfully Updated.'
  3578.                 );
  3579.                 $url $this->generateUrl(
  3580.                     'view_bonus_policy'
  3581.                 );
  3582. //                System::AddNewNotification(
  3583. //                    $this->container->getParameter('notification_enabled'),
  3584. //                    $this->container->getParameter('notification_server'),
  3585. //                    $request->getSession()->get(UserConstants::USER_APP_ID),
  3586. //                    $request->getSession()->get(UserConstants::USER_COMPANY_ID),
  3587. //                    "Salary Segregation Policy : " . $doc_here->getDocumentHash() . " Has Been Created And is Under Processing",
  3588. //                    'pos',
  3589. //                    System::getPositionIdsByDepartment($em, GeneralConstant::HRM_DEPARTMENT),
  3590. //                    'success',
  3591. //                    //                    $url . "/" . $TransID,
  3592. //                    $url . "/" . $docId,
  3593. //                    "Journal"
  3594. //
  3595. //                );
  3596.                 return $this->redirect($url "/" $docId);
  3597.             }
  3598.         }
  3599.         //for edits
  3600.         if ($id == 0) {
  3601.         } else {
  3602.             $extDocData $em->getRepository('ApplicationBundle:BonusPolicy')->findOneBy(
  3603.                 array(
  3604.                     'id' => $id///material
  3605.                 )
  3606.             );
  3607.             //now if its not editable, redirect to view
  3608.             if ($extDocData) {
  3609.                 if ($extDocData->getEditFlag() != 1) {
  3610. //          $url = $this->generateUrl(
  3611. ////              'view_salary_segregation_policy'
  3612. //              'salary_segregation_policy'
  3613. //          );
  3614. //          return $this->redirect($url . "/" . $id);
  3615.                 } else {
  3616. //          $extVoucherDetailsData = Accounts::GetVoucherDataForEdit($em, $voucherId);
  3617. //          $extDetailsData = $em->getRepository('ApplicationBundle:SalarySegregationPolicy')->findOneBy(
  3618. //              array(
  3619. //                  'transactionId' => $id, ///material
  3620. //
  3621. //              )
  3622. //          );
  3623.                 }
  3624.             } else {
  3625.             }
  3626.         }
  3627.         $employeeIds $em->getRepository(EmployeeDetails::class)->findAll();
  3628.         $employeeType HumanResourceConstant::$employeeType;
  3629.         $Designation $em->getRepository(SysDepartmentPosition::class)->findAll();
  3630.         $branch $em->getRepository(Branch::class)->findAll();
  3631.         $departments $em->getRepository(SysDepartment::class)->findAll();
  3632.         $department = [];
  3633.         foreach ($departments as $entry) {
  3634.             $department[$entry->getDepartmentId()] = array(
  3635.                 'id' => $entry->getDepartmentId(),
  3636.                 'name' => $entry->getDepartmentName(),
  3637.             );
  3638.         }
  3639.         return $this->render('ApplicationBundle:pages/human_resource/input_forms:create_bonus_policy.html.twig', array(
  3640.             'page_title' => 'Create Bonus Policy',
  3641.             'employeeIds' => $employeeIds,
  3642.             'employeeType' => $employeeType,
  3643.             'Designation' => $Designation,
  3644.             'branch' => $branch,
  3645.             'department' => $department,
  3646.         ));
  3647.     }
  3648.     public function BonusPolicyListAction()
  3649.     {
  3650.         $em $this->getDoctrine()->getManager();
  3651.         $bonusPolicy $em->getRepository(BonusPolicy::class)->findAll();
  3652.         return $this->render('ApplicationBundle:pages/human_resource/list:bonus_policy_list.html.twig', array(
  3653.             'page_title' => 'Increment Policy List',
  3654.             'bonusPolicy' => $bonusPolicy
  3655.         ));
  3656.     }
  3657.     public function createIncrementPolicyAction(Request $request$id 0)
  3658.     {
  3659.         $em $this->getDoctrine()->getManager();
  3660.         $companyId $this->getLoggedUserCompanyId($request);
  3661.         $extDocData = [];
  3662.         $extDetailsData = [];
  3663.         if ($request->isMethod('POST')) {
  3664.             //            Generic::debugMessage($_POST);
  3665.             $em $this->getDoctrine()->getManager();
  3666.             $entity_id array_flip(GeneralConstant::$Entity_list)['IncrementPolicy']; //change
  3667.             $dochash $request->request->get('docHash'); //change
  3668.             $loginId $request->getSession()->get(UserConstants::USER_LOGIN_ID);
  3669.             $approveRole $request->request->get('approvalRole');
  3670.             $approveHash $request->request->get('approvalHash');
  3671.             if (!DocValidation::isInsertable(
  3672.                 $em,
  3673.                 $entity_id,
  3674.                 $dochash,
  3675.                 $loginId,
  3676.                 $approveRole,
  3677.                 $approveHash,
  3678.                 $id
  3679.             )
  3680.             ) {
  3681.                 $this->addFlash(
  3682.                     'error',
  3683.                     'Sorry Couldnot insert Data.'
  3684.                 );
  3685.             } else {
  3686.                 $funcname 'IncrementPolicy';
  3687.                 DeleteDocument::$funcname($em$id0);
  3688.                 $docId HumanResource::createIncrementPolicy($em$request$companyId0);
  3689.                 //now add Approval info
  3690.                 $loginId $request->getSession()->get(UserConstants::USER_LOGIN_ID);
  3691.                 $approveRole $request->request->get('approvalRole');
  3692.                 $options = array(
  3693.                     'notification_enabled' => $this->container->getParameter('notification_enabled'),
  3694.                     'notification_server' => $this->container->getParameter('notification_server'),
  3695.                     'appId' => $request->getSession()->get(UserConstants::USER_APP_ID),
  3696.                     'url' => $this->generateUrl(
  3697.                         GeneralConstant::$Entity_list_details[array_flip(GeneralConstant::$Entity_list)['IncrementPolicy']]['view_increment_policy']
  3698.                     )
  3699.                 );
  3700.                 System::setApprovalInfo(
  3701.                     $this->getDoctrine()->getManager(),
  3702.                     $options,
  3703.                     array_flip(GeneralConstant::$Entity_list)['IncrementPolicy'],
  3704.                     $docId,
  3705.                     $request->getSession()->get(UserConstants::USER_LOGIN_ID),
  3706.                     3    //journal voucher
  3707.                 );
  3708.                 System::createEditSignatureHash(
  3709.                     $this->getDoctrine()->getManager(),
  3710.                     array_flip(GeneralConstant::$Entity_list)['IncrementPolicy'],
  3711.                     $docId,
  3712.                     $loginId,
  3713.                     $approveRole,
  3714.                     $request->request->get('approvalHash')
  3715.                 );
  3716.                 $doc_here $this->getDoctrine()
  3717.                     ->getRepository('ApplicationBundle:IncrementPolicy')
  3718.                     ->findOneBy(
  3719.                         array(
  3720.                             'id' => $docId
  3721.                         )
  3722.                     );
  3723.                 //notify
  3724.                 $this->addFlash(
  3725.                     'success',
  3726.                     'Policy Successfully Updated.'
  3727.                 );
  3728.                 $url $this->generateUrl(
  3729.                     'view_increment_policy'
  3730.                 );
  3731. //                System::AddNewNotification(
  3732. //                    $this->container->getParameter('notification_enabled'),
  3733. //                    $this->container->getParameter('notification_server'),
  3734. //                    $request->getSession()->get(UserConstants::USER_APP_ID),
  3735. //                    $request->getSession()->get(UserConstants::USER_COMPANY_ID),
  3736. //                    "Salary Segregation Policy : " . $doc_here->getDocumentHash() . " Has Been Created And is Under Processing",
  3737. //                    'pos',
  3738. //                    System::getPositionIdsByDepartment($em, GeneralConstant::HRM_DEPARTMENT),
  3739. //                    'success',
  3740. //                    //                    $url . "/" . $TransID,
  3741. //                    $url . "/" . $docId,
  3742. //                    "Journal"
  3743. //
  3744. //                );
  3745.                 return $this->redirect($url "/" $docId);
  3746.             }
  3747.         }
  3748.         //for edits
  3749.         if ($id == 0) {
  3750.         } else {
  3751.             $extDocData $em->getRepository('ApplicationBundle:IncrementPolicy')->findOneBy(
  3752.                 array(
  3753.                     'id' => $id///material
  3754.                 )
  3755.             );
  3756.             //now if its not editable, redirect to view
  3757.             if ($extDocData) {
  3758.                 if ($extDocData->getEditFlag() != 1) {
  3759. //          $url = $this->generateUrl(
  3760. ////              'view_salary_segregation_policy'
  3761. //              'salary_segregation_policy'
  3762. //          );
  3763. //          return $this->redirect($url . "/" . $id);
  3764.                 } else {
  3765. //          $extVoucherDetailsData = Accounts::GetVoucherDataForEdit($em, $voucherId);
  3766. //          $extDetailsData = $em->getRepository('ApplicationBundle:SalarySegregationPolicy')->findOneBy(
  3767. //              array(
  3768. //                  'transactionId' => $id, ///material
  3769. //
  3770. //              )
  3771. //          );
  3772.                 }
  3773.             } else {
  3774.             }
  3775.         }
  3776.         //$em = $this->getDoctrine()->getManager();
  3777.         $employeeIds $em->getRepository(EmployeeDetails::class)->findAll();
  3778.         $employeeType HumanResourceConstant::$employeeType;
  3779.         $Designation $em->getRepository(SysDepartmentPosition::class)->findAll();
  3780.         $branch $em->getRepository(Branch::class)->findAll();
  3781.         $departments $em->getRepository(SysDepartment::class)->findAll();
  3782.         $department = [];
  3783.         foreach ($departments as $entry) {
  3784.             $department[$entry->getDepartmentId()] = array(
  3785.                 'id' => $entry->getDepartmentId(),
  3786.                 'name' => $entry->getDepartmentName(),
  3787.             );
  3788.         }
  3789.         return $this->render('ApplicationBundle:pages/human_resource/input_forms:create_increment_policy.html.twig', array(
  3790.             'page_title' => 'Create Increment Policy',
  3791.             'employeeIds' => $employeeIds,
  3792.             'employeeType' => $employeeType,
  3793.             'Designation' => $Designation,
  3794.             'branch' => $branch,
  3795.             'department' => $department,
  3796.         ));
  3797.     }
  3798.     public function IncrementPolicyListAction()
  3799.     {
  3800.         $em $this->getDoctrine()->getManager();
  3801.         $incrementPolicy $em->getRepository(IncrementPolicy::class)->findAll();
  3802.         return $this->render('ApplicationBundle:pages/human_resource/list:increment_policy_list.html.twig', array(
  3803.             'page_title' => 'Increment Policy List',
  3804.             'incrementPolicy' => $incrementPolicy
  3805.         ));
  3806.     }
  3807.     public function ViewIncrementPolicyAction(Request $request$id)
  3808.     {
  3809.         $em $this->getDoctrine()->getManager();
  3810.         $incrementPolicy $em->getRepository(IncrementPolicy::class)->find($id);
  3811.         $Approval_data System::checkIfApprovalExists(
  3812.             $em,
  3813.             array_flip(GeneralConstant::$Entity_list)['IncrementPolicy'],
  3814.             $id,
  3815.             $request->getSession()->get(UserConstants::USER_LOGIN_ID)
  3816.         );
  3817.         return $this->render('ApplicationBundle:pages/human_resource/views:view_increment_policy.html.twig', array(
  3818.             'page_title' => 'Increment Policy List',
  3819.             'incrementPolicy' => $incrementPolicy,
  3820.             'approval_status' => $incrementPolicy->getApproved(),
  3821.             'approval_data' => $Approval_data,
  3822.             'auto_created' => $incrementPolicy->getAutocreated(),
  3823.             'id' => $id,
  3824.             'document_log' => $incrementPolicy->getAutocreated() == System::getDocumentLog(
  3825.                 $this->getDoctrine()->getManager(),
  3826.                 array_flip(GeneralConstant::$Entity_list)['FundRequisition'],
  3827.                 $id,
  3828.                 $incrementPolicy->getCreatedLoginId(),
  3829.                 $incrementPolicy->getEditedLoginId()
  3830.             ) : []
  3831.         ));
  3832.     }
  3833.     public function createConsultancyTopicAction(Request $request$id 0)
  3834.     {
  3835.         $em $this->getDoctrine()->getManager();
  3836.         $companyId $this->getLoggedUserCompanyId($request);
  3837.         if ($request->isMethod('POST')) {
  3838.             $loginId $request->getSession()->get(UserConstants::USER_LOGIN_ID);
  3839.             $new = new ConsultancyTopic();
  3840.             $new->setTopicName($request->request->get('topicName'));
  3841.             $new->setParentTopicName($request->request->get('parentTopicName'));
  3842.             $new->setUniqueHash($request->request->get('uniqueHash'));
  3843.             $new->setCompanyId($companyId);
  3844.             $new->setTopicSlug($request->request->get('topicSlug'));
  3845.             $new->setTitle($request->request->get('title'));
  3846.             $new->setSubTitle($request->request->get('subTitle'));
  3847.             $new->setSummary($request->request->get('content'));
  3848.             $new->setVideo($request->request->get('video'));
  3849.             $new->setAuthor($request->request->get('author'));
  3850.             $new->setAuthorSummary($request->request->get('authorSummary'));
  3851.             $new->setCreatedLoginId($request->getSession()->get(UserConstants::USER_LOGIN_ID));
  3852. //            $arr = [
  3853. //                'requirement' => $request->request->get('requirement'),
  3854. //
  3855. //            ];
  3856. //            $new->setRequirementData(json_encode($arr));
  3857.             $em->persist($new);
  3858.             $em->flush();
  3859.         }
  3860. //            $data = [];
  3861. //            $em = $this->getDoctrine()->getManager();
  3862. //            $companyId = $this->getLoggedUserCompanyId($request);
  3863. //            if ($request->isMethod('POST')) {
  3864. //                $em = $this->getDoctrine()->getManager();
  3865. //                $entity_id = array_flip(GeneralConstant::$Entity_list)['ConsultancyTopic'];
  3866. //                //$dochash = $request->request->get('docHash');//change
  3867. //                $approveRole = $request->request->get('approvalRole');
  3868. //                $approveHash = $request->request->get('approvalHash');
  3869. //                $loginId = $request->getSession()->get(UserConstants::USER_LOGIN_ID);
  3870. //                if (!DocValidation::isInsertable($em, $entity_id,
  3871. //                    $loginId, $approveRole, $approveHash, $id)
  3872. //                ) {
  3873. //                    $this->addFlash(
  3874. //                        'error',
  3875. //                        'Sorry Could not insert Data.'
  3876. //                    );
  3877. //                }  else {
  3878. //                    $data = $request->request;
  3879. //                    $docId = HumanResource::createConsultancyTopic($em, $loginId, $id, $data, $companyId);
  3880. ////                    now add Approval info
  3881. //
  3882. //                    $approveRole = $request->request->get('approvalRole');
  3883. //                    $options = array(
  3884. //                        'notification_enabled' => $this->container->getParameter('notification_enabled'),
  3885. //                        'notification_server' => $this->container->getParameter('notification_server'),
  3886. //                        'appId' => $request->getSession()->get(UserConstants::USER_APP_ID),
  3887. ////                        'url' => $this->generateUrl(
  3888. ////                            GeneralConstant::$Entity_list_details[array_flip(GeneralConstant::$Entity_list)['EmployeePerformanceEvolution']]
  3889. ////                            ['entity_view_route_path_name']
  3890. ////                        )
  3891. //                    );
  3892. //                    System::setApprovalInfo($this->getDoctrine()->getManager(), $options,
  3893. //                        array_flip(GeneralConstant::$Entity_list)['ConsultancyTopic'],
  3894. //                        $docId,
  3895. //                        $request->getSession()->get(UserConstants::USER_LOGIN_ID)    //journal voucher
  3896. //                    );
  3897. //                    System::createEditSignatureHash($this->getDoctrine()->getManager(), array_flip(GeneralConstant::$Entity_list)['ConsultancyTopic'],
  3898. //                        $docId,
  3899. //                        $loginId,
  3900. //                        $request->request->get('approvalHash'));
  3901. //                    $this->addFlash(
  3902. //                        'success',
  3903. //                        'New Consultancy Topic Added.'
  3904. //                    );
  3905. ////                    $url = $this->generateUrl(
  3906. ////                        'create_consultancy_topic'
  3907. ////                    );
  3908. //                    //return $this->redirect($url);
  3909. //
  3910. //                }
  3911. //            }
  3912.         $consultancyDetails $em->getRepository('ApplicationBundle:ConsultancyTopic')->findAll();
  3913.         return $this->render('ApplicationBundle:pages/human_resource/input_forms:create_consultancy.html.twig', array(
  3914.             'page_title' => 'Consultancy Topic',
  3915.             'consultancyDetails' => $consultancyDetails,
  3916. //                'requirement' => json_decode($consultancyDetails->getRequirementData())
  3917.         ));
  3918.     }
  3919.     public function createTopicAction(Request $request$id 0)
  3920.     {
  3921.         $em $this->getDoctrine()->getManager('company_group');
  3922.         $companyId $this->getLoggedUserCompanyId($request);
  3923.         $documentQRY $em->getRepository('CompanyGroupBundle:EntityCreateDocument')->findAll();
  3924.         $topicList $em->getRepository('CompanyGroupBundle:EntityCreateTopic')->findAll();
  3925.         $topic = [];
  3926.         $sessionName ConsultancyConstant::$sessionName;
  3927.         $document = [];
  3928.         foreach ($documentQRY as $d) {
  3929.             $document[$d->getId()] = array(
  3930.                 'id' => $d->getId(),
  3931.                 'documentName' => $d->getDocumentName(),
  3932.                 'text' => $d->getDocumentName(),
  3933.             );
  3934.         }
  3935.         $topicId $id;
  3936.         if ($topicId != 0)
  3937.             $topic $em->getRepository('CompanyGroupBundle:EntityCreateTopic')->findOneBy(
  3938.                 array(
  3939.                     'id' => $topicId
  3940.                 )
  3941.             );
  3942.         if ($request->isMethod('POST')) {
  3943.             if ($request->request->has('topicId'))
  3944.                 $topicId $request->request->get('topicId');
  3945. //            $loginId = $request->getSession()->get(UserConstants::USER_LOGIN_ID);
  3946.             if ($topicId != 0)
  3947.                 $new $em->getRepository('CompanyGroupBundle:EntityCreateTopic')->findOneBy(
  3948.                     array(
  3949.                         'id' => $topicId
  3950.                     )
  3951.                 );
  3952.             else
  3953.                 $new = new EntityCreateTopic();
  3954.             $new->setTopicName($request->request->get('topicName'));
  3955.             $new->setParentTopicId($request->request->get('parentTopic'));
  3956.             if ($request->request->get('countryId') != '')
  3957.                 $new->setCountryId($request->request->get('countryId'));
  3958.             else if ($request->request->get('parentTopic') != '') {
  3959.                 $parentTopic $em->getRepository('CompanyGroupBundle:EntityCreateTopic')->findOneBy(
  3960.                     array(
  3961.                         'id' => $request->request->get('parentTopic')
  3962.                     )
  3963.                 );
  3964.                 if ($parentTopic)
  3965.                     $new->setCountryId($parentTopic->getCountryId());
  3966.             }
  3967.             $new->setTimeSlotMultipliers($request->request->get('timeSlotMultipliers'));
  3968.             $new->setOnlyBookableByAdmin($request->request->get('onlyBookableByAdmin'0));
  3969.             $new->setMeetingType($request->request->get('meetingType'0));
  3970.             $new->setConsultantCanUpload($request->request->get('consultantCanUpload'0));
  3971.             $new->setTopicMarker($request->request->get('topicMarker'));
  3972.             $new->setCoinMultiplierValue($request->request->get('coinMultiplierValue'1));
  3973.             $new->setMinLifetimeCoinsBalance($request->request->get('minLifetimeCoinsBalance'0));
  3974.             $new->setMapEmbedIframe($request->request->get('mapEmbedIframe'''));
  3975.             $new->setTopicSummary($request->request->get('topicSummary'));
  3976.             $new->setAddress($request->request->get('address'));
  3977.             $new->setLocationString($request->request->get('locationString'));
  3978.             $new->setLocationLat($request->request->get('locationLat'));
  3979.             $new->setLocationLong($request->request->get('locationLong'));
  3980.             $new->setUniversityRanking($request->request->get('universityRanking'));
  3981.             $new->setIsParent($request->request->get('isParent'));
  3982.             $new->setIsEvent($request->request->get('isEvent'));
  3983.             $new->setConsultancyEnabled($request->request->get('consultancyEnabled'0));
  3984.             $new->setEventExpired($request->request->get('eventExpired'0));
  3985.             $new->setEventDesc($request->request->get('eventDesc'0));
  3986.             $eventStartDate = new \DateTime($request->request->get('eventStartDate'));
  3987.             $eventEndDate = new \DateTime($request->request->get('eventStartDate'));
  3988.             $new->setEventStartDate($eventStartDate);
  3989.             $new->setEventStartDateTs($eventStartDate->format('U'));
  3990.             $new->setEventEndDate($eventEndDate);
  3991.             $new->setEventStartDateTs($eventEndDate->format('U'));
  3992.             $new->setCreatedLoginId($request->getSession()->get(UserConstants::USER_LOGIN_ID));
  3993.             $checkListStringArray = [];
  3994.             if ($request->request->has('checkList'))
  3995.                 foreach ($request->request->get('checkList') as $value) {
  3996.                     $checkListStringArray [] = explode(","$value);
  3997.                 }
  3998.             $docData = [];
  3999.             foreach ($request->request->get('document', []) as $key => $value)
  4000.                 $docData[] = [
  4001.                     'document' => $request->request->get('document')[$key],
  4002.                     'expDays' => $request->request->get('expDays')[$key],
  4003.                     'stage' => $request->request->get('stage')[$key],
  4004.                     'generalProcessingDays' => $request->request->get('generalProcessingDays')[$key],
  4005.                     'emergencyProcessingDays' => $request->request->get('emergencyProcessingDays')[$key],
  4006.                     'thresholdDaysOffset' => $request->request->get('thresholdDaysOffset')[$key],
  4007.                     'checklist' => explode(","$request->request->get('checkList')[$key])
  4008.                 ];
  4009.             $coursePlanData = [];
  4010.             foreach ($request->request->get('coursePlanSessionNo', []) as $key => $value)
  4011.                 if ($request->request->get('coursePlanSessionNo')[$key] != '' and $request->request->get('coursePlanSessionNo')[$key] != null) {
  4012.                     if (!isset($coursePlanData[$request->request->get('coursePlanSessionNo')[$key]]))
  4013.                         $coursePlanData[$request->request->get('coursePlanSessionNo')[$key]] = [];
  4014.                     $coursePlanData[$request->request->get('coursePlanSessionNo')[$key]][] = [
  4015.                         'sessionNo' => $request->request->get('coursePlanSessionNo')[$key],
  4016.                         'subject' => $request->request->get('coursePlanSubject')[$key],
  4017.                         'details' => $request->request->get('coursePlanDetails')[$key],
  4018.                         'optimumMin' => $request->request->get('coursePlanOptimumMin')[$key],
  4019.                     ];
  4020.                 }
  4021.             $routineData = [];
  4022.             foreach ($request->request->get('routine_sequence', []) as $key => $value) {
  4023.                 $routineData[] = [
  4024.                     'sequence' => $request->request->get('routine_sequence')[$key],
  4025.                     'topicId' => $request->request->get('routine_topic_id')[$key],
  4026.                     'topicName' => $request->request->get('routine_topic_name')[$key],
  4027.                     'meetingType' => $request->request->get('routine_topic_meeting_type')[$key],
  4028.                     'duration' => $request->request->get('routine_duration')[$key],
  4029.                     'offset' => $request->request->get('routine_offset')[$key],
  4030.                     'coins' => $request->request->get('routine_coins')[$key],
  4031.                     'nextSequenceStart' => $request->request->has('routine_next_sequence_start_' $value) ? 0,
  4032.                     'modifiable' => $request->request->has('routine_modifiable_' $value) ? 0,
  4033.                 ];
  4034.             }
  4035.             $sessionData = [];
  4036.             foreach ($request->request->get('sessionId', []) as $key => $value)
  4037.                 $sessionData[] = [
  4038.                     'sessionId' => $request->request->get('sessionId')[$key],
  4039.                     'sessionYear' => $request->request->get('year')[$key],
  4040.                     'threshold' => $request->request->get('threshold')[$key],
  4041.                     'sessionStart' => $request->request->get('sessionStart')[$key],
  4042.                     'applicationStartDate' => $request->request->get('applicationStartDate')[$key],
  4043.                 ];
  4044.             $coursesData = [];
  4045.             foreach ($request->request->get('courseName', []) as $key => $value)
  4046.                 $coursesData[] = [
  4047.                     'courseName' => $request->request->get('courseName')[$key],
  4048.                 ];
  4049.             $departmentData = [];
  4050.             foreach ($request->request->get('departmentName', []) as $key => $value)
  4051.                 $departmentData[] = [
  4052.                     'departmentName' => $request->request->get('departmentName')[$key],
  4053.                 ];
  4054.             $benefitsData = [];
  4055.             foreach ($request->request->get('benefit', []) as $key => $value)
  4056.                 $benefitsData[] = [
  4057.                     'benefit' => $request->request->get('benefit')[$key],
  4058.                 ];
  4059.             $new->setRoutineData(json_encode($routineData));
  4060.             $new->setDocumentData(json_encode($docData));
  4061.             $new->setCoursePlanData(json_encode($coursePlanData));
  4062.             $new->setSessionData(json_encode($sessionData));
  4063.             $new->setCourses(json_encode($coursesData));
  4064.             $new->setDepartments(json_encode($departmentData));
  4065.             $new->setBenefits(json_encode($benefitsData));
  4066.             $otherDataObj = [];
  4067.             foreach (ConsultancyConstant::$otherDataByHash as $ohash => $otherDataGroup)
  4068.                 foreach ($otherDataGroup as $otherData) {
  4069.                     $fieldExists $request->request->has($ohash '_' $otherData['field']);
  4070.                     if ($fieldExists) {
  4071.                         $fieldValue $request->request->get($ohash '_' $otherData['field'], '');
  4072.                         $otherDataObj[$ohash '_' $otherData['field']] = $fieldValue;
  4073.                     }
  4074.                 }
  4075.             $new->setOtherData(json_encode($otherDataObj));
  4076.             $new->setBenefits(json_encode($benefitsData));
  4077.             $em->persist($new);
  4078.             $em->flush();
  4079.             $path "";
  4080.             $defaultProductImage '';
  4081.             $uploadedFile null;
  4082.             $upl_dir $this->container->getParameter('kernel.root_dir') . '/../web/uploads/topicImage/';
  4083.             $uploadedFile $request->files->get('topicSummaryImage');
  4084.             if ($uploadedFile != null) {
  4085.                 $fileName 'TSI' $new->getId() . '.' $uploadedFile->guessExtension();
  4086.                 $path $fileName;
  4087. //            $upl_dir = $this->container->getParameter('kernel.root_dir') . '/../web/uploads/Products/';
  4088.                 if (!file_exists($upl_dir)) {
  4089.                     mkdir($upl_dir0777true);
  4090.                 }
  4091.                 $uploadedFile->move($upl_dir$path);
  4092.                 $defaultProductImage 'uploads/topicImage/' $path;
  4093.                 $new->setTopicSummaryImage($defaultProductImage);
  4094.                 $em->flush();
  4095.             }
  4096.             $path "";
  4097.             $defaultProductImage '';
  4098.             $uploadedFile null;
  4099.             $upl_dir $this->container->getParameter('kernel.root_dir') . '/../web/uploads/topicImage/';
  4100.             $uploadedFile $request->files->get('topicImage');
  4101.             if ($uploadedFile != null) {
  4102.                 $fileName 'TI' $new->getId() . '.' $uploadedFile->guessExtension();
  4103.                 $path $fileName;
  4104. //            $upl_dir = $this->container->getParameter('kernel.root_dir') . '/../web/uploads/Products/';
  4105.                 if (!file_exists($upl_dir)) {
  4106.                     mkdir($upl_dir0777true);
  4107.                 }
  4108.                 $uploadedFile->move($upl_dir$path);
  4109.                 $defaultProductImage 'uploads/topicImage/' $path;
  4110.                 $new->setTopicImage($defaultProductImage);
  4111.                 $em->flush();
  4112.             }
  4113.             $this->addFlash(
  4114.                 'success',
  4115.                 'Topic Added.'
  4116.             );
  4117.         }
  4118.         return $this->render('ApplicationBundle:pages/human_resource/input_forms:create_topic.html.twig', array(
  4119.             'page_title' => 'Create Topic',
  4120.             'defaultCoursePlan' => ConsultancyConstant::$defaultCoursePlan,
  4121.             'coursePlanSessionTitle' => ConsultancyConstant::$coursePlanSessionTitle,
  4122.             'coursePlanSessionTitleShort' => ConsultancyConstant::$coursePlanSessionTitleShort,
  4123.             'document' => $document,
  4124.             'topic' => $topic,
  4125.             'otherDataByHash' => ConsultancyConstant::$otherDataByHash,
  4126.             'topicId' => $topicId,
  4127.             'topicList' => $topicList,
  4128.             'topicMarker' => ConsultancyConstant::$topicMarkup,
  4129.             'sessionName' => $sessionName,
  4130.         ));
  4131.     }
  4132.     public function ConsultancyRequirementSettingsAction(Request $request$id 0)
  4133.     {
  4134.         $em $this->getDoctrine()->getManager('company_group');
  4135.         $entityList $em->getRepository('CompanyGroupBundle:EntityCountryConsultantRequirements')->findAll();
  4136.         $documentQRY $em->getRepository('CompanyGroupBundle:EntityCreateDocument')->findAll();
  4137.         $entity = [];
  4138.         $sessionName ConsultancyConstant::$sessionName;
  4139.         $document = [];
  4140.         foreach ($documentQRY as $d) {
  4141.             $document[$d->getId()] = array(
  4142.                 'id' => $d->getId(),
  4143.                 'documentName' => $d->getDocumentName(),
  4144.                 'text' => $d->getDocumentName(),
  4145.             );
  4146.         }
  4147.         $countryId $id;
  4148.         if ($countryId != 0)
  4149.             $entity $em->getRepository('CompanyGroupBundle:EntityCountryConsultantRequirements')->findOneBy(
  4150.                 array(
  4151.                     'countryId' => $countryId
  4152.                 )
  4153.             );
  4154.         if ($request->isMethod('POST')) {
  4155.             if ($request->request->has('countryId'))
  4156.                 $countryId $request->request->get('countryId');
  4157. //            $loginId = $request->getSession()->get(UserConstants::USER_LOGIN_ID);
  4158.             if ($countryId != 0) {
  4159.                 $new $em->getRepository('CompanyGroupBundle:EntityCountryConsultantRequirements')->findOneBy(
  4160.                     array(
  4161.                         'countryId' => $countryId
  4162.                     )
  4163.                 );
  4164.                 if (!$new)
  4165.                     $new = new EntityCountryConsultantRequirements();
  4166.             } else
  4167.                 $new = new EntityCountryConsultantRequirements();
  4168.             $new->setCountryId($request->request->get('countryId'));
  4169.             $new->setContractLetterHtml($request->request->get('contractLetterHtml'));
  4170.             $new->setRequiredFields($request->request->get('requiredFields'));
  4171.             $new->setAllowedWorkingHoursPerDay($request->request->get('allowedWorkingHoursPerDay'));
  4172.             $new->setAllowedWorkingHoursPerMonth($request->request->get('allowedWorkingHoursPerMonth'));
  4173.             $new->setAllowedWorkingHoursPerWeek($request->request->get('allowedWorkingHoursPerWeek'));
  4174.             $new->setAllowedWorkingHoursPerYear($request->request->get('allowedWorkingHoursPerYear'));
  4175.             $new->setAllowedEarningPerDay($request->request->get('allowedEarningPerDay'));
  4176.             $new->setAllowedEarningPerMonth($request->request->get('allowedEarningPerMonth'));
  4177.             $new->setAllowedEarningPerWeek($request->request->get('allowedEarningPerWeek'));
  4178.             $new->setAllowedEarningPerYear($request->request->get('allowedEarningPerYear'));
  4179.             $new->setRevenuePercentagePerSession($request->request->get('revenuePercentagePerSession'));
  4180.             $docData = [];
  4181.             foreach ($request->request->get('document', []) as $key => $value)
  4182.                 $docData[] = [
  4183.                     'document' => $request->request->get('document')[$key],
  4184.                     'expDays' => $request->request->get('expDays')[$key],
  4185.                     'stage' => $request->request->get('stage')[$key],
  4186.                     'generalProcessingDays' => $request->request->get('generalProcessingDays')[$key],
  4187.                     'emergencyProcessingDays' => $request->request->get('emergencyProcessingDays')[$key],
  4188.                     'thresholdDaysOffset' => $request->request->get('thresholdDaysOffset')[$key],
  4189.                     'checklist' => explode(","$request->request->get('checkList')[$key])
  4190.                 ];
  4191.             $new->setDocumentList(json_encode($docData));
  4192.             $em->persist($new);
  4193.             $em->flush();
  4194.             $this->addFlash(
  4195.                 'success',
  4196.                 'Restriction Updated.'
  4197.             );
  4198.         }
  4199.         return $this->render('ApplicationBundle:pages/consultancy:create_consultancy_requirements.html.twig', array(
  4200.             'page_title' => 'Create Requirements',
  4201.             'defaultCoursePlan' => ConsultancyConstant::$defaultCoursePlan,
  4202.             'coursePlanSessionTitle' => ConsultancyConstant::$coursePlanSessionTitle,
  4203.             'coursePlanSessionTitleShort' => ConsultancyConstant::$coursePlanSessionTitleShort,
  4204.             'document' => $document,
  4205.             'entity' => $entity,
  4206.             'otherDataByHash' => ConsultancyConstant::$otherDataByHash,
  4207.             'countryId' => $countryId,
  4208.             'entityList' => $entityList,
  4209.             'topicMarker' => ConsultancyConstant::$topicMarkup,
  4210.             'sessionName' => $sessionName,
  4211.         ));
  4212.     }
  4213.     public function PromoCodeSettingsAction(Request $request$id 0)
  4214.     {
  4215.         $em $this->getDoctrine()->getManager('company_group');
  4216.         $entityList $em->getRepository('CompanyGroupBundle:PromoCode')->findAll();
  4217.         $applicantList $em->getRepository('CompanyGroupBundle:EntityApplicantDetails')->findAll();
  4218.         $promoCodeId $id;
  4219.         $entity = [];
  4220.         if ($promoCodeId != 0)
  4221.             $entity $em->getRepository('CompanyGroupBundle:PromoCode')->findOneBy(
  4222.                 array(
  4223.                     'id' => $promoCodeId
  4224.                 )
  4225.             );
  4226.         if ($request->isMethod('POST')) {
  4227.             if ($request->request->has('promoCodeId'))
  4228.                 $promoCodeId $request->request->get('promoCodeId');
  4229. //            $loginId = $request->getSession()->get(UserConstants::USER_LOGIN_ID);
  4230.             if ($promoCodeId != 0) {
  4231.                 $new $em->getRepository('CompanyGroupBundle:PromoCode')->findOneBy(
  4232.                     array(
  4233.                         'id' => $promoCodeId
  4234.                     )
  4235.                 );
  4236.                 if (!$new)
  4237.                     $new = new PromoCode();
  4238.             } else
  4239.                 $new = new PromoCode();
  4240. //            $new->setCountryId($request->request->get('countryId'));
  4241.             $new->setCode($request->request->get('code'''));
  4242.             $new->setPromoType($request->request->get('promoType'1));
  4243.             $new->setPromoCodeType($request->request->get('promoCodeType'1));
  4244.             $new->setPromoValue($request->request->get('promoValue'0));
  4245.             $new->setPerpetual($request->request->get('perpetual'0));
  4246.             $new->setMaxDiscountAmount($request->request->get('maxDiscountAmount', -1));
  4247.             $new->setMaxCoinAddition($request->request->get('maxCoinAddition', -1));
  4248.             $new->setMinAmountForApplication($request->request->get('minAmountForApplication'0));
  4249.             $new->setMinCoinForApplication($request->request->get('minCoinForApplication'0));
  4250.             $new->setNextApplicationEachCoinCount($request->request->get('nextApplicationEachCoinCount', -1));
  4251.             $new->setMaxUseCount($request->request->get('maxUseCount', -1));
  4252.             $new->setMaxUseCountPerUser($request->request->get('maxUseCountPerUser', -1));
  4253.             $new->setUseCountBalance($request->request->get('useCountBalance', -1));
  4254.             $new->setReferralApplicantId($request->request->get('referralApplicantId'0));
  4255.             $new->setMaxReferralCommissionCount($request->request->get('maxReferralCommissionCount'0));
  4256.             $new->setReferralCommissionCountBalance($request->request->get('referralCommissionCountBalance'0));
  4257.             $new->setReferralCommissionType($request->request->get('referralCommissionType'1));
  4258.             $new->setReferralAmount($request->request->get('referralAmount'0));
  4259.             $startsAt = new \DateTime($request->request->get('startsAt'''));
  4260.             $expiresAt = new \DateTime($request->request->get('expiresAt'''));
  4261.             $new->setStartsAtTs($startsAt->format('U'));
  4262.             $new->setExpiresAtTs($expiresAt->format('U'));
  4263. //
  4264. //        startsAtTs:
  4265. //            type: integer
  4266. //            nullable: true
  4267. //        expiresAtTs:
  4268. //            type: integer
  4269. //            nullable: true
  4270.             $em->persist($new);
  4271.             $em->flush();
  4272.             $this->addFlash(
  4273.                 'success',
  4274.                 'Promo Code Updated.'
  4275.             );
  4276.         }
  4277.         return $this->render('ApplicationBundle:pages/consultancy:buddybee_promo_code_settings.html.twig', array(
  4278.             'page_title' => 'Promo Codes',
  4279.             'entity' => $entity,
  4280.             'promoCodeId' => $promoCodeId,
  4281.             'entityList' => $entityList,
  4282.             'applicantList' => $applicantList,
  4283.         ));
  4284.     }
  4285.     public function createDocumentAction(Request $request$id 0)
  4286.     {
  4287.         $em $this->getDoctrine()->getManager('company_group');
  4288.         $companyId $this->getLoggedUserCompanyId($request);
  4289.         $document $em->getRepository('CompanyGroupBundle:EntityCreateDocument')->findAll();
  4290.         $thisDoc = [];
  4291.         if ($id != 0)
  4292.             $thisDoc $em->getRepository('CompanyGroupBundle:EntityCreateDocument')->findOneBy(
  4293.                 array(
  4294.                     'Id' => $id
  4295.                 )
  4296.             );
  4297.         if ($request->isMethod('POST')) {
  4298.             if ($id != 0)
  4299.                 $new $thisDoc;
  4300.             else
  4301.                 $new = new EntityCreateDocument();
  4302.             $new->setDocumentName($request->request->get('docName'));
  4303.             $new->setExpiryDays($request->request->get('expDays'));
  4304.             $new->setProcessingDays($request->request->get('processingDays'));
  4305.             $new->setEmergencyProcessingDays($request->request->get('emergencyProcessingDays'));
  4306.             $new->setDocVideo($request->request->get('docVideoLink'));
  4307.             $new->setRequiredDocument(json_encode($request->request->get('requiredDoc')));
  4308.             $new->setCreatedLoginId($request->getSession()->get(UserConstants::USER_LOGIN_ID));
  4309.             $arr = [
  4310.                 'checkListName' => $request->request->get('checkListName'),
  4311.             ];
  4312.             $new->setCheckList(json_encode($arr));
  4313.             $em->persist($new);
  4314.             $em->flush();
  4315.         }
  4316.         $this->addFlash(
  4317.             'Document Added',
  4318.             'Topic Added.'
  4319.         );
  4320.         return $this->render('ApplicationBundle:pages/human_resource/input_forms:create_document.html.twig', array(
  4321.             'page_title' => 'Create Document',
  4322.             'document' => $document,
  4323.             'thisDoc' => $thisDoc
  4324.         ));
  4325.     }
  4326.     public function getIndividualDocumentAction(Request $request$id)
  4327.     {
  4328.         $em $this->getDoctrine()->getManager('company_group');
  4329.         if ($id == 0) {
  4330.             if ($request->request->has('documentId'))
  4331.                 $id $request->request->get('documentId');
  4332.         }
  4333.         $document $em->getRepository('CompanyGroupBundle:EntityCreateDocument')->find($id);
  4334.         return new JsonResponse(
  4335.             array(
  4336.                 'success' => true,
  4337.                 'rowId' => $request->request->get('rowId'),
  4338.                 'expiryDays' => $document->getExpiryDays(),
  4339.                 'processingDays' => $document->getProcessingDays(),
  4340.                 'emergencyProcessing' => $document->getEmergencyProcessingDays(),
  4341.                 'checklist' => json_decode($document->getCheckList()),
  4342.             )
  4343.         );
  4344.     }
  4345.     public function createBlogAction(Request $request$id)
  4346.     {
  4347.         if (!$id) {
  4348.             if ($request->isMethod('POST')) {
  4349.                 $em $this->getDoctrine()->getManager('company_group');
  4350.                 $loginId $request->getSession()->get(UserConstants::USER_LOGIN_ID);
  4351.                 $new = new EntityCreateBlog();
  4352.                 $new->setTopicId($request->request->get('topicId'));
  4353.                 $new->setTitle($request->request->get('title'));
  4354.                 $new->setSubtitle($request->request->get('subTitle'));
  4355.                 $new->setContent($request->request->get('content'));
  4356.                 $new->setVideoLink($request->request->get('videoLink'));
  4357.                 $new->setAuthorName($request->request->get('authorName'));
  4358.                 $new->setAuthorSummary($request->request->get('authorSummary'));
  4359.                 $new->setIsPrimaryBlog($request->request->get('checkPrimaryBlog'));
  4360.                 $em->persist($new);
  4361.                 $em->flush();
  4362.                 //$fileName = 'cv' . $consultantDetails->getApplicantId() . '.' . $uploadedFile->guessExtension();
  4363.                 $path "";
  4364.                 $defaultProductImage '';
  4365.                 $uploadedFile null;
  4366.                 $upl_dir $this->container->getParameter('kernel.root_dir') . '/../web/uploads/authorImage/';
  4367.                 $uploadedFile $request->files->get('authorImage');
  4368.                 if ($uploadedFile != null) {
  4369.                     $fileName 'authorImage' $new->getId() . '.' $uploadedFile->guessExtension();
  4370.                     $path $fileName;
  4371. //            $upl_dir = $this->container->getParameter('kernel.root_dir') . '/../web/uploads/Products/';
  4372.                     if (!file_exists($upl_dir)) {
  4373.                         mkdir($upl_dir0777true);
  4374.                     }
  4375.                     $uploadedFile->move($upl_dir$path);
  4376.                     $defaultProductImage 'uploads/authorImage/' $path;
  4377.                     $new->setAuthorImage($defaultProductImage);
  4378.                     $em->flush();
  4379.                 }
  4380.                 $path "";
  4381.                 $defaultProductImage '';
  4382.                 $uploadedFile null;
  4383.                 $upl_dir $this->container->getParameter('kernel.root_dir') . '/../web/uploads/mainImage/';
  4384.                 $uploadedFile $request->files->get('main_img');
  4385.                 if ($uploadedFile != null) {
  4386.                     $fileName 'mainImage' $new->getId() . '.' $uploadedFile->guessExtension();
  4387.                     $path $fileName;
  4388. //            $upl_dir = $this->container->getParameter('kernel.root_dir') . '/../web/uploads/Products/';
  4389.                     if (!file_exists($upl_dir)) {
  4390.                         mkdir($upl_dir0777true);
  4391.                     }
  4392.                     $uploadedFile->move($upl_dir$path);
  4393.                     $defaultProductImage 'uploads/mainImage/' $path;
  4394.                     $new->setMainImage($defaultProductImage);
  4395.                     $em->flush();
  4396.                 }
  4397.                 $topicDetails $em->getRepository('CompanyGroupBundle:EntityCreateTopic')->findOneBy(
  4398.                     array(
  4399.                         'id' => $request->request->get('topicId')
  4400.                     )
  4401.                 );
  4402.                 if ($new->getIsPrimaryBlog() == 1) {
  4403.                     if ($topicDetails)
  4404.                         $topic $topicDetails;
  4405.                     else
  4406.                         $topic = new EntityCreateTopic();
  4407.                     $topic->setPrimaryBlogId($new->getId());
  4408.                     $em->flush();
  4409.                 }
  4410.                 $this->addFlash(
  4411.                     'success',
  4412.                     'Blog Added.'
  4413.                 );
  4414.             } else {
  4415.                 $em $this->getDoctrine()->getManager('company_group');
  4416.                 $topic $em->getRepository('CompanyGroupBundle:EntityCreateTopic')->findAll();
  4417.                 $applicant $em->getRepository('CompanyGroupBundle:EntityApplicantDetails')->findAll();
  4418.                 $blogs $em->getRepository('CompanyGroupBundle:EntityCreateBlog')->findAll();
  4419.                 $topicIds = [];
  4420.                 foreach ($blogs as $blog) {
  4421.                     $topicIds [] = $blog->getTopicId();
  4422.                 }
  4423. //                $topic = $em->getRepository('CompanyGroupBundle:EntityCreateTopic')->findBy(
  4424. //                    array(
  4425. //                        'id' => $topicIds
  4426. //                    )
  4427. //                );
  4428.                 return $this->render('ApplicationBundle:pages/human_resource/input_forms:create_blog.html.twig', array(
  4429.                     'page_title' => 'Create Blog',
  4430.                     'topic' => $topic,
  4431.                     'applicant' => $applicant,
  4432.                     'blog' => $blogs,
  4433.                     'id' => $id,
  4434.                 ));
  4435.             }
  4436.         } else {
  4437.             if ($request->isMethod('GET')) {
  4438.                 $em $this->getDoctrine()->getManager('company_group');
  4439.                 $topic $em->getRepository('CompanyGroupBundle:EntityCreateTopic')->findAll();
  4440.                 $applicant $em->getRepository('CompanyGroupBundle:EntityApplicantDetails')->findAll();
  4441.                 $blogs $em->getRepository('CompanyGroupBundle:EntityCreateBlog')->find($id);
  4442.                 return $this->render('ApplicationBundle:pages/human_resource/input_forms:create_blog.html.twig', array(
  4443.                     'page_title' => 'Create Blog',
  4444.                     'topic' => $topic,
  4445.                     'applicant' => $applicant,
  4446.                     'blog' => $blogs,
  4447.                     'id' => $id,
  4448.                 ));
  4449.             } else {
  4450.                 $em $this->getDoctrine()->getManager('company_group');
  4451.                 $new = new EntityCreateBlog();
  4452.                 $new->setTopicId($request->request->get('topicId'));
  4453.                 $new->setTitle($request->request->get('title'));
  4454.                 $new->setSubtitle($request->request->get('subTitle'));
  4455.                 $new->setContent($request->request->get('content'));
  4456.                 $new->setVideoLink($request->request->get('videoLink'));
  4457.                 $new->setAuthorName($request->request->get('authorName'));
  4458.                 $new->setAuthorSummary($request->request->get('authorSummary'));
  4459.                 //$em->persist($new);
  4460.                 $em->flush();
  4461.                 $path "";
  4462.                 $defaultProductImage '';
  4463.                 $uploadedFile null;
  4464.                 $upl_dir $this->container->getParameter('kernel.root_dir') . '/../web/uploads/authorImage/';
  4465.                 $uploadedFile $request->files->get('authorImage');
  4466.                 if ($uploadedFile != null) {
  4467.                     $fileName 'authorImage' '.' $uploadedFile->guessExtension();
  4468.                     $path $fileName;
  4469. //            $upl_dir = $this->container->getParameter('kernel.root_dir') . '/../web/uploads/Products/';
  4470.                     if (!file_exists($upl_dir)) {
  4471.                         mkdir($upl_dir0777true);
  4472.                     }
  4473.                     $uploadedFile->move($upl_dir$path);
  4474.                     $defaultProductImage 'uploads/authorImage/' $path;
  4475.                     $new->setAuthorImage($defaultProductImage);
  4476.                     $em->flush();
  4477.                 }
  4478.                 $this->addFlash(
  4479.                     'success',
  4480.                     'Blog Updated.'
  4481.                 );
  4482.             }
  4483.         }
  4484.         return new JsonResponse(
  4485.             array(
  4486.                 'success' => true,
  4487.             )
  4488.         );
  4489. //        if ($request->isMethod('POST')) {
  4490. //            $loginId = $request->getSession()->get(UserConstants::USER_LOGIN_ID);
  4491. //
  4492. //            $new = new EntityCreateBlog();
  4493. //
  4494. //            $new->setTopicId($request->request->get('topicId'));
  4495. //            $new->setTitle($request->request->get('title'));
  4496. //            $new->setSubtitle($request->request->get('subTitle'));
  4497. //            $new->setContent($request->request->get('content'));
  4498. //            $new->setVideoLink($request->request->get('videoLink'));
  4499. //            $new->setAuthorName($request->request->get('authorName'));
  4500. //            $new->setAuthorSummary($request->request->get('authorSummary'));
  4501. //
  4502. //            $em->persist($new);
  4503. //            $em->flush();
  4504. //
  4505. //
  4506. //            $path = "";
  4507. //            $defaultProductImage = '';
  4508. //            $uploadedFile = null;
  4509. //            $upl_dir = $this->container->getParameter('kernel.root_dir') . '/../web/uploads/authorImage/';
  4510. //            $uploadedFile=  $request->files->get('authorImage');
  4511. //
  4512. //            if ($uploadedFile != null) {
  4513. //
  4514. //                $fileName = 'authorImage' .'.' . $uploadedFile->guessExtension();
  4515. //                $path = $fileName;
  4516. ////            $upl_dir = $this->container->getParameter('kernel.root_dir') . '/../web/uploads/Products/';
  4517. //                if (!file_exists($upl_dir)) {
  4518. //                    mkdir($upl_dir, 0777, true);
  4519. //                }
  4520. //                $uploadedFile->move($upl_dir, $path);
  4521. //                $defaultProductImage = 'uploads/authorImage/' . $path;
  4522. //                $new->setAuthorImage($defaultProductImage);
  4523. //                $em->flush();
  4524. //
  4525. //            }
  4526. //            $this->addFlash(
  4527. //                'success',
  4528. //                'Blog Added.'
  4529. //            );
  4530. //        }
  4531. //        return $this->render('ApplicationBundle:pages/human_resource/input_forms:create_blog.html.twig', array(
  4532. //            'page_title' => 'Create Blog',
  4533. //            'topic'=> $topic,
  4534. //            'applicant' => $applicant,
  4535. //            'blog' => $blogs
  4536. //        ));
  4537.     }
  4538.     public function applicantConsultancyAction()
  4539.     {
  4540.         return $this->render('ApplicationBundle:pages/human_resource/input_forms:consultancy.html.twig', array(
  4541.             'page_title' => 'Consultancy',
  4542.         ));
  4543.     }
  4544.     public function viewConsultantDetailsAction(Request $request$id 0)
  4545.     {
  4546.         $gocEnabled 1;
  4547.         $currAppId 4;
  4548.         $honeybeeAppId 1;
  4549.         $buddybeeAppId 4;
  4550.         $em_goc $this->getDoctrine()->getManager('company_group');
  4551.         $em $this->getDoctrine()->getManager();
  4552.         $option = [];
  4553.         $option['appId'] = $currAppId//honeybee
  4554.         $option['departmentId'] = 18//consultancy
  4555.         $option['designationId'] = 50;
  4556. //        $dataToConnect = System::changeDoctrineManagerByAppId(
  4557. //            $this->getDoctrine()->getManager('company_group'),
  4558. //            $gocEnabled,
  4559. //            $currAppId
  4560. //        );
  4561. //        if (!empty($dataToConnect)) {
  4562. //            $connector = $this->container->get('application_connector');
  4563. //            $connector->resetConnection(
  4564. //                'default',
  4565. //                $dataToConnect['dbName'],
  4566. //                $dataToConnect['dbUser'],
  4567. //                $dataToConnect['dbPass'],
  4568. //                $dataToConnect['dbHost'],
  4569. //                $reset = true
  4570. //            );
  4571. //            $em = $this->getDoctrine()->getManager();
  4572. //        } else {
  4573. //            $currAppId = $honeybeeAppId;
  4574. //            $dataToConnectAgain = System::changeDoctrineManagerByAppId(
  4575. //                $this->getDoctrine()->getManager('company_group'),
  4576. //                $gocEnabled,
  4577. //                $currAppId
  4578. //            );
  4579. //            if (!empty($dataToConnectAgain)) {
  4580. //                $connector = $this->container->get('application_connector');
  4581. //                $connector->resetConnection(
  4582. //                    'default',
  4583. //                    $dataToConnect['dbName'],
  4584. //                    $dataToConnect['dbUser'],
  4585. //                    $dataToConnect['dbPass'],
  4586. //                    $dataToConnect['dbHost'],
  4587. //                    $reset = true
  4588. //                );
  4589. //                $em = $this->getDoctrine()->getManager();
  4590. //            }
  4591. //
  4592. //        }
  4593.         $consultantDetails $em_goc->getRepository(EntityApplicantDetails::class)->find($id);
  4594.         $skill $em_goc->getRepository(EntitySkill::class)->findAll();
  4595.         $gender HumanResourceConstant::$sex;
  4596.         $blood HumanResourceConstant::$BloodGroup;
  4597.         $consultantLevel HumanResourceConstant::$consultantLevel;
  4598.         $companyId $this->getLoggedUserCompanyId($request);
  4599.         $designation $em->getRepository("ApplicationBundle:SysDepartmentPosition")->findAll();
  4600.         $departments $em->getRepository("ApplicationBundle:SysDepartment")->findAll();
  4601.         $companyData Company::getCompanyData($em$companyId);
  4602.         $currDate = new \DateTime();
  4603.         if ($request->isMethod('POST')) {
  4604.             //for consultant only
  4605.             $convertToConsultant HumanResource::convertToConsultant($em_goc$em$id$option$request->request);
  4606.             if ($request->request->get('confirmStatus'0) == 1) {
  4607.                 $bodyTemplate 'ApplicationBundle:email/templates:consultantApprovalEmail.html.twig';
  4608.                 $contractLetterHtml '';
  4609.                 $bodyData = array(
  4610.                     'name' => $consultantDetails->getFirstname() . ' ' $consultantDetails->getLastname(),
  4611.                     'companyData' => $companyData,
  4612.                     'contractLetterHtml' => $contractLetterHtml,
  4613.                     'commentText' => $request->request->get('commentText'),
  4614.                 );
  4615.                 $new_mail $this->get('mail_module');
  4616.                 $new_mail->sendMyMail(array(
  4617.                     'senderHash' => '_CUSTOM_',
  4618.                     'encryptionMethod' => 'ssl',
  4619.                     'userName' => 'management@buddybee.eu',
  4620.                     'fromAddress' => 'management@buddybee.eu',
  4621.                     'password' => 'Eco@0112',
  4622.                     'smtpServer' => 'smtp.hostinger.com',
  4623.                     'smtpPort' => '465',
  4624.                     'forwardToMailAddress' => $consultantDetails->getEmail(),
  4625.                     'subject' => 'Consultant Contract Letter Of ' $consultantDetails->getFirstName(),
  4626.                     'fileName' => '',
  4627.                     //'attachments' => $attachments,
  4628.                     'toAddress' => $consultantDetails->getEmail(),
  4629.                     'mailTemplate' => $bodyTemplate,
  4630.                     'templateData' => $bodyData,
  4631.                     'embedCompanyImage' => 1,
  4632.                     'companyId' => $companyId,
  4633.                     'companyImagePath' => ""
  4634.                 ));
  4635.             }
  4636.             if ($request->request->get('confirmStatus'0) == 0) {
  4637.                 $bodyTemplate 'ApplicationBundle:email/templates:consultantRejectionEmail.html.twig';
  4638.                 $contractLetterHtml '';
  4639.                 $bodyData = array(
  4640.                     'name' => $consultantDetails->getFirstname() . ' ' $consultantDetails->getLastname(),
  4641.                     'companyData' => $companyData,
  4642.                     'contractLetterHtml' => $contractLetterHtml,
  4643.                     'commentText' => $request->request->get('commentText'),
  4644.                 );
  4645.                 $new_mail $this->get('mail_module');
  4646.                 $new_mail->sendMyMail(array(
  4647.                     'senderHash' => '_CUSTOM_',
  4648.                     'encryptionMethod' => 'ssl',
  4649.                     'userName' => 'management@buddybee.eu',
  4650.                     'fromAddress' => 'management@buddybee.eu',
  4651.                     'password' => 'Eco@0112',
  4652.                     'smtpServer' => 'smtp.hostinger.com',
  4653.                     'smtpPort' => '465',
  4654.                     'forwardToMailAddress' => $consultantDetails->getEmail(),
  4655.                     'subject' => 'Rejection Letter Of ' $consultantDetails->getFirstName(),
  4656.                     'fileName' => '',
  4657.                     //'attachments' => $attachments,
  4658.                     'toAddress' => $consultantDetails->getEmail(),
  4659.                     'mailTemplate' => $bodyTemplate,
  4660.                     'templateData' => $bodyData,
  4661.                     'embedCompanyImage' => 1,
  4662.                     'companyId' => $companyId,
  4663.                     'companyImagePath' => ""
  4664.                 ));
  4665.             }
  4666.         }
  4667.         $docList MiscActions::GetDocumentDataForBuddybeeConsultantApply($em_goc,
  4668.             $id,
  4669.             $consultantDetails->getCurrentCountryId()
  4670.         );
  4671.         return $this->render('ApplicationBundle:pages/human_resource/views:viewConsultantDetails.html.twig', array(
  4672.             'page_title' => 'Consultant Details',
  4673.             'applicantId' => $id,
  4674.             'consultantDetails' => $consultantDetails,
  4675.             'education' => json_decode($consultantDetails->getEducationData(), true),
  4676.             'workExperience' => json_decode($consultantDetails->getWorkExperienceData(), true),
  4677.             'certificate' => json_decode($consultantDetails->getCertificateData(), true),
  4678.             'gender' => $gender,
  4679.             'blood' => $blood,
  4680.             'skill' => $skill,
  4681.             'docList' => $docList,
  4682.             'countryId' => $consultantDetails->getCurrentCountryId(),
  4683.             'consultantLevel' => $consultantLevel,
  4684.             'designation' => $designation,
  4685.             'department' => $departments
  4686.         ));
  4687.     }
  4688.     public function ApplicableEmployeSettingsAction()
  4689.     {
  4690.         $em $this->getDoctrine()->getManager();
  4691.         $employeeIds $em->getRepository(Employee::class)->findAll();
  4692.         return $this->render('ApplicationBundle:pages/human_resource/input_forms:applicable_employee_settings.html.twig', array(
  4693.             'page_title' => 'Applicable Employee Settings',
  4694.             'employeeIds' => $employeeIds
  4695.         ));
  4696.     }
  4697.     public function GetApplicableSettingsForSingleEmployeeAction($id)
  4698.     {
  4699.         $em $this->getDoctrine()->getManager();
  4700.         $bankLists $em->getRepository(WorkHourPolicy::class)->findAll();
  4701.         if (json_decode($bankLists->getEmployeeIds()) == $id) {
  4702.             return new JsonResponse(
  4703.                 array(
  4704.                     'success' => true,
  4705.                     'msg' => 'employee found'
  4706.                 )
  4707.             );
  4708.         } else {
  4709.             return new JsonResponse(
  4710.                 array(
  4711.                     'success' => true,
  4712.                     'msg' => 'employee not found'
  4713.                 )
  4714.             );
  4715.         }
  4716.     }
  4717. //    public function  getEmployeeDataAction(){
  4718. //        $em = $this->getDoctrine()->getManager();
  4719. //        $emplyeeDetails =  $em->getRepository('ApplicationBundle:EmployeeDeatils')->findAll();
  4720. //        $days = HumanResourceConstant::$days;
  4721. //        $holidays = ;
  4722. //        $workHourPolicies = ;
  4723. //
  4724. //    }
  4725.     public function meetingSchedulingForTabAction()
  4726.     {
  4727.         $em $this->getDoctrine()->getManager();
  4728.         $date date('Y-m-d');
  4729.         $month date('m');
  4730.         $year date('Y');
  4731.         $monthName date("F"mktime(000$month));
  4732.         $totalDayOfMonth cal_days_in_month(CAL_GREGORIAN$month$year);
  4733.         $fromdt date('Y-m-01 'strtotime("First Day Of  $monthName $year"));
  4734. //        echo "Start Date : $fromdt" . "<br>";
  4735.         $todt date('Y-m-d 'strtotime("Last Day of $monthName $year"));
  4736. //        echo "End Date : $todt" . "<br>";
  4737.         $num_friday '';
  4738.         for ($i 0$i < ((strtotime($todt) - strtotime($fromdt)) / 86400); $i++) {
  4739.             if (date('l'strtotime($fromdt) + ($i 86400)) == 'Friday') {
  4740.                 $num_friday++;
  4741.             }
  4742.         }
  4743.         $num_saturday '';
  4744.         for ($i 0$i < ((strtotime($todt) - strtotime($fromdt)) / 86400); $i++) {
  4745.             if (date('l'strtotime($fromdt) + ($i 86400)) == 'Saturday') {
  4746.                 $num_saturday++;
  4747.             }
  4748.         }
  4749.         $totalWeekends $num_saturday $num_friday;
  4750.         $totalCompanyWorkingDay $totalDayOfMonth $totalWeekends;
  4751. //        $attendanceData=$em->getRepository('ApplicationBundle:EmployeeAttendanceLog')->findOneBy(
  4752. //            array(
  4753. //                'employeeId' => 3
  4754. //            )
  4755. //        );
  4756.         $DateRange = [];
  4757.         $holidayDates $em->getRepository('ApplicationBundle:HolidayCalendarDates')->findAll();
  4758.         foreach ($holidayDates as $holiday) {
  4759.             $holidaayData = array(
  4760.                 'startDate' => $holiday->getStartDate(),
  4761.                 'endDate' => $holiday->getEndDate(),
  4762.             );
  4763.             $DateRange $holidaayData;
  4764.         }
  4765.         $employeeDataDetail = [];
  4766.         $employeeDetail $em->getRepository('ApplicationBundle:EmployeeDetails')->findOneBy(
  4767.             array(
  4768.                 'id' => 3
  4769.             )
  4770.         );
  4771. //        foreach($employeeDetail as $employee){
  4772.         $employeeData = array(
  4773.             'firstName' => $employeeDetail->getFirstname(),
  4774.             'basic' => $employeeDetail->getEar1(),
  4775.             'dearness' => $employeeDetail->getEar2(),
  4776.             'houseRent' => $employeeDetail->getEar3(),
  4777.             'medical' => $employeeDetail->getEar4(),
  4778.             'leaveTravel' => $employeeDetail->getEar5(),
  4779.             'childEducation' => $employeeDetail->getEar6(),
  4780.             'totalEarning' => $employeeDetail->getEart(),
  4781.         );
  4782.         $employeeDataDetail $employeeData;
  4783. //        }
  4784.         $attendanceData $em->getRepository(EmployeeAttendanceLog::class);
  4785. //        $employeeId = $attendanceData->getEmployeeId();
  4786. //        $countId = count($employeeId);
  4787.         $totalPresent $attendanceData->createQueryBuilder('a')
  4788.             // Filter by some parameter if you want
  4789.             ->where('a.employeeId = 3')
  4790.             ->andWhere('a.isPresent = 1')
  4791.             ->select('a.isPresent')
  4792.             ->getQuery()
  4793.             ->getResult();
  4794. //        $countAt = 0;
  4795.         $count count($totalPresent);
  4796. //        $count = $countAt+$count;
  4797.         //get holiday
  4798.         $holidayStartDate $DateRange['startDate']->format('Y-m-d');
  4799.         $holidayEndDate $DateRange['endDate']->format('Y-m-d');
  4800.         $dates HumanResource::getBetweenDates($holidayStartDate$holidayEndDate);
  4801.         $dateCount count($dates);
  4802.         $totalOffDay $totalWeekends $dateCount;
  4803.         $totalCompanyWorkingDay $totalDayOfMonth $totalOffDay;
  4804.         $totalAbsent $totalCompanyWorkingDay $count;
  4805. //        foreach($dates as $compDate ){
  4806. //
  4807. //
  4808. //
  4809. //            if($date == $compDate){
  4810. //                echo $date;
  4811. //                echo $compDate;
  4812. //                echo "holiday" ;
  4813. //
  4814. //            }
  4815. //            else{
  4816. //                echo "no holiday" ;
  4817. //            }
  4818. //        }
  4819.         $twigData HumanResource::twigDataForWorkHourPolicy($em);
  4820.         return $this->render('ApplicationBundle:pages/human_resource/list:meeting_schedule_list_for_tab.html.twig', array(
  4821.             'page_title' => 'Meeting Schedule List',
  4822.             'date' => $date,
  4823.             'totalWeekends' => $totalWeekends,
  4824.             'totalCompanyWorkingDay' => $totalCompanyWorkingDay,
  4825. //            'attendanceData' => $attendanceData,
  4826. //            'employeeId' => $employeeId,
  4827.             'count' => $count,
  4828.             'totalAbsent' => $totalAbsent,
  4829.             'employeeDataDetail' => $employeeDataDetail,
  4830.             'holiday' => $DateRange,
  4831.             'holidayStartDate' => $holidayStartDate,
  4832.             'holidayEndDate' => $holidayEndDate,
  4833.             'holidayCount' => $dateCount,
  4834.             'totalOffDay' => $totalOffDay,
  4835.             'employeeIds' => $twigData['employeeIds'],
  4836.         ));
  4837.     }
  4838.     public function getEmployeeDataForDisburseAction($id)
  4839.     {
  4840.         $em $this->getDoctrine()->getManager();
  4841.         $employeeDetail $em->getRepository('ApplicationBundle:EmployeeDetails')->find($id);
  4842.         return new JsonResponse(
  4843.             array(
  4844.                 'success' => true,
  4845.                 'firstName' => $employeeDetail->getFirstName(),
  4846.             )
  4847.         );
  4848.     }
  4849.     public function BulkAttendanceAction(Request $request)
  4850.     {
  4851.         $em $this->getDoctrine()->getManager();
  4852.         $companyId $this->getLoggedUserCompanyId($request);
  4853.         if ($request->isMethod('POST')) {
  4854.             $attendance = [];
  4855.             foreach ($request->request->get('date') as $key => $val) {
  4856.                 $loginId $request->getSession()->get(UserConstants::USER_LOGIN_ID);
  4857.                 $bulkAttendance=null;
  4858.                 if($request->request->get('attId')[$key]!=0)
  4859.                     $bulkAttendance $em->getRepository('ApplicationBundle:EmployeeAttendance')->findOneBy(array(
  4860.                         'id' => $request->request->get('attId')[$key],
  4861.                     ));
  4862.                 if(!$bulkAttendance)
  4863.                     $bulkAttendance = new EmployeeAttendance;
  4864.                 $theDate=new \DateTime($request->request->get('date')[$key]);
  4865.                 $bulkAttendance->setEmployeeId($request->request->get('employeeId'));
  4866.                 $bulkAttendance->setDate($theDate);
  4867.                 $bulkAttendance->setEntry(
  4868.                     ($request->request->get('startTimeTs')[$key] =='' ||
  4869.                         $request->request->get('startTimeTs')[$key]=='NaN' ||
  4870.                         $request->request->get('startTimeTs')[$key]==0) ?null:
  4871.                         new \DateTime('@'.$request->request->get('startTimeTs')[$key])
  4872.                 );
  4873.                 $bulkAttendance->setLastOut(($request->request->get('endTimeTs')[$key] =='' ||
  4874.                     $request->request->get('endTimeTs')[$key]=='NaN' ||
  4875.                     $request->request->get('endTimeTs')[$key]==0) ?null:
  4876.                     new \DateTime('@'.$request->request->get('endTimeTs')[$key]));
  4877.                 $bulkAttendance->setData(json_encode(
  4878.                     array(
  4879.                         "in"=>json_decode($request->request->get('entryDataIn')[$key],true),
  4880.                         "out"=>json_decode($request->request->get('entryDataOut')[$key],true)
  4881.                     )
  4882.                 ));
  4883. //                $bulkAttendance->setLastStartTime(new \DateTime($request->request->get('startDate')));
  4884. //                $bulkAttendance->setIsPresent(1);
  4885.                 $bulkAttendance->setLastStartTimeTs($request->request->get('startTimeTs')[$key]);
  4886.                 $bulkAttendance->setLastEndTimeTs($request->request->get('endTimeTs')[$key]);
  4887. //                $bulkAttendance->setTotalWorkHour($request->request->get('totalWorkHour')[$key]);
  4888.                 $em->persist($bulkAttendance);
  4889.                 $em->flush();
  4890.                 $bulkAttendanceLog $em->getRepository('ApplicationBundle:EmployeeAttendanceLog')->findOneBy(array(
  4891.                     'attendance_id' => $bulkAttendance->getId(),
  4892.                 ));
  4893.                 if(!$bulkAttendanceLog)
  4894.                     $bulkAttendanceLog = new EmployeeAttendanceLog;
  4895.                 $bulkAttendanceLog->setAttendanceId($bulkAttendance->getId());
  4896.                 $bulkAttendanceLog->setEmployeeId($request->request->get('employeeId'));
  4897.                 $bulkAttendanceLog->setLastStartTime(
  4898.                     ($request->request->get('startTimeTs')[$key] =='' ||
  4899.                         $request->request->get('startTimeTs')[$key]=='NaN' ||
  4900.                         $request->request->get('startTimeTs')[$key]==0) ?null:
  4901.                         new \DateTime('@'.$request->request->get('startTimeTs')[$key])
  4902.                 );
  4903.                 $bulkAttendanceLog->setLastEndTime(($request->request->get('endTimeTs')[$key] =='' ||
  4904.                     $request->request->get('endTimeTs')[$key]=='NaN' ||
  4905.                     $request->request->get('endTimeTs')[$key]==0) ?null:
  4906.                     new \DateTime('@'.$request->request->get('endTimeTs')[$key]));
  4907. //                $bulkAttendance->setLastStartTime(new \DateTime($request->request->get('startDate')));
  4908.                 $bulkAttendanceLog->setIsPresent(1);
  4909.                 $bulkAttendanceLog->setLastStartTimeTs($request->request->get('startTimeTs')[$key]);
  4910.                 $bulkAttendanceLog->setLastEndTimeTs($request->request->get('endTimeTs')[$key]);
  4911.                 $bulkAttendanceLog->setTotalWorkHour($request->request->get('totalWorkHour')[$key]);
  4912. //                $bulkAttendanceLog->setPositionArray(json_encode($request->request->get('locations')[$key]));
  4913.                 $em->persist($bulkAttendanceLog);
  4914.                 $em->flush();
  4915.             }
  4916.         }
  4917.         $startDate=$request->query->get('start_date','');
  4918.         $endDate=$request->query->get('end_date','');
  4919.         $employeeId=$request->query->get('employee_id',0);
  4920.         $existingData=[];
  4921.         $startDateTs=0;
  4922.         $endDateTs=0;
  4923.         $returnData=array(
  4924.             'page_title' => 'Bulk Attendance',
  4925.             'existingData' => $existingData,
  4926.             'startDateTs' =>  $startDateTs,
  4927.             'endDateTs' =>  $endDateTs,
  4928.         );
  4929.         if ($request->query->has('returnJson')) {
  4930.             if($startDate !='' && $endDate !='' && $employeeId!=0)
  4931.             {
  4932.                 $startDateDt=new \DateTime($startDate);
  4933.                 $endDateDt=new \DateTime($endDate);
  4934.                 $startDateTs=$startDateDt->format('U');
  4935.                 $endDateTs=$endDateDt->format('U');
  4936.                 $attendanceQuery $em->getRepository('ApplicationBundle:EmployeeAttendance')
  4937.                     ->createQueryBuilder('p')
  4938.                     ->where("p.employeeId = ".$employeeId)
  4939. //                ->andWhere("p.date => '" . ($startDateDt->format('Y-m-d'))."'")
  4940.                     ->andWhere("p.date <= :last" )
  4941.                     ->andWhere("p.date >= :start" )
  4942.                     ->setParameter('start'$startDateDt)
  4943.                     ->setParameter('last'$endDateDt);
  4944.                 $attendanceResults $attendanceQuery->getQuery()->getResult();
  4945.                 foreach($attendanceResults as $att)
  4946.                 {
  4947.                     $entryDateTime=null;
  4948.                     $outDateTime=null;
  4949.                     if($att->getEntry()) $entryDateTime=new \DateTime($att->getDate()->format('Y-m-d').' '.$att->getEntry()->format('H:i:00 +0000'));
  4950.                     if($att->getLastOut()) $outDateTime=new \DateTime($att->getDate()->format('Y-m-d').' '.$att->getLastOut()->format('H:i:00 +0000'));
  4951.                     $attData=array(
  4952.                         'id'=>$att->getId(),
  4953.                         'date_str'=>$att->getDate()->format('Y-m-d'),
  4954.                         'date_str_full'=>$att->getDate()->format('Y-m-d H:i:s'),
  4955.                         'in_time_full'=>$entryDateTime?$entryDateTime->format(DATE_RFC2822 ):'',
  4956.                         'date_ts'=>$att->getDate()->format('U'),
  4957.                         'in_time' => $entryDateTime?$entryDateTime->format('H:i:s'):'',
  4958.                         'in_time_ts' => $entryDateTime?$entryDateTime->format('U'):0,
  4959.                         'last_out_time' =>$outDateTime?$outDateTime->format('H:i:s'):'',
  4960.                         'last_out_time_ts' => $outDateTime?$outDateTime->format('U'):'',
  4961.                     );
  4962.                     $locations = [];
  4963.                     $locList = [];
  4964.                     $logHere $em->getRepository('ApplicationBundle:EmployeeAttendanceLog')->findOneBy(array(
  4965.                         'attendance_id' => $att->getId(),
  4966.                     ));
  4967.                     if ($logHere)
  4968.                         $locList json_decode($logHere->getPositionArray(), true);
  4969.                     if ($locList == null)
  4970.                         $locList = [];
  4971.                     $entry_data json_decode($att->getData(), true);
  4972.                     if ($entry_data == null$entry_data = [];
  4973.                     $lastLat 0;
  4974.                     $lastLng 0;
  4975.                     foreach ($locList as $lg) {
  4976.                         $dist 0;
  4977.                         if (isset($lg['lat'])) {
  4978.                             if ($lastLat == 0) {
  4979.                                 $lastLat $lg['lat'];
  4980.                                 $lastLng $lg['lng'];
  4981.                             }
  4982.                             $theta $lastLng $lg['lng'];
  4983.                             $dist sin(deg2rad($lastLat)) * sin(deg2rad($lg['lat'])) + cos(deg2rad($lastLat)) * cos(deg2rad($lg['lat'])) * cos(deg2rad($theta));
  4984.                             $dist acos($dist);
  4985.                             $dist rad2deg($dist);
  4986.                             $miles $dist 60 1.1515;
  4987.                             $dist $miles 1609.344;
  4988.                             if (abs($dist) > 1000) {
  4989.                                 $locations[] = array(
  4990.                                     'ts' => $lg['ts'],
  4991.                                     'lat' => $lg['lat'],
  4992.                                     'lng' => $lg['lng'],
  4993.                                 );
  4994.                                 $lastLat $lg['lat'];
  4995.                                 $lastLng $lg['lng'];
  4996.                             }
  4997.                         }
  4998.                     }
  4999.                     $attData['locations']=$locations;
  5000.                     $attData['entryData']=$entry_data;
  5001.                     $existingData[$att->getDate()->format('U')]=$attData;
  5002.                 }
  5003.             }
  5004.             $returnData=array(
  5005.                 'page_title' => 'Bulk Attendance',
  5006.                 'existingData' => $existingData,
  5007.                 'startDateTs' =>  $startDateTs,
  5008.                 'endDateTs' =>  $endDateTs,
  5009.             );
  5010.             return new JsonResponse($returnData);
  5011.         }
  5012.         else
  5013.             return $this->render('ApplicationBundle:pages/human_resource/attendance:bulk_attendance.html.twig'$returnData);
  5014.     }
  5015.     public function CreateAttendanceAmendmentAction(Request $request$id 0)
  5016.     {
  5017.         $em $this->getDoctrine()->getManager();
  5018.         $companyId $this->getLoggedUserCompanyId($request);
  5019.         $extDocData = [];
  5020.         if ($request->isMethod('POST') ) {
  5021.             $em $this->getDoctrine()->getManager();
  5022.             $entity_id array_flip(GeneralConstant::$Entity_list)['AttendanceAmendment']; //change
  5023.             $dochash $request->request->get('docHash'); //change
  5024.             $loginId $request->getSession()->get(UserConstants::USER_LOGIN_ID);
  5025.             $approveRole $request->request->get('approvalRole');
  5026.             $approveHash $request->request->get('approvalHash');
  5027.             if ($dochash == '') {
  5028.                 $numberHash MiscActions::GetNumberHash($em'ATAM'$request->request->get('prefix_hash',$request->request->get('employeeId',0)), $request->request->get('assoc_hash',0), ''1);
  5029.                 $dochash 'ATAM' '/' $request->request->get('prefix_hash',$request->request->get('employeeId',0)) . '/' $request->request->get('assoc_hash',0) . '/' $numberHash;
  5030.             }
  5031.             else
  5032.                 $numberHash $request->request->get('number_hash');
  5033.             if (!DocValidation::isInsertable($em$entity_id$dochash,
  5034.                 $loginId$approveRole$approveHash$id)
  5035.             ) {
  5036.                 if ($request->request->has('returnJson')) {
  5037.                     return new JsonResponse(array(
  5038.                         'success' => false,
  5039.                         'documentHash' => 0,
  5040.                         'documentId' => 0,
  5041.                     ));
  5042.                 } else
  5043.                     $this->addFlash(
  5044.                         'error',
  5045.                         'Sorry Could not insert Data.'
  5046.                     );
  5047.             } else {
  5048.                 $funcname 'AttendanceAmendment';
  5049.                 $doc_id $id;
  5050.                 DeleteDocument::$funcname($em$doc_id0);
  5051.                 $attendanceAmendment = new AttendanceAmendment();
  5052.                 $attendanceAmendment->setDocumentHash($dochash);
  5053.                 $attendanceAmendment->setAttendanceAmendmentDate(new \DateTime($request->request->get('docDate','')));
  5054.                 $attendanceAmendment->setStartDate(new \DateTime($request->request->get('startDate','')));
  5055.                 $attendanceAmendment->setEndDate(new \DateTime($request->request->get('endDate','')));
  5056.                 $attendanceAmendment->setTypeHash('ATAM');
  5057.                 $attendanceAmendment->setPrefixHash($request->request->get('prefix_hash',0));
  5058.                 $attendanceAmendment->setAssocHash($request->request->get('assoc_hash',0));
  5059.                 $attendanceAmendment->setNumberHash($numberHash);
  5060.                 $attendanceAmendment->setCreatedLoginId($request->getSession()->get(UserConstants::USER_LOGIN_ID));
  5061.                 $attendanceAmendment->setApproved(array_flip(GeneralConstant::$approvalStatus)['pending']);
  5062.                 $attendanceAmendment->setAutoCreated($request->request->get('fullApprove',0));
  5063.                 $attendanceAmendment->setEmployeeId($request->request->get('forcedEmployeeId',$request->request->get('employeeId',0)));
  5064. //                $attendanceAmendment->setAutocreated(0);
  5065.                 if ($request->request->has('dataArrayJson')) {
  5066.                     $attendanceAmendment->setData($request->request->get('dataArrayJson''[]'));
  5067.                 } else {
  5068.                     $arr = [
  5069.                     ];
  5070.                     //dump($arr);
  5071.                     foreach ($request->request->get('date',[]) as $key => $val) {
  5072.                         if($request->request->get('isChanged')[$key]==1) {
  5073.                             $dt = array(
  5074.                                 'enabled' => 1,
  5075.                                 'attId' => $request->request->get('attId')[$key],
  5076.                                 'note' => $request->request->get('note')[$key],
  5077.                                 'startTimeTs' => $request->request->get('startTimeTs')[$key],
  5078.                                 'endTimeTs' => $request->request->get('endTimeTs')[$key],
  5079.                                 'totalWorkHour' => $request->request->get('totalWorkHour')[$key],
  5080.                                 'entryDataIn' => json_decode($request->request->get('entryDataIn')[$key], true),
  5081.                                 'entryDataOut' => json_decode($request->request->get('entryDataOut')[$key], true),
  5082.                             );
  5083.                             $arr[$val] = $dt;
  5084.                         }
  5085.                     }
  5086.                     $attendanceAmendment->setData(json_encode($arr));
  5087.                 }
  5088.                 $em->persist($attendanceAmendment);
  5089.                 $em->flush();
  5090.                 $ID=$attendanceAmendment->getAttendanceAmendmentId();
  5091.                 //now add Approval info
  5092.                 $loginId $request->getSession()->get(UserConstants::USER_LOGIN_ID);
  5093.                 $approveRole 1;  //created
  5094.                 $options = array(
  5095.                     'notification_enabled' => $this->container->getParameter('notification_enabled'),
  5096.                     'notification_server' => $this->container->getParameter('notification_server'),
  5097.                     'appId' => $request->getSession()->get(UserConstants::USER_APP_ID),
  5098.                     'url' => $this->generateUrl(
  5099.                         GeneralConstant::$Entity_list_details[array_flip(GeneralConstant::$Entity_list)['AttendanceAmendment']]
  5100.                         ['entity_view_route_path_name']
  5101.                     )
  5102.                 );
  5103.                 System::setApprovalInfo($this->getDoctrine()->getManager(), $options,
  5104.                     array_flip(GeneralConstant::$Entity_list)['AttendanceAmendment'],
  5105.                     $ID,
  5106.                     $request->getSession()->get(UserConstants::USER_LOGIN_ID)    //journal voucher
  5107.                 );
  5108.                 if($request->request->get('fullApprove',0)==1)
  5109.                 {
  5110.                     DeleteDocument::AttendanceAmendment($em,$ID);
  5111.                 }
  5112.                 else {
  5113.                     System::createEditSignatureHash($this->getDoctrine()->getManager(), array_flip(GeneralConstant::$Entity_list)['AttendanceAmendment'], $ID,
  5114.                         $loginId,
  5115.                         $approveRole,
  5116.                         $request->request->get('approvalHash'));
  5117.                     $url $this->generateUrl(
  5118.                         'view_attendance_amendment'
  5119.                     );
  5120.                     if ($request->request->has('returnJson')) {
  5121.                         return new JsonResponse(array(
  5122.                             'success' => true,
  5123.                             'documentHash' => $dochash,
  5124.                             'documentId' => $ID,
  5125.                             'viewUrl' => $url "/" $ID,
  5126.                         ));
  5127.                     } else {
  5128.                         $this->addFlash(
  5129.                             'success',
  5130.                             'Attendance Amendment Note Added.'
  5131.                         );
  5132.                         return $this->redirect($url "/" $ID);
  5133.                     }
  5134.                 }
  5135.             }
  5136.         }
  5137.         if ($id == 0) {
  5138.         }
  5139.         else {
  5140.             $extDoc $em->getRepository('ApplicationBundle:AttendanceAmendment')->findOneBy(
  5141.                 array(
  5142.                     'salesOrderId' => $id///material
  5143.                 )
  5144.             );
  5145.             //now if its not editable, redirect to view
  5146.             if ($extDoc) {
  5147.                 if ($extDoc->getEditFlag() != 1) {
  5148.                     $url $this->generateUrl(
  5149.                         'view_attendance_amendment'
  5150.                     );
  5151.                     return $this->redirect($url "/" $id);
  5152.                 } else {
  5153.                     $extDocData $extDoc;
  5154.                 }
  5155.             } else {
  5156.             }
  5157.         }
  5158.         $startDate=$request->query->get('start_date','');
  5159.         $endDate=$request->query->get('end_date','');
  5160.         $employeeId=$request->query->get('employee_id',0);
  5161.         $existingData=[];
  5162.         $startDateTs=0;
  5163.         $endDateTs=0;
  5164.         $returnData=array(
  5165.             'page_title' => 'Attendance Amendment',
  5166.             'existingData' => $existingData,
  5167.             'startDateTs' =>  $startDateTs,
  5168.             'extDocData' =>  $extDocData,
  5169.             'endDateTs' =>  $endDateTs,
  5170.         );
  5171.         if ($request->query->has('returnJson')) {
  5172.             if($startDate !='' && $endDate !='' && $employeeId!=0)
  5173.             {
  5174.                 $startDateDt=new \DateTime($startDate);
  5175.                 $endDateDt=new \DateTime($endDate);
  5176.                 $startDateTs=$startDateDt->format('U');
  5177.                 $endDateTs=$endDateDt->format('U');
  5178.                 $attendanceQuery $em->getRepository('ApplicationBundle:EmployeeAttendance')
  5179.                     ->createQueryBuilder('p')
  5180.                     ->where("p.employeeId = ".$employeeId)
  5181. //                ->andWhere("p.date => '" . ($startDateDt->format('Y-m-d'))."'")
  5182.                     ->andWhere("p.date <= :last" )
  5183.                     ->andWhere("p.date >= :start" )
  5184.                     ->setParameter('start'$startDateDt)
  5185.                     ->setParameter('last'$endDateDt);
  5186.                 $attendanceResults $attendanceQuery->getQuery()->getResult();
  5187.                 foreach($attendanceResults as $att)
  5188.                 {
  5189.                     $entryDateTime=null;
  5190.                     $outDateTime=null;
  5191.                     if($att->getEntry()) $entryDateTime=new \DateTime($att->getDate()->format('Y-m-d').' '.$att->getEntry()->format('H:i:00 +0000'));
  5192.                     if($att->getLastOut()) $outDateTime=new \DateTime($att->getDate()->format('Y-m-d').' '.$att->getLastOut()->format('H:i:00 +0000'));
  5193.                     $attData=array(
  5194.                         'id'=>$att->getId(),
  5195.                         'date_str'=>$att->getDate()->format('Y-m-d'),
  5196.                         'date_str_full'=>$att->getDate()->format('Y-m-d H:i:s'),
  5197.                         'in_time_full'=>$entryDateTime?$entryDateTime->format(DATE_RFC2822 ):'',
  5198.                         'date_ts'=>$att->getDate()->format('U'),
  5199.                         'in_time' => $entryDateTime?$entryDateTime->format('H:i:s'):'',
  5200.                         'in_time_ts' => $entryDateTime?$entryDateTime->format('U'):0,
  5201.                         'last_out_time' =>$outDateTime?$outDateTime->format('H:i:s'):'',
  5202.                         'last_out_time_ts' => $outDateTime?$outDateTime->format('U'):'',
  5203.                     );
  5204.                     $locations = [];
  5205.                     $locList = [];
  5206.                     $logHere $em->getRepository('ApplicationBundle:EmployeeAttendanceLog')->findOneBy(array(
  5207.                         'attendance_id' => $att->getId(),
  5208.                     ));
  5209.                     if ($logHere)
  5210.                         $locList json_decode($logHere->getPositionArray(), true);
  5211.                     if ($locList == null)
  5212.                         $locList = [];
  5213.                     $entry_data json_decode($att->getData(), true);
  5214.                     if ($entry_data == null$entry_data = [];
  5215.                     $lastLat 0;
  5216.                     $lastLng 0;
  5217.                     foreach ($locList as $lg) {
  5218.                         $dist 0;
  5219.                         if (isset($lg['lat'])) {
  5220.                             if ($lastLat == 0) {
  5221.                                 $lastLat $lg['lat'];
  5222.                                 $lastLng $lg['lng'];
  5223.                             }
  5224.                             $theta $lastLng $lg['lng'];
  5225.                             $dist sin(deg2rad($lastLat)) * sin(deg2rad($lg['lat'])) + cos(deg2rad($lastLat)) * cos(deg2rad($lg['lat'])) * cos(deg2rad($theta));
  5226.                             $dist acos($dist);
  5227.                             $dist rad2deg($dist);
  5228.                             $miles $dist 60 1.1515;
  5229.                             $dist $miles 1609.344;
  5230.                             if (abs($dist) > 1000) {
  5231.                                 $locations[] = array(
  5232.                                     'ts' => $lg['ts'],
  5233.                                     'lat' => $lg['lat'],
  5234.                                     'lng' => $lg['lng'],
  5235.                                 );
  5236.                                 $lastLat $lg['lat'];
  5237.                                 $lastLng $lg['lng'];
  5238.                             }
  5239.                         }
  5240.                     }
  5241.                     $attData['locations']=$locations;
  5242.                     $attData['entryData']=$entry_data;
  5243.                     $existingData[$att->getDate()->format('U')]=$attData;
  5244.                 }
  5245.             }
  5246.             $returnData=array(
  5247.                 'page_title' => 'Attendance Amendment',
  5248.                 'existingData' => $existingData,
  5249.                 'startDateTs' =>  $startDateTs,
  5250.                 'extDocData' =>  $extDocData,
  5251.                 'endDateTs' =>  $endDateTs,
  5252.             );
  5253.             return new JsonResponse($returnData);
  5254.         }
  5255.         else
  5256.             return $this->render('ApplicationBundle:pages/human_resource/attendance:create_attendance_amendment.html.twig'$returnData);
  5257.     }
  5258.     public function AttendanceAmendmentListAction(Request $request)
  5259.     {
  5260.         $data = [];
  5261.         return $this->render('ApplicationBundle:pages/human_resource/list:attendance_amendment_list.html.twig',
  5262.             array(
  5263.                 'page_title' => 'Attendance Amendment List',
  5264.                 'data' => $data
  5265.             )
  5266.         );
  5267.     }
  5268.     public function ViewAttendanceAmendmentAction(Request $request$id)
  5269.     {
  5270.         $em $this->getDoctrine()->getManager();
  5271.         $dt HumanResource::GetAttendanceAmendmentDetails($em$id);
  5272.         return $this->render('ApplicationBundle:pages/human_resource/views:view_attendance_amendment.html.twig',
  5273.             array(
  5274.                 'page_title' => 'Attendance Amendment',
  5275.                 'data' => $dt,
  5276.                 'approval_data' => System::checkIfApprovalExists($emarray_flip(GeneralConstant::$Entity_list)['AttendanceAmendment'],
  5277.                     $id$request->getSession()->get(UserConstants::USER_LOGIN_ID)),
  5278.                 'document_log' => System::getDocumentLog($this->getDoctrine()->getManager(),
  5279.                     array_flip(GeneralConstant::$Entity_list)['AttendanceAmendment'],
  5280.                     $id,
  5281.                     $dt['created_by'],
  5282.                     $dt['edited_by'])
  5283.             )
  5284.         );
  5285.     }
  5286.     public function PrintAttendanceAmendmentAction(Request $request$id)
  5287.     {
  5288.         $em $this->getDoctrine()->getManager();
  5289.         $dt HumanResource::GetAttendanceAmendmentDetails($em$id);
  5290.         $company_data Company::getCompanyData($em1);
  5291.         $document_mark = array(
  5292.             'original' => '/images/Original-Stamp-PNG-Picture.png',
  5293.             'copy' => ''
  5294.         );
  5295.         if ($request->query->has('pdf') && $this->get('knp_snappy.pdf')) {
  5296.             $html $this->renderView('ApplicationBundle:pages/inventory/print:print_stock_received_note.html.twig',
  5297.                 array(
  5298.                     //full array here
  5299.                     'pdf' => true,
  5300.                     'page_title' => 'Stock Received Note',
  5301.                     'export' => 'pdf,print',
  5302.                     'data' => $dt,
  5303.                     'approval_data' => System::checkIfApprovalExists($emarray_flip(GeneralConstant::$Entity_list)['AttendanceAmendment'],
  5304.                         $id$request->getSession()->get(UserConstants::USER_LOGIN_ID)),
  5305.                     'document_log' => System::getDocumentLog($this->getDoctrine()->getManager(),
  5306.                         array_flip(GeneralConstant::$Entity_list)['AttendanceAmendment'],
  5307.                         $id,
  5308.                         $dt['created_by'],
  5309.                         $dt['edited_by']),
  5310.                     'document_mark_image' => $document_mark['original'],
  5311.                     'company_name' => $company_data->getName(),
  5312.                     'company_data' => $company_data,
  5313.                     'company_address' => $company_data->getAddress(),
  5314.                     'company_image' => $company_data->getImage(),
  5315.                     'invoice_footer' => $company_data->getInvoiceFooter(),
  5316.                     'red' => 0
  5317.                 )
  5318.             );
  5319.             $pdf_response $this->get('knp_snappy.pdf')->getOutputFromHtml($html, array(
  5320. //                'orientation' => 'landscape',
  5321. //                'enable-javascript' => true,
  5322. //                'javascript-delay' => 1000,0
  5323.                 'no-stop-slow-scripts' => false,
  5324.                 'no-background' => false,
  5325.                 'lowquality' => false,
  5326.                 'encoding' => 'utf-8',
  5327. //            'images' => true,
  5328. //            'cookie' => array(),
  5329.                 'dpi' => 300,
  5330.                 'image-dpi' => 300,
  5331. //                'enable-external-links' => true,
  5332. //                'enable-internal-links' => true
  5333.             ));
  5334.             return new Response(
  5335.                 $pdf_response,
  5336.                 200,
  5337.                 array(
  5338.                     'Content-Type' => 'application/pdf',
  5339.                     'Content-Disposition' => 'attachment; filename="stock_received_note_' $id '.pdf"'
  5340.                 )
  5341.             );
  5342.         }
  5343.         return $this->render('ApplicationBundle:pages/human_resource/views:view_attendance_amendment.html.twig',
  5344.             array(
  5345.                 'page_title' => 'Attendance Amendment',
  5346.                 'data' => $dt,
  5347.                 'approval_data' => System::checkIfApprovalExists($emarray_flip(GeneralConstant::$Entity_list)['AttendanceAmendment'],
  5348.                     $id$request->getSession()->get(UserConstants::USER_LOGIN_ID)),
  5349.                 'document_log' => System::getDocumentLog($this->getDoctrine()->getManager(),
  5350.                     array_flip(GeneralConstant::$Entity_list)['AttendanceAmendment'],
  5351.                     $id,
  5352.                     $dt['created_by'],
  5353.                     $dt['edited_by'])
  5354.             )
  5355.         );
  5356.     }
  5357.     public function createRoomAction(Request $request)
  5358.     {
  5359.         $em $this->getDoctrine()->getManager();
  5360.         $companyId $this->getLoggedUserCompanyId($request);
  5361.         if ($request->isMethod('POST')) {
  5362.             $loginId $request->getSession()->get(UserConstants::USER_LOGIN_ID);
  5363.             $room = new Room;
  5364.             $room->setRoomNo($request->request->get('RoomNo'));
  5365.             //$room->setRoomName($request->request->get('RoomName'));
  5366.             $room->setBuilding($request->request->get('buildingName'));
  5367.             $room->setFloor($request->request->get('floor'));
  5368.             $room->setCapacity($request->request->get('capacity'));
  5369.             $room->setCreatedLoginId($request->getSession()->get(UserConstants::USER_LOGIN_ID));
  5370.             $em->persist($room);
  5371.             $em->flush();
  5372.         }
  5373.         return $this->render('ApplicationBundle:pages/human_resource/input_forms:create_room.html.twig', array(
  5374.             'page_title' => 'Add Room',
  5375.         ));
  5376.     }
  5377.     public function ExpenseTypeAction()
  5378.     {
  5379.         $expenseType HumanResourceConstant::$employeeExpenseAllowanceTypes;
  5380.         $expenseTypeArray = [];
  5381.         foreach ($expenseType as $k => $dt) {
  5382.             $dt['id'] = $k;
  5383.             $newSegs = [];
  5384.             foreach ($dt['segregations'] as $l => $s) {
  5385.                 $newOptions = [];
  5386.                 foreach ($s['options'] as $l2 => $s2) {
  5387.                     $s3 = array(
  5388.                         'value' => $l2,
  5389.                         'text' => $s2,
  5390.                     );
  5391.                     $newOptions[] = $s3;
  5392.                 }
  5393.                 $s['options'] = $newOptions;
  5394.                 if (is_string($s['defaultVal'])) $s['defaultVal'] = [$s['defaultVal']];
  5395.                 $newSegs[] = $s;
  5396.             }
  5397.             $dt['segregations'] = $newSegs;
  5398.             $expenseTypeArray[] = $dt;
  5399.         }
  5400.         return new JsonResponse(
  5401.             array(
  5402.                 'success' => true,
  5403.                 'expenseType' => $expenseType,
  5404.                 'expenseTypeArray' => $expenseTypeArray,
  5405.             )
  5406.         );
  5407.     }
  5408.     public function DemoDataTableAction()
  5409.     {
  5410.         return $this->render('ApplicationBundle:pages/human_resource/list:demo_data_table.html.twig', array(
  5411.             'page_title' => 'Add Room',
  5412.         ));
  5413.     }
  5414.     public function workEnrtyAction(Request $request)
  5415.     {
  5416. //        $em = $this->getDoctrine()->getManager();
  5417. //        $companyId = $this->getLoggedUserCompanyId($request);
  5418. //        if ($request->isMethod('POST')) {
  5419. //            $loginId = $request->getSession()->get(UserConstants::USER_LOGIN_ID);
  5420. //            $labour = new Labour();
  5421. //            $labour->setLabourName($request->request->get('labourName'));
  5422. //            $labour->setNidNumber($request->request->get('nidNumber'));
  5423. //            $em->persist($labour);
  5424. //            $em->flush();
  5425. //            $this->addFlash(
  5426. //                'success',
  5427. //                'Labour Added'
  5428. //            );
  5429. //        }
  5430.         return $this->render('ApplicationBundle:pages/human_resource/input_forms:work_entry.html.twig', array(
  5431.             'page_title' => 'Work Entry',
  5432.         ));
  5433.     }
  5434.     public function ViewContractLetterAction(Request  $request$id)
  5435.     {
  5436.         $em $this->getDoctrine()->getManager();
  5437.         $employeeDetail $em->getRepository('ApplicationBundle:EmployeeDetails')->find($id);
  5438. //        $employeeData = [];
  5439. //        foreach ($employeeDetails as $employeeDetail) {
  5440. //            $data = array(
  5441. //                'firstName' => $employeeDetail->getNid(),
  5442. //
  5443. //
  5444. //
  5445. //            );
  5446. //
  5447. //
  5448. //            $employeeData[] = $data;
  5449. //        }
  5450.         return $this->render('ApplicationBundle:pages/human_resource/views:viewContractLetter.html.twig', array(
  5451.             'page_title' => 'Contract Letter',
  5452.             'employeeDetail' => $employeeDetail
  5453.         ));
  5454.     }
  5455. }