src/ApplicationBundle/Controller/HumanResourceController.php line 3038

Open in your IDE?
  1. <?php
  2. namespace ApplicationBundle\Controller;
  3. use ApplicationBundle\Constants\BuddybeeConstant;
  4. use ApplicationBundle\Constants\GeneralConstant;
  5. use ApplicationBundle\Constants\HumanResourceConstant;
  6. use ApplicationBundle\Constants\MeetingSchedulingConstant;
  7. use ApplicationBundle\Entity\AttendanceAmendment;
  8. use ApplicationBundle\Entity\BankList;
  9. use ApplicationBundle\Entity\BonusPolicy;
  10. use ApplicationBundle\Entity\Branch;
  11. use ApplicationBundle\Entity\ConsultancyTopic;
  12. use ApplicationBundle\Entity\EducationQualification;
  13. use ApplicationBundle\Entity\Employee;
  14. use ApplicationBundle\Entity\EmployeeAttendance;
  15. use ApplicationBundle\Entity\EmployeeAttendanceLog;
  16. use ApplicationBundle\Entity\EmployeeDetails;
  17. use ApplicationBundle\Entity\EmployeeLeaveApplication;
  18. use ApplicationBundle\Entity\EvaluationCategory;
  19. use ApplicationBundle\Entity\HolidayCalendar;
  20. use ApplicationBundle\Entity\HolidayCalendarDates;
  21. use ApplicationBundle\Entity\IncrementPolicy;
  22. use ApplicationBundle\Entity\LeaveSettings;
  23. use ApplicationBundle\Entity\PayrollPolicy;
  24. use ApplicationBundle\Entity\PlanningItem;
  25. use ApplicationBundle\Entity\Questionnaire;
  26. use ApplicationBundle\Entity\ScheduledMeeting;
  27. use ApplicationBundle\Entity\Skill;
  28. use ApplicationBundle\Entity\SysDepartment;
  29. use ApplicationBundle\Entity\SysDepartmentPosition;
  30. use ApplicationBundle\Entity\SysUser;
  31. use ApplicationBundle\Entity\TrainingCourse;
  32. use ApplicationBundle\Entity\WorkHourPolicy;
  33. use ApplicationBundle\Helper\ResponseStructure;
  34. use ApplicationBundle\Interfaces\SessionCheckInterface;
  35. use ApplicationBundle\Modules\Accounts\Accounts;
  36. use ApplicationBundle\Modules\Authentication\Constants\UserConstants;
  37. use ApplicationBundle\Modules\Buddybee\Buddybee;
  38. use ApplicationBundle\Modules\HumanResource\HumanResource;
  39. use ApplicationBundle\Modules\HumanResource\HumanResourceHelper;
  40. use ApplicationBundle\Modules\Inventory\Inventory;
  41. use ApplicationBundle\Modules\Sales\Client;
  42. use ApplicationBundle\Modules\System\DeleteDocument;
  43. use ApplicationBundle\Modules\System\DocValidation;
  44. use ApplicationBundle\Modules\System\MiscActions;
  45. use ApplicationBundle\Modules\System\System;
  46. use ApplicationBundle\Modules\User\Company;
  47. use CompanyGroupBundle\Entity\EntityApplicantDetails;
  48. use CompanyGroupBundle\Entity\EntityCountryConsultantRequirements;
  49. use CompanyGroupBundle\Entity\EntityCreateBlog;
  50. use CompanyGroupBundle\Entity\EntityCreateDocument;
  51. use CompanyGroupBundle\Entity\EntityCreateTopic;
  52. use CompanyGroupBundle\Entity\EntityFile;
  53. use CompanyGroupBundle\Entity\EntityInvoice;
  54. use CompanyGroupBundle\Entity\EntitySkill;
  55. use CompanyGroupBundle\Entity\PromoCode;
  56. use CompanyGroupBundle\Modules\ApplicantM;
  57. use DateTime;
  58. use Ps\PdfBundle\Annotation\Pdf;
  59. use Symfony\Component\HttpFoundation\JsonResponse;
  60. use Symfony\Component\HttpFoundation\Request;
  61. use Symfony\Component\HttpFoundation\Response;
  62. use Symfony\Component\Routing\Generator\UrlGenerator;
  63. use Throwable;
  64. //use Symfony\Bundle\FrameworkBundle\Console\Application;
  65. //use Symfony\Component\Console\Input\ArrayInput;
  66. //use Symfony\Component\Console\Output\NullOutput;
  67. class HumanResourceController extends GenericController implements SessionCheckInterface
  68. {
  69. //temporary for adding session
  70.     public function CheckoutPageAction(Request $request$encData '')
  71.     {
  72.         $em $this->getDoctrine()->getManager('company_group');
  73.         $em_goc $this->getDoctrine()->getManager('company_group');
  74.         $sandBoxMode $this->container->hasParameter('sand_box_mode') ? $this->container->getParameter('sand_box_mode') : 0;
  75.         $systemType $this->container->getParameter('system_type') ?: '_CENTRAL_';
  76.         $invoiceId $request->request->get('invoiceId'$request->query->get('invoiceId'0));
  77.         if ($encData != "") {
  78.             $encryptedData json_decode($this->get('url_encryptor')->decrypt($encData), true);
  79.             if ($encryptedData == null$encryptedData = [];
  80.             if (isset($encryptedData['invoiceId'])) $invoiceId $encryptedData['invoiceId'];
  81.         }
  82.         $session $request->getSession();
  83.         $currencyForGateway 'eur';
  84.         $gatewayInvoice null;
  85.         if ($invoiceId != 0)
  86.             $gatewayInvoice $em->getRepository(EntityInvoice::class)->find($invoiceId);
  87.         $paymentGateway $request->request->get('paymentGateway''stripe'); //aamarpay,bkash
  88.         $paymentType $request->request->get('paymentType''credit');
  89.         $retailerId $request->request->get('retailerId'0);
  90.         if ($request->query->has('currency'))
  91.             $currencyForGateway $request->query->get('currency');
  92.         else
  93.             $currencyForGateway $request->request->get('currency''eur');
  94. //        {
  95. //            if ($request->query->has('meetingSessionId'))
  96. //                $id = $request->query->get('meetingSessionId');
  97. //        }
  98.         $currentUserBalance 0;
  99.         $currentUserCoinBalance 0;
  100.         $gatewayAmount 0;
  101.         $redeemedAmount 0;
  102.         $redeemedSessionCount 0;
  103.         $toConsumeSessionCount 0;
  104.         $invoiceSessionCount 0;
  105.         $payableAmount 0;
  106.         $promoClaimedAmount 0;
  107.         $promoCodeId 0;
  108.         $promoClaimedSession 0;
  109.         $bookingExpireTime null;
  110.         $bookingExpireTs 0;
  111.         $imageBypackageId = [
  112.             => "https://www.buddybee.eu/buddybee_assets/ADULT-BEE.png",
  113.             => "https://www.buddybee.eu/buddybee_assets/ADULT-BEE.png",
  114.             => "https://www.buddybee.eu/buddybee_assets/ADULT-BEE.png",
  115.             => "https://www.buddybee.eu/buddybee_assets/ADULT-BEE.png",
  116.             => "https://www.buddybee.eu/buddybee_assets/ADULT-BEE.png",
  117.             => "https://www.buddybee.eu/buddybee_assets/ADULT-BEE.png",
  118.         ];
  119.         $imageBySessionCount = [
  120.             => "https://www.buddybee.eu/buddybee_assets/ADULT-BEE.png",
  121.             100 => "https://www.buddybee.eu/buddybee_assets/ADULT-BEE.png",
  122.             200 => "https://www.buddybee.eu/buddybee_assets/ADULT-BEE.png",
  123.             300 => "https://www.buddybee.eu/buddybee_assets/ADULT-BEE.png",
  124.             400 => "https://www.buddybee.eu/buddybee_assets/ADULT-BEE.png",
  125.             500 => "https://www.buddybee.eu/buddybee_assets/ADULT-BEE.png",
  126.             600 => "https://www.buddybee.eu/buddybee_assets/ADULT-BEE.png",
  127.             700 => "https://www.buddybee.eu/buddybee_assets/ADULT-BEE.png",
  128.             800 => "https://www.buddybee.eu/buddybee_assets/ADULT-BEE.png",
  129.             900 => "https://www.buddybee.eu/buddybee_assets/ADULT-BEE.png",
  130.             1000 => "https://www.buddybee.eu/buddybee_assets/ADULT-BEE.png",
  131.             1100 => "https://www.buddybee.eu/buddybee_assets/ADULT-BEE.png",
  132.             1200 => "https://www.buddybee.eu/buddybee_assets/ADULT-BEE.png",
  133.             1300 => "https://www.buddybee.eu/buddybee_assets/ADULT-BEE.png",
  134.             1400 => "https://www.buddybee.eu/buddybee_assets/ADULT-BEE.png",
  135.             1500 => "https://www.buddybee.eu/buddybee_assets/ADULT-BEE.png",
  136.             1600 => "https://www.buddybee.eu/buddybee_assets/ADULT-BEE.png",
  137.             1700 => "https://www.buddybee.eu/buddybee_assets/ADULT-BEE.png",
  138.             1800 => "https://www.buddybee.eu/buddybee_assets/ADULT-BEE.png",
  139.             1900 => "https://www.buddybee.eu/buddybee_assets/ADULT-BEE.png",
  140.             2000 => "https://www.buddybee.eu/buddybee_assets/ADULT-BEE.png",
  141.             2100 => "https://www.buddybee.eu/buddybee_assets/ADULT-BEE.png",
  142.             2200 => "https://www.buddybee.eu/buddybee_assets/ADULT-BEE.png",
  143.             2300 => "https://www.buddybee.eu/buddybee_assets/ADULT-BEE.png",
  144.             2400 => "https://www.buddybee.eu/buddybee_assets/ADULT-BEE.png",
  145.             2500 => "https://www.buddybee.eu/buddybee_assets/ADULT-BEE.png",
  146.             2600 => "https://www.buddybee.eu/buddybee_assets/ADULT-BEE.png",
  147.             2700 => "https://www.buddybee.eu/buddybee_assets/ADULT-BEE.png",
  148.             2800 => "https://www.buddybee.eu/buddybee_assets/ADULT-BEE.png",
  149.             2900 => "https://www.buddybee.eu/buddybee_assets/ADULT-BEE.png",
  150.             3000 => "https://www.buddybee.eu/buddybee_assets/ADULT-BEE.png",
  151.             3100 => "https://www.buddybee.eu/buddybee_assets/ADULT-BEE.png",
  152.             3200 => "https://www.buddybee.eu/buddybee_assets/ADULT-BEE.png",
  153.             3300 => "https://www.buddybee.eu/buddybee_assets/ADULT-BEE.png",
  154.             3400 => "https://www.buddybee.eu/buddybee_assets/ADULT-BEE.png",
  155.             3500 => "https://www.buddybee.eu/buddybee_assets/ADULT-BEE.png",
  156.             3600 => "https://www.buddybee.eu/buddybee_assets/ADULT-BEE.png",
  157.             3700 => "https://www.buddybee.eu/buddybee_assets/ADULT-BEE.png",
  158.         ];
  159.         if (!$gatewayInvoice) {
  160.             if ($request->isMethod('POST')) {
  161.                 $totalAmount 0;
  162.                 $totalSessionCount 0;
  163.                 $consumedAmount 0;
  164.                 $consumedSessionCount 0;
  165.                 $bookedById 0;
  166.                 $bookingRefererId 0;
  167.                 if ($session->get(UserConstants::USER_ID)) {
  168.                     $bookedById $session->get(UserConstants::USER_ID);
  169.                     $bookingRefererId 0;
  170. //                    $toConsumeSessionCount = 1 * $request->request->get('meetingSessionConsumeCount', 0);
  171.                     $invoiceSessionCount * ($request->request->get('sessionCount'0) == '' $request->request->get('sessionCount'0));
  172.                     //1st do the necessary
  173.                     $extMeeting null;
  174.                     $meetingSessionId 0;
  175.                     $dataAppId $request->request->get('appId'$session->get(UserConstants::USER_APP_ID));
  176.                     $expireTsAddition $request->request->get('expireTsAddition',
  177.                         $request->request->get('billingFrequency'2) == 30 24 3600 365 24 2600
  178.                     );
  179.                     $expireTsModification $request->request->get('expireTsModification'0);
  180.                     $userAddition $request->request->get('userAddition'0);
  181.                     $userModification $request->request->get('userModification'0);
  182.                     $adminAddition $request->request->get('adminAddition'0);
  183.                     $adminModification $request->request->get('adminModification'0);
  184.                     $packageId $request->request->get('packageId'1);
  185.                     $successActionData = [
  186.                         'appId' => $dataAppId,
  187.                         'packageId' => $packageId,
  188.                         'expireTsAddition' => $expireTsAddition,/// can also be - if needed
  189.                         'expireTsModification' => $expireTsModification,/// can also be - if needed
  190.                         'userAddition' => $userAddition,/// can also be - if needed
  191.                         'userModification' => $userModification,/// can also be - if needed
  192.                         'adminAddition' => $adminAddition,/// can also be - if needed
  193.                         'adminModification' => $adminModification,/// can also be - if needed
  194.                     ];
  195.                     $expireActonData = [
  196.                     ];
  197.                     if ($request->request->has('purchasePackage')) {
  198.                         //1. check if any bee card if yes try to claim it , modify current balance then
  199.                         $beeCodeSerial $request->request->get('beeCodeSerial''');
  200.                         $promoCode $request->request->get('promoCode''');
  201.                         $beeCodePin $request->request->get('beeCodePin''');
  202.                         $userId $request->request->get('userId'$session->get(UserConstants::USER_ID));
  203.                         $studentDetails null;
  204.                         $studentDetails $em_goc->getRepository(EntityApplicantDetails::class)->find($userId);
  205.                         if ($studentDetails) {
  206.                             $currentUserBalance $studentDetails->getAccountBalance();
  207.                         }
  208.                         if ($beeCodeSerial != '' && $beeCodePin != '') {
  209.                             $claimData MiscActions::ClaimBeeCode($em,
  210.                                 [
  211.                                     'claimFlag' => 1,
  212.                                     'pin' => $beeCodePin,
  213.                                     'serial' => $beeCodeSerial,
  214.                                     'userId' => $userId,
  215.                                 ]);
  216.                             if ($userId == $session->get(UserConstants::USER_ID)) {
  217.                                 MiscActions::RefreshBuddybeeBalanceOnSession($em$request->getSession());
  218.                                 $claimData['newCoinBalance'] = $session->get('BUDDYBEE_COIN_BALANCE');
  219.                                 $claimData['newBalance'] = $session->get('BUDDYBEE_BALANCE');
  220.                             }
  221.                             $redeemedAmount $claimData['data']['claimedAmount'];
  222.                             $redeemedSessionCount $claimData['data']['claimedCoin'];
  223.                         } else
  224.                             if ($userId == $session->get(UserConstants::USER_ID)) {
  225.                                 MiscActions::RefreshBuddybeeBalanceOnSession($em$request->getSession());
  226.                             }
  227.                         $payableAmount round($request->request->get('payableAmount'0), 0);
  228.                         $totalAmountWoDiscount round($request->request->get('totalAmountWoDiscount'0), 0);
  229.                         //now claim and process promocode
  230.                         if ($promoCode != '') {
  231.                             $claimData MiscActions::ClaimPromoCode($em,
  232.                                 [
  233.                                     'claimFlag' => 1,
  234.                                     'promoCode' => $promoCode,
  235.                                     'decryptedPromoCodeData' => json_decode($this->get('url_encryptor')->decrypt($promoCode), true),
  236.                                     'orderValue' => $totalAmountWoDiscount,
  237.                                     'currency' => $currencyForGateway,
  238.                                     'orderCoin' => $invoiceSessionCount,
  239.                                     'userId' => $userId,
  240.                                 ]);
  241.                             $promoClaimedAmount 0;
  242. //                            $promoClaimedAmount = $claimData['data']['claimedAmount']*(BuddybeeConstant::$convMultFromTo['eur'][$currencyForGateway]);
  243.                             $promoCodeId $claimData['promoCodeId'];
  244.                             $promoClaimedSession $claimData['data']['claimedCoin'];
  245.                         }
  246.                         if ($userId == $session->get(UserConstants::USER_ID)) {
  247.                             MiscActions::RefreshBuddybeeBalanceOnSession($em$request->getSession());
  248.                             $currentUserBalance $session->get('BUDDYBEE_BALANCE');
  249.                             $currentUserCoinBalance $session->get('BUDDYBEE_COIN_BALANCE');
  250.                         } else {
  251.                             if ($bookingRefererId == 0)
  252.                                 $bookingRefererId $session->get(UserConstants::USER_ID);
  253.                             $studentDetails $em_goc->getRepository(EntityApplicantDetails::class)->find($userId);
  254.                             if ($studentDetails) {
  255.                                 $currentUserBalance $studentDetails->getAccountBalance();
  256.                                 $currentUserCoinBalance $studentDetails->getSessionCountBalance();
  257.                                 if ($bookingRefererId != $userId && $bookingRefererId != 0) {
  258.                                     $bookingReferer $em_goc->getRepository(EntityApplicantDetails::class)->find($bookingRefererId);
  259.                                     if ($bookingReferer)
  260.                                         if ($bookingReferer->getIsAdmin()) {
  261.                                             $studentDetails->setAssignedSalesRepresentativeId($bookingRefererId);
  262.                                             $em_goc->flush();
  263.                                         }
  264.                                 }
  265.                             }
  266.                         }
  267.                         //2. check if any promo code  if yes add it to promo discount
  268.                         //3. check if scheule is still temporarily booked if not return that you cannot book it
  269.                         Buddybee::ExpireAnyMeetingSessionIfNeeded($em);
  270.                         Buddybee::ExpireAnyEntityInvoiceIfNeeded($em);
  271. //                        if ($request->request->get('autoAssignMeetingSession', 0) == 1
  272. //                            && $request->request->get('consultancyScheduleId', 0) != 0
  273. //                            && $request->request->get('consultancyScheduleId', 0) != ''
  274. //                        )
  275.                         {
  276.                             //1st check if a meeting session exxists with same TS, student id , consultant id
  277. //                            $scheduledStartTime = new \DateTime('@' . $request->request->get('consultancyScheduleId', ''));
  278. //                            $extMeeting = $em->getRepository('CompanyGroupBundle:EntityMeetingSession')
  279. //                                ->findOneBy(
  280. //                                    array(
  281. //                                        'scheduledTimeTs' => $scheduledStartTime->format('U'),
  282. //                                        'consultantId' => $request->request->get('consultantId', 0),
  283. //                                        'studentId' => $request->request->get('studentId', 0),
  284. //                                        'durationAllowedMin' => $request->request->get('meetingSessionScheduledDuration', BuddybeeConstant::PER_SESSION_MINUTE),
  285. //                                    )
  286. //                                );
  287. //                            if ($extMeeting) {
  288. //                                $new = $extMeeting;
  289. //                                $meetingSessionId = $new->getSessionId();
  290. //                                $periodMarker = $scheduledStartTime->format('Ym');
  291. //
  292. //                            }
  293. //                            else {
  294. //
  295. //
  296. //                                $scheduleValidity = MiscActions::CheckIfScheduleCanBeConfirmed(
  297. //                                    $em,
  298. //                                    $request->request->get('consultantId', 0),
  299. //                                    $request->request->get('studentId', 0),
  300. //                                    $scheduledStartTime->format('U'),
  301. //                                    $request->request->get('meetingSessionScheduledDuration', BuddybeeConstant::PER_SESSION_MINUTE),
  302. //                                    1
  303. //                                );
  304. //
  305. //                                if (!$scheduleValidity) {
  306. //                                    $url = $this->generateUrl(
  307. //                                        'consultant_profile'
  308. //                                    );
  309. //                                    $output = [
  310. //
  311. //                                        'proceedToCheckout' => 0,
  312. //                                        'message' => 'Session Booking Expired or not Found!',
  313. //                                        'errorFlag' => 1,
  314. //                                        'redirectUrl' => $url . '/' . $request->request->get('consultantId', 0)
  315. //                                    ];
  316. //                                    return new JsonResponse($output);
  317. //                                }
  318. //                                $new = new EntityMeetingSession();
  319. //
  320. //                                $new->setTopicId($request->request->get('consultancyTopic', 0));
  321. //                                $new->setConsultantId($request->request->get('consultantId', 0));
  322. //                                $new->setStudentId($request->request->get('studentId', 0));
  323. //                                $consultancyTopic = $em_goc->getRepository(EntityCreateTopic::class)->find($request->request->get('consultancyTopic', 0));
  324. //                                $new->setMeetingType($consultancyTopic ? $consultancyTopic->getMeetingType() : 0);
  325. //                                $new->setConsultantCanUpload($consultancyTopic ? $consultancyTopic->getConsultantCanUpload() : 0);
  326. //
  327. //
  328. //                                $scheduledEndTime = new \DateTime($request->request->get('scheduledTime', ''));
  329. //                                $scheduledEndTime = $scheduledEndTime->modify('+' . $request->request->get('meetingSessionScheduledDuration', 30) . ' minute');
  330. //
  331. //                                //$new->setScheduledTime($request->request->get('setScheduledTime'));
  332. //                                $new->setScheduledTime($scheduledStartTime);
  333. //                                $new->setDurationAllowedMin($request->request->get('meetingSessionScheduledDuration', 30));
  334. //                                $new->setDurationLeftMin($request->request->get('meetingSessionScheduledDuration', 30));
  335. //                                $new->setSessionExpireDate($scheduledEndTime);
  336. //                                $new->setSessionExpireDateTs($scheduledEndTime->format('U'));
  337. //                                $new->setEquivalentSessionCount($request->request->get('meetingSessionConsumeCount', 0));
  338. //                                $new->setMeetingSpecificNote($request->request->get('meetingSpecificNote', ''));
  339. //
  340. //                                $new->setUsableSessionCount($request->request->get('meetingSessionConsumeCount', 0));
  341. //                                $new->setRedeemSessionCount($request->request->get('meetingSessionConsumeCount', 0));
  342. //                                $new->setMeetingActionFlag(0);// no action waiting for meeting
  343. //                                $new->setScheduledTime($scheduledStartTime);
  344. //                                $new->setScheduledTimeTs($scheduledStartTime->format('U'));
  345. //                                $new->setPayableAmount($request->request->get('payableAmount', 0));
  346. //                                $new->setDueAmount($request->request->get('dueAmount', 0));
  347. //                                //$new->setScheduledTime(new \DateTime($request->get('setScheduledTime')));
  348. //                                //$new->setPcakageDetails(json_encode(($request->request->get('packageData'))));
  349. //                                $new->setPackageName(($request->request->get('packageName', '')));
  350. //                                $new->setPcakageDetails(($request->request->get('packageData', '')));
  351. //                                $new->setScheduleId(($request->request->get('consultancyScheduleId', 0)));
  352. //                                $currentUnixTime = new \DateTime();
  353. //                                $currentUnixTimeStamp = $currentUnixTime->format('U');
  354. //                                $studentId = $request->request->get('studentId', 0);
  355. //                                $consultantId = $request->request->get('consultantId', 0);
  356. //                                $new->setMeetingRoomId(str_pad($consultantId, 4, STR_PAD_LEFT) . $currentUnixTimeStamp . str_pad($studentId, 4, STR_PAD_LEFT));
  357. //                                $new->setSessionValue(($request->request->get('sessionValue', 0)));
  358. ////                        $new->setIsPayment(0);
  359. //                                $new->setConsultantIsPaidFull(0);
  360. //
  361. //                                if ($bookingExpireTs == 0) {
  362. //
  363. //                                    $bookingExpireTime = new \DateTime();
  364. //                                    $currTime = new \DateTime();
  365. //                                    $currTimeTs = $currTime->format('U');
  366. //                                    $bookingExpireTs = (1 * $scheduledStartTime->format('U')) - (24 * 3600);
  367. //                                    if ($bookingExpireTs < $currTimeTs) {
  368. //                                        if ((1 * $scheduledStartTime->format('U')) - $currTimeTs > (12 * 3600))
  369. //                                            $bookingExpireTs = (1 * $scheduledStartTime->format('U')) - (2 * 3600);
  370. //                                        else
  371. //                                            $bookingExpireTs = (1 * $scheduledStartTime->format('U'));
  372. //                                    }
  373. //
  374. ////                                    $bookingExpireTs = $bookingExpireTime->format('U');
  375. //                                }
  376. //
  377. //                                $new->setPaidSessionCount(0);
  378. //                                $new->setBookedById($bookedById);
  379. //                                $new->setBookingRefererId($bookingRefererId);
  380. //                                $new->setDueSessionCount($request->request->get('meetingSessionConsumeCount', 0));
  381. //                                $new->setExpireIfUnpaidTs($bookingExpireTs);
  382. //                                $new->setBookingExpireTs($bookingExpireTs);
  383. //                                $new->setConfirmationExpireTs($bookingExpireTs);
  384. //                                $new->setIsPaidFull(0);
  385. //                                $new->setIsExpired(0);
  386. //
  387. //
  388. //                                $em_goc->persist($new);
  389. //                                $em_goc->flush();
  390. //                                $meetingSessionId = $new->getSessionId();
  391. //                                $periodMarker = $scheduledStartTime->format('Ym');
  392. //                                MiscActions::UpdateSchedulingRestrictions($em_goc, $consultantId, $periodMarker, (($request->request->get('meetingSessionScheduledDuration', 30)) / 60), -(($request->request->get('meetingSessionScheduledDuration', 30)) / 60));
  393. //                            }
  394.                         }
  395.                         //4. if after all this stages passed then calcualte gateway payable
  396.                         if ($request->request->get('isRecharge'0) == 1) {
  397.                             if (($redeemedAmount $promoClaimedAmount) >= $payableAmount) {
  398.                                 $payableAmount = ($redeemedAmount $promoClaimedAmount);
  399.                                 $gatewayAmount 0;
  400.                             } else
  401.                                 $gatewayAmount $payableAmount - ($redeemedAmount $promoClaimedAmount);
  402.                         } else {
  403. //                            if ($toConsumeSessionCount <= $currentUserCoinBalance && $invoiceSessionCount <= $toConsumeSessionCount) {
  404. //                                $payableAmount = 0;
  405. //                                $gatewayAmount = 0;
  406. //                            } else if (($redeemedAmount + $promoClaimedAmount) >= $payableAmount) {
  407. //                                $payableAmount = ($redeemedAmount + $promoClaimedAmount);
  408. //                                $gatewayAmount = 0;
  409. //                            } else
  410.                             $gatewayAmount $payableAmount <= ($currentUserBalance + ($redeemedAmount $promoClaimedAmount)) ? : ($payableAmount $currentUserBalance - ($redeemedAmount $promoClaimedAmount));
  411.                         }
  412.                         $gatewayAmount round($gatewayAmount2);
  413.                         $dueAmount round($request->request->get('dueAmount'$payableAmount), 0);
  414.                         if ($request->request->has('gatewayProductData'))
  415.                             $gatewayProductData $request->request->get('gatewayProductData');
  416.                         $gatewayProductData = [[
  417.                             'price_data' => [
  418.                                 'currency' => $currencyForGateway,
  419.                                 'unit_amount' => $gatewayAmount != ? ((100 $gatewayAmount) / 1) : 200000,
  420.                                 'product_data' => [
  421. //                            'name' => $request->request->has('packageName') ? $request->request->get('packageName') : 'Advanced Consultancy Package',
  422.                                     'name' => 'HoneyBee Hive Subscription- '.GeneralConstant::$packageDetails[$packageId]['packageName'],
  423.                                     'images' => [$imageBypackageId[$packageId]],
  424.                                 ],
  425.                             ],
  426.                             'quantity' =>  1,
  427.                         ]];
  428.                         $new_invoice null;
  429. //                        if ($extMeeting) {
  430. //                            $new_invoice = $em->getRepository('CompanyGroupBundle:EntityInvoice')
  431. //                                ->findOneBy(
  432. //                                    array(
  433. //                                        'invoiceType' => $request->request->get('invoiceType', BuddybeeConstant::ENTITY_INVOICE_TYPE_PAYMENT_TO_HONEYBEE),
  434. //                                        'meetingId' => $extMeeting->getSessionId(),
  435. //                                    )
  436. //                                );
  437. //                        }
  438.                         if ($new_invoice) {
  439.                         } else {
  440.                             $new_invoice = new EntityInvoice();
  441.                             $invoiceDate = new \DateTime();
  442.                             $new_invoice->setInvoiceDate($invoiceDate);
  443.                             $new_invoice->setInvoiceDateTs($invoiceDate->format('U'));
  444.                             $new_invoice->setStudentId($userId);
  445.                             $new_invoice->setBillerId($retailerId == $retailerId);
  446.                             $new_invoice->setRetailerId($retailerId);
  447.                             $new_invoice->setBillToId($userId);
  448.                             $new_invoice->setAmountTransferGateWayHash($paymentGateway);
  449.                             $new_invoice->setAmountCurrency($currencyForGateway);
  450.                             $cardIds $request->request->get('cardIds', []);
  451.                             $new_invoice->setMeetingId($meetingSessionId);
  452.                             $new_invoice->setGatewayBillAmount($gatewayAmount);
  453.                             $new_invoice->setRedeemedAmount($redeemedAmount);
  454.                             $new_invoice->setPromoDiscountAmount($promoClaimedAmount);
  455.                             $new_invoice->setPromoCodeId($promoCodeId);
  456.                             $new_invoice->setRedeemedSessionCount($redeemedSessionCount);
  457.                             $new_invoice->setPaidAmount($payableAmount $dueAmount);
  458.                             $new_invoice->setProductDataForPaymentGateway(json_encode($gatewayProductData));
  459.                             $new_invoice->setDueAmount($dueAmount);
  460.                             $new_invoice->setInvoiceType($request->request->get('invoiceType'BuddybeeConstant::ENTITY_INVOICE_TYPE_PAYMENT_TO_HONEYBEE));
  461.                             $new_invoice->setDocumentHash(MiscActions::GenerateRandomCrypto('BEI' microtime(true)));
  462.                             $new_invoice->setCardIds(json_encode($cardIds));
  463.                             $new_invoice->setAmountType($request->request->get('amountType'1));
  464.                             $new_invoice->setAmount($payableAmount);
  465.                             $new_invoice->setConsumeAmount($payableAmount);
  466.                             $new_invoice->setSessionCount($invoiceSessionCount);
  467.                             $new_invoice->setConsumeSessionCount($toConsumeSessionCount);
  468.                             $new_invoice->setIsPaidfull(0);
  469.                             $new_invoice->setIsProcessed(0);
  470.                             $new_invoice->setApplicantId($userId);
  471.                             $new_invoice->setBookedById($bookedById);
  472.                             $new_invoice->setBookingRefererId($bookingRefererId);
  473.                             $new_invoice->setIsRecharge($request->request->get('isRecharge'0));
  474.                             $new_invoice->setAutoConfirmTaggedMeeting($request->request->get('autoConfirmTaggedMeeting'0));
  475.                             $new_invoice->setAutoConfirmOtherMeeting($request->request->get('autoConfirmOtherMeeting'0));
  476.                             $new_invoice->setAutoClaimPurchasedCards($request->request->get('autoClaimPurchasedCards'0));
  477.                             $new_invoice->setIsPayment(0); //0 means receive
  478.                             $new_invoice->setStatus(GeneralConstant::ACTIVE); //0 means receive
  479.                             $new_invoice->setStage(BuddybeeConstant::ENTITY_INVOICE_STAGE_INITIATED); //0 means receive
  480.                             $new_invoice->setSuccessActionData(json_encode($successActionData)); //0 means receive
  481.                             if ($bookingExpireTs == 0) {
  482.                                 $bookingExpireTime = new \DateTime();
  483.                                 $bookingExpireTime->modify('+30 day');
  484.                                 $bookingExpireTs $bookingExpireTime->format('U');
  485.                             }
  486.                             $new_invoice->setExpireIfUnpaidTs($bookingExpireTs);
  487.                             $new_invoice->setBookingExpireTs($bookingExpireTs);
  488.                             $new_invoice->setConfirmationExpireTs($bookingExpireTs);
  489. //            $new_invoice->setStatus($request->request->get(0));
  490.                             $em_goc->persist($new_invoice);
  491.                             $em_goc->flush();
  492.                         }
  493.                         $invoiceId $new_invoice->getId();
  494.                         $gatewayInvoice $new_invoice;
  495.                         if ($request->request->get('isRecharge'0) == 1) {
  496.                         } else {
  497.                             if ($gatewayAmount <= 0) {
  498.                                 $meetingId 0;
  499.                                 if ($invoiceId != 0) {
  500.                                     $retData Buddybee::ProcessEntityInvoice($em_goc$invoiceId, ['stage' => BuddybeeConstant::ENTITY_INVOICE_STAGE_COMPLETED],
  501.                                         $this->container->getParameter('kernel.root_dir'),
  502.                                         false,
  503.                                         $this->container->getParameter('notification_enabled'),
  504.                                         $this->container->getParameter('notification_server')
  505.                                     );
  506.                                     $meetingId $retData['meetingId'];
  507.                                 }
  508.                                 MiscActions::RefreshBuddybeeBalanceOnSession($em$request->getSession());
  509.                                 if (GeneralConstant::EMAIL_ENABLED == 1) {
  510.                                     $billerDetails = [];
  511.                                     $billToDetails = [];
  512.                                     $invoice $gatewayInvoice;
  513.                                     if ($invoice) {
  514.                                         $billerDetails $em->getRepository('CompanyGroupBundle:EntityApplicantDetails')
  515.                                             ->findOneBy(
  516.                                                 array(
  517.                                                     'applicantId' => $invoice->getBillerId(),
  518.                                                 )
  519.                                             );
  520.                                         $billToDetails $em->getRepository('CompanyGroupBundle:EntityApplicantDetails')
  521.                                             ->findOneBy(
  522.                                                 array(
  523.                                                     'applicantId' => $invoice->getBillToId(),
  524.                                                 )
  525.                                             );
  526.                                     }
  527.                                     $bodyTemplate 'ApplicationBundle:email/templates:buddybeeInvoiceEmail.html.twig';
  528.                                     $bodyData = array(
  529.                                         'page_title' => 'Invoice',
  530. //            'studentDetails' => $student,
  531.                                         'billerDetails' => $billerDetails,
  532.                                         'billToDetails' => $billToDetails,
  533.                                         'invoice' => $invoice,
  534.                                         'currencyList' => BuddybeeConstant::$currency_List,
  535.                                         'currencyListByMarker' => BuddybeeConstant::$currency_List_by_marker,
  536.                                     );
  537.                                     $attachments = [];
  538.                                     $forwardToMailAddress $billToDetails->getOAuthEmail();
  539. //                    $upl_dir = $this->container->getParameter('kernel.root_dir') . '/../web/uploads/temp/' . 'ledger' . '.pdf'
  540.                                     $new_mail $this->get('mail_module');
  541.                                     $new_mail->sendMyMail(array(
  542.                                         'senderHash' => '_CUSTOM_',
  543.                                         //                        'senderHash'=>'_CUSTOM_',
  544.                                         'forwardToMailAddress' => $forwardToMailAddress,
  545.                                         'subject' => 'YourInvoice #' 'D' str_pad('BB'5'0'STR_PAD_LEFT) . str_pad('76'2'0'STR_PAD_LEFT) . str_pad($invoice->getId(), 8"0"STR_PAD_LEFT) . ' from BuddyBee ',
  546. //                        'fileName' => 'Order#' . str_pad($id, 8, '0', STR_PAD_LEFT) . '.pdf',
  547.                                         'attachments' => $attachments,
  548.                                         'toAddress' => $forwardToMailAddress,
  549.                                         'fromAddress' => 'no-reply@buddybee.eu',
  550.                                         'userName' => 'no-reply@buddybee.eu',
  551.                                         'password' => 'Honeybee@0112',
  552.                                         'smtpServer' => 'smtp.hostinger.com',
  553.                                         'smtpPort' => 465,
  554. //                            'emailBody' => $bodyHtml,
  555.                                         'mailTemplate' => $bodyTemplate,
  556.                                         'templateData' => $bodyData,
  557.                                         'embedCompanyImage' => 0,
  558.                                         'companyId' => 0,
  559.                                         'companyImagePath' => ''
  560. //                        'embedCompanyImage' => 1,
  561. //                        'companyId' => $companyId,
  562. //                        'companyImagePath' => $company_data->getImage()
  563.                                     ));
  564.                                 }
  565.                                 if ($meetingId != 0) {
  566.                                     $url $this->generateUrl(
  567.                                         'consultancy_session'
  568.                                     );
  569.                                     $output = [
  570.                                         'invoiceId' => $gatewayInvoice->getId(),
  571.                                         'meetingId' => $meetingId,
  572.                                         'proceedToCheckout' => 0,
  573.                                         'redirectUrl' => $url '/' $meetingId
  574.                                     ];
  575.                                 } else {
  576.                                     $url $this->generateUrl(
  577.                                         $systemType == '_BUDDYBEE_' 'buddybee_dashboard' 'central_landing'
  578.                                     );
  579.                                     $output = [
  580.                                         'invoiceId' => $gatewayInvoice->getId(),
  581.                                         'meetingId' => 0,
  582.                                         'proceedToCheckout' => 0,
  583.                                         'redirectUrl' => $url
  584.                                     ];
  585.                                 }
  586.                                 return new JsonResponse($output);
  587. //                return $this->redirect($url);
  588.                             } else {
  589.                             }
  590. //                $url = $this->generateUrl(
  591. //                    'checkout_page'
  592. //                );
  593. //
  594. //                return $this->redirect($url."?meetingSessionId=".$new->getSessionId().'&invoiceId='.$invoiceId);
  595.                         }
  596.                     }
  597.                 } else {
  598.                     $url $this->generateUrl(
  599.                         'user_login'
  600.                     );
  601.                     $session->set('LAST_REQUEST_URI_BEFORE_LOGIN'$this->generateUrl(
  602.                         'pricing_plan_page', [
  603.                         'autoRedirected' => 1
  604.                     ],
  605.                         UrlGenerator::ABSOLUTE_URL
  606.                     ));
  607.                     $output = [
  608.                         'proceedToCheckout' => 0,
  609.                         'redirectUrl' => $url,
  610.                         'clearLs' => 0
  611.                     ];
  612.                     return new JsonResponse($output);
  613.                 }
  614.                 //now proceed to checkout page if the user has lower balance or recharging
  615.                 //$invoiceDetails = $em->getRepository('CompanyGroupBundle:EntityInvoice')->
  616.             }
  617.         }
  618.         if ($gatewayInvoice) {
  619.             $gatewayProductData json_decode($gatewayInvoice->getProductDataForPaymentGateway(), true);
  620.             if ($gatewayProductData == null$gatewayProductData = [];
  621.             if (empty($gatewayProductData))
  622.                 $gatewayProductData = [
  623.                     [
  624.                         'price_data' => [
  625.                             'currency' => 'eur',
  626.                             'unit_amount' => $gatewayAmount != ? (100 $gatewayAmount) : 200000,
  627.                             'product_data' => [
  628. //                            'name' => $request->request->has('packageName') ? $request->request->get('packageName') : 'Advanced Consultancy Package',
  629.                                 'name' => 'Bee Coins',
  630.                                 'images' => [$imageBySessionCount[0]],
  631.                             ],
  632.                         ],
  633.                         'quantity' => 1,
  634.                     ]
  635.                 ];
  636.             $productDescStr '';
  637.             $productDescArr = [];
  638.             foreach ($gatewayProductData as $gpd) {
  639.                 $productDescArr[] = $gpd['price_data']['product_data']['name'];
  640.             }
  641.             $productDescStr implode(','$productDescArr);
  642.             $paymentGatewayFromInvoice $gatewayInvoice->getAmountTransferGateWayHash();
  643. //            return new JsonResponse(
  644. //                [
  645. //                    'paymentGateway' => $paymentGatewayFromInvoice,
  646. //                    'gateWayData' => $gatewayProductData[0]
  647. //                ]
  648. //            );
  649.             if ($paymentGateway == null$paymentGatewayFromInvoice 'stripe';
  650.             if ($paymentGatewayFromInvoice == 'stripe' || $paymentGatewayFromInvoice == 'aamarpay' || $paymentGatewayFromInvoice == 'bkash') {
  651.                 if (GeneralConstant::EMAIL_ENABLED == 1) {
  652.                     $billerDetails = [];
  653.                     $billToDetails = [];
  654.                     $invoice $gatewayInvoice;
  655.                     if ($invoice) {
  656.                         $billerDetails $em->getRepository('CompanyGroupBundle:EntityApplicantDetails')
  657.                             ->findOneBy(
  658.                                 array(
  659.                                     'applicantId' => $invoice->getBillerId(),
  660.                                 )
  661.                             );
  662.                         $billToDetails $em->getRepository('CompanyGroupBundle:EntityApplicantDetails')
  663.                             ->findOneBy(
  664.                                 array(
  665.                                     'applicantId' => $invoice->getBillToId(),
  666.                                 )
  667.                             );
  668.                     }
  669.                     $bodyTemplate 'ApplicationBundle:email/templates:buddybeeInvoiceEmail.html.twig';
  670.                     $bodyData = array(
  671.                         'page_title' => 'Invoice',
  672. //            'studentDetails' => $student,
  673.                         'billerDetails' => $billerDetails,
  674.                         'billToDetails' => $billToDetails,
  675.                         'invoice' => $invoice,
  676.                         'currencyList' => BuddybeeConstant::$currency_List,
  677.                         'currencyListByMarker' => BuddybeeConstant::$currency_List_by_marker,
  678.                     );
  679.                     $attachments = [];
  680.                     $forwardToMailAddress $billToDetails->getOAuthEmail();
  681. //                    $upl_dir = $this->container->getParameter('kernel.root_dir') . '/../web/uploads/temp/' . 'ledger' . '.pdf'
  682.                     $new_mail $this->get('mail_module');
  683.                     $new_mail->sendMyMail(array(
  684.                         'senderHash' => '_CUSTOM_',
  685.                         //                        'senderHash'=>'_CUSTOM_',
  686.                         'forwardToMailAddress' => $forwardToMailAddress,
  687.                         'subject' => 'YourInvoice #' 'D' str_pad('BB'5'0'STR_PAD_LEFT) . str_pad('76'2'0'STR_PAD_LEFT) . str_pad($invoice->getId(), 8"0"STR_PAD_LEFT) . ' from BuddyBee ',
  688. //                        'fileName' => 'Order#' . str_pad($id, 8, '0', STR_PAD_LEFT) . '.pdf',
  689.                         'attachments' => $attachments,
  690.                         'toAddress' => $forwardToMailAddress,
  691.                         'fromAddress' => 'no-reply@buddybee.eu',
  692.                         'userName' => 'no-reply@buddybee.eu',
  693.                         'password' => 'Honeybee@0112',
  694.                         'smtpServer' => 'smtp.hostinger.com',
  695.                         'smtpPort' => 465,
  696. //                            'emailBody' => $bodyHtml,
  697.                         'mailTemplate' => $bodyTemplate,
  698.                         'templateData' => $bodyData,
  699.                         'embedCompanyImage' => 0,
  700.                         'companyId' => 0,
  701.                         'companyImagePath' => ''
  702. //                        'embedCompanyImage' => 1,
  703. //                        'companyId' => $companyId,
  704. //                        'companyImagePath' => $company_data->getImage()
  705.                     ));
  706.                 }
  707.             }
  708.             if ($paymentGatewayFromInvoice == 'stripe') {
  709.                 $stripe = new \Stripe\Stripe();
  710.                 \Stripe\Stripe::setApiKey('sk_test_51IxYTAJXs21fVb0QMop2Nb0E7u9Da4LwGrym1nGHUHqaSNtT3p9HBgHd7YyDsTKHscgPPECPQniTy79Ab8Sgxfbm00JF2AndUz');
  711.                 $stripe::setApiKey('sk_test_51IxYTAJXs21fVb0QMop2Nb0E7u9Da4LwGrym1nGHUHqaSNtT3p9HBgHd7YyDsTKHscgPPECPQniTy79Ab8Sgxfbm00JF2AndUz');
  712.                 {
  713.                     if ($request->query->has('meetingSessionId'))
  714.                         $id $request->query->get('meetingSessionId');
  715.                 }
  716.                 $paymentIntent = [
  717.                     "id" => "pi_1DoWjK2eZvKYlo2Csy9J3BHs",
  718.                     "object" => "payment_intent",
  719.                     "amount" => 3000,
  720.                     "amount_capturable" => 0,
  721.                     "amount_received" => 0,
  722.                     "application" => null,
  723.                     "application_fee_amount" => null,
  724.                     "canceled_at" => null,
  725.                     "cancellation_reason" => null,
  726.                     "capture_method" => "automatic",
  727.                     "charges" => [
  728.                         "object" => "list",
  729.                         "data" => [],
  730.                         "has_more" => false,
  731.                         "url" => "/v1/charges?payment_intent=pi_1DoWjK2eZvKYlo2Csy9J3BHs"
  732.                     ],
  733.                     "client_secret" => "pi_1DoWjK2eZvKYlo2Csy9J3BHs_secret_vmxAcWZxo2kt1XhpWtZtnjDtd",
  734.                     "confirmation_method" => "automatic",
  735.                     "created" => 1546523966,
  736.                     "currency" => $currencyForGateway,
  737.                     "customer" => null,
  738.                     "description" => null,
  739.                     "invoice" => null,
  740.                     "last_payment_error" => null,
  741.                     "livemode" => false,
  742.                     "metadata" => [],
  743.                     "next_action" => null,
  744.                     "on_behalf_of" => null,
  745.                     "payment_method" => null,
  746.                     "payment_method_options" => [],
  747.                     "payment_method_types" => [
  748.                         "card"
  749.                     ],
  750.                     "receipt_email" => null,
  751.                     "review" => null,
  752.                     "setup_future_usage" => null,
  753.                     "shipping" => null,
  754.                     "statement_descriptor" => null,
  755.                     "statement_descriptor_suffix" => null,
  756.                     "status" => "requires_payment_method",
  757.                     "transfer_data" => null,
  758.                     "transfer_group" => null
  759.                 ];
  760.                 $checkout_session = \Stripe\Checkout\Session::create([
  761.                     'payment_method_types' => ['card'],
  762.                     'line_items' => $gatewayProductData,
  763.                     'mode' => 'payment',
  764.                     'success_url' => $this->generateUrl(
  765.                         'payment_gateway_success',
  766.                         ['encData' => $this->get('url_encryptor')->encrypt(json_encode(array(
  767.                             'invoiceId' => $invoiceId'autoRedirect' => $request->request->get('autoRedirect'1)
  768.                         ))), 'hbeeSessionToken' => $session->get('token'0)], UrlGenerator::ABSOLUTE_URL
  769.                     ),
  770.                     'cancel_url' => $this->generateUrl(
  771.                         'payment_gateway_cancel', ['invoiceId' => $invoiceId'autoRedirect' => $request->request->get('autoRedirect'1), 'hbeeSessionToken' => $session->get('token'0)], UrlGenerator::ABSOLUTE_URL
  772.                     ),
  773.                 ]);
  774.                 $output = [
  775.                     'clientSecret' => $paymentIntent['client_secret'],
  776.                     'id' => $checkout_session->id,
  777.                     'paymentGateway' => $paymentGatewayFromInvoice,
  778.                     'proceedToCheckout' => 1
  779.                 ];
  780.                 return new JsonResponse($output);
  781.             }
  782.             if ($paymentGatewayFromInvoice == 'aamarpay') {
  783.                 $studentDetails $em_goc->getRepository(EntityApplicantDetails::class)->find($gatewayInvoice->getBillToId());
  784.                 $url $sandBoxMode == 'https://sandbox.aamarpay.com/request.php' 'https://secure.aamarpay.com/request.php';
  785.                 $fields = array(
  786. //                    'store_id' => 'aamarpaytest', //store id will be aamarpay,  contact integration@aamarpay.com for test/live id
  787.                     'store_id' => $sandBoxMode == 'aamarpaytest' 'buddybee'//store id will be aamarpay,  contact integration@aamarpay.com for test/live id
  788.                     'amount' => $gatewayInvoice->getGateWayBillamount(), //transaction amount
  789.                     'payment_type' => 'VISA'//no need to change
  790.                     'currency' => strtoupper($currencyForGateway),  //currenct will be USD/BDT
  791.                     'tran_id' => $gatewayInvoice->getDocumentHash(), //transaction id must be unique from your end
  792.                     'cus_name' => $studentDetails->getFirstname() . ' ' $studentDetails->getLastName(),  //customer name
  793.                     'cus_email' => $studentDetails->getEmail(), //customer email address
  794.                     'cus_add1' => $studentDetails->getCurrAddr(),  //customer address
  795.                     'cus_add2' => $studentDetails->getCurrAddrCity(), //customer address
  796.                     'cus_city' => $studentDetails->getCurrAddrCity(),  //customer city
  797.                     'cus_state' => $studentDetails->getCurrAddrState(),  //state
  798.                     'cus_postcode' => $studentDetails->getCurrAddrZip(), //postcode or zipcode
  799.                     'cus_country' => 'Bangladesh',  //country
  800.                     'cus_phone' => ($studentDetails->getPhone() == null || $studentDetails->getPhone() == '') ? '+8801911706483' $studentDetails->getPhone(), //customer phone number
  801.                     'cus_fax' => '',  //fax
  802.                     'ship_name' => ''//ship name
  803.                     'ship_add1' => '',  //ship address
  804.                     'ship_add2' => '',
  805.                     'ship_city' => '',
  806.                     'ship_state' => '',
  807.                     'ship_postcode' => '',
  808.                     'ship_country' => 'Bangladesh',
  809.                     'desc' => $productDescStr,
  810.                     'success_url' => $this->generateUrl(
  811.                         'payment_gateway_success',
  812.                         ['encData' => $this->get('url_encryptor')->encrypt(json_encode(array(
  813.                             'invoiceId' => $invoiceId'autoRedirect' => $request->request->get('autoRedirect'1)
  814.                         ))), 'hbeeSessionToken' => $session->get('token'0)], UrlGenerator::ABSOLUTE_URL
  815.                     ),
  816.                     'fail_url' => $this->generateUrl(
  817.                         'payment_gateway_cancel', ['invoiceId' => $invoiceId'autoRedirect' => $request->request->get('autoRedirect'1), 'hbeeSessionToken' => $session->get('token'0)], UrlGenerator::ABSOLUTE_URL
  818.                     ),
  819.                     'cancel_url' => $this->generateUrl(
  820.                         'payment_gateway_cancel', ['invoiceId' => $invoiceId'autoRedirect' => $request->request->get('autoRedirect'1), 'hbeeSessionToken' => $session->get('token'0)], UrlGenerator::ABSOLUTE_URL
  821.                     ),
  822. //                    'opt_a' => 'Reshad',  //optional paramter
  823. //                    'opt_b' => 'Akil',
  824. //                    'opt_c' => 'Liza',
  825. //                    'opt_d' => 'Sohel',
  826. //                    'signature_key' => 'dbb74894e82415a2f7ff0ec3a97e4183',  //sandbox
  827.                     'signature_key' => $sandBoxMode == 'dbb74894e82415a2f7ff0ec3a97e4183' 'b7304a40e21fe15af3be9a948307f524'  //live
  828.                 ); //signature key will provided aamarpay, contact integration@aamarpay.com for test/live signature key
  829.                 $fields_string http_build_query($fields);
  830. //                $ch = curl_init();
  831. //                curl_setopt($ch, CURLOPT_VERBOSE, true);
  832. //                curl_setopt($ch, CURLOPT_URL, $url);
  833. //
  834. //                curl_setopt($ch, CURLOPT_POSTFIELDS, $fields_string);
  835. //                curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  836. //                curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
  837. //                $url_forward = str_replace('"', '', stripslashes(curl_exec($ch)));
  838. //                curl_close($ch);
  839. //                $this->redirect_to_merchant($url_forward);
  840.                 $output = [
  841. //
  842. //                    'redirectUrl' => ($sandBoxMode == 1 ? 'https://sandbox.aamarpay.com/' : 'https://secure.aamarpay.com/') . $url_forward, //keeping it off temporarily
  843. //                    'fields'=>$fields,
  844. //                    'fields_string'=>$fields_string,
  845. //                    'redirectUrl' => $this->generateUrl(
  846. //                        'payment_gateway_success',
  847. //                        ['encData' => $this->get('url_encryptor')->encrypt(json_encode(array(
  848. //                            'invoiceId' => $invoiceId, 'autoRedirect' => $request->request->get('autoRedirect', 1)
  849. //                        ))), 'hbeeSessionToken' => $request->request->get('token', 0)], UrlGenerator::ABSOLUTE_URL
  850. //                    ),
  851.                     'paymentGateway' => $paymentGatewayFromInvoice,
  852.                     'proceedToCheckout' => 1,
  853.                     'data' => $fields
  854.                 ];
  855.                 return new JsonResponse($output);
  856.             } else if ($paymentGatewayFromInvoice == 'bkash') {
  857.                 $studentDetails $em_goc->getRepository(EntityApplicantDetails::class)->find($gatewayInvoice->getBillToId());
  858.                 $baseUrl = ($sandBoxMode == 1) ? 'https://tokenized.sandbox.bka.sh/v1.2.0-beta' 'https://tokenized.pay.bka.sh/v1.2.0-beta';
  859.                 $username_value = ($sandBoxMode == 1) ? 'sandboxTokenizedUser02' '01891962953';
  860.                 $password_value = ($sandBoxMode == 1) ? 'sandboxTokenizedUser02@12345' ',a&kPV4deq&';
  861.                 $app_key_value = ($sandBoxMode == 1) ? '4f6o0cjiki2rfm34kfdadl1eqq' '2ueVHdwz5gH3nxx7xn8wotlztc';
  862.                 $app_secret_value = ($sandBoxMode == 1) ? '2is7hdktrekvrbljjh44ll3d9l1dtjo4pasmjvs5vl5qr3fug4b' '49Ay3h3wWJMBFD7WF5CassyLrtA1jt6ONhspqjqFx5hTjhqh5dHU';
  863.                 $request_data = array(
  864.                     'app_key' => $app_key_value,
  865.                     'app_secret' => $app_secret_value
  866.                 );
  867.                 $url curl_init($baseUrl '/tokenized/checkout/token/grant');
  868.                 $request_data_json json_encode($request_data);
  869.                 $header = array(
  870.                     'Content-Type:application/json',
  871.                     'username:' $username_value,
  872.                     'password:' $password_value
  873.                 );
  874.                 curl_setopt($urlCURLOPT_HTTPHEADER$header);
  875.                 curl_setopt($urlCURLOPT_CUSTOMREQUEST"POST");
  876.                 curl_setopt($urlCURLOPT_RETURNTRANSFERtrue);
  877.                 curl_setopt($urlCURLOPT_POSTFIELDS$request_data_json);
  878.                 curl_setopt($urlCURLOPT_FOLLOWLOCATION1);
  879.                 curl_setopt($urlCURLOPT_IPRESOLVECURL_IPRESOLVE_V4);
  880.                 $tokenData json_decode(curl_exec($url), true);
  881.                 curl_close($url);
  882.                 $id_token $tokenData['id_token'];
  883.                 $goToBkashPage 0;
  884.                 if ($tokenData['statusCode'] == '0000') {
  885.                     $auth $id_token;
  886.                     $requestbody = array(
  887.                         "mode" => "0011",
  888. //                        "payerReference" => "01723888888",
  889.                         "payerReference" => $invoiceDate->format('U'),
  890.                         "callbackURL" => $this->generateUrl(
  891.                             'bkash_callback', [], UrlGenerator::ABSOLUTE_URL
  892.                         ),
  893. //                    "merchantAssociationInfo" => "MI05MID54RF09123456One",
  894.                         "amount" => number_format($gatewayInvoice->getGateWayBillamount(), 2'.'''),
  895.                         "currency" => "BDT",
  896.                         "intent" => "sale",
  897.                         "merchantInvoiceNumber" => $invoiceId
  898.                     );
  899.                     $url curl_init($baseUrl '/tokenized/checkout/create');
  900.                     $requestbodyJson json_encode($requestbody);
  901.                     $header = array(
  902.                         'Content-Type:application/json',
  903.                         'Authorization:' $auth,
  904.                         'X-APP-Key:' $app_key_value
  905.                     );
  906.                     curl_setopt($urlCURLOPT_HTTPHEADER$header);
  907.                     curl_setopt($urlCURLOPT_CUSTOMREQUEST"POST");
  908.                     curl_setopt($urlCURLOPT_RETURNTRANSFERtrue);
  909.                     curl_setopt($urlCURLOPT_POSTFIELDS$requestbodyJson);
  910.                     curl_setopt($urlCURLOPT_FOLLOWLOCATION1);
  911.                     curl_setopt($urlCURLOPT_IPRESOLVECURL_IPRESOLVE_V4);
  912.                     $resultdata curl_exec($url);
  913. //                    curl_close($url);
  914. //                    echo $resultdata;
  915.                     $obj json_decode($resultdatatrue);
  916.                     $goToBkashPage 1;
  917.                     $justNow = new \DateTime();
  918.                     $justNow->modify('+' $tokenData['expires_in'] . ' second');
  919.                     $gatewayInvoice->setGatewayIdTokenExpireTs($justNow->format('U'));
  920.                     $gatewayInvoice->setGatewayIdToken($tokenData['id_token']);
  921.                     $gatewayInvoice->setGatewayPaymentId($obj['paymentID']);
  922.                     $gatewayInvoice->setGatewayIdRefreshToken($tokenData['refresh_token']);
  923.                     $em->flush();
  924.                     $output = [
  925. //                        'redirectUrl' => $obj['bkashURL'],
  926.                         'paymentGateway' => $paymentGatewayFromInvoice,
  927.                         'proceedToCheckout' => $goToBkashPage,
  928.                         'tokenData' => $tokenData,
  929.                         'obj' => $obj,
  930.                         'id_token' => $tokenData['id_token'],
  931.                         'data' => [
  932.                             'amount' => $gatewayInvoice->getGateWayBillamount(), //transaction amount
  933. //                            'payment_type' => 'VISA', //no need to change
  934.                             'currency' => strtoupper($currencyForGateway),  //currenct will be USD/BDT
  935.                             'tran_id' => $gatewayInvoice->getDocumentHash(), //transaction id must be unique from your end
  936.                             'cus_name' => $studentDetails->getFirstname() . ' ' $studentDetails->getLastName(),  //customer name
  937.                             'cus_email' => $studentDetails->getEmail(), //customer email address
  938.                             'cus_add1' => $studentDetails->getCurrAddr(),  //customer address
  939.                             'cus_add2' => $studentDetails->getCurrAddrCity(), //customer address
  940.                             'cus_city' => $studentDetails->getCurrAddrCity(),  //customer city
  941.                             'cus_state' => $studentDetails->getCurrAddrState(),  //state
  942.                             'cus_postcode' => $studentDetails->getCurrAddrZip(), //postcode or zipcode
  943.                             'cus_country' => 'Bangladesh',  //country
  944.                             'cus_phone' => ($studentDetails->getPhone() == null || $studentDetails->getPhone() == '') ? '+8801911706483' $studentDetails->getPhone(), //customer phone number
  945.                             'cus_fax' => '',  //fax
  946.                             'ship_name' => ''//ship name
  947.                             'ship_add1' => '',  //ship address
  948.                             'ship_add2' => '',
  949.                             'ship_city' => '',
  950.                             'ship_state' => '',
  951.                             'ship_postcode' => '',
  952.                             'ship_country' => 'Bangladesh',
  953.                             'desc' => $productDescStr,
  954.                         ]
  955.                     ];
  956.                     return new JsonResponse($output);
  957.                 }
  958. //                $fields = array(
  959. //
  960. //                    "mode" => "0011",
  961. //                    "payerReference" => "01723888888",
  962. //                    "callbackURL" => $this->generateUrl(
  963. //                        'payment_gateway_success',
  964. //                        ['encData' => $this->get('url_encryptor')->encrypt(json_encode(array(
  965. //                            'invoiceId' => $invoiceId, 'autoRedirect' => $request->request->get('autoRedirect', 1)
  966. //                        ))), 'hbeeSessionToken' => $session->get('token', 0)], UrlGenerator::ABSOLUTE_URL
  967. //                    ),
  968. //                    "merchantAssociationInfo" => "MI05MID54RF09123456One",
  969. //                    "amount" => 1*number_format($gatewayInvoice->getGateWayBillamount(),2,'.',''),,
  970. //                    "currency" => "BDT",
  971. //                    "intent" => "sale",
  972. //                    "merchantInvoiceNumber" => 'BEI' . str_pad($gatewayInvoice->getBillerId(), 3, '0', STR_PAD_LEFT) . str_pad($gatewayInvoice->getBillToId(), 5, '0', STR_PAD_LEFT) . str_pad($gatewayInvoice->getId(), 4, '0', STR_PAD_LEFT)
  973. //
  974. //                );
  975. //                $fields = array(
  976. ////                    'store_id' => 'aamarpaytest', //store id will be aamarpay,  contact integration@aamarpay.com for test/live id
  977. //                    'store_id' => $sandBoxMode == 1 ? 'aamarpaytest' : 'buddybee', //store id will be aamarpay,  contact integration@aamarpay.com for test/live id
  978. //                    'amount' => 1*number_format($gatewayInvoice->getGateWayBillamount(),2,'.',''),, //transaction amount
  979. //                    'payment_type' => 'VISA', //no need to change
  980. //                    'currency' => strtoupper($currencyForGateway),  //currenct will be USD/BDT
  981. //                    'tran_id' => 'BEI' . str_pad($gatewayInvoice->getBillerId(), 3, '0', STR_PAD_LEFT) . str_pad($gatewayInvoice->getBillToId(), 5, '0', STR_PAD_LEFT) . str_pad($gatewayInvoice->getId(), 4, '0', STR_PAD_LEFT), //transaction id must be unique from your end
  982. //                    'cus_name' => $studentDetails->getFirstname() . ' ' . $studentDetails->getLastName(),  //customer name
  983. //                    'cus_email' => $studentDetails->getEmail(), //customer email address
  984. //                    'cus_add1' => $studentDetails->getCurrAddr(),  //customer address
  985. //                    'cus_add2' => $studentDetails->getCurrAddrCity(), //customer address
  986. //                    'cus_city' => $studentDetails->getCurrAddrCity(),  //customer city
  987. //                    'cus_state' => $studentDetails->getCurrAddrState(),  //state
  988. //                    'cus_postcode' => $studentDetails->getCurrAddrZip(), //postcode or zipcode
  989. //                    'cus_country' => 'Bangladesh',  //country
  990. //                    'cus_phone' => ($studentDetails->getPhone() == null || $studentDetails->getPhone() == '') ? ' + 8801911706483' : $studentDetails->getPhone(), //customer phone number
  991. //                    'cus_fax' => '',  //fax
  992. //                    'ship_name' => '', //ship name
  993. //                    'ship_add1' => '',  //ship address
  994. //                    'ship_add2' => '',
  995. //                    'ship_city' => '',
  996. //                    'ship_state' => '',
  997. //                    'ship_postcode' => '',
  998. //                    'ship_country' => 'Bangladesh',
  999. //                    'desc' => $productDescStr,
  1000. //                    'success_url' => $this->generateUrl(
  1001. //                        'payment_gateway_success',
  1002. //                        ['encData' => $this->get('url_encryptor')->encrypt(json_encode(array(
  1003. //                            'invoiceId' => $invoiceId, 'autoRedirect' => $request->request->get('autoRedirect', 1)
  1004. //                        ))), 'hbeeSessionToken' => $session->get('token', 0)], UrlGenerator::ABSOLUTE_URL
  1005. //                    ),
  1006. //                    'fail_url' => $this->generateUrl(
  1007. //                        'payment_gateway_cancel', ['invoiceId' => $invoiceId, 'autoRedirect' => $request->request->get('autoRedirect', 1), 'hbeeSessionToken' => $session->get('token', 0)], UrlGenerator::ABSOLUTE_URL
  1008. //                    ),
  1009. //                    'cancel_url' => $this->generateUrl(
  1010. //                        'payment_gateway_cancel', ['invoiceId' => $invoiceId, 'autoRedirect' => $request->request->get('autoRedirect', 1), 'hbeeSessionToken' => $session->get('token', 0)], UrlGenerator::ABSOLUTE_URL
  1011. //                    ),
  1012. ////                    'opt_a' => 'Reshad',  //optional paramter
  1013. ////                    'opt_b' => 'Akil',
  1014. ////                    'opt_c' => 'Liza',
  1015. ////                    'opt_d' => 'Sohel',
  1016. ////                    'signature_key' => 'dbb74894e82415a2f7ff0ec3a97e4183',  //sandbox
  1017. //                    'signature_key' => $sandBoxMode == 1 ? 'dbb74894e82415a2f7ff0ec3a97e4183' : 'b7304a40e21fe15af3be9a948307f524'  //live
  1018. //
  1019. //                ); //signature key will provided aamarpay, contact integration@aamarpay.com for test/live signature key
  1020. //
  1021. //                $fields_string = http_build_query($fields);
  1022. //
  1023. //                $ch = curl_init();
  1024. //                curl_setopt($ch, CURLOPT_VERBOSE, true);
  1025. //                curl_setopt($ch, CURLOPT_URL, $url);
  1026. //
  1027. //                curl_setopt($ch, CURLOPT_POSTFIELDS, $fields_string);
  1028. //                curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  1029. //                curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
  1030. //                $url_forward = str_replace('"', '', stripslashes(curl_exec($ch)));
  1031. //                curl_close($ch);
  1032. //                $this->redirect_to_merchant($url_forward);
  1033.             } else if ($paymentGatewayFromInvoice == 'onsite_pos' || $paymentGatewayFromInvoice == 'onsite_cash' || $paymentGatewayFromInvoice == 'onsite_bkash') {
  1034.                 $meetingId 0;
  1035.                 if ($gatewayInvoice->getId() != 0) {
  1036.                     if ($gatewayInvoice->getDueAmount() <= 0) {
  1037.                         $retData Buddybee::ProcessEntityInvoice($em_goc$gatewayInvoice->getId(), ['stage' => BuddybeeConstant::ENTITY_INVOICE_STAGE_COMPLETED], $this->container->getParameter('kernel.root_dir'), false,
  1038.                             $this->container->getParameter('notification_enabled'),
  1039.                             $this->container->getParameter('notification_server')
  1040.                         );
  1041.                         $meetingId $retData['meetingId'];
  1042.                     }
  1043.                     if (GeneralConstant::EMAIL_ENABLED == 1) {
  1044.                         $billerDetails = [];
  1045.                         $billToDetails = [];
  1046.                         $invoice $gatewayInvoice;
  1047.                         if ($invoice) {
  1048.                             $billerDetails $em->getRepository('CompanyGroupBundle:EntityApplicantDetails')
  1049.                                 ->findOneBy(
  1050.                                     array(
  1051.                                         'applicantId' => $invoice->getBillerId(),
  1052.                                     )
  1053.                                 );
  1054.                             $billToDetails $em->getRepository('CompanyGroupBundle:EntityApplicantDetails')
  1055.                                 ->findOneBy(
  1056.                                     array(
  1057.                                         'applicantId' => $invoice->getBillToId(),
  1058.                                     )
  1059.                                 );
  1060.                         }
  1061.                         $bodyTemplate 'ApplicationBundle:email/templates:buddybeeInvoiceEmail.html.twig';
  1062.                         $bodyData = array(
  1063.                             'page_title' => 'Invoice',
  1064. //            'studentDetails' => $student,
  1065.                             'billerDetails' => $billerDetails,
  1066.                             'billToDetails' => $billToDetails,
  1067.                             'invoice' => $invoice,
  1068.                             'currencyList' => BuddybeeConstant::$currency_List,
  1069.                             'currencyListByMarker' => BuddybeeConstant::$currency_List_by_marker,
  1070.                         );
  1071.                         $attachments = [];
  1072.                         $forwardToMailAddress $billToDetails->getOAuthEmail();
  1073. //                    $upl_dir = $this->container->getParameter('kernel.root_dir') . '/../web/uploads/temp/' . 'ledger' . '.pdf'
  1074.                         $new_mail $this->get('mail_module');
  1075.                         $new_mail->sendMyMail(array(
  1076.                             'senderHash' => '_CUSTOM_',
  1077.                             //                        'senderHash'=>'_CUSTOM_',
  1078.                             'forwardToMailAddress' => $forwardToMailAddress,
  1079.                             'subject' => 'YourInvoice #' 'D' str_pad('BB'5'0'STR_PAD_LEFT) . str_pad('76'2'0'STR_PAD_LEFT) . str_pad($invoice->getId(), 8"0"STR_PAD_LEFT) . ' from BuddyBee ',
  1080. //                        'fileName' => 'Order#' . str_pad($id, 8, '0', STR_PAD_LEFT) . '.pdf',
  1081.                             'attachments' => $attachments,
  1082.                             'toAddress' => $forwardToMailAddress,
  1083.                             'fromAddress' => 'no-reply@buddybee.eu',
  1084.                             'userName' => 'no-reply@buddybee.eu',
  1085.                             'password' => 'Honeybee@0112',
  1086.                             'smtpServer' => 'smtp.hostinger.com',
  1087.                             'smtpPort' => 465,
  1088. //                            'emailBody' => $bodyHtml,
  1089.                             'mailTemplate' => $bodyTemplate,
  1090.                             'templateData' => $bodyData,
  1091.                             'embedCompanyImage' => 0,
  1092.                             'companyId' => 0,
  1093.                             'companyImagePath' => ''
  1094. //                        'embedCompanyImage' => 1,
  1095. //                        'companyId' => $companyId,
  1096. //                        'companyImagePath' => $company_data->getImage()
  1097.                         ));
  1098.                     }
  1099.                 }
  1100.                 MiscActions::RefreshBuddybeeBalanceOnSession($em$request->getSession());
  1101.                 if ($meetingId != 0) {
  1102.                     $url $this->generateUrl(
  1103.                         'consultancy_session'
  1104.                     );
  1105.                     $output = [
  1106.                         'proceedToCheckout' => 0,
  1107.                         'invoiceId' => $gatewayInvoice->getId(),
  1108.                         'meetingId' => $meetingId,
  1109.                         'redirectUrl' => $url '/' $meetingId
  1110.                     ];
  1111.                 } else {
  1112.                     $url $this->generateUrl(
  1113.                         'buddybee_dashboard'
  1114.                     );
  1115.                     $output = [
  1116.                         'proceedToCheckout' => 0,
  1117.                         'invoiceId' => $gatewayInvoice->getId(),
  1118.                         'meetingId' => $meetingId,
  1119.                         'redirectUrl' => $url
  1120.                     ];
  1121.                 }
  1122.                 return new JsonResponse($output);
  1123.             }
  1124.         }
  1125.         $output = [
  1126.             'clientSecret' => 0,
  1127.             'id' => 0,
  1128.             'proceedToCheckout' => 0
  1129.         ];
  1130.         return new JsonResponse($output);
  1131. //        return $this->render('ApplicationBundle:pages/stripe:checkout.html.twig', array(
  1132. //            'page_title' => 'Checkout',
  1133. ////            'stripe' => $stripe,
  1134. //            'stripe' => null,
  1135. ////            'PaymentIntent' => $paymentIntent,
  1136. //
  1137. ////            'consultantDetail' => $consultantDetail,
  1138. ////            'consultantDetails'=> $consultantDetails,
  1139. ////
  1140. ////            'meetingSession' => $meetingSession,
  1141. ////            'packageDetails' => json_decode($meetingSession->getPcakageDetails(),true),
  1142. ////            'packageName' => json_decode($meetingSession->getPackageName(),true),
  1143. ////            'pay' => $payableAmount,
  1144. ////            'balance' => $currStudentBal
  1145. //        ));
  1146.     }
  1147.     //changes dev
  1148.     public function AddEmployeeAction(Request $data$id 0)
  1149.     {
  1150.         $em $this->getDoctrine()->getManager();
  1151.         $connection $em->getConnection();
  1152.         $connection->beginTransaction();
  1153.         $skills $em->getRepository(Skill::class)->findAll();
  1154.         $session $data->getSession();
  1155.         $ownOnly 0;
  1156.         $consultancyLevel HumanResourceConstant::$consultantLevel;
  1157.         $systemType $this->container->hasParameter('system_type') ? $this->container->getParameter('system_type') : '_ERP_';
  1158.         $banks $em->getRepository(BankList::class)->findAll();
  1159.         $bankListObj = [];
  1160.         $id $data->request->get('employeeId'$id);
  1161.         foreach ($banks as $bank) {
  1162.             $bankListObj[$bank->getBankId()] = $bank->getName();
  1163.         }
  1164.         if ($id === "my") {
  1165.             $id $session->get(UserConstants::USER_EMPLOYEE_ID);
  1166.             $ownOnly 1;
  1167.             if ($id == || $id == null) {
  1168.                 return $this->redirectToRoute('permission_denied_page');
  1169.             }
  1170.         }
  1171.         if ($id) {
  1172.             if ($data->isMethod('GET')) {
  1173.                 $Employee $this->getDoctrine()->getRepository(EmployeeDetails::class)->find($id);
  1174.                 if (!$Employee) {
  1175.                     $this->addFlash(
  1176.                         'error',
  1177.                         'Invalid User ID!'
  1178.                     );
  1179.                     return $this->redirectToRoute('add_employee');
  1180.                 } else {
  1181.                     $EmployeeRes HumanResource::TwigDataForAddEmployee($em$id);
  1182.                     $Employee $EmployeeRes['employee'];
  1183.                     $EmployeeMain $EmployeeRes['employeeMain'];
  1184.                     $sysUserId $EmployeeRes['sysId'];
  1185.                     $existingSysUser $sysUserId $em->getRepository('ApplicationBundle:SysUser')->find($sysUserId) : [];
  1186.                     $regionIdsArray json_decode($EmployeeMain->getRegionIds(), true) ?: [];
  1187.                     $regionLeaderFlagsArray json_decode($EmployeeMain->getRegionLeaderFlags(), true) ?: [];
  1188.                     $existingRegionAssociations = [];
  1189.                     if (!empty($regionIdsArray)) {
  1190.                         $regionRepo $this->getDoctrine()->getRepository('ApplicationBundle:Region');
  1191.                         $regions $regionRepo->findBy(['id' => $regionIdsArray]);
  1192.                         $regionMap = [];
  1193.                         foreach ($regions as $region) {
  1194.                             $regionMap[$region->getId()] = $region;
  1195.                         }
  1196.                         foreach ($regionIdsArray as $index => $regionId) {
  1197.                             if (!isset($regionMap[$regionId])) continue;
  1198.                             $region $regionMap[$regionId];
  1199.                             $existingRegionAssociations[] = [
  1200.                                 'regionLevelId' => $region->getRegionLevelId(),
  1201.                                 'regionId' => $region->getId(),
  1202.                                 'isLeader' => isset($regionLeaderFlagsArray[$index]) ? (int)$regionLeaderFlagsArray[$index] : 0
  1203.                             ];
  1204.                         }
  1205.                     }
  1206.                     $TwigData HumanResource::TwigDataForAddEmployee($em0);
  1207.                     return $this->render(
  1208.                         'ApplicationBundle:pages/human_resource/input_forms:add_employee.html.twig',
  1209.                         array(
  1210.                             'page_title' => 'Update Employee',
  1211.                             'ownOnly' => $ownOnly,
  1212.                             'branches' => $TwigData['branches'],
  1213.                             'bankListObj' => $bankListObj,
  1214.                             'heads' => Accounts::getLedgerHeadsWithParents($em),
  1215.                             'departments' => $TwigData['departments'],
  1216.                             'departmentPositions' => $TwigData['departmentPositions'],
  1217.                             'regions' => $TwigData['regions'],
  1218.                             'supervisors' => $TwigData['supervisors'],
  1219.                             'sysUsers' => $TwigData['sysUser'],
  1220.                             'EmploymentStatus' => $TwigData['EmploymentStatus'],
  1221.                             'sex' => $TwigData['sex'],
  1222.                             'BloodGroup' => $TwigData['BloodGroup'],
  1223.                             'days' => $TwigData['days'],
  1224.                             'employeeMain' => $EmployeeMain,
  1225.                             'employee' => $Employee,
  1226.                             'skills' => $skills,
  1227.                             'existingSysUser' => $existingSysUser,
  1228.                             'id' => $id,
  1229.                             'default_route' => $EmployeeRes['defaultRoute'],
  1230.                             'user_type' => $EmployeeRes['userType'],
  1231.                             'user_type_data' => HumanResourceConstant::$userType,
  1232.                             'AccountTypes' => $TwigData['AccountType'],
  1233.                             'weekends' => explode(','$Employee->getWeeklyHoliday()),
  1234.                             'consultancyLevel' => $consultancyLevel,
  1235.                             'module_data_array' => $TwigData['module_data_array'],
  1236.                             'HasUpdateMode' => true,
  1237.                             'brand_list' => Inventory::GetBrandList($em$this->getLoggedUserCompanyId($data)),
  1238.                             'branch_list' => Client::BranchList($this->getDoctrine()->getManager(), $this->getLoggedUserCompanyId($data)),
  1239.                             'region_data' => Client::RegionList($this->getDoctrine()->getManager(), $this->getLoggedUserCompanyId($data)),
  1240.                             'leaveSettings' => $TwigData['leaveSettings'],
  1241.                             'leaveData' => $EmployeeRes['leaveData'],
  1242.                             'positions' => $EmployeeRes['positions'],
  1243.                             'existing_region_associations' => $existingRegionAssociations
  1244.                         )
  1245.                     );
  1246.                 }
  1247.             } else {
  1248.                 $approveHash $data->request->get('approvalHash');
  1249.                 $loginId $data->getSession()->get(UserConstants::USER_LOGIN_ID);
  1250.                 $isSignatureOk DocValidation::isSignatureOk($em$loginId$approveHash);
  1251.                 $upl_dir $this->container->getParameter('kernel.root_dir') . '/../web/uploads/Users/';
  1252.                 $image $data->files->get('img');
  1253.                 $profileImage $this->uploadImage($image$data);
  1254.                 $path '';
  1255.                 if ($isSignatureOk) {
  1256.                     $CompanyId $this->getLoggedUserCompanyId($data);
  1257.                     $user $em->getRepository('ApplicationBundle:SysUser')->findOneBy(['email' => $data->get('email')]);
  1258.                     if ($user) {
  1259.                         $sysUserId $user->getUserId();
  1260.                         $message $this->get('user_module')->updateUser(
  1261.                             $sysUserId,
  1262.                             $data->request->get('firstname') . " " $data->request->get('lastname'),
  1263.                             $data->request->has('email') ? $data->request->get('email') : '_UNCHANGED_',
  1264.                             $data->request->has('username') ? $data->request->get('username') : '_UNCHANGED_',
  1265.                             $data->request->get('password'),
  1266.                             1,
  1267.                             $data->request->get('user_type''_UNCHANGED_'),
  1268.                             $data->request->get('supervisor'),
  1269.                             $data->request->get('default_route'),
  1270.                             $data->request->get('branch'),
  1271.                             $data->request->has('access_module') ? 0,
  1272.                             $data->getSession()->get(UserConstants::USER_LOGIN_ID),
  1273.                             $data->request->get('global_user_id'null),
  1274.                             $profileImage,
  1275.                             $upl_dir
  1276.                         );
  1277.                         if (isset($message[0]) && $message[0] === 'success') {
  1278.                             HumanResource::StoreDataForAddEmployee($em$data$id$CompanyId$profileImage);
  1279.                             $connection->commit();
  1280.                             if ($systemType == '_CENTRAL_') {
  1281.                             } else {
  1282.                                 $Employee $em->getRepository(Employee::class)->find($id);
  1283.                                 $EmployeeDetails $em->getRepository(EmployeeDetails::class)->findOneBy(
  1284.                                     array(
  1285.                                         'id' => $id
  1286.                                     )
  1287.                                 );
  1288.                                 $em_goc $this->getDoctrine()->getManager('company_group');
  1289.                                 $em_goc->getConnection()->connect();
  1290.                                 $connected $em_goc->getConnection()->isConnected();
  1291.                                 $gocDataList = [];
  1292.                                 $gocDataListByAppId = [];
  1293.                                 $retDataDebug = array();
  1294.                                 $appIds $message[3]->getUserAppId();
  1295.                                 $userIds $message[3]->getUserId();
  1296.                                 if ($connected) {
  1297.                                     $findByQuery = array(
  1298.                                         'active' => 1
  1299.                                     );
  1300.                                     if ($appIds !== '_UNSET_')
  1301.                                         $findByQuery['appId'] = $appIds;
  1302.                                     $gocList $this->getDoctrine()->getManager('company_group')
  1303.                                         ->getRepository("CompanyGroupBundle:CompanyGroup")
  1304.                                         ->findBy($findByQuery);
  1305.                                     foreach ($gocList as $entry) {
  1306.                                         $d = array(
  1307.                                             'name' => $entry->getName(),
  1308.                                             'id' => $entry->getId(),
  1309.                                             'image' => $entry->getImage(),
  1310.                                             'companyGroupHash' => $entry->getCompanyGroupHash(),
  1311.                                             'dbName' => $entry->getDbName(),
  1312.                                             'dbUser' => $entry->getDbUser(),
  1313.                                             'dbPass' => $entry->getDbPass(),
  1314.                                             'dbHost' => $entry->getDbHost(),
  1315.                                             'appId' => $entry->getAppId(),
  1316.                                             'companyRemaining' => $entry->getCompanyRemaining(),
  1317.                                             'companyAllowed' => $entry->getCompanyAllowed(),
  1318.                                         );
  1319.                                         $gocDataList[$entry->getId()] = $d;
  1320.                                         $gocDataListByAppId[$entry->getAppId()] = $d;
  1321.                                     }
  1322.                                     $debugCount 0;
  1323.                                     foreach ($gocDataList as $gocId => $entry) {
  1324.                                         $skipSend 1;
  1325.                                         $connector $this->container->get('application_connector');
  1326.                                         $connector->resetConnection(
  1327.                                             'default',
  1328.                                             $gocDataList[$gocId]['dbName'],
  1329.                                             $gocDataList[$gocId]['dbUser'],
  1330.                                             $gocDataList[$gocId]['dbPass'],
  1331.                                             $gocDataList[$gocId]['dbHost'],
  1332.                                             $reset true);
  1333.                                         $em $this->getDoctrine()->getManager();
  1334.                                         if ($userIds !== '_UNSET_')
  1335.                                             $users $this->getDoctrine()
  1336.                                                 ->getRepository('ApplicationBundle:SysUser')
  1337.                                                 ->findBy(
  1338.                                                     array(
  1339.                                                         'userId' => $userIds
  1340.                                                     )
  1341.                                                 );
  1342.                                         else
  1343.                                             $users $this->getDoctrine()
  1344.                                                 ->getRepository('ApplicationBundle:SysUser')
  1345.                                                 ->findBy(
  1346.                                                     array()
  1347.                                                 );
  1348.                                         $output '';
  1349.                                         $userData = array();
  1350.                                         $userFiles = array();
  1351.                                         foreach ($users as $user) {
  1352.                                             $file $this->container->getParameter('kernel.root_dir') . '/../web/' $user->getImage();
  1353.                                             if ($user->getImage() != '' && $user->getImage() != null && file_exists($file)) {
  1354.                                                 $mime mime_content_type($file);
  1355.                                                 $info pathinfo($file);
  1356.                                                 $name $info['basename'];
  1357.                                                 if (strpos($mime'image') !== false) {
  1358.                                                     $output = new \CURLFile($file$mime$name);
  1359.                                                 }
  1360.                                                 $skipSend 0;
  1361.                                                 $userFiles['file_' $user->getUserAppId() . '_' $user->getUserId()] = $output;
  1362.                                             } else {
  1363.                                                 $user->setImage(null);
  1364.                                                 $userFiles['file_' $user->getUserAppId() . '_' $user->getUserId()] = 'pika';
  1365.                                                 $em->flush();
  1366.                                             }
  1367.                                             $getters array_filter(get_class_methods($user), function ($method) {
  1368.                                                 return 'get' === substr($method03);
  1369.                                             });
  1370.                                             $userDataSingle = array();
  1371.                                             foreach ($getters as $getter) {
  1372.                                                 if ($getter == 'getCreatedAt' || $getter == 'getUpdatedAt' || $getter == 'getImage')
  1373.                                                     continue;
  1374.                                                 if ($user->{$getter}() instanceof \DateTime) {
  1375.                                                     $ggtd $user->{$getter}();
  1376.                                                     $userDataSingle[$getter] = $ggtd->format('Y-m-d');
  1377.                                                 } else
  1378.                                                     $userDataSingle[$getter] = $user->{$getter}();
  1379.                                             }
  1380.                                             $employeeGetters = array(
  1381.                                                 'getFirstname''getLastname''getImage''getIsImgLegal''getNid''getDob''getSex''getReligion''getFather',
  1382.                                                 'getMother''getSpouse''getChild1''getChild2''getBlood''getPhone''getOfficailPhone''getCurrAddr',
  1383.                                                 'getCurrAddrLat''getCurrAddrLng''getPermAddr''getEmmContact''getUsername''getEmail''getPassword',
  1384.                                                 'getUserId''getJoiningDate''getEmpValidTill''getEmpStatus''getEmpType''getEmpCode''getEmpLabel''getTin',
  1385.                                                 'getTinValidTill''getMedIns''getMedInsValidTill''getDocs''getNocApproval''getInst1''getYr1''getDur1',
  1386.                                                 'getInst2''getYr2''getDur2''getInst3''getYr3''getDur3''getEinst1''getEyr1''getEdeg1''getEinst2',
  1387.                                                 'getEyr2''getEdeg2''getEinst3''getEyr3''getEdeg3''getBankAcc''getBankAccType''getBankAccValidFrom',
  1388.                                                 'getBankAccValidTo''getRoutingCode''getSwiftCode''getEar1''getEar2''getEar3''getEar4''getEar5''getEar6',
  1389.                                                 'getEart''getDed1''getDed2''getDed3''getDed4''getDedt''getPayable''getHandCash''getBankTransfer',
  1390.                                                 'getSecDep''getSecDepSpan''getSecDepRemMon''getSecDepRemAmount''getSlQty''getSlTkn''getSlFreq''getMlQty',
  1391.                                                 'getMlTkn''getMlFreq''getElQty''getElTkn''getElFreq''getClQty''getClTkn''getClFreq''getLevt',
  1392.                                                 'getWeeklyHoliday''getFiles''getSupervisor''getDept''getDesg''getBranch''getDivision''getCreatedAt',
  1393.                                                 'getUpdatedAt''getEmployeeLevel''getSkill''getProbationaryPeriod''getDocBookedFlag''getTimeStampOfForm',
  1394.                                                 'getIsConsultant''getConsultantLevel''getApplicationText''getCurrentEmployment''getEmergencyContactNumber',
  1395.                                                 'getPostalCode''getCountry''getEducationData''getWorkExperienceData''getCertificateData''getLanguagesData',
  1396.                                                 'getBeneficiaryName''getBankName''getBranchName''getClockedIn'
  1397.                                             );
  1398.                                             foreach ($employeeGetters as $getter) {
  1399.                                                 if (!method_exists($EmployeeDetails$getter)) continue;
  1400.                                                 try {
  1401.                                                     $value $EmployeeDetails->{$getter}();
  1402.                                                     if ($value instanceof \DateTime) {
  1403.                                                         $userDataSingle[$getter] = $value->format('Y-m-d');
  1404.                                                     } elseif (is_object($value)) {
  1405.                                                         continue;
  1406.                                                     } else {
  1407.                                                         $userDataSingle[$getter] = $value;
  1408.                                                     }
  1409.                                                 } catch (\Exception $e) {
  1410.                                                     continue;
  1411.                                                 }
  1412.                                             }
  1413.                                             $userData[] = $userDataSingle;
  1414.                                         }
  1415.                                         $retDataDebug[$debugCount] = array(
  1416.                                             'skipSend' => $skipSend
  1417.                                         );
  1418.                                         {
  1419.                                             $urlToCall GeneralConstant::HONEYBEE_CENTRAL_SERVER '/SyncUserToCentralUser';
  1420.                                             $userFiles['userData'] = json_encode($userData);
  1421.                                             $curl curl_init();
  1422.                                             curl_setopt_array($curl, array(
  1423.                                                 CURLOPT_RETURNTRANSFER => 1,
  1424.                                                 CURLOPT_POST => 1,
  1425.                                                 CURLOPT_URL => $urlToCall,
  1426.                                                 CURLOPT_CONNECTTIMEOUT => 10,
  1427.                                                 CURLOPT_SSL_VERIFYPEER => false,
  1428.                                                 CURLOPT_SSL_VERIFYHOST => false,
  1429.                                                 CURLOPT_HTTPHEADER => array(),
  1430.                                                 CURLOPT_POSTFIELDS => $userFiles
  1431.                                             ));
  1432.                                             $retData curl_exec($curl);
  1433.                                             $errData curl_error($curl);
  1434.                                             curl_close($curl);
  1435.                                             $retDataObj json_decode($retDatatrue);
  1436.                                             $retDataDebug[$debugCount] = $retDataObj;
  1437.                                             if (isset($retDataObj['globalIdsData']))
  1438.                                                 foreach ($retDataObj['globalIdsData'] as $app_id => $usrList) {
  1439.                                                     $connector $this->container->get('application_connector');
  1440.                                                     $connector->resetConnection(
  1441.                                                         'default',
  1442.                                                         $gocDataListByAppId[$app_id]['dbName'],
  1443.                                                         $gocDataListByAppId[$app_id]['dbUser'],
  1444.                                                         $gocDataListByAppId[$app_id]['dbPass'],
  1445.                                                         $gocDataListByAppId[$app_id]['dbHost'],
  1446.                                                         $reset true);
  1447.                                                     $em $this->getDoctrine()->getManager();
  1448.                                                     foreach ($usrList as $sys_id => $globaldata) {
  1449.                                                         $user $this->getDoctrine()
  1450.                                                             ->getRepository('ApplicationBundle:SysUser')
  1451.                                                             ->findOneBy(
  1452.                                                                 array(
  1453.                                                                     'userId' => $sys_id
  1454.                                                                 )
  1455.                                                             );
  1456.                                                         if ($user) {
  1457.                                                             $user->setGlobalId($globaldata['gid']);
  1458.                                                             $em->flush();
  1459.                                                         }
  1460.                                                     }
  1461.                                                 }
  1462.                                         }
  1463.                                         $debugCount++;
  1464.                                     }
  1465.                                 }
  1466.                             }
  1467.                         } else {
  1468.                             $errorMsg $message['message'] ?? 'Unknown error occurred.';
  1469.                             $this->addFlash('error'$errorMsg);
  1470.                             return $this->redirectToRoute('add_employee');
  1471.                         }
  1472.                         $userType $data->getSession()->get(UserConstants::USER_TYPE);
  1473.                         $redirctUrl $this->generateUrl('employee_list', [], UrlGenerator::ABSOLUTE_URL);
  1474.                         if ($userType == 1) {
  1475.                             $redirctUrl $this->generateUrl('employee_list', [], UrlGenerator::ABSOLUTE_URL);
  1476.                         } else {
  1477.                             $redirctUrl $this->generateUrl('edit_employee', [], UrlGenerator::ABSOLUTE_URL) . '/my';
  1478.                         }
  1479.                         return new JsonResponse(array(
  1480.                             'employeeId' => $Employee->getEmployeeId(),
  1481.                             'redirectToNew' => 0,
  1482.                             'success' => true,
  1483.                             'redirectUrl' => $redirctUrl,
  1484.                         ));
  1485.                     }
  1486.                 } else {
  1487.                     $this->addFlash(
  1488.                         'error',
  1489.                         'Invalid Approval Hash!'
  1490.                     );
  1491.                     return $this->redirectToRoute('add_employee');
  1492.                 }
  1493.             }
  1494.         } else {
  1495.             if ($data->isMethod('GET')) {
  1496.                 $TwigData HumanResource::TwigDataForAddEmployee($em0);
  1497.                 $existingRegionAssociations = [];
  1498.                 return $this->render(
  1499.                     'ApplicationBundle:pages/human_resource/input_forms:add_employee.html.twig',
  1500.                     array(
  1501.                         'page_title' => 'Add Employee',
  1502.                         'ownOnly' => $ownOnly,
  1503.                         'heads' => Accounts::getLedgerHeadsWithParents($em),
  1504.                         'bankListObj' => $bankListObj,
  1505.                         'branches' => $TwigData['branches'],
  1506.                         'departments' => $TwigData['departments'],
  1507.                         'departmentPositions' => $TwigData['departmentPositions'],
  1508.                         'regions' => $TwigData['regions'],
  1509.                         'supervisors' => $TwigData['supervisors'],
  1510.                         'sysUsers' => $TwigData['sysUser'],
  1511.                         'EmploymentStatus' => $TwigData['EmploymentStatus'],
  1512.                         'sex' => $TwigData['sex'],
  1513.                         'skills' => $skills,
  1514.                         'id' => $id,
  1515.                         'consultancyLevel' => $consultancyLevel,
  1516.                         'existingSysUser' => null,
  1517.                         'BloodGroup' => $TwigData['BloodGroup'],
  1518.                         'days' => $TwigData['days'],
  1519.                         'AccountTypes' => $TwigData['AccountType'],
  1520.                         'module_data_array' => $TwigData['module_data_array'],
  1521.                         'user_type_data' => HumanResourceConstant::$userType,
  1522.                         'HasUpdateMode' => false,
  1523.                         'brand_list' => Inventory::GetBrandList($em$this->getLoggedUserCompanyId($data)),
  1524.                         'leaveSettings' => $TwigData['leaveSettings'],
  1525.                         'employee' => [],
  1526.                         'positions' => $TwigData['positions'],
  1527.                         'existing_region_associations' => $existingRegionAssociations ?? [],
  1528.                         'branch_list' => Client::BranchList($this->getDoctrine()->getManager(), $this->getLoggedUserCompanyId($data)),
  1529.                         'region_data' => Client::RegionList($this->getDoctrine()->getManager(), $this->getLoggedUserCompanyId($data)),
  1530.                     )
  1531.                 );
  1532.             } else {
  1533.                 try {
  1534.                     $approveHash $data->request->get('approvalHash');
  1535.                     $loginId $data->getSession()->get(UserConstants::USER_LOGIN_ID);
  1536.                     $CompanyId $this->getLoggedUserCompanyId($data);
  1537.                     $isSignatureOk DocValidation::isSignatureOk($em$loginId$approveHash);
  1538.                     if (!$isSignatureOk) {
  1539.                         $this->addFlash('error''Invalid Approval Hash!');
  1540.                         return $this->redirectToRoute('add_employee');
  1541.                     }
  1542.                     $message $this->get('user_module')->addNewUser(
  1543.                         $data->request->get('firstname') . " " $data->request->get('lastname'),
  1544.                         $data->request->get('email'),
  1545.                         $data->request->get('username'),
  1546.                         $data->request->get('password'),
  1547.                         $data->request->get('desg'),
  1548.                         $this->getLoggedUserLoginId($data),
  1549.                         $data->request->get('company'),
  1550.                         $data->request->get('user_type'),
  1551.                         $data->request->get('companyIdList'),
  1552.                         $data->request->get('branch'),
  1553.                         $data->request->get('supervisor'),
  1554.                         $data->request->get('default_route'),
  1555.                         $data->request->has('access_module') ? 0,
  1556.                         "",
  1557.                         $data->files->get('img'),
  1558.                         '',
  1559.                         00,
  1560.                         ''''''0''0,
  1561.                         $data->request->get('global_user_id'null)
  1562.                     );
  1563.                     if ($message[0] === 'error') {
  1564.                         $this->addFlash('error''Invalid Approval Hash!');
  1565.                         return $this->redirectToRoute('add_employee');
  1566.                     }
  1567.                     $isSuccess HumanResource::StoreDataForAddEmployee($em$datafalse$CompanyId);
  1568.                     $Employee $isSuccess;
  1569.                     $EmployeeDetails $em->getRepository(EmployeeDetails::class)->findOneBy(['id' => $id]);
  1570.                     $Employee->setUserId($message[3]->getUserId());
  1571.                     $em->persist($Employee);
  1572.                     if ($EmployeeDetails) {
  1573.                         $EmployeeDetails->setUserId($message[3]->getUserId());
  1574.                         $em->persist($EmployeeDetails);
  1575.                     }
  1576.                     $em->flush();
  1577.                     $connection->commit();
  1578.                 } catch (Throwable $e) {
  1579.                     $connection->rollBack();
  1580.                     $em->close();
  1581.                     $this->addFlash('error''Failed to save employee: ' $e->getMessage());
  1582.                     return $this->redirectToRoute('add_employee');
  1583.                 }
  1584.                 if ($systemType !== '_CENTRAL_') {
  1585.                     $em_goc $this->getDoctrine()->getManager('company_group');
  1586.                     $em_goc->getConnection()->connect();
  1587.                     $connected $em_goc->getConnection()->isConnected();
  1588.                     if ($connected) {
  1589.                         $appIds $message[2]->getAppId();
  1590.                         $userIds $message[3]->getUserId();
  1591.                         $findByQuery = ['active' => 1];
  1592.                         if ($appIds !== '_UNSET_'$findByQuery['appId'] = $appIds;
  1593.                         $gocList $em_goc->getRepository("CompanyGroupBundle:CompanyGroup")->findBy($findByQuery);
  1594.                         $gocDataList $gocDataListByAppId = [];
  1595.                         foreach ($gocList as $entry) {
  1596.                             $d = [
  1597.                                 'name' => $entry->getName(),
  1598.                                 'id' => $entry->getId(),
  1599.                                 'image' => $entry->getImage(),
  1600.                                 'companyGroupHash' => $entry->getCompanyGroupHash(),
  1601.                                 'dbName' => $entry->getDbName(),
  1602.                                 'dbUser' => $entry->getDbUser(),
  1603.                                 'dbPass' => $entry->getDbPass(),
  1604.                                 'dbHost' => $entry->getDbHost(),
  1605.                                 'appId' => $entry->getAppId(),
  1606.                                 'companyRemaining' => $entry->getCompanyRemaining(),
  1607.                                 'companyAllowed' => $entry->getCompanyAllowed(),
  1608.                             ];
  1609.                             $gocDataList[$entry->getId()] = $d;
  1610.                             $gocDataListByAppId[$entry->getAppId()] = $d;
  1611.                         }
  1612.                         $debugCount 0;
  1613.                         foreach ($gocDataList as $gocId => $entry) {
  1614.                             $skipSend 1;
  1615.                             $connector $this->container->get('application_connector');
  1616.                             $connector->resetConnection(
  1617.                                 'default',
  1618.                                 $entry['dbName'],
  1619.                                 $entry['dbUser'],
  1620.                                 $entry['dbPass'],
  1621.                                 $entry['dbHost'],
  1622.                                 $reset true
  1623.                             );
  1624.                             $em $this->getDoctrine()->getManager();
  1625.                             $users = ($userIds !== '_UNSET_')
  1626.                                 ? $this->getDoctrine()->getRepository('ApplicationBundle:SysUser')->findBy(['userId' => $userIds])
  1627.                                 : $this->getDoctrine()->getRepository('ApplicationBundle:SysUser')->findBy([]);
  1628.                             $userData $userFiles = [];
  1629.                             foreach ($users as $user) {
  1630.                                 $filePath $this->container->getParameter('kernel.root_dir') . '/../web/' $user->getImage();
  1631.                                 if ($user->getImage() && file_exists($filePath)) {
  1632.                                     $mime mime_content_type($filePath);
  1633.                                     $info pathinfo($filePath);
  1634.                                     $name $info['basename'];
  1635.                                     if (strpos($mime'image') !== false) {
  1636.                                         $userFiles['file_' $user->getUserAppId() . '_' $user->getUserId()] = new \CURLFile($filePath$mime$name);
  1637.                                         $skipSend 0;
  1638.                                     }
  1639.                                 } else {
  1640.                                     $user->setImage(null);
  1641.                                     $userFiles['file_' $user->getUserAppId() . '_' $user->getUserId()] = 'pika';
  1642.                                     $em->flush();
  1643.                                 }
  1644.                                 $getters array_filter(get_class_methods($user), function ($m) {
  1645.                                     return substr($m03) === 'get';
  1646.                                 });
  1647.                                 $userDataSingle = [];
  1648.                                 foreach ($getters as $getter) {
  1649.                                     if (in_array($getter, ['getCreatedAt''getUpdatedAt''getImage'])) continue;
  1650.                                     $val $user->{$getter}();
  1651.                                     $userDataSingle[$getter] = $val instanceof \DateTime $val->format('Y-m-d') : $val;
  1652.                                 }
  1653.                                 $employeeGetters = [
  1654.                                     'getFirstname''getLastname''getImage''getIsImgLegal''getNid''getDob''getSex''getReligion',
  1655.                                     'getFather''getMother''getSpouse''getChild1''getChild2''getBlood''getPhone''getOfficailPhone',
  1656.                                     'getCurrAddr''getCurrAddrLat''getCurrAddrLng''getPermAddr''getEmmContact''getUsername''getEmail',
  1657.                                     'getPassword''getUserId''getJoiningDate''getEmpValidTill''getEmpStatus''getEmpType''getEmpCode',
  1658.                                     'getEmpLabel''getTin''getTinValidTill''getMedIns''getMedInsValidTill''getDocs''getNocApproval',
  1659.                                     'getInst1''getYr1''getDur1''getInst2''getYr2''getDur2''getInst3''getYr3''getDur3''getEinst1',
  1660.                                     'getEyr1''getEdeg1''getEinst2''getEyr2''getEdeg2''getEinst3''getEyr3''getEdeg3''getBankAcc',
  1661.                                     'getBankAccType''getBankAccValidFrom''getBankAccValidTo''getRoutingCode''getSwiftCode''getEar1',
  1662.                                     'getEar2''getEar3''getEar4''getEar5''getEar6''getEart''getDed1''getDed2''getDed3''getDed4',
  1663.                                     'getDedt''getPayable''getHandCash''getBankTransfer''getSecDep''getSecDepSpan''getSecDepRemMon',
  1664.                                     'getSecDepRemAmount''getSlQty''getSlTkn''getSlFreq''getMlQty''getMlTkn''getMlFreq''getElQty',
  1665.                                     'getElTkn''getElFreq''getClQty''getClTkn''getClFreq''getLevt''getWeeklyHoliday''getFiles',
  1666.                                     'getSupervisor''getDept''getDesg''getBranch''getDivision''getCreatedAt''getUpdatedAt',
  1667.                                     'getEmployeeLevel''getSkill''getProbationaryPeriod''getDocBookedFlag''getTimeStampOfForm',
  1668.                                     'getIsConsultant''getConsultantLevel''getApplicationText''getCurrentEmployment''getEmergencyContactNumber',
  1669.                                     'getPostalCode''getCountry''getEducationData''getWorkExperienceData''getCertificateData''getLanguagesData',
  1670.                                     'getBeneficiaryName''getBankName''getBranchName''getClockedIn'
  1671.                                 ];
  1672.                                 foreach ($employeeGetters as $getter) {
  1673.                                     if (!method_exists($EmployeeDetails$getter)) continue;
  1674.                                     $value $EmployeeDetails->{$getter}();
  1675.                                     if ($value instanceof \DateTime$userDataSingle[$getter] = $value->format('Y-m-d');
  1676.                                     elseif (!is_object($value)) $userDataSingle[$getter] = $value;
  1677.                                 }
  1678.                                 $userData[] = $userDataSingle;
  1679.                             }
  1680.                             $retDataDebug[$debugCount] = ['skipSend' => $skipSend];
  1681.                             $urlToCall GeneralConstant::HONEYBEE_CENTRAL_SERVER '/SyncUserToCentralUser';
  1682.                             $userFiles['userData'] = json_encode($userData);
  1683.                             $curl curl_init();
  1684.                             curl_setopt_array($curl, [
  1685.                                 CURLOPT_RETURNTRANSFER => 1,
  1686.                                 CURLOPT_POST => 1,
  1687.                                 CURLOPT_URL => $urlToCall,
  1688.                                 CURLOPT_CONNECTTIMEOUT => 10,
  1689.                                 CURLOPT_SSL_VERIFYPEER => false,
  1690.                                 CURLOPT_SSL_VERIFYHOST => false,
  1691.                                 CURLOPT_POSTFIELDS => $userFiles
  1692.                             ]);
  1693.                             $retData curl_exec($curl);
  1694.                             $errData curl_error($curl);
  1695.                             curl_close($curl);
  1696.                             $retDataObj $errData ? ['status' => 'error''message' => 'cURL Error: ' $errData] : json_decode($retDatatrue);
  1697.                             $retDataDebug[$debugCount] = $retDataObj;
  1698.                             if (isset($retDataObj['globalIdsData'])) {
  1699.                                 foreach ($retDataObj['globalIdsData'] as $app_id => $usrList) {
  1700.                                     $connector->resetConnection(
  1701.                                         'default',
  1702.                                         $gocDataListByAppId[$app_id]['dbName'],
  1703.                                         $gocDataListByAppId[$app_id]['dbUser'],
  1704.                                         $gocDataListByAppId[$app_id]['dbPass'],
  1705.                                         $gocDataListByAppId[$app_id]['dbHost'],
  1706.                                         $reset true
  1707.                                     );
  1708.                                     $em $this->getDoctrine()->getManager();
  1709.                                     foreach ($usrList as $sys_id => $globaldata) {
  1710.                                         $user $this->getDoctrine()->getRepository('ApplicationBundle:SysUser')->findOneBy(['userId' => $sys_id]);
  1711.                                         if ($user) {
  1712.                                             $user->setGlobalId($globaldata['gid']);
  1713.                                             $em->persist($user);
  1714.                                             $em->flush();
  1715.                                         }
  1716.                                     }
  1717.                                 }
  1718.                             }
  1719.                             $debugCount++;
  1720.                         }
  1721.                     }
  1722.                 }
  1723.                 $companyData $message[2];
  1724.                 if ($message[0] === 'success' && GeneralConstant::EMAIL_ENABLED == 1) {
  1725.                     $bodyTemplate 'ApplicationBundle:email/user:registration.html.twig';
  1726.                     $bodyData = [
  1727.                         'name' => $data->request->get('name'),
  1728.                         'companyData' => $companyData,
  1729.                         'userName' => $data->request->get('username'),
  1730.                         'password' => $data->request->get('password'),
  1731.                     ];
  1732.                     $new_mail $this->get('mail_module');
  1733.                     $new_mail->sendMyMail([
  1734.                         'senderHash' => '_CUSTOM_',
  1735.                         'forwardToMailAddress' => $data->request->get('email'),
  1736.                         'subject' => 'User Registration on HoneyBee Ecosystem under Entity ' $companyData->getName(),
  1737.                         'fileName' => '',
  1738.                         'attachments' => [],
  1739.                         'toAddress' => $data->request->get('email'),
  1740.                         'fromAddress' => 'no-reply@ourhoneybee.eu',
  1741.                         'userName' => 'no-reply@ourhoneybee.eu',
  1742.                         'password' => 'Y41dh8g0112',
  1743.                         'smtpServer' => 'smtp.hostinger.com',
  1744.                         'smtpPort' => 465,
  1745.                         'mailTemplate' => $bodyTemplate,
  1746.                         'templateData' => $bodyData,
  1747.                         'embedCompanyImage' => 1,
  1748.                         'companyId' => $data->request->get('company'),
  1749.                         'companyImagePath' => $companyData->getImage()
  1750.                     ]);
  1751.                 }
  1752.                 $this->addFlash('success''New Employee Successfully Added!');
  1753.                 $userType $data->getSession()->get(UserConstants::USER_TYPE);
  1754.                 $redirectUrl $userType == 1
  1755.                     $this->generateUrl('employee_list', [], UrlGenerator::ABSOLUTE_URL)
  1756.                     : $this->generateUrl('add_employee', [], UrlGenerator::ABSOLUTE_URL);
  1757.                 return new JsonResponse([
  1758.                     'employeeId' => $Employee->getEmployeeId(),
  1759.                     'redirectToNew' => 1,
  1760.                     'success' => true,
  1761.                     'redirectUrl' => $redirectUrl,
  1762.                 ]);
  1763.             }
  1764.         }
  1765.     }
  1766.     public function AddNewEmployeeAction(Request $request$id)
  1767.     {
  1768.         $em $this->getDoctrine()->getManager();
  1769.         $systemType $this->container->hasParameter('system_type') ? $this->container->getParameter('system_type') : '_ERP_';
  1770.         $approveHash $request->request->get('approvalHash');
  1771.         $loginId $request->getSession()->get(UserConstants::USER_LOGIN_ID);
  1772.         $CompanyId $this->getLoggedUserCompanyId($request);
  1773.         $isSignatureOk DocValidation::isSignatureOk($em$loginId$approveHash);
  1774.         $employee HumanResource::StoreDataForAddEmployee($em$requestfalse$CompanyId);
  1775.         $isUserExist $em->getRepository(EmployeeDetails::class);
  1776.         if ($isSignatureOk) {
  1777.             if ($isUserExist) {
  1778.                 if ($employee) {
  1779.                     $message $this->get('user_module')->addNewUser(
  1780.                         $request->request->get('firstname') . " " $request->request->get('lastname'),
  1781.                         $request->request->get('email'),
  1782.                         $request->request->get('username'),
  1783.                         $request->request->get('password'),
  1784.                         $request->request->get('desg'),
  1785.                         $request->getLoggedUserLoginId($request),
  1786.                         $request->request->get('company'),
  1787.                         $request->request->get('user_type'),
  1788.                         $request->request->get('companyIdList'),
  1789.                         $request->request->get('branch'),
  1790.                         $request->request->get('supervisor'),
  1791.                         $request->request->get('default_route'),
  1792.                         $request->request->has('access_module') ? 0
  1793.                     );
  1794.                     if ($message[0] == 'success') {
  1795.                         $employee->setUserId($message[3]->getUserId());
  1796.                         $em->flush();
  1797.                         if ($systemType == '_CENTRAL_') {
  1798.                         } else {
  1799.                             $em_goc $this->getDoctrine()->getManager('company_group');
  1800.                             $em_goc->getConnection()->connect();
  1801.                             $connected $em_goc->getConnection()->isConnected();
  1802.                             $gocDataList = [];
  1803.                             $gocDataListByAppId = [];
  1804.                             $retDataDebug = array();
  1805.                             $appIds $message[2]->getAppId();
  1806.                             $userIds $message[3]->getUserId();
  1807.                             if ($connected) {
  1808.                                 $findByQuery = array(
  1809.                                     'active' => 1
  1810.                                 );
  1811.                                 if ($appIds !== '_UNSET_')
  1812.                                     $findByQuery['appId'] = $appIds;
  1813.                                 $gocList $this->getDoctrine()->getManager('company_group')
  1814.                                     ->getRepository("CompanyGroupBundle:CompanyGroup")
  1815.                                     ->findBy($findByQuery);
  1816.                                 foreach ($gocList as $entry) {
  1817.                                     $d = array(
  1818.                                         'name' => $entry->getName(),
  1819.                                         'id' => $entry->getId(),
  1820.                                         'image' => $entry->getImage(),
  1821.                                         'companyGroupHash' => $entry->getCompanyGroupHash(),
  1822.                                         'dbName' => $entry->getDbName(),
  1823.                                         'dbUser' => $entry->getDbUser(),
  1824.                                         'dbPass' => $entry->getDbPass(),
  1825.                                         'dbHost' => $entry->getDbHost(),
  1826.                                         'appId' => $entry->getAppId(),
  1827.                                         'companyRemaining' => $entry->getCompanyRemaining(),
  1828.                                         'companyAllowed' => $entry->getCompanyAllowed(),
  1829.                                     );
  1830.                                     $gocDataList[$entry->getId()] = $d;
  1831.                                     $gocDataListByAppId[$entry->getAppId()] = $d;
  1832.                                 }
  1833.                                 $debugCount 0;
  1834.                                 foreach ($gocDataList as $gocId => $entry) {
  1835.                                     $skipSend 1;
  1836.                                     $connector $this->container->get('application_connector');
  1837.                                     $connector->resetConnection(
  1838.                                         'default',
  1839.                                         $gocDataList[$gocId]['dbName'],
  1840.                                         $gocDataList[$gocId]['dbUser'],
  1841.                                         $gocDataList[$gocId]['dbPass'],
  1842.                                         $gocDataList[$gocId]['dbHost'],
  1843.                                         $reset true);
  1844.                                     $em $this->getDoctrine()->getManager();
  1845.                                     if ($userIds !== '_UNSET_')
  1846.                                         $users $this->getDoctrine()
  1847.                                             ->getRepository('ApplicationBundle:SysUser')
  1848.                                             ->findBy(
  1849.                                                 array(
  1850.                                                     'userId' => $userIds
  1851.                                                 )
  1852.                                             );
  1853.                                     else
  1854.                                         $users $this->getDoctrine()
  1855.                                             ->getRepository('ApplicationBundle:SysUser')
  1856.                                             ->findBy(
  1857.                                                 array()
  1858.                                             );
  1859.                                     $output '';
  1860.                                     $userData = array();
  1861.                                     $userFiles = array();
  1862.                                     foreach ($users as $user) {
  1863.                                         $file $this->container->getParameter('kernel.root_dir') . '/../web/' $user->getImage();
  1864.                                         if ($user->getImage() != '' && $user->getImage() != null && file_exists($file)) {
  1865.                                             $mime mime_content_type($file);
  1866.                                             $info pathinfo($file);
  1867.                                             $name $info['basename'];
  1868.                                             if (strpos($mime'image') !== false) {
  1869.                                                 $output = new \CURLFile($file$mime$name);
  1870.                                             }
  1871.                                             $skipSend 0;
  1872.                                             $userFiles['file_' $user->getUserAppId() . '_' $user->getUserId()] = $output;
  1873.                                         } else {
  1874.                                             $user->setImage(null);
  1875.                                             $userFiles['file_' $user->getUserAppId() . '_' $user->getUserId()] = 'pika';
  1876.                                             $em->flush();
  1877.                                         }
  1878.                                         $getters array_filter(get_class_methods($user), function ($method) {
  1879.                                             return 'get' === substr($method03);
  1880.                                         });
  1881.                                         $userDataSingle = array();
  1882.                                         foreach ($getters as $getter) {
  1883.                                             if ($getter == 'getCreatedAt' || $getter == 'getUpdatedAt' || $getter == 'getImage')
  1884.                                                 continue;
  1885. //                                if(is_string($user->{$getter}())|| is_numeric($user->{$getter}()))
  1886. //                                {
  1887. //                                    $userDataSingle[$getter]= $user->{$getter}();
  1888. //                                }
  1889.                                             if ($user->{$getter}() instanceof \DateTime) {
  1890.                                                 $ggtd $user->{$getter}();
  1891.                                                 $userDataSingle[$getter] = $ggtd->format('Y-m-d');
  1892.                                             } else
  1893.                                                 $userDataSingle[$getter] = $user->{$getter}();
  1894.                                         }
  1895. //                                                    $userDataSingle['getNid']=$Employee->getNid();
  1896. //                                                    $userDataSingle['getCurrAddr'] = $Employee->getCurrAddr();
  1897.                                         $userData[] = $userDataSingle;
  1898.                                     }
  1899.                                     $retDataDebug[$debugCount] = array(
  1900.                                         'skipSend' => $skipSend
  1901.                                     );
  1902.                                     {
  1903.                                         $urlToCall GeneralConstant::HONEYBEE_CENTRAL_SERVER '/SyncUserToCentralUser';
  1904.                                         $userFiles['userData'] = json_encode($userData);
  1905.                                         $curl curl_init();
  1906.                                         curl_setopt_array($curl, array(
  1907.                                             CURLOPT_RETURNTRANSFER => 1,
  1908.                                             CURLOPT_POST => 1,
  1909.                                             CURLOPT_URL => $urlToCall,
  1910.                                             CURLOPT_CONNECTTIMEOUT => 10,
  1911.                                             CURLOPT_SSL_VERIFYPEER => false,
  1912.                                             CURLOPT_SSL_VERIFYHOST => false,
  1913. //                            CURLOPT_SAFE_UPLOAD => false,
  1914.                                             CURLOPT_HTTPHEADER => array(//                                "Accept: multipart/form-data",
  1915.                                             ),
  1916.                                             //                        CURLOPT_USERAGENT => 'InnoPM',
  1917. //                            CURLOPT_POSTFIELDS => array(
  1918. //                                'userData'=>json_encode($userData),
  1919. //                                'userFiles'=>$userFiles
  1920. //                            ),
  1921.                                             CURLOPT_POSTFIELDS => $userFiles
  1922.                                         ));
  1923.                                         $retData curl_exec($curl);
  1924.                                         $errData curl_error($curl);
  1925.                                         curl_close($curl);
  1926.                                         $response = [];
  1927.                                         if ($errData) {
  1928.                                             $response['status'] = 'error';
  1929.                                             $response['message'] = 'cURL Error: ' $errData;
  1930.                                         } else {
  1931.                                             $retDataObj json_decode($retDatatrue);
  1932.                                             if (!$retDataObj) {
  1933.                                                 $response['status'] = 'error';
  1934.                                                 $response['message'] = 'Invalid response from central server';
  1935.                                                 $response['raw_response'] = $retData;
  1936.                                             } else {
  1937.                                                 $response['status'] = 'success';
  1938.                                                 $response['data'] = $retDataObj;
  1939.                                             }
  1940.                                         }
  1941. // Return JSON response
  1942. //                                                    return new JsonResponse($response);
  1943.                                         $retDataDebug[$debugCount] = $retDataObj;
  1944.                                         if (isset($retDataObj['globalIdsData']))
  1945.                                             foreach ($retDataObj['globalIdsData'] as $app_id => $usrList) {
  1946.                                                 $connector $this->container->get('application_connector');
  1947.                                                 $connector->resetConnection(
  1948.                                                     'default',
  1949.                                                     $gocDataListByAppId[$app_id]['dbName'],
  1950.                                                     $gocDataListByAppId[$app_id]['dbUser'],
  1951.                                                     $gocDataListByAppId[$app_id]['dbPass'],
  1952.                                                     $gocDataListByAppId[$app_id]['dbHost'],
  1953.                                                     $reset true);
  1954.                                                 $em $this->getDoctrine()->getManager();
  1955.                                                 foreach ($usrList as $sys_id => $globaldata) {
  1956.                                                     $user $this->getDoctrine()
  1957.                                                         ->getRepository('ApplicationBundle:SysUser')
  1958.                                                         ->findOneBy(
  1959.                                                             array(
  1960.                                                                 'userId' => $sys_id
  1961.                                                             )
  1962.                                                         );
  1963.                                                     if ($user) {
  1964.                                                         $user->setGlobalId($globaldata['gid']);
  1965.                                                         $em->persist($user);
  1966.                                                         $em->flush();
  1967.                                                     }
  1968.                                                 }
  1969.                                             }
  1970.                                     }
  1971.                                     $debugCount++;
  1972.                                 }
  1973.                             }
  1974. //                    return new JsonResponse($retDataDebug);
  1975.                         }
  1976.                     }
  1977. //                                    if($message[0]=='success'){
  1978. //                                        $SysUserRepo = $em->getRepository('ApplicationBundle:SysUser');
  1979. //                                        $SysUser = $SysUserRepo->findOneBy([
  1980. //                                            'email' => $data->request->get('email')
  1981. //                                        ]);
  1982. //
  1983. //                                        if ($SysUser === null) {
  1984. //                                            throw new \Exception("User with email " . $data->request->get('email') . " not found.");
  1985. //                                        }
  1986. //
  1987. //                                        $isSuccess->setUserId($SysUser->getUserId());
  1988. //                                        $em->persist($isSuccess);
  1989. //                                        $em->flush();
  1990. //                                    }
  1991.                     $companyData $message[2];
  1992.                     if ($message[0] == 'success' && GeneralConstant::EMAIL_ENABLED == 1) {
  1993.                         $bodyHtml '';
  1994.                         $bodyTemplate 'ApplicationBundle:email/user:registration.html.twig';
  1995.                         $bodyData = array(
  1996.                             'name' => $request->request->get('name'),
  1997.                             'companyData' => $companyData,
  1998.                             'userName' => $request->request->get('username'),
  1999.                             'password' => $request->request->get('password'),
  2000.                         );
  2001.                         $attachments = [];
  2002.                         $new_mail $this->get('mail_module');
  2003.                         $new_mail->sendMyMail(array(
  2004.                             'senderHash' => '_CUSTOM_',
  2005.                             //                        'senderHash'=>'_CUSTOM_',
  2006.                             'forwardToMailAddress' => $request->request->get('email'),
  2007.                             'fromAddress' => 'no-reply@ourhoneybee.eu',
  2008.                             'userName' => 'no-reply@ourhoneybee.eu',
  2009.                             'password' => 'Honeybee@0112',
  2010.                             'smtpServer' => 'smtp.hostinger.com',
  2011.                             'smtpPort' => 465,
  2012.                             'subject' => 'User Registration on HoneyBee Ecosystem under Entity ' $companyData->getName(),
  2013.                             'fileName' => '',
  2014.                             'attachments' => $attachments,
  2015.                             'toAddress' => $request->request->get('email'),
  2016.                             'mailTemplate' => $bodyTemplate,
  2017.                             'templateData' => $bodyData,
  2018.                             'embedCompanyImage' => 1,
  2019.                             'companyId' => $request->request->get('company'),
  2020.                             'companyImagePath' => $companyData->getImage()
  2021.                         ));
  2022.                     }
  2023.                 }
  2024.                 $this->addFlash(
  2025.                     'success',
  2026.                     'New Employee Successfully Added!'
  2027.                 );
  2028.                 return $this->redirectToRoute('add_employee');
  2029.             } else {
  2030. //                        $requiredFields = [
  2031. //                            'email', 'username', 'password', 'firstname', 'lastname', 'nid', 'dob',
  2032. //                            'sex', 'blood', 'phone', 'perm_addr', 'dept', 'desg', 'branch',
  2033. //                            'emp_type', 'tin'
  2034. //                        ];
  2035. //
  2036. //                        $missingFields = [];
  2037. //
  2038. //                        foreach ($requiredFields as $field) {
  2039. //                            if (!$data->request->get($field)) {
  2040. //                                $missingFields[] = $field;
  2041. //                            }
  2042. //                        }
  2043. //                        if (!empty($missingFields)) {
  2044. //                            $this->addFlash('error', 'Missing fields: ' . implode(', ', $missingFields));
  2045. //                            return $this->redirectToRoute('add_employee');
  2046. //                        }
  2047. //                        $password = $data->request->get('password');
  2048. //                        $passwordPattern = '/^(?=.*[A-Z])(?=.*[a-z])(?=.*\d)(?=.*[\W_]).{8,}$/';
  2049. //                        if (!preg_match($passwordPattern, $password)) {
  2050. //                            $this->addFlash('error', 'Password must be at least 8 characters long, contain at least one uppercase letter, one lowercase letter, one special character, and one number. ' . implode(', ', $missingFields));
  2051. //                            return $this->redirectToRoute('add_employee');
  2052. //                        }
  2053.                 $CompanyId $this->getLoggedUserCompanyId($request);
  2054.                 $isSuccess HumanResource::StoreDataForAddEmployee($em$requestfalse$CompanyId);
  2055.                 if ($isSuccess) {
  2056.                     if ($request->request->has('send_appointment')) {
  2057.                         $email $request->request->get('email');
  2058.                         $bodyHtml '';
  2059.                         $bodyTemplate 'ApplicationBundle:email/general:appointment_letter_test.html.twig';
  2060.                         $bodyData = [];
  2061.                         $attachments = [];
  2062.                         $forwardToMailAddress $email;
  2063.                         $new_mail $this->get('mail_module');
  2064.                         $new_mail->sendMyMail(array(
  2065.                             'senderHash' => '_CUSTOM_',
  2066.                             'forwardToMailAddress' => $forwardToMailAddress,
  2067.                             'subject' => 'Appointment Letter',
  2068.                             'attachments' => $attachments,
  2069.                             'toAddress' => $forwardToMailAddress,
  2070.                             'fromAddress' => 'no-reply@ourhoneybee.eu',
  2071.                             'userName' => 'no-reply@ourhoneybee.eu',
  2072.                             'password' => 'Honeybee@0112',
  2073.                             'smtpServer' => 'smtp.hostinger.com',
  2074.                             'smtpPort' => 465,
  2075.                             'emailBody' => $bodyHtml,
  2076.                             'mailTemplate' => $bodyTemplate,
  2077.                             'templateData' => $bodyData,
  2078.                         ));
  2079.                     }
  2080.                     // Mailer function
  2081.                     if ($request->get("send_mail") && empty($request->get('sys_user'))) {
  2082.                         $message $this->get('user_module')->addNewUser(
  2083.                             $request->request->get('firstname') . " " $request->request->get('lastname'),
  2084.                             $request->request->get('email'),
  2085.                             $request->request->get('username'),
  2086.                             $request->request->get('password'),
  2087.                             $request->request->get('desg'),
  2088.                             $request->getLoggedUserLoginId($request),
  2089.                             $request->request->get('company'),
  2090.                             $request->request->get('user_type'),
  2091.                             $request->request->get('companyIdList'),
  2092.                             $request->request->get('branch'),
  2093.                             $request->request->get('supervisor'),
  2094.                             $request->request->get('default_route'),
  2095.                             $request->request->has('access_module') ? 0
  2096.                         );
  2097.                         if ($message[0] == 'success') {
  2098.                             if ($systemType == '_CENTRAL_') {
  2099.                             } else {
  2100.                                 $em_goc $this->getDoctrine()->getManager('company_group');
  2101.                                 $em_goc->getConnection()->connect();
  2102.                                 $connected $em_goc->getConnection()->isConnected();
  2103.                                 $gocDataList = [];
  2104.                                 $gocDataListByAppId = [];
  2105.                                 $retDataDebug = array();
  2106.                                 $appIds $message[2]->getAppId();
  2107.                                 $userIds $message[3]->getUserId();
  2108.                                 if ($connected) {
  2109.                                     $findByQuery = array(
  2110.                                         'active' => 1
  2111.                                     );
  2112.                                     if ($appIds !== '_UNSET_')
  2113.                                         $findByQuery['appId'] = $appIds;
  2114.                                     $gocList $this->getDoctrine()->getManager('company_group')
  2115.                                         ->getRepository("CompanyGroupBundle:CompanyGroup")
  2116.                                         ->findBy($findByQuery);
  2117.                                     foreach ($gocList as $entry) {
  2118.                                         $d = array(
  2119.                                             'name' => $entry->getName(),
  2120.                                             'id' => $entry->getId(),
  2121.                                             'image' => $entry->getImage(),
  2122.                                             'companyGroupHash' => $entry->getCompanyGroupHash(),
  2123.                                             'dbName' => $entry->getDbName(),
  2124.                                             'dbUser' => $entry->getDbUser(),
  2125.                                             'dbPass' => $entry->getDbPass(),
  2126.                                             'dbHost' => $entry->getDbHost(),
  2127.                                             'appId' => $entry->getAppId(),
  2128.                                             'companyRemaining' => $entry->getCompanyRemaining(),
  2129.                                             'companyAllowed' => $entry->getCompanyAllowed(),
  2130.                                         );
  2131.                                         $gocDataList[$entry->getId()] = $d;
  2132.                                         $gocDataListByAppId[$entry->getAppId()] = $d;
  2133.                                     }
  2134.                                     $debugCount 0;
  2135.                                     foreach ($gocDataList as $gocId => $entry) {
  2136.                                         $skipSend 1;
  2137.                                         $connector $this->container->get('application_connector');
  2138.                                         $connector->resetConnection(
  2139.                                             'default',
  2140.                                             $gocDataList[$gocId]['dbName'],
  2141.                                             $gocDataList[$gocId]['dbUser'],
  2142.                                             $gocDataList[$gocId]['dbPass'],
  2143.                                             $gocDataList[$gocId]['dbHost'],
  2144.                                             $reset true);
  2145.                                         $em $this->getDoctrine()->getManager();
  2146.                                         if ($userIds !== '_UNSET_')
  2147.                                             $users $this->getDoctrine()
  2148.                                                 ->getRepository('ApplicationBundle:SysUser')
  2149.                                                 ->findBy(
  2150.                                                     array(
  2151.                                                         'userId' => $userIds
  2152.                                                     )
  2153.                                                 );
  2154.                                         else
  2155.                                             $users $this->getDoctrine()
  2156.                                                 ->getRepository('ApplicationBundle:SysUser')
  2157.                                                 ->findBy(
  2158.                                                     array()
  2159.                                                 );
  2160.                                         $output '';
  2161.                                         $userData = array();
  2162.                                         $userFiles = array();
  2163.                                         foreach ($users as $user) {
  2164.                                             $file $this->container->getParameter('kernel.root_dir') . '/../web/' $user->getImage();
  2165.                                             if ($user->getImage() != '' && $user->getImage() != null && file_exists($file)) {
  2166.                                                 $mime mime_content_type($file);
  2167.                                                 $info pathinfo($file);
  2168.                                                 $name $info['basename'];
  2169.                                                 if (strpos($mime'image') !== false) {
  2170.                                                     $output = new \CURLFile($file$mime$name);
  2171.                                                 }
  2172.                                                 $skipSend 0;
  2173.                                                 $userFiles['file_' $user->getUserAppId() . '_' $user->getUserId()] = $output;
  2174.                                             } else {
  2175.                                                 $user->setImage(null);
  2176.                                                 $userFiles['file_' $user->getUserAppId() . '_' $user->getUserId()] = 'pika';
  2177.                                                 $em->flush();
  2178.                                             }
  2179.                                             $getters array_filter(get_class_methods($user), function ($method) {
  2180.                                                 return 'get' === substr($method03);
  2181.                                             });
  2182.                                             $userDataSingle = array();
  2183.                                             foreach ($getters as $getter) {
  2184.                                                 if ($getter == 'getCreatedAt' || $getter == 'getUpdatedAt' || $getter == 'getImage')
  2185.                                                     continue;
  2186. //                                if(is_string($user->{$getter}())|| is_numeric($user->{$getter}()))
  2187. //                                {
  2188. //                                    $userDataSingle[$getter]= $user->{$getter}();
  2189. //                                }
  2190.                                                 if ($user->{$getter}() instanceof \DateTime) {
  2191.                                                     $ggtd $user->{$getter}();
  2192.                                                     $userDataSingle[$getter] = $ggtd->format('Y-m-d');
  2193.                                                 } else
  2194.                                                     $userDataSingle[$getter] = $user->{$getter}();
  2195.                                             }
  2196. //                                                    $userDataSingle['getNid']=$Employee->getNid();
  2197. //                                                    $userDataSingle['getCurrAddr'] = $Employee->getCurrAddr();
  2198.                                             $userData[] = $userDataSingle;
  2199.                                         }
  2200.                                         $retDataDebug[$debugCount] = array(
  2201.                                             'skipSend' => $skipSend
  2202.                                         );
  2203.                                         {
  2204.                                             $urlToCall GeneralConstant::HONEYBEE_CENTRAL_SERVER '/SyncUserToCentralUser';
  2205.                                             $userFiles['userData'] = json_encode($userData);
  2206.                                             $curl curl_init();
  2207.                                             curl_setopt_array($curl, array(
  2208.                                                 CURLOPT_RETURNTRANSFER => 1,
  2209.                                                 CURLOPT_POST => 1,
  2210.                                                 CURLOPT_URL => $urlToCall,
  2211.                                                 CURLOPT_CONNECTTIMEOUT => 10,
  2212.                                                 CURLOPT_SSL_VERIFYPEER => false,
  2213.                                                 CURLOPT_SSL_VERIFYHOST => false,
  2214. //                            CURLOPT_SAFE_UPLOAD => false,
  2215.                                                 CURLOPT_HTTPHEADER => array(//                                "Accept: multipart/form-data",
  2216.                                                 ),
  2217.                                                 //                        CURLOPT_USERAGENT => 'InnoPM',
  2218. //                            CURLOPT_POSTFIELDS => array(
  2219. //                                'userData'=>json_encode($userData),
  2220. //                                'userFiles'=>$userFiles
  2221. //                            ),
  2222.                                                 CURLOPT_POSTFIELDS => $userFiles
  2223.                                             ));
  2224.                                             $retData curl_exec($curl);
  2225.                                             $errData curl_error($curl);
  2226.                                             curl_close($curl);
  2227.                                             $response = [];
  2228.                                             if ($errData) {
  2229.                                                 $response['status'] = 'error';
  2230.                                                 $response['message'] = 'cURL Error: ' $errData;
  2231.                                             } else {
  2232.                                                 $retDataObj json_decode($retDatatrue);
  2233.                                                 if (!$retDataObj) {
  2234.                                                     $response['status'] = 'error';
  2235.                                                     $response['message'] = 'Invalid response from central server';
  2236.                                                     $response['raw_response'] = $retData;
  2237.                                                 } else {
  2238.                                                     $response['status'] = 'success';
  2239.                                                     $response['data'] = $retDataObj;
  2240.                                                 }
  2241.                                             }
  2242. // Return JSON response
  2243. //                                                    return new JsonResponse($response);
  2244.                                             $retDataDebug[$debugCount] = $retDataObj;
  2245.                                             if (isset($retDataObj['globalIdsData']))
  2246.                                                 foreach ($retDataObj['globalIdsData'] as $app_id => $usrList) {
  2247.                                                     $connector $this->container->get('application_connector');
  2248.                                                     $connector->resetConnection(
  2249.                                                         'default',
  2250.                                                         $gocDataListByAppId[$app_id]['dbName'],
  2251.                                                         $gocDataListByAppId[$app_id]['dbUser'],
  2252.                                                         $gocDataListByAppId[$app_id]['dbPass'],
  2253.                                                         $gocDataListByAppId[$app_id]['dbHost'],
  2254.                                                         $reset true);
  2255.                                                     $em $this->getDoctrine()->getManager();
  2256.                                                     foreach ($usrList as $sys_id => $globaldata) {
  2257.                                                         $user $this->getDoctrine()
  2258.                                                             ->getRepository('ApplicationBundle:SysUser')
  2259.                                                             ->findOneBy(
  2260.                                                                 array(
  2261.                                                                     'userId' => $sys_id
  2262.                                                                 )
  2263.                                                             );
  2264.                                                         if ($user) {
  2265.                                                             $user->setGlobalId($globaldata['gid']);
  2266.                                                             $em->persist($user);
  2267.                                                             $em->flush();
  2268.                                                         }
  2269.                                                     }
  2270.                                                 }
  2271.                                         }
  2272.                                         $debugCount++;
  2273.                                     }
  2274.                                 }
  2275. //                    return new JsonResponse($retDataDebug);
  2276.                             }
  2277.                         }
  2278.                         $SysUserRepo $em->getRepository(SysUser::class);
  2279.                         $SysUser $SysUserRepo->findOneBy(array(
  2280.                             'email' => $request->request->get('email')
  2281.                         ));
  2282.                         $isSuccess->setUserId($SysUser->getUserId());
  2283.                         $em->persist($isSuccess);
  2284.                         $em->flush();
  2285.                         $companyData $message[2];
  2286.                         if ($message[0] == 'success' && GeneralConstant::EMAIL_ENABLED == 1) {
  2287.                             $bodyHtml '';
  2288.                             $bodyTemplate 'ApplicationBundle:email/user:registration.html.twig';
  2289.                             $bodyData = array(
  2290.                                 'name' => $request->request->get('name'),
  2291.                                 'companyData' => $companyData,
  2292.                                 'userName' => $request->request->get('username'),
  2293.                                 'password' => $request->request->get('password'),
  2294.                             );
  2295.                             $attachments = [];
  2296. //                    $upl_dir = $this->container->getParameter('kernel.root_dir') . '/../web/uploads/temp/' . 'ledger' . '.pdf'
  2297.                             $new_mail $this->get('mail_module');
  2298.                             $new_mail->sendMyMail(array(
  2299.                                 'senderHash' => '_CUSTOM_',
  2300.                                 //                        'senderHash'=>'_CUSTOM_',
  2301.                                 'forwardToMailAddress' => $request->request->get('email'),
  2302.                                 'subject' => 'User Registration on HoneyBee Ecosystem under Entity ' $companyData->getName(),
  2303.                                 'fileName' => '',
  2304.                                 'attachments' => $attachments,
  2305.                                 'toAddress' => $request->request->get('email'),
  2306.                                 'fromAddress' => 'no-reply@ourhoneybee.eu',
  2307.                                 'userName' => 'no-reply@ourhoneybee.eu',
  2308.                                 'password' => 'Y41dh8g0112',
  2309.                                 'smtpServer' => 'smtp.hostinger.com',
  2310.                                 'smtpPort' => 465,
  2311. //                        'fromAddress'=>'sales@entity.innobd.com',
  2312. //                        'userName'=>'sales@entity.innobd.com',
  2313. //                        'password'=>'Y41dh8g0112',
  2314. //                        'smtpServer'=>'smtp.hostinger.com',
  2315. //                        'smtpPort'=>587,
  2316. //                        'emailBody'=>$bodyHtml,
  2317.                                 'mailTemplate' => $bodyTemplate,
  2318.                                 'templateData' => $bodyData,
  2319.                                 'embedCompanyImage' => 1,
  2320.                                 'companyId' => $request->request->get('company'),
  2321.                                 'companyImagePath' => $companyData->getImage()
  2322.                             ));
  2323. //                  $emailmessage = (new \Swift_Message('Registration to Entity'))
  2324. //                    ->setFrom('registration@entity.innobd.com')
  2325. //                    ->setTo($data->request->get('email'))
  2326. //                    ->setBody(
  2327. //                      $this->renderView(
  2328. //                        'ApplicationBundle:email/user:registration.html.twig',
  2329. //                        array(
  2330. //                          'name' => $data->request->get('name'),
  2331. //                          'companyData' => $companyData,
  2332. //                          'userName' => $data->request->get('email'),
  2333. //                          'password' => $data->request->get('password'),
  2334. //                        )
  2335. //                      ),
  2336. //                      'text/html'
  2337. //                    );
  2338. //                  $this->get('mailer')->send($emailmessage);
  2339.                         }
  2340.                     }
  2341.                     // End Mailer function
  2342.                     $this->addFlash(
  2343.                         'success',
  2344.                         'New Employee Successfully Added!'
  2345.                     );
  2346.                     return $this->redirectToRoute('employee_list');
  2347.                 } else {
  2348.                     $this->addFlash(
  2349.                         'error',
  2350.                         'Something Went Wrong!'
  2351.                     );
  2352.                     return $this->redirectToRoute('add_employee');
  2353.                 }
  2354.             }
  2355.         } else {
  2356.             $this->addFlash(
  2357.                 'error',
  2358.                 'Invalid Approval Hash!'
  2359.             );
  2360.             return $this->redirectToRoute('add_employee');
  2361.         }
  2362.     }
  2363.     public function UpdateEmployeeAction(Request $request$id)
  2364.     {
  2365.     }
  2366.     private function uploadImage($image$request)
  2367.     {
  2368.         $upl_dir $this->container->getParameter('kernel.root_dir') . '/../web/uploads/Users/';
  2369.         $profileImage '';
  2370.         if ($image != null) {
  2371.             $fileName $request->request->get('firstname') . '.' $request->request->get('global_user_id') . '.' $image->guessExtension();
  2372.             $path $fileName;
  2373.             if (!file_exists($upl_dir)) {
  2374.                 mkdir($upl_dir0777true);
  2375.             }
  2376.             $image->move($upl_dir$path);
  2377.             $profileImage 'uploads/Users/' $path;
  2378.         }
  2379.         return $profileImage;
  2380.     }
  2381.     private function uploadMeetingFile($file$request)
  2382.     {
  2383.         $upl_dir $this->container->getParameter('kernel.root_dir') . '/../web/uploads/meeting/';
  2384.         $uploadedFilePath '';
  2385.         if ($file != null) {
  2386.             $fileName uniqid() . '.' $file->guessExtension();
  2387.             if (!file_exists($upl_dir)) {
  2388.                 mkdir($upl_dir0777true);
  2389.             }
  2390.             $file->move($upl_dir$fileName);
  2391.             $uploadedFilePath 'uploads/meeting/' $fileName;
  2392.         }
  2393.         return $uploadedFilePath;
  2394.     }
  2395.     public function OnboardEmployeeAction(Request $request)
  2396.     {
  2397.         $systemType $this->container->hasParameter('system_type') ? $this->container->getParameter('system_type') : '_ERP_';
  2398.         $email $request->request->get('email');
  2399.         $applicantId $request->request->get('applicant_id');
  2400.         $em $this->getDoctrine()->getManager();
  2401.         $session $request->getSession();
  2402.         $companyId $session->get('userCompanyId');
  2403.         $appId $session->get('userAppId');
  2404.         $urlToCall GeneralConstant::HONEYBEE_CENTRAL_SERVER '/get_applicant_data_central';
  2405.         $applicantFiles = [
  2406.             'email' => $email,
  2407.             'applicantId' => $applicantId
  2408.         ];
  2409.         $entityToken $em->getRepository('ApplicationBundle:EntityTokenStorage')
  2410.             ->findOneBy(['userId' => $applicantId]);
  2411.         $curl curl_init();
  2412.         curl_setopt_array($curl, array(
  2413.             CURLOPT_RETURNTRANSFER => 1,
  2414.             CURLOPT_POST => 1,
  2415.             CURLOPT_URL => $urlToCall,
  2416.             CURLOPT_CONNECTTIMEOUT => 10,
  2417.             CURLOPT_SSL_VERIFYPEER => false,
  2418.             CURLOPT_SSL_VERIFYHOST => false,
  2419.             CURLOPT_HTTPHEADER => array(),
  2420.             CURLOPT_POSTFIELDS => $applicantFiles
  2421.         ));
  2422.         $retData curl_exec($curl);
  2423.         $errData curl_error($curl);
  2424.         curl_close($curl);
  2425.         $retDataObj json_decode($retDatatrue);
  2426.         if (!isset($retDataObj['status']) || $retDataObj['status'] !== 'success') {
  2427.             return new JsonResponse([
  2428.                 'status' => 'error',
  2429.                 'message' => 'Failed to get applicant data from central server',
  2430.                 'response' => $retDataObj
  2431.             ]);
  2432.         }
  2433.         $centralData $retDataObj['centralData'];
  2434.         $em $this->getDoctrine()->getManager();
  2435.         $existingUser $em->getRepository('ApplicationBundle:SysUser')->findOneBy([
  2436.             'globalId' => $centralData['globalId']
  2437.         ]);
  2438.         if ($existingUser) {
  2439.             return new JsonResponse([
  2440.                 'status' => 'info',
  2441.                 'message' => 'User is already onboarded',
  2442.                 'userId' => $existingUser->getUserId(),
  2443.                 'redirectUrl' => 'dashboard'
  2444.             ]);
  2445.         }
  2446.         $sysUser = new SysUser();
  2447.         $sysUser->setGlobalId($centralData['globalId'] ?? '');
  2448.         $sysUser->setUsername($centralData['username'] ?? '');
  2449.         $sysUser->setEmail($centralData['email'] ?? '');
  2450.         $sysUser->setName($centralData['firstname'] ?? '');
  2451.         $sysUser->setUserType(1);
  2452.         $sysUser->setUserAppId($appId);
  2453.         $sysUser->setUserCompanyId($companyId);
  2454.         $sysUser->setStatus(1);
  2455.         $sysUser->setDefaultRoute('sales_dashboard');
  2456.         $em->persist($sysUser);
  2457.         $em->flush();
  2458.         $employee $em->getRepository('ApplicationBundle:Employee')
  2459.             ->findOneBy(
  2460.                 array(
  2461.                     'userId' => $sysUser->getUserId(),
  2462.                 )
  2463.             );
  2464.         if (!$employee) {
  2465.             $employee = new Employee();
  2466.             if ($sysUser->getUserId()) {
  2467.                 $employee->setEmail($sysUser->getEmail());
  2468.                 $employee->setFirstName($sysUser->getUsername());
  2469.                 $employee->setLastName($sysUser->getName());
  2470.                 $employee->setCompanyId($sysUser->getUserCompanyId());
  2471.                 $employee->setStatus(1);
  2472.                 $employee->setUserId($sysUser->getUserId());
  2473.                 $em->persist($employee);
  2474.                 $em->flush();
  2475.             } else {
  2476.                 return new JsonResponse([
  2477.                     'status' => 'error',
  2478.                     'message' => 'Missing employee data',
  2479.                 ]);
  2480.             }
  2481.         }
  2482.         $employeeDetails $em->getRepository('ApplicationBundle:EmployeeDetails')
  2483.             ->findOneBy([
  2484.                 'userId' => $sysUser->getUserId(),
  2485.             ]);
  2486.         if (!$employeeDetails) {
  2487.             $employeeDetails = new EmployeeDetails();
  2488.             if ($sysUser->getUserId() && $employee->getEmployeeId()) {
  2489.                 $employeeDetails->setId($employee->getEmployeeId());
  2490.                 $employeeDetails->setEmail($sysUser->getEmail());
  2491.                 $employeeDetails->setFirstName($sysUser->getUsername());
  2492.                 $employeeDetails->setLastName($sysUser->getName());
  2493.                 $employeeDetails->setUsername($sysUser->getUsername());
  2494.                 $employeeDetails->setUserId($sysUser->getUserId());
  2495.                 $employeeDetails->setEmpStatus(1);
  2496.                 $em->persist($employeeDetails);
  2497.                 $em->flush();
  2498.             } else {
  2499.                 return new JsonResponse([
  2500.                     'status' => 'error',
  2501.                     'message' => 'Missing employee details data',
  2502.                 ]);
  2503.             }
  2504.         }
  2505.         $company $em->getRepository('ApplicationBundle:Company')->find($companyId);
  2506.         $companyName $company $company->getName() : '';
  2507.         $newAccess = [
  2508.             'userType' => 2,
  2509.             'userTypeName' => UserConstants::$userTypeName[2],
  2510.             'globalId' => $applicantId,
  2511.             'serverId' => 1,
  2512.             'serverUrl' => $request->getSchemeAndHttpHost(),
  2513.             'serverPort' => 80,
  2514.             'systemType' => '_ERP_',
  2515.             'companyId' => 1,
  2516.             'appId' => $appId,
  2517.             'companyLogoUrl' => '/uploads/CompanyImage/company_image' $request->request->get('appId') . '.png',
  2518.             'companyName' => $companyName,
  2519.             'authenticationStr' => $this->get('url_encryptor')->encrypt(json_encode(
  2520.                     array(
  2521.                         'globalId' => $applicantId,
  2522.                         'appId' => $appId,
  2523.                         'authenticate' => 1,
  2524.                         'userType' => 2,
  2525.                         'userTypeName' => UserConstants::$userTypeName[2]
  2526.                     )
  2527.                 )
  2528.             ),
  2529.             'userCompanyList' => [],
  2530.         ];
  2531.         $urlToCall GeneralConstant::HONEYBEE_CENTRAL_SERVER '/update_token_storage';
  2532.         $curl curl_init();
  2533.         curl_setopt_array($curl, array(
  2534.             CURLOPT_RETURNTRANSFER => 1,
  2535.             CURLOPT_POST => 1,
  2536.             CURLOPT_URL => $urlToCall,
  2537.             CURLOPT_CONNECTTIMEOUT => 10,
  2538.             CURLOPT_SSL_VERIFYPEER => false,
  2539.             CURLOPT_SSL_VERIFYHOST => false,
  2540.             CURLOPT_HTTPHEADER => array(),
  2541.             CURLOPT_POSTFIELDS => json_encode($newAccess)
  2542.         ));
  2543.         $retData curl_exec($curl);
  2544.         $errData curl_error($curl);
  2545.         return new JsonResponse([
  2546.             'status' => 'success',
  2547.             'message' => 'User onboarded successfully',
  2548.             'redirectUlr' => 'dashboard',
  2549.             'returnData' => $retData,
  2550.             'errorData' => $errData
  2551.         ]);
  2552.     }
  2553.     public function DecodeQrAction(Request $request)
  2554.     {
  2555.         $applicantId $request->request->get('applicant_id');
  2556.         $urlToCall GeneralConstant::HONEYBEE_CENTRAL_SERVER '/get_applicant_data_central';
  2557.         $applicantFiles = [
  2558.             'applicantId' => $applicantId
  2559.         ];
  2560.         $curl curl_init();
  2561.         curl_setopt_array($curl, array(
  2562.             CURLOPT_RETURNTRANSFER => 1,
  2563.             CURLOPT_POST => 1,
  2564.             CURLOPT_URL => $urlToCall,
  2565.             CURLOPT_CONNECTTIMEOUT => 10,
  2566.             CURLOPT_SSL_VERIFYPEER => false,
  2567.             CURLOPT_SSL_VERIFYHOST => false,
  2568.             CURLOPT_HTTPHEADER => array(),
  2569.             CURLOPT_POSTFIELDS => $applicantFiles
  2570.         ));
  2571.         $retData curl_exec($curl);
  2572.         $errData curl_error($curl);
  2573.         curl_close($curl);
  2574.         $retDataObj json_decode($retDatatrue);
  2575.         return new JsonResponse($retDataObj['centralData']);
  2576.     }
  2577.     public function GetApplicantDataForErpAction(Request $request)
  2578.     {
  2579.         $applicantId $request->request->get('applicantId');
  2580.         if (!$applicantId) {
  2581.             return new JsonResponse([
  2582.                 'status' => 'error',
  2583.                 'message' => 'Missing applicantId in request.'
  2584.             ]);
  2585.         }
  2586.         $em_goc $this->getDoctrine()->getManager('company_group');
  2587.         $entityApplicant $em_goc->getRepository("CompanyGroupBundle:EntityApplicantDetails")
  2588.             ->findOneBy(['applicantId' => $applicantId]);
  2589.         if (!$entityApplicant) {
  2590.             return new JsonResponse([
  2591.                 'status' => 'error',
  2592.                 'message' => 'Applicant not found.'
  2593.             ]);
  2594.         }
  2595.         return new JsonResponse([
  2596.             'status' => 'success',
  2597.             'centralData' => [
  2598.                 'globalId' => $entityApplicant->getApplicantId(),
  2599.                 'username' => $entityApplicant->getUsername(),
  2600.                 'email' => $entityApplicant->getEmail(),
  2601.                 'firstname' => $entityApplicant->getFirstname(),
  2602.                 'lastname' => $entityApplicant->getLastname(),
  2603.                 'image' => $entityApplicant->getImage(),
  2604.                 'phone' => $entityApplicant->getPhone(),
  2605.                 'address' => $entityApplicant->getPermAddr()
  2606.             ]
  2607.         ]);
  2608.     }
  2609.     public function UpdateTokenStorageAction(Request $request)
  2610.     {
  2611.         $em_goc $this->getDoctrine()->getManager('company_group');
  2612.         $newAccess $request->request->all();
  2613.         $appId = isset($newAccess['appId']) ? $newAccess['appId'] : null;
  2614.         $globalId = isset($newAccess['globalId']) ? $newAccess['globalId'] : null;
  2615.         $sesssionData MiscActions::UpdateCompanyListInSession(
  2616.             $em_goc,
  2617.             $globalId,
  2618.             1,
  2619.             1,
  2620.             1,
  2621.             $newAccess
  2622.         );
  2623.         return new JsonResponse([
  2624.             'status' => 'success',
  2625.             'message' => 'Token storage updated',
  2626.             'newaccess' => $newAccess
  2627.         ]);
  2628.     }
  2629.     public function EmployeeListAction(Request $data)
  2630.     {
  2631.         $em $this->getDoctrine()->getManager();
  2632.         if ($data->isMethod('GET')) {
  2633.             return $this->render("ApplicationBundle:pages/human_resource/list:list_employee.html.twig", array(
  2634.                 'page_title' => 'Employee List',
  2635.             ));
  2636.         }
  2637.     }
  2638.     public function OrganizationChartAction()
  2639.     {
  2640.         $em $this->getDoctrine()->getManager();
  2641.         $Reponse HumanResource::TwigDataForOrgChart($em);
  2642.         return $this->render('ApplicationBundle:pages/human_resource/views:org_chart.html.twig', array(
  2643.             'page_title' => 'Organization Chart',
  2644.             'supervisors' => $Reponse['TreantJsData'],
  2645.             'alluser' => $Reponse['TreantJsInitUser']
  2646.         ));
  2647.     }
  2648.     public function EmployeeListSelectizeAjaxAction(Request $request$str '_EMPTY_')
  2649.     {
  2650.         $em $this->getDoctrine()->getManager();
  2651.         $companyId $this->getLoggedUserCompanyId($request);
  2652.         $company_data Company::getCompanyData($em$companyId);
  2653.         $data = [];
  2654.         $html '';
  2655.         $qryStrs explode(' '$str);
  2656.         $qryStrAddedForSpacedName "";
  2657.         if ($str == '_EMPTY_') {
  2658.             $query "SELECT *
  2659. from  employee  order by employee_id asc limit 10";
  2660.         } else {
  2661.             foreach ($qryStrs as $qryStr) {
  2662.                 $qryStrAddedForSpacedName .= "or first_name like '%$qryStr%' or last_name like '%$qryStr%' ";
  2663.             }
  2664.             $query "SELECT  *
  2665. 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";
  2666.         }
  2667.         $stmt $em->getConnection()->prepare($query);
  2668.         $stmt->execute();
  2669.         $res $stmt->fetchAll();
  2670. //    if(!empty($res)) {
  2671.         foreach ($res as $i => $r) {
  2672.             $res[$i]['id_padded'] = str_pad($r['employee_id'], 8'0'STR_PAD_LEFT);
  2673.         }
  2674. //    }
  2675.         return new JsonResponse(
  2676.             array(
  2677.                 'success' => true,
  2678.                 'data' => $res,
  2679.             )
  2680.         );
  2681.     }
  2682.     public function AttendanceAction(Request $data$remoteVerify 0)
  2683.     {
  2684.         $em $this->getDoctrine()->getManager();
  2685.         $em_goc $this->getDoctrine()->getManager('company_group');
  2686.         $session $data->getSession();
  2687. //        $token = $session->get(UserConstants::USER_TOKEN);
  2688. //        $providedToken = $data->headers->get('auth-token');
  2689. //
  2690. //        if (empty($providedToken) || $providedToken !== $token) {
  2691. //            return new JsonResponse([
  2692. //                'status' => 'error',
  2693. //                'message' => 'Token not match or missing',
  2694. //            ], 401);
  2695. //        }
  2696.         $workHourPolicy $em->getRepository('ApplicationBundle:WorkHourPolicy')->findAll();
  2697.         $options = array(
  2698.             'notification_enabled' => $this->container->getParameter('notification_enabled'),
  2699.             'notification_server' => $this->container->getParameter('notification_server'),
  2700.         );
  2701.         if ($data->get('DataTable')) {
  2702.             $response HumanResource::HandelAjaxRequestForManualAttendance($em$data);
  2703.             return new JsonResponse($response);
  2704.         }
  2705.         if ($data->request->get('getAttendanceStatus')) {
  2706.             $response HumanResource::getAttendanceStatus($em$data);
  2707.             return new JsonResponse($response);
  2708.         }
  2709. //        if ($session->get('devAdminMode', 0) != 1 && $data->get('returnJson', 0) == 0)
  2710. //            return $this->redirectToRoute('permission_denied_page');
  2711.         // Auto attendance
  2712.         if ($data->get('autoAttendance') && $data->request->has('position_array')) {
  2713. //            $empId = $data->query->get('id');
  2714.             $empId $data->request->get('id'$session->get(UserConstants::USER_EMPLOYEE_ID));
  2715.             $positionsArray $data->request->get('position_array', []);
  2716.             if (is_string($positionsArray)) $positionsArray json_decode($positionsArraytrue);
  2717.             if ($positionsArray == null$positionsArray = [];
  2718.             $dataByAttId = [];
  2719.             $workPlaceType '_UNSET_';
  2720.             foreach ($positionsArray as $d) {
  2721.                 $sysUserId 0;
  2722.                 $userId 0;
  2723.                 $empId 0;
  2724.                 $dtTs 0;
  2725.                 $timeZoneStr '+0000';
  2726. //                $timeZoneStr = '+0600';
  2727.                 $token '_unset_';
  2728.                 if (isset($d['token'])) $token $d['token'];
  2729.                 if (isset($d['employeeId'])) $empId $d['employeeId'];
  2730.                 if (isset($d['userId'])) $userId $d['userId'];
  2731.                 if (isset($d['sysUserId'])) $sysUserId $d['sysUserId'];
  2732.                 if (isset($d['tsMilSec'])) {
  2733.                     $dtTs ceil(($d['tsMilSec']) / 1000);
  2734.                 }
  2735.                 if ($token != '_unset_') {
  2736.                     $sessionData MiscActions::GetSessionDataFromToken($em_goc$token)['sessionData'];
  2737.                     if (isset($sessionData[UserConstants::USER_EMPLOYEE_ID]))
  2738.                         $empId $sessionData[UserConstants::USER_EMPLOYEE_ID];
  2739.                 }
  2740.                 if ($sysUserId == 0)
  2741.                     $sysUserId $userId;
  2742.                 if ($sysUserId == 0)
  2743.                     $sysUserId $em->getRepository(Employee::class)
  2744.                         ->findOneBy(['employeeId' => $empId])->getUserId();
  2745.                 if ($dtTs == 0) {
  2746.                     $currTsTime = new \DateTime();
  2747.                     $dtTs $currTsTime->format('U');
  2748.                 } else {
  2749.                     $currTsTime = new \DateTime('@' $dtTs);
  2750.                 }
  2751.                 $currTsTime->setTimezone(new \DateTimeZone('UTC'));
  2752.                 $attDate = new \DateTime($currTsTime->format('Y-m-d') . ' 00:00:00' $timeZoneStr);
  2753.                 $EmployeeAttendance $this->getDoctrine()
  2754.                     ->getRepository(EmployeeAttendance::class)
  2755.                     ->findOneBy(array('employeeId' => $empId'date' => $attDate));
  2756.                 if (!$EmployeeAttendance)
  2757.                     $EmployeeAttendance = new EmployeeAttendance;
  2758.                 $attendanceInfo HumanResource::StoreAttendance($em$empId$sysUserId$data$EmployeeAttendance$attDate$dtTs$timeZoneStr$d['markerId']);
  2759.                 if ($d['markerId'] == HumanResourceConstant::ATTENDANCE_MARKER_CLOCK_IN) {
  2760.                     if ($empId == 24)
  2761.                         $workPlaceType '_HYBRID_';
  2762.                     else
  2763.                         $workPlaceType '_STATIC_';
  2764.                 }
  2765.                 if (!isset($dataByAttId[$attendanceInfo->getId()]))
  2766.                     $dataByAttId[$attendanceInfo->getId()] = array(
  2767.                         'attendanceInfo' => $attendanceInfo,
  2768.                         'empId' => $empId,
  2769.                         'lat' => 0,
  2770.                         'lng' => 0,
  2771.                         'address' => 0,
  2772.                         'sysUserId' => $sysUserId,
  2773.                         'companyId' => $data->getSession()->get(UserConstants::USER_COMPANY_ID),
  2774.                         'appId' => $data->getSession()->get(UserConstants::USER_APP_ID),
  2775.                         'positionArray' => []
  2776.                     );
  2777.                 $posData = array(
  2778.                     'ts' => $dtTs,
  2779.                     'lat' => $d['lat'],
  2780.                     'lng' => $d['lng'],
  2781.                     'marker' => $d['markerId'],
  2782.                     'src' => 2,
  2783.                 );
  2784.                 $posDataArray = array(
  2785.                     $dtTs,
  2786.                     $d['lat'],
  2787.                     $d['lng'],
  2788.                     $d['markerId'],
  2789.                     2
  2790.                 );
  2791.                 $dataByAttId[$attendanceInfo->getId()]['markerId'] = $d['markerId'];
  2792.                 //this markerId will be calclulted and modified to check if user is in our out of office/workplace later
  2793.                 $dataByAttId[$attendanceInfo->getId()]['attendanceInfo'] = $attendanceInfo;
  2794.                 $dataByAttId[$attendanceInfo->getId()]['positionArray'][] = $posData;
  2795.                 $dataByAttId[$attendanceInfo->getId()]['lat'] = $d['lat'];  //for last lat lng etc
  2796.                 $dataByAttId[$attendanceInfo->getId()]['lng'] = $d['lng'];  //for last lat lng etc
  2797.                 if (isset($d['address']))
  2798.                     $dataByAttId[$attendanceInfo->getId()]['address'] = $d['address'];  //for last lat lng etc
  2799. //                $dataByAttId[$attendanceInfo->getId()]['positionArray'][]=$posDataArray;
  2800.             }
  2801.             $response = array(
  2802.                 'success' => true,
  2803.             );
  2804.             foreach ($dataByAttId as $attInfoId => $d) {
  2805.                 $response HumanResource::setAttendanceLogFlutterApp($em,
  2806.                     $d['empId'],
  2807.                     $d['sysUserId'],
  2808.                     $d['companyId'],
  2809.                     $d['appId'],
  2810.                     $data,
  2811.                     $d['attendanceInfo'],
  2812.                     $options,
  2813.                     $d['positionArray'],
  2814.                     $d['lat'],
  2815.                     $d['lng'],
  2816.                     $d['address'],
  2817.                     $d['markerId']
  2818.                 );
  2819.             }
  2820.             if ($data->request->get('requestFromMobile')) {
  2821.                 $today = new \DateTime(date('y-m-d'));
  2822.                 $repository $this->getDoctrine()->getRepository(EmployeeAttendance::class);
  2823.                 $ActivitiesTemplate HumanResource::getCurrentStatusFromDb($repository$empId$today);
  2824.                 return new JsonResponse(array(
  2825.                     'success' => $response['success'] == true true false,
  2826.                     'msg' => $response['success'] == true 'Employee activities successfully updated.' 'Action Failed',
  2827.                     'workPlaceType' => $workPlaceType,
  2828.                     'data' => $ActivitiesTemplate
  2829.                 ));
  2830.             }
  2831.             return new JsonResponse(
  2832.                 array(
  2833.                     'success' => true,
  2834.                     'msg' => 'Employee activities successfully updated.',
  2835.                     'workPlaceType' => $workPlaceType,
  2836.                 )
  2837.             );
  2838.         } else if ($data->get('autoAttendance')) {
  2839.             $sysUserId 0;
  2840.             $userId 0;
  2841.             $empId 0;
  2842.             $dtTs 0;
  2843. //            $timeZoneStr = '+0600';
  2844.             $timeZoneStr '+0000';
  2845.             if ($data->request->get('requestFromMobile')) {
  2846.                 $empId $data->request->get('employeeId');
  2847.                 $userId $data->request->get('userId'0);
  2848.                 $sysUserId $data->request->get('id'0);
  2849. //        $empId = $em->getRepository(Employee::class)
  2850. //            ->findOneBy(['userId' => $userId])->getEmployeeId();
  2851.             } else {
  2852.                 $empId $data->request->get('employeeId'0);
  2853.                 $sysUserId $data->request->get('userId'0);
  2854.             }
  2855.             $dtTs $data->request->get('timeTs'0);
  2856.             if ($sysUserId == 0)
  2857.                 $sysUserId $userId;
  2858.             if ($sysUserId == 0)
  2859.                 $sysUserId $em->getRepository(Employee::class)
  2860.                     ->findOneBy(['employeeId' => $empId])->getUserId();
  2861.             if ($dtTs == 0) {
  2862.                 $currTsTime = new \DateTime();
  2863.                 $dtTs $currTsTime->format('U');
  2864.             } else {
  2865.                 $currTsTime = new \DateTime('@' $dtTs);
  2866.             }
  2867.             if ($sysUserId == 0)
  2868.                 $sysUserId $userId;
  2869.             if ($sysUserId == 0)
  2870.                 $sysUserId $em->getRepository(Employee::class)
  2871.                     ->findOneBy(['employeeId' => $empId])->getUserId();
  2872.             $today = new \DateTime(date('y-m-d'));
  2873.             $currTsTime->setTimezone(new \DateTimeZone('UTC'));
  2874.             $attDate = new \DateTime($currTsTime->format('Y-m-d') . ' 00:00:00' $timeZoneStr);
  2875.             $EmployeeAttendance $this->getDoctrine()
  2876.                 ->getRepository(EmployeeAttendance::class)
  2877.                 ->findOneBy(array('employeeId' => $empId'date' => $attDate));
  2878.             if (!$EmployeeAttendance)
  2879.                 $EmployeeAttendance = new EmployeeAttendance;
  2880. //            return new JsonResponse(["success" => true, "data" => $ActivitiesTemplate]);
  2881. //            $attendanceInfo = HumanResource::StoreAttendance($em, $empId, $sysUserId, $data, $EmployeeAttendance, $customTime);
  2882.             $attendanceInfo HumanResource::StoreAttendance($em$empId$sysUserId$data$EmployeeAttendance$attDate$dtTs$timeZoneStrHumanResourceConstant::ATTENDANCE_MARKER_START_WORKING_FORCED);
  2883.             if (!isset($dataByAttId[$attendanceInfo->getId()]))
  2884.                 $dataByAttId[$attendanceInfo->getId()] = array(
  2885.                     'attendanceInfo' => $attendanceInfo,
  2886.                     'empId' => $empId,
  2887.                     'lat' => 0,
  2888.                     'lng' => 0,
  2889.                     'address' => 0,
  2890.                     'sysUserId' => $sysUserId,
  2891.                     'companyId' => $data->getSession()->get(UserConstants::USER_COMPANY_ID),
  2892.                     'appId' => $data->getSession()->get(UserConstants::USER_APP_ID),
  2893.                     'positionArray' => []
  2894.                 );
  2895.             $posData = array(
  2896.                 'ts' => $dtTs,
  2897.                 'lat' => 0,
  2898.                 'lng' => 0,
  2899.                 'marker' => HumanResourceConstant::ATTENDANCE_MARKER_START_WORKING_FORCED,
  2900.                 'src' => 1,
  2901.             );
  2902.             $posDataArray = array(
  2903.                 $dtTs,
  2904.                 0,
  2905.                 0,
  2906.                 HumanResourceConstant::ATTENDANCE_MARKER_START_WORKING_FORCED,
  2907.                 1
  2908.             );
  2909.             $dataByAttId[$attendanceInfo->getId()]['markerId'] = HumanResourceConstant::ATTENDANCE_MARKER_START_WORKING_FORCED;
  2910.             //this markerId will be calclulted and modified to check if user is in our out of office/workplace later
  2911.             $dataByAttId[$attendanceInfo->getId()]['attendanceInfo'] = $attendanceInfo;
  2912.             $dataByAttId[$attendanceInfo->getId()]['positionArray'][] = $posData;
  2913.             $dataByAttId[$attendanceInfo->getId()]['lat'] = 0;  //for last lat lng etc
  2914.             $dataByAttId[$attendanceInfo->getId()]['lng'] = 0;  //for last lat lng etc
  2915.             if (isset($d['address']))
  2916.                 $dataByAttId[$attendanceInfo->getId()]['address'] = '';  //for last lat lng etc
  2917.             $response = array(
  2918.                 'success' => true
  2919.             );
  2920.             foreach ($dataByAttId as $attInfoId => $d) {
  2921.                 $response HumanResource::setAttendanceLogFlutterApp($em,
  2922.                     $d['empId'],
  2923.                     $d['sysUserId'],
  2924.                     $d['companyId'],
  2925.                     $d['appId'],
  2926.                     $data,
  2927.                     $d['attendanceInfo'],
  2928.                     $options,
  2929.                     $d['positionArray'],
  2930.                     $d['lat'],
  2931.                     $d['lng'],
  2932.                     $d['address'],
  2933.                     $d['markerId']
  2934.                 );
  2935.             }
  2936.             if ($data->request->get('requestFromMobile')) {
  2937.                 return new JsonResponse(array(
  2938.                     'success' => $response['success'] == true true false,
  2939.                     'msg' => $response['success'] == true 'Employee activities successfully updated.' 'Action Failed',
  2940.                 ));
  2941.             }
  2942.             return new JsonResponse(
  2943.                 array(
  2944.                     'success' => true,
  2945.                     'dtTs' => $dtTs,
  2946.                     'attDate' => $attDate->format(DATE_RFC822),
  2947.                     'currTsTime' => $currTsTime->format(DATE_RFC822),
  2948.                     'msg' => 'Employee activities successfully updated.',
  2949.                 )
  2950.             );
  2951. //
  2952. //
  2953. //            $response = HumanResource::setAttendanceLog($em, $empId, $sysUserId,
  2954. //                $data->getSession()->get(UserConstants::USER_COMPANY_ID),
  2955. //                $data->getSession()->get(UserConstants::USER_APP_ID),
  2956. //                $data, $attendanceInfo, $options);
  2957. //
  2958. //            if ($data->request->get('requestFromMobile')) {
  2959. //                return new JsonResponse($response);
  2960. //            }
  2961. //
  2962. //            return new JsonResponse(
  2963. //                array(
  2964. //                    'success' => true,
  2965. //                    'msg' => 'Employee activities successfully updated.'
  2966. //                )
  2967. //            );
  2968.             // }
  2969.             // else {
  2970.             //   return new JsonResponse(
  2971.             //     array(
  2972.             //       'success' => false,
  2973.             //       'msg' => "Invalid employee ID"
  2974.             //     )
  2975.             //   );
  2976.             // }
  2977.         } else {
  2978.             if ($data->get('manualAttendance')) {
  2979.                 return $this->render(
  2980.                     'ApplicationBundle:pages/human_resource/input_forms:manual_attendance.html.twig',
  2981.                     array(
  2982.                         'page_title' => 'Manual Attendance',
  2983.                         'workPolicy' => $workHourPolicy,
  2984. //                        'workTime' => json_decode($workHourPolicy->getRepeatationData()),
  2985. //                        'workTime' => json_decode($workHourPolicy->getRepeatationData()),
  2986. //                        'workTime' => json_decode($workHourPolicy->getEmployeeTypeIds(),true),
  2987.                     )
  2988.                 );
  2989.             }
  2990.             // Show all matching employee list during ajax request
  2991.             // Show current location according to id
  2992.             if ($data->get('getCurrLocById')) {
  2993.                 $Id $data->get("id");
  2994.                 $options = array(
  2995.                     'employeeId' => $Id,
  2996.                     'entityDbaseName' => 'work_hour_policy',
  2997.                     'entityDbaseIdField' => 'id',
  2998.                     'entityDbaseEmployeeIdsField' => 'employeeIds',
  2999.                     'entityDesignationIdsField' => 'designationIds',
  3000.                     'entityDepartmentIdsField' => 'departmentIds',
  3001.                     'entityEmployeeTypeIdsField' => 'employee_types',
  3002.                     'limit' => 1,
  3003.                     'single' => 1,
  3004.                 );
  3005.                 $workHourPolicyData HumanResource::getApplicableSettingsDataForEmployee($em$options);
  3006.                 $today = new \DateTime(date('y-m-d'));
  3007.                 $repository $this->getDoctrine()->getRepository(EmployeeAttendance::class);
  3008.                 $ActivitiesTemplate HumanResource::getActivitiesTemplate($repository$Id$today);
  3009.                 return new JsonResponse(["success" => true"workHourPolicyData" => $workHourPolicyData"template" => $ActivitiesTemplate]);
  3010.             }
  3011.         }
  3012.     }
  3013.     public function AttendanceForAppAction(Request $data$remoteVerify 0)
  3014.     {
  3015.         $em $this->getDoctrine()->getManager();
  3016.         $em_goc $this->getDoctrine()->getManager('company_group');
  3017.         $session $data->getSession();
  3018.         $token $session->get(UserConstants::USER_TOKEN);
  3019.         $providedToken $data->headers->get('auth-token');
  3020.         if (empty($providedToken) || $providedToken !== $token) {
  3021.             return new JsonResponse([
  3022.                 'status' => 'error',
  3023.                 'message' => 'Token not match or missing',
  3024.             ], 401);
  3025.         }
  3026.         $workHourPolicy $em->getRepository('ApplicationBundle:WorkHourPolicy')->findAll();
  3027.         $options = array(
  3028.             'notification_enabled' => $this->container->getParameter('notification_enabled'),
  3029.             'notification_server' => $this->container->getParameter('notification_server'),
  3030.         );
  3031.         if ($data->get('DataTable')) {
  3032.             $response HumanResource::HandelAjaxRequestForManualAttendance($em$data);
  3033.             return new JsonResponse($response);
  3034.         }
  3035.         if ($data->request->get('getAttendanceStatus')) {
  3036.             $response HumanResource::getAttendanceStatus($em$data);
  3037.             return new JsonResponse($response);
  3038.         }
  3039. //        if ($session->get('devAdminMode', 0) != 1 && $data->get('returnJson', 0) == 0)
  3040. //            return $this->redirectToRoute('permission_denied_page');
  3041.         // Auto attendance
  3042.         if ($data->get('autoAttendance') && $data->request->has('position_array')) {
  3043. //            $empId = $data->query->get('id');
  3044.             $empId $data->request->get('id'$session->get(UserConstants::USER_EMPLOYEE_ID));
  3045.             $positionsArray $data->request->get('position_array', []);
  3046.             if (is_string($positionsArray)) $positionsArray json_decode($positionsArraytrue);
  3047.             if ($positionsArray == null$positionsArray = [];
  3048.             $dataByAttId = [];
  3049.             $workPlaceType '_UNSET_';
  3050.             foreach ($positionsArray as $d) {
  3051.                 $sysUserId 0;
  3052.                 $userId 0;
  3053.                 $empId 0;
  3054.                 $dtTs 0;
  3055.                 $timeZoneStr '+0000';
  3056. //                $timeZoneStr = '+0600';
  3057.                 $token '_unset_';
  3058.                 if (isset($d['token'])) $token $d['token'];
  3059.                 if (isset($d['employeeId'])) $empId $d['employeeId'];
  3060.                 if (isset($d['userId'])) $userId $d['userId'];
  3061.                 if (isset($d['sysUserId'])) $sysUserId $d['sysUserId'];
  3062.                 if (isset($d['tsMilSec'])) {
  3063.                     $dtTs ceil(($d['tsMilSec']) / 1000);
  3064.                 }
  3065.                 if ($token != '_unset_') {
  3066.                     $sessionData MiscActions::GetSessionDataFromToken($em_goc$token)['sessionData'];
  3067.                     if (isset($sessionData[UserConstants::USER_EMPLOYEE_ID]))
  3068.                         $empId $sessionData[UserConstants::USER_EMPLOYEE_ID];
  3069.                 }
  3070.                 if ($sysUserId == 0)
  3071.                     $sysUserId $userId;
  3072.                 if ($sysUserId == 0)
  3073.                     $sysUserId $em->getRepository(Employee::class)
  3074.                         ->findOneBy(['employeeId' => $empId])->getUserId();
  3075.                 if ($dtTs == 0) {
  3076.                     $currTsTime = new \DateTime();
  3077.                     $dtTs $currTsTime->format('U');
  3078.                 } else {
  3079.                     $currTsTime = new \DateTime('@' $dtTs);
  3080.                 }
  3081.                 $currTsTime->setTimezone(new \DateTimeZone('UTC'));
  3082.                 $attDate = new \DateTime($currTsTime->format('Y-m-d') . ' 00:00:00' $timeZoneStr);
  3083.                 $EmployeeAttendance $this->getDoctrine()
  3084.                     ->getRepository(EmployeeAttendance::class)
  3085.                     ->findOneBy(array('employeeId' => $empId'date' => $attDate));
  3086.                 if (!$EmployeeAttendance)
  3087.                     $EmployeeAttendance = new EmployeeAttendance;
  3088.                 $attendanceInfo HumanResource::StoreAttendance($em$empId$sysUserId$data$EmployeeAttendance$attDate$dtTs$timeZoneStr$d['markerId']);
  3089.                 if ($d['markerId'] == HumanResourceConstant::ATTENDANCE_MARKER_CLOCK_IN) {
  3090.                     if ($empId == 24)
  3091.                         $workPlaceType '_HYBRID_';
  3092.                     else
  3093.                         $workPlaceType '_STATIC_';
  3094.                 }
  3095.                 if (!isset($dataByAttId[$attendanceInfo->getId()]))
  3096.                     $dataByAttId[$attendanceInfo->getId()] = array(
  3097.                         'attendanceInfo' => $attendanceInfo,
  3098.                         'empId' => $empId,
  3099.                         'lat' => 0,
  3100.                         'lng' => 0,
  3101.                         'address' => 0,
  3102.                         'sysUserId' => $sysUserId,
  3103.                         'companyId' => $data->getSession()->get(UserConstants::USER_COMPANY_ID),
  3104.                         'appId' => $data->getSession()->get(UserConstants::USER_APP_ID),
  3105.                         'positionArray' => []
  3106.                     );
  3107.                 $posData = array(
  3108.                     'ts' => $dtTs,
  3109.                     'lat' => $d['lat'],
  3110.                     'lng' => $d['lng'],
  3111.                     'marker' => $d['markerId'],
  3112.                     'src' => 2,
  3113.                 );
  3114.                 $posDataArray = array(
  3115.                     $dtTs,
  3116.                     $d['lat'],
  3117.                     $d['lng'],
  3118.                     $d['markerId'],
  3119.                     2
  3120.                 );
  3121.                 $dataByAttId[$attendanceInfo->getId()]['markerId'] = $d['markerId'];
  3122.                 //this markerId will be calclulted and modified to check if user is in our out of office/workplace later
  3123.                 $dataByAttId[$attendanceInfo->getId()]['attendanceInfo'] = $attendanceInfo;
  3124.                 $dataByAttId[$attendanceInfo->getId()]['positionArray'][] = $posData;
  3125.                 $dataByAttId[$attendanceInfo->getId()]['lat'] = $d['lat'];  //for last lat lng etc
  3126.                 $dataByAttId[$attendanceInfo->getId()]['lng'] = $d['lng'];  //for last lat lng etc
  3127.                 if (isset($d['address']))
  3128.                     $dataByAttId[$attendanceInfo->getId()]['address'] = $d['address'];  //for last lat lng etc
  3129. //                $dataByAttId[$attendanceInfo->getId()]['positionArray'][]=$posDataArray;
  3130.             }
  3131.             $response = array(
  3132.                 'success' => true,
  3133.             );
  3134.             foreach ($dataByAttId as $attInfoId => $d) {
  3135.                 $response HumanResource::setAttendanceLogFlutterApp($em,
  3136.                     $d['empId'],
  3137.                     $d['sysUserId'],
  3138.                     $d['companyId'],
  3139.                     $d['appId'],
  3140.                     $data,
  3141.                     $d['attendanceInfo'],
  3142.                     $options,
  3143.                     $d['positionArray'],
  3144.                     $d['lat'],
  3145.                     $d['lng'],
  3146.                     $d['address'],
  3147.                     $d['markerId']
  3148.                 );
  3149.             }
  3150.             if ($data->request->get('requestFromMobile')) {
  3151.                 $today = new \DateTime(date('y-m-d'));
  3152.                 $repository $this->getDoctrine()->getRepository(EmployeeAttendance::class);
  3153.                 $ActivitiesTemplate HumanResource::getCurrentStatusFromDb($repository$empId$today);
  3154.                 return new JsonResponse(array(
  3155.                     'success' => $response['success'] == true true false,
  3156.                     'msg' => $response['success'] == true 'Employee activities successfully updated.' 'Action Failed',
  3157.                     'workPlaceType' => $workPlaceType,
  3158.                     'data' => $ActivitiesTemplate
  3159.                 ));
  3160.             }
  3161.             return new JsonResponse(
  3162.                 array(
  3163.                     'success' => true,
  3164.                     'msg' => 'Employee activities successfully updated.',
  3165.                     'workPlaceType' => $workPlaceType,
  3166.                 )
  3167.             );
  3168.         } else if ($data->get('autoAttendance')) {
  3169.             $sysUserId 0;
  3170.             $userId 0;
  3171.             $empId 0;
  3172.             $dtTs 0;
  3173. //            $timeZoneStr = '+0600';
  3174.             $timeZoneStr '+0000';
  3175.             if ($data->request->get('requestFromMobile')) {
  3176.                 $empId $data->request->get('employeeId');
  3177.                 $userId $data->request->get('userId'0);
  3178.                 $sysUserId $data->request->get('id'0);
  3179. //        $empId = $em->getRepository(Employee::class)
  3180. //            ->findOneBy(['userId' => $userId])->getEmployeeId();
  3181.             } else {
  3182.                 $empId $data->request->get('employeeId'0);
  3183.                 $sysUserId $data->request->get('userId'0);
  3184.             }
  3185.             $dtTs $data->request->get('timeTs'0);
  3186.             if ($sysUserId == 0)
  3187.                 $sysUserId $userId;
  3188.             if ($sysUserId == 0)
  3189.                 $sysUserId $em->getRepository(Employee::class)
  3190.                     ->findOneBy(['employeeId' => $empId])->getUserId();
  3191.             if ($dtTs == 0) {
  3192.                 $currTsTime = new \DateTime();
  3193.                 $dtTs $currTsTime->format('U');
  3194.             } else {
  3195.                 $currTsTime = new \DateTime('@' $dtTs);
  3196.             }
  3197.             if ($sysUserId == 0)
  3198.                 $sysUserId $userId;
  3199.             if ($sysUserId == 0)
  3200.                 $sysUserId $em->getRepository(Employee::class)
  3201.                     ->findOneBy(['employeeId' => $empId])->getUserId();
  3202.             $today = new \DateTime(date('y-m-d'));
  3203.             $currTsTime->setTimezone(new \DateTimeZone('UTC'));
  3204.             $attDate = new \DateTime($currTsTime->format('Y-m-d') . ' 00:00:00' $timeZoneStr);
  3205.             $EmployeeAttendance $this->getDoctrine()
  3206.                 ->getRepository(EmployeeAttendance::class)
  3207.                 ->findOneBy(array('employeeId' => $empId'date' => $attDate));
  3208.             if (!$EmployeeAttendance)
  3209.                 $EmployeeAttendance = new EmployeeAttendance;
  3210. //            return new JsonResponse(["success" => true, "data" => $ActivitiesTemplate]);
  3211. //            $attendanceInfo = HumanResource::StoreAttendance($em, $empId, $sysUserId, $data, $EmployeeAttendance, $customTime);
  3212.             $attendanceInfo HumanResource::StoreAttendance($em$empId$sysUserId$data$EmployeeAttendance$attDate$dtTs$timeZoneStrHumanResourceConstant::ATTENDANCE_MARKER_START_WORKING_FORCED);
  3213.             if (!isset($dataByAttId[$attendanceInfo->getId()]))
  3214.                 $dataByAttId[$attendanceInfo->getId()] = array(
  3215.                     'attendanceInfo' => $attendanceInfo,
  3216.                     'empId' => $empId,
  3217.                     'lat' => 0,
  3218.                     'lng' => 0,
  3219.                     'address' => 0,
  3220.                     'sysUserId' => $sysUserId,
  3221.                     'companyId' => $data->getSession()->get(UserConstants::USER_COMPANY_ID),
  3222.                     'appId' => $data->getSession()->get(UserConstants::USER_APP_ID),
  3223.                     'positionArray' => []
  3224.                 );
  3225.             $posData = array(
  3226.                 'ts' => $dtTs,
  3227.                 'lat' => 0,
  3228.                 'lng' => 0,
  3229.                 'marker' => HumanResourceConstant::ATTENDANCE_MARKER_START_WORKING_FORCED,
  3230.                 'src' => 1,
  3231.             );
  3232.             $posDataArray = array(
  3233.                 $dtTs,
  3234.                 0,
  3235.                 0,
  3236.                 HumanResourceConstant::ATTENDANCE_MARKER_START_WORKING_FORCED,
  3237.                 1
  3238.             );
  3239.             $dataByAttId[$attendanceInfo->getId()]['markerId'] = HumanResourceConstant::ATTENDANCE_MARKER_START_WORKING_FORCED;
  3240.             //this markerId will be calclulted and modified to check if user is in our out of office/workplace later
  3241.             $dataByAttId[$attendanceInfo->getId()]['attendanceInfo'] = $attendanceInfo;
  3242.             $dataByAttId[$attendanceInfo->getId()]['positionArray'][] = $posData;
  3243.             $dataByAttId[$attendanceInfo->getId()]['lat'] = 0;  //for last lat lng etc
  3244.             $dataByAttId[$attendanceInfo->getId()]['lng'] = 0;  //for last lat lng etc
  3245.             if (isset($d['address']))
  3246.                 $dataByAttId[$attendanceInfo->getId()]['address'] = '';  //for last lat lng etc
  3247.             $response = array(
  3248.                 'success' => true
  3249.             );
  3250.             foreach ($dataByAttId as $attInfoId => $d) {
  3251.                 $response HumanResource::setAttendanceLogFlutterApp($em,
  3252.                     $d['empId'],
  3253.                     $d['sysUserId'],
  3254.                     $d['companyId'],
  3255.                     $d['appId'],
  3256.                     $data,
  3257.                     $d['attendanceInfo'],
  3258.                     $options,
  3259.                     $d['positionArray'],
  3260.                     $d['lat'],
  3261.                     $d['lng'],
  3262.                     $d['address'],
  3263.                     $d['markerId']
  3264.                 );
  3265.             }
  3266.             if ($data->request->get('requestFromMobile')) {
  3267.                 return new JsonResponse(array(
  3268.                     'success' => $response['success'] == true true false,
  3269.                     'msg' => $response['success'] == true 'Employee activities successfully updated.' 'Action Failed',
  3270.                 ));
  3271.             }
  3272.             return new JsonResponse(
  3273.                 array(
  3274.                     'success' => true,
  3275.                     'dtTs' => $dtTs,
  3276.                     'attDate' => $attDate->format(DATE_RFC822),
  3277.                     'currTsTime' => $currTsTime->format(DATE_RFC822),
  3278.                     'msg' => 'Employee activities successfully updated.',
  3279.                 )
  3280.             );
  3281. //
  3282. //
  3283. //            $response = HumanResource::setAttendanceLog($em, $empId, $sysUserId,
  3284. //                $data->getSession()->get(UserConstants::USER_COMPANY_ID),
  3285. //                $data->getSession()->get(UserConstants::USER_APP_ID),
  3286. //                $data, $attendanceInfo, $options);
  3287. //
  3288. //            if ($data->request->get('requestFromMobile')) {
  3289. //                return new JsonResponse($response);
  3290. //            }
  3291. //
  3292. //            return new JsonResponse(
  3293. //                array(
  3294. //                    'success' => true,
  3295. //                    'msg' => 'Employee activities successfully updated.'
  3296. //                )
  3297. //            );
  3298.             // }
  3299.             // else {
  3300.             //   return new JsonResponse(
  3301.             //     array(
  3302.             //       'success' => false,
  3303.             //       'msg' => "Invalid employee ID"
  3304.             //     )
  3305.             //   );
  3306.             // }
  3307.         } else {
  3308.             if ($data->get('manualAttendance')) {
  3309.                 return $this->render(
  3310.                     'ApplicationBundle:pages/human_resource/input_forms:manual_attendance.html.twig',
  3311.                     array(
  3312.                         'page_title' => 'Manual Attendance',
  3313.                         'workPolicy' => $workHourPolicy,
  3314. //                        'workTime' => json_decode($workHourPolicy->getRepeatationData()),
  3315. //                        'workTime' => json_decode($workHourPolicy->getRepeatationData()),
  3316. //                        'workTime' => json_decode($workHourPolicy->getEmployeeTypeIds(),true),
  3317.                     )
  3318.                 );
  3319.             }
  3320.             // Show all matching employee list during ajax request
  3321.             // Show current location according to id
  3322.             if ($data->get('getCurrLocById')) {
  3323.                 $Id $data->get("id");
  3324.                 $options = array(
  3325.                     'employeeId' => $Id,
  3326.                     'entityDbaseName' => 'work_hour_policy',
  3327.                     'entityDbaseIdField' => 'id',
  3328.                     'entityDbaseEmployeeIdsField' => 'employeeIds',
  3329.                     'entityDesignationIdsField' => 'designationIds',
  3330.                     'entityDepartmentIdsField' => 'departmentIds',
  3331.                     'entityEmployeeTypeIdsField' => 'employee_types',
  3332.                     'limit' => 1,
  3333.                     'single' => 1,
  3334.                 );
  3335.                 $workHourPolicyData HumanResource::getApplicableSettingsDataForEmployee($em$options);
  3336.                 $today = new \DateTime(date('y-m-d'));
  3337.                 $repository $this->getDoctrine()->getRepository(EmployeeAttendance::class);
  3338.                 $ActivitiesTemplate HumanResource::getActivitiesTemplate($repository$Id$today);
  3339.                 return new JsonResponse(["success" => true"workHourPolicyData" => $workHourPolicyData"template" => $ActivitiesTemplate]);
  3340.             }
  3341.         }
  3342.     }
  3343.     public function getCurrentStatusAction($id)
  3344.     {
  3345.         $today = new \DateTime(date('y-m-d'));
  3346.         $repository $this->getDoctrine()->getRepository(EmployeeAttendance::class);
  3347.         $ActivitiesTemplate HumanResource::getCurrentStatusFromDb($repository$id$today);
  3348.         return new JsonResponse(["success" => true"data" => $ActivitiesTemplate]);
  3349.     }
  3350.     public function CurrentAttendanceAction(Request $data)
  3351.     {
  3352.         $em $this->getDoctrine()->getManager();
  3353.         $options = array(
  3354.             'notification_enabled' => $this->container->getParameter('notification_enabled'),
  3355.             'notification_server' => $this->container->getParameter('notification_server'),
  3356.         );
  3357.         if ($data->get('DataTable')) {
  3358.             $response HumanResource::HandelAjaxRequestForManualAttendance($em$data);
  3359.             return new JsonResponse($response);
  3360.         }
  3361.         if ($data->request->get('getAttendanceStatus')) {
  3362.             $response HumanResource::getAttendanceStatus($em$data);
  3363.             return new JsonResponse($response);
  3364.         }
  3365.         // Auto attendance
  3366.         if ($data->get('autoAttendance')) {
  3367.             $empId $data->query->get('id');
  3368.             $sysUserId 0;
  3369.             if ($data->get('requestFromMobile')) {
  3370.                 $sysUserId $data->request->get('id');
  3371.                 $empId $em->getRepository(Employee::class)
  3372.                     ->findOneBy(['userId' => $sysUserId])->getEmployeeId();
  3373.             } else {
  3374.                 $sysUserId $em->getRepository(Employee::class)
  3375.                     ->findOneBy(['employeeId' => $empId])->getUserId();
  3376.             }
  3377.             $customTime $data->get('time');
  3378.             $today = new \DateTime(date('y-m-d'));
  3379.             $EmployeeAttendance $this->getDoctrine()
  3380.                 ->getRepository(EmployeeAttendance::class)
  3381.                 ->findOneBy(array('employeeId' => $empId'date' => $today));
  3382.             if (!$EmployeeAttendance)
  3383.                 $EmployeeAttendance = new EmployeeAttendance;
  3384.             $attendanceInfo HumanResource::StoreAttendance($em$empId$sysUserId$data$EmployeeAttendance$customTime);
  3385.             $response HumanResource::setAttendanceLog($em$empId$sysUserId,
  3386.                 $data->getSession()->get(UserConstants::USER_COMPANY_ID),
  3387.                 $data->getSession()->get(UserConstants::USER_APP_ID),
  3388.                 $data$attendanceInfo$options);
  3389.             if ($data->get('requestFromMobile')) {
  3390.                 return new JsonResponse([$response]);
  3391.             }
  3392.             return new JsonResponse(
  3393.                 array(
  3394.                     'success' => true,
  3395.                     'msg' => 'Employee activities successfully updated.'
  3396.                 )
  3397.             );
  3398.             // }
  3399.             // else {
  3400.             //   return new JsonResponse(
  3401.             //     array(
  3402.             //       'success' => false,
  3403.             //       'msg' => "Invalid employee ID"
  3404.             //     )
  3405.             //   );
  3406.             // }
  3407.         } else {
  3408.             if ($data->get('manualAttendance')) {
  3409.                 return $this->render(
  3410.                     'ApplicationBundle:pages/human_resource/report:current_attendance.html.twig',
  3411.                     array(
  3412.                         'page_title' => 'Current Attendance Status',
  3413.                     )
  3414.                 );
  3415.             }
  3416.             // Show all matching employee list during ajax request
  3417.             // Show current location according to id
  3418.             if ($data->get('getCurrLocById')) {
  3419.                 $Id $data->get("id");
  3420.                 $today = new \DateTime(date('y-m-d'));
  3421.                 $repository $this->getDoctrine()->getRepository(EmployeeAttendance::class);
  3422.                 $ActivitiesTemplate HumanResource::getActivitiesTemplate($repository$Id$today);
  3423.                 return new JsonResponse(["success" => true"template" => $ActivitiesTemplate]);
  3424.             }
  3425.         }
  3426.     }
  3427.     public function EmployeeLeaveAction(Request $data$id 0)
  3428.     {
  3429.         $em $this->getDoctrine()->getManager();
  3430.         $request $data;
  3431.         if (!$id) {
  3432.             if ($data->isMethod('GET')) {
  3433.                 $EmpID $data->query->get('id');
  3434.                 $LeaveType $data->query->get('leaveType');
  3435.                 if ($data->query->has('id') && $data->query->has('leaveType')) {
  3436.                     $response HumanResource::HandelAjaxRequestForLeaveApp($em$EmpID$LeaveType);
  3437.                     return new JsonResponse($response);
  3438.                 }
  3439.                 if ($data->query->has('id')) {
  3440.                     $Response HumanResource::HandelAjaxRequestForLeaveApp($em$EmpID);
  3441.                     return new JsonResponse($Response);
  3442.                 }
  3443.                 $TemplateData HumanResource::TwigDataForLeaveApp($emFalse);
  3444.                 return $this->render(
  3445.                     'ApplicationBundle:pages/human_resource/input_forms:employee_leave.html.twig',
  3446.                     array(
  3447.                         'page_title' => $TemplateData['Title'],
  3448.                         'EmployeeList' => $TemplateData['EmployeeList'],
  3449.                         'DesignationList' => $TemplateData['DesignationList'],
  3450.                         'HasUpdateMode' => false
  3451.                     )
  3452.                 );
  3453.             } else {
  3454.                 $CompanyId $this->getLoggedUserCompanyId($data);
  3455.                 $Response HumanResource::StoreDataForLeaveApplication($em$id$datafalse$CompanyId);
  3456.                 if ($Response['HasErr']) {
  3457.                     $this->addFlash('error'$Response['msg']);
  3458.                     if ($data->request->has('returnJson')) {
  3459.                         return new JsonResponse(array(
  3460.                             'success' => false,
  3461.                             'errorStr' => $Response['msg'],
  3462.                         ));
  3463.                     } else {
  3464.                         return $this->redirectToRoute('employee_leave');
  3465.                     }
  3466.                 }
  3467.                 $applicationId $Response['applicationId'];
  3468.                 $em_goc $this->getDoctrine()->getManager('company_group');
  3469.                 $file_path_list = [];
  3470.                 if ($applicationId != 0) {
  3471.                     if (!empty($request->files)) {
  3472.                         MiscActions::RemoveFilesForEntityDoc($em_goc'EmployeeLeaveApplication'$applicationId);
  3473.                         $storePath 'uploads/LeaveDoc/';
  3474.                         $path "";
  3475.                         $file_path "";
  3476.                         $session $request->getSession();
  3477.                         MiscActions::RemoveExpiredFiles($em_goc);
  3478.                         foreach ($request->files as $uploadedFileGG) {
  3479.                             //            if($uploadedFile->getImage())
  3480.                             //                var_dump($uploadedFile->getFile());
  3481.                             //                var_dump($uploadedFile);
  3482.                             $tempD $uploadedFileGG;
  3483.                             if (!is_array($uploadedFileGG)) {
  3484.                                 $uploadedFileGG = array();
  3485.                                 $uploadedFileGG[] = $tempD;
  3486.                             }
  3487.                             foreach ($uploadedFileGG as $uploadedFile) {
  3488.                                 if ($uploadedFile != null) {
  3489.                                     $extension $uploadedFile->guessExtension();
  3490.                                     $size $uploadedFile->getSize();
  3491.                                     $fileName 'LDOC_' $applicationId '_' . (md5(uniqid())) . '.' $uploadedFile->guessExtension();
  3492.                                     $path $fileName;
  3493.                                     $upl_dir $this->container->getParameter('kernel.root_dir') . '/../web/' $storePath;
  3494.                                     if (!file_exists($upl_dir)) {
  3495.                                         mkdir($upl_dir0777true);
  3496.                                     }
  3497.                                     if (file_exists($upl_dir '' $path)) {
  3498.                                         chmod($upl_dir '' $path0755);
  3499.                                         unlink($upl_dir '' $path);
  3500.                                     }
  3501.                                     $file $uploadedFile->move($upl_dir$path);
  3502.                                     $expireNever 1;
  3503.                                     $expireTs 0;
  3504.                                     $EntityFile = new EntityFile();
  3505.                                     $EntityFile->setPath($this->container->getParameter('kernel.root_dir') . '/../web/' $storePath $path);
  3506.                                     $EntityFile->setMarker('_GEN_');
  3507.                                     $EntityFile->setExtension($extension);
  3508.                                     $EntityFile->setExpireTs($expireTs);
  3509.                                     $EntityFile->setSize($size);
  3510.                                     $EntityFile->setRelativePath($storePath $path);
  3511.                                     $EntityFile->setEntityName('EmployeeLeaveApplication');
  3512.                                     $EntityFile->setEntityBundle('EmployeeLeaveApplication');
  3513.                                     $EntityFile->setEntityId($applicationId);
  3514.                                     $EntityFile->setEntityIdField('employeeLeaveApplicationId');
  3515.                                     $EntityFile->setModifyFieldSetter('setFiles');
  3516.                                     $EntityFile->setDocIdForApplicant(0);
  3517.                                     $EntityFile->setUserId($session->get(UserConstants::USER_ID0));
  3518.                                     $EntityFile->setAppId($session->get(UserConstants::USER_APP_ID0));
  3519.                                     $EntityFile->setEmployeeId($session->get(UserConstants::USER_EMPLOYEE_ID0));
  3520.                                     $EntityFile->setUserType($session->get(UserConstants::USER_TYPE0));
  3521.                                     $em_goc->persist($EntityFile);
  3522.                                     $em_goc->flush();
  3523.                                     $EntityFileId $EntityFile->getId();
  3524.                                 }
  3525.                                 if ($path != "")
  3526.                                     $file_path_list[] = ($storePath $path);
  3527.                             }
  3528.                         }
  3529.                         $g_path $this->container->getParameter('kernel.root_dir') . '/../web/' $storePath $path;
  3530.                         $v $em->getRepository('ApplicationBundle:EmployeeLeaveApplication')->findOneBy(array(
  3531.                             'employeeLeaveApplicationId' => $applicationId,
  3532.                         ));
  3533.                         if ($v) {
  3534.                             $v->setFiles(implode(','$file_path_list));
  3535.                             $em->flush();
  3536.                         } else {
  3537.                         }
  3538.                     }
  3539.                 }
  3540.                 // $this->addFlash('success', 'Application submitted successfully!');
  3541.                 // return $this->redirectToRoute('leave_application_list');
  3542.                 if ($data->request->has('returnJson')) {
  3543.                     return new JsonResponse(array(
  3544.                         'success' => true,
  3545.                     ));
  3546.                 } else {
  3547.                     return $this->redirectToRoute('view_employee_leave_application', array('id' => $applicationId));
  3548.                 }
  3549.             }
  3550.         } else {
  3551.             if ($data->isMethod('GET')) {
  3552.                 $ApplicationRepo $em->getRepository(EmployeeLeaveApplication::class);
  3553.                 $OldData $ApplicationRepo->find(array('employeeLeaveApplicationId' => $id));
  3554.                 $TemplateData HumanResource::TwigDataForLeaveApp($em$OldData);
  3555.                 return $this->render(
  3556.                     'ApplicationBundle:pages/human_resource/input_forms:employee_leave.html.twig',
  3557.                     array(
  3558.                         'page_title' => $TemplateData['Title'],
  3559.                         'EmployeeList' => $TemplateData['EmployeeList'],
  3560.                         'DesignationList' => $TemplateData['DesignationList'],
  3561.                         'OldData' => $TemplateData['OldData'],
  3562.                         'AvailableLeave' => $TemplateData['AvailableLeave'],
  3563.                         'HasUpdateMode' => true
  3564.                     )
  3565.                 );
  3566.             } else {
  3567.                 $CompanyId $this->getLoggedUserCompanyId($data);
  3568.                 $Response HumanResource::StoreDataForLeaveApplication($em$id$datatrue$CompanyId);
  3569.                 if ($Response['HasErr']) {
  3570.                     $this->addFlash('error'$Response['msg']);
  3571.                     return $this->redirectToRoute('employee_leave');
  3572.                 }
  3573.                 $this->addFlash('success'"Application updated successfully!");
  3574.                 return $this->redirectToRoute('leave_application_list');
  3575.             }
  3576.         }
  3577.     }
  3578.     public function ViewLeaveApplicationAction(Request $request$id)
  3579.     {
  3580.         $em $this->getDoctrine()->getManager();
  3581.         if ($id) {
  3582.             $TwigData HumanResource::TwigDataForViewLeaveApplication($em$request$id);
  3583.             if ($TwigData['HasErr']) {
  3584.                 return new JsonResponse(array(
  3585.                     'success' => false,
  3586.                     'msg' => $TwigData['Msg']
  3587.                 ));
  3588.             }
  3589.             return $this->render(
  3590.                 'ApplicationBundle:pages/human_resource/views:leave_application_view.html.twig',
  3591.                 array(
  3592.                     'page_title' => 'View Leave Application',
  3593.                     'Applicant' => $TwigData['Applicant'],
  3594.                     'Application' => $TwigData['Application'],
  3595.                     'LeaveType' => $TwigData['LeaveType'],
  3596.                     'LeaveCategory' => $TwigData['LeaveCategory'],
  3597.                     'leaveDataArray' => $TwigData['leaveDataArray'],
  3598.                     'FrwdEmp' => $TwigData['FrwdEmp'],
  3599.                     'ApplicantDesg' => $TwigData['ApplicantDesg'],
  3600.                     'approval_status' => $TwigData['approval_status'],
  3601.                     'approval_data' => $TwigData['approval_data'],
  3602.                     'document_log' => $TwigData['document_log'],
  3603.                     'auto_created' => 0,
  3604.                 )
  3605.             );
  3606.         }
  3607.         return new JsonResponse(array(
  3608.             'success' => false,
  3609.             'msg' => 'Wrong URL format! Please try with application ID'
  3610.         ));
  3611.     }
  3612.     public function PrintLeaveApplicationAction(Request $request$id)
  3613.     {
  3614.         if ($id) {
  3615.             $em $this->getDoctrine()->getManager();
  3616.             $company_data Company::getCompanyData($em1);
  3617.             $Authorizations System::getSignatureListForDocumentPrint($emarray_flip(GeneralConstant::$Entity_list)['EmployeeLeaveApplication'], $id);
  3618.             $TwigData HumanResource::TwigDataForViewLeaveApplication($em$request$id);
  3619.             if ($TwigData['HasErr']) {
  3620.                 return new JsonResponse(array(
  3621.                     'success' => false,
  3622.                     'msg' => $TwigData['Msg']
  3623.                 ));
  3624.             }
  3625.             $ApplicationCategory $TwigData['Application']->getLeaveCategory();
  3626.             $ApplicationType = ($ApplicationCategory != && $ApplicationCategory != 2) ? $TwigData['LeaveType'] : '';
  3627.             return $this->render(
  3628.                 'ApplicationBundle:pages/human_resource/print:leave_application_print.html.twig',
  3629.                 array(
  3630.                     'page_title' => 'Print Leave Application',
  3631.                     'export' => 'pdf,print',
  3632.                     'company_name' => $company_data->getName(),
  3633.                     'company_data' => $company_data,
  3634.                     'company_address' => $company_data->getAddress(),
  3635.                     'company_image' => $company_data->getImage(),
  3636.                     'Authorizations' => $Authorizations,
  3637.                     'ApplicationType' => $ApplicationType,
  3638.                     'ApplicationCategory' => $ApplicationCategory,
  3639.                     'Applicant' => $TwigData['Applicant'],
  3640.                     'Application' => $TwigData['Application'],
  3641.                     'LeaveType' => $TwigData['LeaveType'],
  3642.                     'LeaveCategory' => $TwigData['LeaveCategory'],
  3643.                     'leaveDataArray' => $TwigData['leaveDataArray'],
  3644.                     'FrwdEmp' => $TwigData['FrwdEmp'],
  3645.                     'ApplicantDesg' => $TwigData['ApplicantDesg'],
  3646.                     'approval_status' => $TwigData['approval_status'],
  3647.                     'approval_data' => $TwigData['approval_data'],
  3648.                     'document_log' => $TwigData['document_log'],
  3649.                     'red' => 0,
  3650.                     'invoice_footer' => 0
  3651.                 )
  3652.             );
  3653.         }
  3654.         return new JsonResponse(array(
  3655.             'success' => false,
  3656.             'msg' => 'Wrong URL format! Please try with application ID'
  3657.         ));
  3658.     }
  3659.     public function LeaveApplicationListAction(Request $request)
  3660.     {
  3661.         $em $this->getDoctrine()->getManager();
  3662.         $response HumanResource::GetEmployeeLeaveApplicationList($em$request);
  3663.         if ($request->isMethod('GET')) {
  3664.             return $this->render("ApplicationBundle:pages/human_resource/list:leave_application_list.html.twig", array(
  3665.                 'page_title' => 'Leave Application List',
  3666.                 'application_data' => $response,
  3667.             ));
  3668.         }
  3669.     }
  3670.     public function PayrollPolicySettingsAction(Request $request$id)
  3671.     {
  3672.         $em $this->getDoctrine()->getManager();
  3673.         $CompanyId $this->getLoggedUserCompanyId($request);
  3674.         if ($id) {
  3675.             if ($request->isMethod('GET')) {
  3676.                 $Row $em->getRepository(PayrollPolicy::class)->find($id);
  3677.                 if (!$Row) {
  3678.                     $this->addFlash('error''Invalid Payroll Policy Id');
  3679.                     return $this->redirectToRoute('payroll_policy_settings');
  3680.                 }
  3681.                 $TwigData HumanResource::GetPayrollPolicyTwigData($em);
  3682.                 $OldData HumanResource::GetPayrollPolicyTwigData($em$id);
  3683.                 return $this->render('ApplicationBundle:pages/human_resource/input_forms:payroll_policy_settings.html.twig', array(
  3684.                     'page_title' => 'Update Payroll Policy Settings',
  3685.                     'EmployeeIds' => $TwigData['EmployeeIds'],
  3686.                     'EmployeeType' => $TwigData['EmployeeType'],//
  3687.                     'department' => $TwigData['department'],
  3688.                     'Designation' => $TwigData['Designation'],
  3689.                     'WorkingDays' => $TwigData['WorkingDays'],
  3690.                     'OldData' => $OldData['Row'],
  3691.                     'earningAspects' => HumanResourceConstant::$earningAspectsForPayrollPolicy,
  3692.                     'leaveTypes' => HumanResourceConstant::$LeaveTypeForPayrollPolicy,
  3693.                     'leaveTypesArray' => HumanResourceConstant::$LeaveTypeArrayForPayrollPolicy,
  3694.                     'deductionAspects' => HumanResourceConstant::$deductionAspects,
  3695.                     'deductionCondition' => json_decode($Row->getDeductionCondition(), true),
  3696.                     'HasUpdateMode' => true,
  3697.                 ));
  3698.             } else {
  3699.                 $Response HumanResource::StorePayrollPolicyData($em$id$CompanyId$request);
  3700.                 if ($Response['HasErr']) {
  3701.                     $this->addFlash('error'$Response['msg']);
  3702.                     return $this->redirectToRoute('payroll_policy_settings');
  3703.                 }
  3704.                 return $this->redirectToRoute('payroll_policy_settings');
  3705. //        if ($Response['isSuccess']) {
  3706. //          return new JsonResponse(array('success' => true, 'msg' => 'don\'t forget to redirect'));
  3707. //        }
  3708. //        return new JsonResponse(array('success' => false, 'msg' => 'Sorry something went wrong'));
  3709.             }
  3710.         } else {
  3711.             if ($request->isMethod('GET')) {
  3712.                 if ($request->query->get('GetDocHash')) {
  3713.                     $Dochash HumanResource::GenerateDocHashForPayrollSettings($em$request);
  3714.                     return new JsonResponse($Dochash);
  3715.                 }
  3716.                 $TwigData HumanResource::GetPayrollPolicyTwigData($em);
  3717.                 return $this->render(
  3718.                     'ApplicationBundle:pages/human_resource/input_forms:payroll_policy_settings.html.twig',
  3719.                     array(
  3720.                         'page_title' => 'Create Payroll Policy Settings',
  3721.                         'EmployeeIds' => $TwigData['EmployeeIds'],
  3722.                         'EmployeeType' => $TwigData['EmployeeType'],
  3723.                         'WorkingDays' => $TwigData['WorkingDays'],
  3724.                         'Designation' => $TwigData['Designation'],
  3725.                         'department' => $TwigData['department'],
  3726.                         'earningAspects' => HumanResourceConstant::$earningAspectsForPayrollPolicy,
  3727.                         'leaveTypes' => HumanResourceConstant::$LeaveTypeForPayrollPolicy,
  3728.                         'leaveTypesArray' => HumanResourceConstant::$LeaveTypeArrayForPayrollPolicy,
  3729.                         'deductionAspects' => HumanResourceConstant::$deductionAspects,
  3730.                         'HasUpdateMode' => false
  3731.                     )
  3732.                 );
  3733.             } else {
  3734.                 $Response HumanResource::StorePayrollPolicyData($em$id$CompanyId$request);
  3735.                 if ($Response['HasErr']) {
  3736.                     $this->addFlash('error'$Response['msg']);
  3737.                     return $this->redirectToRoute('payroll_policy_settings');
  3738.                 }
  3739.                 return $this->redirectToRoute('payroll_policy_settings');
  3740. //        return new JsonResponse(array("success" => true, 'msg' => 'Dont forget to redirect!'));
  3741.             }
  3742.         }
  3743.     }
  3744.     public function AttendanceReportAction(Request $request$apiKey 'impose')
  3745.     {
  3746.         $em $this->getDoctrine()->getManager();
  3747.         $attendanceSource HumanResourceConstant::$attendanceSources;
  3748.         $routeName $request->attributes->get('_route');
  3749.         if ($routeName == 'app_get_attendendance_data') {
  3750.             $ReportData HumanResource::GenerateAttendanceReport($em$request$request->get('considerCurrTsIfNoOut'1));
  3751.             $newReports = [];
  3752.             foreach ($ReportData['Reports'] as $gg) {
  3753.                 foreach ($gg as $d) {
  3754.                     $newReports[] = $d;
  3755. //                if(!isset($newReports[$d['id']]))
  3756. //                    $newReports[$d['id']]=array();
  3757. //                    $newReports[$d['id']][]=$d;
  3758.                 }
  3759.             }
  3760.             return new JsonResponse (array(
  3761.                 'attendanceSource' => $attendanceSource,
  3762. //                'Reports' => $ReportData['Reports'],
  3763.                 'Reports' => $newReports,
  3764.                 'from_date' => $ReportData['from_date'],
  3765.                 'to_date' => $ReportData['to_date'],
  3766.                 'report_for' => $ReportData['generated_for'],
  3767.                 'attendance' => $ReportData['attendance'],
  3768.             ));
  3769.         } else {
  3770.             $EmployeeIds $em->getRepository(EmployeeDetails::class)->findAll();
  3771.             $Departments $em->getRepository(SysDepartment::class)->findAll();
  3772.             if ($request->isMethod('GET')) {
  3773.                 return $this->render('ApplicationBundle:pages/human_resource/report:attendance_report.html.twig', array(
  3774.                     'page_title' => 'Attendance Report',
  3775.                     'employes' => $EmployeeIds,
  3776.                     'departments' => $Departments,
  3777.                     'isMethodGet' => true,
  3778.                     'from_date' => '',
  3779.                     'to_date' => '',
  3780.                     'report_for' => '',
  3781.                     'attendance' => [],
  3782.                     'Reports' => [],
  3783.                     'qry' => ''
  3784.                 ));
  3785.             }
  3786.             $ReportData HumanResource::GenerateAttendanceReport($em$request$request->request->get('considerCurrTsIfNoOut'0));
  3787.             if ($request->request->get('returnJson'0) == 1) {
  3788.                 return new JsonResponse($ReportData);
  3789.             }
  3790.             $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') : []));
  3791.             return $this->render('ApplicationBundle:pages/human_resource/report:attendance_report.html.twig', array(
  3792.                 'page_title' => 'Attendance Report',
  3793.                 'isMethodGet' => false,
  3794.                 'departments' => $Departments,
  3795.                 'employes' => $EmployeeIds,
  3796.                 'attendanceSource' => $attendanceSource,
  3797.                 'Reports' => $ReportData['Reports'],
  3798.                 'from_date' => $ReportData['from_date'],
  3799.                 'to_date' => $ReportData['to_date'],
  3800.                 'report_for' => $ReportData['generated_for'],
  3801.                 'attendance' => $ReportData['attendance'],
  3802.                 'qry' => $Qry
  3803.             ));
  3804.         }
  3805.     }
  3806.     public function PrintAttendanceReportAction(Request $request)
  3807.     {
  3808.         $em $this->getDoctrine()->getManager();
  3809.         $company_data Company::getCompanyData($em1);
  3810.         $ReportData HumanResource::GenerateAttendanceReport($em$request);
  3811.         return $this->render(
  3812.             'ApplicationBundle:pages/human_resource/print:print_attendance_report.html.twig',
  3813.             array(
  3814.                 'page_title' => 'Print Attendance Report',
  3815.                 'export' => 'pdf,print',
  3816.                 'company_name' => $company_data->getName(),
  3817.                 'company_data' => $company_data,
  3818.                 'company_address' => $company_data->getAddress(),
  3819.                 'company_image' => $company_data->getImage(),
  3820.                 'Reports' => $ReportData['Reports'],
  3821.                 'from_date' => $ReportData['from_date'],
  3822.                 'to_date' => $ReportData['to_date'],
  3823.                 'report_for' => $ReportData['generated_for'],
  3824.                 'attendance' => $ReportData['attendance'],
  3825.                 'red' => 0
  3826.             )
  3827.         );
  3828.     }
  3829.     public function DisburseSalaryAction(Request $request)
  3830.     {
  3831.         $em $this->getDoctrine()->getManager();
  3832.         $EmployeeIds $em->getRepository(EmployeeDetails::class)->findBy(
  3833.             array(
  3834.                 'emp_status' => 1
  3835.             )
  3836.         );
  3837.         $startDate $request->get('salary_start_date''');
  3838.         $endDate $request->get('salary_till_date''');
  3839.         $filterType $request->get('filterType'1);
  3840.         $filterBranchIds $request->get('branchIds', []);
  3841.         $filterBankIds $request->get('bankIds', []);
  3842.         $filterDepartmentIds $request->get('departmentIds', []);
  3843.         $filterEmployeeIds $request->get('employeeIds', []);
  3844.         $Departments $em->getRepository(SysDepartment::class)->findAll();
  3845.         $attendance $em->getRepository(EmployeeAttendanceLog::class)->findAll();
  3846.         $banks $em->getRepository(BankList::class)->findAll();
  3847.         $branches $em->getRepository(Branch::class)->findAll();
  3848.         if ($request->isMethod('GET')) {
  3849.             return $this->render('ApplicationBundle:pages/human_resource/report:disburse_salary.html.twig', array(
  3850.                 'page_title' => 'Disburse Salary',
  3851.                 'EmployeeIds' => $EmployeeIds,
  3852.                 'departments' => $Departments,
  3853.                 'attendance' => $attendance,
  3854.                 'branches' => $branches,
  3855.                 'banks' => $banks,
  3856.                 'SalaryReports' => [],
  3857.                 'from_date' => '',
  3858.                 'to_date' => '',
  3859.                 'Qry' => '',
  3860.                 'isMethodGet' => true,
  3861.                 'filterType' => $filterType,
  3862.                 'startDate' => $startDate,
  3863.                 'endDate' => $endDate,
  3864.                 'filterBranchIds' => $filterBranchIds,
  3865.                 'filterBankIds' => $filterBankIds,
  3866.                 'filterDepartmentIds' => $filterDepartmentIds,
  3867.                 'filterEmployeeIds' => $filterEmployeeIds,
  3868.             ));
  3869.         }
  3870.         $SalaryReports HumanResource::BasicDeduction($em$request);
  3871. //        $SalaryReportsNew = HumanResource::calculateSalary($em,
  3872. //            array(
  3873. //                'startDate' => $request->get('salary_start_date', ''),
  3874. //                'endDate' => $request->get('salary_end_date', ''),
  3875. //                'timeZone' => $request->get('time_zone', '+0600'),
  3876. //                'employeeIds' => $request->get('employeeIds', []),
  3877. //                'departmentIds' => $request->get('department', []),
  3878. //                'allFlag' => $request->get('show_all', 0),
  3879. //
  3880. //            )
  3881. //        );
  3882.         $Qry "salary_till_date=" $endDate '&' "departmentIds=" implode(','$filterDepartmentIds) . '&' "employeeIds=" implode(','$filterEmployeeIds) .
  3883.             '&' "salary_start_date=" $startDate .
  3884.             '&' "filterType=" $filterType .
  3885.             '&' "branchIds=" implode(','$filterBranchIds) .
  3886.             '&' "bankIds=" implode(','$filterBankIds);
  3887. //        if ($request->get('returnJson', 0) == 1) {
  3888.         if ($request->get('returnJson'0) == 1) {
  3889.             return new JsonResponse(array(
  3890.                 'SalaryReports' => $SalaryReports,
  3891.             ));
  3892.         } else {
  3893.             return $this->render('ApplicationBundle:pages/human_resource/report:disburse_salary.html.twig', array(
  3894.                 'page_title' => 'Disburse Salary',
  3895.                 'EmployeeIds' => $EmployeeIds,
  3896.                 'departments' => $Departments,
  3897.                 'branches' => $branches,
  3898.                 'banks' => $banks,
  3899.                 'SalaryReports' => $SalaryReports,
  3900.                 'for_month' => $SalaryReports[0]['for_month'],
  3901.                 'from_date' => $SalaryReports[0]['from_date'],
  3902.                 'to_date' => $SalaryReports[0]['to_date'],
  3903.                 'Qry' => $Qry,
  3904.                 'isMethodGet' => false,
  3905.                 'startDate' => $startDate,
  3906.                 'endDate' => $endDate,
  3907.                 'filterType' => $filterType,
  3908.                 'filterBranchIds' => $filterBranchIds,
  3909.                 'filterBankIds' => $filterBankIds,
  3910.                 'filterDepartmentIds' => $filterDepartmentIds,
  3911.                 'filterEmployeeIds' => $filterEmployeeIds,
  3912.             ));
  3913.         }
  3914.     }
  3915.     public function PrintDisburseSalaryAction(Request $Req)
  3916.     {
  3917.         $em $this->getDoctrine()->getManager();
  3918.         $company_data Company::getCompanyData($em1);
  3919.         $SalaryReports HumanResource::BasicDeduction($em$Req);
  3920.         return $this->render(
  3921.             'ApplicationBundle:pages/human_resource/print:print_disburse_salary.html.twig',
  3922.             array(
  3923.                 'page_title' => 'Print Disburse Salary',
  3924.                 'export' => 'pdf,print',
  3925.                 'company_name' => $company_data->getName(),
  3926.                 'company_data' => $company_data,
  3927.                 'company_address' => $company_data->getAddress(),
  3928.                 'company_image' => $company_data->getImage(),
  3929.                 'SalaryReports' => $SalaryReports,
  3930.                 'for_month' => $SalaryReports[0]['for_month'],
  3931.                 'from_date' => $SalaryReports[0]['from_date'],
  3932.                 'to_date' => $SalaryReports[0]['to_date'],
  3933.                 'red' => 0
  3934.             )
  3935.         );
  3936.     }
  3937.     public function SalaryReportAction(Request $request)
  3938.     {
  3939.         $em $this->getDoctrine()->getManager();
  3940.         $startDate $request->get('salary_start_date''');
  3941.         $endDate $request->get('salary_till_date''');
  3942.         $segregationType $request->get('segregationType'1);
  3943.         $filterBranchIds $request->get('branchIds', []);
  3944.         $filterBankIds $request->get('bankIds', []);
  3945.         $approvalFilterTypes $request->get('approvalFilterTypes', []);
  3946.         $filterDepartmentIds $request->get('departmentIds', []);
  3947.         $filterEmployeeIds $request->get('employeeIds', []);
  3948.         $Departments $em->getRepository(SysDepartment::class)->findAll();
  3949.         $attendance $em->getRepository(EmployeeAttendanceLog::class)->findAll();
  3950.         $banks $em->getRepository(BankList::class)->findAll();
  3951.         $branches $em->getRepository(Branch::class)->findAll();
  3952.         $SalaryReports HumanResource::GenerateSalaryReport($em$request);
  3953. //        dump($SalaryReports);
  3954.         $Qry "salary_till_date=" $endDate '&' "departmentIds=" implode(','$filterDepartmentIds) . '&' "employeeIds=" implode(','$filterEmployeeIds) .
  3955.             '&' "salary_start_date=" $startDate .
  3956.             '&' "segregationType=" $segregationType .
  3957.             '&' "branchIds=" implode(','$filterBranchIds) .
  3958.             '&' "bankIds=" implode(','$filterBankIds);
  3959. //        if ($request->get('returnJson', 0) == 1) {
  3960.         if ($request->get('returnJson'0) == 1) {
  3961.             return new JsonResponse(array(
  3962.                 'SalaryReports' => $SalaryReports,
  3963.             ));
  3964.         } else {
  3965.             return $this->render('ApplicationBundle:pages/human_resource/report:salary_report.html.twig', array(
  3966.                 'page_title' => 'Salary Report',
  3967.                 'departments' => $Departments,
  3968.                 'branches' => $branches,
  3969.                 'banks' => $banks,
  3970.                 'approvalFilterTypes' => $approvalFilterTypes,
  3971.                 'salaryInfo' => $SalaryReports,
  3972.                 'SalaryReports' => $SalaryReports,
  3973.                 'for_month' => '',
  3974.                 'from_date' => $startDate,
  3975.                 'to_date' => $endDate,
  3976.                 'Qry' => $Qry,
  3977.                 'isMethodGet' => false,
  3978.                 'startDate' => $startDate,
  3979.                 'endDate' => $endDate,
  3980.                 'segregationType' => $segregationType,
  3981.                 'filterBranchIds' => $filterBranchIds,
  3982.                 'filterBankIds' => $filterBankIds,
  3983.                 'filterDepartmentIds' => $filterDepartmentIds,
  3984.                 'filterEmployeeIds' => $filterEmployeeIds,
  3985.             ));
  3986.         }
  3987.     }
  3988.     public function createJobRecruitmentAction(Request $request$id 0)
  3989.     {
  3990.         $data = [];
  3991.         $em_goc $this->getDoctrine()->getManager('company_group');
  3992.         $skillDetails $em_goc->getRepository(EntitySkill::class)->findAll();
  3993.         $em $this->getDoctrine()->getManager();
  3994.         $companyId $this->getLoggedUserCompanyId($request);
  3995.         if ($request->isMethod('POST')) {
  3996.             $em $this->getDoctrine()->getManager();
  3997.             $entity_id array_flip(GeneralConstant::$Entity_list)['JobRecruitment']; //change
  3998.             $dochash $request->request->get('docHash'); //change
  3999.             $loginId $request->getSession()->get(UserConstants::USER_LOGIN_ID);
  4000.             $approveRole $request->request->get('approvalRole');
  4001.             $approveHash $request->request->get('approvalHash');
  4002.             if (!DocValidation::isInsertable($em$entity_id$dochash,
  4003.                 $loginId$approveRole$approveHash$id)
  4004.             ) {
  4005.                 $this->addFlash(
  4006.                     'error',
  4007.                     'Sorry Could not insert Data.'
  4008.                 );
  4009.             } else {
  4010.                 $data $request->request;
  4011.                 $docId HumanResource::createJobRecruitment($em$loginId$id$data$companyId);
  4012.                 //now add Approval info
  4013.                 $approveRole $request->request->get('approvalRole');
  4014.                 $options = array(
  4015.                     'notification_enabled' => $this->container->getParameter('notification_enabled'),
  4016.                     'notification_server' => $this->container->getParameter('notification_server'),
  4017.                     'appId' => $request->getSession()->get(UserConstants::USER_APP_ID),
  4018.                     'url' => $this->generateUrl(
  4019.                         GeneralConstant::$Entity_list_details[array_flip(GeneralConstant::$Entity_list)['JobRecruitment']]
  4020.                         ['entity_view_route_path_name']
  4021.                     )
  4022.                 );
  4023.                 System::setApprovalInfo($this->getDoctrine()->getManager(), $options,
  4024.                     array_flip(GeneralConstant::$Entity_list)['JobRecruitment'],
  4025.                     $docId,
  4026.                     $request->getSession()->get(UserConstants::USER_LOGIN_ID)    //journal voucher
  4027.                 );
  4028.                 System::createEditSignatureHash($this->getDoctrine()->getManager(), array_flip(GeneralConstant::$Entity_list)['JobRecruitment'],
  4029.                     $docId,
  4030.                     $loginId,
  4031.                     $approveRole,
  4032.                     $request->request->get('approvalHash'));
  4033.                 $this->addFlash(
  4034.                     'success',
  4035.                     'New Recruitment Document Added.'
  4036.                 );
  4037.                 $url $this->generateUrl(
  4038.                     'view_job_recruitment'
  4039.                 );
  4040.                 return $this->redirect($url "/" $docId);
  4041.             }
  4042.         }
  4043.         if ($id == 0) {
  4044.         } else {
  4045.             $extDoc $em->getRepository('ApplicationBundle:JobRecruitment')->findOneBy(
  4046.                 array(
  4047.                     'jobRecruitmentId' => $id///material
  4048.                 )
  4049.             );
  4050.             //now if its not editable, redirect to view
  4051.             if ($extDoc) {
  4052.                 if ($extDoc->getEditFlag() != 1) {
  4053.                     $url $this->generateUrl(
  4054.                         'view_job_recruitment'
  4055.                     );
  4056.                     return $this->redirect($url "/" $id);
  4057.                 }
  4058.             }
  4059.         }
  4060.         $jobType HumanResourceConstant::$employeeType;
  4061.         //$skillDetails = $em->getRepository(Skill::class)->findAll();
  4062.         $educationDetails $em->getRepository('ApplicationBundle:EducationQualification')->findAll();
  4063.         $employeeIds $em->getRepository('ApplicationBundle:Employee')->findAll();
  4064.         $location HumanResourceConstant::$location;
  4065.         $salaryPer HumanResourceConstant::$salaryPer;
  4066.         $workExperience HumanResourceConstant::$workExperience;
  4067.         $jobOpeningStatus HumanResourceConstant::$jobOpeningStatus;
  4068.         $compatibility HumanResourceConstant::$compatibility;
  4069.         return $this->render('ApplicationBundle:pages/human_resource/input_forms:create_new_job_post.html.twig', [
  4070.             'page_title' => 'Create New Job Post',
  4071.             'jobType' => $jobType,
  4072.             'skillDetails' => $skillDetails,
  4073.             'educationDetails' => $educationDetails,
  4074.             'employeeIds' => $employeeIds,
  4075.             'location' => $location,
  4076.             'salaryPer' => $salaryPer,
  4077.             'workExperience' => $workExperience,
  4078.             'jobOpeningStatus' => $jobOpeningStatus,
  4079.             'compatibility' => $compatibility
  4080.         ]);
  4081.     }
  4082.     public function viewApplicantInfoAction(Request $request$id)
  4083.     {
  4084.         $em $this->getDoctrine()->getManager('company_group');
  4085.         //$session = $request->getSession();
  4086.         $consultantDetails $em->getRepository(EntityApplicantDetails::class)->find($id);
  4087.         $skillDetails $em->getRepository('CompanyGroupBundle:EntitySkill')->findAll();
  4088.         //$companyId = $this->getLoggedUserCompanyId($request);
  4089.         $gender HumanResourceConstant::$sex;
  4090.         $blood HumanResourceConstant::$BloodGroup;
  4091.         //$userId = $session->get(UserConstants::USER_ID);
  4092.         return $this->render('ApplicationBundle:pages/human_resource/views:view_applicant_info.html.twig', [
  4093.             'page_title' => 'Applicant Information',
  4094.             'gender' => $gender,
  4095.             'blood' => $blood,
  4096.             'consultantDetails' => $consultantDetails,
  4097.             'education' => json_decode($consultantDetails->getEducationData(), true),
  4098.             'workExperience' => json_decode($consultantDetails->getWorkExperienceData(), true),
  4099.             'certificate' => json_decode($consultantDetails->getCertificateData(), true),
  4100.             'courses' => json_decode($consultantDetails->getCoursesData(), true),
  4101.             'languages' => json_decode($consultantDetails->getLanguagesData(), true),
  4102.             'skillDetails' => $skillDetails
  4103.         ]);
  4104.     }
  4105.     public function ListJobRecruitmentAction()
  4106.     {
  4107.         $em $this->getDoctrine()->getManager();
  4108.         $jobRecruitmentList = [];
  4109.         $jobRecruitments $em->getRepository('ApplicationBundle:JobRecruitment')->findAll();
  4110.         foreach ($jobRecruitments as $jobRecruitment) {
  4111.             $jobData = array(
  4112.                 'jobRecruitmentId' => $jobRecruitment->getJobRecruitmentId(),
  4113.                 'title' => $jobRecruitment->getTitle(),
  4114.                 'date' => $jobRecruitment->getDate(),
  4115.                 'jobOpeningStatus' => $jobRecruitment->getJobOpeningStatus(),
  4116.                 'applicationOpeningDate' => $jobRecruitment->getApplicationOpeningDate(),
  4117.                 'applicationClosingDate' => $jobRecruitment->getApplicationClosingDate(),
  4118.             );
  4119.             $jobRecruitmentList[] = $jobData;
  4120.         }
  4121.         return $this->render('ApplicationBundle:pages/human_resource/list:job_recruitment_list.html.twig', [
  4122.             'page_title' => 'Job RecruitmentAction List',
  4123.             'jobRecruitments' => $jobRecruitmentList
  4124.         ]);
  4125.     }
  4126.     public function ViewJobRecruitmentAction(Request $request$id 0)
  4127.     {
  4128.         $em_goc $this->getDoctrine()->getManager('company_group');
  4129.         $skillDetails $em_goc->getRepository('CompanyGroupBundle:EntitySkill')->findAll();
  4130.         $em $this->getDoctrine()->getManager();
  4131.         $companyId $this->getLoggedUserCompanyId($request);
  4132.         $company_data Company::getCompanyData($em$companyId);
  4133. //        return new JsonResponse($encryptedDataArray);
  4134.         $location HumanResourceConstant::$location;
  4135.         $salaryPer HumanResourceConstant::$salaryPer;
  4136.         $workExperience HumanResourceConstant::$workExperience;
  4137.         $jobOpeningStatus HumanResourceConstant::$jobOpeningStatus;
  4138.         $compatibility HumanResourceConstant::$compatibility;
  4139.         $jobType HumanResourceConstant::$employeeType;
  4140.         $educationDetail $em->getRepository(EducationQualification::class)->findAll();
  4141.         $jobRecruitments $em->getRepository('ApplicationBundle:JobRecruitment')->find($id);
  4142.         $em_goc $this->getDoctrine()->getManager('company_group');
  4143.         $applicantApplicationList $em_goc->getRepository("CompanyGroupBundle:EntityApplicantApplicationList")->findBy(
  4144.             array(
  4145.                 'jobPostId' => $id,
  4146.                 'CompanyId' => $companyId,
  4147.                 'appId' => $company_data->getAppId()
  4148.             )
  4149.         );
  4150.         $applicantIdList = [];
  4151.         foreach ($applicantApplicationList as $dt) {
  4152.             $applicantIdList[] = $dt->getApplicantId();
  4153.         }
  4154.         $applicantList ApplicantM::getApplicantList($em_goc$applicantIdList);
  4155.         $Approval_data = [
  4156.             'exists' => 0,
  4157.             'approvalId' => 0,
  4158.             'roleType' => 0,
  4159.             'required' => 0,
  4160.             'acted' => 0,
  4161.             'entity' => array_flip(GeneralConstant::$Entity_list)['JobRecruitment'],
  4162.             'entityId' => $id,
  4163.         ];
  4164.         if (in_array($request->getSession()->get(UserConstants::USER_TYPE), [125]))
  4165.             $Approval_data System::checkIfApprovalExists(
  4166.                 $em,
  4167.                 array_flip(GeneralConstant::$Entity_list)['JobRecruitment'],
  4168.                 $id,
  4169.                 $request->getSession()->get(UserConstants::USER_LOGIN_ID)
  4170.             );
  4171.         return $this->render('ApplicationBundle:pages/human_resource/views:view_job_recruitment.html.twig', [
  4172.             'page_title' => 'View Job RecruitmentAction',
  4173.             'jobRecruitments' => $jobRecruitments,
  4174.             'applicantApplicationList' => $applicantApplicationList,
  4175.             'applicantList' => $applicantList,
  4176. //            'encryptedData' => $encryptedData,
  4177.             'skills' => json_decode($jobRecruitments->getskills()),
  4178.             'skillDetails' => $skillDetails,
  4179.             'education' => json_decode($jobRecruitments->getEducations()),
  4180.             'educationDetails' => $educationDetail,
  4181.             'location' => $location,
  4182.             'salaryPer' => $salaryPer,
  4183.             'workExperience' => $workExperience,
  4184.             'jobType' => $jobType,
  4185.             'compatibility' => $compatibility,
  4186.             'approval_status' => $jobRecruitments->getApproved(),
  4187.             'jobOpeningStatus' => $jobOpeningStatus,
  4188.             'approval_data' => $Approval_data,
  4189.             'auto_created' => $jobRecruitments->getAutocreated(),
  4190.             'document_log' => $jobRecruitments->getAutocreated() == System::getDocumentLog(
  4191.                 $em,
  4192.                 array_flip(GeneralConstant::$Entity_list)['JobRecruitment'],
  4193.                 $id,
  4194.                 $jobRecruitments->getCreatedLoginId(),
  4195.                 $jobRecruitments->getEditedLoginId()
  4196.             ) : []
  4197.         ]);
  4198.     }
  4199.     public function ViewApplicantScheduleAction(Request $request$id 0)
  4200.     {
  4201.         $em $this->getDoctrine()->getManager();
  4202.         $companyId $this->getLoggedUserCompanyId($request);
  4203.         $company_data Company::getCompanyData($em$companyId);
  4204.         $em_goc $this->getDoctrine()->getManager('company_group');
  4205.         $applicantApplicationList $em_goc->getRepository("CompanyGroupBundle:EntityApplicantApplicationList")->findBy(
  4206.             array(
  4207.                 'jobPostId' => $id,
  4208.                 'CompanyId' => $companyId,
  4209.                 'appId' => $company_data->getAppId()
  4210.             )
  4211.         );
  4212.         $applicantIdList = [];
  4213.         foreach ($applicantApplicationList as $dt) {
  4214.             $applicantIdList[] = $dt->getApplicantId();
  4215.         }
  4216.         $applicantList ApplicantM::getApplicantList($em_goc$applicantIdList);
  4217.         return $this->render('ApplicationBundle:pages/human_resource/views:view_applicant_scheduled.html.twig', [
  4218.             'page_title' => 'View Applicant Scheduled',
  4219.             'applicantApplicationList' => $applicantApplicationList,
  4220.             'applicantList' => $applicantList,
  4221.         ]);
  4222.     }
  4223.     public function ViewApplicantReportAction(Request $request$id 0)
  4224.     {
  4225.         $em $this->getDoctrine()->getManager();
  4226.         $companyId $this->getLoggedUserCompanyId($request);
  4227.         $company_data Company::getCompanyData($em$companyId);
  4228.         $em_goc $this->getDoctrine()->getManager('company_group');
  4229.         $applicantApplicationList $em_goc->getRepository("CompanyGroupBundle:EntityApplicantApplicationList")->findBy(
  4230.             array(
  4231.                 'jobPostId' => $id,
  4232.                 'CompanyId' => $companyId,
  4233.                 'appId' => $company_data->getAppId()
  4234.             )
  4235.         );
  4236.         $applicantIdList = [];
  4237.         foreach ($applicantApplicationList as $dt) {
  4238.             $applicantIdList[] = $dt->getApplicantId();
  4239.         }
  4240.         $applicantList ApplicantM::getApplicantList($em_goc$applicantIdList);
  4241.         return $this->render('ApplicationBundle:pages/human_resource/views:view_applicant_report.html.twig', [
  4242.             'page_title' => 'View Applicant Report',
  4243.             'applicantApplicationList' => $applicantApplicationList,
  4244.             'applicantList' => $applicantList,
  4245.         ]);
  4246.     }
  4247.     public function createEmployeePerformanceEvaluationAction(Request $request$id 0)
  4248.     {
  4249.         $data = [];
  4250.         $em $this->getDoctrine()->getManager();
  4251.         $companyId $this->getLoggedUserCompanyId($request);
  4252.         if ($request->isMethod('POST')) {
  4253.             $em $this->getDoctrine()->getManager();
  4254.             $entity_id array_flip(GeneralConstant::$Entity_list)['EmployeePerformanceEvolution']; //change
  4255.             $dochash $request->request->get('docHash'); //change
  4256.             $loginId $request->getSession()->get(UserConstants::USER_LOGIN_ID);
  4257.             $approveRole $request->request->get('approvalRole');
  4258.             $approveHash $request->request->get('approvalHash');
  4259.             if (!DocValidation::isInsertable($em$entity_id$dochash,
  4260.                 $loginId$approveRole$approveHash$id)
  4261.             ) {
  4262.                 $this->addFlash(
  4263.                     'error',
  4264.                     'Sorry Could not insert Data.'
  4265.                 );
  4266.             } else {
  4267.                 $data $request->request;
  4268.                 $docId HumanResource::createEmployeePerformanceEvaluation($em$loginId$id$data$companyId);
  4269.                 //now add Approval info
  4270.                 $approveRole $request->request->get('approvalRole');
  4271.                 $options = array(
  4272.                     'notification_enabled' => $this->container->getParameter('notification_enabled'),
  4273.                     'notification_server' => $this->container->getParameter('notification_server'),
  4274.                     'appId' => $request->getSession()->get(UserConstants::USER_APP_ID),
  4275.                     'url' => $this->generateUrl(
  4276.                         GeneralConstant::$Entity_list_details[array_flip(GeneralConstant::$Entity_list)['EmployeePerformanceEvolution']]
  4277.                         ['entity_view_route_path_name']
  4278.                     )
  4279.                 );
  4280.                 System::setApprovalInfo($this->getDoctrine()->getManager(), $options,
  4281.                     array_flip(GeneralConstant::$Entity_list)['JobRecruitment'],
  4282.                     $docId,
  4283.                     $request->getSession()->get(UserConstants::USER_LOGIN_ID)    //journal voucher
  4284.                 );
  4285.                 System::createEditSignatureHash($this->getDoctrine()->getManager(), array_flip(GeneralConstant::$Entity_list)['EmployeePerformanceEvolution'],
  4286.                     $docId,
  4287.                     $loginId,
  4288.                     $approveRole,
  4289.                     $request->request->get('approvalHash'));
  4290.                 $this->addFlash(
  4291.                     'success',
  4292.                     'New Recruitment Document Added.'
  4293.                 );
  4294.                 $url $this->generateUrl(
  4295.                     'view_employee_performance_evolution'
  4296.                 );
  4297.                 return $this->redirect($url "/" $docId);
  4298.             }
  4299.         }
  4300.         $skill $em->getRepository(Skill::class)->findAll();
  4301.         $educationDetail $em->getRepository(EducationQualification::class)->findAll();
  4302.         $employeeIds $em->getRepository(EmployeeDetails::class)->findAll();
  4303.         $employeeType HumanResourceConstant::$employeeType;
  4304.         $Designation $em->getRepository(SysDepartmentPosition::class)->findAll();
  4305.         $branch $em->getRepository(Branch::class)->findAll();
  4306.         $departments $em->getRepository(SysDepartment::class)->findAll();
  4307.         $department = [];
  4308.         foreach ($departments as $entry) {
  4309.             $department[$entry->getDepartmentId()] = array(
  4310.                 'id' => $entry->getDepartmentId(),
  4311.                 'name' => $entry->getDepartmentName(),
  4312.             );
  4313.         }
  4314.         return $this->render('ApplicationBundle:pages/human_resource/input_forms:employee_performance_evolution.html.twig',
  4315.             array(
  4316.                 'page_title' => 'Create Employee Performance Evaluation',
  4317.                 'employeeIds' => $employeeIds,
  4318.                 'employeeType' => $employeeType,
  4319.                 'Designation' => $Designation,
  4320.                 'branch' => $branch,
  4321.                 'department' => $department,
  4322.                 'skill' => $skill,
  4323.                 'educationDetail' => $educationDetail
  4324.             )
  4325.         );
  4326.     }
  4327.     public function ViewIndividualReviewAction()
  4328.     {
  4329.         return $this->render('ApplicationBundle:pages/human_resource/views:individual_review.html.twig',
  4330.             array(
  4331.                 'page_title' => 'Individual Performance View',
  4332.             )
  4333.         );
  4334.     }
  4335.     public function EmployeeListBySkillPerformanceAction()
  4336.     {
  4337.         $em $this->getDoctrine()->getManager();
  4338.         $employee $em->getRepository('ApplicationBundle:EmployeeDetails')->findAll();
  4339.         $skill $em->getRepository('ApplicationBundle:Skill')->findAll();
  4340.         return $this->render('ApplicationBundle:pages/human_resource/list:employee_performance_evolution_list.html.twig',
  4341.             array(
  4342.                 'page_title' => 'Employee Skill & Performance',
  4343.                 'employee' => $employee,
  4344.                 //'employeeSkill' => json_decode($employee->getSkill(),true),
  4345.                 'skill' => $skill,
  4346.             )
  4347.         );
  4348.     }
  4349.     public function setWorkPlaceAction(Request $req)
  4350.     {
  4351.         $em $this->getDoctrine()->getManager();
  4352.         $companyId $this->getLoggedUserCompanyId($req);
  4353.         $docHash '';
  4354.         if ($req->request->has('XHRreq')) {
  4355.             $docHash HumanResource::HandelXHRreqForEmpWorkplace($em$req);
  4356.             return new JsonResponse([$docHash]);
  4357.         }
  4358.         if ($req->isMethod('GET')) {
  4359.             $TwigData HumanResource::TwigDataForEmployeeWorkplace($em);
  4360.             return $this->render(
  4361.                 'ApplicationBundle:pages/human_resource/input_forms:update_workplace.html.twig',
  4362.                 [
  4363.                     'page_title' => 'Set Workplace',
  4364.                     'employeeIds' => $TwigData['employeeIds']
  4365.                 ]
  4366.             );
  4367.         }
  4368.         if ($req->isMethod('POST')) {
  4369.             $approveHash $req->request->get('approvalHash');
  4370.             $loginId $req->getSession()->get(UserConstants::USER_LOGIN_ID);
  4371.             $isSignatureOk DocValidation::isSignatureOk($em$loginId$approveHash);
  4372.             if ($isSignatureOk) {
  4373.                 $isSuccess HumanResource::CreateOrUpdateForEmpWorkplace($em$req$companyIdfalse$docHash);
  4374.                 if ($isSuccess) {
  4375.                     $this->addFlash(
  4376.                         'success',
  4377.                         'Workplace set!'
  4378.                     );
  4379.                     return $this->redirectToRoute('set_workplace');
  4380.                 }
  4381.             } else {
  4382.                 $this->addFlash(
  4383.                     'error',
  4384.                     'Invalid Approval Hash!'
  4385.                 );
  4386.                 return $this->redirectToRoute('set_workplace');
  4387.             }
  4388.         }
  4389.     }
  4390.     public function setWorkPlaceForAppAction(Request $req)
  4391.     {
  4392.         $em $this->getDoctrine()->getManager();
  4393.         $companyId $this->getLoggedUserCompanyId($req);
  4394.         $docHash HumanResource::HandelXHRreqForEmpWorkplace($em$req);
  4395.         if ($req->isMethod('GET')) {
  4396.             $TwigData HumanResource::TwigDataForEmployeeWorkplace($em);
  4397.             return $this->render(
  4398.                 'ApplicationBundle:pages/human_resource/input_forms:update_workplace.html.twig',
  4399.                 [
  4400.                     'page_title' => 'Set Workplace',
  4401.                     'employeeIds' => $TwigData['employeeIds']
  4402.                 ]
  4403.             );
  4404.         }
  4405.         if ($req->isMethod('POST')) {
  4406.             $approveHash $req->request->get('approvalHash');
  4407.             $loginId $req->getSession()->get(UserConstants::USER_LOGIN_ID);
  4408.             $isSignatureOk DocValidation::isSignatureOk($em$loginId$approveHash);
  4409.             if ($isSignatureOk) {
  4410.                 $isSuccess HumanResource::CreateOrUpdateForEmpWorkplace($em$req$companyIdfalse$docHash);
  4411.                 if ($isSuccess) {
  4412.                     $this->addFlash(
  4413.                         'success',
  4414.                         'Workplace set!'
  4415.                     );
  4416. //                    return $this->redirectToRoute('set_workplace');
  4417.                     return new JsonResponse(array(
  4418.                         "success" => true
  4419.                     ));
  4420.                 }
  4421.             } else {
  4422.                 $this->addFlash(
  4423.                     'error',
  4424.                     'Invalid Approval Hash!'
  4425.                 );
  4426. //                return $this->redirectToRoute('set_workplace');
  4427.             }
  4428.         }
  4429.     }
  4430.     public function ViewMeetingAction(Request $req$action 0$id 0)
  4431.     {
  4432.         $em $this->getDoctrine()->getManager();
  4433.         $companyId $this->getLoggedUserCompanyId($req);
  4434.         if ($req->request->has('XHRreq')) {
  4435.             return new JsonResponse([HumanResource::HandelXHRreqForMeetingScheduling($em$req)]);
  4436.         }
  4437.         if ($action === 'view') {
  4438.             $response HumanResource::TwigDataForScheduledMeetingView($em$req$id);
  4439.             return $this->render(
  4440.                 'ApplicationBundle:pages/human_resource/views:scheduled_meeting_view.html.twig',
  4441.                 [
  4442.                     'page_title' => 'View Scheduled Meeting',
  4443.                     'duration' => $response['duration'],
  4444.                     'appId' => $response['appId'],
  4445.                     'publicView' => 0,
  4446.                     'meeting_data' => $response['meeting_data'],
  4447.                     'agenda_list' => $response['agenda_list'],
  4448.                     'id' => $req->query->get('view_meeting'),
  4449.                     'approval_data' => $response['approval_data'],
  4450.                     'document_log' => $response['document_log'],
  4451.                     'approval_status' => $response['approval_status'],
  4452.                     'created_by' => $response['created_by'],
  4453.                     'updated_at' => $response['updated_at'],
  4454.                     'auto_created' => 0,
  4455.                 ]
  4456.             );
  4457.         }
  4458.         if ($action === 'print') {
  4459.             $response HumanResource::TwigDataForScheduledMeetingView($em$req$id);
  4460. //      $id = $req->query->get('print_meeting');
  4461.             $em $this->getDoctrine()->getManager();
  4462.             $company_data Company::getCompanyData($em1);
  4463.             $Authorizations System::getSignatureListForDocumentPrint($emarray_flip(GeneralConstant::$Entity_list)['ScheduledMeeting'], $id);
  4464.             return $this->render(
  4465.                 'ApplicationBundle:pages/human_resource/print:scheduled_meeting_print.html.twig',
  4466.                 array(
  4467.                     'page_title' => 'View Scheduled Meeting',
  4468.                     'duration' => $response['duration'],
  4469.                     'meeting_data' => $response['meeting_data'],
  4470.                     'agenda_list' => $response['agenda_list'],
  4471.                     'export' => 'pdf,print',
  4472.                     'company_name' => $company_data->getName(),
  4473.                     'company_data' => $company_data,
  4474.                     'company_address' => $company_data->getAddress(),
  4475.                     'company_image' => $company_data->getImage(),
  4476.                     'Authorizations' => $Authorizations,
  4477.                     'red' => 0
  4478.                 )
  4479.             );
  4480.         }
  4481.     }
  4482.     public function UpdateMeetingMinutesAction(Request $req$action 0$id 0)
  4483.     {
  4484.         $em $this->getDoctrine()->getManager();
  4485.         $companyId $this->getLoggedUserCompanyId($req);
  4486.         $scheduleId $req->request->get('scheduleId');
  4487.         $minuteText $req->request->get('minuteText');
  4488.         $agendaKey $req->request->get('key');
  4489.         $scheduledMeeting $em->getRepository(ScheduledMeeting::class)
  4490.             ->find($scheduleId);
  4491.         $agendaList json_decode($scheduledMeeting->getAgendaList(), true);
  4492.         foreach ($agendaList as $key => $item) {
  4493.             if ($key == $agendaKey)
  4494.                 $agendaList[$key]['minutes'] = $minuteText;
  4495.         }
  4496.         $scheduledMeeting->setAgendaList(json_encode($agendaList));
  4497.         $em->flush();
  4498.         return new JsonResponse(array(
  4499.             'success' => true
  4500.         ));
  4501.     }
  4502.     public function deleteLastAttendanceAction(Request $request)
  4503.     {
  4504.         $em $this->getDoctrine()->getManager();
  4505.         $lastAttendance $em->getRepository('ApplicationBundle:EmployeeAttendance')
  4506.             ->createQueryBuilder('ea')
  4507.             ->orderBy('ea.id''DESC')
  4508.             ->setMaxResults(1)
  4509.             ->getQuery()
  4510.             ->getOneOrNullResult();
  4511.         $lastAttendanceLog $em->getRepository('ApplicationBundle:EmployeeAttendanceLog')
  4512.             ->createQueryBuilder('eal')
  4513.             ->orderBy('eal.id''DESC')
  4514.             ->setMaxResults(1)
  4515.             ->getQuery()
  4516.             ->getOneOrNullResult();
  4517.         $deletedCount 0;
  4518.         if ($lastAttendance) {
  4519.             $em->remove($lastAttendance);
  4520.             $deletedCount++;
  4521.         }
  4522.         if ($lastAttendanceLog) {
  4523.             $em->remove($lastAttendanceLog);
  4524.             $deletedCount++;
  4525.         }
  4526.         $em->flush();
  4527.         return new JsonResponse(
  4528.             [
  4529.                 'success' => true,
  4530.                 'message' => "Deleted `$deletedCount` rows from attendance tables."
  4531.             ]
  4532.         );
  4533.     }
  4534.     public function SendMeetingUpdatesAction(Request $req$action 0$id 0)
  4535.     {
  4536.         $em $this->getDoctrine()->getManager();
  4537.         $companyId $this->getLoggedUserCompanyId($req);
  4538.         $session $req->getSession();
  4539.         $companyData Company::getCompanyData($em$companyId);
  4540.         $scheduleId $req->request->get('scheduleId');
  4541.         $minuteText $req->request->get('minuteText');
  4542.         $agendaKey $req->request->get('key');
  4543.         $scheduledMeeting $em->getRepository(ScheduledMeeting::class)
  4544.             ->find($scheduleId);
  4545.         $sendEmailInvitationTo json_decode($scheduledMeeting->getAllParticipantsNameEmail(), true);
  4546.         if ($sendEmailInvitationTo == null)
  4547.             $sendEmailInvitationTo = [];
  4548.         $agendaList json_decode($scheduledMeeting->getAgendaList(), true);
  4549.         if ($agendaList == null)
  4550.             $agendaList = [];
  4551.         $EmployeeList HumanResource::GetEmployeeList($em, []);
  4552.         $meetingType MeetingSchedulingConstant::$meetingType[$scheduledMeeting->getMeetingType()];
  4553.         foreach ($sendEmailInvitationTo as $key => $email) {
  4554.             $name ucWords(str_replace("_"" "$key));
  4555.             $bodyHtml '';
  4556.             $bodyTemplate 'ApplicationBundle:email/meeting_scheduling:scheduled_meeting_update.html.twig';
  4557.             $bodyData = array(
  4558.                 'name' => $name,
  4559.                 'gocId' => $session->get(UserConstants::USER_GOC_ID),
  4560.                 'appId' => $session->get(UserConstants::USER_APP_ID),
  4561.                 'email' => $email,
  4562.                 'meetingData' => $scheduledMeeting,
  4563.                 'meeting_type' => $meetingType,
  4564.                 'agenda_list' => $agendaList,
  4565.                 'companyData' => $companyData,
  4566.                 'employeeList' => $EmployeeList,
  4567.             );
  4568.             $attachments = [];
  4569.             $new_mail $this->get('mail_module');
  4570.             $new_mail->sendMyMail(array(
  4571.                 'senderHash' => '_MEETING_',
  4572.                 'forwardToMailAddress' => $email,
  4573.                 'subject' => "Meeting Updates Arranged By - " $companyData->getName() . " on " $scheduledMeeting->getTitle() . ". ",
  4574.                 'fileName' => '',
  4575.                 'attachments' => $attachments,
  4576.                 'toAddress' => $email,
  4577.                 'mailTemplate' => $bodyTemplate,
  4578.                 'templateData' => $bodyData,
  4579.                 'embedCompanyImage' => 1,
  4580.                 'companyId' => $companyId,
  4581.                 'companyImagePath' => $companyData->getImage()
  4582.             ));
  4583.         }
  4584.         return new JsonResponse(array(
  4585.             'success' => true
  4586.         ));
  4587.     }
  4588.     public function meetingSchedulingAction(Request $req$action 0)
  4589.     {
  4590.         $em $this->getDoctrine()->getManager();
  4591.         $companyId $this->getLoggedUserCompanyId($req);
  4592.         $session $req->getSession();
  4593.         if ($req->request->has('XHRreq')) {
  4594.             return new JsonResponse([HumanResource::HandelXHRreqForMeetingScheduling($em$req)]);
  4595.         }
  4596.         if ($action === 'list') {
  4597.             $response HumanResource::TwigDataForScheduledMeetingList($em, [0null]);
  4598.             return $this->render(
  4599.                 'ApplicationBundle:pages/human_resource/list:scheduled_meeting_list.html.twig',
  4600.                 [
  4601.                     'page_title' => 'Scheduled Meeting List',
  4602.                     'list' => $response
  4603.                 ]
  4604.             );
  4605.         }
  4606.         if ($req->isMethod('GET')) {
  4607.             $response HumanResource::twigDataForMeetingScheduling($em);
  4608.             return $this->render(
  4609.                 'ApplicationBundle:pages/human_resource/input_forms:meeting_scheduling.html.twig',
  4610.                 [
  4611.                     'page_title' => 'Schedule a Meeting',
  4612.                     'employeeIds' => $response['employeeIds'],
  4613.                     'branches' => $response['branches'],
  4614.                     'asset' => $response['asset'],
  4615.                     'rooms' => $response['rooms'],
  4616.                     'sales_orders' => $response['salesOrders'],
  4617.                     'purchase_orders' => $response['purchaseOrders'],
  4618.                     'meeting_types' => $response['meetingType'],
  4619.                 ]
  4620.             );
  4621.         }
  4622.         if ($req->isMethod('POST')) {
  4623.             $approveHash $req->request->get('approvalHash');
  4624.             $approveRole $req->request->get('approvalRole');
  4625.             $loginId $req->getSession()->get(UserConstants::USER_LOGIN_ID);
  4626.             $isSignatureOk DocValidation::isSignatureOk($em$loginId$approveHash);
  4627.             $companyData Company::getCompanyData($em$companyId);
  4628.             if ($isSignatureOk) {
  4629.                 $isSuccess HumanResource::createOrUpdateDataForMeetingScheduling($em$req);
  4630.                 if ($isSuccess) {
  4631.                     $options = array(
  4632.                         'notification_enabled' => $this->container->getParameter('notification_enabled'),
  4633.                         'notification_server' => $this->container->getParameter('notification_server'),
  4634.                         'appId' => $req->getSession()->get(UserConstants::USER_APP_ID),
  4635.                         'url' => $this->generateUrl(
  4636.                             GeneralConstant::$Entity_list_details[array_flip(GeneralConstant::$Entity_list)['ScheduledMeeting']]['entity_view_route_path_name']
  4637.                         )
  4638.                     );
  4639.                     $meetingId $isSuccess[1];
  4640.                     System::setApprovalInfo(
  4641.                         $this->getDoctrine()->getManager(),
  4642.                         $options,
  4643.                         array_flip(GeneralConstant::$Entity_list)['ScheduledMeeting'],
  4644.                         $meetingId,
  4645.                         $req->getSession()->get(UserConstants::USER_LOGIN_ID),
  4646.                         0//normal meeting
  4647.                         0,
  4648.                         $this->get('mail_module')
  4649.                     );
  4650.                     System::createEditSignatureHash(
  4651.                         $this->getDoctrine()->getManager(),
  4652.                         array_flip(GeneralConstant::$Entity_list)['ScheduledMeeting'],
  4653.                         $meetingId,
  4654.                         $loginId,
  4655.                         $approveRole,
  4656.                         $req->request->get('approvalHash')
  4657.                     );
  4658.                     $url $this->generateUrl(
  4659.                         'view_scheduled_meeting'
  4660.                     );
  4661.                     return $this->redirect($url "/" $meetingId);
  4662.                 } else {
  4663.                     return new JsonResponse(array(
  4664.                         'success' => false
  4665.                     ));
  4666.                 }
  4667.             } else {
  4668.                 $this->addFlash(
  4669.                     'error',
  4670.                     'Invalid Approval Hash!'
  4671.                 );
  4672.                 return $this->redirectToRoute('meeting_scheduling');
  4673.             }
  4674.         }
  4675.         return $this->redirectToRoute('meeting_scheduling');
  4676.     }
  4677.     public function MeetingSchedulingForAppAction(Request $request): JsonResponse
  4678.     {
  4679.         $em $this->getDoctrine()->getManager();
  4680.         $session $request->getSession();
  4681.         $mailer $this->get('mail_module');
  4682.         $helper = new HumanResourceHelper($em$mailer);
  4683.         try {
  4684.             $data $request->request->all();
  4685.             $files $request->files->all();
  4686.             $companyId $this->getLoggedUserCompanyId($request);
  4687.             $meeting $helper->prepareMeeting($data$session);
  4688.             $agendaList = [];
  4689.             if (!empty($data['agendaList']) && is_array($data['agendaList'])) {
  4690.                 foreach ($data['agendaList'] as $index => $agendaData) {
  4691.                     $agenda = [
  4692.                         'title' => $agendaData['title'] ?? null,
  4693.                         'desc' => $agendaData['desc'] ?? null,
  4694.                         'notes' => $agendaData['notes'] ?? null,
  4695.                         'taggedDocuments' => $agendaData['taggedDocuments'] ?? [],
  4696.                         'otherDocuments' => [],
  4697.                     ];
  4698.                     if (!empty($files['agendaList'][$index]['otherDocuments'])) {
  4699.                         foreach ($files['agendaList'][$index]['otherDocuments'] as $uploadedFile) {
  4700.                             $uploadedFilePath $this->uploadMeetingFile($uploadedFile$request);
  4701.                             if ($uploadedFilePath) {
  4702.                                 $agenda['otherDocuments'][] = [
  4703.                                     'fileName' => basename($uploadedFilePath),
  4704.                                     'path' => $uploadedFilePath,
  4705.                                     'type' => $uploadedFile->getClientOriginalExtension(),
  4706.                                 ];
  4707.                             }
  4708.                         }
  4709.                     }
  4710.                     $agendaList[] = $agenda;
  4711.                 }
  4712.             }
  4713.             $meeting->setAgendaList(json_encode($agendaList));
  4714.             [$internalInfo$otherInfo$internalIds] = $helper->resolveParticipants(
  4715.                 $data['guests'] ?? [],
  4716.                 $session->get('userEmployeeId')
  4717.             );
  4718.             // Save **full participant objects** to DB
  4719.             $meeting->setInternalParticipantIds(!empty($internalInfo) ? json_encode($internalInfo) : null);
  4720.             $meeting->setOtherParticipantInfo(!empty($otherInfo) ? json_encode($otherInfo) : null);
  4721.             $meeting->setParticipantInfo(json_encode([
  4722.                 'internal' => $internalInfo,
  4723.                 'other' => $otherInfo,
  4724.             ]));
  4725.             // Persist the meeting
  4726.             $em->persist($meeting);
  4727.             $em->flush();
  4728.             // Send invitations
  4729.             $helper->sendInvitations($meeting$internalIds$otherInfo$companyId);
  4730.             return new JsonResponse([
  4731.                 'success' => true,
  4732.                 'message' => 'Meeting scheduled successfully',
  4733.                 'meetingId' => $meeting->getScheduleId(),
  4734.                 'documentHas' => $meeting->getDocumentHash(),
  4735.             ]);
  4736.         } catch (\Exception $e) {
  4737.             return new JsonResponse(['success' => false'error' => $e->getMessage()], 500);
  4738.         }
  4739.     }
  4740.     public function updateMeetingForAppAction(Request $requestint $meetingId): JsonResponse
  4741.     {
  4742.         $em $this->getDoctrine()->getManager();
  4743.         $session $request->getSession();
  4744.         $mailer $this->get('mail_module');
  4745.         $helper = new HumanResourceHelper($em$mailer);
  4746.         try {
  4747.             $data $request->request->all();
  4748.             $files $request->files->all();
  4749.             $meeting $em->getRepository(ScheduledMeeting::class)->find($meetingId);
  4750.             if (!$meeting) {
  4751.                 return new JsonResponse(['success' => false'error' => 'Meeting not found'], 404);
  4752.             }
  4753.             $meeting->setTitle($data['title'] ?? $meeting->getTitle());
  4754.             $meeting->setSpecialType($data['specialType'] ?? $meeting->getSpecialType());
  4755.             $meeting->setStartAt(!empty($data['startAt']) ? new \DateTime($data['startAt']) : $meeting->getStartAt());
  4756.             $meeting->setEndAt(!empty($data['endAt']) ? new \DateTime($data['endAt']) : $meeting->getEndAt());
  4757.             $meeting->setMeetingType($data['meetingType'] ?? $meeting->getMeetingType());
  4758.             $meeting->setLocation($data['location'] ?? $meeting->getLocation());
  4759.             $meeting->setRoomId($data['roomId'] ?? $meeting->getRoomId());
  4760.             $meeting->setDesc($data['desc'] ?? $meeting->getDesc());
  4761.             $meeting->setLastModifiedDate(new \DateTime());
  4762.             if (isset($data['agendaList']) && is_array($data['agendaList'])) {
  4763.                 $agendaList = [];
  4764.                 foreach ($data['agendaList'] as $index => $agendaData) {
  4765.                     $agenda = [
  4766.                         'title' => $agendaData['title'] ?? null,
  4767.                         'desc' => $agendaData['desc'] ?? null,
  4768.                         'notes' => $agendaData['notes'] ?? null,
  4769.                         'taggedDocuments' => $agendaData['taggedDocuments'] ?? [],
  4770.                         'otherDocuments' => [],
  4771.                     ];
  4772.                     if (!empty($files['agendaList'][$index]['otherDocuments'])) {
  4773.                         foreach ($files['agendaList'][$index]['otherDocuments'] as $uploadedFile) {
  4774.                             $uploadedFilePath $this->uploadMeetingFile($uploadedFile$request);
  4775.                             if ($uploadedFilePath) {
  4776.                                 $agenda['otherDocuments'][] = [
  4777.                                     'fileName' => basename($uploadedFilePath),
  4778.                                     'path' => $uploadedFilePath,
  4779.                                     'type' => $uploadedFile->getClientOriginalExtension(),
  4780.                                 ];
  4781.                             }
  4782.                         }
  4783.                     }
  4784.                     if (!empty($agendaData['otherDocumentsExisting'])) {
  4785.                         $agenda['otherDocuments'] = array_merge(
  4786.                             $agenda['otherDocuments'],
  4787.                             $agendaData['otherDocumentsExisting']
  4788.                         );
  4789.                     }
  4790.                     $agendaList[] = $agenda;
  4791.                 }
  4792.                 $meeting->setAgendaList(json_encode($agendaList));
  4793.             }
  4794.             if (isset($data['guests'])) {
  4795.                 [$internalIds$otherInfo] = $helper->resolveParticipants($data['guests'], $session->get('userEmployeeId'));
  4796.                 $meeting->setInternalParticipantIds(!empty($internalIds) ? json_encode($internalIds) : null);
  4797.                 $meeting->setOtherParticipantInfo(!empty($otherInfo) ? json_encode($otherInfo) : null);
  4798.             }
  4799.             $em->persist($meeting);
  4800.             $em->flush();
  4801.             if (isset($internalIds) || isset($otherInfo)) {
  4802.                 $helper->sendInvitations($meeting$internalIds ?? [], $otherInfo ?? [], $meeting->getCompanyId());
  4803.             }
  4804.             return new JsonResponse([
  4805.                 'success' => true,
  4806.                 'message' => 'Meeting updated successfully',
  4807.                 'meetingId' => $meeting->getScheduleId(),
  4808.                 'facilitator' => ['id' => $meeting->getFacilitatorId(), 'name' => $meeting->getFacilitatorName()],
  4809.                 'companyId' => $meeting->getCompanyId(),
  4810.                 'branchId' => $meeting->getBranchId(),
  4811.                 'internalParticipants' => json_decode($meeting->getInternalParticipantIds(), true) ?? [],
  4812.                 'otherParticipants' => json_decode($meeting->getOtherParticipantInfo(), true) ?? [],
  4813.                 'agendas' => json_decode($meeting->getAgendaList(), true) ?? [],
  4814.             ]);
  4815.         } catch (\Exception $e) {
  4816.             return new JsonResponse(['success' => false'error' => $e->getMessage()], 500);
  4817.         }
  4818.     }
  4819.     public function GetDocumentsForMeetingScheduleAppAction(Request $request): JsonResponse
  4820.     {
  4821.         $em $this->getDoctrine()->getManager();
  4822.         $hrHelper = new HumanResourceHelper($em);
  4823.         try {
  4824.             $documents $hrHelper->getAllDocumentsFromApproval($request);
  4825.             return ResponseStructure::success($documents'Documents fetched successfully');
  4826.         } catch (\Exception $e) {
  4827.             return ResponseStructure::error($e->getMessage());
  4828.         }
  4829.     }
  4830.     public function getMeetingsByDateAction(Request $request): JsonResponse
  4831.     {
  4832.         $em $this->getDoctrine()->getManager();
  4833.         $dateParam $request->query->get('date');
  4834.         $monthParam $request->query->get('month');
  4835.         $dayParam $request->query->get('day');
  4836.         $yearParam $request->query->get('year');
  4837.         $start $end null;
  4838.         try {
  4839.             if ($dateParam) {
  4840.                 if (strpos($dateParam',') !== false) {
  4841.                     [$startStr$endStr] = explode(','$dateParam);
  4842.                     $start = new \DateTime($startStr " 00:00:00");
  4843.                     $end = new \DateTime($endStr " 23:59:59");
  4844.                 } else {
  4845.                     $parts explode('-'$dateParam);
  4846.                     if (count($parts) === 3) {
  4847.                         $start = new \DateTime($dateParam " 00:00:00");
  4848.                         $end = new \DateTime($dateParam " 23:59:59");
  4849.                     } elseif (count($parts) === 2) {
  4850.                         $start = new \DateTime($dateParam "-01 00:00:00");
  4851.                         $end = (clone $start)->modify('last day of this month')->setTime(235959);
  4852.                     } else {
  4853.                         throw new \Exception("Invalid date format");
  4854.                     }
  4855.                 }
  4856.             } elseif ($monthParam) {
  4857.                 $year $yearParam ?: date('Y');
  4858.                 $monthDate = new \DateTime("first day of $monthParam $year");
  4859.                 $start = (clone $monthDate)->setTime(000);
  4860.                 $end = (clone $monthDate)->modify('last day of this month')->setTime(235959);
  4861.             } elseif ($dayParam) {
  4862.                 $year $yearParam ?: date('Y');
  4863.                 $startOfYear = new \DateTime("$year-01-01 00:00:00");
  4864.                 $endOfYear = new \DateTime("$year-12-31 23:59:59");
  4865.                 $meetings $em->getRepository(\ApplicationBundle\Entity\ScheduledMeeting::class)
  4866.                     ->createQueryBuilder('m')
  4867.                     ->where('m.startAt BETWEEN :start AND :end')
  4868.                     ->setParameter('start'$startOfYear)
  4869.                     ->setParameter('end'$endOfYear)
  4870.                     ->getQuery()
  4871.                     ->getResult();
  4872.                 $meetingType MeetingSchedulingConstant::$meetingType;
  4873.                 $data = [];
  4874.                 foreach ($meetings as $meeting) {
  4875.                     if (strtolower($meeting->getStartAt()->format('l')) === strtolower($dayParam)) {
  4876.                         $data[] = [
  4877.                             'id' => $meeting->getScheduleId(),
  4878.                             'title' => $meeting->getTitle(),
  4879.                             'desc' => $meeting->getDesc(),
  4880.                             'startAt' => $meeting->getStartAt()->format('Y-m-d H:i:s'),
  4881.                             'endAt' => $meeting->getEndAt() ? $meeting->getEndAt()->format('Y-m-d H:i:s') : null,
  4882.                             'roomId' => $meeting->getRoomId(),
  4883.                             'meetingType' => $meetingType[$meeting->getMeetingType()] ?? null,
  4884.                             'location' => $meeting->getLocation(),
  4885.                             'participant' => json_decode($meeting->getParticipantInfo()),
  4886.                             'status' => $meeting->getStatus(),
  4887.                             'approved' => (bool)$meeting->getApproved(),
  4888.                         ];
  4889.                     }
  4890.                 }
  4891.                 return new JsonResponse([
  4892.                     'success' => true,
  4893.                     'filter' => [
  4894.                         'day' => $dayParam,
  4895.                         'year' => $year
  4896.                     ],
  4897.                     'meetings' => $data
  4898.                 ]);
  4899.             } else {
  4900.                 return new JsonResponse([
  4901.                     'success' => false,
  4902.                     'error' => 'Please provide month, day, or date query parameter.'
  4903.                 ], 400);
  4904.             }
  4905.         } catch (\Exception $e) {
  4906.             return new JsonResponse([
  4907.                 'success' => false,
  4908.                 'error' => 'Invalid date format or input. ' $e->getMessage()
  4909.             ], 400);
  4910.         }
  4911.         $meetings $em->getRepository(\ApplicationBundle\Entity\ScheduledMeeting::class)
  4912.             ->createQueryBuilder('m')
  4913.             ->where('m.startAt BETWEEN :start AND :end')
  4914.             ->setParameter('start'$start)
  4915.             ->setParameter('end'$end)
  4916.             ->getQuery()
  4917.             ->getResult();
  4918.         $meetingType MeetingSchedulingConstant::$meetingType;
  4919.         $data = [];
  4920.         foreach ($meetings as $meeting) {
  4921.             $data[] = [
  4922.                 'id' => $meeting->getScheduleId(),
  4923.                 'title' => $meeting->getTitle(),
  4924.                 'desc' => $meeting->getDesc(),
  4925.                 'startAt' => $meeting->getStartAt() ? $meeting->getStartAt()->format('Y-m-d H:i:s') : null,
  4926.                 'endAt' => $meeting->getEndAt() ? $meeting->getEndAt()->format('Y-m-d H:i:s') : null,
  4927.                 'roomId' => $meeting->getRoomId(),
  4928.                 'meetingType' => $meetingType[$meeting->getMeetingType()] ?? null,
  4929.                 'location' => $meeting->getLocation(),
  4930.                 'participant' => json_decode($meeting->getParticipantInfo()),
  4931.                 'status' => $meeting->getStatus(),
  4932.                 'approved' => (bool)$meeting->getApproved(),
  4933.             ];
  4934.         }
  4935.         return new JsonResponse([
  4936.             'success' => true,
  4937.             'range' => [
  4938.                 'start' => $start->format('Y-m-d H:i:s'),
  4939.                 'end' => $end->format('Y-m-d H:i:s')
  4940.             ],
  4941.             'meetings' => $data
  4942.         ]);
  4943.     }
  4944.     public function getMeetingByYearlyAction(Request $request): JsonResponse
  4945.     {
  4946.         $em $this->getDoctrine()->getManager();
  4947.         $yearParam $request->query->get('year');
  4948.         try {
  4949.             $data HumanResourceHelper::GetMeetingByYearlyAction($em$yearParam);
  4950.             return new JsonResponse($data200);
  4951.         } catch (\Exception $e) {
  4952.             return new JsonResponse([
  4953.                 'success' => false,
  4954.                 'error' => $e->getMessage()
  4955.             ], 400);
  4956.         }
  4957.     }
  4958.     public function getMeetingByIdAction(Request $requestint $id): JsonResponse
  4959.     {
  4960.         $em $this->getDoctrine()->getManager();
  4961.         $meeting $em->getRepository(\ApplicationBundle\Entity\ScheduledMeeting::class)->find($id);
  4962.         if (!$meeting) {
  4963.             return new JsonResponse([
  4964.                 'success' => false,
  4965.                 'error' => 'Meeting not found'
  4966.             ], 404);
  4967.         }
  4968.         return new JsonResponse([
  4969.             'success' => true,
  4970.             'meeting' => [
  4971.                 'id' => $meeting->getScheduleId(),
  4972.                 'docHash' => $meeting->getDocumentHash(),
  4973.                 'title' => $meeting->getTitle(),
  4974.                 'desc' => $meeting->getDesc(),
  4975.                 'specialType' => $meeting->getSpecialType(),
  4976.                 'startAt' => $meeting->getStartAt() ? $meeting->getStartAt()->format('Y-m-d H:i:s') : null,
  4977.                 'endAt' => $meeting->getEndAt() ? $meeting->getEndAt()->format('Y-m-d H:i:s') : null,
  4978.                 'meetingType' => $meeting->getMeetingType(),
  4979.                 'location' => $meeting->getLocation(),
  4980.                 'roomId' => $meeting->getRoomId(),
  4981.                 'facilitator' => [
  4982.                     'id' => $meeting->getFacilitatorId(),
  4983.                     'name' => $meeting->getFacilitatorName()
  4984.                 ],
  4985.                 'companyId' => $meeting->getCompanyId(),
  4986.                 'branchId' => $meeting->getBranchId(),
  4987.                 'agendaList' => $meeting->getAgendaList() ? json_decode($meeting->getAgendaList(), true) : [],
  4988.                 'internalParticipants' => $meeting->getInternalParticipantIds() ? json_decode($meeting->getInternalParticipantIds(), true) : [],
  4989.                 'otherParticipants' => $meeting->getOtherParticipantInfo() ? json_decode($meeting->getOtherParticipantInfo(), true) : [],
  4990.                 'createdAt' => $meeting->getCreatedAt()->format('Y-m-d H:i:s'),
  4991.             ]
  4992.         ]);
  4993.     }
  4994.     public function updateMeetingAction(Request $requestint $id): JsonResponse
  4995.     {
  4996.         $em $this->getDoctrine()->getManager();
  4997.         $meeting $em->getRepository(\ApplicationBundle\Entity\ScheduledMeeting::class)->find($id);
  4998.         if (!$meeting) {
  4999.             return new JsonResponse(['success' => false'error' => 'Meeting not found'], 404);
  5000.         }
  5001.         $data json_decode($request->getContent(), true);
  5002.         if (!$data) {
  5003.             $data $request->request->all();
  5004.         }
  5005.         if (!$data) {
  5006.             return new JsonResponse(['success' => false'error' => 'Invalid data'], 400);
  5007.         }
  5008.         if (isset($data['title'])) $meeting->setTitle($data['title']);
  5009.         if (isset($data['desc'])) $meeting->setDesc($data['desc']);
  5010.         if (isset($data['startAt'])) $meeting->setStartAt(new \DateTime($data['startAt']));
  5011.         if (isset($data['endAt'])) $meeting->setEndAt(new \DateTime($data['endAt']));
  5012.         if (isset($data['location'])) $meeting->setLocation($data['location']);
  5013.         if (isset($data['meetingType'])) $meeting->setMeetingType($data['meetingType']);
  5014.         if (isset($data['roomId'])) $meeting->setRoomId($data['roomId']);
  5015.         if (isset($data['agendaList'])) {
  5016.             $agendaList is_array($data['agendaList']) ? $data['agendaList'] : json_decode($data['agendaList'], true);
  5017.             $meeting->setAgendaList(json_encode($agendaList));
  5018.         }
  5019.         $meeting->setLastModifiedDate(new \DateTime());
  5020.         $em->flush();
  5021.         return new JsonResponse([
  5022.             'success' => true,
  5023.             'message' => 'Meeting updated successfully',
  5024.             'meetingId' => $meeting->getScheduleId()
  5025.         ]);
  5026.     }
  5027.     public function deleteMeetingAction(Request $requestint $id): JsonResponse
  5028.     {
  5029.         $em $this->getDoctrine()->getManager();
  5030.         $meeting $em->getRepository(\ApplicationBundle\Entity\ScheduledMeeting::class)->find($id);
  5031.         if (!$meeting) {
  5032.             return new JsonResponse(['success' => false'error' => 'Meeting not found'], 404);
  5033.         }
  5034.         $em->remove($meeting);
  5035.         $em->flush();
  5036.         return new JsonResponse([
  5037.             'success' => true,
  5038.             'message' => 'Meeting deleted successfully',
  5039.             'deletedId' => $id
  5040.         ]);
  5041.     }
  5042.     public function searchParticipantByEmailAction(Request $request): JsonResponse
  5043.     {
  5044.         $em $this->getDoctrine()->getManager();
  5045.         $email trim($request->query->get('email'));
  5046.         if (empty($email)) {
  5047.             return new JsonResponse([
  5048.                 'success' => false,
  5049.                 'error' => 'Email is required'
  5050.             ], 400);
  5051.         }
  5052.         try {
  5053.             $companyId $this->getLoggedUserCompanyId($request);
  5054.             $client $em->getRepository(\ApplicationBundle\Entity\AccClients::class)
  5055.                 ->findOneBy(['email' => $email]);
  5056.             if ($client) {
  5057.                 return new JsonResponse([
  5058.                     'success' => true,
  5059.                     'type' => 'client',
  5060.                     'data' => [
  5061.                         'client_id' => $client->getClientId(),
  5062.                         'company_id' => $client->getCompanyId(),
  5063.                         'client_name' => $client->getClientName(),
  5064.                         'email' => $client->getEmail(),
  5065.                     ]
  5066.                 ]);
  5067.             }
  5068.             $employee $em->getRepository(\ApplicationBundle\Entity\Employee::class)
  5069.                 ->findOneBy(['email' => $email]);
  5070.             if ($employee) {
  5071.                 return new JsonResponse([
  5072.                     'success' => true,
  5073.                     'type' => 'employee',
  5074.                     'data' => [
  5075.                         'name' => $employee->getName(),
  5076.                         'email' => $employee->getEmail(),
  5077.                         'user_id' => $employee->getUserId(),
  5078.                         'address_contact' => $employee->getAddressContact(),
  5079.                     ]
  5080.                 ]);
  5081.             }
  5082.             return new JsonResponse([
  5083.                 'success' => false,
  5084.                 'error' => 'No client or employee found for this email'
  5085.             ], 404);
  5086.         } catch (\Exception $e) {
  5087.             return new JsonResponse([
  5088.                 'success' => false,
  5089.                 'error' => $e->getMessage()
  5090.             ], 500);
  5091.         }
  5092.     }
  5093.     public function GetRoomInformationForMeetingAction(Request $request): JsonResponse
  5094.     {
  5095.         $em $this->getDoctrine()->getManager();
  5096.         $onlyAvailable $request->query->getBoolean('onlyAvailable'false);
  5097.         $rooms HumanResourceHelper::getRooms($em$onlyAvailable);
  5098.         return new JsonResponse([
  5099.             'status' => 'success',
  5100.             'data' => $rooms
  5101.         ]);
  5102.     }
  5103.     public function MeetingTypeAction(Request $request)
  5104.     {
  5105.         return new JsonResponse([
  5106.             'success' => true,
  5107.             'data' => MeetingSchedulingConstant::$meetingType
  5108.         ]);
  5109.     }
  5110.     public function GetPriorityListAction()
  5111.     {
  5112.         $priority HumanResourceHelper::priorityList();
  5113.         return new JsonResponse([
  5114.             'success' => true,
  5115.             'data' => $priority
  5116.         ]);
  5117.     }
  5118.     public function CreateTrainingScheduleAction(Request $req$action 0)
  5119.     {
  5120.         $em $this->getDoctrine()->getManager();
  5121.         $companyId $this->getLoggedUserCompanyId($req);
  5122.         $session $req->getSession();
  5123.         if ($req->request->has('XHRreq')) {
  5124.             return new JsonResponse([HumanResource::HandelXHRreqForMeetingScheduling($em$req)]);
  5125.         }
  5126.         if ($action === 'list') {
  5127.             $response HumanResource::TwigDataForScheduledMeetingList($em, [1]);
  5128.             return $this->render(
  5129.                 'ApplicationBundle:pages/human_resource/list:scheduled_meeting_list.html.twig',
  5130.                 [
  5131.                     'page_title' => 'Training Schedule List',
  5132.                     'list' => $response
  5133.                 ]
  5134.             );
  5135.         }
  5136.         if ($req->isMethod('GET')) {
  5137.         }
  5138.         if ($req->isMethod('POST')) {
  5139.             $approveHash $req->request->get('approvalHash');
  5140.             $approveRole $req->request->get('approvalRole');
  5141.             $loginId $req->getSession()->get(UserConstants::USER_LOGIN_ID);
  5142.             $isSignatureOk DocValidation::isSignatureOk($em$loginId$approveHash);
  5143.             $companyData Company::getCompanyData($em$companyId);
  5144.             if ($isSignatureOk) {
  5145.                 $isSuccess HumanResource::createOrUpdateDataForMeetingScheduling($em$req);
  5146.                 if ($isSuccess) {
  5147.                     $options = array(
  5148.                         'notification_enabled' => $this->container->getParameter('notification_enabled'),
  5149.                         'notification_server' => $this->container->getParameter('notification_server'),
  5150.                         'appId' => $req->getSession()->get(UserConstants::USER_APP_ID),
  5151.                         'url' => $this->generateUrl(
  5152.                             GeneralConstant::$Entity_list_details[array_flip(GeneralConstant::$Entity_list)['ScheduledMeeting']]['entity_view_route_path_name']
  5153.                         )
  5154.                     );
  5155.                     $meetingId $isSuccess[1];
  5156.                     System::setApprovalInfo(
  5157.                         $this->getDoctrine()->getManager(),
  5158.                         $options,
  5159.                         array_flip(GeneralConstant::$Entity_list)['ScheduledMeeting'],
  5160.                         $meetingId,
  5161.                         $req->getSession()->get(UserConstants::USER_LOGIN_ID),
  5162.                         '',
  5163.                         0,
  5164.                         $this->get('mail_module')
  5165.                     );
  5166.                     System::createEditSignatureHash(
  5167.                         $this->getDoctrine()->getManager(),
  5168.                         array_flip(GeneralConstant::$Entity_list)['ScheduledMeeting'],
  5169.                         $meetingId,
  5170.                         $loginId,
  5171.                         $approveRole,
  5172.                         $req->request->get('approvalHash')
  5173.                     );
  5174.                     $url $this->generateUrl(
  5175.                         'view_scheduled_meeting'
  5176.                     );
  5177.                     return $this->redirect($url "/" $meetingId);
  5178.                 } else {
  5179.                     return new JsonResponse(array(
  5180.                         'success' => false
  5181.                     ));
  5182.                 }
  5183.             } else {
  5184.                 $this->addFlash(
  5185.                     'error',
  5186.                     'Invalid Approval Hash!'
  5187.                 );
  5188.                 return $this->redirectToRoute('create_training_schedule');
  5189.             }
  5190.         }
  5191.         $response HumanResource::twigDataForTrainingScheduling($em);
  5192.         return $this->render(
  5193.             'ApplicationBundle:pages/human_resource/input_forms:create_training_schedule.html.twig',
  5194.             [
  5195.                 'page_title' => 'Schedule a Training',
  5196.                 'employeeIds' => $response['employeeIds'],
  5197.                 'branches' => $response['branches'],
  5198.                 'asset' => $response['asset'],
  5199.                 'rooms' => $response['rooms'],
  5200.                 'courseList' => $response['courseList'],
  5201.                 'sales_orders' => $response['salesOrders'],
  5202.                 'purchase_orders' => $response['purchaseOrders'],
  5203.                 'meeting_types' => $response['meetingType'],
  5204.                 'skillList' => $response['skillList'],
  5205.             ]
  5206.         );
  5207.     }
  5208.     public function ScheduledTrainingListAction(Request $req$action 0)
  5209.     {
  5210.         $em $this->getDoctrine()->getManager();
  5211.         $companyId $this->getLoggedUserCompanyId($req);
  5212.         $session $req->getSession();
  5213.         $response HumanResource::TwigDataForScheduledMeetingList($em, [1]);
  5214.         return $this->render(
  5215.             'ApplicationBundle:pages/human_resource/list:scheduled_training_list.html.twig',
  5216.             [
  5217.                 'page_title' => 'Scheduled Trainings ',
  5218.                 'list' => $response
  5219.             ]
  5220.         );
  5221.     }
  5222.     public function ScheduledInterviewListAction(Request $req$action 0)
  5223.     {
  5224.         $em $this->getDoctrine()->getManager();
  5225.         $companyId $this->getLoggedUserCompanyId($req);
  5226.         $session $req->getSession();
  5227.         $response HumanResource::TwigDataForScheduledMeetingList($em, [2]);
  5228.         return $this->render(
  5229.             'ApplicationBundle:pages/human_resource/list:scheduled_interview_list.html.twig',
  5230.             [
  5231.                 'page_title' => 'Scheduled Interviews ',
  5232.                 'list' => $response
  5233.             ]
  5234.         );
  5235.     }
  5236.     public function GetFilteredQuestionsAction(Request $request$search '')
  5237.     {
  5238.         $em $this->getDoctrine()->getManager();
  5239.         $companyId $this->getLoggedUserCompanyId($request);
  5240.         if ($search == '' || $search == '_EMPTY_')
  5241.             $Query "SELECT  * FROM questionnaire WHERE 1 limit 10;";
  5242.         else
  5243.             $Query "SELECT  * FROM questionnaire WHERE question_text like '%$search%'  limit 10;";
  5244.         $stmt $em->getConnection()->prepare($Query);
  5245.         $stmt->execute();
  5246.         $queryResult $stmt->fetchAll();
  5247.         $parent_head_ids = [];
  5248.         $queryResultIndexed = [];
  5249.         foreach ($queryResult as $dt) {
  5250.             $queryResultIndexed[$dt['question_id']] = $dt;
  5251.         }
  5252.         return new JsonResponse(array(
  5253.             'data' => $queryResult,
  5254.             'queryResultIndexed' => $queryResultIndexed,
  5255.         ));
  5256.     }
  5257.     public function CreateTrainingCourseAction(Request $request$id 0)
  5258.     {
  5259.         $em $this->getDoctrine()->getManager();
  5260.         $companyId $this->getLoggedUserCompanyId($request);
  5261.         $skills $em->getRepository('ApplicationBundle:Skill')->findAll();
  5262.         $courses $em->getRepository('ApplicationBundle:TrainingCourse')->findAll();
  5263.         if ($request->isMethod('POST')) {
  5264.             $loginId $request->getSession()->get(UserConstants::USER_LOGIN_ID);
  5265.             $skill = new TrainingCourse;
  5266.             $skill->setTitle($request->request->get('name'));
  5267.             $skill->setCourseHash($request->request->get('coursehash'));
  5268.             $skill->setTrainingMaterialText($request->request->get('overview'));
  5269.             $skill->setTaggedSkillHashes(json_encode($request->request->get('skill')));
  5270.             $skill->setCompanyId($companyId);
  5271.             //$skill->setEditFlag(1); //editable usually
  5272.             $skill->setCreatedLoginId($request->getSession()->get(UserConstants::USER_LOGIN_ID));
  5273.             //$skill->setApproved(GeneralConstant::APPROVAL_STATUS_PENDING);
  5274.             //$skill->setAutocreated(0);
  5275.             $em->persist($skill);
  5276.             $em->flush();
  5277.         }
  5278.         return $this->render(
  5279.             'ApplicationBundle:pages/human_resource/input_forms:create_training_course.html.twig',
  5280.             [
  5281.                 'page_title' => 'Create Training Course',
  5282.                 'skills' => $skills,
  5283.                 'courses' => $courses
  5284.             ]
  5285.         );
  5286.     }
  5287.     public function CreateEmployeeExpenseAllowanceSettingsAction(Request $request$id 0)
  5288.     {
  5289.         $em $this->getDoctrine()->getManager();
  5290.         $companyId $this->getLoggedUserCompanyId($request);
  5291.         $extDocData = [];
  5292.         $extDetailsData = [];
  5293.         if ($request->isMethod('POST')) {
  5294.             //            Generic::debugMessage($_POST);
  5295.             $em $this->getDoctrine()->getManager();
  5296.             $entity_id array_flip(GeneralConstant::$Entity_list)['EmployeeExpenseAllowanceSettings']; //change
  5297.             $dochash $request->request->get('docHash'); //change
  5298.             $loginId $request->getSession()->get(UserConstants::USER_LOGIN_ID);
  5299.             $approveRole $request->request->get('approvalRole');
  5300.             $approveHash $request->request->get('approvalHash');
  5301.             if (!DocValidation::isInsertable(
  5302.                 $em,
  5303.                 $entity_id,
  5304.                 $dochash,
  5305.                 $loginId,
  5306.                 $approveRole,
  5307.                 $approveHash,
  5308.                 $id
  5309.             )
  5310.             ) {
  5311.                 $this->addFlash(
  5312.                     'error',
  5313.                     'Sorry Could not insert Data.'
  5314.                 );
  5315.             } else {
  5316.                 $funcname 'EmployeeExpenseAllowanceSettings';
  5317.                 DeleteDocument::$funcname($em$id0);
  5318.                 $docId HumanResource::CreateSalarySegregationPolicy($em$request$companyId0);
  5319.                 //now add Approval info
  5320.                 $loginId $request->getSession()->get(UserConstants::USER_LOGIN_ID);
  5321.                 $approveRole $request->request->get('approvalRole');
  5322.                 $options = array(
  5323.                     'notification_enabled' => $this->container->getParameter('notification_enabled'),
  5324.                     'notification_server' => $this->container->getParameter('notification_server'),
  5325.                     'appId' => $request->getSession()->get(UserConstants::USER_APP_ID),
  5326.                     'url' => $this->generateUrl(
  5327.                         GeneralConstant::$Entity_list_details[array_flip(GeneralConstant::$Entity_list)['EmployeeExpenseAllowanceSettings']]['entity_view_route_path_name']
  5328.                     )
  5329.                 );
  5330.                 System::setApprovalInfo(
  5331.                     $this->getDoctrine()->getManager(),
  5332.                     $options,
  5333.                     array_flip(GeneralConstant::$Entity_list)['EmployeeExpenseAllowanceSettings'],
  5334.                     $docId,
  5335.                     $request->getSession()->get(UserConstants::USER_LOGIN_ID)
  5336.                 );
  5337.                 System::createEditSignatureHash(
  5338.                     $this->getDoctrine()->getManager(),
  5339.                     array_flip(GeneralConstant::$Entity_list)['EmployeeExpenseAllowanceSettings'],
  5340.                     $docId,
  5341.                     $loginId,
  5342.                     $approveRole,
  5343.                     $request->request->get('approvalHash')
  5344.                 );
  5345.                 $doc_here $this->getDoctrine()
  5346.                     ->getRepository('ApplicationBundle:EmployeeExpenseAllowanceSettings')
  5347.                     ->findOneBy(
  5348.                         array(
  5349.                             'id' => $docId
  5350.                         )
  5351.                     );
  5352.                 //notify
  5353.                 $this->addFlash(
  5354.                     'success',
  5355.                     'Settings Successfully Updated.'
  5356.                 );
  5357.                 $url $this->generateUrl(
  5358.                     GeneralConstant::$Entity_list_details[array_flip(GeneralConstant::$Entity_list)['EmployeeExpenseAllowanceSettings']]['entity_view_route_path_name']
  5359.                 );
  5360.                 System::AddNewNotification(
  5361.                     $this->container->getParameter('notification_enabled'),
  5362.                     $this->container->getParameter('notification_server'),
  5363.                     $request->getSession()->get(UserConstants::USER_APP_ID),
  5364.                     $request->getSession()->get(UserConstants::USER_COMPANY_ID),
  5365.                     "Salary Segregation Policy : " $doc_here->getDocumentHash() . " Has Been Created And is Under Processing",
  5366.                     'pos',
  5367.                     System::getPositionIdsByDepartment($emGeneralConstant::HRM_DEPARTMENT),
  5368.                     'success',
  5369.                     //                    $url . "/" . $TransID,
  5370.                     $url "/" $docId,
  5371.                     "Journal"
  5372.                 );
  5373.                 return $this->redirect($url "/" $docId);
  5374.             }
  5375.         }
  5376.         //for edits
  5377.         if ($id == 0) {
  5378.         } else {
  5379.             $extDocData $em->getRepository('ApplicationBundle:EmployeeExpenseAllowanceSettings')->findOneBy(
  5380.                 array(
  5381.                     'id' => $id///material
  5382.                 )
  5383.             );
  5384.             //now if its not editable, redirect to view
  5385.             if ($extDocData) {
  5386.                 if ($extDocData->getEditFlag() != 1) {
  5387. //          $url = $this->generateUrl(
  5388. ////              'view_salary_segregation_policy'
  5389. //              'salary_segregation_policy'
  5390. //          );
  5391. //          return $this->redirect($url . "/" . $id);
  5392.                 } else {
  5393. //          $extVoucherDetailsData = Accounts::GetVoucherDataForEdit($em, $voucherId);
  5394. //          $extDetailsData = $em->getRepository('ApplicationBundle:SalarySegregationPolicy')->findOneBy(
  5395. //              array(
  5396. //                  'transactionId' => $id, ///material
  5397. //
  5398. //              )
  5399. //          );
  5400.                 }
  5401.             } else {
  5402.             }
  5403.         }
  5404.         $employeeIds $em->getRepository("ApplicationBundle:Employee")->findAll();
  5405.         $employeeType HumanResourceConstant::$employeeType;
  5406.         $employeeExpenseAllowanceTypes HumanResourceConstant::$employeeExpenseAllowanceTypes;
  5407.         $Designation $em->getRepository("ApplicationBundle:SysDepartmentPosition")->findAll();
  5408.         $branch $em->getRepository("ApplicationBundle:Branch")->findAll();
  5409.         $departments $em->getRepository("ApplicationBundle:SysDepartment")->findAll();
  5410.         $department = [];
  5411.         foreach ($departments as $entry) {
  5412.             $department[$entry->getDepartmentId()] = array(
  5413.                 'id' => $entry->getDepartmentId(),
  5414.                 'name' => $entry->getDepartmentName(),
  5415.             );
  5416.         }
  5417.         return $this->render(
  5418.             'ApplicationBundle:pages/human_resource/input_forms:create_employee_expense_allowance_settings.html.twig',
  5419.             [
  5420.                 'page_title' => 'Employee Expense Allowance Settings',
  5421.                 'employeeIds' => $employeeIds,
  5422.                 'extId' => $id,
  5423.                 'extDocData' => $extDocData,
  5424.                 'employeeType' => $employeeType,
  5425.                 'employeeExpenseAllowanceTypes' => $employeeExpenseAllowanceTypes,
  5426.                 'Designation' => $Designation,
  5427.                 'branch' => $branch,
  5428.                 'department' => $department,
  5429.             ]
  5430.         );
  5431.     }
  5432.     public function EmployeeExpenseAllowanceSettingsListAction(Request $request)
  5433.     {
  5434.         $em $this->getDoctrine()->getManager();
  5435.         $allowed_ids = [];
  5436.         $companyId $this->getLoggedUserCompanyId($request);
  5437.         $listData HumanResource::GetDataForEmployeeExpenseAllowanceSettingsListAction($em$request->isMethod('POST') ? 'POST' 'GET'$request->request$companyId);
  5438.         if ($request->isMethod('POST')) {
  5439.             if ($request->query->has('dataTableQry')) {
  5440.                 return new JsonResponse(
  5441.                     $listData
  5442.                 );
  5443.             }
  5444.         }
  5445.         return $this->render('ApplicationBundle:pages/human_resource/list:employee_expense_allowance_settings_list.html.twig',
  5446. //         return $this->render('ApplicationBundle:pages/dashboard:test_pix_invent.html.twig',
  5447.             array(
  5448.                 'page_title' => 'Expense Allowance Settings List',
  5449. //            'data' => SalesOrderM::GetClientList($em, [], $companyId),
  5450. //            'client_types' => Client::GetClientType($em, $companyId),
  5451. //            'region_list' => Client::RegionList($em, $companyId),
  5452. //            'geographical_region_list' => Client::GeographicalRegionList($em, $companyId)
  5453.             )
  5454.         );
  5455.     }
  5456.     public function salarySegAction(Request $request$id 0)
  5457.     {
  5458.         $em $this->getDoctrine()->getManager();
  5459.         $companyId $this->getLoggedUserCompanyId($request);
  5460.         $extDocData = [];
  5461.         $extDetailsData = [];
  5462.         if ($request->isMethod('POST')) {
  5463.             //            Generic::debugMessage($_POST);
  5464.             $em $this->getDoctrine()->getManager();
  5465.             $entity_id array_flip(GeneralConstant::$Entity_list)['SalarySegregationPolicy']; //change
  5466.             $dochash $request->request->get('docHash'); //change
  5467.             $loginId $request->getSession()->get(UserConstants::USER_LOGIN_ID);
  5468.             $approveRole $request->request->get('approvalRole');
  5469.             $approveHash $request->request->get('approvalHash');
  5470.             if (!DocValidation::isInsertable(
  5471.                 $em,
  5472.                 $entity_id,
  5473.                 $dochash,
  5474.                 $loginId,
  5475.                 $approveRole,
  5476.                 $approveHash,
  5477.                 $id
  5478.             )
  5479.             ) {
  5480.                 $this->addFlash(
  5481.                     'error',
  5482.                     'Sorry Couldnot insert Data.'
  5483.                 );
  5484.             } else {
  5485.                 $funcname 'SalarySegregationPolicy';
  5486.                 DeleteDocument::$funcname($em$id0);
  5487.                 $docId HumanResource::CreateSalarySegregationPolicy($em$request$companyId0);
  5488.                 //now add Approval info
  5489.                 $loginId $request->getSession()->get(UserConstants::USER_LOGIN_ID);
  5490.                 $approveRole $request->request->get('approvalRole');
  5491.                 $options = array(
  5492.                     'notification_enabled' => $this->container->getParameter('notification_enabled'),
  5493.                     'notification_server' => $this->container->getParameter('notification_server'),
  5494.                     'appId' => $request->getSession()->get(UserConstants::USER_APP_ID),
  5495.                     'url' => $this->generateUrl(
  5496.                         GeneralConstant::$Entity_list_details[array_flip(GeneralConstant::$Entity_list)['SalarySegregationPolicy']]['entity_view_route_path_name']
  5497.                     )
  5498.                 );
  5499.                 System::setApprovalInfo(
  5500.                     $this->getDoctrine()->getManager(),
  5501.                     $options,
  5502.                     array_flip(GeneralConstant::$Entity_list)['SalarySegregationPolicy'],
  5503.                     $docId,
  5504.                     $request->getSession()->get(UserConstants::USER_LOGIN_ID),
  5505.                     3    //journal voucher
  5506.                 );
  5507.                 System::createEditSignatureHash(
  5508.                     $this->getDoctrine()->getManager(),
  5509.                     array_flip(GeneralConstant::$Entity_list)['SalarySegregationPolicy'],
  5510.                     $docId,
  5511.                     $loginId,
  5512.                     $approveRole,
  5513.                     $request->request->get('approvalHash')
  5514.                 );
  5515.                 $doc_here $this->getDoctrine()
  5516.                     ->getRepository('ApplicationBundle:SalarySegregationPolicy')
  5517.                     ->findOneBy(
  5518.                         array(
  5519.                             'id' => $docId
  5520.                         )
  5521.                     );
  5522.                 //notify
  5523.                 $this->addFlash(
  5524.                     'success',
  5525.                     'Policy Successfully Updated.'
  5526.                 );
  5527.                 $url $this->generateUrl(
  5528.                     'salary_segregation_policy'
  5529.                 );
  5530.                 System::AddNewNotification(
  5531.                     $this->container->getParameter('notification_enabled'),
  5532.                     $this->container->getParameter('notification_server'),
  5533.                     $request->getSession()->get(UserConstants::USER_APP_ID),
  5534.                     $request->getSession()->get(UserConstants::USER_COMPANY_ID),
  5535.                     "Salary Segregation Policy : " $doc_here->getDocumentHash() . " Has Been Created And is Under Processing",
  5536.                     'pos',
  5537.                     System::getPositionIdsByDepartment($emGeneralConstant::HRM_DEPARTMENT),
  5538.                     'success',
  5539.                     //                    $url . "/" . $TransID,
  5540.                     $url "/" $docId,
  5541.                     "Journal"
  5542.                 );
  5543.                 return $this->redirect($url "/" $docId);
  5544.             }
  5545.         }
  5546.         //for edits
  5547.         if ($id == 0) {
  5548.         } else {
  5549.             $extDocData $em->getRepository('ApplicationBundle:SalarySegregationPolicy')->findOneBy(
  5550.                 array(
  5551.                     'id' => $id///material
  5552.                 )
  5553.             );
  5554.             //now if its not editable, redirect to view
  5555.             if ($extDocData) {
  5556.                 if ($extDocData->getEditFlag() != 1) {
  5557. //          $url = $this->generateUrl(
  5558. ////              'view_salary_segregation_policy'
  5559. //              'salary_segregation_policy'
  5560. //          );
  5561. //          return $this->redirect($url . "/" . $id);
  5562.                 } else {
  5563. //          $extVoucherDetailsData = Accounts::GetVoucherDataForEdit($em, $voucherId);
  5564. //          $extDetailsData = $em->getRepository('ApplicationBundle:SalarySegregationPolicy')->findOneBy(
  5565. //              array(
  5566. //                  'transactionId' => $id, ///material
  5567. //
  5568. //              )
  5569. //          );
  5570.                 }
  5571.             } else {
  5572.             }
  5573.         }
  5574.         $employeeIds $em->getRepository(EmployeeDetails::class)->findAll();
  5575.         $employeeType HumanResourceConstant::$employeeType;
  5576.         $Designation $em->getRepository(SysDepartmentPosition::class)->findAll();
  5577.         $branch $em->getRepository(Branch::class)->findAll();
  5578.         $departments $em->getRepository(SysDepartment::class)->findAll();
  5579.         $department = [];
  5580.         foreach ($departments as $entry) {
  5581.             $department[$entry->getDepartmentId()] = array(
  5582.                 'id' => $entry->getDepartmentId(),
  5583.                 'name' => $entry->getDepartmentName(),
  5584.             );
  5585.         }
  5586.         return $this->render(
  5587.             'ApplicationBundle:pages/human_resource/input_forms:salary_segregation_policy.html.twig',
  5588.             [
  5589.                 'page_title' => 'Salary Segregation Policy',
  5590.                 'employeeIds' => $employeeIds,
  5591.                 'extId' => $id,
  5592.                 'extDocData' => $extDocData,
  5593.                 'employeeType' => $employeeType,
  5594.                 'Designation' => $Designation,
  5595.                 'branch' => $branch,
  5596.                 'department' => $department,
  5597.             ]
  5598.         );
  5599.     }
  5600.     public function GetSalarySegregationDataForEmployeeEntryAction(Request $request)
  5601.     {
  5602.         $em $this->getDoctrine()->getManager();
  5603.         $companyId $this->getLoggedUserCompanyId($request);
  5604.         if ($request->request->has('salSagDataReq')) {
  5605.             $ajaxData HumanResource::handelXhrForSalSeg($em$request);
  5606.             return new JsonResponse($ajaxData);
  5607.         }
  5608.         return new JsonResponse(array('success' => false));
  5609.     }
  5610.     public function WorkHourPolicyAction(Request $req$id 0)
  5611.     {
  5612.         $em $this->getDoctrine()->getManager();
  5613.         $companyId $this->getLoggedUserCompanyId($req);
  5614.         $extData = [];
  5615.         if ($id != 0) {
  5616.             $extData $em->getRepository('ApplicationBundle:WorkHourPolicy')
  5617.                 ->findOneBy(
  5618.                     array(
  5619.                         'id' => $id
  5620.                     )
  5621.                 );
  5622.         }
  5623.         if ($req->isMethod('POST')) {
  5624.             $storeDataRes HumanResource::checkSignature($em$req);
  5625.             if ($storeDataRes['hasErr']) {
  5626.                 $msg $storeDataRes['msg'];
  5627.                 $this->addFlash(
  5628.                     'error',
  5629.                     $msg
  5630.                 );
  5631.                 return $this->redirectToRoute('work_hour_policy');
  5632.             } else {
  5633.                 HumanResource::storeDataForWhPolicy($em$req$companyId);
  5634.                 $this->addFlash(
  5635.                     'success',
  5636.                     'Policy Successfully Created!'
  5637.                 );
  5638.                 return $this->redirectToRoute('work_hour_policy');
  5639.             }
  5640.         }
  5641.         $twigData HumanResource::twigDataForWorkHourPolicy($em);
  5642.         $timeZonesArray = array();
  5643.         return $this->render(
  5644.             'ApplicationBundle:pages/human_resource/input_forms:work_hour_policy.html.twig',
  5645.             [
  5646.                 'page_title' => 'Work Hour Policy',
  5647.                 'extId' => $id,
  5648.                 'extData' => $extData,
  5649.                 'employeeIds' => $twigData['employeeIds'],
  5650.                 'employeeType' => $twigData['employeeType'],
  5651.                 'Designation' => $twigData['Designation'],
  5652.                 'branch' => $twigData['branch'],
  5653.                 'department' => $twigData['department'],
  5654.             ]
  5655.         );
  5656.     }
  5657.     public function WorkHourPolicyListAction(Request $request)
  5658.     {
  5659.         $em $this->getDoctrine()->getManager();
  5660.         $allowed_ids = [];
  5661.         $companyId $this->getLoggedUserCompanyId($request);
  5662.         $listData HumanResource::GetDataForWorkHourPolicyListAction($em$request->isMethod('POST') ? 'POST' 'GET'$request->request$companyId);
  5663.         if ($request->isMethod('POST')) {
  5664.             if ($request->query->has('dataTableQry')) {
  5665.                 return new JsonResponse(
  5666.                     $listData
  5667.                 );
  5668.             }
  5669.         }
  5670.         return $this->render('ApplicationBundle:pages/human_resource/list:work_hour_policy_list.html.twig',
  5671. //         return $this->render('ApplicationBundle:pages/dashboard:test_pix_invent.html.twig',
  5672.             array(
  5673.                 'page_title' => 'Work Hour Policy List',
  5674. //            'data' => SalesOrderM::GetClientList($em, [], $companyId),
  5675. //            'client_types' => Client::GetClientType($em, $companyId),
  5676. //            'region_list' => Client::RegionList($em, $companyId),
  5677. //            'geographical_region_list' => Client::GeographicalRegionList($em, $companyId)
  5678.             )
  5679.         );
  5680.     }
  5681.     public function WorkPlacePolicyListAction(Request $request)
  5682.     {
  5683.         $em $this->getDoctrine()->getManager();
  5684.         $workplacePolicyDetails $em->getRepository('ApplicationBundle:EmployeeWorkplace')->findAll();
  5685. //        $employee = $em->getRepository('ApplicationBundle:Employee')->findAll();
  5686.         return $this->render('ApplicationBundle:pages/human_resource/list:work_place_policy_list.html.twig', array(
  5687.             'page_title' => 'Work Place Policy List',
  5688.             'workplacePolicyDetails' => $workplacePolicyDetails,
  5689. //            'employee'=>$employee
  5690.         ));
  5691.     }
  5692.     public function workPlacePolicyAction(Request $data$id)
  5693.     {
  5694.         $em $this->getDoctrine()->getManager();
  5695.         $workPlacePolicy $em->getRepository('ApplicationBundle:EmployeeWorkplace')->find($id);
  5696.         $employee $em->getRepository(Employee::class)->findAll();
  5697.         $Approval_data System::checkIfApprovalExists(
  5698.             $em,
  5699.             array_flip(GeneralConstant::$Entity_list)['EmployeeWorkplace'],
  5700.             $id,
  5701.             $data->getSession()->get(UserConstants::USER_LOGIN_ID)
  5702.         );
  5703.         $ApprovalStatus GeneralConstant::$approvalStatus;
  5704.         return $this->render('ApplicationBundle:pages/human_resource/views:viewWorkPlacePolicy.html.twig', array(
  5705.             'page_title' => 'Work Place Policy  View',
  5706.             'workPlacePolicy' => $workPlacePolicy,
  5707.             'employee' => $employee,
  5708.             'approval_data' => $Approval_data,
  5709.             'approval_status' => $workPlacePolicy->getApproved(),
  5710.             'id' => $id,
  5711.         ));
  5712.     }
  5713.     public function SalarySegregationPolicyListAction(Request $request)
  5714.     {
  5715.         $em $this->getDoctrine()->getManager();
  5716.         $allowed_ids = [];
  5717.         $companyId $this->getLoggedUserCompanyId($request);
  5718.         $listData HumanResource::GetDataForSalarySegregationPolicyListAction($em$request->isMethod('POST') ? 'POST' 'GET'$request->request$companyId);
  5719.         if ($request->isMethod('POST')) {
  5720.             if ($request->query->has('dataTableQry')) {
  5721.                 return new JsonResponse(
  5722.                     $listData
  5723.                 );
  5724.             }
  5725.         }
  5726.         return $this->render('ApplicationBundle:pages/human_resource/list:salary_segregation_policy_list.html.twig',
  5727. //         return $this->render('ApplicationBundle:pages/dashboard:test_pix_invent.html.twig',
  5728.             array(
  5729.                 'page_title' => 'Salary Segregation Policy List',
  5730. //            'data' => SalesOrderM::GetClientList($em, [], $companyId),
  5731. //            'client_types' => Client::GetClientType($em, $companyId),
  5732. //            'region_list' => Client::RegionList($em, $companyId),
  5733. //            'geographical_region_list' => Client::GeographicalRegionList($em, $companyId)
  5734.             )
  5735.         );
  5736.     }
  5737.     public function HolidayCalendarListAction(Request $request)
  5738.     {
  5739.         $q $this->getDoctrine()
  5740.             ->getRepository('ApplicationBundle:HolidayCalendar')
  5741.             ->findBy(
  5742.                 array(
  5743. //                'status' => GeneralConstant::ACTIVE,
  5744.                     'CompanyId' => $this->getLoggedUserCompanyId($request)
  5745. //                    'approved' =>  GeneralConstant::APPROVED,
  5746.                 )
  5747.             );
  5748.         $stage_list = array(
  5749.             => 'Pending',
  5750.             => 'Pending',
  5751.             => 'Complete',
  5752.             => 'Partial',
  5753.         );
  5754.         $data = [];
  5755.         foreach ($q as $entry) {
  5756.             $data[] = array(
  5757. //          'doc_date' => $entry->getSalesReplacementDate(),
  5758.                 'id' => $entry->getHolidayCalendarId(),
  5759.                 'title' => $entry->getHoliDayTitle(),
  5760.                 'approval_status' => GeneralConstant::$approvalStatus[$entry->getApproved()],
  5761. //          'stage' => $stage_list[$entry->getStage()]
  5762.             );
  5763.         }
  5764.         return $this->render('ApplicationBundle:pages/human_resource/list:holiday_calendar_list.html.twig',
  5765.             array(
  5766.                 'page_title' => 'Holiday Calendar List',
  5767.                 'data' => $data
  5768.             )
  5769.         );
  5770.     }
  5771.     public function PayrollPolicyListAction(Request $request)
  5772.     {
  5773.         $em $this->getDoctrine()->getManager();
  5774.         $allowed_ids = [];
  5775.         $companyId $this->getLoggedUserCompanyId($request);
  5776.         $listData HumanResource::GetDataForPayrollPolicyListAction($em$request->isMethod('POST') ? 'POST' 'GET'$request->request$companyId);
  5777.         if ($request->isMethod('POST')) {
  5778.             if ($request->query->has('dataTableQry')) {
  5779.                 return new JsonResponse(
  5780.                     $listData
  5781.                 );
  5782.             }
  5783.         }
  5784.         return $this->render('ApplicationBundle:pages/human_resource/list:payroll_policy_list.html.twig',
  5785. //         return $this->render('ApplicationBundle:pages/dashboard:test_pix_invent.html.twig',
  5786.             array(
  5787.                 'page_title' => 'Payroll Policy List',
  5788. //            'data' => SalesOrderM::GetClientList($em, [], $companyId),
  5789. //            'client_types' => Client::GetClientType($em, $companyId),
  5790. //            'region_list' => Client::RegionList($em, $companyId),
  5791. //            'geographical_region_list' => Client::GeographicalRegionList($em, $companyId)
  5792.             )
  5793.         );
  5794.     }
  5795.     public function payslipAction(Request $req$action 0$id 0)
  5796.     {
  5797.         $em $this->getDoctrine()->getManager();
  5798.         $attendanceSource HumanResourceConstant::$attendanceSources;
  5799.         if ($action === 'list') {
  5800.             $response HumanResource::twigDataForPayslipList($em);
  5801.             $approval_status GeneralConstant::$approvalAction;
  5802.             return $this->render(
  5803.                 'ApplicationBundle:pages/human_resource/list:payslip_list.html.twig',
  5804.                 [
  5805.                     'page_title' => 'Payslip List',
  5806.                     'reports' => $response,
  5807.                     'approval_status' => $approval_status
  5808.                 ]
  5809.             );
  5810.         }
  5811.         if ($action === 'view') {
  5812.             $response HumanResource::twigDataForPayslipViewAndPrint($em$req$id);
  5813.             return $this->render(
  5814.                 'ApplicationBundle:pages/human_resource/views:payslip_view.html.twig',
  5815.                 [
  5816.                     'page_title' => 'View Payslip',
  5817.                     'approval_data' => $response['approval_data'],
  5818.                     'payslip' => $response['payslip'],
  5819.                     'bankAccount' => $response['bankAccount'],
  5820.                     'tin' => $response['tin'],
  5821.                     'employeeCode' => $response['employeeCode'],
  5822.                     'earningValues' => $response['earningValues'],
  5823.                     'facilityValues' => $response['facilityValues'],
  5824.                     'deductionValues' => $response['deductionValues'],
  5825.                     'document_log' => $response['document_log'],
  5826.                     'approval_status' => $response['approval_status'],
  5827.                     'created_by' => $response['created_by'],
  5828.                     'updated_at' => $response['updated_at'],
  5829.                     'employeeId' => $response['employeeId'],
  5830.                     'totalAttendance' => $response['totalPresent'],
  5831.                     'leaveList' => HumanResourceConstant::$LeaveType,
  5832.                     'AttReportData' => $response['AttReportData'],
  5833. //                    'attendanceLog' => $response['attendanceLog'],
  5834.                     'attendanceSource' => $attendanceSource,
  5835.                     'auto_created' => 0,
  5836.                 ]
  5837.             );
  5838.         }
  5839.         if ($action === 'print') {
  5840.             $em $this->getDoctrine()->getManager();
  5841.             $company_data Company::getCompanyData($em1);
  5842.             $Authorizations System::getSignatureListForDocumentPrint($emarray_flip(GeneralConstant::$Entity_list)['Payslip'], $id);
  5843.             $response HumanResource::twigDataForPayslipViewAndPrint($em$req$id);
  5844.             return $this->render(
  5845.                 'ApplicationBundle:pages/human_resource/print:payslip_print.html.twig',
  5846.                 array(
  5847.                     'page_title' => 'Print Payslip',
  5848.                     'export' => 'pdf,print',
  5849.                     'payslip' => $response['payslip'],
  5850.                     'bankAccount' => $response['bankAccount'],
  5851.                     'tin' => $response['tin'],
  5852.                     'employeeCode' => $response['employeeCode'],
  5853.                     'earningValues' => $response['earningValues'],
  5854.                     'facilityValues' => $response['facilityValues'],
  5855.                     'deductionValues' => $response['deductionValues'],
  5856.                     'company_name' => $company_data->getName(),
  5857.                     'company_data' => $company_data,
  5858.                     'company_address' => $company_data->getAddress(),
  5859.                     'company_image' => $company_data->getImage(),
  5860.                     'Authorizations' => $Authorizations,
  5861.                     'totalAttendance' => $response['totalPresent'],
  5862.                     'leaveList' => HumanResourceConstant::$LeaveType,
  5863.                     'AttReportData' => $response['AttReportData'],
  5864.                     'attendanceSource' => $attendanceSource,
  5865.                     'red' => 0
  5866.                 )
  5867.             );
  5868.         }
  5869.         if ($req->isMethod('POST')) {
  5870.             $sigRes HumanResource::checkSignature($em$req);
  5871.             if ($sigRes['hasErr']) {
  5872.                 $msg $sigRes['msg'];
  5873.                 return new JsonResponse(['success' => false'msg' => $msg]);
  5874.             }
  5875.             HumanResource::storeDataForPayslip($em$req);
  5876.             return new JsonResponse(['success' => true]);
  5877.         }
  5878.     }
  5879.     public function applicantInfoAction(Request $request$id)
  5880.     {
  5881.         $em $this->getDoctrine()->getManager('company_group');
  5882.         $session $request->getSession();
  5883.         $consultantDetails $em->getRepository(EntityApplicantDetails::class)->find($session->get(UserConstants::USER_ID));
  5884.         $skillDetails $em->getRepository(EntitySkill::class)->findAll();
  5885.         $companyId $this->getLoggedUserCompanyId($request);
  5886.         $gender HumanResourceConstant::$sex;
  5887.         $blood HumanResourceConstant::$BloodGroup;
  5888.         $userId $session->get(UserConstants::USER_ID);
  5889.         $encData $request->query->has('ref') ? $request->query->get('ref') : '';
  5890.         $education = array(
  5891.             'instituteName' => $request->get('instituteName'),
  5892.             'courseOfStudy' => $request->get('courseOfStudy'),
  5893.             'courseStartDate' => $request->get('courseStartDate'),
  5894.             'courseEndDate' => $request->get('courseEndDate'),
  5895.             'result' => $request->get('result'),
  5896.             'grade' => $request->get('grade'),
  5897.             'degree' => $request->get('degree'),
  5898.         );
  5899.         $workExperience = array(
  5900.             'title' => $request->get('title'),
  5901.             'companyName' => $request->get('companyName'),
  5902.             'jobStartDate' => $request->get('jobStartDate'),
  5903.             'jobEndDate' => $request->get('jobEndDate'),
  5904.             'description' => $request->get('description'),
  5905.         );
  5906.         $certificate = array(
  5907.             'certificatename' => $request->get('certificatename'),
  5908.             'issuedDate' => $request->get('issuedDate'),
  5909.         );
  5910.         $courses = array(
  5911.             'courseName' => $request->get('courseName'),
  5912.             'date' => $request->get('date'),
  5913.             'duration' => $request->get('duration')
  5914.         );
  5915.         $languages = array(
  5916.             'languageName' => $request->get('languageName'),
  5917.             'writtenSkill' => $request->get('writtenSkill'),
  5918.             'verbalSkill' => $request->get('verbalSkill'),
  5919.         );
  5920.         if ($request->isMethod('POST')) {
  5921.             if ($consultantDetails)
  5922.                 $consultant $consultantDetails;
  5923.             else
  5924.                 $consultant = new EntityApplicantDetails();
  5925.             $consultant->setApplicationText($request->request->get('applicationText'));
  5926.             $consultant->setFirstname($request->request->get('firstname'));
  5927.             $consultant->setLastname($request->request->get('lastname'));
  5928.             $consultant->setIsImgLegal($request->request->get('is_img_legal'));
  5929.             $consultant->setNid($request->request->get('nid'));
  5930.             $consultant->setDob(new \DateTime($request->get('dob')));
  5931.             $consultant->setSex($request->request->get('sex'));
  5932.             $consultant->setFather($request->request->get('father'));
  5933.             $consultant->setMother($request->request->get('mother'));
  5934.             $consultant->setBlood($request->request->get('blood'));
  5935.             $consultant->setPhone($request->request->get('phone'));
  5936.             $consultant->setCountry($request->request->get('country'));
  5937.             $consultant->setPostalCode($request->request->get('postalCode'));
  5938.             $consultant->setCurrAddr($request->request->get('curr_addr'));
  5939.             $consultant->setSkill(json_encode($request->request->get('skill')));
  5940.             $consultant->setEmergencyContactNumber($request->request->get('emm_contact'));
  5941.             $consultant->setCurrentEmployment($request->request->get('currentEmployment'));
  5942.             $consultant->setTin($request->request->get('tin'));
  5943.             $consultant->setEducationData(json_encode($education));
  5944.             $consultant->setWorkExperienceData(json_encode($workExperience));
  5945.             $consultant->setCertificateData(json_encode($certificate));
  5946.             $consultant->setCoursesData(json_encode($courses));
  5947.             $consultant->setLanguagesData(json_encode($languages));
  5948.             $consultant->setWorkExperienceYear($request->request->get('workExperienceYear'));
  5949.             //$consultant->setApplyForConsultant(1);
  5950.             $em->persist($consultant);
  5951.             $em->flush();
  5952.             $path "";
  5953.             $defaultProductImage '';
  5954.             $uploadedFile null;
  5955.             $upl_dir $this->container->getParameter('kernel.root_dir') . '/../web/uploads/applicantCv/';
  5956.             $uploadedFile $request->files->get('docUpload');
  5957.             if ($uploadedFile != null) {
  5958.                 $fileName 'cv' $consultantDetails->getApplicantId() . '.' $uploadedFile->guessExtension();
  5959.                 $path $fileName;
  5960. //            $upl_dir = $this->container->getParameter('kernel.root_dir') . '/../web/uploads/Products/';
  5961.                 if (!file_exists($upl_dir)) {
  5962.                     mkdir($upl_dir0777true);
  5963.                 }
  5964.                 $uploadedFile->move($upl_dir$path);
  5965.                 $defaultProductImage 'uploads/applicantCv/' $path;
  5966.                 $consultant->setDocImage($defaultProductImage);
  5967.                 $em->flush();
  5968.             }
  5969.             $this->addFlash(
  5970.                 'success',
  5971.                 'Data Updated.'
  5972.             );
  5973.             if ($encData != '') {
  5974.                 $url $this->generateUrl(
  5975.                     'applicant_job_recruitment_view'
  5976.                 );
  5977.                 return $this->redirect($url '?auto_apply=1&encData=' $encData);
  5978.             }
  5979.             $url $this->generateUrl(
  5980.                 'job_recruitment_list_applicant'
  5981.             );
  5982.             return $this->redirect($url);
  5983.         }
  5984.         return $this->render('ApplicationBundle:pages/human_resource/input_forms:applicant_info.html.twig', array(
  5985.             'page_title' => 'My Information ',
  5986.             'gender' => $gender,
  5987.             'blood' => $blood,
  5988.             'consultantDetails' => $consultantDetails,
  5989.             'education' => json_decode($consultantDetails->getEducationData(), true),
  5990.             'workExperience' => json_decode($consultantDetails->getWorkExperienceData(), true),
  5991.             'certificate' => json_decode($consultantDetails->getCertificateData(), true),
  5992.             'courses' => json_decode($consultantDetails->getCoursesData(), true),
  5993.             'languages' => json_decode($consultantDetails->getLanguagesData(), true),
  5994.             'skill' => json_decode($consultantDetails->getSkill(), true),
  5995.             'skillDetails' => $skillDetails
  5996.         ));
  5997. //        $em = $this->getDoctrine()->getManager('company_group');
  5998. //        $applicantRepo = $em->getRepository(EntityApplicantDetails::class);
  5999. //        $skillDetails = $em->getRepository(EntitySkill::class)->findAll();
  6000. //
  6001. //
  6002. //        if ($req->isMethod('POST')) {
  6003. //            $applicant = $applicantRepo->find($id);
  6004. //
  6005. //            if ($req->files->get('img')) {
  6006. //                $ImgName = HumanResource::StoreFiles($req->files->get('img'), 'Applicant');
  6007. //                $applicant->setImage($ImgName);
  6008. //            }
  6009. //
  6010. //            $applicant->setFirstname($req->request->get('firstname'));
  6011. //            $applicant->setLastname($req->request->get('lastname'));
  6012. //            $applicant->setIsImgLegal($req->request->get('is_img_legal'));
  6013. //            $applicant->setNid($req->request->get('nid'));
  6014. //            $applicant->setDob(HumanResource::StringToDate($req->request->get('dob')));
  6015. //            $applicant->setSex($req->request->get('sex'));
  6016. //            $applicant->setFather($req->request->get('father'));
  6017. //            $applicant->setMother($req->request->get('mother'));
  6018. //            $applicant->setSpouse($req->request->get('spouse'));
  6019. //            $applicant->setChild1($req->request->get('child_1'));
  6020. //            $applicant->setChild2($req->request->get('child_2'));
  6021. //            $applicant->setBlood($req->request->get('blood'));
  6022. //            $applicant->setPhone($req->request->get('phone'));
  6023. //            $applicant->setOAuthEmail($req->request->get('oauth_email'));
  6024. //            $applicant->setCurrAddr($req->request->get('curr_addr'));
  6025. //            $applicant->setPermAddr($req->request->get('perm_addr'));
  6026. //            $applicant->setEmmContact($req->request->get('emm_contact'));
  6027. //
  6028. //            $applicant->setInst1($req->request->get('inst1'));
  6029. //            $applicant->setYr1($req->request->get('yr1'));
  6030. //            $applicant->setDur1($req->request->get('dur1'));
  6031. //            $applicant->setInst2($req->request->get('inst2'));
  6032. //            $applicant->setYr2($req->request->get('yr2'));
  6033. //            $applicant->setDur2($req->request->get('dur2'));
  6034. //            $applicant->setInst3($req->request->get('inst3'));
  6035. //            $applicant->setYr3($req->request->get('yr3'));
  6036. //            $applicant->setDur3($req->request->get('dur3'));
  6037. //            $applicant->setEinst1($req->request->get('einst1'));
  6038. //            $applicant->setEyr1($req->request->get('eyr1'));
  6039. //            $applicant->setEdeg1($req->request->get('edeg1'));
  6040. //            $applicant->setEinst2($req->request->get('einst2'));
  6041. //            $applicant->setEyr2($req->request->get('eyr2'));
  6042. //            $applicant->setEdeg2($req->request->get('edeg2'));
  6043. //            $applicant->setEinst3($req->request->get('einst3'));
  6044. //            $applicant->setEyr3($req->request->get('eyr3'));
  6045. //            $applicant->setEdeg3($req->request->get('edeg3'));
  6046. //
  6047. //            $em->persist($applicant);
  6048. //            $em->flush();
  6049. //
  6050. //            return $this->render(
  6051. //                'ApplicationBundle:pages/human_resource/input_forms:applicant_info.html.twig',
  6052. //                [
  6053. //                    'page_title' => 'Applicant Info',
  6054. //                    'applicant_info' => $applicant,
  6055. //                    'blood' => HumanResourceConstant::$BloodGroup,
  6056. //                    'gender' => HumanResourceConstant::$sex,
  6057. //                    'skillDetails' => $skillDetails,
  6058. //                    'HasUpdateMode' => true,
  6059. //                ]
  6060. //            );
  6061. //        }
  6062. //
  6063. //        if ($id) {
  6064. //            $applicant = $applicantRepo->find($id);
  6065. //
  6066. //            return $this->render(
  6067. //                'ApplicationBundle:pages/human_resource/input_forms:applicant_info.html.twig',
  6068. //                [
  6069. //                    'page_title' => 'Applicant Info',
  6070. //                    'applicant_info' => $applicant,
  6071. //                    'blood' => HumanResourceConstant::$BloodGroup,
  6072. //                    'gender' => HumanResourceConstant::$sex,
  6073. //                    'skillDetails' => $skillDetails,
  6074. //                    'HasUpdateMode' => false,
  6075. //                ]
  6076. //            );
  6077. //        }
  6078. //
  6079. //        $google_client = new Google_Client();
  6080. //        $google_client->setClientId('916737688016-l2qfmb9p37cumudkaqpu8s7ndngq9una.apps.googleusercontent.com');
  6081. //        $google_client->setClientSecret('BEWpEBRvv3-hSoB4cGBrVB3z');
  6082. //        $google_client->setRedirectUri('http://localhost/applicant_info');
  6083. //        $google_client->addScope('email');
  6084. //        $google_client->addScope('profile');
  6085.     }
  6086.     public function applicantDashboardAction()
  6087.     {
  6088.         return new JsonResponse(['this is applicant dashboard']);
  6089.     }
  6090.     public function resignApplicationAction(Request $req$id)
  6091.     {
  6092.         $em $this->getDoctrine()->getManager();
  6093.         if ($req->request->has('xhrReq')) {
  6094.             $response HumanResource::HandelXhrForResignApplication($em$req);
  6095.             return new JsonResponse($response);
  6096.         }
  6097.         if ($req->isMethod('GET')) {
  6098.             $applicant $em->getRepository(EmployeeDetails::class)->findBy(['emp_status' => 1]);
  6099.             $resignReason HumanResourceConstant::$resignReason;
  6100.             return $this->render(
  6101.                 'ApplicationBundle:pages/human_resource/input_forms:resign_application.html.twig',
  6102.                 [
  6103.                     'page_title' => 'Resign Application',
  6104.                     'employeeIds' => $applicant,
  6105.                     'resignReasons' => $resignReason,
  6106.                     'HasUpdateMode' => false,
  6107.                 ]
  6108.             );
  6109.         }
  6110.         if ($req->isMethod('POST')) {
  6111.             $approveHash $req->request->get('approvalHash');
  6112.             $loginId $req->getSession()->get(UserConstants::USER_LOGIN_ID);
  6113.             $isSignatureOk DocValidation::isSignatureOk($em$loginId$approveHash);
  6114.             if ($isSignatureOk) {
  6115.                 $response HumanResource::storeResignApplicationData($em$req);
  6116.                 if ($response) {
  6117.                     return $this->redirectToRoute(
  6118.                         'view_resign_application',
  6119.                         array('id' => $response->getResignApplicationId()),
  6120.                         Response::HTTP_MOVED_PERMANENTLY
  6121.                     );
  6122.                 }
  6123.             } else {
  6124.                 $this->addFlash(
  6125.                     'error',
  6126.                     'Invalid Approval Hash!'
  6127.                 );
  6128.                 return $this->redirectToRoute('resign_application');
  6129.             }
  6130.         }
  6131.     }
  6132.     public function viewResignApplicationAction(Request $req$id 0)
  6133.     {
  6134.         $em $this->getDoctrine()->getManager();
  6135.         $response HumanResource::twigDataForResignApplicationView($em$req$id);
  6136.         return $this->render(
  6137.             'ApplicationBundle:pages/human_resource/views:resign_application_view.html.twig',
  6138.             [
  6139.                 'page_title' => 'View Resign Application',
  6140.                 'approval_data' => $response['approval_data'],
  6141.                 'application' => $response['application'],
  6142.                 'applicant' => $response['applicant'],
  6143.                 'document_log' => $response['document_log'],
  6144.                 'approval_status' => $response['approval_status'],
  6145.                 'created_by' => $response['created_by'],
  6146.                 'updated_at' => $response['updated_at'],
  6147.                 'auto_created' => 0,
  6148.             ]
  6149.         );
  6150.     }
  6151.     public function printResignApplicationAction(Request $req$id)
  6152.     {
  6153.         if ($id) {
  6154.             $em $this->getDoctrine()->getManager();
  6155.             $company_data Company::getCompanyData($em1);
  6156.             $authorizations System::getSignatureListForDocumentPrint($emarray_flip(GeneralConstant::$Entity_list)['ResignApplication'], $id);
  6157.             $response HumanResource::twigDataForResignApplicationView($em$req$id);
  6158.             return $this->render(
  6159.                 'ApplicationBundle:pages/human_resource/print:resign_application_print.html.twig',
  6160.                 array(
  6161.                     'page_title' => 'Print Resign Application',
  6162.                     'export' => 'pdf,print',
  6163.                     'company_name' => $company_data->getName(),
  6164.                     'company_data' => $company_data,
  6165.                     'company_address' => $company_data->getAddress(),
  6166.                     'company_image' => $company_data->getImage(),
  6167.                     'application' => $response['application'],
  6168.                     'applicant' => $response['applicant'],
  6169.                     'Authorizations' => $authorizations,
  6170.                     'red' => 0
  6171.                 )
  6172.             );
  6173.         }
  6174.         return new JsonResponse(array(
  6175.             'success' => false,
  6176.             'msg' => 'Wrong URL format! Please try with application ID'
  6177.         ));
  6178.     }
  6179.     public function listResignApplicationAction(Request $req)
  6180.     {
  6181.         $em $this->getDoctrine()->getManager();
  6182.         $response HumanResource::getResignApplicationList($em$req);
  6183.         return $this->render("ApplicationBundle:pages/human_resource/list:resign_application_list.html.twig", array(
  6184.             'page_title' => 'Resign Application List',
  6185.             'applications' => $response,
  6186.         ));
  6187.     }
  6188.     public function viewNocApprovalAction(Request $req$id)
  6189.     {
  6190.         $em $this->getDoctrine()->getManager();
  6191.         $response HumanResource::twigDataForNocView($em$req$id);
  6192.         return $this->render(
  6193.             'ApplicationBundle:pages/human_resource/views:noc_view.html.twig',
  6194.             [
  6195.                 'page_title' => 'View NOC',
  6196.                 'approval_data' => $response['approval_data'],
  6197.                 'noc_application' => $response['noc_application'],
  6198.                 'resign_application' => $response['resign_application'],
  6199.                 'applicant' => $response['applicant'],
  6200.                 'document_log' => $response['document_log'],
  6201.                 'approval_status' => $response['approval_status'],
  6202.                 'created_by' => $response['created_by'],
  6203.                 'updated_at' => $response['updated_at'],
  6204.                 'auto_created' => 0,
  6205.             ]
  6206.         );
  6207.     }
  6208.     public function printNocApprovalAction(Request $req$id)
  6209.     {
  6210.         $em $this->getDoctrine()->getManager();
  6211.         $company_data Company::getCompanyData($em1);
  6212.         $Authorizations System::getSignatureListForDocumentPrint($emarray_flip(GeneralConstant::$Entity_list)['NocApproval'], $id);
  6213.         $response HumanResource::twigDataForNocView($em$req$id);
  6214.         return $this->render(
  6215.             'ApplicationBundle:pages/human_resource/print:noc_print.html.twig',
  6216.             [
  6217.                 'page_title' => 'Print NOC',
  6218.                 'noc_application' => $response['noc_application'],
  6219.                 'resign_application' => $response['resign_application'],
  6220.                 'applicant' => $response['applicant'],
  6221.                 'export' => 'pdf,print',
  6222.                 'company_name' => $company_data->getName(),
  6223.                 'company_data' => $company_data,
  6224.                 'company_address' => $company_data->getAddress(),
  6225.                 'company_image' => $company_data->getImage(),
  6226.                 'Authorizations' => $Authorizations,
  6227.                 'red' => 0
  6228.             ]
  6229.         );
  6230.     }
  6231.     public function createHolidayAction(Request $request$id)
  6232.     {
  6233.         $em $this->getDoctrine()->getManager();
  6234.         $companyId $this->getLoggedUserCompanyId($request);
  6235.         if ($request->isMethod('POST')) {
  6236.             $entity_id array_flip(GeneralConstant::$Entity_list)['HolidayCalendar']; //change
  6237.             $dochash $request->request->get('doc_hash'); //change
  6238.             $loginId $request->getSession()->get(UserConstants::USER_LOGIN_ID);
  6239.             $approveRole $request->request->get('approvalRole');
  6240.             $approveHash $request->request->get('approvalHash');
  6241.             if (!DocValidation::isInsertable(
  6242.                 $em,
  6243.                 $entity_id,
  6244.                 $dochash,
  6245.                 $loginId,
  6246.                 $approveRole,
  6247.                 $approveHash,
  6248.                 $id
  6249.             )
  6250.             ) {
  6251.                 $this->addFlash(
  6252.                     'error',
  6253.                     'Sorry Couldnot insert Data.'
  6254.                 );
  6255.             } else {
  6256.                 $funcname 'HolidayCalendar';
  6257.                 $doc_id $id;
  6258.                 DeleteDocument::$funcname($em$doc_id0);
  6259.                 if ($id != 0)
  6260.                     $HolidayCalender $em->getRepository(HolidayCalendar::class)->find($id);
  6261.                 else
  6262.                     $HolidayCalender = new HolidayCalendar;
  6263.                 $HolidayCalender->setDocumentHash($request->request->get('doc_hash'));
  6264.                 $HolidayCalender->setHoliDayTitle($request->request->get('holidayCalendarTitle'));
  6265.                 $HolidayCalender->setEmployeeIds(json_encode($request->request->get('employee')));
  6266.                 $HolidayCalender->setEmployeeTypeIds(json_encode($request->request->get('emp_status')));
  6267.                 $HolidayCalender->setDesignationIds(json_encode($request->request->get('desg', [])));
  6268.                 $HolidayCalender->setDepartmentIds(json_encode($request->request->get('dept', [])));
  6269.                 $HolidayCalender->setBranchIds(json_encode($request->request->get('branch', [])));
  6270.                 $HolidayCalender->setLevelSelectionStr($request->get('levelSelectionStr'''));
  6271.                 $HolidayCalender->setLevels(json_encode(HumanResource::getLevelsFromLevelSelectionStr($request->get('levelSelectionStr'''))));
  6272.                 $HolidayCalender->setCompanyId($companyId);
  6273.                 $HolidayCalender->setTypeHash('HD');
  6274.                 $HolidayCalender->setEditFlag(1); //editable usually
  6275.                 $HolidayCalender->setPrefixHash($request->request->get('prefix'));
  6276.                 $HolidayCalender->setAssocHash($request->request->get('assoc'));
  6277.                 $HolidayCalender->setNumberHash($request->request->get('number_hash'));
  6278.                 $HolidayCalender->setCreatedLoginId($request->getSession()->get(UserConstants::USER_LOGIN_ID));
  6279.                 $HolidayCalender->setApproved(GeneralConstant::APPROVAL_STATUS_PENDING);
  6280.                 $HolidayCalender->setAutocreated(0);
  6281. //
  6282. //        $arr = [
  6283. //            'date' =>$request->request->get('start_date'),
  6284. //            'title' => $request->request->get('title'),
  6285. //        ];
  6286. //
  6287. //        $HolidayCalender->setData(json_encode($arr));
  6288.                 $em->persist($HolidayCalender);
  6289.                 $em->flush();
  6290.                 $indHolidays = [];
  6291.                 if ($request->request->has('start_date'))
  6292.                     $indHolidays $request->request->get('start_date');
  6293.                 foreach ($indHolidays as $ind => $dateRangeStr) {
  6294.                     $currRow $request->request->get('row')[$ind];//string
  6295.                     $holidayTitle $request->request->get('title')[$ind];//string
  6296.                     $currStartDate $request->request->get('start_date')[$ind];//string
  6297.                     $currEndDate $request->request->get('end_date')[$ind];//string
  6298.                     $HolidayDate = new HolidayCalendarDates();
  6299.                     $HolidayDate->setHolidayCalendarId($HolidayCalender->getHolidayCalendarId());
  6300.                     $HolidayDate->setDateRange($currStartDate '-' $currEndDate);//string
  6301.                     $HolidayDate->setStartDate(new \DateTime($currStartDate));//date
  6302.                     $HolidayDate->setEndDate(new \DateTime($currEndDate ' 23:59:59'));//date
  6303.                     $HolidayDate->setHolidayTitle($holidayTitle);
  6304. //          $HolidayDate->setIsVariableEachYearFlag($request->request->get('is_variable_each_year',null));
  6305.                     $HolidayDate->setIsVariableEachYearFlag($request->request->get('is_variable_each_year_' $currRownull));
  6306.                     $HolidayDate->setAllDayFlag($request->request->get('all_day_flag_' $currRow1));
  6307.                     $em->persist($HolidayDate);
  6308.                     $em->flush();
  6309.                 }
  6310.                 $options = [];
  6311.                 $entity array_flip(GeneralConstant::$Entity_list)['HolidayCalendar'];
  6312.                 $loginId $request->getSession()->get(UserConstants::USER_LOGIN_ID);
  6313.                 $approveRole $request->request->get('approvalRole');
  6314.                 System::setApprovalInfo(
  6315.                     $em,
  6316.                     $options,
  6317.                     $entity,
  6318.                     $HolidayCalender->getHolidayCalendarId(),
  6319.                     $request->getSession()->get(UserConstants::USER_LOGIN_ID)
  6320.                 );
  6321.                 System::createEditSignatureHash(
  6322.                     $em,
  6323.                     $entity,
  6324.                     $HolidayCalender->getHolidayCalendarId(),
  6325.                     $loginId,
  6326.                     $approveRole,
  6327.                     $request->request->get('approvalHash')
  6328.                 );
  6329.                 $url $this->generateUrl(
  6330.                     'view_holiday_calendar'
  6331.                 );
  6332.                 return $this->redirect($url "/" $HolidayCalender->getHolidayCalendarId());
  6333.             }
  6334.         }
  6335.         $em $this->getDoctrine()->getManager();
  6336.         $branches $em->getRepository(Branch::class)->findAll();
  6337.         $employee $em->getRepository(Employee::class)->findAll();
  6338.         $departments $em->getRepository(SysDepartment::class)->findAll();
  6339.         $departmentPositions $em->getRepository(SysDepartmentPosition::class)->findAll();
  6340.         $EmploymentStatus HumanResourceConstant::$employeeType;
  6341.         $em $this->getDoctrine()->getManager();
  6342.         $extDocData = [];
  6343.         if ($id != 0)
  6344.             $extDocData $em->getRepository(HolidayCalendar::class)->find($id);
  6345.         return $this->render(
  6346.             'ApplicationBundle:pages/human_resource/input_forms:create_holiday.html.twig',
  6347.             [
  6348.                 'page_title' => 'Create Holiday',
  6349.                 'branches' => $branches,
  6350.                 'id' => $id,
  6351.                 'extDocData' => $extDocData,
  6352.                 'departments' => $departments,
  6353.                 'departmentPositions' => $departmentPositions,
  6354.                 'employeeStatus' => $EmploymentStatus,
  6355.                 'employeeIds' => $employee,
  6356.                 'holidayCalendarList' => $em->getRepository('ApplicationBundle:HolidayCalendar')
  6357.                     ->findBy(array())
  6358.             ]
  6359.         );
  6360.     }
  6361.     public function HolidayViewAction(Request $request$id)
  6362.     {
  6363.         $em $this->getDoctrine()->getManager();
  6364.         $HolidaysCalendar $em->getRepository(HolidayCalendar::class)->find($id);
  6365.         $holidayCalendarDetails $em->getRepository('ApplicationBundle:HolidayCalendarDates')
  6366.             ->findBy(array(
  6367.                 'holidayCalendarId' => $id
  6368.             ));
  6369.         $Approval_data System::checkIfApprovalExists(
  6370.             $em,
  6371.             array_flip(GeneralConstant::$Entity_list)['HolidayCalendar'],
  6372.             $id,
  6373.             $request->getSession()->get(UserConstants::USER_LOGIN_ID)
  6374.         );
  6375.         return $this->render('ApplicationBundle:pages/human_resource/views:holidays_view.html.twig', array(
  6376.             'page_title' => 'View Holiday',
  6377.             'holidays' => $HolidaysCalendar,
  6378.             'holidayCalendarDetails' => $holidayCalendarDetails,
  6379.             'approval_status' => $HolidaysCalendar->getApproved(),
  6380.             'approval_data' => $Approval_data,
  6381.             'auto_created' => $HolidaysCalendar->getAutocreated(),
  6382.             'document_log' => $HolidaysCalendar->getAutocreated() == System::getDocumentLog(
  6383.                 $this->getDoctrine()->getManager(),
  6384.                 array_flip(GeneralConstant::$Entity_list)['HolidayCalendar'],
  6385.                 $id,
  6386.                 $HolidaysCalendar->getCreatedLoginId(),
  6387.                 $HolidaysCalendar->getEditedLoginId()
  6388.             ) : []
  6389.         ));
  6390.     }
  6391.     public function GetHolidayDetailsAction(Request $request$id)
  6392.     {
  6393.         $em $this->getDoctrine()->getManager();
  6394.         $holidayCalendar $em->getRepository('ApplicationBundle:HolidayCalendar')
  6395.             ->findOneBy(array(
  6396.                 'holidayCalendarId' => $id
  6397.             ));
  6398.         $holidayCalendarDetails $em->getRepository('ApplicationBundle:HolidayCalendarDates')
  6399.             ->findBy(array(
  6400.                 'holidayCalendarId' => $id
  6401.             ));
  6402.         $holidayList = [];
  6403.         foreach ($holidayCalendarDetails as $det) {
  6404.             $dateDet = array(
  6405.                 'title' => $det->getHolidayTitle(),
  6406.                 'startDate' => $det->getStartDate()->format('Y-m-d'),
  6407.                 'endDate' => $det->getEndDate()->format('Y-m-d'),
  6408.             );
  6409.             $holidayList[] = $dateDet;
  6410.         }
  6411.         return new JsonResponse(
  6412.             array(
  6413.                 'success' => true,
  6414.                 'holidayList' => $holidayList
  6415.             )
  6416.         );
  6417.     }
  6418.     public function GetHolidayListByEmployeeIdAction(Request $request$id)
  6419.     {
  6420.         $em $this->getDoctrine()->getManager();
  6421.         $options = [];
  6422.         $options['employeeId'] = $id;
  6423.         HumanResource::getFilteredHolidaysSingle($em$options);
  6424.         $holidayCalendar $em->getRepository('ApplicationBundle:HolidayCalendar')
  6425.             ->findOneBy(array(
  6426.                 'holidayCalendarId' => $id
  6427.             ));
  6428.         $holidayCalendarDetails $em->getRepository('ApplicationBundle:HolidayCalendarDates')
  6429.             ->findBy(array(
  6430.                 'holidayCalendarId' => $id
  6431.             ));
  6432.         $holidayList = [];
  6433.         foreach ($holidayCalendarDetails as $det) {
  6434.             $dateDet = array(
  6435.                 'title' => $det->getHolidayTitle(),
  6436.                 'startDate' => $det->getStartDate()->format('Y-m-d'),
  6437.                 'endDate' => $det->getEndDate()->format('Y-m-d'),
  6438.             );
  6439.             $holidayList[] = $dateDet;
  6440.         }
  6441.         return new JsonResponse(
  6442.             array(
  6443.                 'success' => true,
  6444.                 'holidayList' => $holidayList
  6445.             )
  6446.         );
  6447.     }
  6448.     public function createQuestionAction(Request $request)
  6449.     {
  6450.         $em $this->getDoctrine()->getManager();
  6451.         $em_goc $this->getDoctrine()->getManager('company_group');
  6452.         $companyId $this->getLoggedUserCompanyId($request);
  6453.         if ($request->isMethod('POST')) {
  6454.             $loginId $request->getSession()->get(UserConstants::USER_LOGIN_ID);
  6455.             $question = new Questionnaire();
  6456.             $question->setQuestionTitle($request->request->get('questionTitle'''));
  6457.             $question->setQuestionText($request->request->get('questionText'''));
  6458.             $question->setIsForPlanningItem($request->request->has('forPlanningItem') ? 0);
  6459.             $question->setIsForInterview($request->request->has('forInterview') ? 0);
  6460.             $question->setIsForMock($request->request->has('forMock') ? 0);
  6461.             $question->setIsForTraining($request->request->has('forTraining') ? 0);
  6462.             $question->setTaggedSkillHashes($request->request->get('skillHash'));
  6463.             $question->setCorrectAnswers(json_encode($request->request->get('correctAns')));
  6464.             $question->setCompanyId($companyId);
  6465.             $optionData = [];
  6466.             foreach ($request->request->get('optionText') as $key => $val) {
  6467.                 $option = array(
  6468.                     'index' => $request->request->get('optionIndex')[$key],
  6469.                     'text' => $val,
  6470.                 );
  6471.                 $optionData[] = $option;
  6472.             }
  6473.             $question->setOptions(json_encode($optionData));
  6474.             $question->setQuestionValueWeight(1);
  6475.             $question->setQuestionText($request->request->get('questionText'));
  6476.             $question->setUniqueHash('_NONE_');
  6477.             $question->setType($request->request->get('type'0));
  6478.             //$skill->setEditFlag(1); //editable usually
  6479.             $question->setCreatedLoginId($request->getSession()->get(UserConstants::USER_LOGIN_ID));
  6480.             //$skill->setApproved(GeneralConstant::APPROVAL_STATUS_PENDING);
  6481.             //$skill->setAutocreated(0);
  6482.             $em->persist($question);
  6483.             $em->flush();
  6484.             $questionId $question->getQuestionId();
  6485.             $file_path_list = [];
  6486.             if ($questionId != 0)
  6487.                 if (!empty($request->files)) {
  6488.                     MiscActions::RemoveFilesForEntityDoc($em_goc'Question'$questionId);
  6489.                     $storePath 'uploads/Questionnaire/';
  6490.                     $path "";
  6491.                     $file_path "";
  6492.                     $session $request->getSession();
  6493. //                    MiscActions::RemoveExpiredFiles($em_goc);
  6494.                     foreach ($request->files as $uploadedFileGG) {
  6495.                         //            if($uploadedFile->getImage())
  6496.                         //                var_dump($uploadedFile->getFile());
  6497.                         //                var_dump($uploadedFile);
  6498.                         $tempD $uploadedFileGG;
  6499.                         if (!is_array($uploadedFileGG)) {
  6500.                             $uploadedFileGG = array();
  6501.                             $uploadedFileGG[] = $tempD;
  6502.                         }
  6503.                         foreach ($uploadedFileGG as $uploadedFile) {
  6504.                             if ($uploadedFile != null) {
  6505.                                 $extension $uploadedFile->guessExtension();
  6506.                                 $size $uploadedFile->getSize();
  6507.                                 $fileName 'QUES_' $questionId '_' . (md5(uniqid())) . '.' $uploadedFile->guessExtension();
  6508.                                 $path $fileName;
  6509.                                 $upl_dir $this->container->getParameter('kernel.root_dir') . '/../web/' $storePath;
  6510.                                 if (!file_exists($upl_dir)) {
  6511.                                     mkdir($upl_dir0777true);
  6512.                                 }
  6513.                                 if (file_exists($upl_dir '' $path)) {
  6514.                                     chmod($upl_dir '' $path0755);
  6515.                                     unlink($upl_dir '' $path);
  6516.                                 }
  6517.                                 $file $uploadedFile->move($upl_dir$path);
  6518.                                 $expireNever 1;
  6519.                                 $expireTs 0;
  6520.                                 $EntityFile = new EntityFile();
  6521.                                 $EntityFile->setPath($this->container->getParameter('kernel.root_dir') . '/../web/' $storePath $path);
  6522.                                 $EntityFile->setMarker('_GEN_');
  6523.                                 $EntityFile->setExtension($extension);
  6524.                                 $EntityFile->setExpireTs($expireTs);
  6525.                                 $EntityFile->setSize($size);
  6526.                                 $EntityFile->setRelativePath($storePath $path);
  6527.                                 $EntityFile->setEntityName('Questionnaire');
  6528.                                 $EntityFile->setEntityBundle('ApplicationBundle');
  6529.                                 $EntityFile->setEntityId($questionId);
  6530.                                 $EntityFile->setEntityIdField('questionId');
  6531.                                 $EntityFile->setModifyFieldSetter('setFiles');
  6532.                                 $EntityFile->setDocIdForApplicant(0);
  6533.                                 $EntityFile->setUserId($session->get(UserConstants::USER_ID0));
  6534.                                 $EntityFile->setAppId($session->get(UserConstants::USER_APP_ID0));
  6535.                                 $EntityFile->setEmployeeId($session->get(UserConstants::USER_EMPLOYEE_ID0));
  6536.                                 $EntityFile->setUserType($session->get(UserConstants::USER_TYPE0));
  6537.                                 $em_goc->persist($EntityFile);
  6538.                                 $em_goc->flush();
  6539.                                 $EntityFileId $EntityFile->getId();
  6540.                             }
  6541.                             if ($path != "")
  6542.                                 $file_path_list[] = ($storePath $path);
  6543.                         }
  6544.                     }
  6545.                     $g_path $this->container->getParameter('kernel.root_dir') . '/../web/' $storePath $path;
  6546.                     $question->setFiles(implode(','$file_path_list));
  6547.                     $em->flush();
  6548.                 }
  6549.             if ($request->request->has('returnJson') || $request->query->has('returnJson')) {
  6550.                 if ($question)
  6551.                     return new JsonResponse(
  6552.                         array(
  6553.                             'id' => $questionId,
  6554.                             'value' => $questionId,
  6555.                             'question_id' => $questionId,
  6556.                             'text' => $question->getQuestionText(),
  6557.                             'question_text' => $question->getQuestionText(),
  6558.                             'question_title' => $question->getQuestionTitle(),
  6559.                             'files' => explode(','$question->getFiles()),
  6560.                             'options' => json_decode($question->getFiles(), true),
  6561.                             'answer_text' => '',
  6562.                             'success' => true
  6563.                         )
  6564.                     );
  6565.                 else
  6566.                     return new JsonResponse(
  6567.                         array(
  6568.                             'success' => false
  6569.                         )
  6570.                     );
  6571.             }
  6572.         }
  6573.         $skillDetails $em->getRepository(Skill::class)->findAll();
  6574.         $skillListObj = [];
  6575.         $skillListArray = [];
  6576.         foreach ($skillDetails as $skillDetail) {
  6577.             $dt = array(
  6578.                 'id' => $skillDetail->getSkillId(),
  6579.                 'name' => $skillDetail->getName(),
  6580.                 'hash' => $skillDetail->getUniqueHash(),
  6581.             );
  6582.             $skillListArray[] = $dt;
  6583.         }
  6584.         return $this->render('ApplicationBundle:pages/human_resource/input_forms:createQuestion.html.twig', array(
  6585.             'page_title' => 'Create Question',
  6586.             'skiillDetails' => $skillDetails,
  6587.             'skillListArray' => $skillListArray,
  6588.         ));
  6589.     }
  6590.     public function createSkillAction(Request $request)
  6591.     {
  6592.         $em $this->getDoctrine()->getManager();
  6593.         $companyId $this->getLoggedUserCompanyId($request);
  6594.         if ($request->isMethod('POST')) {
  6595.             $loginId $request->getSession()->get(UserConstants::USER_LOGIN_ID);
  6596.             $skill = new Skill;
  6597.             $skill->setName($request->request->get('skillName'));
  6598.             $skill->setParentId($request->request->get('parentName'));
  6599.             $skill->setUniqueHash($request->request->get('uniqueHash'));
  6600.             $skill->setCompanyId($companyId);
  6601.             //$skill->setEditFlag(1); //editable usually
  6602.             $skill->setCreatedLoginId($request->getSession()->get(UserConstants::USER_LOGIN_ID));
  6603.             //$skill->setApproved(GeneralConstant::APPROVAL_STATUS_PENDING);
  6604.             //$skill->setAutocreated(0);
  6605.             $em->persist($skill);
  6606.             $em->flush();
  6607.         }
  6608.         $skillDetails $em->getRepository(Skill::class)->findAll();
  6609.         return $this->render('ApplicationBundle:pages/human_resource/input_forms:createSkill.html.twig', array(
  6610.             'page_title' => 'Create Skill',
  6611.             'skiillDetails' => $skillDetails,
  6612.         ));
  6613.     }
  6614.     public function createEducationQualificationAction(Request $request)
  6615.     {
  6616.         $em $this->getDoctrine()->getManager();
  6617.         $companyId $this->getLoggedUserCompanyId($request);
  6618.         if ($request->isMethod('POST')) {
  6619.             $loginId $request->getSession()->get(UserConstants::USER_LOGIN_ID);
  6620.             $new = new EducationQualification;
  6621.             $new->setName($request->request->get('educationName'));
  6622.             $new->setParentId($request->request->get('parentName'));
  6623.             $new->setUniqueHash($request->request->get('uniqueHash'));
  6624.             $new->setCompanyId($companyId);
  6625.             //$skill->setEditFlag(1); //editable usually
  6626.             $new->setCreatedLoginId($request->getSession()->get(UserConstants::USER_LOGIN_ID));
  6627.             //$skill->setApproved(GeneralConstant::APPROVAL_STATUS_PENDING);
  6628.             //$skill->setAutocreated(0);
  6629.             $em->persist($new);
  6630.             $em->flush();
  6631.         }
  6632.         $educationDetails $em->getRepository(EducationQualification::class)->findAll();
  6633.         return $this->render('ApplicationBundle:pages/human_resource/input_forms:create_education.html.twig', array(
  6634.             'page_title' => 'Create Education',
  6635.             'educationDetails' => $educationDetails,
  6636.         ));
  6637.     }
  6638.     public function createEvaluationCategoryAction(Request $request$id 0)
  6639.     {
  6640.         $em $this->getDoctrine()->getManager();
  6641.         $companyId $this->getLoggedUserCompanyId($request);
  6642.         if ($request->isMethod('POST')) {
  6643.             $loginId $request->getSession()->get(UserConstants::USER_LOGIN_ID);
  6644.             $new = new EvaluationCategory;
  6645.             $new->setName($request->request->get('name'));
  6646.             $new->setBranch($request->request->get('branch'));
  6647.             $new->setSelectionType($request->request->get('selection_type'));
  6648.             $new->setEmployeeIds($request->request->get('selected_employeeIds'));
  6649.             $new->setEmployeeTypeIds($request->request->get('employee_types'));
  6650.             $new->setDesignationIds($request->request->get('designation'));
  6651.             $new->setDesignationIds($request->request->get('designation'));
  6652.             $new->setmark($request->request->get('mark'));
  6653.             $new->setSkills(json_encode($request->request->get('skill')));
  6654.             $new->setLevelSelectionStr($request->request->get('levelSelectionStr'));
  6655.             $new->setCompanyId($companyId);
  6656.             $new->setCreatedLoginId($request->getSession()->get(UserConstants::USER_LOGIN_ID));
  6657.             $em->persist($new);
  6658.             $em->flush();
  6659.         }
  6660.         $skill $em->getRepository(Skill::class)->findAll();
  6661.         $employeeIds $em->getRepository(EmployeeDetails::class)->findAll();
  6662.         $employeeType HumanResourceConstant::$employeeType;
  6663.         $Designation $em->getRepository(SysDepartmentPosition::class)->findAll();
  6664.         $branch $em->getRepository(Branch::class)->findAll();
  6665.         $departments $em->getRepository(SysDepartment::class)->findAll();
  6666.         $department = [];
  6667.         foreach ($departments as $entry) {
  6668.             $department[$entry->getDepartmentId()] = array(
  6669.                 'id' => $entry->getDepartmentId(),
  6670.                 'name' => $entry->getDepartmentName(),
  6671.             );
  6672.             return $this->render('ApplicationBundle:pages/human_resource/input_forms:create_evaluation_category.html.twig', array(
  6673.                 'page_title' => 'Create Evaluation Category',
  6674.                 'employeeIds' => $employeeIds,
  6675.                 'employeeType' => $employeeType,
  6676.                 'Designation' => $Designation,
  6677.                 'branch' => $branch,
  6678.                 'department' => $department,
  6679.                 'skill' => $skill,
  6680.             ));
  6681.         }
  6682.     }
  6683.     public function createWorkplaceHarassmentAction(Request $request$id 0)
  6684.     {
  6685.         $em $this->getDoctrine()->getManager();
  6686.         $employeeIds $em->getRepository(EmployeeDetails::class)->findAll();
  6687.         //$employeeType = HumanResourceConstant::$employeeType;
  6688.         $Designation $em->getRepository(SysDepartmentPosition::class)->findAll();
  6689.         $branches $em->getRepository(Branch::class)->findAll();
  6690.         $departments $em->getRepository(SysDepartment::class)->findAll();
  6691.         $harassmentType HumanResourceConstant::$harrasmentType;
  6692.         $department = [];
  6693.         foreach ($departments as $entry) {
  6694.             $department[$entry->getDepartmentId()] = array(
  6695.                 'id' => $entry->getDepartmentId(),
  6696.                 'name' => $entry->getDepartmentName(),
  6697.             );
  6698.         }
  6699.         return $this->render('ApplicationBundle:pages/human_resource/input_forms:create_workplace_harrasment.html.twig', array(
  6700.             'page_title' => 'Create Workplace Harrasment',
  6701.             'employeeIds' => $employeeIds,
  6702.             'branches' => $branches,
  6703.             'harassmentType' => $harassmentType,
  6704.             'departments' => $department,
  6705.             'designationIds' => $Designation
  6706.         ));
  6707.     }
  6708.     public function ViewHarasssmentComplainAction()
  6709.     {
  6710.         return $this->render('ApplicationBundle:pages/human_resource/views:view_harassment_compalin.html.twig', array(
  6711.             'page_title' => 'View Harassment Complain',
  6712.         ));
  6713.     }
  6714.     public function createWorkplaceViolenceAction(Request $request$id 0)
  6715.     {
  6716.         $em $this->getDoctrine()->getManager();
  6717.         $employeeIds $em->getRepository(EmployeeDetails::class)->findAll();
  6718.         //$employeeType = HumanResourceConstant::$employeeType;
  6719.         $Designation $em->getRepository(SysDepartmentPosition::class)->findAll();
  6720.         $branches $em->getRepository(Branch::class)->findAll();
  6721.         $departments $em->getRepository(SysDepartment::class)->findAll();
  6722.         $harassmentType HumanResourceConstant::$harrasmentType;
  6723.         $department = [];
  6724.         foreach ($departments as $entry) {
  6725.             $department[$entry->getDepartmentId()] = array(
  6726.                 'id' => $entry->getDepartmentId(),
  6727.                 'name' => $entry->getDepartmentName(),
  6728.             );
  6729.         }
  6730.         return $this->render('ApplicationBundle:pages/human_resource/input_forms:register_workplace_complaint.html.twig', array(
  6731.             'page_title' => 'Register Complaint',
  6732.             'employeeIds' => $employeeIds,
  6733.             'branches' => $branches,
  6734.             'harassmentType' => $harassmentType,
  6735.             'departments' => $department,
  6736.             'designationIds' => $Designation
  6737.         ));
  6738.     }
  6739.     public function createBonusPolicyAction(Request $request$id 0)
  6740.     {
  6741.         $em $this->getDoctrine()->getManager();
  6742.         $companyId $this->getLoggedUserCompanyId($request);
  6743.         $extDocData = [];
  6744.         $extDetailsData = [];
  6745.         if ($request->isMethod('POST')) {
  6746.             //            Generic::debugMessage($_POST);
  6747.             $em $this->getDoctrine()->getManager();
  6748.             $entity_id array_flip(GeneralConstant::$Entity_list)['BonusPolicy']; //change
  6749.             $dochash $request->request->get('docHash'); //change
  6750.             $loginId $request->getSession()->get(UserConstants::USER_LOGIN_ID);
  6751.             $approveRole $request->request->get('approvalRole');
  6752.             $approveHash $request->request->get('approvalHash');
  6753.             if (!DocValidation::isInsertable(
  6754.                 $em,
  6755.                 $entity_id,
  6756.                 $dochash,
  6757.                 $loginId,
  6758.                 $approveRole,
  6759.                 $approveHash,
  6760.                 $id
  6761.             )
  6762.             ) {
  6763.                 $this->addFlash(
  6764.                     'error',
  6765.                     'Sorry Couldnot insert Data.'
  6766.                 );
  6767.             } else {
  6768.                 $funcname 'BonusPolicy';
  6769.                 DeleteDocument::$funcname($em$id0);
  6770.                 $loginId $request->getSession()->get(UserConstants::USER_LOGIN_ID);
  6771.                 $docId HumanResource::createBonusPolicy($em$request$companyId$loginId0);
  6772.                 //now add Approval info
  6773.                 $approveRole $request->request->get('approvalRole');
  6774.                 $options = array(
  6775.                     'notification_enabled' => $this->container->getParameter('notification_enabled'),
  6776.                     'notification_server' => $this->container->getParameter('notification_server'),
  6777.                     'appId' => $request->getSession()->get(UserConstants::USER_APP_ID),
  6778.                     'url' => $this->generateUrl(
  6779.                         GeneralConstant::$Entity_list_details[array_flip(GeneralConstant::$Entity_list)['BonusPolicy']]['entity_view_route_path_name']
  6780.                     )
  6781.                 );
  6782.                 System::setApprovalInfo(
  6783.                     $this->getDoctrine()->getManager(),
  6784.                     $options,
  6785.                     array_flip(GeneralConstant::$Entity_list)['BonusPolicy'],
  6786.                     $docId,
  6787.                     $request->getSession()->get(UserConstants::USER_LOGIN_ID)
  6788.                 );
  6789.                 System::createEditSignatureHash(
  6790.                     $this->getDoctrine()->getManager(),
  6791.                     array_flip(GeneralConstant::$Entity_list)['BonusPolicy'],
  6792.                     $docId,
  6793.                     $loginId,
  6794.                     $approveRole,
  6795.                     $request->request->get('approvalHash')
  6796.                 );
  6797.                 $doc_here $this->getDoctrine()
  6798.                     ->getRepository('ApplicationBundle:BonusPolicy')
  6799.                     ->findOneBy(
  6800.                         array(
  6801.                             'id' => $docId
  6802.                         )
  6803.                     );
  6804.                 //notify
  6805.                 $this->addFlash(
  6806.                     'success',
  6807.                     'Policy Successfully Updated.'
  6808.                 );
  6809.                 $url $this->generateUrl(
  6810.                     'view_bonus_policy'
  6811.                 );
  6812. //                System::AddNewNotification(
  6813. //                    $this->container->getParameter('notification_enabled'),
  6814. //                    $this->container->getParameter('notification_server'),
  6815. //                    $request->getSession()->get(UserConstants::USER_APP_ID),
  6816. //                    $request->getSession()->get(UserConstants::USER_COMPANY_ID),
  6817. //                    "Salary Segregation Policy : " . $doc_here->getDocumentHash() . " Has Been Created And is Under Processing",
  6818. //                    'pos',
  6819. //                    System::getPositionIdsByDepartment($em, GeneralConstant::HRM_DEPARTMENT),
  6820. //                    'success',
  6821. //                    //                    $url . "/" . $TransID,
  6822. //                    $url . "/" . $docId,
  6823. //                    "Journal"
  6824. //
  6825. //                );
  6826.                 return $this->redirect($url "/" $docId);
  6827.             }
  6828.         }
  6829.         //for edits
  6830.         if ($id == 0) {
  6831.         } else {
  6832.             $extDocData $em->getRepository('ApplicationBundle:BonusPolicy')->findOneBy(
  6833.                 array(
  6834.                     'id' => $id///material
  6835.                 )
  6836.             );
  6837.             //now if its not editable, redirect to view
  6838.             if ($extDocData) {
  6839.                 if ($extDocData->getEditFlag() != 1) {
  6840. //          $url = $this->generateUrl(
  6841. ////              'view_salary_segregation_policy'
  6842. //              'salary_segregation_policy'
  6843. //          );
  6844. //          return $this->redirect($url . "/" . $id);
  6845.                 } else {
  6846. //          $extVoucherDetailsData = Accounts::GetVoucherDataForEdit($em, $voucherId);
  6847. //          $extDetailsData = $em->getRepository('ApplicationBundle:SalarySegregationPolicy')->findOneBy(
  6848. //              array(
  6849. //                  'transactionId' => $id, ///material
  6850. //
  6851. //              )
  6852. //          );
  6853.                 }
  6854.             } else {
  6855.             }
  6856.         }
  6857.         $employeeIds $em->getRepository(EmployeeDetails::class)->findAll();
  6858.         $employeeType HumanResourceConstant::$employeeType;
  6859.         $Designation $em->getRepository(SysDepartmentPosition::class)->findAll();
  6860.         $branch $em->getRepository(Branch::class)->findAll();
  6861.         $departments $em->getRepository(SysDepartment::class)->findAll();
  6862.         $department = [];
  6863.         foreach ($departments as $entry) {
  6864.             $department[$entry->getDepartmentId()] = array(
  6865.                 'id' => $entry->getDepartmentId(),
  6866.                 'name' => $entry->getDepartmentName(),
  6867.             );
  6868.         }
  6869.         return $this->render('ApplicationBundle:pages/human_resource/input_forms:create_bonus_policy.html.twig', array(
  6870.             'page_title' => 'Create Bonus Policy',
  6871.             'employeeIds' => $employeeIds,
  6872.             'employeeType' => $employeeType,
  6873.             'Designation' => $Designation,
  6874.             'branch' => $branch,
  6875.             'department' => $department,
  6876.         ));
  6877.     }
  6878.     public function BonusPolicyListAction()
  6879.     {
  6880.         $em $this->getDoctrine()->getManager();
  6881.         $bonusPolicy $em->getRepository(BonusPolicy::class)->findAll();
  6882.         return $this->render('ApplicationBundle:pages/human_resource/list:bonus_policy_list.html.twig', array(
  6883.             'page_title' => 'Increment Policy List',
  6884.             'bonusPolicy' => $bonusPolicy
  6885.         ));
  6886.     }
  6887.     public function createIncrementPolicyAction(Request $request$id 0)
  6888.     {
  6889.         $em $this->getDoctrine()->getManager();
  6890.         $companyId $this->getLoggedUserCompanyId($request);
  6891.         $extDocData = [];
  6892.         $extDetailsData = [];
  6893.         if ($request->isMethod('POST')) {
  6894.             //            Generic::debugMessage($_POST);
  6895.             $em $this->getDoctrine()->getManager();
  6896.             $entity_id array_flip(GeneralConstant::$Entity_list)['IncrementPolicy']; //change
  6897.             $dochash $request->request->get('docHash'); //change
  6898.             $loginId $request->getSession()->get(UserConstants::USER_LOGIN_ID);
  6899.             $approveRole $request->request->get('approvalRole');
  6900.             $approveHash $request->request->get('approvalHash');
  6901.             if (!DocValidation::isInsertable(
  6902.                 $em,
  6903.                 $entity_id,
  6904.                 $dochash,
  6905.                 $loginId,
  6906.                 $approveRole,
  6907.                 $approveHash,
  6908.                 $id
  6909.             )
  6910.             ) {
  6911.                 $this->addFlash(
  6912.                     'error',
  6913.                     'Sorry Couldnot insert Data.'
  6914.                 );
  6915.             } else {
  6916.                 $funcname 'IncrementPolicy';
  6917.                 DeleteDocument::$funcname($em$id0);
  6918.                 $docId HumanResource::createIncrementPolicy($em$request$companyId0);
  6919.                 //now add Approval info
  6920.                 $loginId $request->getSession()->get(UserConstants::USER_LOGIN_ID);
  6921.                 $approveRole $request->request->get('approvalRole');
  6922.                 $options = array(
  6923.                     'notification_enabled' => $this->container->getParameter('notification_enabled'),
  6924.                     'notification_server' => $this->container->getParameter('notification_server'),
  6925.                     'appId' => $request->getSession()->get(UserConstants::USER_APP_ID),
  6926.                     'url' => $this->generateUrl(
  6927.                         GeneralConstant::$Entity_list_details[array_flip(GeneralConstant::$Entity_list)['IncrementPolicy']]
  6928.                         ['entity_view_route_path_name']
  6929.                     )
  6930.                 );
  6931.                 System::setApprovalInfo(
  6932.                     $this->getDoctrine()->getManager(),
  6933.                     $options,
  6934.                     array_flip(GeneralConstant::$Entity_list)['IncrementPolicy'],
  6935.                     $docId,
  6936.                     $request->getSession()->get(UserConstants::USER_LOGIN_ID),
  6937.                     3    //journal voucher
  6938.                 );
  6939.                 System::createEditSignatureHash(
  6940.                     $this->getDoctrine()->getManager(),
  6941.                     array_flip(GeneralConstant::$Entity_list)['IncrementPolicy'],
  6942.                     $docId,
  6943.                     $loginId,
  6944.                     $approveRole,
  6945.                     $request->request->get('approvalHash')
  6946.                 );
  6947.                 $doc_here $this->getDoctrine()
  6948.                     ->getRepository('ApplicationBundle:IncrementPolicy')
  6949.                     ->findOneBy(
  6950.                         array(
  6951.                             'id' => $docId
  6952.                         )
  6953.                     );
  6954.                 //notify
  6955.                 $this->addFlash(
  6956.                     'success',
  6957.                     'Policy Successfully Updated.'
  6958.                 );
  6959.                 $url $this->generateUrl(
  6960.                     'view_increment_policy'
  6961.                 );
  6962.                 return $this->redirect($url "/" $docId);
  6963.             }
  6964.         }
  6965.         //for edits
  6966.         if ($id == 0) {
  6967.         } else {
  6968.             $extDocData $em->getRepository('ApplicationBundle:IncrementPolicy')->findOneBy(
  6969.                 array(
  6970.                     'id' => $id///material
  6971.                 )
  6972.             );
  6973.             //now if its not editable, redirect to view
  6974.             if ($extDocData) {
  6975.                 if ($extDocData->getEditFlag() != 1) {
  6976. //          $url = $this->generateUrl(
  6977. ////              'view_salary_segregation_policy'
  6978. //              'salary_segregation_policy'
  6979. //          );
  6980. //          return $this->redirect($url . "/" . $id);
  6981.                 } else {
  6982. //          $extVoucherDetailsData = Accounts::GetVoucherDataForEdit($em, $voucherId);
  6983. //          $extDetailsData = $em->getRepository('ApplicationBundle:SalarySegregationPolicy')->findOneBy(
  6984. //              array(
  6985. //                  'transactionId' => $id, ///material
  6986. //
  6987. //              )
  6988. //          );
  6989.                 }
  6990.             } else {
  6991.             }
  6992.         }
  6993.         //$em = $this->getDoctrine()->getManager();
  6994.         $employeeIds $em->getRepository(EmployeeDetails::class)->findAll();
  6995.         $employeeType HumanResourceConstant::$employeeType;
  6996.         $Designation $em->getRepository(SysDepartmentPosition::class)->findAll();
  6997.         $branch $em->getRepository(Branch::class)->findAll();
  6998.         $departments $em->getRepository(SysDepartment::class)->findAll();
  6999.         $department = [];
  7000.         foreach ($departments as $entry) {
  7001.             $department[$entry->getDepartmentId()] = array(
  7002.                 'id' => $entry->getDepartmentId(),
  7003.                 'name' => $entry->getDepartmentName(),
  7004.             );
  7005.         }
  7006.         return $this->render('ApplicationBundle:pages/human_resource/input_forms:create_increment_policy.html.twig', array(
  7007.             'page_title' => 'Create Increment Policy',
  7008.             'employeeIds' => $employeeIds,
  7009.             'employeeType' => $employeeType,
  7010.             'Designation' => $Designation,
  7011.             'branch' => $branch,
  7012.             'department' => $department,
  7013.         ));
  7014.     }
  7015.     public function IncrementPolicyListAction()
  7016.     {
  7017.         $em $this->getDoctrine()->getManager();
  7018.         $incrementPolicy $em->getRepository(IncrementPolicy::class)->findAll();
  7019.         return $this->render('ApplicationBundle:pages/human_resource/list:increment_policy_list.html.twig', array(
  7020.             'page_title' => 'Increment Policy List',
  7021.             'incrementPolicy' => $incrementPolicy
  7022.         ));
  7023.     }
  7024.     public function ViewIncrementPolicyAction(Request $request$id)
  7025.     {
  7026.         $em $this->getDoctrine()->getManager();
  7027.         $incrementPolicy $em->getRepository(IncrementPolicy::class)->find($id);
  7028.         $Approval_data System::checkIfApprovalExists(
  7029.             $em,
  7030.             array_flip(GeneralConstant::$Entity_list)['IncrementPolicy'],
  7031.             $id,
  7032.             $request->getSession()->get(UserConstants::USER_LOGIN_ID)
  7033.         );
  7034.         return $this->render('ApplicationBundle:pages/human_resource/views:view_increment_policy.html.twig', array(
  7035.             'page_title' => 'Increment Policy List',
  7036.             'incrementPolicy' => $incrementPolicy,
  7037.             'approval_status' => $incrementPolicy->getApproved(),
  7038.             'approval_data' => $Approval_data,
  7039.             'auto_created' => $incrementPolicy->getAutocreated(),
  7040.             'id' => $id,
  7041.             'document_log' => $incrementPolicy->getAutocreated() == System::getDocumentLog(
  7042.                 $this->getDoctrine()->getManager(),
  7043.                 array_flip(GeneralConstant::$Entity_list)['FundRequisition'],
  7044.                 $id,
  7045.                 $incrementPolicy->getCreatedLoginId(),
  7046.                 $incrementPolicy->getEditedLoginId()
  7047.             ) : []
  7048.         ));
  7049.     }
  7050.     public function createConsultancyTopicAction(Request $request$id 0)
  7051.     {
  7052.         $em $this->getDoctrine()->getManager();
  7053.         $companyId $this->getLoggedUserCompanyId($request);
  7054.         if ($request->isMethod('POST')) {
  7055.             $loginId $request->getSession()->get(UserConstants::USER_LOGIN_ID);
  7056.             $new = new ConsultancyTopic();
  7057.             $new->setTopicName($request->request->get('topicName'));
  7058.             $new->setParentTopicName($request->request->get('parentTopicName'));
  7059.             $new->setUniqueHash($request->request->get('uniqueHash'));
  7060.             $new->setCompanyId($companyId);
  7061.             $new->setTopicSlug($request->request->get('topicSlug'));
  7062.             $new->setTitle($request->request->get('title'));
  7063.             $new->setSubTitle($request->request->get('subTitle'));
  7064.             $new->setSummary($request->request->get('content'));
  7065.             $new->setVideo($request->request->get('video'));
  7066.             $new->setAuthor($request->request->get('author'));
  7067.             $new->setAuthorSummary($request->request->get('authorSummary'));
  7068.             $new->setCreatedLoginId($request->getSession()->get(UserConstants::USER_LOGIN_ID));
  7069. //            $arr = [
  7070. //                'requirement' => $request->request->get('requirement'),
  7071. //
  7072. //            ];
  7073. //            $new->setRequirementData(json_encode($arr));
  7074.             $em->persist($new);
  7075.             $em->flush();
  7076.         }
  7077. //            $data = [];
  7078. //            $em = $this->getDoctrine()->getManager();
  7079. //            $companyId = $this->getLoggedUserCompanyId($request);
  7080. //            if ($request->isMethod('POST')) {
  7081. //                $em = $this->getDoctrine()->getManager();
  7082. //                $entity_id = array_flip(GeneralConstant::$Entity_list)['ConsultancyTopic'];
  7083. //                //$dochash = $request->request->get('docHash');//change
  7084. //                $approveRole = $request->request->get('approvalRole');
  7085. //                $approveHash = $request->request->get('approvalHash');
  7086. //                $loginId = $request->getSession()->get(UserConstants::USER_LOGIN_ID);
  7087. //                if (!DocValidation::isInsertable($em, $entity_id,
  7088. //                    $loginId, $approveRole, $approveHash, $id)
  7089. //                ) {
  7090. //                    $this->addFlash(
  7091. //                        'error',
  7092. //                        'Sorry Could not insert Data.'
  7093. //                    );
  7094. //                }  else {
  7095. //                    $data = $request->request;
  7096. //                    $docId = HumanResource::createConsultancyTopic($em, $loginId, $id, $data, $companyId);
  7097. ////                    now add Approval info
  7098. //
  7099. //                    $approveRole = $request->request->get('approvalRole');
  7100. //                    $options = array(
  7101. //                        'notification_enabled' => $this->container->getParameter('notification_enabled'),
  7102. //                        'notification_server' => $this->container->getParameter('notification_server'),
  7103. //                        'appId' => $request->getSession()->get(UserConstants::USER_APP_ID),
  7104. ////                        'url' => $this->generateUrl(
  7105. ////                            GeneralConstant::$Entity_list_details[array_flip(GeneralConstant::$Entity_list)['EmployeePerformanceEvolution']]
  7106. ////                            ['entity_view_route_path_name']
  7107. ////                        )
  7108. //                    );
  7109. //                    System::setApprovalInfo($this->getDoctrine()->getManager(), $options,
  7110. //                        array_flip(GeneralConstant::$Entity_list)['ConsultancyTopic'],
  7111. //                        $docId,
  7112. //                        $request->getSession()->get(UserConstants::USER_LOGIN_ID)    //journal voucher
  7113. //                    );
  7114. //                    System::createEditSignatureHash($this->getDoctrine()->getManager(), array_flip(GeneralConstant::$Entity_list)['ConsultancyTopic'],
  7115. //                        $docId,
  7116. //                        $loginId,
  7117. //                        $request->request->get('approvalHash'));
  7118. //                    $this->addFlash(
  7119. //                        'success',
  7120. //                        'New Consultancy Topic Added.'
  7121. //                    );
  7122. ////                    $url = $this->generateUrl(
  7123. ////                        'create_consultancy_topic'
  7124. ////                    );
  7125. //                    //return $this->redirect($url);
  7126. //
  7127. //                }
  7128. //            }
  7129.         $consultancyDetails $em->getRepository('ApplicationBundle:ConsultancyTopic')->findAll();
  7130.         return $this->render('ApplicationBundle:pages/human_resource/input_forms:create_consultancy.html.twig', array(
  7131.             'page_title' => 'Consultancy Topic',
  7132.             'consultancyDetails' => $consultancyDetails,
  7133. //                'requirement' => json_decode($consultancyDetails->getRequirementData())
  7134.         ));
  7135.     }
  7136.     public function createTopicAction(Request $request$id 0)
  7137.     {
  7138.         $em $this->getDoctrine()->getManager('company_group');
  7139.         $companyId $this->getLoggedUserCompanyId($request);
  7140.         $documentQRY $em->getRepository('CompanyGroupBundle:EntityCreateDocument')->findAll();
  7141.         $topicList $em->getRepository('CompanyGroupBundle:EntityCreateTopic')->findAll();
  7142.         $topic = [];
  7143.         $sessionName BuddybeeConstant::$sessionName;
  7144.         $document = [];
  7145.         foreach ($documentQRY as $d) {
  7146.             $document[$d->getId()] = array(
  7147.                 'id' => $d->getId(),
  7148.                 'documentName' => $d->getDocumentName(),
  7149.                 'text' => $d->getDocumentName(),
  7150.             );
  7151.         }
  7152.         $topicId $id;
  7153.         if ($topicId != 0)
  7154.             $topic $em->getRepository('CompanyGroupBundle:EntityCreateTopic')->findOneBy(
  7155.                 array(
  7156.                     'id' => $topicId
  7157.                 )
  7158.             );
  7159.         if ($request->isMethod('POST')) {
  7160.             if ($request->request->has('topicId'))
  7161.                 $topicId $request->request->get('topicId');
  7162. //            $loginId = $request->getSession()->get(UserConstants::USER_LOGIN_ID);
  7163.             if ($topicId != 0)
  7164.                 $new $em->getRepository('CompanyGroupBundle:EntityCreateTopic')->findOneBy(
  7165.                     array(
  7166.                         'id' => $topicId
  7167.                     )
  7168.                 );
  7169.             else
  7170.                 $new = new EntityCreateTopic();
  7171.             $new->setTopicName($request->request->get('topicName'));
  7172.             $new->setParentTopicId($request->request->get('parentTopic'));
  7173.             if ($request->request->get('countryId') != '')
  7174.                 $new->setCountryId($request->request->get('countryId'));
  7175.             else if ($request->request->get('parentTopic') != '') {
  7176.                 $parentTopic $em->getRepository('CompanyGroupBundle:EntityCreateTopic')->findOneBy(
  7177.                     array(
  7178.                         'id' => $request->request->get('parentTopic')
  7179.                     )
  7180.                 );
  7181.                 if ($parentTopic)
  7182.                     $new->setCountryId($parentTopic->getCountryId());
  7183.             }
  7184.             $new->setTimeSlotMultipliers($request->request->get('timeSlotMultipliers'));
  7185.             $new->setOnlyBookableByAdmin($request->request->get('onlyBookableByAdmin'0));
  7186.             $new->setMeetingType($request->request->get('meetingType'0));
  7187.             $new->setConsultantCanUpload($request->request->get('consultantCanUpload'0));
  7188.             $new->setTopicMarker($request->request->get('topicMarker'));
  7189.             $new->setCoinMultiplierValue($request->request->get('coinMultiplierValue'1));
  7190.             $new->setMinLifetimeCoinsBalance($request->request->get('minLifetimeCoinsBalance'0));
  7191.             $new->setMapEmbedIframe($request->request->get('mapEmbedIframe'''));
  7192.             $new->setTopicSummary($request->request->get('topicSummary'));
  7193.             $new->setAddress($request->request->get('address'));
  7194.             $new->setLocationString($request->request->get('locationString'));
  7195.             $new->setLocationLat($request->request->get('locationLat'));
  7196.             $new->setLocationLong($request->request->get('locationLong'));
  7197.             $new->setUniversityRanking($request->request->get('universityRanking'));
  7198.             $new->setIsParent($request->request->get('isParent'));
  7199.             $new->setIsEvent($request->request->get('isEvent'));
  7200.             $new->setConsultancyEnabled($request->request->get('consultancyEnabled'0));
  7201.             $new->setEventExpired($request->request->get('eventExpired'0));
  7202.             $new->setEventDesc($request->request->get('eventDesc'0));
  7203.             $eventStartDate = new \DateTime($request->request->get('eventStartDate'));
  7204.             $eventEndDate = new \DateTime($request->request->get('eventStartDate'));
  7205.             $new->setEventStartDate($eventStartDate);
  7206.             $new->setEventStartDateTs($eventStartDate->format('U'));
  7207.             $new->setEventEndDate($eventEndDate);
  7208.             $new->setEventStartDateTs($eventEndDate->format('U'));
  7209.             $new->setCreatedLoginId($request->getSession()->get(UserConstants::USER_LOGIN_ID));
  7210.             $checkListStringArray = [];
  7211.             if ($request->request->has('checkList'))
  7212.                 foreach ($request->request->get('checkList') as $value) {
  7213.                     $checkListStringArray [] = explode(","$value);
  7214.                 }
  7215.             $docData = [];
  7216.             foreach ($request->request->get('document', []) as $key => $value)
  7217.                 $docData[] = [
  7218.                     'document' => $request->request->get('document')[$key],
  7219.                     'expDays' => $request->request->get('expDays')[$key],
  7220.                     'stage' => $request->request->get('stage')[$key],
  7221.                     'generalProcessingDays' => $request->request->get('generalProcessingDays')[$key],
  7222.                     'emergencyProcessingDays' => $request->request->get('emergencyProcessingDays')[$key],
  7223.                     'thresholdDaysOffset' => $request->request->get('thresholdDaysOffset')[$key],
  7224.                     'checklist' => explode(","$request->request->get('checkList')[$key])
  7225.                 ];
  7226.             $coursePlanData = [];
  7227.             foreach ($request->request->get('coursePlanSessionNo', []) as $key => $value)
  7228.                 if ($request->request->get('coursePlanSessionNo')[$key] != '' and $request->request->get('coursePlanSessionNo')[$key] != null) {
  7229.                     if (!isset($coursePlanData[$request->request->get('coursePlanSessionNo')[$key]]))
  7230.                         $coursePlanData[$request->request->get('coursePlanSessionNo')[$key]] = [];
  7231.                     $coursePlanData[$request->request->get('coursePlanSessionNo')[$key]][] = [
  7232.                         'sessionNo' => $request->request->get('coursePlanSessionNo')[$key],
  7233.                         'subject' => $request->request->get('coursePlanSubject')[$key],
  7234.                         'details' => $request->request->get('coursePlanDetails')[$key],
  7235.                         'optimumMin' => $request->request->get('coursePlanOptimumMin')[$key],
  7236.                     ];
  7237.                 }
  7238.             $routineData = [];
  7239.             foreach ($request->request->get('routine_sequence', []) as $key => $value) {
  7240.                 $routineData[] = [
  7241.                     'sequence' => $request->request->get('routine_sequence')[$key],
  7242.                     'topicId' => $request->request->get('routine_topic_id')[$key],
  7243.                     'topicName' => $request->request->get('routine_topic_name')[$key],
  7244.                     'meetingType' => $request->request->get('routine_topic_meeting_type')[$key],
  7245.                     'duration' => $request->request->get('routine_duration')[$key],
  7246.                     'offset' => $request->request->get('routine_offset')[$key],
  7247.                     'coins' => $request->request->get('routine_coins')[$key],
  7248.                     'nextSequenceStart' => $request->request->has('routine_next_sequence_start_' $value) ? 0,
  7249.                     'modifiable' => $request->request->has('routine_modifiable_' $value) ? 0,
  7250.                 ];
  7251.             }
  7252.             $sessionData = [];
  7253.             foreach ($request->request->get('sessionId', []) as $key => $value)
  7254.                 $sessionData[] = [
  7255.                     'sessionId' => $request->request->get('sessionId')[$key],
  7256.                     'sessionYear' => $request->request->get('year')[$key],
  7257.                     'threshold' => $request->request->get('threshold')[$key],
  7258.                     'sessionStart' => $request->request->get('sessionStart')[$key],
  7259.                     'applicationStartDate' => $request->request->get('applicationStartDate')[$key],
  7260.                 ];
  7261.             $coursesData = [];
  7262.             foreach ($request->request->get('courseName', []) as $key => $value)
  7263.                 $coursesData[] = [
  7264.                     'courseName' => $request->request->get('courseName')[$key],
  7265.                 ];
  7266.             $departmentData = [];
  7267.             foreach ($request->request->get('departmentName', []) as $key => $value)
  7268.                 $departmentData[] = [
  7269.                     'departmentName' => $request->request->get('departmentName')[$key],
  7270.                 ];
  7271.             $benefitsData = [];
  7272.             foreach ($request->request->get('benefit', []) as $key => $value)
  7273.                 $benefitsData[] = [
  7274.                     'benefit' => $request->request->get('benefit')[$key],
  7275.                 ];
  7276.             $new->setRoutineData(json_encode($routineData));
  7277.             $new->setDocumentData(json_encode($docData));
  7278.             $new->setCoursePlanData(json_encode($coursePlanData));
  7279.             $new->setSessionData(json_encode($sessionData));
  7280.             $new->setCourses(json_encode($coursesData));
  7281.             $new->setDepartments(json_encode($departmentData));
  7282.             $new->setBenefits(json_encode($benefitsData));
  7283.             $otherDataObj = [];
  7284.             foreach (BuddybeeConstant::$otherDataByHash as $ohash => $otherDataGroup)
  7285.                 foreach ($otherDataGroup as $otherData) {
  7286.                     $fieldExists $request->request->has($ohash '_' $otherData['field']);
  7287.                     if ($fieldExists) {
  7288.                         $fieldValue $request->request->get($ohash '_' $otherData['field'], '');
  7289.                         $otherDataObj[$ohash '_' $otherData['field']] = $fieldValue;
  7290.                     }
  7291.                 }
  7292.             $new->setOtherData(json_encode($otherDataObj));
  7293.             $new->setBenefits(json_encode($benefitsData));
  7294.             $em->persist($new);
  7295.             $em->flush();
  7296.             $path "";
  7297.             $defaultProductImage '';
  7298.             $uploadedFile null;
  7299.             $upl_dir $this->container->getParameter('kernel.root_dir') . '/../web/uploads/topicImage/';
  7300.             $uploadedFile $request->files->get('topicSummaryImage');
  7301.             if ($uploadedFile != null) {
  7302.                 $fileName 'TSI' $new->getId() . '.' $uploadedFile->guessExtension();
  7303.                 $path $fileName;
  7304. //            $upl_dir = $this->container->getParameter('kernel.root_dir') . '/../web/uploads/Products/';
  7305.                 if (!file_exists($upl_dir)) {
  7306.                     mkdir($upl_dir0777true);
  7307.                 }
  7308.                 $uploadedFile->move($upl_dir$path);
  7309.                 $defaultProductImage 'uploads/topicImage/' $path;
  7310.                 $new->setTopicSummaryImage($defaultProductImage);
  7311.                 $em->flush();
  7312.             }
  7313.             $path "";
  7314.             $defaultProductImage '';
  7315.             $uploadedFile null;
  7316.             $upl_dir $this->container->getParameter('kernel.root_dir') . '/../web/uploads/topicImage/';
  7317.             $uploadedFile $request->files->get('topicImage');
  7318.             if ($uploadedFile != null) {
  7319.                 $fileName 'TI' $new->getId() . '.' $uploadedFile->guessExtension();
  7320.                 $path $fileName;
  7321. //            $upl_dir = $this->container->getParameter('kernel.root_dir') . '/../web/uploads/Products/';
  7322.                 if (!file_exists($upl_dir)) {
  7323.                     mkdir($upl_dir0777true);
  7324.                 }
  7325.                 $uploadedFile->move($upl_dir$path);
  7326.                 $defaultProductImage 'uploads/topicImage/' $path;
  7327.                 $new->setTopicImage($defaultProductImage);
  7328.                 $em->flush();
  7329.             }
  7330.             $this->addFlash(
  7331.                 'success',
  7332.                 'Topic Added.'
  7333.             );
  7334.         }
  7335.         return $this->render('ApplicationBundle:pages/human_resource/input_forms:create_topic.html.twig', array(
  7336.             'page_title' => 'Create Topic',
  7337.             'defaultCoursePlan' => BuddybeeConstant::$defaultCoursePlan,
  7338.             'coursePlanSessionTitle' => BuddybeeConstant::$coursePlanSessionTitle,
  7339.             'coursePlanSessionTitleShort' => BuddybeeConstant::$coursePlanSessionTitleShort,
  7340.             'document' => $document,
  7341.             'topic' => $topic,
  7342.             'otherDataByHash' => BuddybeeConstant::$otherDataByHash,
  7343.             'topicId' => $topicId,
  7344.             'topicList' => $topicList,
  7345.             'topicMarker' => BuddybeeConstant::$topicMarkup,
  7346.             'sessionName' => $sessionName,
  7347.         ));
  7348.     }
  7349.     public function ConsultancyRequirementSettingsAction(Request $request$id 0)
  7350.     {
  7351.         $em $this->getDoctrine()->getManager('company_group');
  7352.         $entityList $em->getRepository('CompanyGroupBundle:EntityCountryConsultantRequirements')->findAll();
  7353.         $documentQRY $em->getRepository('CompanyGroupBundle:EntityCreateDocument')->findAll();
  7354.         $entity = [];
  7355.         $sessionName BuddybeeConstant::$sessionName;
  7356.         $document = [];
  7357.         foreach ($documentQRY as $d) {
  7358.             $document[$d->getId()] = array(
  7359.                 'id' => $d->getId(),
  7360.                 'documentName' => $d->getDocumentName(),
  7361.                 'text' => $d->getDocumentName(),
  7362.             );
  7363.         }
  7364.         $countryId $id;
  7365.         if ($countryId != 0)
  7366.             $entity $em->getRepository('CompanyGroupBundle:EntityCountryConsultantRequirements')->findOneBy(
  7367.                 array(
  7368.                     'countryId' => $countryId
  7369.                 )
  7370.             );
  7371.         if ($request->isMethod('POST')) {
  7372.             if ($request->request->has('countryId'))
  7373.                 $countryId $request->request->get('countryId');
  7374. //            $loginId = $request->getSession()->get(UserConstants::USER_LOGIN_ID);
  7375.             if ($countryId != 0) {
  7376.                 $new $em->getRepository('CompanyGroupBundle:EntityCountryConsultantRequirements')->findOneBy(
  7377.                     array(
  7378.                         'countryId' => $countryId
  7379.                     )
  7380.                 );
  7381.                 if (!$new)
  7382.                     $new = new EntityCountryConsultantRequirements();
  7383.             } else
  7384.                 $new = new EntityCountryConsultantRequirements();
  7385.             $new->setCountryId($request->request->get('countryId'));
  7386.             $new->setContractLetterHtml($request->request->get('contractLetterHtml'));
  7387.             $new->setRequiredFields($request->request->get('requiredFields'));
  7388.             $new->setAllowedWorkingHoursPerDay($request->request->get('allowedWorkingHoursPerDay'));
  7389.             $new->setAllowedWorkingHoursPerMonth($request->request->get('allowedWorkingHoursPerMonth'));
  7390.             $new->setAllowedWorkingHoursPerWeek($request->request->get('allowedWorkingHoursPerWeek'));
  7391.             $new->setAllowedWorkingHoursPerYear($request->request->get('allowedWorkingHoursPerYear'));
  7392.             $new->setAllowedEarningPerDay($request->request->get('allowedEarningPerDay'));
  7393.             $new->setAllowedEarningPerMonth($request->request->get('allowedEarningPerMonth'));
  7394.             $new->setAllowedEarningPerWeek($request->request->get('allowedEarningPerWeek'));
  7395.             $new->setAllowedEarningPerYear($request->request->get('allowedEarningPerYear'));
  7396.             $new->setRevenuePercentagePerSession($request->request->get('revenuePercentagePerSession'));
  7397.             $docData = [];
  7398.             foreach ($request->request->get('document', []) as $key => $value)
  7399.                 $docData[] = [
  7400.                     'document' => $request->request->get('document')[$key],
  7401.                     'expDays' => $request->request->get('expDays')[$key],
  7402.                     'stage' => $request->request->get('stage')[$key],
  7403.                     'generalProcessingDays' => $request->request->get('generalProcessingDays')[$key],
  7404.                     'emergencyProcessingDays' => $request->request->get('emergencyProcessingDays')[$key],
  7405.                     'thresholdDaysOffset' => $request->request->get('thresholdDaysOffset')[$key],
  7406.                     'checklist' => explode(","$request->request->get('checkList')[$key])
  7407.                 ];
  7408.             $new->setDocumentList(json_encode($docData));
  7409.             $em->persist($new);
  7410.             $em->flush();
  7411.             $this->addFlash(
  7412.                 'success',
  7413.                 'Restriction Updated.'
  7414.             );
  7415.         }
  7416.         return $this->render('@Buddybee/pages/create_consultancy_requirements.html.twig', array(
  7417.             'page_title' => 'Create Requirements',
  7418.             'defaultCoursePlan' => BuddybeeConstant::$defaultCoursePlan,
  7419.             'coursePlanSessionTitle' => BuddybeeConstant::$coursePlanSessionTitle,
  7420.             'coursePlanSessionTitleShort' => BuddybeeConstant::$coursePlanSessionTitleShort,
  7421.             'document' => $document,
  7422.             'entity' => $entity,
  7423.             'otherDataByHash' => BuddybeeConstant::$otherDataByHash,
  7424.             'countryId' => $countryId,
  7425.             'entityList' => $entityList,
  7426.             'topicMarker' => BuddybeeConstant::$topicMarkup,
  7427.             'sessionName' => $sessionName,
  7428.         ));
  7429.     }
  7430.     public function PromoCodeSettingsAction(Request $request$id 0)
  7431.     {
  7432.         $em $this->getDoctrine()->getManager('company_group');
  7433.         $entityList $em->getRepository('CompanyGroupBundle:PromoCode')->findAll();
  7434.         $applicantList $em->getRepository('CompanyGroupBundle:EntityApplicantDetails')->findAll();
  7435.         $promoCodeId $id;
  7436.         $entity = [];
  7437.         if ($promoCodeId != 0)
  7438.             $entity $em->getRepository('CompanyGroupBundle:PromoCode')->findOneBy(
  7439.                 array(
  7440.                     'id' => $promoCodeId
  7441.                 )
  7442.             );
  7443.         if ($request->isMethod('POST')) {
  7444.             if ($request->request->has('promoCodeId'))
  7445.                 $promoCodeId $request->request->get('promoCodeId');
  7446. //            $loginId = $request->getSession()->get(UserConstants::USER_LOGIN_ID);
  7447.             if ($promoCodeId != 0) {
  7448.                 $new $em->getRepository('CompanyGroupBundle:PromoCode')->findOneBy(
  7449.                     array(
  7450.                         'id' => $promoCodeId
  7451.                     )
  7452.                 );
  7453.                 if (!$new)
  7454.                     $new = new PromoCode();
  7455.             } else
  7456.                 $new = new PromoCode();
  7457. //            $new->setCountryId($request->request->get('countryId'));
  7458.             $new->setCode($request->request->get('code'''));
  7459.             $new->setPromoType($request->request->get('promoType'1));
  7460.             $new->setPromoCodeType($request->request->get('promoCodeType'1));
  7461.             $new->setPromoValue($request->request->get('promoValue'0));
  7462.             $new->setPerpetual($request->request->get('perpetual'0));
  7463.             $new->setMaxDiscountAmount($request->request->get('maxDiscountAmount', -1));
  7464.             $new->setMaxCoinAddition($request->request->get('maxCoinAddition', -1));
  7465.             $new->setMinAmountForApplication($request->request->get('minAmountForApplication'0));
  7466.             $new->setMinCoinForApplication($request->request->get('minCoinForApplication'0));
  7467.             $new->setNextApplicationEachCoinCount($request->request->get('nextApplicationEachCoinCount', -1));
  7468.             $new->setMaxUseCount($request->request->get('maxUseCount', -1));
  7469.             $new->setMaxUseCountPerUser($request->request->get('maxUseCountPerUser', -1));
  7470.             $new->setUseCountBalance($request->request->get('useCountBalance', -1));
  7471.             $new->setReferralApplicantId($request->request->get('referralApplicantId'0));
  7472.             $new->setMaxReferralCommissionCount($request->request->get('maxReferralCommissionCount'0));
  7473.             $new->setReferralCommissionCountBalance($request->request->get('referralCommissionCountBalance'0));
  7474.             $new->setReferralCommissionType($request->request->get('referralCommissionType'1));
  7475.             $new->setReferralAmount($request->request->get('referralAmount'0));
  7476.             $startsAt = new \DateTime($request->request->get('startsAt'''));
  7477.             $expiresAt = new \DateTime($request->request->get('expiresAt'''));
  7478.             $new->setStartsAtTs($startsAt->format('U'));
  7479.             $new->setExpiresAtTs($expiresAt->format('U'));
  7480. //
  7481. //        startsAtTs:
  7482. //            type: integer
  7483. //            nullable: true
  7484. //        expiresAtTs:
  7485. //            type: integer
  7486. //            nullable: true
  7487.             $em->persist($new);
  7488.             $em->flush();
  7489.             $this->addFlash(
  7490.                 'success',
  7491.                 'Promo Code Updated.'
  7492.             );
  7493.         }
  7494.         return $this->render('@Buddybee/pages/buddybee_promo_code_settings.html.twig', array(
  7495.             'page_title' => 'Promo Codes',
  7496.             'entity' => $entity,
  7497.             'promoCodeId' => $promoCodeId,
  7498.             'entityList' => $entityList,
  7499.             'applicantList' => $applicantList,
  7500.         ));
  7501.     }
  7502.     public function createDocumentAction(Request $request$id 0)
  7503.     {
  7504.         $em $this->getDoctrine()->getManager('company_group');
  7505.         $companyId $this->getLoggedUserCompanyId($request);
  7506.         $document $em->getRepository('CompanyGroupBundle:EntityCreateDocument')->findAll();
  7507.         $thisDoc = [];
  7508.         if ($id != 0)
  7509.             $thisDoc $em->getRepository('CompanyGroupBundle:EntityCreateDocument')->findOneBy(
  7510.                 array(
  7511.                     'Id' => $id
  7512.                 )
  7513.             );
  7514.         if ($request->isMethod('POST')) {
  7515.             if ($id != 0)
  7516.                 $new $thisDoc;
  7517.             else
  7518.                 $new = new EntityCreateDocument();
  7519.             $new->setDocumentName($request->request->get('docName'));
  7520.             $new->setExpiryDays($request->request->get('expDays'));
  7521.             $new->setProcessingDays($request->request->get('processingDays'));
  7522.             $new->setEmergencyProcessingDays($request->request->get('emergencyProcessingDays'));
  7523.             $new->setDocVideo($request->request->get('docVideoLink'));
  7524.             $new->setRequiredDocument(json_encode($request->request->get('requiredDoc')));
  7525.             $new->setCreatedLoginId($request->getSession()->get(UserConstants::USER_LOGIN_ID));
  7526.             $arr = [
  7527.                 'checkListName' => $request->request->get('checkListName'),
  7528.             ];
  7529.             $new->setCheckList(json_encode($arr));
  7530.             $em->persist($new);
  7531.             $em->flush();
  7532.         }
  7533.         $this->addFlash(
  7534.             'Document Added',
  7535.             'Topic Added.'
  7536.         );
  7537.         return $this->render('ApplicationBundle:pages/human_resource/input_forms:create_document.html.twig', array(
  7538.             'page_title' => 'Create Document',
  7539.             'document' => $document,
  7540.             'thisDoc' => $thisDoc
  7541.         ));
  7542.     }
  7543.     public function getIndividualDocumentAction(Request $request$id)
  7544.     {
  7545.         $em $this->getDoctrine()->getManager('company_group');
  7546.         if ($id == 0) {
  7547.             if ($request->request->has('documentId'))
  7548.                 $id $request->request->get('documentId');
  7549.         }
  7550.         $document $em->getRepository('CompanyGroupBundle:EntityCreateDocument')->find($id);
  7551.         return new JsonResponse(
  7552.             array(
  7553.                 'success' => true,
  7554.                 'rowId' => $request->request->get('rowId'),
  7555.                 'expiryDays' => $document->getExpiryDays(),
  7556.                 'processingDays' => $document->getProcessingDays(),
  7557.                 'emergencyProcessing' => $document->getEmergencyProcessingDays(),
  7558.                 'checklist' => json_decode($document->getCheckList()),
  7559.             )
  7560.         );
  7561.     }
  7562.     public function createBlogAction(Request $request$id)
  7563.     {
  7564.         if (!$id) {
  7565.             if ($request->isMethod('POST')) {
  7566.                 $em $this->getDoctrine()->getManager('company_group');
  7567.                 $loginId $request->getSession()->get(UserConstants::USER_LOGIN_ID);
  7568.                 $new = new EntityCreateBlog();
  7569.                 $new->setTopicId($request->request->get('topicId'));
  7570.                 $new->setTitle($request->request->get('title'));
  7571.                 $new->setSubtitle($request->request->get('subTitle'));
  7572.                 $new->setContent($request->request->get('content'));
  7573.                 $new->setVideoLink($request->request->get('videoLink'));
  7574.                 $new->setAuthorName($request->request->get('authorName'));
  7575.                 $new->setAuthorSummary($request->request->get('authorSummary'));
  7576.                 $new->setIsPrimaryBlog($request->request->get('checkPrimaryBlog'));
  7577.                 $em->persist($new);
  7578.                 $em->flush();
  7579.                 //$fileName = 'cv' . $consultantDetails->getApplicantId() . '.' . $uploadedFile->guessExtension();
  7580.                 $path "";
  7581.                 $defaultProductImage '';
  7582.                 $uploadedFile null;
  7583.                 $upl_dir $this->container->getParameter('kernel.root_dir') . '/../web/uploads/authorImage/';
  7584.                 $uploadedFile $request->files->get('authorImage');
  7585.                 if ($uploadedFile != null) {
  7586.                     $fileName 'authorImage' $new->getId() . '.' $uploadedFile->guessExtension();
  7587.                     $path $fileName;
  7588. //            $upl_dir = $this->container->getParameter('kernel.root_dir') . '/../web/uploads/Products/';
  7589.                     if (!file_exists($upl_dir)) {
  7590.                         mkdir($upl_dir0777true);
  7591.                     }
  7592.                     $uploadedFile->move($upl_dir$path);
  7593.                     $defaultProductImage 'uploads/authorImage/' $path;
  7594.                     $new->setAuthorImage($defaultProductImage);
  7595.                     $em->flush();
  7596.                 }
  7597.                 $path "";
  7598.                 $defaultProductImage '';
  7599.                 $uploadedFile null;
  7600.                 $upl_dir $this->container->getParameter('kernel.root_dir') . '/../web/uploads/mainImage/';
  7601.                 $uploadedFile $request->files->get('main_img');
  7602.                 if ($uploadedFile != null) {
  7603.                     $fileName 'mainImage' $new->getId() . '.' $uploadedFile->guessExtension();
  7604.                     $path $fileName;
  7605. //            $upl_dir = $this->container->getParameter('kernel.root_dir') . '/../web/uploads/Products/';
  7606.                     if (!file_exists($upl_dir)) {
  7607.                         mkdir($upl_dir0777true);
  7608.                     }
  7609.                     $uploadedFile->move($upl_dir$path);
  7610.                     $defaultProductImage 'uploads/mainImage/' $path;
  7611.                     $new->setMainImage($defaultProductImage);
  7612.                     $em->flush();
  7613.                 }
  7614.                 $topicDetails $em->getRepository('CompanyGroupBundle:EntityCreateTopic')->findOneBy(
  7615.                     array(
  7616.                         'id' => $request->request->get('topicId')
  7617.                     )
  7618.                 );
  7619.                 if ($new->getIsPrimaryBlog() == 1) {
  7620.                     if ($topicDetails)
  7621.                         $topic $topicDetails;
  7622.                     else
  7623.                         $topic = new EntityCreateTopic();
  7624.                     $topic->setPrimaryBlogId($new->getId());
  7625.                     $em->flush();
  7626.                 }
  7627.                 $this->addFlash(
  7628.                     'success',
  7629.                     'Blog Added.'
  7630.                 );
  7631.             } else {
  7632.                 $em $this->getDoctrine()->getManager('company_group');
  7633.                 $topic $em->getRepository('CompanyGroupBundle:EntityCreateTopic')->findAll();
  7634.                 $applicant $em->getRepository('CompanyGroupBundle:EntityApplicantDetails')->findAll();
  7635.                 $blogs $em->getRepository('CompanyGroupBundle:EntityCreateBlog')->findAll();
  7636.                 $topicIds = [];
  7637.                 foreach ($blogs as $blog) {
  7638.                     $topicIds [] = $blog->getTopicId();
  7639.                 }
  7640. //                $topic = $em->getRepository('CompanyGroupBundle:EntityCreateTopic')->findBy(
  7641. //                    array(
  7642. //                        'id' => $topicIds
  7643. //                    )
  7644. //                );
  7645.                 return $this->render('ApplicationBundle:pages/human_resource/input_forms:create_blog.html.twig', array(
  7646.                     'page_title' => 'Create Blog',
  7647.                     'topic' => $topic,
  7648.                     'applicant' => $applicant,
  7649.                     'blog' => $blogs,
  7650.                     'id' => $id,
  7651.                 ));
  7652.             }
  7653.         } else {
  7654.             if ($request->isMethod('GET')) {
  7655.                 $em $this->getDoctrine()->getManager('company_group');
  7656.                 $topic $em->getRepository('CompanyGroupBundle:EntityCreateTopic')->findAll();
  7657.                 $applicant $em->getRepository('CompanyGroupBundle:EntityApplicantDetails')->findAll();
  7658.                 $blogs $em->getRepository('CompanyGroupBundle:EntityCreateBlog')->find($id);
  7659.                 return $this->render('ApplicationBundle:pages/human_resource/input_forms:create_blog.html.twig', array(
  7660.                     'page_title' => 'Create Blog',
  7661.                     'topic' => $topic,
  7662.                     'applicant' => $applicant,
  7663.                     'blog' => $blogs,
  7664.                     'id' => $id,
  7665.                 ));
  7666.             } else {
  7667.                 $em $this->getDoctrine()->getManager('company_group');
  7668.                 $new = new EntityCreateBlog();
  7669.                 $new->setTopicId($request->request->get('topicId'));
  7670.                 $new->setTitle($request->request->get('title'));
  7671.                 $new->setSubtitle($request->request->get('subTitle'));
  7672.                 $new->setContent($request->request->get('content'));
  7673.                 $new->setVideoLink($request->request->get('videoLink'));
  7674.                 $new->setAuthorName($request->request->get('authorName'));
  7675.                 $new->setAuthorSummary($request->request->get('authorSummary'));
  7676.                 //$em->persist($new);
  7677.                 $em->flush();
  7678.                 $path "";
  7679.                 $defaultProductImage '';
  7680.                 $uploadedFile null;
  7681.                 $upl_dir $this->container->getParameter('kernel.root_dir') . '/../web/uploads/authorImage/';
  7682.                 $uploadedFile $request->files->get('authorImage');
  7683.                 if ($uploadedFile != null) {
  7684.                     $fileName 'authorImage' '.' $uploadedFile->guessExtension();
  7685.                     $path $fileName;
  7686. //            $upl_dir = $this->container->getParameter('kernel.root_dir') . '/../web/uploads/Products/';
  7687.                     if (!file_exists($upl_dir)) {
  7688.                         mkdir($upl_dir0777true);
  7689.                     }
  7690.                     $uploadedFile->move($upl_dir$path);
  7691.                     $defaultProductImage 'uploads/authorImage/' $path;
  7692.                     $new->setAuthorImage($defaultProductImage);
  7693.                     $em->flush();
  7694.                 }
  7695.                 $this->addFlash(
  7696.                     'success',
  7697.                     'Blog Updated.'
  7698.                 );
  7699.             }
  7700.         }
  7701.         return new JsonResponse(
  7702.             array(
  7703.                 'success' => true,
  7704.             )
  7705.         );
  7706. //        if ($request->isMethod('POST')) {
  7707. //            $loginId = $request->getSession()->get(UserConstants::USER_LOGIN_ID);
  7708. //
  7709. //            $new = new EntityCreateBlog();
  7710. //
  7711. //            $new->setTopicId($request->request->get('topicId'));
  7712. //            $new->setTitle($request->request->get('title'));
  7713. //            $new->setSubtitle($request->request->get('subTitle'));
  7714. //            $new->setContent($request->request->get('content'));
  7715. //            $new->setVideoLink($request->request->get('videoLink'));
  7716. //            $new->setAuthorName($request->request->get('authorName'));
  7717. //            $new->setAuthorSummary($request->request->get('authorSummary'));
  7718. //
  7719. //            $em->persist($new);
  7720. //            $em->flush();
  7721. //
  7722. //
  7723. //            $path = "";
  7724. //            $defaultProductImage = '';
  7725. //            $uploadedFile = null;
  7726. //            $upl_dir = $this->container->getParameter('kernel.root_dir') . '/../web/uploads/authorImage/';
  7727. //            $uploadedFile=  $request->files->get('authorImage');
  7728. //
  7729. //            if ($uploadedFile != null) {
  7730. //
  7731. //                $fileName = 'authorImage' .'.' . $uploadedFile->guessExtension();
  7732. //                $path = $fileName;
  7733. ////            $upl_dir = $this->container->getParameter('kernel.root_dir') . '/../web/uploads/Products/';
  7734. //                if (!file_exists($upl_dir)) {
  7735. //                    mkdir($upl_dir, 0777, true);
  7736. //                }
  7737. //                $uploadedFile->move($upl_dir, $path);
  7738. //                $defaultProductImage = 'uploads/authorImage/' . $path;
  7739. //                $new->setAuthorImage($defaultProductImage);
  7740. //                $em->flush();
  7741. //
  7742. //            }
  7743. //            $this->addFlash(
  7744. //                'success',
  7745. //                'Blog Added.'
  7746. //            );
  7747. //        }
  7748. //        return $this->render('ApplicationBundle:pages/human_resource/input_forms:create_blog.html.twig', array(
  7749. //            'page_title' => 'Create Blog',
  7750. //            'topic'=> $topic,
  7751. //            'applicant' => $applicant,
  7752. //            'blog' => $blogs
  7753. //        ));
  7754.     }
  7755.     public function applicantConsultancyAction()
  7756.     {
  7757.         return $this->render('ApplicationBundle:pages/human_resource/input_forms:consultancy.html.twig', array(
  7758.             'page_title' => 'Consultancy',
  7759.         ));
  7760.     }
  7761.     public function viewConsultantDetailsAction(Request $request$id 0)
  7762.     {
  7763.         $gocEnabled 1;
  7764.         $currAppId 4;
  7765.         $honeybeeAppId 1;
  7766.         $buddybeeAppId 4;
  7767.         $em_goc $this->getDoctrine()->getManager('company_group');
  7768.         $em $this->getDoctrine()->getManager();
  7769.         $option = [];
  7770.         $option['appId'] = $currAppId//honeybee
  7771.         $option['departmentId'] = 18//consultancy
  7772.         $option['designationId'] = 50;
  7773. //        $dataToConnect = System::changeDoctrineManagerByAppId(
  7774. //            $this->getDoctrine()->getManager('company_group'),
  7775. //            $gocEnabled,
  7776. //            $currAppId
  7777. //        );
  7778. //        if (!empty($dataToConnect)) {
  7779. //            $connector = $this->container->get('application_connector');
  7780. //            $connector->resetConnection(
  7781. //                'default',
  7782. //                $dataToConnect['dbName'],
  7783. //                $dataToConnect['dbUser'],
  7784. //                $dataToConnect['dbPass'],
  7785. //                $dataToConnect['dbHost'],
  7786. //                $reset = true
  7787. //            );
  7788. //            $em = $this->getDoctrine()->getManager();
  7789. //        } else {
  7790. //            $currAppId = $honeybeeAppId;
  7791. //            $dataToConnectAgain = System::changeDoctrineManagerByAppId(
  7792. //                $this->getDoctrine()->getManager('company_group'),
  7793. //                $gocEnabled,
  7794. //                $currAppId
  7795. //            );
  7796. //            if (!empty($dataToConnectAgain)) {
  7797. //                $connector = $this->container->get('application_connector');
  7798. //                $connector->resetConnection(
  7799. //                    'default',
  7800. //                    $dataToConnect['dbName'],
  7801. //                    $dataToConnect['dbUser'],
  7802. //                    $dataToConnect['dbPass'],
  7803. //                    $dataToConnect['dbHost'],
  7804. //                    $reset = true
  7805. //                );
  7806. //                $em = $this->getDoctrine()->getManager();
  7807. //            }
  7808. //
  7809. //        }
  7810.         $consultantDetails $em_goc->getRepository(EntityApplicantDetails::class)->find($id);
  7811.         $skill $em_goc->getRepository(EntitySkill::class)->findAll();
  7812.         $gender HumanResourceConstant::$sex;
  7813.         $blood HumanResourceConstant::$BloodGroup;
  7814.         $consultantLevel HumanResourceConstant::$consultantLevel;
  7815.         $companyId $this->getLoggedUserCompanyId($request);
  7816.         $designation $em->getRepository("ApplicationBundle:SysDepartmentPosition")->findAll();
  7817.         $departments $em->getRepository("ApplicationBundle:SysDepartment")->findAll();
  7818.         $companyData Company::getCompanyData($em$companyId);
  7819.         $currDate = new \DateTime();
  7820.         if ($request->isMethod('POST')) {
  7821.             //for consultant only
  7822.             $convertToConsultant HumanResource::convertToConsultant($em_goc$em$id$option$request->request);
  7823.             if ($request->request->get('confirmStatus'0) == 1) {
  7824.                 $bodyTemplate 'ApplicationBundle:email/templates:consultantApprovalEmail.html.twig';
  7825.                 $contractLetterHtml '';
  7826.                 $bodyData = array(
  7827.                     'name' => $consultantDetails->getFirstname() . ' ' $consultantDetails->getLastname(),
  7828.                     'companyData' => $companyData,
  7829.                     'contractLetterHtml' => $contractLetterHtml,
  7830.                     'commentText' => $request->request->get('commentText'),
  7831.                 );
  7832.                 $new_mail $this->get('mail_module');
  7833.                 $new_mail->sendMyMail(array(
  7834.                     'senderHash' => '_CUSTOM_',
  7835.                     'encryptionMethod' => 'ssl',
  7836.                     'userName' => 'management@buddybee.eu',
  7837.                     'fromAddress' => 'management@buddybee.eu',
  7838.                     'password' => 'Eco@0112',
  7839.                     'smtpServer' => 'smtp.hostinger.com',
  7840.                     'smtpPort' => '465',
  7841.                     'forwardToMailAddress' => $consultantDetails->getEmail(),
  7842.                     'subject' => 'Consultant Contract Letter Of ' $consultantDetails->getFirstName(),
  7843.                     'fileName' => '',
  7844.                     //'attachments' => $attachments,
  7845.                     'toAddress' => $consultantDetails->getEmail(),
  7846.                     'mailTemplate' => $bodyTemplate,
  7847.                     'templateData' => $bodyData,
  7848.                     'embedCompanyImage' => 1,
  7849.                     'companyId' => $companyId,
  7850.                     'companyImagePath' => ""
  7851.                 ));
  7852.             }
  7853.             if ($request->request->get('confirmStatus'0) == 0) {
  7854.                 $bodyTemplate 'ApplicationBundle:email/templates:consultantRejectionEmail.html.twig';
  7855.                 $contractLetterHtml '';
  7856.                 $bodyData = array(
  7857.                     'name' => $consultantDetails->getFirstname() . ' ' $consultantDetails->getLastname(),
  7858.                     'companyData' => $companyData,
  7859.                     'contractLetterHtml' => $contractLetterHtml,
  7860.                     'commentText' => $request->request->get('commentText'),
  7861.                 );
  7862.                 $new_mail $this->get('mail_module');
  7863.                 $new_mail->sendMyMail(array(
  7864.                     'senderHash' => '_CUSTOM_',
  7865.                     'encryptionMethod' => 'ssl',
  7866.                     'userName' => 'management@buddybee.eu',
  7867.                     'fromAddress' => 'management@buddybee.eu',
  7868.                     'password' => 'Eco@0112',
  7869.                     'smtpServer' => 'smtp.hostinger.com',
  7870.                     'smtpPort' => '465',
  7871.                     'forwardToMailAddress' => $consultantDetails->getEmail(),
  7872.                     'subject' => 'Rejection Letter Of ' $consultantDetails->getFirstName(),
  7873.                     'fileName' => '',
  7874.                     //'attachments' => $attachments,
  7875.                     'toAddress' => $consultantDetails->getEmail(),
  7876.                     'mailTemplate' => $bodyTemplate,
  7877.                     'templateData' => $bodyData,
  7878.                     'embedCompanyImage' => 1,
  7879.                     'companyId' => $companyId,
  7880.                     'companyImagePath' => ""
  7881.                 ));
  7882.             }
  7883.         }
  7884.         $docList MiscActions::GetDocumentDataForBuddybeeConsultantApply($em_goc,
  7885.             $id,
  7886.             $consultantDetails->getCurrentCountryId()
  7887.         );
  7888.         return $this->render('ApplicationBundle:pages/human_resource/views:viewConsultantDetails.html.twig', array(
  7889.             'page_title' => 'Consultant Details',
  7890.             'applicantId' => $id,
  7891.             'consultantDetails' => $consultantDetails,
  7892.             'education' => json_decode($consultantDetails->getEducationData(), true),
  7893.             'workExperience' => json_decode($consultantDetails->getWorkExperienceData(), true),
  7894.             'certificate' => json_decode($consultantDetails->getCertificateData(), true),
  7895.             'gender' => $gender,
  7896.             'blood' => $blood,
  7897.             'skill' => $skill,
  7898.             'docList' => $docList,
  7899.             'countryId' => $consultantDetails->getCurrentCountryId(),
  7900.             'consultantLevel' => $consultantLevel,
  7901.             'designation' => $designation,
  7902.             'department' => $departments
  7903.         ));
  7904.     }
  7905.     public function ApplicableEmployeSettingsAction()
  7906.     {
  7907.         $em $this->getDoctrine()->getManager();
  7908.         $employeeIds $em->getRepository(Employee::class)->findAll();
  7909.         return $this->render('ApplicationBundle:pages/human_resource/input_forms:applicable_employee_settings.html.twig', array(
  7910.             'page_title' => 'Applicable Employee Settings',
  7911.             'employeeIds' => $employeeIds
  7912.         ));
  7913.     }
  7914.     public function GetApplicableSettingsForSingleEmployeeAction($id)
  7915.     {
  7916.         $em $this->getDoctrine()->getManager();
  7917.         $bankLists $em->getRepository(WorkHourPolicy::class)->findAll();
  7918.         if (json_decode($bankLists->getEmployeeIds()) == $id) {
  7919.             return new JsonResponse(
  7920.                 array(
  7921.                     'success' => true,
  7922.                     'msg' => 'employee found'
  7923.                 )
  7924.             );
  7925.         } else {
  7926.             return new JsonResponse(
  7927.                 array(
  7928.                     'success' => true,
  7929.                     'msg' => 'employee not found'
  7930.                 )
  7931.             );
  7932.         }
  7933.     }
  7934. //    public function  getEmployeeDataAction(){
  7935. //        $em = $this->getDoctrine()->getManager();
  7936. //        $emplyeeDetails =  $em->getRepository('ApplicationBundle:EmployeeDeatils')->findAll();
  7937. //        $days = HumanResourceConstant::$days;
  7938. //        $holidays = ;
  7939. //        $workHourPolicies = ;
  7940. //
  7941. //    }
  7942.     public function meetingSchedulingForTabAction()
  7943.     {
  7944.         $em $this->getDoctrine()->getManager();
  7945.         $date date('Y-m-d');
  7946.         $month date('m');
  7947.         $year date('Y');
  7948.         $monthName date("F"mktime(000$month));
  7949.         $totalDayOfMonth cal_days_in_month(CAL_GREGORIAN$month$year);
  7950.         $fromdt date('Y-m-01 'strtotime("First Day Of  $monthName $year"));
  7951. //        echo "Start Date : $fromdt" . "<br>";
  7952.         $todt date('Y-m-d 'strtotime("Last Day of $monthName $year"));
  7953. //        echo "End Date : $todt" . "<br>";
  7954.         $num_friday '';
  7955.         for ($i 0$i < ((strtotime($todt) - strtotime($fromdt)) / 86400); $i++) {
  7956.             if (date('l'strtotime($fromdt) + ($i 86400)) == 'Friday') {
  7957.                 $num_friday++;
  7958.             }
  7959.         }
  7960.         $num_saturday '';
  7961.         for ($i 0$i < ((strtotime($todt) - strtotime($fromdt)) / 86400); $i++) {
  7962.             if (date('l'strtotime($fromdt) + ($i 86400)) == 'Saturday') {
  7963.                 $num_saturday++;
  7964.             }
  7965.         }
  7966.         $totalWeekends $num_saturday $num_friday;
  7967.         $totalCompanyWorkingDay $totalDayOfMonth $totalWeekends;
  7968. //        $attendanceData=$em->getRepository('ApplicationBundle:EmployeeAttendanceLog')->findOneBy(
  7969. //            array(
  7970. //                'employeeId' => 3
  7971. //            )
  7972. //        );
  7973.         $DateRange = [];
  7974.         $holidayDates $em->getRepository('ApplicationBundle:HolidayCalendarDates')->findAll();
  7975.         foreach ($holidayDates as $holiday) {
  7976.             $holidaayData = array(
  7977.                 'startDate' => $holiday->getStartDate(),
  7978.                 'endDate' => $holiday->getEndDate(),
  7979.             );
  7980.             $DateRange $holidaayData;
  7981.         }
  7982.         $employeeDataDetail = [];
  7983.         $employeeDetail $em->getRepository('ApplicationBundle:EmployeeDetails')->findOneBy(
  7984.             array(
  7985.                 'id' => 3
  7986.             )
  7987.         );
  7988. //        foreach($employeeDetail as $employee){
  7989.         $employeeData = array(
  7990.             'firstName' => $employeeDetail->getFirstname(),
  7991.             'basic' => $employeeDetail->getEar1(),
  7992.             'dearness' => $employeeDetail->getEar2(),
  7993.             'houseRent' => $employeeDetail->getEar3(),
  7994.             'medical' => $employeeDetail->getEar4(),
  7995.             'leaveTravel' => $employeeDetail->getEar5(),
  7996.             'childEducation' => $employeeDetail->getEar6(),
  7997.             'totalEarning' => $employeeDetail->getEart(),
  7998.         );
  7999.         $employeeDataDetail $employeeData;
  8000. //        }
  8001.         $attendanceData $em->getRepository(EmployeeAttendanceLog::class);
  8002. //        $employeeId = $attendanceData->getEmployeeId();
  8003. //        $countId = count($employeeId);
  8004.         $totalPresent $attendanceData->createQueryBuilder('a')
  8005.             // Filter by some parameter if you want
  8006.             ->where('a.employeeId = 3')
  8007.             ->andWhere('a.isPresent = 1')
  8008.             ->select('a.isPresent')
  8009.             ->getQuery()
  8010.             ->getResult();
  8011. //        $countAt = 0;
  8012.         $count count($totalPresent);
  8013. //        $count = $countAt+$count;
  8014.         //get holiday
  8015.         $holidayStartDate $DateRange['startDate']->format('Y-m-d');
  8016.         $holidayEndDate $DateRange['endDate']->format('Y-m-d');
  8017.         $dates HumanResource::getBetweenDates($holidayStartDate$holidayEndDate);
  8018.         $dateCount count($dates);
  8019.         $totalOffDay $totalWeekends $dateCount;
  8020.         $totalCompanyWorkingDay $totalDayOfMonth $totalOffDay;
  8021.         $totalAbsent $totalCompanyWorkingDay $count;
  8022. //        foreach($dates as $compDate ){
  8023. //
  8024. //
  8025. //
  8026. //            if($date == $compDate){
  8027. //                echo $date;
  8028. //                echo $compDate;
  8029. //                echo "holiday" ;
  8030. //
  8031. //            }
  8032. //            else{
  8033. //                echo "no holiday" ;
  8034. //            }
  8035. //        }
  8036.         $twigData HumanResource::twigDataForWorkHourPolicy($em);
  8037.         return $this->render('ApplicationBundle:pages/human_resource/list:meeting_schedule_list_for_tab.html.twig', array(
  8038.             'page_title' => 'Meeting Schedule List',
  8039.             'date' => $date,
  8040.             'totalWeekends' => $totalWeekends,
  8041.             'totalCompanyWorkingDay' => $totalCompanyWorkingDay,
  8042. //            'attendanceData' => $attendanceData,
  8043. //            'employeeId' => $employeeId,
  8044.             'count' => $count,
  8045.             'totalAbsent' => $totalAbsent,
  8046.             'employeeDataDetail' => $employeeDataDetail,
  8047.             'holiday' => $DateRange,
  8048.             'holidayStartDate' => $holidayStartDate,
  8049.             'holidayEndDate' => $holidayEndDate,
  8050.             'holidayCount' => $dateCount,
  8051.             'totalOffDay' => $totalOffDay,
  8052.             'employeeIds' => $twigData['employeeIds'],
  8053.         ));
  8054.     }
  8055.     public function getEmployeeDataForDisburseAction($id)
  8056.     {
  8057.         $em $this->getDoctrine()->getManager();
  8058.         $employeeDetail $em->getRepository('ApplicationBundle:EmployeeDetails')->find($id);
  8059.         return new JsonResponse(
  8060.             array(
  8061.                 'success' => true,
  8062.                 'firstName' => $employeeDetail->getFirstName(),
  8063.             )
  8064.         );
  8065.     }
  8066.     public function BulkAttendanceAction(Request $request)
  8067.     {
  8068.         $em $this->getDoctrine()->getManager();
  8069.         $companyId $this->getLoggedUserCompanyId($request);
  8070.         if ($request->isMethod('POST')) {
  8071.             $attendance = [];
  8072.             foreach ($request->request->get('date') as $key => $val) {
  8073.                 $loginId $request->getSession()->get(UserConstants::USER_LOGIN_ID);
  8074.                 $bulkAttendance null;
  8075.                 if ($request->request->get('attId')[$key] != 0)
  8076.                     $bulkAttendance $em->getRepository('ApplicationBundle:EmployeeAttendance')->findOneBy(array(
  8077.                         'id' => $request->request->get('attId')[$key],
  8078.                     ));
  8079.                 if (!$bulkAttendance)
  8080.                     $bulkAttendance = new EmployeeAttendance;
  8081.                 $theDate = new \DateTime($request->request->get('date')[$key]);
  8082.                 $bulkAttendance->setEmployeeId($request->request->get('employeeId'));
  8083.                 $bulkAttendance->setDate($theDate);
  8084.                 $bulkAttendance->setEntry(
  8085.                     ($request->request->get('startTimeTs')[$key] == '' ||
  8086.                         $request->request->get('startTimeTs')[$key] == 'NaN' ||
  8087.                         $request->request->get('startTimeTs')[$key] == 0) ? null :
  8088.                         new \DateTime('@' $request->request->get('startTimeTs')[$key])
  8089.                 );
  8090.                 $bulkAttendance->setLastOut(($request->request->get('endTimeTs')[$key] == '' ||
  8091.                     $request->request->get('endTimeTs')[$key] == 'NaN' ||
  8092.                     $request->request->get('endTimeTs')[$key] == 0) ? null :
  8093.                     new \DateTime('@' $request->request->get('endTimeTs')[$key]));
  8094.                 $bulkAttendance->setData(json_encode(
  8095.                     array(
  8096.                         "in" => json_decode($request->request->get('entryDataIn')[$key], true),
  8097.                         "out" => json_decode($request->request->get('entryDataOut')[$key], true)
  8098.                     )
  8099.                 ));
  8100. //                $bulkAttendance->setLastStartTime(new \DateTime($request->request->get('startDate')));
  8101. //                $bulkAttendance->setIsPresent(1);
  8102.                 $bulkAttendance->setLastStartTimeTs($request->request->get('startTimeTs')[$key]);
  8103.                 $bulkAttendance->setLastEndTimeTs($request->request->get('endTimeTs')[$key]);
  8104. //                $bulkAttendance->setTotalWorkHour($request->request->get('totalWorkHour')[$key]);
  8105.                 $em->persist($bulkAttendance);
  8106.                 $em->flush();
  8107.                 $bulkAttendanceLog $em->getRepository('ApplicationBundle:EmployeeAttendanceLog')->findOneBy(array(
  8108.                     'attendance_id' => $bulkAttendance->getId(),
  8109.                 ));
  8110.                 if (!$bulkAttendanceLog)
  8111.                     $bulkAttendanceLog = new EmployeeAttendanceLog;
  8112.                 $bulkAttendanceLog->setAttendanceId($bulkAttendance->getId());
  8113.                 $bulkAttendanceLog->setEmployeeId($request->request->get('employeeId'));
  8114.                 $bulkAttendanceLog->setLastStartTime(
  8115.                     ($request->request->get('startTimeTs')[$key] == '' ||
  8116.                         $request->request->get('startTimeTs')[$key] == 'NaN' ||
  8117.                         $request->request->get('startTimeTs')[$key] == 0) ? null :
  8118.                         new \DateTime('@' $request->request->get('startTimeTs')[$key])
  8119.                 );
  8120.                 $bulkAttendanceLog->setLastEndTime(($request->request->get('endTimeTs')[$key] == '' ||
  8121.                     $request->request->get('endTimeTs')[$key] == 'NaN' ||
  8122.                     $request->request->get('endTimeTs')[$key] == 0) ? null :
  8123.                     new \DateTime('@' $request->request->get('endTimeTs')[$key]));
  8124. //                $bulkAttendance->setLastStartTime(new \DateTime($request->request->get('startDate')));
  8125.                 $bulkAttendanceLog->setIsPresent(1);
  8126.                 $bulkAttendanceLog->setLastStartTimeTs($request->request->get('startTimeTs')[$key]);
  8127.                 $bulkAttendanceLog->setLastEndTimeTs($request->request->get('endTimeTs')[$key]);
  8128.                 $bulkAttendanceLog->setTotalWorkHour($request->request->get('totalWorkHour')[$key]);
  8129. //                $bulkAttendanceLog->setPositionArray(json_encode($request->request->get('locations')[$key]));
  8130.                 $em->persist($bulkAttendanceLog);
  8131.                 $em->flush();
  8132.             }
  8133.         }
  8134.         $startDate $request->query->get('start_date''');
  8135.         $endDate $request->query->get('end_date''');
  8136.         $employeeId $request->query->get('employee_id'0);
  8137.         $existingData = [];
  8138.         $startDateTs 0;
  8139.         $endDateTs 0;
  8140.         $returnData = array(
  8141.             'page_title' => 'Bulk Attendance',
  8142.             'existingData' => $existingData,
  8143.             'startDateTs' => $startDateTs,
  8144.             'endDateTs' => $endDateTs,
  8145.         );
  8146.         if ($request->query->has('returnJson')) {
  8147.             if ($startDate != '' && $endDate != '' && $employeeId != 0) {
  8148.                 $startDateDt = new \DateTime($startDate);
  8149.                 $endDateDt = new \DateTime($endDate);
  8150.                 $startDateTs $startDateDt->format('U');
  8151.                 $endDateTs $endDateDt->format('U');
  8152.                 $attendanceQuery $em->getRepository('ApplicationBundle:EmployeeAttendance')
  8153.                     ->createQueryBuilder('p')
  8154.                     ->where("p.employeeId = " $employeeId)
  8155. //                ->andWhere("p.date => '" . ($startDateDt->format('Y-m-d'))."'")
  8156.                     ->andWhere("p.date <= :last")
  8157.                     ->andWhere("p.date >= :start")
  8158.                     ->setParameter('start'$startDateDt)
  8159.                     ->setParameter('last'$endDateDt);
  8160.                 $attendanceResults $attendanceQuery->getQuery()->getResult();
  8161.                 foreach ($attendanceResults as $att) {
  8162.                     $entryDateTime null;
  8163.                     $outDateTime null;
  8164.                     if ($att->getEntry()) $entryDateTime = new \DateTime($att->getDate()->format('Y-m-d') . ' ' $att->getEntry()->format('H:i:00 +0000'));
  8165.                     if ($att->getLastOut()) $outDateTime = new \DateTime($att->getDate()->format('Y-m-d') . ' ' $att->getLastOut()->format('H:i:00 +0000'));
  8166.                     $attData = array(
  8167.                         'id' => $att->getId(),
  8168.                         'date_str' => $att->getDate()->format('Y-m-d'),
  8169.                         'date_str_full' => $att->getDate()->format('Y-m-d H:i:s'),
  8170.                         'in_time_full' => $entryDateTime $entryDateTime->format(DATE_RFC2822) : '',
  8171.                         'date_ts' => $att->getDate()->format('U'),
  8172.                         'in_time' => $entryDateTime $entryDateTime->format('H:i:s') : '',
  8173.                         'in_time_ts' => $entryDateTime $entryDateTime->format('U') : 0,
  8174.                         'last_out_time' => $outDateTime $outDateTime->format('H:i:s') : '',
  8175.                         'last_out_time_ts' => $outDateTime $outDateTime->format('U') : '',
  8176.                     );
  8177.                     $locations = [];
  8178.                     $locList = [];
  8179.                     $logHere $em->getRepository('ApplicationBundle:EmployeeAttendanceLog')->findOneBy(array(
  8180.                         'attendance_id' => $att->getId(),
  8181.                     ));
  8182.                     if ($logHere)
  8183.                         $locList json_decode($logHere->getPositionArray(), true);
  8184.                     if ($locList == null)
  8185.                         $locList = [];
  8186.                     $entry_data json_decode($att->getData(), true);
  8187.                     if ($entry_data == null$entry_data = [];
  8188.                     $lastLat 0;
  8189.                     $lastLng 0;
  8190.                     foreach ($locList as $lg) {
  8191.                         $dist 0;
  8192.                         if (isset($lg['lat'])) {
  8193.                             if ($lastLat == 0) {
  8194.                                 $lastLat $lg['lat'];
  8195.                                 $lastLng $lg['lng'];
  8196.                             }
  8197.                             $theta $lastLng $lg['lng'];
  8198.                             $dist sin(deg2rad($lastLat)) * sin(deg2rad($lg['lat'])) + cos(deg2rad($lastLat)) * cos(deg2rad($lg['lat'])) * cos(deg2rad($theta));
  8199.                             $dist acos($dist);
  8200.                             $dist rad2deg($dist);
  8201.                             $miles $dist 60 1.1515;
  8202.                             $dist $miles 1609.344;
  8203.                             if (abs($dist) > 1000) {
  8204.                                 $locations[] = array(
  8205.                                     'ts' => $lg['ts'],
  8206.                                     'lat' => $lg['lat'],
  8207.                                     'lng' => $lg['lng'],
  8208.                                 );
  8209.                                 $lastLat $lg['lat'];
  8210.                                 $lastLng $lg['lng'];
  8211.                             }
  8212.                         }
  8213.                     }
  8214.                     $attData['locations'] = $locations;
  8215.                     $attData['entryData'] = $entry_data;
  8216.                     $existingData[$att->getDate()->format('U')] = $attData;
  8217.                 }
  8218.             }
  8219.             $returnData = array(
  8220.                 'page_title' => 'Bulk Attendance',
  8221.                 'existingData' => $existingData,
  8222.                 'startDateTs' => $startDateTs,
  8223.                 'endDateTs' => $endDateTs,
  8224.             );
  8225.             return new JsonResponse($returnData);
  8226.         } else
  8227.             return $this->render('ApplicationBundle:pages/human_resource/attendance:bulk_attendance.html.twig'$returnData);
  8228.     }
  8229.     public function CreateAttendanceAmendmentAction(Request $request$id 0)
  8230.     {
  8231.         $em $this->getDoctrine()->getManager();
  8232.         $companyId $this->getLoggedUserCompanyId($request);
  8233.         $extDocData = [];
  8234.         if ($request->isMethod('POST')) {
  8235.             $em $this->getDoctrine()->getManager();
  8236.             $entity_id array_flip(GeneralConstant::$Entity_list)['AttendanceAmendment']; //change
  8237.             $dochash $request->request->get('docHash'); //change
  8238.             $loginId $request->getSession()->get(UserConstants::USER_LOGIN_ID);
  8239.             $approveRole $request->request->get('approvalRole');
  8240.             $approveHash $request->request->get('approvalHash');
  8241.             if ($dochash == '') {
  8242.                 $numberHash MiscActions::GetNumberHash($em'ATAM'$request->request->get('prefix_hash'$request->request->get('employeeId'0)), $request->request->get('assoc_hash'0), ''1);
  8243.                 $dochash 'ATAM' '/' $request->request->get('prefix_hash'$request->request->get('employeeId'0)) . '/' $request->request->get('assoc_hash'0) . '/' $numberHash;
  8244.             } else
  8245.                 $numberHash $request->request->get('number_hash');
  8246.             if (!DocValidation::isInsertable($em$entity_id$dochash,
  8247.                 $loginId$approveRole$approveHash$id)
  8248.             ) {
  8249.                 if ($request->request->has('returnJson')) {
  8250.                     return new JsonResponse(array(
  8251.                         'success' => false,
  8252.                         'documentHash' => 0,
  8253.                         'documentId' => 0,
  8254.                     ));
  8255.                 } else
  8256.                     $this->addFlash(
  8257.                         'error',
  8258.                         'Sorry Could not insert Data.'
  8259.                     );
  8260.             } else {
  8261.                 $funcname 'AttendanceAmendment';
  8262.                 $doc_id $id;
  8263.                 DeleteDocument::$funcname($em$doc_id0);
  8264.                 $attendanceAmendment = new AttendanceAmendment();
  8265.                 $attendanceAmendment->setDocumentHash($dochash);
  8266.                 $attendanceAmendment->setAttendanceAmendmentDate(new \DateTime($request->request->get('docDate''')));
  8267.                 $attendanceAmendment->setStartDate(new \DateTime($request->request->get('startDate''')));
  8268.                 $attendanceAmendment->setEndDate(new \DateTime($request->request->get('endDate''')));
  8269.                 $attendanceAmendment->setTypeHash('ATAM');
  8270.                 $attendanceAmendment->setPrefixHash($request->request->get('prefix_hash'0));
  8271.                 $attendanceAmendment->setAssocHash($request->request->get('assoc_hash'0));
  8272.                 $attendanceAmendment->setNumberHash($numberHash);
  8273.                 $attendanceAmendment->setCreatedLoginId($request->getSession()->get(UserConstants::USER_LOGIN_ID));
  8274.                 $attendanceAmendment->setApproved(array_flip(GeneralConstant::$approvalStatus)['pending']);
  8275.                 $attendanceAmendment->setAutoCreated($request->request->get('fullApprove'0));
  8276.                 $attendanceAmendment->setEmployeeId($request->request->get('forcedEmployeeId'$request->request->get('employeeId'0)));
  8277. //                $attendanceAmendment->setAutocreated(0);
  8278.                 if ($request->request->has('dataArrayJson')) {
  8279.                     $attendanceAmendment->setData($request->request->get('dataArrayJson''[]'));
  8280.                 } else {
  8281.                     $arr = [
  8282.                     ];
  8283.                     //dump($arr);
  8284.                     foreach ($request->request->get('date', []) as $key => $val) {
  8285.                         if ($request->request->get('isChanged')[$key] == 1) {
  8286.                             $dt = array(
  8287.                                 'enabled' => 1,
  8288.                                 'attId' => $request->request->get('attId')[$key],
  8289.                                 'note' => $request->request->get('note')[$key],
  8290.                                 'startTimeTs' => $request->request->get('startTimeTs')[$key],
  8291.                                 'endTimeTs' => $request->request->get('endTimeTs')[$key],
  8292.                                 'totalWorkHour' => $request->request->get('totalWorkHour')[$key],
  8293.                                 'entryDataIn' => json_decode($request->request->get('entryDataIn')[$key], true),
  8294.                                 'entryDataOut' => json_decode($request->request->get('entryDataOut')[$key], true),
  8295.                             );
  8296.                             $arr[$val] = $dt;
  8297.                         }
  8298.                     }
  8299.                     $attendanceAmendment->setData(json_encode($arr));
  8300.                 }
  8301.                 $em->persist($attendanceAmendment);
  8302.                 $em->flush();
  8303.                 $ID $attendanceAmendment->getAttendanceAmendmentId();
  8304.                 //now add Approval info
  8305.                 $loginId $request->getSession()->get(UserConstants::USER_LOGIN_ID);
  8306.                 $approveRole 1;  //created
  8307.                 $options = array(
  8308.                     'notification_enabled' => $this->container->getParameter('notification_enabled'),
  8309.                     'notification_server' => $this->container->getParameter('notification_server'),
  8310.                     'appId' => $request->getSession()->get(UserConstants::USER_APP_ID),
  8311.                     'url' => $this->generateUrl(
  8312.                         GeneralConstant::$Entity_list_details[array_flip(GeneralConstant::$Entity_list)['AttendanceAmendment']]
  8313.                         ['entity_view_route_path_name']
  8314.                     )
  8315.                 );
  8316.                 System::setApprovalInfo($this->getDoctrine()->getManager(), $options,
  8317.                     array_flip(GeneralConstant::$Entity_list)['AttendanceAmendment'],
  8318.                     $ID,
  8319.                     $request->getSession()->get(UserConstants::USER_LOGIN_ID)    //journal voucher
  8320.                 );
  8321.                 if ($request->request->get('fullApprove'0) == 1) {
  8322.                     DeleteDocument::AttendanceAmendment($em$ID);
  8323.                 } else {
  8324.                     System::createEditSignatureHash($this->getDoctrine()->getManager(), array_flip(GeneralConstant::$Entity_list)['AttendanceAmendment'], $ID,
  8325.                         $loginId,
  8326.                         $approveRole,
  8327.                         $request->request->get('approvalHash'));
  8328.                     $url $this->generateUrl(
  8329.                         'view_attendance_amendment'
  8330.                     );
  8331.                     if ($request->request->has('returnJson')) {
  8332.                         return new JsonResponse(array(
  8333.                             'success' => true,
  8334.                             'documentHash' => $dochash,
  8335.                             'documentId' => $ID,
  8336.                             'viewUrl' => $url "/" $ID,
  8337.                         ));
  8338.                     } else {
  8339.                         $this->addFlash(
  8340.                             'success',
  8341.                             'Attendance Amendment Note Added.'
  8342.                         );
  8343.                         return $this->redirect($url "/" $ID);
  8344.                     }
  8345.                 }
  8346.             }
  8347.         }
  8348.         if ($id == 0) {
  8349.         } else {
  8350.             $extDoc $em->getRepository('ApplicationBundle:AttendanceAmendment')->findOneBy(
  8351.                 array(
  8352.                     'salesOrderId' => $id///material
  8353.                 )
  8354.             );
  8355.             //now if its not editable, redirect to view
  8356.             if ($extDoc) {
  8357.                 if ($extDoc->getEditFlag() != 1) {
  8358.                     $url $this->generateUrl(
  8359.                         'view_attendance_amendment'
  8360.                     );
  8361.                     return $this->redirect($url "/" $id);
  8362.                 } else {
  8363.                     $extDocData $extDoc;
  8364.                 }
  8365.             } else {
  8366.             }
  8367.         }
  8368.         $startDate $request->query->get('start_date''');
  8369.         $endDate $request->query->get('end_date''');
  8370.         $employeeId $request->query->get('employee_id'0);
  8371.         $existingData = [];
  8372.         $startDateTs 0;
  8373.         $endDateTs 0;
  8374.         $returnData = array(
  8375.             'page_title' => 'Attendance Amendment',
  8376.             'existingData' => $existingData,
  8377.             'startDateTs' => $startDateTs,
  8378.             'extDocData' => $extDocData,
  8379.             'endDateTs' => $endDateTs,
  8380.         );
  8381.         if ($request->query->has('returnJson')) {
  8382.             if ($startDate != '' && $endDate != '' && $employeeId != 0) {
  8383.                 $startDateDt = new \DateTime($startDate);
  8384.                 $endDateDt = new \DateTime($endDate);
  8385.                 $startDateTs $startDateDt->format('U');
  8386.                 $endDateTs $endDateDt->format('U');
  8387.                 $attendanceQuery $em->getRepository('ApplicationBundle:EmployeeAttendance')
  8388.                     ->createQueryBuilder('p')
  8389.                     ->where("p.employeeId = " $employeeId)
  8390. //                ->andWhere("p.date => '" . ($startDateDt->format('Y-m-d'))."'")
  8391.                     ->andWhere("p.date <= :last")
  8392.                     ->andWhere("p.date >= :start")
  8393.                     ->setParameter('start'$startDateDt)
  8394.                     ->setParameter('last'$endDateDt);
  8395.                 $attendanceResults $attendanceQuery->getQuery()->getResult();
  8396.                 foreach ($attendanceResults as $att) {
  8397.                     $entryDateTime null;
  8398.                     $outDateTime null;
  8399.                     if ($att->getEntry()) $entryDateTime = new \DateTime($att->getDate()->format('Y-m-d') . ' ' $att->getEntry()->format('H:i:00 +0000'));
  8400.                     if ($att->getLastOut()) $outDateTime = new \DateTime($att->getDate()->format('Y-m-d') . ' ' $att->getLastOut()->format('H:i:00 +0000'));
  8401.                     $attData = array(
  8402.                         'id' => $att->getId(),
  8403.                         'date_str' => $att->getDate()->format('Y-m-d'),
  8404.                         'date_str_full' => $att->getDate()->format('Y-m-d H:i:s'),
  8405.                         'in_time_full' => $entryDateTime $entryDateTime->format(DATE_RFC2822) : '',
  8406.                         'date_ts' => $att->getDate()->format('U'),
  8407.                         'in_time' => $entryDateTime $entryDateTime->format('H:i:s') : '',
  8408.                         'in_time_ts' => $entryDateTime $entryDateTime->format('U') : 0,
  8409.                         'last_out_time' => $outDateTime $outDateTime->format('H:i:s') : '',
  8410.                         'last_out_time_ts' => $outDateTime $outDateTime->format('U') : '',
  8411.                     );
  8412.                     $locations = [];
  8413.                     $locList = [];
  8414.                     $logHere $em->getRepository('ApplicationBundle:EmployeeAttendanceLog')->findOneBy(array(
  8415.                         'attendance_id' => $att->getId(),
  8416.                     ));
  8417.                     if ($logHere)
  8418.                         $locList json_decode($logHere->getPositionArray(), true);
  8419.                     if ($locList == null)
  8420.                         $locList = [];
  8421.                     $entry_data json_decode($att->getData(), true);
  8422.                     if ($entry_data == null$entry_data = [];
  8423.                     $lastLat 0;
  8424.                     $lastLng 0;
  8425.                     foreach ($locList as $lg) {
  8426.                         $dist 0;
  8427.                         if (isset($lg['lat'])) {
  8428.                             if ($lastLat == 0) {
  8429.                                 $lastLat $lg['lat'];
  8430.                                 $lastLng $lg['lng'];
  8431.                             }
  8432.                             $theta $lastLng $lg['lng'];
  8433.                             $dist sin(deg2rad($lastLat)) * sin(deg2rad($lg['lat'])) + cos(deg2rad($lastLat)) * cos(deg2rad($lg['lat'])) * cos(deg2rad($theta));
  8434.                             $dist acos($dist);
  8435.                             $dist rad2deg($dist);
  8436.                             $miles $dist 60 1.1515;
  8437.                             $dist $miles 1609.344;
  8438.                             if (abs($dist) > 1000) {
  8439.                                 $locations[] = array(
  8440.                                     'ts' => $lg['ts'],
  8441.                                     'lat' => $lg['lat'],
  8442.                                     'lng' => $lg['lng'],
  8443.                                 );
  8444.                                 $lastLat $lg['lat'];
  8445.                                 $lastLng $lg['lng'];
  8446.                             }
  8447.                         }
  8448.                     }
  8449.                     $attData['locations'] = $locations;
  8450.                     $attData['entryData'] = $entry_data;
  8451.                     $existingData[$att->getDate()->format('U')] = $attData;
  8452.                 }
  8453.             }
  8454.             $returnData = array(
  8455.                 'page_title' => 'Attendance Amendment',
  8456.                 'existingData' => $existingData,
  8457.                 'startDateTs' => $startDateTs,
  8458.                 'extDocData' => $extDocData,
  8459.                 'endDateTs' => $endDateTs,
  8460.             );
  8461.             return new JsonResponse($returnData);
  8462.         } else
  8463.             return $this->render('ApplicationBundle:pages/human_resource/attendance:create_attendance_amendment.html.twig'$returnData);
  8464.     }
  8465.     public function AttendanceAmendmentListAction(Request $request)
  8466.     {
  8467.         $data = [];
  8468.         return $this->render('ApplicationBundle:pages/human_resource/list:attendance_amendment_list.html.twig',
  8469.             array(
  8470.                 'page_title' => 'Attendance Amendment List',
  8471.                 'data' => $data
  8472.             )
  8473.         );
  8474.     }
  8475.     public function ViewAttendanceAmendmentAction(Request $request$id)
  8476.     {
  8477.         $em $this->getDoctrine()->getManager();
  8478.         $dt HumanResource::GetAttendanceAmendmentDetails($em$id);
  8479.         return $this->render('ApplicationBundle:pages/human_resource/views:view_attendance_amendment.html.twig',
  8480.             array(
  8481.                 'page_title' => 'Attendance Amendment',
  8482.                 'data' => $dt,
  8483.                 'approval_data' => System::checkIfApprovalExists($emarray_flip(GeneralConstant::$Entity_list)['AttendanceAmendment'],
  8484.                     $id$request->getSession()->get(UserConstants::USER_LOGIN_ID)),
  8485.                 'document_log' => System::getDocumentLog($this->getDoctrine()->getManager(),
  8486.                     array_flip(GeneralConstant::$Entity_list)['AttendanceAmendment'],
  8487.                     $id,
  8488.                     $dt['created_by'],
  8489.                     $dt['edited_by'])
  8490.             )
  8491.         );
  8492.     }
  8493.     public function PrintAttendanceAmendmentAction(Request $request$id)
  8494.     {
  8495.         $em $this->getDoctrine()->getManager();
  8496.         $dt HumanResource::GetAttendanceAmendmentDetails($em$id);
  8497.         $company_data Company::getCompanyData($em1);
  8498.         $document_mark = array(
  8499.             'original' => '/images/Original-Stamp-PNG-Picture.png',
  8500.             'copy' => ''
  8501.         );
  8502.         if ($request->query->has('pdf') && $this->get('knp_snappy.pdf')) {
  8503.             $html $this->renderView('@Inventory/pages/print/print_stock_received_note.html.twig',
  8504.                 array(
  8505.                     //full array here
  8506.                     'pdf' => true,
  8507.                     'page_title' => 'Stock Received Note',
  8508.                     'export' => 'pdf,print',
  8509.                     'data' => $dt,
  8510.                     'approval_data' => System::checkIfApprovalExists($emarray_flip(GeneralConstant::$Entity_list)['AttendanceAmendment'],
  8511.                         $id$request->getSession()->get(UserConstants::USER_LOGIN_ID)),
  8512.                     'document_log' => System::getDocumentLog($this->getDoctrine()->getManager(),
  8513.                         array_flip(GeneralConstant::$Entity_list)['AttendanceAmendment'],
  8514.                         $id,
  8515.                         $dt['created_by'],
  8516.                         $dt['edited_by']),
  8517.                     'document_mark_image' => $document_mark['original'],
  8518.                     'company_name' => $company_data->getName(),
  8519.                     'company_data' => $company_data,
  8520.                     'company_address' => $company_data->getAddress(),
  8521.                     'company_image' => $company_data->getImage(),
  8522.                     'invoice_footer' => $company_data->getInvoiceFooter(),
  8523.                     'red' => 0
  8524.                 )
  8525.             );
  8526.             $pdf_response $this->get('knp_snappy.pdf')->getOutputFromHtml($html, array(
  8527. //                'orientation' => 'landscape',
  8528. //                'enable-javascript' => true,
  8529. //                'javascript-delay' => 1000,0
  8530.                 'no-stop-slow-scripts' => false,
  8531.                 'no-background' => false,
  8532.                 'lowquality' => false,
  8533.                 'encoding' => 'utf-8',
  8534. //            'images' => true,
  8535. //            'cookie' => array(),
  8536.                 'dpi' => 300,
  8537.                 'image-dpi' => 300,
  8538. //                'enable-external-links' => true,
  8539. //                'enable-internal-links' => true
  8540.             ));
  8541.             return new Response(
  8542.                 $pdf_response,
  8543.                 200,
  8544.                 array(
  8545.                     'Content-Type' => 'application/pdf',
  8546.                     'Content-Disposition' => 'attachment; filename="stock_received_note_' $id '.pdf"'
  8547.                 )
  8548.             );
  8549.         }
  8550.         return $this->render('ApplicationBundle:pages/human_resource/views:view_attendance_amendment.html.twig',
  8551.             array(
  8552.                 'page_title' => 'Attendance Amendment',
  8553.                 'data' => $dt,
  8554.                 'approval_data' => System::checkIfApprovalExists($emarray_flip(GeneralConstant::$Entity_list)['AttendanceAmendment'],
  8555.                     $id$request->getSession()->get(UserConstants::USER_LOGIN_ID)),
  8556.                 'document_log' => System::getDocumentLog($this->getDoctrine()->getManager(),
  8557.                     array_flip(GeneralConstant::$Entity_list)['AttendanceAmendment'],
  8558.                     $id,
  8559.                     $dt['created_by'],
  8560.                     $dt['edited_by'])
  8561.             )
  8562.         );
  8563.     }
  8564.     public function createRoomAction(Request $request)
  8565.     {
  8566.         $em $this->getDoctrine()->getManager();
  8567.         $companyId $this->getLoggedUserCompanyId($request);
  8568.         if ($request->isMethod('POST')) {
  8569.             $loginId $request->getSession()->get(UserConstants::USER_LOGIN_ID);
  8570.             $room = new Room;
  8571.             $room->setRoomNo($request->request->get('RoomNo'));
  8572.             //$room->setRoomName($request->request->get('RoomName'));
  8573.             $room->setBuilding($request->request->get('buildingName'));
  8574.             $room->setFloor($request->request->get('floor'));
  8575.             $room->setCapacity($request->request->get('capacity'));
  8576.             $room->setCreatedLoginId($request->getSession()->get(UserConstants::USER_LOGIN_ID));
  8577.             $em->persist($room);
  8578.             $em->flush();
  8579.         }
  8580.         return $this->render('ApplicationBundle:pages/human_resource/input_forms:create_room.html.twig', array(
  8581.             'page_title' => 'Add Room',
  8582.         ));
  8583.     }
  8584.     public function ExpenseTypeAction()
  8585.     {
  8586.         $expenseType HumanResourceConstant::$employeeExpenseAllowanceTypes;
  8587.         $expenseTypeArray = [];
  8588.         foreach ($expenseType as $k => $dt) {
  8589.             $dt['id'] = $k;
  8590.             $newSegs = [];
  8591.             foreach ($dt['segregations'] as $l => $s) {
  8592.                 $newOptions = [];
  8593.                 foreach ($s['options'] as $l2 => $s2) {
  8594.                     $s3 = array(
  8595.                         'value' => $l2,
  8596.                         'text' => $s2,
  8597.                     );
  8598.                     $newOptions[] = $s3;
  8599.                 }
  8600.                 $s['options'] = $newOptions;
  8601.                 if (is_string($s['defaultVal'])) $s['defaultVal'] = [$s['defaultVal']];
  8602.                 $newSegs[] = $s;
  8603.             }
  8604.             $dt['segregations'] = $newSegs;
  8605.             $expenseTypeArray[] = $dt;
  8606.         }
  8607.         return new JsonResponse(
  8608.             array(
  8609.                 'success' => true,
  8610.                 'expenseType' => $expenseType,
  8611.                 'expenseTypeArray' => $expenseTypeArray,
  8612.             )
  8613.         );
  8614.     }
  8615.     public function DemoDataTableAction()
  8616.     {
  8617.         return $this->render('ApplicationBundle:pages/human_resource/list:demo_data_table.html.twig', array(
  8618.             'page_title' => 'Add Room',
  8619.         ));
  8620.     }
  8621.     public function workEnrtyAction(Request $request)
  8622.     {
  8623. //        $em = $this->getDoctrine()->getManager();
  8624. //        $companyId = $this->getLoggedUserCompanyId($request);
  8625. //        if ($request->isMethod('POST')) {
  8626. //            $loginId = $request->getSession()->get(UserConstants::USER_LOGIN_ID);
  8627. //            $labour = new Labour();
  8628. //            $labour->setLabourName($request->request->get('labourName'));
  8629. //            $labour->setNidNumber($request->request->get('nidNumber'));
  8630. //            $em->persist($labour);
  8631. //            $em->flush();
  8632. //            $this->addFlash(
  8633. //                'success',
  8634. //                'Labour Added'
  8635. //            );
  8636. //        }
  8637.         return $this->render('ApplicationBundle:pages/human_resource/input_forms:work_entry.html.twig', array(
  8638.             'page_title' => 'Work Entry',
  8639.         ));
  8640.     }
  8641.     public function ViewContractLetterAction(Request $request$id)
  8642.     {
  8643.         $em $this->getDoctrine()->getManager();
  8644.         $employeeDetail $em->getRepository('ApplicationBundle:EmployeeDetails')->find($id);
  8645. //        $employeeData = [];
  8646. //        foreach ($employeeDetails as $employeeDetail) {
  8647. //            $data = array(
  8648. //                'firstName' => $employeeDetail->getNid(),
  8649. //
  8650. //
  8651. //
  8652. //            );
  8653. //
  8654. //
  8655. //            $employeeData[] = $data;
  8656. //        }
  8657.         return $this->render('ApplicationBundle:pages/human_resource/views:viewContractLetter.html.twig', array(
  8658.             'page_title' => 'Contract Letter',
  8659.             'employeeDetail' => $employeeDetail
  8660.         ));
  8661.     }
  8662.     public function getAttendanceReportForEmployeeAction(Request $request)
  8663.     {
  8664.         $em $this->getDoctrine()->getManager();
  8665.         $session $request->getSession();
  8666.         $fromDateRow = (new \DateTime($request->get('start_date''')));
  8667. //        $fromDate = $fromDateRow->format("M d, Y");
  8668.         $toDateRow = (new \DateTime($request->get('end_date'$fromDateRow) . ' 23:59:59'));
  8669. //        $toDate = $toDateRow->format("M d, Y");
  8670. //        $startDate = "2025-02-13";
  8671. //        $endDate = "2025-02-16";
  8672.         $userId $session->get(UserConstants::USER_ID);
  8673.         $attendanceDetails $em->getRepository('ApplicationBundle:EmployeeAttendance')->createQueryBuilder('A')
  8674. //            ->select('A.createdAt','A.data')
  8675.             ->where('A.sysId = :userId')
  8676.             ->andWhere('A.createdAt >=  :startDate')
  8677.             ->andWhere('A.createdAt <=  :endDate')
  8678.             ->setParameter('userId'$userId)
  8679.             ->setParameter('startDate'$fromDateRow)
  8680.             ->setParameter('endDate'$toDateRow)
  8681.             ->getQuery()
  8682.             ->getResult();
  8683.         $attendance = [];
  8684.         $dt = [];
  8685.         foreach ($attendanceDetails as $data) {
  8686.             $in_out_data json_decode($data->getData(), true);
  8687.             $new_in_data = [];
  8688.             $elapsed_data = [];
  8689.             $new_out_data = [];
  8690.             if ($in_out_data == null$in_out_data = [];
  8691.             if (isset($in_out_data['in'])) {
  8692.                 foreach ($in_out_data['in'] as $ind => $g) {
  8693.                     if (!isset($elapsed_data[$ind])) {
  8694.                         $elapsed_data[$ind] = 0;
  8695.                     }
  8696.                     $the_time = new \DateTime($data->getDate()->format('Y-m-d ') . $g ' +0000');
  8697.                     $new_in_data[] = $the_time->format('U');
  8698.                 }
  8699.             }
  8700.             if (isset($in_out_data['out'])) {
  8701.                 foreach ($in_out_data['out'] as $ind => $g) {
  8702.                     if (!isset($elapsed_data[$ind])) {
  8703.                         $elapsed_data[$ind] = 0;
  8704.                     }
  8705.                     $the_time = new \DateTime($data->getDate()->format('Y-m-d ') . $g ' +0000');
  8706.                     $new_out_data[] = $the_time->format('U');
  8707.                     if (isset($new_in_data[$ind])) {
  8708.                         $elapsed_data[$ind] = $new_out_data[$ind] - $new_in_data[$ind];
  8709.                     }
  8710.                 }
  8711.             }
  8712.             $list = array(
  8713.                 'date' => $data->getDate()->format('F d Y'),
  8714.                 'attendanceData' => [
  8715.                     'in' => $new_in_data,
  8716.                     'out' => $new_out_data,
  8717.                     'elapsedSec' => $elapsed_data,
  8718.                 ]
  8719.             );
  8720.             $dt[] = $list;
  8721.         }
  8722.         $count count($attendance);
  8723. //        for ($i=0;$i < $count; $i++){
  8724. //            $dt[] = $attendance[$i]['date'];
  8725. //            $dt[] = ($attendance[$i]['attendanceData']);
  8726. //        }
  8727. ////        $decodeData = json_decode($dt, true);
  8728. //
  8729. //        $work_hours = [];
  8730. //
  8731. //        foreach ($dt as $index => $entry) {
  8732. //            $in_times = $entry['in'];
  8733. //            $out_times = $entry['out'];
  8734. //
  8735. //
  8736. //            $count = min(count($in_times), count($out_times));
  8737. //
  8738. //            for ($i = 0; $i < $count; $i++) {
  8739. //                $time_in = new DateTime($in_times[$i]);
  8740. //                $time_out = new DateTime($out_times[$i]);
  8741. //
  8742. //
  8743. //                $interval = $time_in->diff($time_out);
  8744. //                $total_hours = $interval->format('%h');
  8745. //                $total_minutes = $interval->format('%i');
  8746. //
  8747. //
  8748. //                $work_hours[] = [
  8749. ////                    "set" => $index + 1,
  8750. //                    "in" => $in_times[$i],
  8751. //                    "out" => $out_times[$i],
  8752. //                    "worked" => "$total_hours hours, $total_minutes minutes"
  8753. //                ];
  8754. //            }
  8755. //        }
  8756. //
  8757. ////        foreach ($work_hours as $work) {
  8758. ////           return new  JsonResponse(
  8759. ////               array(
  8760. ////                   'in'=>$work['in'],
  8761. ////                   'out' => $work['out'],
  8762. ////                   'hour' => $work['worked']
  8763. ////               )
  8764. ////           ) ;
  8765. //////            echo "Set {$work['set']} - IN: {$work['in']} - OUT: {$work['out']} => Worked: {$work['worked']}\n";
  8766. ////        }
  8767.         return new JsonResponse($dt);
  8768.     }
  8769.     public function getTotalWorkHourAction(Request $request)
  8770.     {
  8771.         $em $this->getDoctrine()->getManager();
  8772.         $currentDate = new \DateTime(date('y-m-d'));
  8773.         $session $request->getSession();
  8774.         $token $session->get(UserConstants::USER_TOKEN);
  8775.         $employeeId $session->get(UserConstants::USER_EMPLOYEE_ID);
  8776.         $planningItemId $session->get(UserConstants::USER_CURRENT_PLANNING_ITEM_ID);
  8777.         $attendanceData $em->getRepository('ApplicationBundle:EmployeeAttendance');
  8778.         $currentStatus HumanResource::getCurrentStatusFromDb($attendanceData$employeeId$currentDate);
  8779.         $providedToken $request->headers->get('auth-token');
  8780.         if (empty($providedToken) || $providedToken !== $token) {
  8781.             return new JsonResponse([
  8782.                 'status' => 'error',
  8783.                 'message' => 'Token not match or missing',
  8784.             ], 401);
  8785.         }
  8786.         $planningItemDetails $em->getRepository(PlanningItem::class)->createQueryBuilder('p')
  8787.             ->select('p.itemAlias')
  8788.             ->where('p.id = :planningItemId')
  8789.             ->setParameter('planningItemId'$planningItemId)
  8790.             ->getQuery()
  8791.             ->getResult();
  8792.         // Check if "data" key exists and contains "in" times
  8793.         if (empty($currentStatus["data"]["in"])) {
  8794.             return new JsonResponse([
  8795. //                'message' => 'No attendance data available',
  8796.                 'currentStatus' => $currentStatus,
  8797.                 'totalWorkingTime' => '00:00:00'
  8798.             ]);
  8799.         }
  8800.         $totalSeconds 0;
  8801.         for ($i 0$i count($currentStatus["data"]["in"]); $i++) {
  8802.             $inTime $currentStatus["data"]["in"][$i];
  8803.             // Check if "out" time exists for this "in" time
  8804.             if (!isset($currentStatus["data"]["out"][$i])) {
  8805.                 continue; // Skip this entry if there is no out time
  8806.             }
  8807.             $outTime $currentStatus["data"]["out"][$i];
  8808.             // Calculate the difference
  8809.             $totalSeconds += ($outTime $inTime);
  8810.         }
  8811.         // If no valid time pairs were found, return 00:00:00
  8812. //        if ($totalSeconds == 0) {
  8813. //            return new JsonResponse([
  8814. //                'message' => 'No complete in-out records found',
  8815. //                'totalWorkingTime' => '00:00:00'
  8816. //            ]);
  8817. //        }
  8818.         // Convert total seconds to hours, minutes, and seconds
  8819.         $hours floor($totalSeconds 3600);
  8820.         $minutes floor(($totalSeconds 3600) / 60);
  8821.         $seconds $totalSeconds 60;
  8822.         $totalWorkingTime sprintf("%02d:%02d:%02d"$hours$minutes$seconds);
  8823.         return new JsonResponse([
  8824.             'taskName' => isset($planningItemDetails[0]) ? $planningItemDetails[0]['itemAlias'] : '',
  8825.             'currentStatus' => $currentStatus,
  8826.             'totalWorkingTime' => $totalWorkingTime,
  8827.         ]);
  8828.     }
  8829. //    public function getEmployeeDataAction(Request $request)
  8830. //    {
  8831. //        $em = $this->getDoctrine()->getManager();
  8832. //        $session = $request->getSession();
  8833. //        $employeeId = $session->get(UserConstants::USER_EMPLOYEE_ID);
  8834. //
  8835. //
  8836. //        $employeeDetails = $em->getRepository('ApplicationBundle:EmployeeDetails')->createQueryBuilder('E')
  8837. //            ->select('E.firstname', 'E.lastname', 'E.nid', 'E.tin','E.image', 'P.positionName')
  8838. //            ->addSelect('A.current_balance')
  8839. //            ->leftJoin('ApplicationBundle:SysDepartmentPosition', 'P', 'WITH', 'E.desg = P.positionId')
  8840. //            ->leftJoin('ApplicationBundle:Employee', 'EMP', 'WITH', 'EMP.employeeId = E.id')
  8841. //            ->leftJoin('ApplicationBundle:AccAccountsHead', 'A', 'WITH', 'EMP.accountsHeadId = A.accountsHeadId')
  8842. //            ->where('E.id = :employeeId')
  8843. //            ->setParameter('employeeId', $employeeId)
  8844. //            ->getQuery()
  8845. //            ->getResult();
  8846. //
  8847. //        return new JsonResponse($employeeDetails[0]);
  8848. //    }
  8849. //    public function getEmployeeDataAction(Request $request)
  8850. //    {
  8851. //        $em = $this->getDoctrine()->getManager();
  8852. //        $session = $request->getSession();
  8853. //        $employeeId = $session->get(UserConstants::USER_EMPLOYEE_ID);
  8854. //        $image = $session->get(UserConstants::USER_IMAGE);
  8855. //        $absoluteUrl = $this->generateUrl('dashboard', [], UrlGenerator::ABSOLUTE_URL);
  8856. //
  8857. //        $employeeDetails = $em->getRepository('ApplicationBundle:EmployeeDetails')->createQueryBuilder('E')
  8858. //            ->select('E.firstname', 'E.lastname', 'E.nid', 'E.tin', 'E.image', 'P.positionName')
  8859. //            ->addSelect('A.current_balance')
  8860. //            ->leftJoin('ApplicationBundle:SysDepartmentPosition', 'P', 'WITH', 'E.desg = P.positionId')
  8861. //            ->leftJoin('ApplicationBundle:Employee', 'EMP', 'WITH', 'EMP.employeeId = E.id')
  8862. //            ->leftJoin('ApplicationBundle:AccAccountsHead', 'A', 'WITH', 'EMP.accountsHeadId = A.accountsHeadId')
  8863. //            ->where('E.id = :employeeId')
  8864. //            ->setParameter('employeeId', $employeeId)
  8865. //            ->getQuery()
  8866. //            ->getResult();
  8867. //
  8868. //        // If image is null or empty, assign empty string
  8869. //        if (empty($employeeDetails['image'])) {
  8870. //            $employeeDetails['image'] =  $image;
  8871. //        }
  8872. //
  8873. //        return new JsonResponse($employeeDetails);
  8874. //    }
  8875.     public function getEmployeeDataAction(Request $request)
  8876.     {
  8877.         $em $this->getDoctrine()->getManager();
  8878.         $session $request->getSession();
  8879.         $employeeId $session->get(UserConstants::USER_EMPLOYEE_ID);
  8880.         $image $session->get(UserConstants::USER_IMAGE);
  8881.         $absoluteUrl $this->generateUrl('dashboard', [], UrlGenerator::ABSOLUTE_URL);
  8882.         $userImage $session->get(UserConstants::USER_IMAGE);
  8883.         $employeeDetails $em->getRepository('ApplicationBundle:EmployeeDetails')->createQueryBuilder('E')
  8884.             ->select('E.firstname''E.lastname''E.nid''E.tin''E.image''P.positionName')
  8885.             ->addSelect('A.current_balance')
  8886.             ->leftJoin('ApplicationBundle:SysDepartmentPosition''P''WITH''E.desg = P.positionId')
  8887.             ->leftJoin('ApplicationBundle:Employee''EMP''WITH''EMP.employeeId = E.id')
  8888.             ->leftJoin('ApplicationBundle:AccAccountsHead''A''WITH''EMP.accountsHeadId = A.accountsHeadId')
  8889.             ->where('E.id = :employeeId')
  8890.             ->setParameter('employeeId'$employeeId)
  8891.             ->getQuery()
  8892.             ->getOneOrNullResult(\Doctrine\ORM\Query::HYDRATE_ARRAY); // Only one employee expected
  8893.         if (!$employeeDetails) {
  8894.             return new JsonResponse(['error' => 'Employee not found'], 404);
  8895.         }
  8896.         // If image is missing, fallback to session image
  8897.         if (empty($employeeDetails['image'])) {
  8898.             $employeeDetails['image'] = $image;
  8899.         }
  8900.         // If image is still available, prefix it with absolute URL
  8901.         if (!empty($employeeDetails['image'])) {
  8902.             $employeeDetails['image_url'] = $absoluteUrl '' $userImage;
  8903.         } else {
  8904.             $employeeDetails['image_url'] = ''// no image
  8905.         }
  8906.         return new JsonResponse($employeeDetails);
  8907.     }
  8908.     public function updateEmployeeDataForAppAction(Request $request)
  8909.     {
  8910.         $em $this->getDoctrine()->getManager();
  8911.         $session $request->getSession();
  8912.         $employeeId $session->get(UserConstants::USER_EMPLOYEE_ID);
  8913.         $employeeDetails $em->getRepository('ApplicationBundle:EmployeeDetails')->find($employeeId);
  8914.         if ($request->isMethod('POST')) {
  8915.             $firstname $request->request->get('firstname');
  8916.             $lastname $request->request->get('lastname');
  8917.             $nid $request->request->get('nid');
  8918.             $tin $request->request->get('tin');
  8919.             if ($firstname !== null) {
  8920.                 $employeeDetails->setFirstName($firstname);
  8921.             }
  8922.             if ($lastname !== null) {
  8923.                 $employeeDetails->setLastName($lastname);
  8924.             }
  8925.             if ($nid !== null) {
  8926.                 $employeeDetails->setNid($nid);
  8927.             }
  8928.             if ($tin !== null) {
  8929.                 $employeeDetails->setTin($tin);
  8930.             }
  8931.             $em->flush();
  8932.             return new JsonResponse(['success' => true]);
  8933.         }
  8934.         return new JsonResponse(['success' => false'message' => 'Invalid request method']);
  8935.     }
  8936. //    public function updateEmployeeDataForAppAction(Request $request){
  8937. //        $em = $this->getDoctrine()->getManager();
  8938. //        $session = $request->getSession();
  8939. //        $employeeId = $session->get(UserConstants::USER_EMPLOYEE_ID);
  8940. //        $employeeDetails = $em->getRepository('ApplicationBundle:EmployeeDetails')->find($employeeId);
  8941. //
  8942. //        if ($request->isMethod('POST')) {
  8943. //            $employeeDetails->setFirstName(($request->request->get('firstname',$employeeDetails->getFirstName())));
  8944. //            $employeeDetails->setLastName($request->request->get('lastname',$employeeDetails->getLastName()));
  8945. //            $employeeDetails->setNid($request->request->get('nid'),$employeeDetails->getNid());
  8946. //            $employeeDetails->setTin($request->request->get('tin'),$employeeDetails->getTin());
  8947. //
  8948. //            $em->flush(); //
  8949. //
  8950. //            return new JsonResponse(['success' => true]);
  8951. //        }
  8952. //
  8953. //
  8954. //    }
  8955.     public function leaveApplicationListForAppAction(Request $request)
  8956.     {
  8957.         $em $this->getDoctrine()->getManager();
  8958.         $session $request->getSession();
  8959.         $employeeId $session->get(UserConstants::USER_EMPLOYEE_ID);
  8960.         $leaveType HumanResourceConstant::$LeaveType;
  8961.         $approvalStatus GeneralConstant::$approvalAction;
  8962.         $leaveCategory HumanResourceConstant::$leavCategory;
  8963.         // Get page and limit from request (default: page=1, limit=10)
  8964.         $page max((int)$request->query->get('page'1), 1);
  8965.         $limit max((int)$request->query->get('limit'10), 1);
  8966.         $offset = ($page 1) * $limit;
  8967.         // Get total count
  8968.         $total $em->getRepository('ApplicationBundle:EmployeeLeaveApplication')
  8969.             ->createQueryBuilder('L')
  8970.             ->select('COUNT(L.employeeLeaveApplicationId)')
  8971.             ->where('L.employeeId = :employeeId')
  8972.             ->setParameter('employeeId'$employeeId)
  8973.             ->getQuery()
  8974.             ->getSingleScalarResult();
  8975.         // Get paginated results
  8976.         $leaveRecords $em->getRepository('ApplicationBundle:EmployeeLeaveApplication')
  8977.             ->createQueryBuilder('L')
  8978.             ->select(
  8979.                 'L.documentHash',
  8980.                 'L.employeeLeaveApplicationId',
  8981.                 'L.leaveStartDate',
  8982.                 'L.leaveEndDate',
  8983.                 'L.leaveTypeId',
  8984.                 'L.leaveCategory',
  8985.                 'L.approved',
  8986.                 'L.createdAt',
  8987.                 'L.alternateDate',
  8988.                 'L.leaveComment',
  8989.                 'L.createdAt',
  8990.                 'L.approved_by'
  8991.             )
  8992.             ->where('L.employeeId = :employeeId')
  8993.             ->setParameter('employeeId'$employeeId)
  8994.             ->setFirstResult($offset)
  8995.             ->setMaxResults($limit)
  8996.             ->orderBy('L.employeeLeaveApplicationId''DESC')   //
  8997.             ->getQuery()
  8998.             ->getResult();
  8999.         // Count total approved (approved = 1)
  9000.         $totalApproved $em->getRepository('ApplicationBundle:EmployeeLeaveApplication')
  9001.             ->createQueryBuilder('L')
  9002.             ->select('COUNT(L.employeeLeaveApplicationId)')
  9003.             ->where('L.employeeId = :employeeId')
  9004.             ->andWhere('L.approved = 1')
  9005.             ->setParameter('employeeId'$employeeId)
  9006.             ->getQuery()
  9007.             ->getSingleScalarResult();
  9008. // Count total pending (approved = 3)
  9009.         $totalPending $em->getRepository('ApplicationBundle:EmployeeLeaveApplication')
  9010.             ->createQueryBuilder('L')
  9011.             ->select('COUNT(L.employeeLeaveApplicationId)')
  9012.             ->where('L.employeeId = :employeeId')
  9013.             ->andWhere('L.approved = 3')
  9014.             ->setParameter('employeeId'$employeeId)
  9015.             ->getQuery()
  9016.             ->getSingleScalarResult();
  9017. // Count total cancelled (approved = 0)
  9018.         $totalCancelled $em->getRepository('ApplicationBundle:EmployeeLeaveApplication')
  9019.             ->createQueryBuilder('L')
  9020.             ->select('COUNT(L.employeeLeaveApplicationId)')
  9021.             ->where('L.employeeId = :employeeId')
  9022.             ->andWhere('L.approved = 0')
  9023.             ->setParameter('employeeId'$employeeId)
  9024.             ->getQuery()
  9025.             ->getSingleScalarResult();
  9026.         // Format the results
  9027.         $formattedData = [];
  9028.         foreach ($leaveRecords as $leave) {
  9029.             $formattedData[] = [
  9030.                 'documentHash' => $leave['documentHash'],
  9031.                 'employeeLeaveApplicationId' => $leave['employeeLeaveApplicationId'],
  9032.                 'leaveStartDate' => $leave['leaveStartDate'] ? $leave['leaveStartDate']->getTimestamp() : 0,
  9033.                 'leaveEndDate' => $leave['leaveEndDate'] ? $leave['leaveEndDate']->getTimestamp() : 0,
  9034.                 'leaveType' => $leaveType[$leave['leaveTypeId']] ?? 'Unknown',
  9035.                 'leaveCategory' => $leaveCategory[$leave['leaveCategory']] ?? 'Unknown',
  9036.                 'approved' => $approvalStatus[$leave['approved']] ?? 'Unknown',
  9037.                 'createdAt' => $leave['createdAt'] ? $leave['createdAt']->getTimestamp() : 0,
  9038.                 'alternateDate' => $leave['alternateDate'] ? $leave['alternateDate']->getTimestamp() : 0,
  9039.                 'note' => $leave['leaveComment'] ? $leave['leaveComment'] : '',
  9040.                 'appliedOn' => $leave['createdAt'] ? $leave['createdAt']->getTimestamp() : 0,
  9041.                 'approvedBy' => $leave['approved_by'] ? $leave['approved_by'] : 'automatically approved',
  9042.             ];
  9043.         }
  9044.         $employee $em->getRepository('ApplicationBundle:EmployeeDetails')
  9045.             ->find($employeeId);
  9046.         $totalLeaveBalance 0;
  9047.         for ($i 1$i <= 10$i++) {
  9048.             $getter "getLeave{$i}Tkn";
  9049.             $totalLeaveBalance +=$employee->$getter();
  9050.         }
  9051.         // Final response with pagination meta
  9052.         return new JsonResponse([
  9053.             'success' => true,
  9054.             'message' => 'Leave application list fetched successfully',
  9055.             'totalLeaveBalance' => (int) ($totalLeaveBalance ?? 0),
  9056.             'totalApproved' => (int) ($totalApproved ?? 0),
  9057.             'totalPending' => (int) ($totalPending ?? 0),
  9058.             'totalCancelled' => (int) ($totalCancelled ?? 0),
  9059.             'data' => $formattedData,
  9060.             'CurrentPage' => $page,
  9061.             'limit' => $limit,
  9062.             'total' =>$total,
  9063.         ]);
  9064.     }
  9065.     public function PublicProfilePageAction(Request $request)
  9066.     {
  9067.         return new JsonResponse(['success' => true]);
  9068.     }
  9069.     public function leaveSettingsAction(Request $request)
  9070.     {
  9071.         $em $this->getDoctrine()->getManager();
  9072.         if ($request->isMethod('POST')) {
  9073.             $ids $request->request->get('id', []);
  9074.             $leaveTitles $request->request->get('leaveTitle', []);
  9075.             $carryForwardTypes $request->request->get('carryForwardType', []);
  9076.             $carryForwardQtys $request->request->get('number', []);
  9077.             $totalLeaves $request->request->get('totalLeave', []);
  9078.             $resetFreqTypes $request->request->get('resetFrequencyType', []);
  9079.             $resetFreqQtys $request->request->get('resetFrequencyQty', []);
  9080.             $additionConditions $request->request->get('additionCondition', []);
  9081.             $additionDurations $request->request->get('additionConditionDuration', []);
  9082.             for ($i 0$i count($leaveTitles); $i++) {
  9083.                 if (
  9084.                     isset(
  9085.                         $carryForwardTypes[$i],
  9086.                         $carryForwardQtys[$i],
  9087.                         $totalLeaves[$i],
  9088.                         $resetFreqTypes[$i],
  9089.                         $resetFreqQtys[$i],
  9090.                         $additionConditions[$i],
  9091.                         $additionDurations[$i]
  9092.                     )
  9093.                 ) {
  9094.                     $id $ids[$i] ?? null;
  9095.                     $leaveSetting null;
  9096.                     if ($id) {
  9097.                         $leaveSetting $em->getRepository('ApplicationBundle:LeaveSettings')->find($id);
  9098.                     }
  9099.                     if (!$leaveSetting) {
  9100.                         $leaveSetting = new LeaveSettings();
  9101.                     }
  9102.                     $leaveSetting->setLeaveTitle($leaveTitles[$i]);
  9103.                     $leaveSetting->setCarryForwardType((int)$carryForwardTypes[$i]);
  9104.                     $leaveSetting->setCarryForwardQty((int)$carryForwardQtys[$i]);
  9105.                     $leaveSetting->setTotalLeave((int)$totalLeaves[$i]);
  9106.                     $leaveSetting->setResetFrequencyType((int)$resetFreqTypes[$i]);
  9107.                     $leaveSetting->setResetFrequencyQty((int)$resetFreqQtys[$i]);
  9108.                     $leaveSetting->setAdditionCondition((int)$additionConditions[$i]);
  9109.                     $leaveSetting->setAdditionConditionDuration((int)$additionDurations[$i]);
  9110.                     $em->persist($leaveSetting);
  9111.                 }
  9112.             }
  9113.             $em->flush();
  9114.             $this->addFlash('success''Leave settings saved successfully!');
  9115.             return $this->redirectToRoute('leave_settings_list');
  9116.         }
  9117.         $defaultLeaveType HumanResourceConstant::$defaultLeaveType;
  9118.         $savedLeaveSettings $em->getRepository('ApplicationBundle:LeaveSettings')->findAll();
  9119.         $useDefaultLeave count($savedLeaveSettings) === 0;
  9120.         $leaveSettings array_map(function ($setting) {
  9121.             return [
  9122.                 'id' => $setting->getId(),
  9123.                 'leaveTitle' => $setting->getLeaveTitle(),
  9124.                 'carryForwardType' => $setting->getCarryForwardType(),
  9125.                 'carryForwardQty' => $setting->getCarryForwardQty(),
  9126.                 'totalLeave' => $setting->getTotalLeave(),
  9127.                 'resetFrequencyType' => $setting->getResetFrequencyType(),
  9128.                 'resetFrequencyQty' => $setting->getResetFrequencyQty(),
  9129.                 'additionCondition' => $setting->getAdditionCondition(),
  9130.                 'additionConditionDuration' => $setting->getAdditionConditionDuration(),
  9131.             ];
  9132.         }, $savedLeaveSettings);
  9133.         return $this->render('ApplicationBundle:pages/human_resource/input_forms:leave_settings.html.twig', [
  9134.             'page_title' => 'Leave Settings',
  9135.             'defaultLeaveType' => $defaultLeaveType,
  9136.             'leaveSettings' => $leaveSettings,
  9137.             'useDefaultLeave' => $useDefaultLeave,
  9138.         ]);
  9139.     }
  9140.     public function leavePolicyListAction()
  9141.     {
  9142.         return $this->render("ApplicationBundle:pages/human_resource/list:leaveApplicationSettingsList.html.twig", array(
  9143.             'page_title' => 'Leave PolicyList',
  9144.         ));
  9145.     }
  9146. }