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.         $invoiceId $request->request->get('invoiceId'$request->query->get('invoiceId'0));
  76.         if ($encData != "") {
  77.             $encryptedData json_decode($this->get('url_encryptor')->decrypt($encData), true);
  78.             if ($encryptedData == null$encryptedData = [];
  79.             if (isset($encryptedData['invoiceId'])) $invoiceId $encryptedData['invoiceId'];
  80.         }
  81.         $session $request->getSession();
  82.         $currencyForGateway 'eur';
  83.         $gatewayInvoice null;
  84.         if ($invoiceId != 0)
  85.             $gatewayInvoice $em->getRepository(EntityInvoice::class)->find($invoiceId);
  86.         $paymentGateway $request->request->get('paymentGateway''stripe'); //aamarpay,bkash
  87.         $paymentType $request->request->get('paymentType''credit');
  88.         $retailerId $request->request->get('retailerId'0);
  89.         if ($request->query->has('currency'))
  90.             $currencyForGateway $request->query->get('currency');
  91.         else
  92.             $currencyForGateway $request->request->get('currency''eur');
  93. //        {
  94. //            if ($request->query->has('meetingSessionId'))
  95. //                $id = $request->query->get('meetingSessionId');
  96. //        }
  97.         $currentUserBalance 0;
  98.         $currentUserCoinBalance 0;
  99.         $gatewayAmount 0;
  100.         $redeemedAmount 0;
  101.         $redeemedSessionCount 0;
  102.         $toConsumeSessionCount 0;
  103.         $invoiceSessionCount 0;
  104.         $payableAmount 0;
  105.         $promoClaimedAmount 0;
  106.         $promoCodeId 0;
  107.         $promoClaimedSession 0;
  108.         $bookingExpireTime null;
  109.         $bookingExpireTs 0;
  110.         $imageBySessionCount = [
  111.             => "https://www.buddybee.eu/buddybee_assets/ADULT-BEE.png",
  112.             100 => "https://www.buddybee.eu/buddybee_assets/ADULT-BEE.png",
  113.             200 => "https://www.buddybee.eu/buddybee_assets/ADULT-BEE.png",
  114.             300 => "https://www.buddybee.eu/buddybee_assets/ADULT-BEE.png",
  115.             400 => "https://www.buddybee.eu/buddybee_assets/ADULT-BEE.png",
  116.             500 => "https://www.buddybee.eu/buddybee_assets/ADULT-BEE.png",
  117.             600 => "https://www.buddybee.eu/buddybee_assets/ADULT-BEE.png",
  118.             700 => "https://www.buddybee.eu/buddybee_assets/ADULT-BEE.png",
  119.             800 => "https://www.buddybee.eu/buddybee_assets/ADULT-BEE.png",
  120.             900 => "https://www.buddybee.eu/buddybee_assets/ADULT-BEE.png",
  121.             1000 => "https://www.buddybee.eu/buddybee_assets/ADULT-BEE.png",
  122.             1100 => "https://www.buddybee.eu/buddybee_assets/ADULT-BEE.png",
  123.             1200 => "https://www.buddybee.eu/buddybee_assets/ADULT-BEE.png",
  124.             1300 => "https://www.buddybee.eu/buddybee_assets/ADULT-BEE.png",
  125.             1400 => "https://www.buddybee.eu/buddybee_assets/ADULT-BEE.png",
  126.             1500 => "https://www.buddybee.eu/buddybee_assets/ADULT-BEE.png",
  127.             1600 => "https://www.buddybee.eu/buddybee_assets/ADULT-BEE.png",
  128.             1700 => "https://www.buddybee.eu/buddybee_assets/ADULT-BEE.png",
  129.             1800 => "https://www.buddybee.eu/buddybee_assets/ADULT-BEE.png",
  130.             1900 => "https://www.buddybee.eu/buddybee_assets/ADULT-BEE.png",
  131.             2000 => "https://www.buddybee.eu/buddybee_assets/ADULT-BEE.png",
  132.             2100 => "https://www.buddybee.eu/buddybee_assets/ADULT-BEE.png",
  133.             2200 => "https://www.buddybee.eu/buddybee_assets/ADULT-BEE.png",
  134.             2300 => "https://www.buddybee.eu/buddybee_assets/ADULT-BEE.png",
  135.             2400 => "https://www.buddybee.eu/buddybee_assets/ADULT-BEE.png",
  136.             2500 => "https://www.buddybee.eu/buddybee_assets/ADULT-BEE.png",
  137.             2600 => "https://www.buddybee.eu/buddybee_assets/ADULT-BEE.png",
  138.             2700 => "https://www.buddybee.eu/buddybee_assets/ADULT-BEE.png",
  139.             2800 => "https://www.buddybee.eu/buddybee_assets/ADULT-BEE.png",
  140.             2900 => "https://www.buddybee.eu/buddybee_assets/ADULT-BEE.png",
  141.             3000 => "https://www.buddybee.eu/buddybee_assets/ADULT-BEE.png",
  142.             3100 => "https://www.buddybee.eu/buddybee_assets/ADULT-BEE.png",
  143.             3200 => "https://www.buddybee.eu/buddybee_assets/ADULT-BEE.png",
  144.             3300 => "https://www.buddybee.eu/buddybee_assets/ADULT-BEE.png",
  145.             3400 => "https://www.buddybee.eu/buddybee_assets/ADULT-BEE.png",
  146.             3500 => "https://www.buddybee.eu/buddybee_assets/ADULT-BEE.png",
  147.             3600 => "https://www.buddybee.eu/buddybee_assets/ADULT-BEE.png",
  148.             3700 => "https://www.buddybee.eu/buddybee_assets/ADULT-BEE.png",
  149.         ];
  150.         if (!$gatewayInvoice) {
  151.             if ($request->isMethod('POST')) {
  152.                 $totalAmount 0;
  153.                 $totalSessionCount 0;
  154.                 $consumedAmount 0;
  155.                 $consumedSessionCount 0;
  156.                 $bookedById 0;
  157.                 $bookingRefererId 0;
  158.                 if ($session->get(UserConstants::USER_ID)) {
  159.                     $bookedById $session->get(UserConstants::USER_ID);
  160.                     $bookingRefererId 0;
  161. //                    $toConsumeSessionCount = 1 * $request->request->get('meetingSessionConsumeCount', 0);
  162.                     $invoiceSessionCount * ($request->request->get('sessionCount'0) == '' $request->request->get('sessionCount'0));
  163.                     //1st do the necessary
  164.                     $extMeeting null;
  165.                     $meetingSessionId 0;
  166.                     if ($request->request->has('purchasePackage')) {
  167.                         //1. check if any bee card if yes try to claim it , modify current balance then
  168.                         $beeCodeSerial $request->request->get('beeCodeSerial''');
  169.                         $promoCode $request->request->get('promoCode''');
  170.                         $beeCodePin $request->request->get('beeCodePin''');
  171.                         $userId $request->request->get('userId'$session->get(UserConstants::USER_ID));
  172.                         $studentDetails null;
  173.                         $studentDetails $em_goc->getRepository(EntityApplicantDetails::class)->find($userId);
  174.                         if ($studentDetails) {
  175.                             $currentUserBalance $studentDetails->getAccountBalance();
  176.                         }
  177.                         if ($beeCodeSerial != '' && $beeCodePin != '') {
  178.                             $claimData MiscActions::ClaimBeeCode($em,
  179.                                 [
  180.                                     'claimFlag' => 1,
  181.                                     'pin' => $beeCodePin,
  182.                                     'serial' => $beeCodeSerial,
  183.                                     'userId' => $userId,
  184.                                 ]);
  185.                             if ($userId == $session->get(UserConstants::USER_ID)) {
  186.                                 MiscActions::RefreshBuddybeeBalanceOnSession($em$request->getSession());
  187.                                 $claimData['newCoinBalance'] = $session->get('BUDDYBEE_COIN_BALANCE');
  188.                                 $claimData['newBalance'] = $session->get('BUDDYBEE_BALANCE');
  189.                             }
  190.                             $redeemedAmount $claimData['data']['claimedAmount'];
  191.                             $redeemedSessionCount $claimData['data']['claimedCoin'];
  192.                         } else
  193.                             if ($userId == $session->get(UserConstants::USER_ID)) {
  194.                                 MiscActions::RefreshBuddybeeBalanceOnSession($em$request->getSession());
  195.                             }
  196.                         $payableAmount round($request->request->get('payableAmount'0), 0);
  197.                         $totalAmountWoDiscount round($request->request->get('totalAmountWoDiscount'0), 0);
  198.                         //now claim and process promocode
  199.                         if ($promoCode != '') {
  200.                             $claimData MiscActions::ClaimPromoCode($em,
  201.                                 [
  202.                                     'claimFlag' => 1,
  203.                                     'promoCode' => $promoCode,
  204.                                     'decryptedPromoCodeData' => json_decode($this->get('url_encryptor')->decrypt($promoCode), true),
  205.                                     'orderValue' => $totalAmountWoDiscount,
  206.                                     'currency' => $currencyForGateway,
  207.                                     'orderCoin' => $invoiceSessionCount,
  208.                                     'userId' => $userId,
  209.                                 ]);
  210.                             $promoClaimedAmount 0;
  211. //                            $promoClaimedAmount = $claimData['data']['claimedAmount']*(BuddybeeConstant::$convMultFromTo['eur'][$currencyForGateway]);
  212.                             $promoCodeId $claimData['promoCodeId'];
  213.                             $promoClaimedSession $claimData['data']['claimedCoin'];
  214.                         }
  215.                         if ($userId == $session->get(UserConstants::USER_ID)) {
  216.                             MiscActions::RefreshBuddybeeBalanceOnSession($em$request->getSession());
  217.                             $currentUserBalance $session->get('BUDDYBEE_BALANCE');
  218.                             $currentUserCoinBalance $session->get('BUDDYBEE_COIN_BALANCE');
  219.                         } else {
  220.                             if ($bookingRefererId == 0)
  221.                                 $bookingRefererId $session->get(UserConstants::USER_ID);
  222.                             $studentDetails $em_goc->getRepository(EntityApplicantDetails::class)->find($userId);
  223.                             if ($studentDetails) {
  224.                                 $currentUserBalance $studentDetails->getAccountBalance();
  225.                                 $currentUserCoinBalance $studentDetails->getSessionCountBalance();
  226.                                 if ($bookingRefererId != $userId && $bookingRefererId != 0) {
  227.                                     $bookingReferer $em_goc->getRepository(EntityApplicantDetails::class)->find($bookingRefererId);
  228.                                     if ($bookingReferer)
  229.                                         if ($bookingReferer->getIsAdmin()) {
  230.                                             $studentDetails->setAssignedSalesRepresentativeId($bookingRefererId);
  231.                                             $em_goc->flush();
  232.                                         }
  233.                                 }
  234.                             }
  235.                         }
  236.                         //2. check if any promo code  if yes add it to promo discount
  237.                         //3. check if scheule is still temporarily booked if not return that you cannot book it
  238.                         Buddybee::ExpireAnyMeetingSessionIfNeeded($em);
  239.                         Buddybee::ExpireAnyEntityInvoiceIfNeeded($em);
  240. //                        if ($request->request->get('autoAssignMeetingSession', 0) == 1
  241. //                            && $request->request->get('consultancyScheduleId', 0) != 0
  242. //                            && $request->request->get('consultancyScheduleId', 0) != ''
  243. //                        )
  244.                         {
  245.                             //1st check if a meeting session exxists with same TS, student id , consultant id
  246. //                            $scheduledStartTime = new \DateTime('@' . $request->request->get('consultancyScheduleId', ''));
  247. //                            $extMeeting = $em->getRepository('CompanyGroupBundle:EntityMeetingSession')
  248. //                                ->findOneBy(
  249. //                                    array(
  250. //                                        'scheduledTimeTs' => $scheduledStartTime->format('U'),
  251. //                                        'consultantId' => $request->request->get('consultantId', 0),
  252. //                                        'studentId' => $request->request->get('studentId', 0),
  253. //                                        'durationAllowedMin' => $request->request->get('meetingSessionScheduledDuration', BuddybeeConstant::PER_SESSION_MINUTE),
  254. //                                    )
  255. //                                );
  256. //                            if ($extMeeting) {
  257. //                                $new = $extMeeting;
  258. //                                $meetingSessionId = $new->getSessionId();
  259. //                                $periodMarker = $scheduledStartTime->format('Ym');
  260. //
  261. //                            }
  262. //                            else {
  263. //
  264. //
  265. //                                $scheduleValidity = MiscActions::CheckIfScheduleCanBeConfirmed(
  266. //                                    $em,
  267. //                                    $request->request->get('consultantId', 0),
  268. //                                    $request->request->get('studentId', 0),
  269. //                                    $scheduledStartTime->format('U'),
  270. //                                    $request->request->get('meetingSessionScheduledDuration', BuddybeeConstant::PER_SESSION_MINUTE),
  271. //                                    1
  272. //                                );
  273. //
  274. //                                if (!$scheduleValidity) {
  275. //                                    $url = $this->generateUrl(
  276. //                                        'consultant_profile'
  277. //                                    );
  278. //                                    $output = [
  279. //
  280. //                                        'proceedToCheckout' => 0,
  281. //                                        'message' => 'Session Booking Expired or not Found!',
  282. //                                        'errorFlag' => 1,
  283. //                                        'redirectUrl' => $url . '/' . $request->request->get('consultantId', 0)
  284. //                                    ];
  285. //                                    return new JsonResponse($output);
  286. //                                }
  287. //                                $new = new EntityMeetingSession();
  288. //
  289. //                                $new->setTopicId($request->request->get('consultancyTopic', 0));
  290. //                                $new->setConsultantId($request->request->get('consultantId', 0));
  291. //                                $new->setStudentId($request->request->get('studentId', 0));
  292. //                                $consultancyTopic = $em_goc->getRepository(EntityCreateTopic::class)->find($request->request->get('consultancyTopic', 0));
  293. //                                $new->setMeetingType($consultancyTopic ? $consultancyTopic->getMeetingType() : 0);
  294. //                                $new->setConsultantCanUpload($consultancyTopic ? $consultancyTopic->getConsultantCanUpload() : 0);
  295. //
  296. //
  297. //                                $scheduledEndTime = new \DateTime($request->request->get('scheduledTime', ''));
  298. //                                $scheduledEndTime = $scheduledEndTime->modify('+' . $request->request->get('meetingSessionScheduledDuration', 30) . ' minute');
  299. //
  300. //                                //$new->setScheduledTime($request->request->get('setScheduledTime'));
  301. //                                $new->setScheduledTime($scheduledStartTime);
  302. //                                $new->setDurationAllowedMin($request->request->get('meetingSessionScheduledDuration', 30));
  303. //                                $new->setDurationLeftMin($request->request->get('meetingSessionScheduledDuration', 30));
  304. //                                $new->setSessionExpireDate($scheduledEndTime);
  305. //                                $new->setSessionExpireDateTs($scheduledEndTime->format('U'));
  306. //                                $new->setEquivalentSessionCount($request->request->get('meetingSessionConsumeCount', 0));
  307. //                                $new->setMeetingSpecificNote($request->request->get('meetingSpecificNote', ''));
  308. //
  309. //                                $new->setUsableSessionCount($request->request->get('meetingSessionConsumeCount', 0));
  310. //                                $new->setRedeemSessionCount($request->request->get('meetingSessionConsumeCount', 0));
  311. //                                $new->setMeetingActionFlag(0);// no action waiting for meeting
  312. //                                $new->setScheduledTime($scheduledStartTime);
  313. //                                $new->setScheduledTimeTs($scheduledStartTime->format('U'));
  314. //                                $new->setPayableAmount($request->request->get('payableAmount', 0));
  315. //                                $new->setDueAmount($request->request->get('dueAmount', 0));
  316. //                                //$new->setScheduledTime(new \DateTime($request->get('setScheduledTime')));
  317. //                                //$new->setPcakageDetails(json_encode(($request->request->get('packageData'))));
  318. //                                $new->setPackageName(($request->request->get('packageName', '')));
  319. //                                $new->setPcakageDetails(($request->request->get('packageData', '')));
  320. //                                $new->setScheduleId(($request->request->get('consultancyScheduleId', 0)));
  321. //                                $currentUnixTime = new \DateTime();
  322. //                                $currentUnixTimeStamp = $currentUnixTime->format('U');
  323. //                                $studentId = $request->request->get('studentId', 0);
  324. //                                $consultantId = $request->request->get('consultantId', 0);
  325. //                                $new->setMeetingRoomId(str_pad($consultantId, 4, STR_PAD_LEFT) . $currentUnixTimeStamp . str_pad($studentId, 4, STR_PAD_LEFT));
  326. //                                $new->setSessionValue(($request->request->get('sessionValue', 0)));
  327. ////                        $new->setIsPayment(0);
  328. //                                $new->setConsultantIsPaidFull(0);
  329. //
  330. //                                if ($bookingExpireTs == 0) {
  331. //
  332. //                                    $bookingExpireTime = new \DateTime();
  333. //                                    $currTime = new \DateTime();
  334. //                                    $currTimeTs = $currTime->format('U');
  335. //                                    $bookingExpireTs = (1 * $scheduledStartTime->format('U')) - (24 * 3600);
  336. //                                    if ($bookingExpireTs < $currTimeTs) {
  337. //                                        if ((1 * $scheduledStartTime->format('U')) - $currTimeTs > (12 * 3600))
  338. //                                            $bookingExpireTs = (1 * $scheduledStartTime->format('U')) - (2 * 3600);
  339. //                                        else
  340. //                                            $bookingExpireTs = (1 * $scheduledStartTime->format('U'));
  341. //                                    }
  342. //
  343. ////                                    $bookingExpireTs = $bookingExpireTime->format('U');
  344. //                                }
  345. //
  346. //                                $new->setPaidSessionCount(0);
  347. //                                $new->setBookedById($bookedById);
  348. //                                $new->setBookingRefererId($bookingRefererId);
  349. //                                $new->setDueSessionCount($request->request->get('meetingSessionConsumeCount', 0));
  350. //                                $new->setExpireIfUnpaidTs($bookingExpireTs);
  351. //                                $new->setBookingExpireTs($bookingExpireTs);
  352. //                                $new->setConfirmationExpireTs($bookingExpireTs);
  353. //                                $new->setIsPaidFull(0);
  354. //                                $new->setIsExpired(0);
  355. //
  356. //
  357. //                                $em_goc->persist($new);
  358. //                                $em_goc->flush();
  359. //                                $meetingSessionId = $new->getSessionId();
  360. //                                $periodMarker = $scheduledStartTime->format('Ym');
  361. //                                MiscActions::UpdateSchedulingRestrictions($em_goc, $consultantId, $periodMarker, (($request->request->get('meetingSessionScheduledDuration', 30)) / 60), -(($request->request->get('meetingSessionScheduledDuration', 30)) / 60));
  362. //                            }
  363.                         }
  364.                         //4. if after all this stages passed then calcualte gateway payable
  365.                         if ($request->request->get('isRecharge'0) == 1) {
  366.                             if (($redeemedAmount $promoClaimedAmount) >= $payableAmount) {
  367.                                 $payableAmount = ($redeemedAmount $promoClaimedAmount);
  368.                                 $gatewayAmount 0;
  369.                             } else
  370.                                 $gatewayAmount $payableAmount - ($redeemedAmount $promoClaimedAmount);
  371.                         } else {
  372.                             if ($toConsumeSessionCount <= $currentUserCoinBalance && $invoiceSessionCount <= $toConsumeSessionCount) {
  373.                                 $payableAmount 0;
  374.                                 $gatewayAmount 0;
  375.                             } else if (($redeemedAmount $promoClaimedAmount) >= $payableAmount) {
  376.                                 $payableAmount = ($redeemedAmount $promoClaimedAmount);
  377.                                 $gatewayAmount 0;
  378.                             } else
  379.                                 $gatewayAmount $payableAmount <= ($currentUserBalance + ($redeemedAmount $promoClaimedAmount)) ? : ($payableAmount $currentUserBalance - ($redeemedAmount $promoClaimedAmount));
  380.                         }
  381.                         $gatewayAmount round($gatewayAmount2);
  382.                         $dueAmount round($request->request->get('dueAmount'$payableAmount), 0);
  383.                         if ($request->request->has('gatewayProductData'))
  384.                             $gatewayProductData $request->request->get('gatewayProductData');
  385.                         $gatewayProductData = [[
  386.                             'price_data' => [
  387.                                 'currency' => $currencyForGateway,
  388.                                 'unit_amount' => $gatewayAmount != ? ((100 $gatewayAmount) / ($invoiceSessionCount != $invoiceSessionCount 1)) : 200000,
  389.                                 'product_data' => [
  390. //                            'name' => $request->request->has('packageName') ? $request->request->get('packageName') : 'Advanced Consultancy Package',
  391.                                     'name' => 'Bee Coins',
  392.                                     'images' => [$imageBySessionCount[0]],
  393.                                 ],
  394.                             ],
  395.                             'quantity' => $invoiceSessionCount != $invoiceSessionCount 1,
  396.                         ]];
  397.                         $new_invoice null;
  398.                         if ($extMeeting) {
  399.                             $new_invoice $em->getRepository('CompanyGroupBundle:EntityInvoice')
  400.                                 ->findOneBy(
  401.                                     array(
  402.                                         'invoiceType' => $request->request->get('invoiceType'BuddybeeConstant::ENTITY_INVOICE_TYPE_PAYMENT_TO_HONEYBEE),
  403.                                         'meetingId' => $extMeeting->getSessionId(),
  404.                                     )
  405.                                 );
  406.                         }
  407.                         if ($new_invoice) {
  408.                         } else {
  409.                             $new_invoice = new EntityInvoice();
  410.                             $invoiceDate = new \DateTime();
  411.                             $new_invoice->setInvoiceDate($invoiceDate);
  412.                             $new_invoice->setInvoiceDateTs($invoiceDate->format('U'));
  413.                             $new_invoice->setStudentId($userId);
  414.                             $new_invoice->setBillerId($retailerId == $retailerId);
  415.                             $new_invoice->setRetailerId($retailerId);
  416.                             $new_invoice->setBillToId($userId);
  417.                             $new_invoice->setAmountTransferGateWayHash($paymentGateway);
  418.                             $new_invoice->setAmountCurrency($currencyForGateway);
  419.                             $cardIds $request->request->get('cardIds', []);
  420.                             $new_invoice->setMeetingId($meetingSessionId);
  421.                             $new_invoice->setGatewayBillAmount($gatewayAmount);
  422.                             $new_invoice->setRedeemedAmount($redeemedAmount);
  423.                             $new_invoice->setPromoDiscountAmount($promoClaimedAmount);
  424.                             $new_invoice->setPromoCodeId($promoCodeId);
  425.                             $new_invoice->setRedeemedSessionCount($redeemedSessionCount);
  426.                             $new_invoice->setPaidAmount($payableAmount $dueAmount);
  427.                             $new_invoice->setProductDataForPaymentGateway(json_encode($gatewayProductData));
  428.                             $new_invoice->setDueAmount($dueAmount);
  429.                             $new_invoice->setInvoiceType($request->request->get('invoiceType'BuddybeeConstant::ENTITY_INVOICE_TYPE_PAYMENT_TO_HONEYBEE));
  430.                             $new_invoice->setDocumentHash(MiscActions::GenerateRandomCrypto('BEI' microtime(true)));
  431.                             $new_invoice->setCardIds(json_encode($cardIds));
  432.                             $new_invoice->setAmountType($request->request->get('amountType'1));
  433.                             $new_invoice->setAmount($payableAmount);
  434.                             $new_invoice->setConsumeAmount($payableAmount);
  435.                             $new_invoice->setSessionCount($invoiceSessionCount);
  436.                             $new_invoice->setConsumeSessionCount($toConsumeSessionCount);
  437.                             $new_invoice->setIsPaidfull(0);
  438.                             $new_invoice->setIsProcessed(0);
  439.                             $new_invoice->setApplicantId($userId);
  440.                             $new_invoice->setBookedById($bookedById);
  441.                             $new_invoice->setBookingRefererId($bookingRefererId);
  442.                             $new_invoice->setIsRecharge($request->request->get('isRecharge'0));
  443.                             $new_invoice->setAutoConfirmTaggedMeeting($request->request->get('autoConfirmTaggedMeeting'0));
  444.                             $new_invoice->setAutoConfirmOtherMeeting($request->request->get('autoConfirmOtherMeeting'0));
  445.                             $new_invoice->setAutoClaimPurchasedCards($request->request->get('autoClaimPurchasedCards'0));
  446.                             $new_invoice->setIsPayment(0); //0 means receive
  447.                             $new_invoice->setStatus(GeneralConstant::ACTIVE); //0 means receive
  448.                             $new_invoice->setStage(BuddybeeConstant::ENTITY_INVOICE_STAGE_INITIATED); //0 means receive
  449.                             if ($bookingExpireTs == 0) {
  450.                                 $bookingExpireTime = new \DateTime();
  451.                                 $bookingExpireTime->modify('+30 day');
  452.                                 $bookingExpireTs $bookingExpireTime->format('U');
  453.                             }
  454.                             $new_invoice->setExpireIfUnpaidTs($bookingExpireTs);
  455.                             $new_invoice->setBookingExpireTs($bookingExpireTs);
  456.                             $new_invoice->setConfirmationExpireTs($bookingExpireTs);
  457. //            $new_invoice->setStatus($request->request->get(0));
  458.                             $em_goc->persist($new_invoice);
  459.                             $em_goc->flush();
  460.                         }
  461.                         $invoiceId $new_invoice->getId();
  462.                         $gatewayInvoice $new_invoice;
  463.                         if ($request->request->get('isRecharge'0) == 1) {
  464.                         } else {
  465.                             if ($gatewayAmount <= 0) {
  466.                                 $meetingId 0;
  467.                                 if ($invoiceId != 0) {
  468.                                     $retData Buddybee::ProcessEntityInvoice($em_goc$invoiceId, ['stage' => BuddybeeConstant::ENTITY_INVOICE_STAGE_COMPLETED], false,
  469.                                         $this->container->getParameter('notification_enabled'),
  470.                                         $this->container->getParameter('notification_server')
  471.                                     );
  472.                                     $meetingId $retData['meetingId'];
  473.                                 }
  474.                                 MiscActions::RefreshBuddybeeBalanceOnSession($em$request->getSession());
  475.                                 if (GeneralConstant::EMAIL_ENABLED == 1) {
  476.                                     $billerDetails = [];
  477.                                     $billToDetails = [];
  478.                                     $invoice $gatewayInvoice;
  479.                                     if ($invoice) {
  480.                                         $billerDetails $em->getRepository('CompanyGroupBundle:EntityApplicantDetails')
  481.                                             ->findOneBy(
  482.                                                 array(
  483.                                                     'applicantId' => $invoice->getBillerId(),
  484.                                                 )
  485.                                             );
  486.                                         $billToDetails $em->getRepository('CompanyGroupBundle:EntityApplicantDetails')
  487.                                             ->findOneBy(
  488.                                                 array(
  489.                                                     'applicantId' => $invoice->getBillToId(),
  490.                                                 )
  491.                                             );
  492.                                     }
  493.                                     $bodyTemplate 'ApplicationBundle:email/templates:buddybeeInvoiceEmail.html.twig';
  494.                                     $bodyData = array(
  495.                                         'page_title' => 'Invoice',
  496. //            'studentDetails' => $student,
  497.                                         'billerDetails' => $billerDetails,
  498.                                         'billToDetails' => $billToDetails,
  499.                                         'invoice' => $invoice,
  500.                                         'currencyList' => BuddybeeConstant::$currency_List,
  501.                                         'currencyListByMarker' => BuddybeeConstant::$currency_List_by_marker,
  502.                                     );
  503.                                     $attachments = [];
  504.                                     $forwardToMailAddress $billToDetails->getOAuthEmail();
  505. //                    $upl_dir = $this->container->getParameter('kernel.root_dir') . '/../web/uploads/temp/' . 'ledger' . '.pdf'
  506.                                     $new_mail $this->get('mail_module');
  507.                                     $new_mail->sendMyMail(array(
  508.                                         'senderHash' => '_CUSTOM_',
  509.                                         //                        'senderHash'=>'_CUSTOM_',
  510.                                         'forwardToMailAddress' => $forwardToMailAddress,
  511.                                         '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 ',
  512. //                        'fileName' => 'Order#' . str_pad($id, 8, '0', STR_PAD_LEFT) . '.pdf',
  513.                                         'attachments' => $attachments,
  514.                                         'toAddress' => $forwardToMailAddress,
  515.                                         'fromAddress' => 'no-reply@buddybee.eu',
  516.                                         'userName' => 'no-reply@buddybee.eu',
  517.                                         'password' => 'Honeybee@0112',
  518.                                         'smtpServer' => 'smtp.hostinger.com',
  519.                                         'smtpPort' => 465,
  520. //                            'emailBody' => $bodyHtml,
  521.                                         'mailTemplate' => $bodyTemplate,
  522.                                         'templateData' => $bodyData,
  523.                                         'embedCompanyImage' => 0,
  524.                                         'companyId' => 0,
  525.                                         'companyImagePath' => ''
  526. //                        'embedCompanyImage' => 1,
  527. //                        'companyId' => $companyId,
  528. //                        'companyImagePath' => $company_data->getImage()
  529.                                     ));
  530.                                 }
  531.                                 if ($meetingId != 0) {
  532.                                     $url $this->generateUrl(
  533.                                         'consultancy_session'
  534.                                     );
  535.                                     $output = [
  536.                                         'invoiceId' => $gatewayInvoice->getId(),
  537.                                         'meetingId' => $meetingId,
  538.                                         'proceedToCheckout' => 0,
  539.                                         'redirectUrl' => $url '/' $meetingId
  540.                                     ];
  541.                                 } else {
  542.                                     $url $this->generateUrl(
  543.                                         'buddybee_dashboard'
  544.                                     );
  545.                                     $output = [
  546.                                         'invoiceId' => $gatewayInvoice->getId(),
  547.                                         'meetingId' => 0,
  548.                                         'proceedToCheckout' => 0,
  549.                                         'redirectUrl' => $url
  550.                                     ];
  551.                                 }
  552.                                 return new JsonResponse($output);
  553. //                return $this->redirect($url);
  554.                             } else {
  555.                             }
  556. //                $url = $this->generateUrl(
  557. //                    'checkout_page'
  558. //                );
  559. //
  560. //                return $this->redirect($url."?meetingSessionId=".$new->getSessionId().'&invoiceId='.$invoiceId);
  561.                         }
  562.                     }
  563.                 } else {
  564.                     $url $this->generateUrl(
  565.                         'user_login'
  566.                     );
  567.                     $session->set('LAST_REQUEST_URI_BEFORE_LOGIN'$this->generateUrl(
  568.                         'pricing_plan_page', [
  569.                         'autoRedirected' => 1
  570.                     ],
  571.                         UrlGenerator::ABSOLUTE_URL
  572.                     ));
  573.                     $output = [
  574.                         'proceedToCheckout' => 0,
  575.                         'redirectUrl' => $url,
  576.                         'clearLs' => 0
  577.                     ];
  578.                     return new JsonResponse($output);
  579.                 }
  580.                 //now proceed to checkout page if the user has lower balance or recharging
  581.                 //$invoiceDetails = $em->getRepository('CompanyGroupBundle:EntityInvoice')->
  582.             }
  583.         }
  584.         if ($gatewayInvoice) {
  585.             $gatewayProductData json_decode($gatewayInvoice->getProductDataForPaymentGateway(), true);
  586.             if ($gatewayProductData == null$gatewayProductData = [];
  587.             if (empty($gatewayProductData))
  588.                 $gatewayProductData = [
  589.                     [
  590.                         'price_data' => [
  591.                             'currency' => 'eur',
  592.                             'unit_amount' => $gatewayAmount != ? (100 $gatewayAmount) : 200000,
  593.                             'product_data' => [
  594. //                            'name' => $request->request->has('packageName') ? $request->request->get('packageName') : 'Advanced Consultancy Package',
  595.                                 'name' => 'Bee Coins',
  596.                                 'images' => [$imageBySessionCount[0]],
  597.                             ],
  598.                         ],
  599.                         'quantity' => 1,
  600.                     ]
  601.                 ];
  602.             $productDescStr '';
  603.             $productDescArr = [];
  604.             foreach ($gatewayProductData as $gpd) {
  605.                 $productDescArr[] = $gpd['price_data']['product_data']['name'];
  606.             }
  607.             $productDescStr implode(','$productDescArr);
  608.             $paymentGatewayFromInvoice $gatewayInvoice->getAmountTransferGateWayHash();
  609. //            return new JsonResponse(
  610. //                [
  611. //                    'paymentGateway' => $paymentGatewayFromInvoice,
  612. //                    'gateWayData' => $gatewayProductData[0]
  613. //                ]
  614. //            );
  615.             if ($paymentGateway == null$paymentGatewayFromInvoice 'stripe';
  616.             if ($paymentGatewayFromInvoice == 'stripe' || $paymentGatewayFromInvoice == 'aamarpay' || $paymentGatewayFromInvoice == 'bkash') {
  617.                 if (GeneralConstant::EMAIL_ENABLED == 1) {
  618.                     $billerDetails = [];
  619.                     $billToDetails = [];
  620.                     $invoice $gatewayInvoice;
  621.                     if ($invoice) {
  622.                         $billerDetails $em->getRepository('CompanyGroupBundle:EntityApplicantDetails')
  623.                             ->findOneBy(
  624.                                 array(
  625.                                     'applicantId' => $invoice->getBillerId(),
  626.                                 )
  627.                             );
  628.                         $billToDetails $em->getRepository('CompanyGroupBundle:EntityApplicantDetails')
  629.                             ->findOneBy(
  630.                                 array(
  631.                                     'applicantId' => $invoice->getBillToId(),
  632.                                 )
  633.                             );
  634.                     }
  635.                     $bodyTemplate 'ApplicationBundle:email/templates:buddybeeInvoiceEmail.html.twig';
  636.                     $bodyData = array(
  637.                         'page_title' => 'Invoice',
  638. //            'studentDetails' => $student,
  639.                         'billerDetails' => $billerDetails,
  640.                         'billToDetails' => $billToDetails,
  641.                         'invoice' => $invoice,
  642.                         'currencyList' => BuddybeeConstant::$currency_List,
  643.                         'currencyListByMarker' => BuddybeeConstant::$currency_List_by_marker,
  644.                     );
  645.                     $attachments = [];
  646.                     $forwardToMailAddress $billToDetails->getOAuthEmail();
  647. //                    $upl_dir = $this->container->getParameter('kernel.root_dir') . '/../web/uploads/temp/' . 'ledger' . '.pdf'
  648.                     $new_mail $this->get('mail_module');
  649.                     $new_mail->sendMyMail(array(
  650.                         'senderHash' => '_CUSTOM_',
  651.                         //                        'senderHash'=>'_CUSTOM_',
  652.                         'forwardToMailAddress' => $forwardToMailAddress,
  653.                         '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 ',
  654. //                        'fileName' => 'Order#' . str_pad($id, 8, '0', STR_PAD_LEFT) . '.pdf',
  655.                         'attachments' => $attachments,
  656.                         'toAddress' => $forwardToMailAddress,
  657.                         'fromAddress' => 'no-reply@buddybee.eu',
  658.                         'userName' => 'no-reply@buddybee.eu',
  659.                         'password' => 'Honeybee@0112',
  660.                         'smtpServer' => 'smtp.hostinger.com',
  661.                         'smtpPort' => 465,
  662. //                            'emailBody' => $bodyHtml,
  663.                         'mailTemplate' => $bodyTemplate,
  664.                         'templateData' => $bodyData,
  665.                         'embedCompanyImage' => 0,
  666.                         'companyId' => 0,
  667.                         'companyImagePath' => ''
  668. //                        'embedCompanyImage' => 1,
  669. //                        'companyId' => $companyId,
  670. //                        'companyImagePath' => $company_data->getImage()
  671.                     ));
  672.                 }
  673.             }
  674.             if ($paymentGatewayFromInvoice == 'stripe') {
  675.                 $stripe = new \Stripe\Stripe();
  676.                 \Stripe\Stripe::setApiKey('sk_test_51IxYTAJXs21fVb0QMop2Nb0E7u9Da4LwGrym1nGHUHqaSNtT3p9HBgHd7YyDsTKHscgPPECPQniTy79Ab8Sgxfbm00JF2AndUz');
  677.                 $stripe::setApiKey('sk_test_51IxYTAJXs21fVb0QMop2Nb0E7u9Da4LwGrym1nGHUHqaSNtT3p9HBgHd7YyDsTKHscgPPECPQniTy79Ab8Sgxfbm00JF2AndUz');
  678.                 {
  679.                     if ($request->query->has('meetingSessionId'))
  680.                         $id $request->query->get('meetingSessionId');
  681.                 }
  682.                 $paymentIntent = [
  683.                     "id" => "pi_1DoWjK2eZvKYlo2Csy9J3BHs",
  684.                     "object" => "payment_intent",
  685.                     "amount" => 3000,
  686.                     "amount_capturable" => 0,
  687.                     "amount_received" => 0,
  688.                     "application" => null,
  689.                     "application_fee_amount" => null,
  690.                     "canceled_at" => null,
  691.                     "cancellation_reason" => null,
  692.                     "capture_method" => "automatic",
  693.                     "charges" => [
  694.                         "object" => "list",
  695.                         "data" => [],
  696.                         "has_more" => false,
  697.                         "url" => "/v1/charges?payment_intent=pi_1DoWjK2eZvKYlo2Csy9J3BHs"
  698.                     ],
  699.                     "client_secret" => "pi_1DoWjK2eZvKYlo2Csy9J3BHs_secret_vmxAcWZxo2kt1XhpWtZtnjDtd",
  700.                     "confirmation_method" => "automatic",
  701.                     "created" => 1546523966,
  702.                     "currency" => $currencyForGateway,
  703.                     "customer" => null,
  704.                     "description" => null,
  705.                     "invoice" => null,
  706.                     "last_payment_error" => null,
  707.                     "livemode" => false,
  708.                     "metadata" => [],
  709.                     "next_action" => null,
  710.                     "on_behalf_of" => null,
  711.                     "payment_method" => null,
  712.                     "payment_method_options" => [],
  713.                     "payment_method_types" => [
  714.                         "card"
  715.                     ],
  716.                     "receipt_email" => null,
  717.                     "review" => null,
  718.                     "setup_future_usage" => null,
  719.                     "shipping" => null,
  720.                     "statement_descriptor" => null,
  721.                     "statement_descriptor_suffix" => null,
  722.                     "status" => "requires_payment_method",
  723.                     "transfer_data" => null,
  724.                     "transfer_group" => null
  725.                 ];
  726.                 $checkout_session = \Stripe\Checkout\Session::create([
  727.                     'payment_method_types' => ['card'],
  728.                     'line_items' => $gatewayProductData,
  729.                     'mode' => 'payment',
  730.                     'success_url' => $this->generateUrl(
  731.                         'payment_gateway_success',
  732.                         ['encData' => $this->get('url_encryptor')->encrypt(json_encode(array(
  733.                             'invoiceId' => $invoiceId'autoRedirect' => $request->request->get('autoRedirect'1)
  734.                         ))), 'hbeeSessionToken' => $session->get('token'0)], UrlGenerator::ABSOLUTE_URL
  735.                     ),
  736.                     'cancel_url' => $this->generateUrl(
  737.                         'payment_gateway_cancel', ['invoiceId' => $invoiceId'autoRedirect' => $request->request->get('autoRedirect'1), 'hbeeSessionToken' => $session->get('token'0)], UrlGenerator::ABSOLUTE_URL
  738.                     ),
  739.                 ]);
  740.                 $output = [
  741.                     'clientSecret' => $paymentIntent['client_secret'],
  742.                     'id' => $checkout_session->id,
  743.                     'paymentGateway' => $paymentGatewayFromInvoice,
  744.                     'proceedToCheckout' => 1
  745.                 ];
  746.                 return new JsonResponse($output);
  747.             }
  748.             if ($paymentGatewayFromInvoice == 'aamarpay') {
  749.                 $studentDetails $em_goc->getRepository(EntityApplicantDetails::class)->find($gatewayInvoice->getBillToId());
  750.                 $url $sandBoxMode == 'https://sandbox.aamarpay.com/request.php' 'https://secure.aamarpay.com/request.php';
  751.                 $fields = array(
  752. //                    'store_id' => 'aamarpaytest', //store id will be aamarpay,  contact integration@aamarpay.com for test/live id
  753.                     'store_id' => $sandBoxMode == 'aamarpaytest' 'buddybee'//store id will be aamarpay,  contact integration@aamarpay.com for test/live id
  754.                     'amount' => $gatewayInvoice->getGateWayBillamount(), //transaction amount
  755.                     'payment_type' => 'VISA'//no need to change
  756.                     'currency' => strtoupper($currencyForGateway),  //currenct will be USD/BDT
  757.                     'tran_id' => $gatewayInvoice->getDocumentHash(), //transaction id must be unique from your end
  758.                     'cus_name' => $studentDetails->getFirstname() . ' ' $studentDetails->getLastName(),  //customer name
  759.                     'cus_email' => $studentDetails->getEmail(), //customer email address
  760.                     'cus_add1' => $studentDetails->getCurrAddr(),  //customer address
  761.                     'cus_add2' => $studentDetails->getCurrAddrCity(), //customer address
  762.                     'cus_city' => $studentDetails->getCurrAddrCity(),  //customer city
  763.                     'cus_state' => $studentDetails->getCurrAddrState(),  //state
  764.                     'cus_postcode' => $studentDetails->getCurrAddrZip(), //postcode or zipcode
  765.                     'cus_country' => 'Bangladesh',  //country
  766.                     'cus_phone' => ($studentDetails->getPhone() == null || $studentDetails->getPhone() == '') ? '+8801911706483' $studentDetails->getPhone(), //customer phone number
  767.                     'cus_fax' => '',  //fax
  768.                     'ship_name' => ''//ship name
  769.                     'ship_add1' => '',  //ship address
  770.                     'ship_add2' => '',
  771.                     'ship_city' => '',
  772.                     'ship_state' => '',
  773.                     'ship_postcode' => '',
  774.                     'ship_country' => 'Bangladesh',
  775.                     'desc' => $productDescStr,
  776.                     'success_url' => $this->generateUrl(
  777.                         'payment_gateway_success',
  778.                         ['encData' => $this->get('url_encryptor')->encrypt(json_encode(array(
  779.                             'invoiceId' => $invoiceId'autoRedirect' => $request->request->get('autoRedirect'1)
  780.                         ))), 'hbeeSessionToken' => $session->get('token'0)], UrlGenerator::ABSOLUTE_URL
  781.                     ),
  782.                     'fail_url' => $this->generateUrl(
  783.                         'payment_gateway_cancel', ['invoiceId' => $invoiceId'autoRedirect' => $request->request->get('autoRedirect'1), 'hbeeSessionToken' => $session->get('token'0)], UrlGenerator::ABSOLUTE_URL
  784.                     ),
  785.                     'cancel_url' => $this->generateUrl(
  786.                         'payment_gateway_cancel', ['invoiceId' => $invoiceId'autoRedirect' => $request->request->get('autoRedirect'1), 'hbeeSessionToken' => $session->get('token'0)], UrlGenerator::ABSOLUTE_URL
  787.                     ),
  788. //                    'opt_a' => 'Reshad',  //optional paramter
  789. //                    'opt_b' => 'Akil',
  790. //                    'opt_c' => 'Liza',
  791. //                    'opt_d' => 'Sohel',
  792. //                    'signature_key' => 'dbb74894e82415a2f7ff0ec3a97e4183',  //sandbox
  793.                     'signature_key' => $sandBoxMode == 'dbb74894e82415a2f7ff0ec3a97e4183' 'b7304a40e21fe15af3be9a948307f524'  //live
  794.                 ); //signature key will provided aamarpay, contact integration@aamarpay.com for test/live signature key
  795.                 $fields_string http_build_query($fields);
  796. //                $ch = curl_init();
  797. //                curl_setopt($ch, CURLOPT_VERBOSE, true);
  798. //                curl_setopt($ch, CURLOPT_URL, $url);
  799. //
  800. //                curl_setopt($ch, CURLOPT_POSTFIELDS, $fields_string);
  801. //                curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  802. //                curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
  803. //                $url_forward = str_replace('"', '', stripslashes(curl_exec($ch)));
  804. //                curl_close($ch);
  805. //                $this->redirect_to_merchant($url_forward);
  806.                 $output = [
  807. //
  808. //                    'redirectUrl' => ($sandBoxMode == 1 ? 'https://sandbox.aamarpay.com/' : 'https://secure.aamarpay.com/') . $url_forward, //keeping it off temporarily
  809. //                    'fields'=>$fields,
  810. //                    'fields_string'=>$fields_string,
  811. //                    'redirectUrl' => $this->generateUrl(
  812. //                        'payment_gateway_success',
  813. //                        ['encData' => $this->get('url_encryptor')->encrypt(json_encode(array(
  814. //                            'invoiceId' => $invoiceId, 'autoRedirect' => $request->request->get('autoRedirect', 1)
  815. //                        ))), 'hbeeSessionToken' => $request->request->get('token', 0)], UrlGenerator::ABSOLUTE_URL
  816. //                    ),
  817.                     'paymentGateway' => $paymentGatewayFromInvoice,
  818.                     'proceedToCheckout' => 1,
  819.                     'data' => $fields
  820.                 ];
  821.                 return new JsonResponse($output);
  822.             } else if ($paymentGatewayFromInvoice == 'bkash') {
  823.                 $studentDetails $em_goc->getRepository(EntityApplicantDetails::class)->find($gatewayInvoice->getBillToId());
  824.                 $baseUrl = ($sandBoxMode == 1) ? 'https://tokenized.sandbox.bka.sh/v1.2.0-beta' 'https://tokenized.pay.bka.sh/v1.2.0-beta';
  825.                 $username_value = ($sandBoxMode == 1) ? 'sandboxTokenizedUser02' '01891962953';
  826.                 $password_value = ($sandBoxMode == 1) ? 'sandboxTokenizedUser02@12345' ',a&kPV4deq&';
  827.                 $app_key_value = ($sandBoxMode == 1) ? '4f6o0cjiki2rfm34kfdadl1eqq' '2ueVHdwz5gH3nxx7xn8wotlztc';
  828.                 $app_secret_value = ($sandBoxMode == 1) ? '2is7hdktrekvrbljjh44ll3d9l1dtjo4pasmjvs5vl5qr3fug4b' '49Ay3h3wWJMBFD7WF5CassyLrtA1jt6ONhspqjqFx5hTjhqh5dHU';
  829.                 $request_data = array(
  830.                     'app_key' => $app_key_value,
  831.                     'app_secret' => $app_secret_value
  832.                 );
  833.                 $url curl_init($baseUrl '/tokenized/checkout/token/grant');
  834.                 $request_data_json json_encode($request_data);
  835.                 $header = array(
  836.                     'Content-Type:application/json',
  837.                     'username:' $username_value,
  838.                     'password:' $password_value
  839.                 );
  840.                 curl_setopt($urlCURLOPT_HTTPHEADER$header);
  841.                 curl_setopt($urlCURLOPT_CUSTOMREQUEST"POST");
  842.                 curl_setopt($urlCURLOPT_RETURNTRANSFERtrue);
  843.                 curl_setopt($urlCURLOPT_POSTFIELDS$request_data_json);
  844.                 curl_setopt($urlCURLOPT_FOLLOWLOCATION1);
  845.                 curl_setopt($urlCURLOPT_IPRESOLVECURL_IPRESOLVE_V4);
  846.                 $tokenData json_decode(curl_exec($url), true);
  847.                 curl_close($url);
  848.                 $id_token $tokenData['id_token'];
  849.                 $goToBkashPage 0;
  850.                 if ($tokenData['statusCode'] == '0000') {
  851.                     $auth $id_token;
  852.                     $requestbody = array(
  853.                         "mode" => "0011",
  854. //                        "payerReference" => "01723888888",
  855.                         "payerReference" => $invoiceDate->format('U'),
  856.                         "callbackURL" => $this->generateUrl(
  857.                             'bkash_callback', [], UrlGenerator::ABSOLUTE_URL
  858.                         ),
  859. //                    "merchantAssociationInfo" => "MI05MID54RF09123456One",
  860.                         "amount" => number_format($gatewayInvoice->getGateWayBillamount(), 2'.'''),
  861.                         "currency" => "BDT",
  862.                         "intent" => "sale",
  863.                         "merchantInvoiceNumber" => $invoiceId
  864.                     );
  865.                     $url curl_init($baseUrl '/tokenized/checkout/create');
  866.                     $requestbodyJson json_encode($requestbody);
  867.                     $header = array(
  868.                         'Content-Type:application/json',
  869.                         'Authorization:' $auth,
  870.                         'X-APP-Key:' $app_key_value
  871.                     );
  872.                     curl_setopt($urlCURLOPT_HTTPHEADER$header);
  873.                     curl_setopt($urlCURLOPT_CUSTOMREQUEST"POST");
  874.                     curl_setopt($urlCURLOPT_RETURNTRANSFERtrue);
  875.                     curl_setopt($urlCURLOPT_POSTFIELDS$requestbodyJson);
  876.                     curl_setopt($urlCURLOPT_FOLLOWLOCATION1);
  877.                     curl_setopt($urlCURLOPT_IPRESOLVECURL_IPRESOLVE_V4);
  878.                     $resultdata curl_exec($url);
  879. //                    curl_close($url);
  880. //                    echo $resultdata;
  881.                     $obj json_decode($resultdatatrue);
  882.                     $goToBkashPage 1;
  883.                     $justNow = new \DateTime();
  884.                     $justNow->modify('+' $tokenData['expires_in'] . ' second');
  885.                     $gatewayInvoice->setGatewayIdTokenExpireTs($justNow->format('U'));
  886.                     $gatewayInvoice->setGatewayIdToken($tokenData['id_token']);
  887.                     $gatewayInvoice->setGatewayPaymentId($obj['paymentID']);
  888.                     $gatewayInvoice->setGatewayIdRefreshToken($tokenData['refresh_token']);
  889.                     $em->flush();
  890.                     $output = [
  891. //                        'redirectUrl' => $obj['bkashURL'],
  892.                         'paymentGateway' => $paymentGatewayFromInvoice,
  893.                         'proceedToCheckout' => $goToBkashPage,
  894.                         'tokenData' => $tokenData,
  895.                         'obj' => $obj,
  896.                         'id_token' => $tokenData['id_token'],
  897.                         'data' => [
  898.                             'amount' => $gatewayInvoice->getGateWayBillamount(), //transaction amount
  899. //                            'payment_type' => 'VISA', //no need to change
  900.                             'currency' => strtoupper($currencyForGateway),  //currenct will be USD/BDT
  901.                             'tran_id' => $gatewayInvoice->getDocumentHash(), //transaction id must be unique from your end
  902.                             'cus_name' => $studentDetails->getFirstname() . ' ' $studentDetails->getLastName(),  //customer name
  903.                             'cus_email' => $studentDetails->getEmail(), //customer email address
  904.                             'cus_add1' => $studentDetails->getCurrAddr(),  //customer address
  905.                             'cus_add2' => $studentDetails->getCurrAddrCity(), //customer address
  906.                             'cus_city' => $studentDetails->getCurrAddrCity(),  //customer city
  907.                             'cus_state' => $studentDetails->getCurrAddrState(),  //state
  908.                             'cus_postcode' => $studentDetails->getCurrAddrZip(), //postcode or zipcode
  909.                             'cus_country' => 'Bangladesh',  //country
  910.                             'cus_phone' => ($studentDetails->getPhone() == null || $studentDetails->getPhone() == '') ? '+8801911706483' $studentDetails->getPhone(), //customer phone number
  911.                             'cus_fax' => '',  //fax
  912.                             'ship_name' => ''//ship name
  913.                             'ship_add1' => '',  //ship address
  914.                             'ship_add2' => '',
  915.                             'ship_city' => '',
  916.                             'ship_state' => '',
  917.                             'ship_postcode' => '',
  918.                             'ship_country' => 'Bangladesh',
  919.                             'desc' => $productDescStr,
  920.                         ]
  921.                     ];
  922.                     return new JsonResponse($output);
  923.                 }
  924. //                $fields = array(
  925. //
  926. //                    "mode" => "0011",
  927. //                    "payerReference" => "01723888888",
  928. //                    "callbackURL" => $this->generateUrl(
  929. //                        'payment_gateway_success',
  930. //                        ['encData' => $this->get('url_encryptor')->encrypt(json_encode(array(
  931. //                            'invoiceId' => $invoiceId, 'autoRedirect' => $request->request->get('autoRedirect', 1)
  932. //                        ))), 'hbeeSessionToken' => $session->get('token', 0)], UrlGenerator::ABSOLUTE_URL
  933. //                    ),
  934. //                    "merchantAssociationInfo" => "MI05MID54RF09123456One",
  935. //                    "amount" => 1*number_format($gatewayInvoice->getGateWayBillamount(),2,'.',''),,
  936. //                    "currency" => "BDT",
  937. //                    "intent" => "sale",
  938. //                    "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)
  939. //
  940. //                );
  941. //                $fields = array(
  942. ////                    'store_id' => 'aamarpaytest', //store id will be aamarpay,  contact integration@aamarpay.com for test/live id
  943. //                    'store_id' => $sandBoxMode == 1 ? 'aamarpaytest' : 'buddybee', //store id will be aamarpay,  contact integration@aamarpay.com for test/live id
  944. //                    'amount' => 1*number_format($gatewayInvoice->getGateWayBillamount(),2,'.',''),, //transaction amount
  945. //                    'payment_type' => 'VISA', //no need to change
  946. //                    'currency' => strtoupper($currencyForGateway),  //currenct will be USD/BDT
  947. //                    '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
  948. //                    'cus_name' => $studentDetails->getFirstname() . ' ' . $studentDetails->getLastName(),  //customer name
  949. //                    'cus_email' => $studentDetails->getEmail(), //customer email address
  950. //                    'cus_add1' => $studentDetails->getCurrAddr(),  //customer address
  951. //                    'cus_add2' => $studentDetails->getCurrAddrCity(), //customer address
  952. //                    'cus_city' => $studentDetails->getCurrAddrCity(),  //customer city
  953. //                    'cus_state' => $studentDetails->getCurrAddrState(),  //state
  954. //                    'cus_postcode' => $studentDetails->getCurrAddrZip(), //postcode or zipcode
  955. //                    'cus_country' => 'Bangladesh',  //country
  956. //                    'cus_phone' => ($studentDetails->getPhone() == null || $studentDetails->getPhone() == '') ? ' + 8801911706483' : $studentDetails->getPhone(), //customer phone number
  957. //                    'cus_fax' => '',  //fax
  958. //                    'ship_name' => '', //ship name
  959. //                    'ship_add1' => '',  //ship address
  960. //                    'ship_add2' => '',
  961. //                    'ship_city' => '',
  962. //                    'ship_state' => '',
  963. //                    'ship_postcode' => '',
  964. //                    'ship_country' => 'Bangladesh',
  965. //                    'desc' => $productDescStr,
  966. //                    'success_url' => $this->generateUrl(
  967. //                        'payment_gateway_success',
  968. //                        ['encData' => $this->get('url_encryptor')->encrypt(json_encode(array(
  969. //                            'invoiceId' => $invoiceId, 'autoRedirect' => $request->request->get('autoRedirect', 1)
  970. //                        ))), 'hbeeSessionToken' => $session->get('token', 0)], UrlGenerator::ABSOLUTE_URL
  971. //                    ),
  972. //                    'fail_url' => $this->generateUrl(
  973. //                        'payment_gateway_cancel', ['invoiceId' => $invoiceId, 'autoRedirect' => $request->request->get('autoRedirect', 1), 'hbeeSessionToken' => $session->get('token', 0)], UrlGenerator::ABSOLUTE_URL
  974. //                    ),
  975. //                    'cancel_url' => $this->generateUrl(
  976. //                        'payment_gateway_cancel', ['invoiceId' => $invoiceId, 'autoRedirect' => $request->request->get('autoRedirect', 1), 'hbeeSessionToken' => $session->get('token', 0)], UrlGenerator::ABSOLUTE_URL
  977. //                    ),
  978. ////                    'opt_a' => 'Reshad',  //optional paramter
  979. ////                    'opt_b' => 'Akil',
  980. ////                    'opt_c' => 'Liza',
  981. ////                    'opt_d' => 'Sohel',
  982. ////                    'signature_key' => 'dbb74894e82415a2f7ff0ec3a97e4183',  //sandbox
  983. //                    'signature_key' => $sandBoxMode == 1 ? 'dbb74894e82415a2f7ff0ec3a97e4183' : 'b7304a40e21fe15af3be9a948307f524'  //live
  984. //
  985. //                ); //signature key will provided aamarpay, contact integration@aamarpay.com for test/live signature key
  986. //
  987. //                $fields_string = http_build_query($fields);
  988. //
  989. //                $ch = curl_init();
  990. //                curl_setopt($ch, CURLOPT_VERBOSE, true);
  991. //                curl_setopt($ch, CURLOPT_URL, $url);
  992. //
  993. //                curl_setopt($ch, CURLOPT_POSTFIELDS, $fields_string);
  994. //                curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  995. //                curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
  996. //                $url_forward = str_replace('"', '', stripslashes(curl_exec($ch)));
  997. //                curl_close($ch);
  998. //                $this->redirect_to_merchant($url_forward);
  999.             } else if ($paymentGatewayFromInvoice == 'onsite_pos' || $paymentGatewayFromInvoice == 'onsite_cash' || $paymentGatewayFromInvoice == 'onsite_bkash') {
  1000.                 $meetingId 0;
  1001.                 if ($gatewayInvoice->getId() != 0) {
  1002.                     if ($gatewayInvoice->getDueAmount() <= 0) {
  1003.                         $retData Buddybee::ProcessEntityInvoice($em_goc$gatewayInvoice->getId(), ['stage' => BuddybeeConstant::ENTITY_INVOICE_STAGE_COMPLETED], false,
  1004.                             $this->container->getParameter('notification_enabled'),
  1005.                             $this->container->getParameter('notification_server')
  1006.                         );
  1007.                         $meetingId $retData['meetingId'];
  1008.                     }
  1009.                     if (GeneralConstant::EMAIL_ENABLED == 1) {
  1010.                         $billerDetails = [];
  1011.                         $billToDetails = [];
  1012.                         $invoice $gatewayInvoice;
  1013.                         if ($invoice) {
  1014.                             $billerDetails $em->getRepository('CompanyGroupBundle:EntityApplicantDetails')
  1015.                                 ->findOneBy(
  1016.                                     array(
  1017.                                         'applicantId' => $invoice->getBillerId(),
  1018.                                     )
  1019.                                 );
  1020.                             $billToDetails $em->getRepository('CompanyGroupBundle:EntityApplicantDetails')
  1021.                                 ->findOneBy(
  1022.                                     array(
  1023.                                         'applicantId' => $invoice->getBillToId(),
  1024.                                     )
  1025.                                 );
  1026.                         }
  1027.                         $bodyTemplate 'ApplicationBundle:email/templates:buddybeeInvoiceEmail.html.twig';
  1028.                         $bodyData = array(
  1029.                             'page_title' => 'Invoice',
  1030. //            'studentDetails' => $student,
  1031.                             'billerDetails' => $billerDetails,
  1032.                             'billToDetails' => $billToDetails,
  1033.                             'invoice' => $invoice,
  1034.                             'currencyList' => BuddybeeConstant::$currency_List,
  1035.                             'currencyListByMarker' => BuddybeeConstant::$currency_List_by_marker,
  1036.                         );
  1037.                         $attachments = [];
  1038.                         $forwardToMailAddress $billToDetails->getOAuthEmail();
  1039. //                    $upl_dir = $this->container->getParameter('kernel.root_dir') . '/../web/uploads/temp/' . 'ledger' . '.pdf'
  1040.                         $new_mail $this->get('mail_module');
  1041.                         $new_mail->sendMyMail(array(
  1042.                             'senderHash' => '_CUSTOM_',
  1043.                             //                        'senderHash'=>'_CUSTOM_',
  1044.                             'forwardToMailAddress' => $forwardToMailAddress,
  1045.                             '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 ',
  1046. //                        'fileName' => 'Order#' . str_pad($id, 8, '0', STR_PAD_LEFT) . '.pdf',
  1047.                             'attachments' => $attachments,
  1048.                             'toAddress' => $forwardToMailAddress,
  1049.                             'fromAddress' => 'no-reply@buddybee.eu',
  1050.                             'userName' => 'no-reply@buddybee.eu',
  1051.                             'password' => 'Honeybee@0112',
  1052.                             'smtpServer' => 'smtp.hostinger.com',
  1053.                             'smtpPort' => 465,
  1054. //                            'emailBody' => $bodyHtml,
  1055.                             'mailTemplate' => $bodyTemplate,
  1056.                             'templateData' => $bodyData,
  1057.                             'embedCompanyImage' => 0,
  1058.                             'companyId' => 0,
  1059.                             'companyImagePath' => ''
  1060. //                        'embedCompanyImage' => 1,
  1061. //                        'companyId' => $companyId,
  1062. //                        'companyImagePath' => $company_data->getImage()
  1063.                         ));
  1064.                     }
  1065.                 }
  1066.                 MiscActions::RefreshBuddybeeBalanceOnSession($em$request->getSession());
  1067.                 if ($meetingId != 0) {
  1068.                     $url $this->generateUrl(
  1069.                         'consultancy_session'
  1070.                     );
  1071.                     $output = [
  1072.                         'proceedToCheckout' => 0,
  1073.                         'invoiceId' => $gatewayInvoice->getId(),
  1074.                         'meetingId' => $meetingId,
  1075.                         'redirectUrl' => $url '/' $meetingId
  1076.                     ];
  1077.                 } else {
  1078.                     $url $this->generateUrl(
  1079.                         'buddybee_dashboard'
  1080.                     );
  1081.                     $output = [
  1082.                         'proceedToCheckout' => 0,
  1083.                         'invoiceId' => $gatewayInvoice->getId(),
  1084.                         'meetingId' => $meetingId,
  1085.                         'redirectUrl' => $url
  1086.                     ];
  1087.                 }
  1088.                 return new JsonResponse($output);
  1089.             }
  1090.         }
  1091.         $output = [
  1092.             'clientSecret' => 0,
  1093.             'id' => 0,
  1094.             'proceedToCheckout' => 0
  1095.         ];
  1096.         return new JsonResponse($output);
  1097. //        return $this->render('ApplicationBundle:pages/stripe:checkout.html.twig', array(
  1098. //            'page_title' => 'Checkout',
  1099. ////            'stripe' => $stripe,
  1100. //            'stripe' => null,
  1101. ////            'PaymentIntent' => $paymentIntent,
  1102. //
  1103. ////            'consultantDetail' => $consultantDetail,
  1104. ////            'consultantDetails'=> $consultantDetails,
  1105. ////
  1106. ////            'meetingSession' => $meetingSession,
  1107. ////            'packageDetails' => json_decode($meetingSession->getPcakageDetails(),true),
  1108. ////            'packageName' => json_decode($meetingSession->getPackageName(),true),
  1109. ////            'pay' => $payableAmount,
  1110. ////            'balance' => $currStudentBal
  1111. //        ));
  1112.     }
  1113.     //changes dev
  1114.     public function AddEmployeeAction(Request $data$id 0)
  1115.     {
  1116.         $em $this->getDoctrine()->getManager();
  1117.         $connection $em->getConnection();
  1118.         $connection->beginTransaction();
  1119.         $skills $em->getRepository(Skill::class)->findAll();
  1120.         $session $data->getSession();
  1121.         $ownOnly 0;
  1122.         $consultancyLevel HumanResourceConstant::$consultantLevel;
  1123.         $systemType $this->container->hasParameter('system_type') ? $this->container->getParameter('system_type') : '_ERP_';
  1124.         $banks $em->getRepository(BankList::class)->findAll();
  1125.         $bankListObj = [];
  1126.         $id $data->request->get('employeeId'$id);
  1127.         foreach ($banks as $bank) {
  1128.             $bankListObj[$bank->getBankId()] = $bank->getName();
  1129.         }
  1130.         if ($id === "my") {
  1131.             $id $session->get(UserConstants::USER_EMPLOYEE_ID);
  1132.             $ownOnly 1;
  1133.             if ($id == || $id == null) {
  1134.                 return $this->redirectToRoute('permission_denied_page');
  1135.             }
  1136.         }
  1137.         if ($id) {
  1138.             if ($data->isMethod('GET')) {
  1139.                 $Employee $this->getDoctrine()->getRepository(EmployeeDetails::class)->find($id);
  1140.                 if (!$Employee) {
  1141.                     $this->addFlash(
  1142.                         'error',
  1143.                         'Invalid User ID!'
  1144.                     );
  1145.                     return $this->redirectToRoute('add_employee');
  1146.                 } else {
  1147.                     $EmployeeRes HumanResource::TwigDataForAddEmployee($em$id);
  1148.                     $Employee $EmployeeRes['employee'];
  1149.                     $EmployeeMain $EmployeeRes['employeeMain'];
  1150.                     $sysUserId $EmployeeRes['sysId'];
  1151.                     $existingSysUser $sysUserId $em->getRepository('ApplicationBundle:SysUser')->find($sysUserId) : [];
  1152.                     $regionIdsArray json_decode($EmployeeMain->getRegionIds(), true) ?: [];
  1153.                     $regionLeaderFlagsArray json_decode($EmployeeMain->getRegionLeaderFlags(), true) ?: [];
  1154.                     $existingRegionAssociations = [];
  1155.                     if (!empty($regionIdsArray)) {
  1156.                         $regionRepo $this->getDoctrine()->getRepository('ApplicationBundle:Region');
  1157.                         $regions $regionRepo->findBy(['id' => $regionIdsArray]);
  1158.                         $regionMap = [];
  1159.                         foreach ($regions as $region) {
  1160.                             $regionMap[$region->getId()] = $region;
  1161.                         }
  1162.                         foreach ($regionIdsArray as $index => $regionId) {
  1163.                             if (!isset($regionMap[$regionId])) continue;
  1164.                             $region $regionMap[$regionId];
  1165.                             $existingRegionAssociations[] = [
  1166.                                 'regionLevelId' => $region->getRegionLevelId(),
  1167.                                 'regionId' => $region->getId(),
  1168.                                 'isLeader' => isset($regionLeaderFlagsArray[$index]) ? (int)$regionLeaderFlagsArray[$index] : 0
  1169.                             ];
  1170.                         }
  1171.                     }
  1172.                     $TwigData HumanResource::TwigDataForAddEmployee($em0);
  1173.                     return $this->render(
  1174.                         'ApplicationBundle:pages/human_resource/input_forms:add_employee.html.twig',
  1175.                         array(
  1176.                             'page_title' => 'Update Employee',
  1177.                             'ownOnly' => $ownOnly,
  1178.                             'branches' => $TwigData['branches'],
  1179.                             'bankListObj' => $bankListObj,
  1180.                             'heads' => Accounts::getLedgerHeadsWithParents($em),
  1181.                             'departments' => $TwigData['departments'],
  1182.                             'departmentPositions' => $TwigData['departmentPositions'],
  1183.                             'regions' => $TwigData['regions'],
  1184.                             'supervisors' => $TwigData['supervisors'],
  1185.                             'sysUsers' => $TwigData['sysUser'],
  1186.                             'EmploymentStatus' => $TwigData['EmploymentStatus'],
  1187.                             'sex' => $TwigData['sex'],
  1188.                             'BloodGroup' => $TwigData['BloodGroup'],
  1189.                             'days' => $TwigData['days'],
  1190.                             'employeeMain' => $EmployeeMain,
  1191.                             'employee' => $Employee,
  1192.                             'skills' => $skills,
  1193.                             'existingSysUser' => $existingSysUser,
  1194.                             'id' => $id,
  1195.                             'default_route' => $EmployeeRes['defaultRoute'],
  1196.                             'user_type' => $EmployeeRes['userType'],
  1197.                             'user_type_data' => HumanResourceConstant::$userType,
  1198.                             'AccountTypes' => $TwigData['AccountType'],
  1199.                             'weekends' => explode(','$Employee->getWeeklyHoliday()),
  1200.                             'consultancyLevel' => $consultancyLevel,
  1201.                             'module_data_array' => $TwigData['module_data_array'],
  1202.                             'HasUpdateMode' => true,
  1203.                             'brand_list' => Inventory::GetBrandList($em$this->getLoggedUserCompanyId($data)),
  1204.                             'branch_list' => Client::BranchList($this->getDoctrine()->getManager(), $this->getLoggedUserCompanyId($data)),
  1205.                             'region_data' => Client::RegionList($this->getDoctrine()->getManager(), $this->getLoggedUserCompanyId($data)),
  1206.                             'leaveSettings' => $TwigData['leaveSettings'],
  1207.                             'leaveData' => $EmployeeRes['leaveData'],
  1208.                             'positions' => $EmployeeRes['positions'],
  1209.                             'existing_region_associations' => $existingRegionAssociations
  1210.                         )
  1211.                     );
  1212.                 }
  1213.             } else {
  1214.                 $approveHash $data->request->get('approvalHash');
  1215.                 $loginId $data->getSession()->get(UserConstants::USER_LOGIN_ID);
  1216.                 $isSignatureOk DocValidation::isSignatureOk($em$loginId$approveHash);
  1217.                 $upl_dir $this->container->getParameter('kernel.root_dir') . '/../web/uploads/Users/';
  1218.                 $image $data->files->get('img');
  1219.                 $profileImage $this->uploadImage($image$data);
  1220.                 $path '';
  1221.                 if ($isSignatureOk) {
  1222.                     $CompanyId $this->getLoggedUserCompanyId($data);
  1223.                     $user $em->getRepository('ApplicationBundle:SysUser')->findOneBy(['email' => $data->get('email')]);
  1224.                     if ($user) {
  1225.                         $sysUserId $user->getUserId();
  1226.                         $message $this->get('user_module')->updateUser(
  1227.                             $sysUserId,
  1228.                             $data->request->get('firstname') . " " $data->request->get('lastname'),
  1229.                             $data->request->has('email') ? $data->request->get('email') : '_UNCHANGED_',
  1230.                             $data->request->has('username') ? $data->request->get('username') : '_UNCHANGED_',
  1231.                             $data->request->get('password'),
  1232.                             1,
  1233.                             $data->request->get('user_type''_UNCHANGED_'),
  1234.                             $data->request->get('supervisor'),
  1235.                             $data->request->get('default_route'),
  1236.                             $data->request->get('branch'),
  1237.                             $data->request->has('access_module') ? 0,
  1238.                             $data->getSession()->get(UserConstants::USER_LOGIN_ID),
  1239.                             $data->request->get('global_user_id'null),
  1240.                             $profileImage,
  1241.                             $upl_dir
  1242.                         );
  1243.                         if (isset($message[0]) && $message[0] === 'success') {
  1244.                             HumanResource::StoreDataForAddEmployee($em$data$id$CompanyId$profileImage);
  1245.                             $connection->commit();
  1246.                             if ($systemType == '_CENTRAL_') {
  1247.                             } else {
  1248.                                 $Employee $em->getRepository(Employee::class)->find($id);
  1249.                                 $EmployeeDetails $em->getRepository(EmployeeDetails::class)->findOneBy(
  1250.                                     array(
  1251.                                         'id' => $id
  1252.                                     )
  1253.                                 );
  1254.                                 $em_goc $this->getDoctrine()->getManager('company_group');
  1255.                                 $em_goc->getConnection()->connect();
  1256.                                 $connected $em_goc->getConnection()->isConnected();
  1257.                                 $gocDataList = [];
  1258.                                 $gocDataListByAppId = [];
  1259.                                 $retDataDebug = array();
  1260.                                 $appIds $message[3]->getUserAppId();
  1261.                                 $userIds $message[3]->getUserId();
  1262.                                 if ($connected) {
  1263.                                     $findByQuery = array(
  1264.                                         'active' => 1
  1265.                                     );
  1266.                                     if ($appIds !== '_UNSET_')
  1267.                                         $findByQuery['appId'] = $appIds;
  1268.                                     $gocList $this->getDoctrine()->getManager('company_group')
  1269.                                         ->getRepository("CompanyGroupBundle:CompanyGroup")
  1270.                                         ->findBy($findByQuery);
  1271.                                     foreach ($gocList as $entry) {
  1272.                                         $d = array(
  1273.                                             'name' => $entry->getName(),
  1274.                                             'id' => $entry->getId(),
  1275.                                             'image' => $entry->getImage(),
  1276.                                             'companyGroupHash' => $entry->getCompanyGroupHash(),
  1277.                                             'dbName' => $entry->getDbName(),
  1278.                                             'dbUser' => $entry->getDbUser(),
  1279.                                             'dbPass' => $entry->getDbPass(),
  1280.                                             'dbHost' => $entry->getDbHost(),
  1281.                                             'appId' => $entry->getAppId(),
  1282.                                             'companyRemaining' => $entry->getCompanyRemaining(),
  1283.                                             'companyAllowed' => $entry->getCompanyAllowed(),
  1284.                                         );
  1285.                                         $gocDataList[$entry->getId()] = $d;
  1286.                                         $gocDataListByAppId[$entry->getAppId()] = $d;
  1287.                                     }
  1288.                                     $debugCount 0;
  1289.                                     foreach ($gocDataList as $gocId => $entry) {
  1290.                                         $skipSend 1;
  1291.                                         $connector $this->container->get('application_connector');
  1292.                                         $connector->resetConnection(
  1293.                                             'default',
  1294.                                             $gocDataList[$gocId]['dbName'],
  1295.                                             $gocDataList[$gocId]['dbUser'],
  1296.                                             $gocDataList[$gocId]['dbPass'],
  1297.                                             $gocDataList[$gocId]['dbHost'],
  1298.                                             $reset true);
  1299.                                         $em $this->getDoctrine()->getManager();
  1300.                                         if ($userIds !== '_UNSET_')
  1301.                                             $users $this->getDoctrine()
  1302.                                                 ->getRepository('ApplicationBundle:SysUser')
  1303.                                                 ->findBy(
  1304.                                                     array(
  1305.                                                         'userId' => $userIds
  1306.                                                     )
  1307.                                                 );
  1308.                                         else
  1309.                                             $users $this->getDoctrine()
  1310.                                                 ->getRepository('ApplicationBundle:SysUser')
  1311.                                                 ->findBy(
  1312.                                                     array()
  1313.                                                 );
  1314.                                         $output '';
  1315.                                         $userData = array();
  1316.                                         $userFiles = array();
  1317.                                         foreach ($users as $user) {
  1318.                                             $file $this->container->getParameter('kernel.root_dir') . '/../web/' $user->getImage();
  1319.                                             if ($user->getImage() != '' && $user->getImage() != null && file_exists($file)) {
  1320.                                                 $mime mime_content_type($file);
  1321.                                                 $info pathinfo($file);
  1322.                                                 $name $info['basename'];
  1323.                                                 if (strpos($mime'image') !== false) {
  1324.                                                     $output = new \CURLFile($file$mime$name);
  1325.                                                 }
  1326.                                                 $skipSend 0;
  1327.                                                 $userFiles['file_' $user->getUserAppId() . '_' $user->getUserId()] = $output;
  1328.                                             } else {
  1329.                                                 $user->setImage(null);
  1330.                                                 $userFiles['file_' $user->getUserAppId() . '_' $user->getUserId()] = 'pika';
  1331.                                                 $em->flush();
  1332.                                             }
  1333.                                             $getters array_filter(get_class_methods($user), function ($method) {
  1334.                                                 return 'get' === substr($method03);
  1335.                                             });
  1336.                                             $userDataSingle = array();
  1337.                                             foreach ($getters as $getter) {
  1338.                                                 if ($getter == 'getCreatedAt' || $getter == 'getUpdatedAt' || $getter == 'getImage')
  1339.                                                     continue;
  1340.                                                 if ($user->{$getter}() instanceof \DateTime) {
  1341.                                                     $ggtd $user->{$getter}();
  1342.                                                     $userDataSingle[$getter] = $ggtd->format('Y-m-d');
  1343.                                                 } else
  1344.                                                     $userDataSingle[$getter] = $user->{$getter}();
  1345.                                             }
  1346.                                             $employeeGetters = array(
  1347.                                                 'getFirstname''getLastname''getImage''getIsImgLegal''getNid''getDob''getSex''getReligion''getFather',
  1348.                                                 'getMother''getSpouse''getChild1''getChild2''getBlood''getPhone''getOfficailPhone''getCurrAddr',
  1349.                                                 'getCurrAddrLat''getCurrAddrLng''getPermAddr''getEmmContact''getUsername''getEmail''getPassword',
  1350.                                                 'getUserId''getJoiningDate''getEmpValidTill''getEmpStatus''getEmpType''getEmpCode''getEmpLabel''getTin',
  1351.                                                 'getTinValidTill''getMedIns''getMedInsValidTill''getDocs''getNocApproval''getInst1''getYr1''getDur1',
  1352.                                                 'getInst2''getYr2''getDur2''getInst3''getYr3''getDur3''getEinst1''getEyr1''getEdeg1''getEinst2',
  1353.                                                 'getEyr2''getEdeg2''getEinst3''getEyr3''getEdeg3''getBankAcc''getBankAccType''getBankAccValidFrom',
  1354.                                                 'getBankAccValidTo''getRoutingCode''getSwiftCode''getEar1''getEar2''getEar3''getEar4''getEar5''getEar6',
  1355.                                                 'getEart''getDed1''getDed2''getDed3''getDed4''getDedt''getPayable''getHandCash''getBankTransfer',
  1356.                                                 'getSecDep''getSecDepSpan''getSecDepRemMon''getSecDepRemAmount''getSlQty''getSlTkn''getSlFreq''getMlQty',
  1357.                                                 'getMlTkn''getMlFreq''getElQty''getElTkn''getElFreq''getClQty''getClTkn''getClFreq''getLevt',
  1358.                                                 'getWeeklyHoliday''getFiles''getSupervisor''getDept''getDesg''getBranch''getDivision''getCreatedAt',
  1359.                                                 'getUpdatedAt''getEmployeeLevel''getSkill''getProbationaryPeriod''getDocBookedFlag''getTimeStampOfForm',
  1360.                                                 'getIsConsultant''getConsultantLevel''getApplicationText''getCurrentEmployment''getEmergencyContactNumber',
  1361.                                                 'getPostalCode''getCountry''getEducationData''getWorkExperienceData''getCertificateData''getLanguagesData',
  1362.                                                 'getBeneficiaryName''getBankName''getBranchName''getClockedIn'
  1363.                                             );
  1364.                                             foreach ($employeeGetters as $getter) {
  1365.                                                 if (!method_exists($EmployeeDetails$getter)) continue;
  1366.                                                 try {
  1367.                                                     $value $EmployeeDetails->{$getter}();
  1368.                                                     if ($value instanceof \DateTime) {
  1369.                                                         $userDataSingle[$getter] = $value->format('Y-m-d');
  1370.                                                     } elseif (is_object($value)) {
  1371.                                                         continue;
  1372.                                                     } else {
  1373.                                                         $userDataSingle[$getter] = $value;
  1374.                                                     }
  1375.                                                 } catch (\Exception $e) {
  1376.                                                     continue;
  1377.                                                 }
  1378.                                             }
  1379.                                             $userData[] = $userDataSingle;
  1380.                                         }
  1381.                                         $retDataDebug[$debugCount] = array(
  1382.                                             'skipSend' => $skipSend
  1383.                                         );
  1384.                                         {
  1385.                                             $urlToCall GeneralConstant::HONEYBEE_CENTRAL_SERVER '/SyncUserToCentralUser';
  1386.                                             $userFiles['userData'] = json_encode($userData);
  1387.                                             $curl curl_init();
  1388.                                             curl_setopt_array($curl, array(
  1389.                                                 CURLOPT_RETURNTRANSFER => 1,
  1390.                                                 CURLOPT_POST => 1,
  1391.                                                 CURLOPT_URL => $urlToCall,
  1392.                                                 CURLOPT_CONNECTTIMEOUT => 10,
  1393.                                                 CURLOPT_SSL_VERIFYPEER => false,
  1394.                                                 CURLOPT_SSL_VERIFYHOST => false,
  1395.                                                 CURLOPT_HTTPHEADER => array(),
  1396.                                                 CURLOPT_POSTFIELDS => $userFiles
  1397.                                             ));
  1398.                                             $retData curl_exec($curl);
  1399.                                             $errData curl_error($curl);
  1400.                                             curl_close($curl);
  1401.                                             $retDataObj json_decode($retDatatrue);
  1402.                                             $retDataDebug[$debugCount] = $retDataObj;
  1403.                                             if (isset($retDataObj['globalIdsData']))
  1404.                                                 foreach ($retDataObj['globalIdsData'] as $app_id => $usrList) {
  1405.                                                     $connector $this->container->get('application_connector');
  1406.                                                     $connector->resetConnection(
  1407.                                                         'default',
  1408.                                                         $gocDataListByAppId[$app_id]['dbName'],
  1409.                                                         $gocDataListByAppId[$app_id]['dbUser'],
  1410.                                                         $gocDataListByAppId[$app_id]['dbPass'],
  1411.                                                         $gocDataListByAppId[$app_id]['dbHost'],
  1412.                                                         $reset true);
  1413.                                                     $em $this->getDoctrine()->getManager();
  1414.                                                     foreach ($usrList as $sys_id => $globaldata) {
  1415.                                                         $user $this->getDoctrine()
  1416.                                                             ->getRepository('ApplicationBundle:SysUser')
  1417.                                                             ->findOneBy(
  1418.                                                                 array(
  1419.                                                                     'userId' => $sys_id
  1420.                                                                 )
  1421.                                                             );
  1422.                                                         if ($user) {
  1423.                                                             $user->setGlobalId($globaldata['gid']);
  1424.                                                             $em->flush();
  1425.                                                         }
  1426.                                                     }
  1427.                                                 }
  1428.                                         }
  1429.                                         $debugCount++;
  1430.                                     }
  1431.                                 }
  1432.                             }
  1433.                         } else {
  1434.                             $errorMsg $message['message'] ?? 'Unknown error occurred.';
  1435.                             $this->addFlash('error'$errorMsg);
  1436.                             return $this->redirectToRoute('add_employee');
  1437.                         }
  1438.                         $userType $data->getSession()->get(UserConstants::USER_TYPE);
  1439.                         $redirctUrl $this->generateUrl('employee_list', [], UrlGenerator::ABSOLUTE_URL);
  1440.                         if ($userType == 1) {
  1441.                             $redirctUrl $this->generateUrl('employee_list', [], UrlGenerator::ABSOLUTE_URL);
  1442.                         } else {
  1443.                             $redirctUrl $this->generateUrl('edit_employee', [], UrlGenerator::ABSOLUTE_URL) . '/my';
  1444.                         }
  1445.                         return new JsonResponse(array(
  1446.                             'employeeId' => $Employee->getEmployeeId(),
  1447.                             'redirectToNew' => 0,
  1448.                             'success' => true,
  1449.                             'redirectUrl' => $redirctUrl,
  1450.                         ));
  1451.                     }
  1452.                 } else {
  1453.                     $this->addFlash(
  1454.                         'error',
  1455.                         'Invalid Approval Hash!'
  1456.                     );
  1457.                     return $this->redirectToRoute('add_employee');
  1458.                 }
  1459.             }
  1460.         } else {
  1461.             if ($data->isMethod('GET')) {
  1462.                 $TwigData HumanResource::TwigDataForAddEmployee($em0);
  1463.                 $existingRegionAssociations = [];
  1464.                 return $this->render(
  1465.                     'ApplicationBundle:pages/human_resource/input_forms:add_employee.html.twig',
  1466.                     array(
  1467.                         'page_title' => 'Add Employee',
  1468.                         'ownOnly' => $ownOnly,
  1469.                         'heads' => Accounts::getLedgerHeadsWithParents($em),
  1470.                         'bankListObj' => $bankListObj,
  1471.                         'branches' => $TwigData['branches'],
  1472.                         'departments' => $TwigData['departments'],
  1473.                         'departmentPositions' => $TwigData['departmentPositions'],
  1474.                         'regions' => $TwigData['regions'],
  1475.                         'supervisors' => $TwigData['supervisors'],
  1476.                         'sysUsers' => $TwigData['sysUser'],
  1477.                         'EmploymentStatus' => $TwigData['EmploymentStatus'],
  1478.                         'sex' => $TwigData['sex'],
  1479.                         'skills' => $skills,
  1480.                         'id' => $id,
  1481.                         'consultancyLevel' => $consultancyLevel,
  1482.                         'existingSysUser' => null,
  1483.                         'BloodGroup' => $TwigData['BloodGroup'],
  1484.                         'days' => $TwigData['days'],
  1485.                         'AccountTypes' => $TwigData['AccountType'],
  1486.                         'module_data_array' => $TwigData['module_data_array'],
  1487.                         'user_type_data' => HumanResourceConstant::$userType,
  1488.                         'HasUpdateMode' => false,
  1489.                         'brand_list' => Inventory::GetBrandList($em$this->getLoggedUserCompanyId($data)),
  1490.                         'leaveSettings' => $TwigData['leaveSettings'],
  1491.                         'employee' => [],
  1492.                         'positions' => $TwigData['positions'],
  1493.                         'existing_region_associations' => $existingRegionAssociations ?? [],
  1494.                         'branch_list' => Client::BranchList($this->getDoctrine()->getManager(), $this->getLoggedUserCompanyId($data)),
  1495.                         'region_data' => Client::RegionList($this->getDoctrine()->getManager(), $this->getLoggedUserCompanyId($data)),
  1496.                     )
  1497.                 );
  1498.             } else {
  1499.                 try {
  1500.                     $approveHash $data->request->get('approvalHash');
  1501.                     $loginId $data->getSession()->get(UserConstants::USER_LOGIN_ID);
  1502.                     $CompanyId $this->getLoggedUserCompanyId($data);
  1503.                     $isSignatureOk DocValidation::isSignatureOk($em$loginId$approveHash);
  1504.                     if (!$isSignatureOk) {
  1505.                         $this->addFlash('error''Invalid Approval Hash!');
  1506.                         return $this->redirectToRoute('add_employee');
  1507.                     }
  1508.                     $message $this->get('user_module')->addNewUser(
  1509.                         $data->request->get('firstname') . " " $data->request->get('lastname'),
  1510.                         $data->request->get('email'),
  1511.                         $data->request->get('username'),
  1512.                         $data->request->get('password'),
  1513.                         $data->request->get('desg'),
  1514.                         $this->getLoggedUserLoginId($data),
  1515.                         $data->request->get('company'),
  1516.                         $data->request->get('user_type'),
  1517.                         $data->request->get('companyIdList'),
  1518.                         $data->request->get('branch'),
  1519.                         $data->request->get('supervisor'),
  1520.                         $data->request->get('default_route'),
  1521.                         $data->request->has('access_module') ? 0,
  1522.                         "",
  1523.                         $data->files->get('img'),
  1524.                         '',
  1525.                         00,
  1526.                         ''''''0''0,
  1527.                         $data->request->get('global_user_id'null)
  1528.                     );
  1529.                     if ($message[0] === 'error') {
  1530.                         $this->addFlash('error''Invalid Approval Hash!');
  1531.                         return $this->redirectToRoute('add_employee');
  1532.                     }
  1533.                     $isSuccess HumanResource::StoreDataForAddEmployee($em$datafalse$CompanyId);
  1534.                     $Employee $isSuccess;
  1535.                     $EmployeeDetails $em->getRepository(EmployeeDetails::class)->findOneBy(['id' => $id]);
  1536.                     $Employee->setUserId($message[3]->getUserId());
  1537.                     $em->persist($Employee);
  1538.                     if ($EmployeeDetails) {
  1539.                         $EmployeeDetails->setUserId($message[3]->getUserId());
  1540.                         $em->persist($EmployeeDetails);
  1541.                     }
  1542.                     $em->flush();
  1543.                     $connection->commit();
  1544.                 } catch(Throwable $e) {
  1545.                     $connection->rollBack();
  1546.                     $em->close();
  1547.                     $this->addFlash('error''Failed to save employee: ' $e->getMessage());
  1548.                     return $this->redirectToRoute('add_employee');
  1549.                 }
  1550.                 if ($systemType !== '_CENTRAL_') {
  1551.                     $em_goc $this->getDoctrine()->getManager('company_group');
  1552.                     $em_goc->getConnection()->connect();
  1553.                     $connected $em_goc->getConnection()->isConnected();
  1554.                     if ($connected) {
  1555.                         $appIds $message[2]->getAppId();
  1556.                         $userIds $message[3]->getUserId();
  1557.                         $findByQuery = ['active' => 1];
  1558.                         if ($appIds !== '_UNSET_'$findByQuery['appId'] = $appIds;
  1559.                         $gocList $em_goc->getRepository("CompanyGroupBundle:CompanyGroup")->findBy($findByQuery);
  1560.                         $gocDataList $gocDataListByAppId = [];
  1561.                         foreach ($gocList as $entry) {
  1562.                             $d = [
  1563.                                 'name' => $entry->getName(),
  1564.                                 'id' => $entry->getId(),
  1565.                                 'image' => $entry->getImage(),
  1566.                                 'companyGroupHash' => $entry->getCompanyGroupHash(),
  1567.                                 'dbName' => $entry->getDbName(),
  1568.                                 'dbUser' => $entry->getDbUser(),
  1569.                                 'dbPass' => $entry->getDbPass(),
  1570.                                 'dbHost' => $entry->getDbHost(),
  1571.                                 'appId' => $entry->getAppId(),
  1572.                                 'companyRemaining' => $entry->getCompanyRemaining(),
  1573.                                 'companyAllowed' => $entry->getCompanyAllowed(),
  1574.                             ];
  1575.                             $gocDataList[$entry->getId()] = $d;
  1576.                             $gocDataListByAppId[$entry->getAppId()] = $d;
  1577.                         }
  1578.                         $debugCount 0;
  1579.                         foreach ($gocDataList as $gocId => $entry) {
  1580.                             $skipSend 1;
  1581.                             $connector $this->container->get('application_connector');
  1582.                             $connector->resetConnection(
  1583.                                 'default',
  1584.                                 $entry['dbName'],
  1585.                                 $entry['dbUser'],
  1586.                                 $entry['dbPass'],
  1587.                                 $entry['dbHost'],
  1588.                                 $reset true
  1589.                             );
  1590.                             $em $this->getDoctrine()->getManager();
  1591.                             $users = ($userIds !== '_UNSET_')
  1592.                                 ? $this->getDoctrine()->getRepository('ApplicationBundle:SysUser')->findBy(['userId' => $userIds])
  1593.                                 : $this->getDoctrine()->getRepository('ApplicationBundle:SysUser')->findBy([]);
  1594.                             $userData $userFiles = [];
  1595.                             foreach ($users as $user) {
  1596.                                 $filePath $this->container->getParameter('kernel.root_dir') . '/../web/' $user->getImage();
  1597.                                 if ($user->getImage() && file_exists($filePath)) {
  1598.                                     $mime mime_content_type($filePath);
  1599.                                     $info pathinfo($filePath);
  1600.                                     $name $info['basename'];
  1601.                                     if (strpos($mime'image') !== false) {
  1602.                                         $userFiles['file_' $user->getUserAppId() . '_' $user->getUserId()] = new \CURLFile($filePath$mime$name);
  1603.                                         $skipSend 0;
  1604.                                     }
  1605.                                 } else {
  1606.                                     $user->setImage(null);
  1607.                                     $userFiles['file_' $user->getUserAppId() . '_' $user->getUserId()] = 'pika';
  1608.                                     $em->flush();
  1609.                                 }
  1610.                                 $getters array_filter(get_class_methods($user), function ($m) {
  1611.                                     return substr($m03) === 'get';
  1612.                                 });
  1613.                                 $userDataSingle = [];
  1614.                                 foreach ($getters as $getter) {
  1615.                                     if (in_array($getter, ['getCreatedAt''getUpdatedAt''getImage'])) continue;
  1616.                                     $val $user->{$getter}();
  1617.                                     $userDataSingle[$getter] = $val instanceof \DateTime $val->format('Y-m-d') : $val;
  1618.                                 }
  1619.                                 $employeeGetters = [
  1620.                                     'getFirstname''getLastname''getImage''getIsImgLegal''getNid''getDob''getSex''getReligion',
  1621.                                     'getFather''getMother''getSpouse''getChild1''getChild2''getBlood''getPhone''getOfficailPhone',
  1622.                                     'getCurrAddr''getCurrAddrLat''getCurrAddrLng''getPermAddr''getEmmContact''getUsername''getEmail',
  1623.                                     'getPassword''getUserId''getJoiningDate''getEmpValidTill''getEmpStatus''getEmpType''getEmpCode',
  1624.                                     'getEmpLabel''getTin''getTinValidTill''getMedIns''getMedInsValidTill''getDocs''getNocApproval',
  1625.                                     'getInst1''getYr1''getDur1''getInst2''getYr2''getDur2''getInst3''getYr3''getDur3''getEinst1',
  1626.                                     'getEyr1''getEdeg1''getEinst2''getEyr2''getEdeg2''getEinst3''getEyr3''getEdeg3''getBankAcc',
  1627.                                     'getBankAccType''getBankAccValidFrom''getBankAccValidTo''getRoutingCode''getSwiftCode''getEar1',
  1628.                                     'getEar2''getEar3''getEar4''getEar5''getEar6''getEart''getDed1''getDed2''getDed3''getDed4',
  1629.                                     'getDedt''getPayable''getHandCash''getBankTransfer''getSecDep''getSecDepSpan''getSecDepRemMon',
  1630.                                     'getSecDepRemAmount''getSlQty''getSlTkn''getSlFreq''getMlQty''getMlTkn''getMlFreq''getElQty',
  1631.                                     'getElTkn''getElFreq''getClQty''getClTkn''getClFreq''getLevt''getWeeklyHoliday''getFiles',
  1632.                                     'getSupervisor''getDept''getDesg''getBranch''getDivision''getCreatedAt''getUpdatedAt',
  1633.                                     'getEmployeeLevel''getSkill''getProbationaryPeriod''getDocBookedFlag''getTimeStampOfForm',
  1634.                                     'getIsConsultant''getConsultantLevel''getApplicationText''getCurrentEmployment''getEmergencyContactNumber',
  1635.                                     'getPostalCode''getCountry''getEducationData''getWorkExperienceData''getCertificateData''getLanguagesData',
  1636.                                     'getBeneficiaryName''getBankName''getBranchName''getClockedIn'
  1637.                                 ];
  1638.                                 foreach ($employeeGetters as $getter) {
  1639.                                     if (!method_exists($EmployeeDetails$getter)) continue;
  1640.                                     $value $EmployeeDetails->{$getter}();
  1641.                                     if ($value instanceof \DateTime$userDataSingle[$getter] = $value->format('Y-m-d');
  1642.                                     elseif (!is_object($value)) $userDataSingle[$getter] = $value;
  1643.                                 }
  1644.                                 $userData[] = $userDataSingle;
  1645.                             }
  1646.                             $retDataDebug[$debugCount] = ['skipSend' => $skipSend];
  1647.                             $urlToCall GeneralConstant::HONEYBEE_CENTRAL_SERVER '/SyncUserToCentralUser';
  1648.                             $userFiles['userData'] = json_encode($userData);
  1649.                             $curl curl_init();
  1650.                             curl_setopt_array($curl, [
  1651.                                 CURLOPT_RETURNTRANSFER => 1,
  1652.                                 CURLOPT_POST => 1,
  1653.                                 CURLOPT_URL => $urlToCall,
  1654.                                 CURLOPT_CONNECTTIMEOUT => 10,
  1655.                                 CURLOPT_SSL_VERIFYPEER => false,
  1656.                                 CURLOPT_SSL_VERIFYHOST => false,
  1657.                                 CURLOPT_POSTFIELDS => $userFiles
  1658.                             ]);
  1659.                             $retData curl_exec($curl);
  1660.                             $errData curl_error($curl);
  1661.                             curl_close($curl);
  1662.                             $retDataObj $errData ? ['status' => 'error''message' => 'cURL Error: ' $errData] : json_decode($retDatatrue);
  1663.                             $retDataDebug[$debugCount] = $retDataObj;
  1664.                             if (isset($retDataObj['globalIdsData'])) {
  1665.                                 foreach ($retDataObj['globalIdsData'] as $app_id => $usrList) {
  1666.                                     $connector->resetConnection(
  1667.                                         'default',
  1668.                                         $gocDataListByAppId[$app_id]['dbName'],
  1669.                                         $gocDataListByAppId[$app_id]['dbUser'],
  1670.                                         $gocDataListByAppId[$app_id]['dbPass'],
  1671.                                         $gocDataListByAppId[$app_id]['dbHost'],
  1672.                                         $reset true
  1673.                                     );
  1674.                                     $em $this->getDoctrine()->getManager();
  1675.                                     foreach ($usrList as $sys_id => $globaldata) {
  1676.                                         $user $this->getDoctrine()->getRepository('ApplicationBundle:SysUser')->findOneBy(['userId' => $sys_id]);
  1677.                                         if ($user) {
  1678.                                             $user->setGlobalId($globaldata['gid']);
  1679.                                             $em->persist($user);
  1680.                                             $em->flush();
  1681.                                         }
  1682.                                     }
  1683.                                 }
  1684.                             }
  1685.                             $debugCount++;
  1686.                         }
  1687.                     }
  1688.                 }
  1689.                 $companyData $message[2];
  1690.                 if ($message[0] === 'success' && GeneralConstant::EMAIL_ENABLED == 1) {
  1691.                     $bodyTemplate 'ApplicationBundle:email/user:registration.html.twig';
  1692.                     $bodyData = [
  1693.                         'name' => $data->request->get('name'),
  1694.                         'companyData' => $companyData,
  1695.                         'userName' => $data->request->get('username'),
  1696.                         'password' => $data->request->get('password'),
  1697.                     ];
  1698.                     $new_mail $this->get('mail_module');
  1699.                     $new_mail->sendMyMail([
  1700.                         'senderHash' => '_CUSTOM_',
  1701.                         'forwardToMailAddress' => $data->request->get('email'),
  1702.                         'subject' => 'User Registration on HoneyBee Ecosystem under Entity ' $companyData->getName(),
  1703.                         'fileName' => '',
  1704.                         'attachments' => [],
  1705.                         'toAddress' => $data->request->get('email'),
  1706.                         'fromAddress' => 'no-reply@ourhoneybee.eu',
  1707.                         'userName' => 'no-reply@ourhoneybee.eu',
  1708.                         'password' => 'Y41dh8g0112',
  1709.                         'smtpServer' => 'smtp.hostinger.com',
  1710.                         'smtpPort' => 465,
  1711.                         'mailTemplate' => $bodyTemplate,
  1712.                         'templateData' => $bodyData,
  1713.                         'embedCompanyImage' => 1,
  1714.                         'companyId' => $data->request->get('company'),
  1715.                         'companyImagePath' => $companyData->getImage()
  1716.                     ]);
  1717.                 }
  1718.                 $this->addFlash('success''New Employee Successfully Added!');
  1719.                 $userType $data->getSession()->get(UserConstants::USER_TYPE);
  1720.                 $redirectUrl $userType == 1
  1721.                     $this->generateUrl('employee_list', [], UrlGenerator::ABSOLUTE_URL)
  1722.                     : $this->generateUrl('add_employee', [], UrlGenerator::ABSOLUTE_URL);
  1723.                 return new JsonResponse([
  1724.                     'employeeId' => $Employee->getEmployeeId(),
  1725.                     'redirectToNew' => 1,
  1726.                     'success' => true,
  1727.                     'redirectUrl' => $redirectUrl,
  1728.                 ]);
  1729.             }
  1730.         }
  1731.     }
  1732.     public function AddNewEmployeeAction(Request $request$id)
  1733.     {
  1734.         $em $this->getDoctrine()->getManager();
  1735.         $systemType $this->container->hasParameter('system_type') ? $this->container->getParameter('system_type') : '_ERP_';
  1736.         $approveHash $request->request->get('approvalHash');
  1737.         $loginId $request->getSession()->get(UserConstants::USER_LOGIN_ID);
  1738.         $CompanyId $this->getLoggedUserCompanyId($request);
  1739.         $isSignatureOk DocValidation::isSignatureOk($em$loginId$approveHash);
  1740.         $employee HumanResource::StoreDataForAddEmployee($em$requestfalse$CompanyId);
  1741.         $isUserExist $em->getRepository(EmployeeDetails::class);
  1742.         if ($isSignatureOk) {
  1743.             if ($isUserExist) {
  1744.                 if ($employee) {
  1745.                     $message $this->get('user_module')->addNewUser(
  1746.                         $request->request->get('firstname') . " " $request->request->get('lastname'),
  1747.                         $request->request->get('email'),
  1748.                         $request->request->get('username'),
  1749.                         $request->request->get('password'),
  1750.                         $request->request->get('desg'),
  1751.                         $request->getLoggedUserLoginId($request),
  1752.                         $request->request->get('company'),
  1753.                         $request->request->get('user_type'),
  1754.                         $request->request->get('companyIdList'),
  1755.                         $request->request->get('branch'),
  1756.                         $request->request->get('supervisor'),
  1757.                         $request->request->get('default_route'),
  1758.                         $request->request->has('access_module') ? 0
  1759.                     );
  1760.                     if ($message[0] == 'success') {
  1761.                         $employee->setUserId($message[3]->getUserId());
  1762.                         $em->flush();
  1763.                         if ($systemType == '_CENTRAL_') {
  1764.                         } else {
  1765.                             $em_goc $this->getDoctrine()->getManager('company_group');
  1766.                             $em_goc->getConnection()->connect();
  1767.                             $connected $em_goc->getConnection()->isConnected();
  1768.                             $gocDataList = [];
  1769.                             $gocDataListByAppId = [];
  1770.                             $retDataDebug = array();
  1771.                             $appIds $message[2]->getAppId();
  1772.                             $userIds $message[3]->getUserId();
  1773.                             if ($connected) {
  1774.                                 $findByQuery = array(
  1775.                                     'active' => 1
  1776.                                 );
  1777.                                 if ($appIds !== '_UNSET_')
  1778.                                     $findByQuery['appId'] = $appIds;
  1779.                                 $gocList $this->getDoctrine()->getManager('company_group')
  1780.                                     ->getRepository("CompanyGroupBundle:CompanyGroup")
  1781.                                     ->findBy($findByQuery);
  1782.                                 foreach ($gocList as $entry) {
  1783.                                     $d = array(
  1784.                                         'name' => $entry->getName(),
  1785.                                         'id' => $entry->getId(),
  1786.                                         'image' => $entry->getImage(),
  1787.                                         'companyGroupHash' => $entry->getCompanyGroupHash(),
  1788.                                         'dbName' => $entry->getDbName(),
  1789.                                         'dbUser' => $entry->getDbUser(),
  1790.                                         'dbPass' => $entry->getDbPass(),
  1791.                                         'dbHost' => $entry->getDbHost(),
  1792.                                         'appId' => $entry->getAppId(),
  1793.                                         'companyRemaining' => $entry->getCompanyRemaining(),
  1794.                                         'companyAllowed' => $entry->getCompanyAllowed(),
  1795.                                     );
  1796.                                     $gocDataList[$entry->getId()] = $d;
  1797.                                     $gocDataListByAppId[$entry->getAppId()] = $d;
  1798.                                 }
  1799.                                 $debugCount 0;
  1800.                                 foreach ($gocDataList as $gocId => $entry) {
  1801.                                     $skipSend 1;
  1802.                                     $connector $this->container->get('application_connector');
  1803.                                     $connector->resetConnection(
  1804.                                         'default',
  1805.                                         $gocDataList[$gocId]['dbName'],
  1806.                                         $gocDataList[$gocId]['dbUser'],
  1807.                                         $gocDataList[$gocId]['dbPass'],
  1808.                                         $gocDataList[$gocId]['dbHost'],
  1809.                                         $reset true);
  1810.                                     $em $this->getDoctrine()->getManager();
  1811.                                     if ($userIds !== '_UNSET_')
  1812.                                         $users $this->getDoctrine()
  1813.                                             ->getRepository('ApplicationBundle:SysUser')
  1814.                                             ->findBy(
  1815.                                                 array(
  1816.                                                     'userId' => $userIds
  1817.                                                 )
  1818.                                             );
  1819.                                     else
  1820.                                         $users $this->getDoctrine()
  1821.                                             ->getRepository('ApplicationBundle:SysUser')
  1822.                                             ->findBy(
  1823.                                                 array()
  1824.                                             );
  1825.                                     $output '';
  1826.                                     $userData = array();
  1827.                                     $userFiles = array();
  1828.                                     foreach ($users as $user) {
  1829.                                         $file $this->container->getParameter('kernel.root_dir') . '/../web/' $user->getImage();
  1830.                                         if ($user->getImage() != '' && $user->getImage() != null && file_exists($file)) {
  1831.                                             $mime mime_content_type($file);
  1832.                                             $info pathinfo($file);
  1833.                                             $name $info['basename'];
  1834.                                             if (strpos($mime'image') !== false) {
  1835.                                                 $output = new \CURLFile($file$mime$name);
  1836.                                             }
  1837.                                             $skipSend 0;
  1838.                                             $userFiles['file_' $user->getUserAppId() . '_' $user->getUserId()] = $output;
  1839.                                         } else {
  1840.                                             $user->setImage(null);
  1841.                                             $userFiles['file_' $user->getUserAppId() . '_' $user->getUserId()] = 'pika';
  1842.                                             $em->flush();
  1843.                                         }
  1844.                                         $getters array_filter(get_class_methods($user), function ($method) {
  1845.                                             return 'get' === substr($method03);
  1846.                                         });
  1847.                                         $userDataSingle = array();
  1848.                                         foreach ($getters as $getter) {
  1849.                                             if ($getter == 'getCreatedAt' || $getter == 'getUpdatedAt' || $getter == 'getImage')
  1850.                                                 continue;
  1851. //                                if(is_string($user->{$getter}())|| is_numeric($user->{$getter}()))
  1852. //                                {
  1853. //                                    $userDataSingle[$getter]= $user->{$getter}();
  1854. //                                }
  1855.                                             if ($user->{$getter}() instanceof \DateTime) {
  1856.                                                 $ggtd $user->{$getter}();
  1857.                                                 $userDataSingle[$getter] = $ggtd->format('Y-m-d');
  1858.                                             } else
  1859.                                                 $userDataSingle[$getter] = $user->{$getter}();
  1860.                                         }
  1861. //                                                    $userDataSingle['getNid']=$Employee->getNid();
  1862. //                                                    $userDataSingle['getCurrAddr'] = $Employee->getCurrAddr();
  1863.                                         $userData[] = $userDataSingle;
  1864.                                     }
  1865.                                     $retDataDebug[$debugCount] = array(
  1866.                                         'skipSend' => $skipSend
  1867.                                     );
  1868.                                     {
  1869.                                         $urlToCall GeneralConstant::HONEYBEE_CENTRAL_SERVER '/SyncUserToCentralUser';
  1870.                                         $userFiles['userData'] = json_encode($userData);
  1871.                                         $curl curl_init();
  1872.                                         curl_setopt_array($curl, array(
  1873.                                             CURLOPT_RETURNTRANSFER => 1,
  1874.                                             CURLOPT_POST => 1,
  1875.                                             CURLOPT_URL => $urlToCall,
  1876.                                             CURLOPT_CONNECTTIMEOUT => 10,
  1877.                                             CURLOPT_SSL_VERIFYPEER => false,
  1878.                                             CURLOPT_SSL_VERIFYHOST => false,
  1879. //                            CURLOPT_SAFE_UPLOAD => false,
  1880.                                             CURLOPT_HTTPHEADER => array(//                                "Accept: multipart/form-data",
  1881.                                             ),
  1882.                                             //                        CURLOPT_USERAGENT => 'InnoPM',
  1883. //                            CURLOPT_POSTFIELDS => array(
  1884. //                                'userData'=>json_encode($userData),
  1885. //                                'userFiles'=>$userFiles
  1886. //                            ),
  1887.                                             CURLOPT_POSTFIELDS => $userFiles
  1888.                                         ));
  1889.                                         $retData curl_exec($curl);
  1890.                                         $errData curl_error($curl);
  1891.                                         curl_close($curl);
  1892.                                         $response = [];
  1893.                                         if ($errData) {
  1894.                                             $response['status'] = 'error';
  1895.                                             $response['message'] = 'cURL Error: ' $errData;
  1896.                                         } else {
  1897.                                             $retDataObj json_decode($retDatatrue);
  1898.                                             if (!$retDataObj) {
  1899.                                                 $response['status'] = 'error';
  1900.                                                 $response['message'] = 'Invalid response from central server';
  1901.                                                 $response['raw_response'] = $retData;
  1902.                                             } else {
  1903.                                                 $response['status'] = 'success';
  1904.                                                 $response['data'] = $retDataObj;
  1905.                                             }
  1906.                                         }
  1907. // Return JSON response
  1908. //                                                    return new JsonResponse($response);
  1909.                                         $retDataDebug[$debugCount] = $retDataObj;
  1910.                                         if (isset($retDataObj['globalIdsData']))
  1911.                                             foreach ($retDataObj['globalIdsData'] as $app_id => $usrList) {
  1912.                                                 $connector $this->container->get('application_connector');
  1913.                                                 $connector->resetConnection(
  1914.                                                     'default',
  1915.                                                     $gocDataListByAppId[$app_id]['dbName'],
  1916.                                                     $gocDataListByAppId[$app_id]['dbUser'],
  1917.                                                     $gocDataListByAppId[$app_id]['dbPass'],
  1918.                                                     $gocDataListByAppId[$app_id]['dbHost'],
  1919.                                                     $reset true);
  1920.                                                 $em $this->getDoctrine()->getManager();
  1921.                                                 foreach ($usrList as $sys_id => $globaldata) {
  1922.                                                     $user $this->getDoctrine()
  1923.                                                         ->getRepository('ApplicationBundle:SysUser')
  1924.                                                         ->findOneBy(
  1925.                                                             array(
  1926.                                                                 'userId' => $sys_id
  1927.                                                             )
  1928.                                                         );
  1929.                                                     if ($user) {
  1930.                                                         $user->setGlobalId($globaldata['gid']);
  1931.                                                         $em->persist($user);
  1932.                                                         $em->flush();
  1933.                                                     }
  1934.                                                 }
  1935.                                             }
  1936.                                     }
  1937.                                     $debugCount++;
  1938.                                 }
  1939.                             }
  1940. //                    return new JsonResponse($retDataDebug);
  1941.                         }
  1942.                     }
  1943. //                                    if($message[0]=='success'){
  1944. //                                        $SysUserRepo = $em->getRepository('ApplicationBundle:SysUser');
  1945. //                                        $SysUser = $SysUserRepo->findOneBy([
  1946. //                                            'email' => $data->request->get('email')
  1947. //                                        ]);
  1948. //
  1949. //                                        if ($SysUser === null) {
  1950. //                                            throw new \Exception("User with email " . $data->request->get('email') . " not found.");
  1951. //                                        }
  1952. //
  1953. //                                        $isSuccess->setUserId($SysUser->getUserId());
  1954. //                                        $em->persist($isSuccess);
  1955. //                                        $em->flush();
  1956. //                                    }
  1957.                     $companyData $message[2];
  1958.                     if ($message[0] == 'success' && GeneralConstant::EMAIL_ENABLED == 1) {
  1959.                         $bodyHtml '';
  1960.                         $bodyTemplate 'ApplicationBundle:email/user:registration.html.twig';
  1961.                         $bodyData = array(
  1962.                             'name' => $request->request->get('name'),
  1963.                             'companyData' => $companyData,
  1964.                             'userName' => $request->request->get('username'),
  1965.                             'password' => $request->request->get('password'),
  1966.                         );
  1967.                         $attachments = [];
  1968.                         $new_mail $this->get('mail_module');
  1969.                         $new_mail->sendMyMail(array(
  1970.                             'senderHash' => '_CUSTOM_',
  1971.                             //                        'senderHash'=>'_CUSTOM_',
  1972.                             'forwardToMailAddress' => $request->request->get('email'),
  1973.                             'fromAddress' => 'no-reply@ourhoneybee.eu',
  1974.                             'userName' => 'no-reply@ourhoneybee.eu',
  1975.                             'password' => 'Honeybee@0112',
  1976.                             'smtpServer' => 'smtp.hostinger.com',
  1977.                             'smtpPort' => 465,
  1978.                             'subject' => 'User Registration on HoneyBee Ecosystem under Entity ' $companyData->getName(),
  1979.                             'fileName' => '',
  1980.                             'attachments' => $attachments,
  1981.                             'toAddress' => $request->request->get('email'),
  1982.                             'mailTemplate' => $bodyTemplate,
  1983.                             'templateData' => $bodyData,
  1984.                             'embedCompanyImage' => 1,
  1985.                             'companyId' => $request->request->get('company'),
  1986.                             'companyImagePath' => $companyData->getImage()
  1987.                         ));
  1988.                     }
  1989.                 }
  1990.                 $this->addFlash(
  1991.                     'success',
  1992.                     'New Employee Successfully Added!'
  1993.                 );
  1994.                 return $this->redirectToRoute('add_employee');
  1995.             } else {
  1996. //                        $requiredFields = [
  1997. //                            'email', 'username', 'password', 'firstname', 'lastname', 'nid', 'dob',
  1998. //                            'sex', 'blood', 'phone', 'perm_addr', 'dept', 'desg', 'branch',
  1999. //                            'emp_type', 'tin'
  2000. //                        ];
  2001. //
  2002. //                        $missingFields = [];
  2003. //
  2004. //                        foreach ($requiredFields as $field) {
  2005. //                            if (!$data->request->get($field)) {
  2006. //                                $missingFields[] = $field;
  2007. //                            }
  2008. //                        }
  2009. //                        if (!empty($missingFields)) {
  2010. //                            $this->addFlash('error', 'Missing fields: ' . implode(', ', $missingFields));
  2011. //                            return $this->redirectToRoute('add_employee');
  2012. //                        }
  2013. //                        $password = $data->request->get('password');
  2014. //                        $passwordPattern = '/^(?=.*[A-Z])(?=.*[a-z])(?=.*\d)(?=.*[\W_]).{8,}$/';
  2015. //                        if (!preg_match($passwordPattern, $password)) {
  2016. //                            $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));
  2017. //                            return $this->redirectToRoute('add_employee');
  2018. //                        }
  2019.                 $CompanyId $this->getLoggedUserCompanyId($request);
  2020.                 $isSuccess HumanResource::StoreDataForAddEmployee($em$requestfalse$CompanyId);
  2021.                 if ($isSuccess) {
  2022.                     if ($request->request->has('send_appointment')) {
  2023.                         $email $request->request->get('email');
  2024.                         $bodyHtml '';
  2025.                         $bodyTemplate 'ApplicationBundle:email/general:appointment_letter_test.html.twig';
  2026.                         $bodyData = [];
  2027.                         $attachments = [];
  2028.                         $forwardToMailAddress $email;
  2029.                         $new_mail $this->get('mail_module');
  2030.                         $new_mail->sendMyMail(array(
  2031.                             'senderHash' => '_CUSTOM_',
  2032.                             'forwardToMailAddress' => $forwardToMailAddress,
  2033.                             'subject' => 'Appointment Letter',
  2034.                             'attachments' => $attachments,
  2035.                             'toAddress' => $forwardToMailAddress,
  2036.                             'fromAddress' => 'no-reply@ourhoneybee.eu',
  2037.                             'userName' => 'no-reply@ourhoneybee.eu',
  2038.                             'password' => 'Honeybee@0112',
  2039.                             'smtpServer' => 'smtp.hostinger.com',
  2040.                             'smtpPort' => 465,
  2041.                             'emailBody' => $bodyHtml,
  2042.                             'mailTemplate' => $bodyTemplate,
  2043.                             'templateData' => $bodyData,
  2044.                         ));
  2045.                     }
  2046.                     // Mailer function
  2047.                     if ($request->get("send_mail") && empty($request->get('sys_user'))) {
  2048.                         $message $this->get('user_module')->addNewUser(
  2049.                             $request->request->get('firstname') . " " $request->request->get('lastname'),
  2050.                             $request->request->get('email'),
  2051.                             $request->request->get('username'),
  2052.                             $request->request->get('password'),
  2053.                             $request->request->get('desg'),
  2054.                             $request->getLoggedUserLoginId($request),
  2055.                             $request->request->get('company'),
  2056.                             $request->request->get('user_type'),
  2057.                             $request->request->get('companyIdList'),
  2058.                             $request->request->get('branch'),
  2059.                             $request->request->get('supervisor'),
  2060.                             $request->request->get('default_route'),
  2061.                             $request->request->has('access_module') ? 0
  2062.                         );
  2063.                         if ($message[0] == 'success') {
  2064.                             if ($systemType == '_CENTRAL_') {
  2065.                             } else {
  2066.                                 $em_goc $this->getDoctrine()->getManager('company_group');
  2067.                                 $em_goc->getConnection()->connect();
  2068.                                 $connected $em_goc->getConnection()->isConnected();
  2069.                                 $gocDataList = [];
  2070.                                 $gocDataListByAppId = [];
  2071.                                 $retDataDebug = array();
  2072.                                 $appIds $message[2]->getAppId();
  2073.                                 $userIds $message[3]->getUserId();
  2074.                                 if ($connected) {
  2075.                                     $findByQuery = array(
  2076.                                         'active' => 1
  2077.                                     );
  2078.                                     if ($appIds !== '_UNSET_')
  2079.                                         $findByQuery['appId'] = $appIds;
  2080.                                     $gocList $this->getDoctrine()->getManager('company_group')
  2081.                                         ->getRepository("CompanyGroupBundle:CompanyGroup")
  2082.                                         ->findBy($findByQuery);
  2083.                                     foreach ($gocList as $entry) {
  2084.                                         $d = array(
  2085.                                             'name' => $entry->getName(),
  2086.                                             'id' => $entry->getId(),
  2087.                                             'image' => $entry->getImage(),
  2088.                                             'companyGroupHash' => $entry->getCompanyGroupHash(),
  2089.                                             'dbName' => $entry->getDbName(),
  2090.                                             'dbUser' => $entry->getDbUser(),
  2091.                                             'dbPass' => $entry->getDbPass(),
  2092.                                             'dbHost' => $entry->getDbHost(),
  2093.                                             'appId' => $entry->getAppId(),
  2094.                                             'companyRemaining' => $entry->getCompanyRemaining(),
  2095.                                             'companyAllowed' => $entry->getCompanyAllowed(),
  2096.                                         );
  2097.                                         $gocDataList[$entry->getId()] = $d;
  2098.                                         $gocDataListByAppId[$entry->getAppId()] = $d;
  2099.                                     }
  2100.                                     $debugCount 0;
  2101.                                     foreach ($gocDataList as $gocId => $entry) {
  2102.                                         $skipSend 1;
  2103.                                         $connector $this->container->get('application_connector');
  2104.                                         $connector->resetConnection(
  2105.                                             'default',
  2106.                                             $gocDataList[$gocId]['dbName'],
  2107.                                             $gocDataList[$gocId]['dbUser'],
  2108.                                             $gocDataList[$gocId]['dbPass'],
  2109.                                             $gocDataList[$gocId]['dbHost'],
  2110.                                             $reset true);
  2111.                                         $em $this->getDoctrine()->getManager();
  2112.                                         if ($userIds !== '_UNSET_')
  2113.                                             $users $this->getDoctrine()
  2114.                                                 ->getRepository('ApplicationBundle:SysUser')
  2115.                                                 ->findBy(
  2116.                                                     array(
  2117.                                                         'userId' => $userIds
  2118.                                                     )
  2119.                                                 );
  2120.                                         else
  2121.                                             $users $this->getDoctrine()
  2122.                                                 ->getRepository('ApplicationBundle:SysUser')
  2123.                                                 ->findBy(
  2124.                                                     array()
  2125.                                                 );
  2126.                                         $output '';
  2127.                                         $userData = array();
  2128.                                         $userFiles = array();
  2129.                                         foreach ($users as $user) {
  2130.                                             $file $this->container->getParameter('kernel.root_dir') . '/../web/' $user->getImage();
  2131.                                             if ($user->getImage() != '' && $user->getImage() != null && file_exists($file)) {
  2132.                                                 $mime mime_content_type($file);
  2133.                                                 $info pathinfo($file);
  2134.                                                 $name $info['basename'];
  2135.                                                 if (strpos($mime'image') !== false) {
  2136.                                                     $output = new \CURLFile($file$mime$name);
  2137.                                                 }
  2138.                                                 $skipSend 0;
  2139.                                                 $userFiles['file_' $user->getUserAppId() . '_' $user->getUserId()] = $output;
  2140.                                             } else {
  2141.                                                 $user->setImage(null);
  2142.                                                 $userFiles['file_' $user->getUserAppId() . '_' $user->getUserId()] = 'pika';
  2143.                                                 $em->flush();
  2144.                                             }
  2145.                                             $getters array_filter(get_class_methods($user), function ($method) {
  2146.                                                 return 'get' === substr($method03);
  2147.                                             });
  2148.                                             $userDataSingle = array();
  2149.                                             foreach ($getters as $getter) {
  2150.                                                 if ($getter == 'getCreatedAt' || $getter == 'getUpdatedAt' || $getter == 'getImage')
  2151.                                                     continue;
  2152. //                                if(is_string($user->{$getter}())|| is_numeric($user->{$getter}()))
  2153. //                                {
  2154. //                                    $userDataSingle[$getter]= $user->{$getter}();
  2155. //                                }
  2156.                                                 if ($user->{$getter}() instanceof \DateTime) {
  2157.                                                     $ggtd $user->{$getter}();
  2158.                                                     $userDataSingle[$getter] = $ggtd->format('Y-m-d');
  2159.                                                 } else
  2160.                                                     $userDataSingle[$getter] = $user->{$getter}();
  2161.                                             }
  2162. //                                                    $userDataSingle['getNid']=$Employee->getNid();
  2163. //                                                    $userDataSingle['getCurrAddr'] = $Employee->getCurrAddr();
  2164.                                             $userData[] = $userDataSingle;
  2165.                                         }
  2166.                                         $retDataDebug[$debugCount] = array(
  2167.                                             'skipSend' => $skipSend
  2168.                                         );
  2169.                                         {
  2170.                                             $urlToCall GeneralConstant::HONEYBEE_CENTRAL_SERVER '/SyncUserToCentralUser';
  2171.                                             $userFiles['userData'] = json_encode($userData);
  2172.                                             $curl curl_init();
  2173.                                             curl_setopt_array($curl, array(
  2174.                                                 CURLOPT_RETURNTRANSFER => 1,
  2175.                                                 CURLOPT_POST => 1,
  2176.                                                 CURLOPT_URL => $urlToCall,
  2177.                                                 CURLOPT_CONNECTTIMEOUT => 10,
  2178.                                                 CURLOPT_SSL_VERIFYPEER => false,
  2179.                                                 CURLOPT_SSL_VERIFYHOST => false,
  2180. //                            CURLOPT_SAFE_UPLOAD => false,
  2181.                                                 CURLOPT_HTTPHEADER => array(//                                "Accept: multipart/form-data",
  2182.                                                 ),
  2183.                                                 //                        CURLOPT_USERAGENT => 'InnoPM',
  2184. //                            CURLOPT_POSTFIELDS => array(
  2185. //                                'userData'=>json_encode($userData),
  2186. //                                'userFiles'=>$userFiles
  2187. //                            ),
  2188.                                                 CURLOPT_POSTFIELDS => $userFiles
  2189.                                             ));
  2190.                                             $retData curl_exec($curl);
  2191.                                             $errData curl_error($curl);
  2192.                                             curl_close($curl);
  2193.                                             $response = [];
  2194.                                             if ($errData) {
  2195.                                                 $response['status'] = 'error';
  2196.                                                 $response['message'] = 'cURL Error: ' $errData;
  2197.                                             } else {
  2198.                                                 $retDataObj json_decode($retDatatrue);
  2199.                                                 if (!$retDataObj) {
  2200.                                                     $response['status'] = 'error';
  2201.                                                     $response['message'] = 'Invalid response from central server';
  2202.                                                     $response['raw_response'] = $retData;
  2203.                                                 } else {
  2204.                                                     $response['status'] = 'success';
  2205.                                                     $response['data'] = $retDataObj;
  2206.                                                 }
  2207.                                             }
  2208. // Return JSON response
  2209. //                                                    return new JsonResponse($response);
  2210.                                             $retDataDebug[$debugCount] = $retDataObj;
  2211.                                             if (isset($retDataObj['globalIdsData']))
  2212.                                                 foreach ($retDataObj['globalIdsData'] as $app_id => $usrList) {
  2213.                                                     $connector $this->container->get('application_connector');
  2214.                                                     $connector->resetConnection(
  2215.                                                         'default',
  2216.                                                         $gocDataListByAppId[$app_id]['dbName'],
  2217.                                                         $gocDataListByAppId[$app_id]['dbUser'],
  2218.                                                         $gocDataListByAppId[$app_id]['dbPass'],
  2219.                                                         $gocDataListByAppId[$app_id]['dbHost'],
  2220.                                                         $reset true);
  2221.                                                     $em $this->getDoctrine()->getManager();
  2222.                                                     foreach ($usrList as $sys_id => $globaldata) {
  2223.                                                         $user $this->getDoctrine()
  2224.                                                             ->getRepository('ApplicationBundle:SysUser')
  2225.                                                             ->findOneBy(
  2226.                                                                 array(
  2227.                                                                     'userId' => $sys_id
  2228.                                                                 )
  2229.                                                             );
  2230.                                                         if ($user) {
  2231.                                                             $user->setGlobalId($globaldata['gid']);
  2232.                                                             $em->persist($user);
  2233.                                                             $em->flush();
  2234.                                                         }
  2235.                                                     }
  2236.                                                 }
  2237.                                         }
  2238.                                         $debugCount++;
  2239.                                     }
  2240.                                 }
  2241. //                    return new JsonResponse($retDataDebug);
  2242.                             }
  2243.                         }
  2244.                         $SysUserRepo $em->getRepository(SysUser::class);
  2245.                         $SysUser $SysUserRepo->findOneBy(array(
  2246.                             'email' => $request->request->get('email')
  2247.                         ));
  2248.                         $isSuccess->setUserId($SysUser->getUserId());
  2249.                         $em->persist($isSuccess);
  2250.                         $em->flush();
  2251.                         $companyData $message[2];
  2252.                         if ($message[0] == 'success' && GeneralConstant::EMAIL_ENABLED == 1) {
  2253.                             $bodyHtml '';
  2254.                             $bodyTemplate 'ApplicationBundle:email/user:registration.html.twig';
  2255.                             $bodyData = array(
  2256.                                 'name' => $request->request->get('name'),
  2257.                                 'companyData' => $companyData,
  2258.                                 'userName' => $request->request->get('username'),
  2259.                                 'password' => $request->request->get('password'),
  2260.                             );
  2261.                             $attachments = [];
  2262. //                    $upl_dir = $this->container->getParameter('kernel.root_dir') . '/../web/uploads/temp/' . 'ledger' . '.pdf'
  2263.                             $new_mail $this->get('mail_module');
  2264.                             $new_mail->sendMyMail(array(
  2265.                                 'senderHash' => '_CUSTOM_',
  2266.                                 //                        'senderHash'=>'_CUSTOM_',
  2267.                                 'forwardToMailAddress' => $request->request->get('email'),
  2268.                                 'subject' => 'User Registration on HoneyBee Ecosystem under Entity ' $companyData->getName(),
  2269.                                 'fileName' => '',
  2270.                                 'attachments' => $attachments,
  2271.                                 'toAddress' => $request->request->get('email'),
  2272.                                 'fromAddress' => 'no-reply@ourhoneybee.eu',
  2273.                                 'userName' => 'no-reply@ourhoneybee.eu',
  2274.                                 'password' => 'Y41dh8g0112',
  2275.                                 'smtpServer' => 'smtp.hostinger.com',
  2276.                                 'smtpPort' => 465,
  2277. //                        'fromAddress'=>'sales@entity.innobd.com',
  2278. //                        'userName'=>'sales@entity.innobd.com',
  2279. //                        'password'=>'Y41dh8g0112',
  2280. //                        'smtpServer'=>'smtp.hostinger.com',
  2281. //                        'smtpPort'=>587,
  2282. //                        'emailBody'=>$bodyHtml,
  2283.                                 'mailTemplate' => $bodyTemplate,
  2284.                                 'templateData' => $bodyData,
  2285.                                 'embedCompanyImage' => 1,
  2286.                                 'companyId' => $request->request->get('company'),
  2287.                                 'companyImagePath' => $companyData->getImage()
  2288.                             ));
  2289. //                  $emailmessage = (new \Swift_Message('Registration to Entity'))
  2290. //                    ->setFrom('registration@entity.innobd.com')
  2291. //                    ->setTo($data->request->get('email'))
  2292. //                    ->setBody(
  2293. //                      $this->renderView(
  2294. //                        'ApplicationBundle:email/user:registration.html.twig',
  2295. //                        array(
  2296. //                          'name' => $data->request->get('name'),
  2297. //                          'companyData' => $companyData,
  2298. //                          'userName' => $data->request->get('email'),
  2299. //                          'password' => $data->request->get('password'),
  2300. //                        )
  2301. //                      ),
  2302. //                      'text/html'
  2303. //                    );
  2304. //                  $this->get('mailer')->send($emailmessage);
  2305.                         }
  2306.                     }
  2307.                     // End Mailer function
  2308.                     $this->addFlash(
  2309.                         'success',
  2310.                         'New Employee Successfully Added!'
  2311.                     );
  2312.                     return $this->redirectToRoute('employee_list');
  2313.                 } else {
  2314.                     $this->addFlash(
  2315.                         'error',
  2316.                         'Something Went Wrong!'
  2317.                     );
  2318.                     return $this->redirectToRoute('add_employee');
  2319.                 }
  2320.             }
  2321.         } else {
  2322.             $this->addFlash(
  2323.                 'error',
  2324.                 'Invalid Approval Hash!'
  2325.             );
  2326.             return $this->redirectToRoute('add_employee');
  2327.         }
  2328.     }
  2329.     public function UpdateEmployeeAction(Request $request$id)
  2330.     {
  2331.     }
  2332.     private function uploadImage($image$request)
  2333.     {
  2334.         $upl_dir $this->container->getParameter('kernel.root_dir') . '/../web/uploads/Users/';
  2335.         $profileImage '';
  2336.         if ($image != null) {
  2337.             $fileName $request->request->get('firstname') . '.' $request->request->get('global_user_id') . '.' $image->guessExtension();
  2338.             $path $fileName;
  2339.             if (!file_exists($upl_dir)) {
  2340.                 mkdir($upl_dir0777true);
  2341.             }
  2342.             $image->move($upl_dir$path);
  2343.             $profileImage 'uploads/Users/' $path;
  2344.         }
  2345.         return $profileImage;
  2346.     }
  2347.     private function uploadMeetingFile($file$request)
  2348.     {
  2349.         $upl_dir $this->container->getParameter('kernel.root_dir') . '/../web/uploads/meeting/';
  2350.         $uploadedFilePath '';
  2351.         if ($file != null) {
  2352.             $fileName uniqid() . '.' $file->guessExtension();
  2353.             if (!file_exists($upl_dir)) {
  2354.                 mkdir($upl_dir0777true);
  2355.             }
  2356.             $file->move($upl_dir$fileName);
  2357.             $uploadedFilePath 'uploads/meeting/' $fileName;
  2358.         }
  2359.         return $uploadedFilePath;
  2360.     }
  2361.     public function OnboardEmployeeAction(Request $request)
  2362.     {
  2363.         $systemType $this->container->hasParameter('system_type') ? $this->container->getParameter('system_type') : '_ERP_';
  2364.         $email $request->request->get('email');
  2365.         $applicantId $request->request->get('applicant_id');
  2366.         $em $this->getDoctrine()->getManager();
  2367.         $session $request->getSession();
  2368.         $companyId $session->get('userCompanyId');
  2369.         $appId $session->get('userAppId');
  2370.         $urlToCall GeneralConstant::HONEYBEE_CENTRAL_SERVER '/get_applicant_data_central';
  2371.         $applicantFiles = [
  2372.             'email' => $email,
  2373.             'applicantId' => $applicantId
  2374.         ];
  2375.         $entityToken $em->getRepository('ApplicationBundle:EntityTokenStorage')
  2376.             ->findOneBy(['userId' => $applicantId]);
  2377.         $curl curl_init();
  2378.         curl_setopt_array($curl, array(
  2379.             CURLOPT_RETURNTRANSFER => 1,
  2380.             CURLOPT_POST => 1,
  2381.             CURLOPT_URL => $urlToCall,
  2382.             CURLOPT_CONNECTTIMEOUT => 10,
  2383.             CURLOPT_SSL_VERIFYPEER => false,
  2384.             CURLOPT_SSL_VERIFYHOST => false,
  2385.             CURLOPT_HTTPHEADER => array(),
  2386.             CURLOPT_POSTFIELDS => $applicantFiles
  2387.         ));
  2388.         $retData curl_exec($curl);
  2389.         $errData curl_error($curl);
  2390.         curl_close($curl);
  2391.         $retDataObj json_decode($retDatatrue);
  2392.         if (!isset($retDataObj['status']) || $retDataObj['status'] !== 'success') {
  2393.             return new JsonResponse([
  2394.                 'status' => 'error',
  2395.                 'message' => 'Failed to get applicant data from central server',
  2396.                 'response' => $retDataObj
  2397.             ]);
  2398.         }
  2399.         $centralData $retDataObj['centralData'];
  2400.         $em $this->getDoctrine()->getManager();
  2401.         $existingUser $em->getRepository('ApplicationBundle:SysUser')->findOneBy([
  2402.             'globalId' => $centralData['globalId']
  2403.         ]);
  2404.         if ($existingUser) {
  2405.             return new JsonResponse([
  2406.                 'status' => 'info',
  2407.                 'message' => 'User is already onboarded',
  2408.                 'userId' => $existingUser->getUserId(),
  2409.                 'redirectUrl' => 'dashboard'
  2410.             ]);
  2411.         }
  2412.         $sysUser = new SysUser();
  2413.         $sysUser->setGlobalId($centralData['globalId'] ?? '');
  2414.         $sysUser->setUsername($centralData['username'] ?? '');
  2415.         $sysUser->setEmail($centralData['email'] ?? '');
  2416.         $sysUser->setName($centralData['firstname'] ?? '');
  2417.         $sysUser->setUserType(1);
  2418.         $sysUser->setUserAppId($appId);
  2419.         $sysUser->setUserCompanyId($companyId);
  2420.         $sysUser->setStatus(1);
  2421.         $sysUser->setDefaultRoute('sales_dashboard');
  2422.         $em->persist($sysUser);
  2423.         $em->flush();
  2424.         $employee $em->getRepository('ApplicationBundle:Employee')
  2425.             ->findOneBy(
  2426.                 array(
  2427.                     'userId' => $sysUser->getUserId(),
  2428.                 )
  2429.             );
  2430.         if (!$employee) {
  2431.             $employee = new Employee();
  2432.             if ($sysUser->getUserId()) {
  2433.                 $employee->setEmail($sysUser->getEmail());
  2434.                 $employee->setFirstName($sysUser->getUsername());
  2435.                 $employee->setLastName($sysUser->getName());
  2436.                 $employee->setCompanyId($sysUser->getUserCompanyId());
  2437.                 $employee->setStatus(1);
  2438.                 $employee->setUserId($sysUser->getUserId());
  2439.                 $em->persist($employee);
  2440.                 $em->flush();
  2441.             } else {
  2442.                 return new JsonResponse([
  2443.                     'status' => 'error',
  2444.                     'message' => 'Missing employee data',
  2445.                 ]);
  2446.             }
  2447.         }
  2448.         $employeeDetails $em->getRepository('ApplicationBundle:EmployeeDetails')
  2449.             ->findOneBy([
  2450.                 'userId' => $sysUser->getUserId(),
  2451.             ]);
  2452.         if (!$employeeDetails) {
  2453.             $employeeDetails = new EmployeeDetails();
  2454.             if ($sysUser->getUserId() && $employee->getEmployeeId()) {
  2455.                 $employeeDetails->setId($employee->getEmployeeId());
  2456.                 $employeeDetails->setEmail($sysUser->getEmail());
  2457.                 $employeeDetails->setFirstName($sysUser->getUsername());
  2458.                 $employeeDetails->setLastName($sysUser->getName());
  2459.                 $employeeDetails->setUsername($sysUser->getUsername());
  2460.                 $employeeDetails->setUserId($sysUser->getUserId());
  2461.                 $employeeDetails->setEmpStatus(1);
  2462.                 $em->persist($employeeDetails);
  2463.                 $em->flush();
  2464.             } else {
  2465.                 return new JsonResponse([
  2466.                     'status' => 'error',
  2467.                     'message' => 'Missing employee details data',
  2468.                 ]);
  2469.             }
  2470.         }
  2471.         $company $em->getRepository('ApplicationBundle:Company')->find($companyId);
  2472.         $companyName $company $company->getName() : '';
  2473.         $newAccess = [
  2474.             'userType' => 2,
  2475.             'userTypeName' => UserConstants::$userTypeName[2],
  2476.             'globalId' => $applicantId,
  2477.             'serverId' => 1,
  2478.             'serverUrl' => $request->getSchemeAndHttpHost(),
  2479.             'serverPort' => 80,
  2480.             'systemType' => '_ERP_',
  2481.             'companyId' => 1,
  2482.             'appId' => $appId,
  2483.             'companyLogoUrl' => '/uploads/CompanyImage/company_image' $request->request->get('appId') . '.png',
  2484.             'companyName' => $companyName,
  2485.             'authenticationStr' => $this->get('url_encryptor')->encrypt(json_encode(
  2486.                     array(
  2487.                         'globalId' => $applicantId,
  2488.                         'appId' => $appId,
  2489.                         'authenticate' => 1,
  2490.                         'userType' => 2,
  2491.                         'userTypeName' => UserConstants::$userTypeName[2]
  2492.                     )
  2493.                 )
  2494.             ),
  2495.             'userCompanyList' => [],
  2496.         ];
  2497.         $urlToCall GeneralConstant::HONEYBEE_CENTRAL_SERVER '/update_token_storage';
  2498.         $curl curl_init();
  2499.         curl_setopt_array($curl, array(
  2500.             CURLOPT_RETURNTRANSFER => 1,
  2501.             CURLOPT_POST => 1,
  2502.             CURLOPT_URL => $urlToCall,
  2503.             CURLOPT_CONNECTTIMEOUT => 10,
  2504.             CURLOPT_SSL_VERIFYPEER => false,
  2505.             CURLOPT_SSL_VERIFYHOST => false,
  2506.             CURLOPT_HTTPHEADER => array(),
  2507.             CURLOPT_POSTFIELDS => json_encode($newAccess)
  2508.         ));
  2509.         $retData curl_exec($curl);
  2510.         $errData curl_error($curl);
  2511.         return new JsonResponse([
  2512.             'status' => 'success',
  2513.             'message' => 'User onboarded successfully',
  2514.             'redirectUlr' => 'dashboard',
  2515.             'returnData' => $retData,
  2516.             'errorData' => $errData
  2517.         ]);
  2518.     }
  2519.     public function DecodeQrAction(Request $request)
  2520.     {
  2521.         $applicantId $request->request->get('applicant_id');
  2522.         $urlToCall GeneralConstant::HONEYBEE_CENTRAL_SERVER '/get_applicant_data_central';
  2523.         $applicantFiles = [
  2524.             'applicantId' => $applicantId
  2525.         ];
  2526.         $curl curl_init();
  2527.         curl_setopt_array($curl, array(
  2528.             CURLOPT_RETURNTRANSFER => 1,
  2529.             CURLOPT_POST => 1,
  2530.             CURLOPT_URL => $urlToCall,
  2531.             CURLOPT_CONNECTTIMEOUT => 10,
  2532.             CURLOPT_SSL_VERIFYPEER => false,
  2533.             CURLOPT_SSL_VERIFYHOST => false,
  2534.             CURLOPT_HTTPHEADER => array(),
  2535.             CURLOPT_POSTFIELDS => $applicantFiles
  2536.         ));
  2537.         $retData curl_exec($curl);
  2538.         $errData curl_error($curl);
  2539.         curl_close($curl);
  2540.         $retDataObj json_decode($retDatatrue);
  2541.         return new JsonResponse($retDataObj['centralData']);
  2542.     }
  2543.     public function GetApplicantDataForErpAction(Request $request)
  2544.     {
  2545.         $applicantId $request->request->get('applicantId');
  2546.         if (!$applicantId) {
  2547.             return new JsonResponse([
  2548.                 'status' => 'error',
  2549.                 'message' => 'Missing applicantId in request.'
  2550.             ]);
  2551.         }
  2552.         $em_goc $this->getDoctrine()->getManager('company_group');
  2553.         $entityApplicant $em_goc->getRepository("CompanyGroupBundle:EntityApplicantDetails")
  2554.             ->findOneBy(['applicantId' => $applicantId]);
  2555.         if (!$entityApplicant) {
  2556.             return new JsonResponse([
  2557.                 'status' => 'error',
  2558.                 'message' => 'Applicant not found.'
  2559.             ]);
  2560.         }
  2561.         return new JsonResponse([
  2562.             'status' => 'success',
  2563.             'centralData' => [
  2564.                 'globalId' => $entityApplicant->getApplicantId(),
  2565.                 'username' => $entityApplicant->getUsername(),
  2566.                 'email' => $entityApplicant->getEmail(),
  2567.                 'firstname' => $entityApplicant->getFirstname(),
  2568.                 'lastname' => $entityApplicant->getLastname(),
  2569.                 'image' => $entityApplicant->getImage(),
  2570.                 'phone' => $entityApplicant->getPhone(),
  2571.                 'address' => $entityApplicant->getPermAddr()
  2572.             ]
  2573.         ]);
  2574.     }
  2575.     public function UpdateTokenStorageAction(Request $request)
  2576.     {
  2577.         $em_goc $this->getDoctrine()->getManager('company_group');
  2578.         $newAccess $request->request->all();
  2579.         $appId = isset($newAccess['appId']) ? $newAccess['appId'] : null;
  2580.         $globalId = isset($newAccess['globalId']) ? $newAccess['globalId'] : null;
  2581.         $sesssionData MiscActions::UpdateCompanyListInSession(
  2582.             $em_goc,
  2583.             $globalId,
  2584.             1,
  2585.             1,
  2586.             1,
  2587.             $newAccess
  2588.         );
  2589.         return new JsonResponse([
  2590.             'status' => 'success',
  2591.             'message' => 'Token storage updated',
  2592.             'newaccess' => $newAccess
  2593.         ]);
  2594.     }
  2595.     public function EmployeeListAction(Request $data)
  2596.     {
  2597.         $em $this->getDoctrine()->getManager();
  2598.         if ($data->isMethod('GET')) {
  2599.             return $this->render("ApplicationBundle:pages/human_resource/list:list_employee.html.twig", array(
  2600.                 'page_title' => 'Employee List',
  2601.             ));
  2602.         }
  2603.     }
  2604.     public function OrganizationChartAction()
  2605.     {
  2606.         $em $this->getDoctrine()->getManager();
  2607.         $Reponse HumanResource::TwigDataForOrgChart($em);
  2608.         return $this->render('ApplicationBundle:pages/human_resource/views:org_chart.html.twig', array(
  2609.             'page_title' => 'Organization Chart',
  2610.             'supervisors' => $Reponse['TreantJsData'],
  2611.             'alluser' => $Reponse['TreantJsInitUser']
  2612.         ));
  2613.     }
  2614.     public function EmployeeListSelectizeAjaxAction(Request $request$str '_EMPTY_')
  2615.     {
  2616.         $em $this->getDoctrine()->getManager();
  2617.         $companyId $this->getLoggedUserCompanyId($request);
  2618.         $company_data Company::getCompanyData($em$companyId);
  2619.         $data = [];
  2620.         $html '';
  2621.         $qryStrs explode(' '$str);
  2622.         $qryStrAddedForSpacedName "";
  2623.         if ($str == '_EMPTY_') {
  2624.             $query "SELECT *
  2625. from  employee  order by employee_id asc limit 10";
  2626.         } else {
  2627.             foreach ($qryStrs as $qryStr) {
  2628.                 $qryStrAddedForSpacedName .= "or first_name like '%$qryStr%' or last_name like '%$qryStr%' ";
  2629.             }
  2630.             $query "SELECT  *
  2631. 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";
  2632.         }
  2633.         $stmt $em->getConnection()->prepare($query);
  2634.         $stmt->execute();
  2635.         $res $stmt->fetchAll();
  2636. //    if(!empty($res)) {
  2637.         foreach ($res as $i => $r) {
  2638.             $res[$i]['id_padded'] = str_pad($r['employee_id'], 8'0'STR_PAD_LEFT);
  2639.         }
  2640. //    }
  2641.         return new JsonResponse(
  2642.             array(
  2643.                 'success' => true,
  2644.                 'data' => $res,
  2645.             )
  2646.         );
  2647.     }
  2648.     public function AttendanceAction(Request $data$remoteVerify 0)
  2649.     {
  2650.         $em $this->getDoctrine()->getManager();
  2651.         $em_goc $this->getDoctrine()->getManager('company_group');
  2652.         $session $data->getSession();
  2653. //        $token = $session->get(UserConstants::USER_TOKEN);
  2654. //        $providedToken = $data->headers->get('auth-token');
  2655. //
  2656. //        if (empty($providedToken) || $providedToken !== $token) {
  2657. //            return new JsonResponse([
  2658. //                'status' => 'error',
  2659. //                'message' => 'Token not match or missing',
  2660. //            ], 401);
  2661. //        }
  2662.         $workHourPolicy $em->getRepository('ApplicationBundle:WorkHourPolicy')->findAll();
  2663.         $options = array(
  2664.             'notification_enabled' => $this->container->getParameter('notification_enabled'),
  2665.             'notification_server' => $this->container->getParameter('notification_server'),
  2666.         );
  2667.         if ($data->get('DataTable')) {
  2668.             $response HumanResource::HandelAjaxRequestForManualAttendance($em$data);
  2669.             return new JsonResponse($response);
  2670.         }
  2671.         if ($data->request->get('getAttendanceStatus')) {
  2672.             $response HumanResource::getAttendanceStatus($em$data);
  2673.             return new JsonResponse($response);
  2674.         }
  2675. //        if ($session->get('devAdminMode', 0) != 1 && $data->get('returnJson', 0) == 0)
  2676. //            return $this->redirectToRoute('permission_denied_page');
  2677.         // Auto attendance
  2678.         if ($data->get('autoAttendance') && $data->request->has('position_array')) {
  2679. //            $empId = $data->query->get('id');
  2680.             $empId $data->request->get('id'$session->get(UserConstants::USER_EMPLOYEE_ID));
  2681.             $positionsArray $data->request->get('position_array', []);
  2682.             if (is_string($positionsArray)) $positionsArray json_decode($positionsArraytrue);
  2683.             if ($positionsArray == null$positionsArray = [];
  2684.             $dataByAttId = [];
  2685.             $workPlaceType '_UNSET_';
  2686.             foreach ($positionsArray as $d) {
  2687.                 $sysUserId 0;
  2688.                 $userId 0;
  2689.                 $empId 0;
  2690.                 $dtTs 0;
  2691.                 $timeZoneStr '+0000';
  2692. //                $timeZoneStr = '+0600';
  2693.                 $token '_unset_';
  2694.                 if (isset($d['token'])) $token $d['token'];
  2695.                 if (isset($d['employeeId'])) $empId $d['employeeId'];
  2696.                 if (isset($d['userId'])) $userId $d['userId'];
  2697.                 if (isset($d['sysUserId'])) $sysUserId $d['sysUserId'];
  2698.                 if (isset($d['tsMilSec'])) {
  2699.                     $dtTs ceil(($d['tsMilSec']) / 1000);
  2700.                 }
  2701.                 if ($token != '_unset_') {
  2702.                     $sessionData MiscActions::GetSessionDataFromToken($em_goc$token)['sessionData'];
  2703.                     if (isset($sessionData[UserConstants::USER_EMPLOYEE_ID]))
  2704.                         $empId $sessionData[UserConstants::USER_EMPLOYEE_ID];
  2705.                 }
  2706.                 if ($sysUserId == 0)
  2707.                     $sysUserId $userId;
  2708.                 if ($sysUserId == 0)
  2709.                     $sysUserId $em->getRepository(Employee::class)
  2710.                         ->findOneBy(['employeeId' => $empId])->getUserId();
  2711.                 if ($dtTs == 0) {
  2712.                     $currTsTime = new \DateTime();
  2713.                     $dtTs $currTsTime->format('U');
  2714.                 } else {
  2715.                     $currTsTime = new \DateTime('@' $dtTs);
  2716.                 }
  2717.                 $currTsTime->setTimezone(new \DateTimeZone('UTC'));
  2718.                 $attDate = new \DateTime($currTsTime->format('Y-m-d') . ' 00:00:00' $timeZoneStr);
  2719.                 $EmployeeAttendance $this->getDoctrine()
  2720.                     ->getRepository(EmployeeAttendance::class)
  2721.                     ->findOneBy(array('employeeId' => $empId'date' => $attDate));
  2722.                 if (!$EmployeeAttendance)
  2723.                     $EmployeeAttendance = new EmployeeAttendance;
  2724.                 $attendanceInfo HumanResource::StoreAttendance($em$empId$sysUserId$data$EmployeeAttendance$attDate$dtTs$timeZoneStr$d['markerId']);
  2725.                 if ($d['markerId'] == HumanResourceConstant::ATTENDANCE_MARKER_CLOCK_IN) {
  2726.                     if ($empId == 24)
  2727.                         $workPlaceType '_HYBRID_';
  2728.                     else
  2729.                         $workPlaceType '_STATIC_';
  2730.                 }
  2731.                 if (!isset($dataByAttId[$attendanceInfo->getId()]))
  2732.                     $dataByAttId[$attendanceInfo->getId()] = array(
  2733.                         'attendanceInfo' => $attendanceInfo,
  2734.                         'empId' => $empId,
  2735.                         'lat' => 0,
  2736.                         'lng' => 0,
  2737.                         'address' => 0,
  2738.                         'sysUserId' => $sysUserId,
  2739.                         'companyId' => $data->getSession()->get(UserConstants::USER_COMPANY_ID),
  2740.                         'appId' => $data->getSession()->get(UserConstants::USER_APP_ID),
  2741.                         'positionArray' => []
  2742.                     );
  2743.                 $posData = array(
  2744.                     'ts' => $dtTs,
  2745.                     'lat' => $d['lat'],
  2746.                     'lng' => $d['lng'],
  2747.                     'marker' => $d['markerId'],
  2748.                     'src' => 2,
  2749.                 );
  2750.                 $posDataArray = array(
  2751.                     $dtTs,
  2752.                     $d['lat'],
  2753.                     $d['lng'],
  2754.                     $d['markerId'],
  2755.                     2
  2756.                 );
  2757.                 $dataByAttId[$attendanceInfo->getId()]['markerId'] = $d['markerId'];
  2758.                 //this markerId will be calclulted and modified to check if user is in our out of office/workplace later
  2759.                 $dataByAttId[$attendanceInfo->getId()]['attendanceInfo'] = $attendanceInfo;
  2760.                 $dataByAttId[$attendanceInfo->getId()]['positionArray'][] = $posData;
  2761.                 $dataByAttId[$attendanceInfo->getId()]['lat'] = $d['lat'];  //for last lat lng etc
  2762.                 $dataByAttId[$attendanceInfo->getId()]['lng'] = $d['lng'];  //for last lat lng etc
  2763.                 if (isset($d['address']))
  2764.                     $dataByAttId[$attendanceInfo->getId()]['address'] = $d['address'];  //for last lat lng etc
  2765. //                $dataByAttId[$attendanceInfo->getId()]['positionArray'][]=$posDataArray;
  2766.             }
  2767.             $response = array(
  2768.                 'success' => true,
  2769.             );
  2770.             foreach ($dataByAttId as $attInfoId => $d) {
  2771.                 $response HumanResource::setAttendanceLogFlutterApp($em,
  2772.                     $d['empId'],
  2773.                     $d['sysUserId'],
  2774.                     $d['companyId'],
  2775.                     $d['appId'],
  2776.                     $data,
  2777.                     $d['attendanceInfo'],
  2778.                     $options,
  2779.                     $d['positionArray'],
  2780.                     $d['lat'],
  2781.                     $d['lng'],
  2782.                     $d['address'],
  2783.                     $d['markerId']
  2784.                 );
  2785.             }
  2786.             if ($data->request->get('requestFromMobile')) {
  2787.                 $today = new \DateTime(date('y-m-d'));
  2788.                 $repository $this->getDoctrine()->getRepository(EmployeeAttendance::class);
  2789.                 $ActivitiesTemplate HumanResource::getCurrentStatusFromDb($repository$empId$today);
  2790.                 return new JsonResponse(array(
  2791.                     'success' => $response['success'] == true true false,
  2792.                     'msg' => $response['success'] == true 'Employee activities successfully updated.' 'Action Failed',
  2793.                     'workPlaceType' => $workPlaceType,
  2794.                     'data' => $ActivitiesTemplate
  2795.                 ));
  2796.             }
  2797.             return new JsonResponse(
  2798.                 array(
  2799.                     'success' => true,
  2800.                     'msg' => 'Employee activities successfully updated.',
  2801.                     'workPlaceType' => $workPlaceType,
  2802.                 )
  2803.             );
  2804.         } else if ($data->get('autoAttendance')) {
  2805.             $sysUserId 0;
  2806.             $userId 0;
  2807.             $empId 0;
  2808.             $dtTs 0;
  2809. //            $timeZoneStr = '+0600';
  2810.             $timeZoneStr '+0000';
  2811.             if ($data->request->get('requestFromMobile')) {
  2812.                 $empId $data->request->get('employeeId');
  2813.                 $userId $data->request->get('userId'0);
  2814.                 $sysUserId $data->request->get('id'0);
  2815. //        $empId = $em->getRepository(Employee::class)
  2816. //            ->findOneBy(['userId' => $userId])->getEmployeeId();
  2817.             } else {
  2818.                 $empId $data->request->get('employeeId'0);
  2819.                 $sysUserId $data->request->get('userId'0);
  2820.             }
  2821.             $dtTs $data->request->get('timeTs'0);
  2822.             if ($sysUserId == 0)
  2823.                 $sysUserId $userId;
  2824.             if ($sysUserId == 0)
  2825.                 $sysUserId $em->getRepository(Employee::class)
  2826.                     ->findOneBy(['employeeId' => $empId])->getUserId();
  2827.             if ($dtTs == 0) {
  2828.                 $currTsTime = new \DateTime();
  2829.                 $dtTs $currTsTime->format('U');
  2830.             } else {
  2831.                 $currTsTime = new \DateTime('@' $dtTs);
  2832.             }
  2833.             if ($sysUserId == 0)
  2834.                 $sysUserId $userId;
  2835.             if ($sysUserId == 0)
  2836.                 $sysUserId $em->getRepository(Employee::class)
  2837.                     ->findOneBy(['employeeId' => $empId])->getUserId();
  2838.             $today = new \DateTime(date('y-m-d'));
  2839.             $currTsTime->setTimezone(new \DateTimeZone('UTC'));
  2840.             $attDate = new \DateTime($currTsTime->format('Y-m-d') . ' 00:00:00' $timeZoneStr);
  2841.             $EmployeeAttendance $this->getDoctrine()
  2842.                 ->getRepository(EmployeeAttendance::class)
  2843.                 ->findOneBy(array('employeeId' => $empId'date' => $attDate));
  2844.             if (!$EmployeeAttendance)
  2845.                 $EmployeeAttendance = new EmployeeAttendance;
  2846. //            return new JsonResponse(["success" => true, "data" => $ActivitiesTemplate]);
  2847. //            $attendanceInfo = HumanResource::StoreAttendance($em, $empId, $sysUserId, $data, $EmployeeAttendance, $customTime);
  2848.             $attendanceInfo HumanResource::StoreAttendance($em$empId$sysUserId$data$EmployeeAttendance$attDate$dtTs$timeZoneStrHumanResourceConstant::ATTENDANCE_MARKER_START_WORKING_FORCED);
  2849.             if (!isset($dataByAttId[$attendanceInfo->getId()]))
  2850.                 $dataByAttId[$attendanceInfo->getId()] = array(
  2851.                     'attendanceInfo' => $attendanceInfo,
  2852.                     'empId' => $empId,
  2853.                     'lat' => 0,
  2854.                     'lng' => 0,
  2855.                     'address' => 0,
  2856.                     'sysUserId' => $sysUserId,
  2857.                     'companyId' => $data->getSession()->get(UserConstants::USER_COMPANY_ID),
  2858.                     'appId' => $data->getSession()->get(UserConstants::USER_APP_ID),
  2859.                     'positionArray' => []
  2860.                 );
  2861.             $posData = array(
  2862.                 'ts' => $dtTs,
  2863.                 'lat' => 0,
  2864.                 'lng' => 0,
  2865.                 'marker' => HumanResourceConstant::ATTENDANCE_MARKER_START_WORKING_FORCED,
  2866.                 'src' => 1,
  2867.             );
  2868.             $posDataArray = array(
  2869.                 $dtTs,
  2870.                 0,
  2871.                 0,
  2872.                 HumanResourceConstant::ATTENDANCE_MARKER_START_WORKING_FORCED,
  2873.                 1
  2874.             );
  2875.             $dataByAttId[$attendanceInfo->getId()]['markerId'] = HumanResourceConstant::ATTENDANCE_MARKER_START_WORKING_FORCED;
  2876.             //this markerId will be calclulted and modified to check if user is in our out of office/workplace later
  2877.             $dataByAttId[$attendanceInfo->getId()]['attendanceInfo'] = $attendanceInfo;
  2878.             $dataByAttId[$attendanceInfo->getId()]['positionArray'][] = $posData;
  2879.             $dataByAttId[$attendanceInfo->getId()]['lat'] = 0;  //for last lat lng etc
  2880.             $dataByAttId[$attendanceInfo->getId()]['lng'] = 0;  //for last lat lng etc
  2881.             if (isset($d['address']))
  2882.                 $dataByAttId[$attendanceInfo->getId()]['address'] = '';  //for last lat lng etc
  2883.             $response = array(
  2884.                 'success' => true
  2885.             );
  2886.             foreach ($dataByAttId as $attInfoId => $d) {
  2887.                 $response HumanResource::setAttendanceLogFlutterApp($em,
  2888.                     $d['empId'],
  2889.                     $d['sysUserId'],
  2890.                     $d['companyId'],
  2891.                     $d['appId'],
  2892.                     $data,
  2893.                     $d['attendanceInfo'],
  2894.                     $options,
  2895.                     $d['positionArray'],
  2896.                     $d['lat'],
  2897.                     $d['lng'],
  2898.                     $d['address'],
  2899.                     $d['markerId']
  2900.                 );
  2901.             }
  2902.             if ($data->request->get('requestFromMobile')) {
  2903.                 return new JsonResponse(array(
  2904.                     'success' => $response['success'] == true true false,
  2905.                     'msg' => $response['success'] == true 'Employee activities successfully updated.' 'Action Failed',
  2906.                 ));
  2907.             }
  2908.             return new JsonResponse(
  2909.                 array(
  2910.                     'success' => true,
  2911.                     'dtTs' => $dtTs,
  2912.                     'attDate' => $attDate->format(DATE_RFC822),
  2913.                     'currTsTime' => $currTsTime->format(DATE_RFC822),
  2914.                     'msg' => 'Employee activities successfully updated.',
  2915.                 )
  2916.             );
  2917. //
  2918. //
  2919. //            $response = HumanResource::setAttendanceLog($em, $empId, $sysUserId,
  2920. //                $data->getSession()->get(UserConstants::USER_COMPANY_ID),
  2921. //                $data->getSession()->get(UserConstants::USER_APP_ID),
  2922. //                $data, $attendanceInfo, $options);
  2923. //
  2924. //            if ($data->request->get('requestFromMobile')) {
  2925. //                return new JsonResponse($response);
  2926. //            }
  2927. //
  2928. //            return new JsonResponse(
  2929. //                array(
  2930. //                    'success' => true,
  2931. //                    'msg' => 'Employee activities successfully updated.'
  2932. //                )
  2933. //            );
  2934.             // }
  2935.             // else {
  2936.             //   return new JsonResponse(
  2937.             //     array(
  2938.             //       'success' => false,
  2939.             //       'msg' => "Invalid employee ID"
  2940.             //     )
  2941.             //   );
  2942.             // }
  2943.         } else {
  2944.             if ($data->get('manualAttendance')) {
  2945.                 return $this->render(
  2946.                     'ApplicationBundle:pages/human_resource/input_forms:manual_attendance.html.twig',
  2947.                     array(
  2948.                         'page_title' => 'Manual Attendance',
  2949.                         'workPolicy' => $workHourPolicy,
  2950. //                        'workTime' => json_decode($workHourPolicy->getRepeatationData()),
  2951. //                        'workTime' => json_decode($workHourPolicy->getRepeatationData()),
  2952. //                        'workTime' => json_decode($workHourPolicy->getEmployeeTypeIds(),true),
  2953.                     )
  2954.                 );
  2955.             }
  2956.             // Show all matching employee list during ajax request
  2957.             // Show current location according to id
  2958.             if ($data->get('getCurrLocById')) {
  2959.                 $Id $data->get("id");
  2960.                 $options = array(
  2961.                     'employeeId' => $Id,
  2962.                     'entityDbaseName' => 'work_hour_policy',
  2963.                     'entityDbaseIdField' => 'id',
  2964.                     'entityDbaseEmployeeIdsField' => 'employeeIds',
  2965.                     'entityDesignationIdsField' => 'designationIds',
  2966.                     'entityDepartmentIdsField' => 'departmentIds',
  2967.                     'entityEmployeeTypeIdsField' => 'employee_types',
  2968.                     'limit' => 1,
  2969.                     'single' => 1,
  2970.                 );
  2971.                 $workHourPolicyData HumanResource::getApplicableSettingsDataForEmployee($em$options);
  2972.                 $today = new \DateTime(date('y-m-d'));
  2973.                 $repository $this->getDoctrine()->getRepository(EmployeeAttendance::class);
  2974.                 $ActivitiesTemplate HumanResource::getActivitiesTemplate($repository$Id$today);
  2975.                 return new JsonResponse(["success" => true"workHourPolicyData" => $workHourPolicyData"template" => $ActivitiesTemplate]);
  2976.             }
  2977.         }
  2978.     }
  2979.     public function AttendanceForAppAction(Request $data$remoteVerify 0)
  2980.     {
  2981.         $em $this->getDoctrine()->getManager();
  2982.         $em_goc $this->getDoctrine()->getManager('company_group');
  2983.         $session $data->getSession();
  2984.         $token $session->get(UserConstants::USER_TOKEN);
  2985.         $providedToken $data->headers->get('auth-token');
  2986.         if (empty($providedToken) || $providedToken !== $token) {
  2987.             return new JsonResponse([
  2988.                 'status' => 'error',
  2989.                 'message' => 'Token not match or missing',
  2990.             ], 401);
  2991.         }
  2992.         $workHourPolicy $em->getRepository('ApplicationBundle:WorkHourPolicy')->findAll();
  2993.         $options = array(
  2994.             'notification_enabled' => $this->container->getParameter('notification_enabled'),
  2995.             'notification_server' => $this->container->getParameter('notification_server'),
  2996.         );
  2997.         if ($data->get('DataTable')) {
  2998.             $response HumanResource::HandelAjaxRequestForManualAttendance($em$data);
  2999.             return new JsonResponse($response);
  3000.         }
  3001.         if ($data->request->get('getAttendanceStatus')) {
  3002.             $response HumanResource::getAttendanceStatus($em$data);
  3003.             return new JsonResponse($response);
  3004.         }
  3005. //        if ($session->get('devAdminMode', 0) != 1 && $data->get('returnJson', 0) == 0)
  3006. //            return $this->redirectToRoute('permission_denied_page');
  3007.         // Auto attendance
  3008.         if ($data->get('autoAttendance') && $data->request->has('position_array')) {
  3009. //            $empId = $data->query->get('id');
  3010.             $empId $data->request->get('id'$session->get(UserConstants::USER_EMPLOYEE_ID));
  3011.             $positionsArray $data->request->get('position_array', []);
  3012.             if (is_string($positionsArray)) $positionsArray json_decode($positionsArraytrue);
  3013.             if ($positionsArray == null$positionsArray = [];
  3014.             $dataByAttId = [];
  3015.             $workPlaceType '_UNSET_';
  3016.             foreach ($positionsArray as $d) {
  3017.                 $sysUserId 0;
  3018.                 $userId 0;
  3019.                 $empId 0;
  3020.                 $dtTs 0;
  3021.                 $timeZoneStr '+0000';
  3022. //                $timeZoneStr = '+0600';
  3023.                 $token '_unset_';
  3024.                 if (isset($d['token'])) $token $d['token'];
  3025.                 if (isset($d['employeeId'])) $empId $d['employeeId'];
  3026.                 if (isset($d['userId'])) $userId $d['userId'];
  3027.                 if (isset($d['sysUserId'])) $sysUserId $d['sysUserId'];
  3028.                 if (isset($d['tsMilSec'])) {
  3029.                     $dtTs ceil(($d['tsMilSec']) / 1000);
  3030.                 }
  3031.                 if ($token != '_unset_') {
  3032.                     $sessionData MiscActions::GetSessionDataFromToken($em_goc$token)['sessionData'];
  3033.                     if (isset($sessionData[UserConstants::USER_EMPLOYEE_ID]))
  3034.                         $empId $sessionData[UserConstants::USER_EMPLOYEE_ID];
  3035.                 }
  3036.                 if ($sysUserId == 0)
  3037.                     $sysUserId $userId;
  3038.                 if ($sysUserId == 0)
  3039.                     $sysUserId $em->getRepository(Employee::class)
  3040.                         ->findOneBy(['employeeId' => $empId])->getUserId();
  3041.                 if ($dtTs == 0) {
  3042.                     $currTsTime = new \DateTime();
  3043.                     $dtTs $currTsTime->format('U');
  3044.                 } else {
  3045.                     $currTsTime = new \DateTime('@' $dtTs);
  3046.                 }
  3047.                 $currTsTime->setTimezone(new \DateTimeZone('UTC'));
  3048.                 $attDate = new \DateTime($currTsTime->format('Y-m-d') . ' 00:00:00' $timeZoneStr);
  3049.                 $EmployeeAttendance $this->getDoctrine()
  3050.                     ->getRepository(EmployeeAttendance::class)
  3051.                     ->findOneBy(array('employeeId' => $empId'date' => $attDate));
  3052.                 if (!$EmployeeAttendance)
  3053.                     $EmployeeAttendance = new EmployeeAttendance;
  3054.                 $attendanceInfo HumanResource::StoreAttendance($em$empId$sysUserId$data$EmployeeAttendance$attDate$dtTs$timeZoneStr$d['markerId']);
  3055.                 if ($d['markerId'] == HumanResourceConstant::ATTENDANCE_MARKER_CLOCK_IN) {
  3056.                     if ($empId == 24)
  3057.                         $workPlaceType '_HYBRID_';
  3058.                     else
  3059.                         $workPlaceType '_STATIC_';
  3060.                 }
  3061.                 if (!isset($dataByAttId[$attendanceInfo->getId()]))
  3062.                     $dataByAttId[$attendanceInfo->getId()] = array(
  3063.                         'attendanceInfo' => $attendanceInfo,
  3064.                         'empId' => $empId,
  3065.                         'lat' => 0,
  3066.                         'lng' => 0,
  3067.                         'address' => 0,
  3068.                         'sysUserId' => $sysUserId,
  3069.                         'companyId' => $data->getSession()->get(UserConstants::USER_COMPANY_ID),
  3070.                         'appId' => $data->getSession()->get(UserConstants::USER_APP_ID),
  3071.                         'positionArray' => []
  3072.                     );
  3073.                 $posData = array(
  3074.                     'ts' => $dtTs,
  3075.                     'lat' => $d['lat'],
  3076.                     'lng' => $d['lng'],
  3077.                     'marker' => $d['markerId'],
  3078.                     'src' => 2,
  3079.                 );
  3080.                 $posDataArray = array(
  3081.                     $dtTs,
  3082.                     $d['lat'],
  3083.                     $d['lng'],
  3084.                     $d['markerId'],
  3085.                     2
  3086.                 );
  3087.                 $dataByAttId[$attendanceInfo->getId()]['markerId'] = $d['markerId'];
  3088.                 //this markerId will be calclulted and modified to check if user is in our out of office/workplace later
  3089.                 $dataByAttId[$attendanceInfo->getId()]['attendanceInfo'] = $attendanceInfo;
  3090.                 $dataByAttId[$attendanceInfo->getId()]['positionArray'][] = $posData;
  3091.                 $dataByAttId[$attendanceInfo->getId()]['lat'] = $d['lat'];  //for last lat lng etc
  3092.                 $dataByAttId[$attendanceInfo->getId()]['lng'] = $d['lng'];  //for last lat lng etc
  3093.                 if (isset($d['address']))
  3094.                     $dataByAttId[$attendanceInfo->getId()]['address'] = $d['address'];  //for last lat lng etc
  3095. //                $dataByAttId[$attendanceInfo->getId()]['positionArray'][]=$posDataArray;
  3096.             }
  3097.             $response = array(
  3098.                 'success' => true,
  3099.             );
  3100.             foreach ($dataByAttId as $attInfoId => $d) {
  3101.                 $response HumanResource::setAttendanceLogFlutterApp($em,
  3102.                     $d['empId'],
  3103.                     $d['sysUserId'],
  3104.                     $d['companyId'],
  3105.                     $d['appId'],
  3106.                     $data,
  3107.                     $d['attendanceInfo'],
  3108.                     $options,
  3109.                     $d['positionArray'],
  3110.                     $d['lat'],
  3111.                     $d['lng'],
  3112.                     $d['address'],
  3113.                     $d['markerId']
  3114.                 );
  3115.             }
  3116.             if ($data->request->get('requestFromMobile')) {
  3117.                 $today = new \DateTime(date('y-m-d'));
  3118.                 $repository $this->getDoctrine()->getRepository(EmployeeAttendance::class);
  3119.                 $ActivitiesTemplate HumanResource::getCurrentStatusFromDb($repository$empId$today);
  3120.                 return new JsonResponse(array(
  3121.                     'success' => $response['success'] == true true false,
  3122.                     'msg' => $response['success'] == true 'Employee activities successfully updated.' 'Action Failed',
  3123.                     'workPlaceType' => $workPlaceType,
  3124.                     'data' => $ActivitiesTemplate
  3125.                 ));
  3126.             }
  3127.             return new JsonResponse(
  3128.                 array(
  3129.                     'success' => true,
  3130.                     'msg' => 'Employee activities successfully updated.',
  3131.                     'workPlaceType' => $workPlaceType,
  3132.                 )
  3133.             );
  3134.         } else if ($data->get('autoAttendance')) {
  3135.             $sysUserId 0;
  3136.             $userId 0;
  3137.             $empId 0;
  3138.             $dtTs 0;
  3139. //            $timeZoneStr = '+0600';
  3140.             $timeZoneStr '+0000';
  3141.             if ($data->request->get('requestFromMobile')) {
  3142.                 $empId $data->request->get('employeeId');
  3143.                 $userId $data->request->get('userId'0);
  3144.                 $sysUserId $data->request->get('id'0);
  3145. //        $empId = $em->getRepository(Employee::class)
  3146. //            ->findOneBy(['userId' => $userId])->getEmployeeId();
  3147.             } else {
  3148.                 $empId $data->request->get('employeeId'0);
  3149.                 $sysUserId $data->request->get('userId'0);
  3150.             }
  3151.             $dtTs $data->request->get('timeTs'0);
  3152.             if ($sysUserId == 0)
  3153.                 $sysUserId $userId;
  3154.             if ($sysUserId == 0)
  3155.                 $sysUserId $em->getRepository(Employee::class)
  3156.                     ->findOneBy(['employeeId' => $empId])->getUserId();
  3157.             if ($dtTs == 0) {
  3158.                 $currTsTime = new \DateTime();
  3159.                 $dtTs $currTsTime->format('U');
  3160.             } else {
  3161.                 $currTsTime = new \DateTime('@' $dtTs);
  3162.             }
  3163.             if ($sysUserId == 0)
  3164.                 $sysUserId $userId;
  3165.             if ($sysUserId == 0)
  3166.                 $sysUserId $em->getRepository(Employee::class)
  3167.                     ->findOneBy(['employeeId' => $empId])->getUserId();
  3168.             $today = new \DateTime(date('y-m-d'));
  3169.             $currTsTime->setTimezone(new \DateTimeZone('UTC'));
  3170.             $attDate = new \DateTime($currTsTime->format('Y-m-d') . ' 00:00:00' $timeZoneStr);
  3171.             $EmployeeAttendance $this->getDoctrine()
  3172.                 ->getRepository(EmployeeAttendance::class)
  3173.                 ->findOneBy(array('employeeId' => $empId'date' => $attDate));
  3174.             if (!$EmployeeAttendance)
  3175.                 $EmployeeAttendance = new EmployeeAttendance;
  3176. //            return new JsonResponse(["success" => true, "data" => $ActivitiesTemplate]);
  3177. //            $attendanceInfo = HumanResource::StoreAttendance($em, $empId, $sysUserId, $data, $EmployeeAttendance, $customTime);
  3178.             $attendanceInfo HumanResource::StoreAttendance($em$empId$sysUserId$data$EmployeeAttendance$attDate$dtTs$timeZoneStrHumanResourceConstant::ATTENDANCE_MARKER_START_WORKING_FORCED);
  3179.             if (!isset($dataByAttId[$attendanceInfo->getId()]))
  3180.                 $dataByAttId[$attendanceInfo->getId()] = array(
  3181.                     'attendanceInfo' => $attendanceInfo,
  3182.                     'empId' => $empId,
  3183.                     'lat' => 0,
  3184.                     'lng' => 0,
  3185.                     'address' => 0,
  3186.                     'sysUserId' => $sysUserId,
  3187.                     'companyId' => $data->getSession()->get(UserConstants::USER_COMPANY_ID),
  3188.                     'appId' => $data->getSession()->get(UserConstants::USER_APP_ID),
  3189.                     'positionArray' => []
  3190.                 );
  3191.             $posData = array(
  3192.                 'ts' => $dtTs,
  3193.                 'lat' => 0,
  3194.                 'lng' => 0,
  3195.                 'marker' => HumanResourceConstant::ATTENDANCE_MARKER_START_WORKING_FORCED,
  3196.                 'src' => 1,
  3197.             );
  3198.             $posDataArray = array(
  3199.                 $dtTs,
  3200.                 0,
  3201.                 0,
  3202.                 HumanResourceConstant::ATTENDANCE_MARKER_START_WORKING_FORCED,
  3203.                 1
  3204.             );
  3205.             $dataByAttId[$attendanceInfo->getId()]['markerId'] = HumanResourceConstant::ATTENDANCE_MARKER_START_WORKING_FORCED;
  3206.             //this markerId will be calclulted and modified to check if user is in our out of office/workplace later
  3207.             $dataByAttId[$attendanceInfo->getId()]['attendanceInfo'] = $attendanceInfo;
  3208.             $dataByAttId[$attendanceInfo->getId()]['positionArray'][] = $posData;
  3209.             $dataByAttId[$attendanceInfo->getId()]['lat'] = 0;  //for last lat lng etc
  3210.             $dataByAttId[$attendanceInfo->getId()]['lng'] = 0;  //for last lat lng etc
  3211.             if (isset($d['address']))
  3212.                 $dataByAttId[$attendanceInfo->getId()]['address'] = '';  //for last lat lng etc
  3213.             $response = array(
  3214.                 'success' => true
  3215.             );
  3216.             foreach ($dataByAttId as $attInfoId => $d) {
  3217.                 $response HumanResource::setAttendanceLogFlutterApp($em,
  3218.                     $d['empId'],
  3219.                     $d['sysUserId'],
  3220.                     $d['companyId'],
  3221.                     $d['appId'],
  3222.                     $data,
  3223.                     $d['attendanceInfo'],
  3224.                     $options,
  3225.                     $d['positionArray'],
  3226.                     $d['lat'],
  3227.                     $d['lng'],
  3228.                     $d['address'],
  3229.                     $d['markerId']
  3230.                 );
  3231.             }
  3232.             if ($data->request->get('requestFromMobile')) {
  3233.                 return new JsonResponse(array(
  3234.                     'success' => $response['success'] == true true false,
  3235.                     'msg' => $response['success'] == true 'Employee activities successfully updated.' 'Action Failed',
  3236.                 ));
  3237.             }
  3238.             return new JsonResponse(
  3239.                 array(
  3240.                     'success' => true,
  3241.                     'dtTs' => $dtTs,
  3242.                     'attDate' => $attDate->format(DATE_RFC822),
  3243.                     'currTsTime' => $currTsTime->format(DATE_RFC822),
  3244.                     'msg' => 'Employee activities successfully updated.',
  3245.                 )
  3246.             );
  3247. //
  3248. //
  3249. //            $response = HumanResource::setAttendanceLog($em, $empId, $sysUserId,
  3250. //                $data->getSession()->get(UserConstants::USER_COMPANY_ID),
  3251. //                $data->getSession()->get(UserConstants::USER_APP_ID),
  3252. //                $data, $attendanceInfo, $options);
  3253. //
  3254. //            if ($data->request->get('requestFromMobile')) {
  3255. //                return new JsonResponse($response);
  3256. //            }
  3257. //
  3258. //            return new JsonResponse(
  3259. //                array(
  3260. //                    'success' => true,
  3261. //                    'msg' => 'Employee activities successfully updated.'
  3262. //                )
  3263. //            );
  3264.             // }
  3265.             // else {
  3266.             //   return new JsonResponse(
  3267.             //     array(
  3268.             //       'success' => false,
  3269.             //       'msg' => "Invalid employee ID"
  3270.             //     )
  3271.             //   );
  3272.             // }
  3273.         } else {
  3274.             if ($data->get('manualAttendance')) {
  3275.                 return $this->render(
  3276.                     'ApplicationBundle:pages/human_resource/input_forms:manual_attendance.html.twig',
  3277.                     array(
  3278.                         'page_title' => 'Manual Attendance',
  3279.                         'workPolicy' => $workHourPolicy,
  3280. //                        'workTime' => json_decode($workHourPolicy->getRepeatationData()),
  3281. //                        'workTime' => json_decode($workHourPolicy->getRepeatationData()),
  3282. //                        'workTime' => json_decode($workHourPolicy->getEmployeeTypeIds(),true),
  3283.                     )
  3284.                 );
  3285.             }
  3286.             // Show all matching employee list during ajax request
  3287.             // Show current location according to id
  3288.             if ($data->get('getCurrLocById')) {
  3289.                 $Id $data->get("id");
  3290.                 $options = array(
  3291.                     'employeeId' => $Id,
  3292.                     'entityDbaseName' => 'work_hour_policy',
  3293.                     'entityDbaseIdField' => 'id',
  3294.                     'entityDbaseEmployeeIdsField' => 'employeeIds',
  3295.                     'entityDesignationIdsField' => 'designationIds',
  3296.                     'entityDepartmentIdsField' => 'departmentIds',
  3297.                     'entityEmployeeTypeIdsField' => 'employee_types',
  3298.                     'limit' => 1,
  3299.                     'single' => 1,
  3300.                 );
  3301.                 $workHourPolicyData HumanResource::getApplicableSettingsDataForEmployee($em$options);
  3302.                 $today = new \DateTime(date('y-m-d'));
  3303.                 $repository $this->getDoctrine()->getRepository(EmployeeAttendance::class);
  3304.                 $ActivitiesTemplate HumanResource::getActivitiesTemplate($repository$Id$today);
  3305.                 return new JsonResponse(["success" => true"workHourPolicyData" => $workHourPolicyData"template" => $ActivitiesTemplate]);
  3306.             }
  3307.         }
  3308.     }
  3309.     public function getCurrentStatusAction($id)
  3310.     {
  3311.         $today = new \DateTime(date('y-m-d'));
  3312.         $repository $this->getDoctrine()->getRepository(EmployeeAttendance::class);
  3313.         $ActivitiesTemplate HumanResource::getCurrentStatusFromDb($repository$id$today);
  3314.         return new JsonResponse(["success" => true"data" => $ActivitiesTemplate]);
  3315.     }
  3316.     public function CurrentAttendanceAction(Request $data)
  3317.     {
  3318.         $em $this->getDoctrine()->getManager();
  3319.         $options = array(
  3320.             'notification_enabled' => $this->container->getParameter('notification_enabled'),
  3321.             'notification_server' => $this->container->getParameter('notification_server'),
  3322.         );
  3323.         if ($data->get('DataTable')) {
  3324.             $response HumanResource::HandelAjaxRequestForManualAttendance($em$data);
  3325.             return new JsonResponse($response);
  3326.         }
  3327.         if ($data->request->get('getAttendanceStatus')) {
  3328.             $response HumanResource::getAttendanceStatus($em$data);
  3329.             return new JsonResponse($response);
  3330.         }
  3331.         // Auto attendance
  3332.         if ($data->get('autoAttendance')) {
  3333.             $empId $data->query->get('id');
  3334.             $sysUserId 0;
  3335.             if ($data->get('requestFromMobile')) {
  3336.                 $sysUserId $data->request->get('id');
  3337.                 $empId $em->getRepository(Employee::class)
  3338.                     ->findOneBy(['userId' => $sysUserId])->getEmployeeId();
  3339.             } else {
  3340.                 $sysUserId $em->getRepository(Employee::class)
  3341.                     ->findOneBy(['employeeId' => $empId])->getUserId();
  3342.             }
  3343.             $customTime $data->get('time');
  3344.             $today = new \DateTime(date('y-m-d'));
  3345.             $EmployeeAttendance $this->getDoctrine()
  3346.                 ->getRepository(EmployeeAttendance::class)
  3347.                 ->findOneBy(array('employeeId' => $empId'date' => $today));
  3348.             if (!$EmployeeAttendance)
  3349.                 $EmployeeAttendance = new EmployeeAttendance;
  3350.             $attendanceInfo HumanResource::StoreAttendance($em$empId$sysUserId$data$EmployeeAttendance$customTime);
  3351.             $response HumanResource::setAttendanceLog($em$empId$sysUserId,
  3352.                 $data->getSession()->get(UserConstants::USER_COMPANY_ID),
  3353.                 $data->getSession()->get(UserConstants::USER_APP_ID),
  3354.                 $data$attendanceInfo$options);
  3355.             if ($data->get('requestFromMobile')) {
  3356.                 return new JsonResponse([$response]);
  3357.             }
  3358.             return new JsonResponse(
  3359.                 array(
  3360.                     'success' => true,
  3361.                     'msg' => 'Employee activities successfully updated.'
  3362.                 )
  3363.             );
  3364.             // }
  3365.             // else {
  3366.             //   return new JsonResponse(
  3367.             //     array(
  3368.             //       'success' => false,
  3369.             //       'msg' => "Invalid employee ID"
  3370.             //     )
  3371.             //   );
  3372.             // }
  3373.         } else {
  3374.             if ($data->get('manualAttendance')) {
  3375.                 return $this->render(
  3376.                     'ApplicationBundle:pages/human_resource/report:current_attendance.html.twig',
  3377.                     array(
  3378.                         'page_title' => 'Current Attendance Status',
  3379.                     )
  3380.                 );
  3381.             }
  3382.             // Show all matching employee list during ajax request
  3383.             // Show current location according to id
  3384.             if ($data->get('getCurrLocById')) {
  3385.                 $Id $data->get("id");
  3386.                 $today = new \DateTime(date('y-m-d'));
  3387.                 $repository $this->getDoctrine()->getRepository(EmployeeAttendance::class);
  3388.                 $ActivitiesTemplate HumanResource::getActivitiesTemplate($repository$Id$today);
  3389.                 return new JsonResponse(["success" => true"template" => $ActivitiesTemplate]);
  3390.             }
  3391.         }
  3392.     }
  3393.     public function EmployeeLeaveAction(Request $data$id 0)
  3394.     {
  3395.         $em $this->getDoctrine()->getManager();
  3396.         $request $data;
  3397.         if (!$id) {
  3398.             if ($data->isMethod('GET')) {
  3399.                 $EmpID $data->query->get('id');
  3400.                 $LeaveType $data->query->get('leaveType');
  3401.                 if ($data->query->has('id') && $data->query->has('leaveType')) {
  3402.                     $response HumanResource::HandelAjaxRequestForLeaveApp($em$EmpID$LeaveType);
  3403.                     return new JsonResponse($response);
  3404.                 }
  3405.                 if ($data->query->has('id')) {
  3406.                     $Response HumanResource::HandelAjaxRequestForLeaveApp($em$EmpID);
  3407.                     return new JsonResponse($Response);
  3408.                 }
  3409.                 $TemplateData HumanResource::TwigDataForLeaveApp($emFalse);
  3410.                 return $this->render(
  3411.                     'ApplicationBundle:pages/human_resource/input_forms:employee_leave.html.twig',
  3412.                     array(
  3413.                         'page_title' => $TemplateData['Title'],
  3414.                         'EmployeeList' => $TemplateData['EmployeeList'],
  3415.                         'DesignationList' => $TemplateData['DesignationList'],
  3416.                         'HasUpdateMode' => false
  3417.                     )
  3418.                 );
  3419.             } else {
  3420.                 $CompanyId $this->getLoggedUserCompanyId($data);
  3421.                 $Response HumanResource::StoreDataForLeaveApplication($em$id$datafalse$CompanyId);
  3422.                 if ($Response['HasErr']) {
  3423.                     $this->addFlash('error'$Response['msg']);
  3424.                     if ($data->request->has('returnJson')) {
  3425.                         return new JsonResponse(array(
  3426.                             'success' => false,
  3427.                             'errorStr' => $Response['msg'],
  3428.                         ));
  3429.                     } else {
  3430.                         return $this->redirectToRoute('employee_leave');
  3431.                     }
  3432.                 }
  3433.                 $applicationId $Response['applicationId'];
  3434.                 $em_goc $this->getDoctrine()->getManager('company_group');
  3435.                 $file_path_list = [];
  3436.                 if ($applicationId != 0) {
  3437.                     if (!empty($request->files)) {
  3438.                         MiscActions::RemoveFilesForEntityDoc($em_goc'EmployeeLeaveApplication'$applicationId);
  3439.                         $storePath 'uploads/LeaveDoc/';
  3440.                         $path "";
  3441.                         $file_path "";
  3442.                         $session $request->getSession();
  3443.                         MiscActions::RemoveExpiredFiles($em_goc);
  3444.                         foreach ($request->files as $uploadedFileGG) {
  3445.                             //            if($uploadedFile->getImage())
  3446.                             //                var_dump($uploadedFile->getFile());
  3447.                             //                var_dump($uploadedFile);
  3448.                             $tempD $uploadedFileGG;
  3449.                             if (!is_array($uploadedFileGG)) {
  3450.                                 $uploadedFileGG = array();
  3451.                                 $uploadedFileGG[] = $tempD;
  3452.                             }
  3453.                             foreach ($uploadedFileGG as $uploadedFile) {
  3454.                                 if ($uploadedFile != null) {
  3455.                                     $extension $uploadedFile->guessExtension();
  3456.                                     $size $uploadedFile->getSize();
  3457.                                     $fileName 'LDOC_' $applicationId '_' . (md5(uniqid())) . '.' $uploadedFile->guessExtension();
  3458.                                     $path $fileName;
  3459.                                     $upl_dir $this->container->getParameter('kernel.root_dir') . '/../web/' $storePath;
  3460.                                     if (!file_exists($upl_dir)) {
  3461.                                         mkdir($upl_dir0777true);
  3462.                                     }
  3463.                                     if (file_exists($upl_dir '' $path)) {
  3464.                                         chmod($upl_dir '' $path0755);
  3465.                                         unlink($upl_dir '' $path);
  3466.                                     }
  3467.                                     $file $uploadedFile->move($upl_dir$path);
  3468.                                     $expireNever 1;
  3469.                                     $expireTs 0;
  3470.                                     $EntityFile = new EntityFile();
  3471.                                     $EntityFile->setPath($this->container->getParameter('kernel.root_dir') . '/../web/' $storePath $path);
  3472.                                     $EntityFile->setMarker('_GEN_');
  3473.                                     $EntityFile->setExtension($extension);
  3474.                                     $EntityFile->setExpireTs($expireTs);
  3475.                                     $EntityFile->setSize($size);
  3476.                                     $EntityFile->setRelativePath($storePath $path);
  3477.                                     $EntityFile->setEntityName('EmployeeLeaveApplication');
  3478.                                     $EntityFile->setEntityBundle('EmployeeLeaveApplication');
  3479.                                     $EntityFile->setEntityId($applicationId);
  3480.                                     $EntityFile->setEntityIdField('employeeLeaveApplicationId');
  3481.                                     $EntityFile->setModifyFieldSetter('setFiles');
  3482.                                     $EntityFile->setDocIdForApplicant(0);
  3483.                                     $EntityFile->setUserId($session->get(UserConstants::USER_ID0));
  3484.                                     $EntityFile->setAppId($session->get(UserConstants::USER_APP_ID0));
  3485.                                     $EntityFile->setEmployeeId($session->get(UserConstants::USER_EMPLOYEE_ID0));
  3486.                                     $EntityFile->setUserType($session->get(UserConstants::USER_TYPE0));
  3487.                                     $em_goc->persist($EntityFile);
  3488.                                     $em_goc->flush();
  3489.                                     $EntityFileId $EntityFile->getId();
  3490.                                 }
  3491.                                 if ($path != "")
  3492.                                     $file_path_list[] = ($storePath $path);
  3493.                             }
  3494.                         }
  3495.                         $g_path $this->container->getParameter('kernel.root_dir') . '/../web/' $storePath $path;
  3496.                         $v $em->getRepository('ApplicationBundle:EmployeeLeaveApplication')->findOneBy(array(
  3497.                             'employeeLeaveApplicationId' => $applicationId,
  3498.                         ));
  3499.                         if ($v) {
  3500.                             $v->setFiles(implode(','$file_path_list));
  3501.                             $em->flush();
  3502.                         } else {
  3503.                         }
  3504.                     }
  3505.                 }
  3506.                 // $this->addFlash('success', 'Application submitted successfully!');
  3507.                 // return $this->redirectToRoute('leave_application_list');
  3508.                 if ($data->request->has('returnJson')) {
  3509.                     return new JsonResponse(array(
  3510.                         'success' => true,
  3511.                     ));
  3512.                 } else {
  3513.                     return $this->redirectToRoute('view_employee_leave_application', array('id' => $applicationId));
  3514.                 }
  3515.             }
  3516.         } else {
  3517.             if ($data->isMethod('GET')) {
  3518.                 $ApplicationRepo $em->getRepository(EmployeeLeaveApplication::class);
  3519.                 $OldData $ApplicationRepo->find(array('employeeLeaveApplicationId' => $id));
  3520.                 $TemplateData HumanResource::TwigDataForLeaveApp($em$OldData);
  3521.                 return $this->render(
  3522.                     'ApplicationBundle:pages/human_resource/input_forms:employee_leave.html.twig',
  3523.                     array(
  3524.                         'page_title' => $TemplateData['Title'],
  3525.                         'EmployeeList' => $TemplateData['EmployeeList'],
  3526.                         'DesignationList' => $TemplateData['DesignationList'],
  3527.                         'OldData' => $TemplateData['OldData'],
  3528.                         'AvailableLeave' => $TemplateData['AvailableLeave'],
  3529.                         'HasUpdateMode' => true
  3530.                     )
  3531.                 );
  3532.             } else {
  3533.                 $CompanyId $this->getLoggedUserCompanyId($data);
  3534.                 $Response HumanResource::StoreDataForLeaveApplication($em$id$datatrue$CompanyId);
  3535.                 if ($Response['HasErr']) {
  3536.                     $this->addFlash('error'$Response['msg']);
  3537.                     return $this->redirectToRoute('employee_leave');
  3538.                 }
  3539.                 $this->addFlash('success'"Application updated successfully!");
  3540.                 return $this->redirectToRoute('leave_application_list');
  3541.             }
  3542.         }
  3543.     }
  3544.     public function ViewLeaveApplicationAction(Request $request$id)
  3545.     {
  3546.         $em $this->getDoctrine()->getManager();
  3547.         if ($id) {
  3548.             $TwigData HumanResource::TwigDataForViewLeaveApplication($em$request$id);
  3549.             if ($TwigData['HasErr']) {
  3550.                 return new JsonResponse(array(
  3551.                     'success' => false,
  3552.                     'msg' => $TwigData['Msg']
  3553.                 ));
  3554.             }
  3555.             return $this->render(
  3556.                 'ApplicationBundle:pages/human_resource/views:leave_application_view.html.twig',
  3557.                 array(
  3558.                     'page_title' => 'View Leave Application',
  3559.                     'Applicant' => $TwigData['Applicant'],
  3560.                     'Application' => $TwigData['Application'],
  3561.                     'LeaveType' => $TwigData['LeaveType'],
  3562.                     'LeaveCategory' => $TwigData['LeaveCategory'],
  3563.                     'leaveDataArray' => $TwigData['leaveDataArray'],
  3564.                     'FrwdEmp' => $TwigData['FrwdEmp'],
  3565.                     'ApplicantDesg' => $TwigData['ApplicantDesg'],
  3566.                     'approval_status' => $TwigData['approval_status'],
  3567.                     'approval_data' => $TwigData['approval_data'],
  3568.                     'document_log' => $TwigData['document_log'],
  3569.                     'auto_created' => 0,
  3570.                 )
  3571.             );
  3572.         }
  3573.         return new JsonResponse(array(
  3574.             'success' => false,
  3575.             'msg' => 'Wrong URL format! Please try with application ID'
  3576.         ));
  3577.     }
  3578.     public function PrintLeaveApplicationAction(Request $request$id)
  3579.     {
  3580.         if ($id) {
  3581.             $em $this->getDoctrine()->getManager();
  3582.             $company_data Company::getCompanyData($em1);
  3583.             $Application $em->getRepository(EmployeeLeaveApplication::class)->find($id);
  3584.             $Authorizations System::getSignatureListForDocumentPrint($emarray_flip(GeneralConstant::$Entity_list)['EmployeeLeaveApplication'], $id);
  3585.             $ApplicationCategory $Application->getLeaveCategory();
  3586.             $ApplicationType = ($ApplicationCategory != && $ApplicationCategory != 2) ? HumanResourceConstant::$LeaveType[$Application->getLeaveTypeId()] : '';
  3587.             $Applicant $em->getRepository(EmployeeDetails::class)
  3588.                 ->find($Application->getEmployeeId());
  3589.             return $this->render(
  3590.                 'ApplicationBundle:pages/human_resource/print:leave_application_print.html.twig',
  3591.                 array(
  3592.                     'page_title' => 'Print Leave Application',
  3593.                     'export' => 'pdf,print',
  3594.                     'company_name' => $company_data->getName(),
  3595.                     'company_data' => $company_data,
  3596.                     'company_address' => $company_data->getAddress(),
  3597.                     'company_image' => $company_data->getImage(),
  3598.                     'Application' => $Application,
  3599.                     'Applicant' => $Applicant,
  3600.                     'Authorizations' => $Authorizations,
  3601.                     'ApplicationType' => $ApplicationType,
  3602.                     'ApplicationCategory' => $ApplicationCategory,
  3603.                     'red' => 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 LeaveApplicationListAction(Request $request)
  3613.     {
  3614.         $em $this->getDoctrine()->getManager();
  3615.         $response HumanResource::GetEmployeeLeaveApplicationList($em$request);
  3616.         if ($request->isMethod('GET')) {
  3617.             return $this->render("ApplicationBundle:pages/human_resource/list:leave_application_list.html.twig", array(
  3618.                 'page_title' => 'Leave Application List',
  3619.                 'application_data' => $response,
  3620.             ));
  3621.         }
  3622.     }
  3623.     public function PayrollPolicySettingsAction(Request $request$id)
  3624.     {
  3625.         $em $this->getDoctrine()->getManager();
  3626.         $CompanyId $this->getLoggedUserCompanyId($request);
  3627.         if ($id) {
  3628.             if ($request->isMethod('GET')) {
  3629.                 $Row $em->getRepository(PayrollPolicy::class)->find($id);
  3630.                 if (!$Row) {
  3631.                     $this->addFlash('error''Invalid Payroll Policy Id');
  3632.                     return $this->redirectToRoute('payroll_policy_settings');
  3633.                 }
  3634.                 $TwigData HumanResource::GetPayrollPolicyTwigData($em);
  3635.                 $OldData HumanResource::GetPayrollPolicyTwigData($em$id);
  3636.                 return $this->render('ApplicationBundle:pages/human_resource/input_forms:payroll_policy_settings.html.twig', array(
  3637.                     'page_title' => 'Update Payroll Policy Settings',
  3638.                     'EmployeeIds' => $TwigData['EmployeeIds'],
  3639.                     'EmployeeType' => $TwigData['EmployeeType'],//
  3640.                     'department' => $TwigData['department'],
  3641.                     'Designation' => $TwigData['Designation'],
  3642.                     'WorkingDays' => $TwigData['WorkingDays'],
  3643.                     'OldData' => $OldData['Row'],
  3644.                     'earningAspects' => HumanResourceConstant::$earningAspectsForPayrollPolicy,
  3645.                     'leaveTypes' => HumanResourceConstant::$LeaveTypeForPayrollPolicy,
  3646.                     'leaveTypesArray' => HumanResourceConstant::$LeaveTypeArrayForPayrollPolicy,
  3647.                     'deductionAspects' => HumanResourceConstant::$deductionAspects,
  3648.                     'deductionCondition' => json_decode($Row->getDeductionCondition(), true),
  3649.                     'HasUpdateMode' => true,
  3650.                 ));
  3651.             } else {
  3652.                 $Response HumanResource::StorePayrollPolicyData($em$id$CompanyId$request);
  3653.                 if ($Response['HasErr']) {
  3654.                     $this->addFlash('error'$Response['msg']);
  3655.                     return $this->redirectToRoute('payroll_policy_settings');
  3656.                 }
  3657.                 return $this->redirectToRoute('payroll_policy_settings');
  3658. //        if ($Response['isSuccess']) {
  3659. //          return new JsonResponse(array('success' => true, 'msg' => 'don\'t forget to redirect'));
  3660. //        }
  3661. //        return new JsonResponse(array('success' => false, 'msg' => 'Sorry something went wrong'));
  3662.             }
  3663.         } else {
  3664.             if ($request->isMethod('GET')) {
  3665.                 if ($request->query->get('GetDocHash')) {
  3666.                     $Dochash HumanResource::GenerateDocHashForPayrollSettings($em$request);
  3667.                     return new JsonResponse($Dochash);
  3668.                 }
  3669.                 $TwigData HumanResource::GetPayrollPolicyTwigData($em);
  3670.                 return $this->render(
  3671.                     'ApplicationBundle:pages/human_resource/input_forms:payroll_policy_settings.html.twig',
  3672.                     array(
  3673.                         'page_title' => 'Create Payroll Policy Settings',
  3674.                         'EmployeeIds' => $TwigData['EmployeeIds'],
  3675.                         'EmployeeType' => $TwigData['EmployeeType'],
  3676.                         'WorkingDays' => $TwigData['WorkingDays'],
  3677.                         'Designation' => $TwigData['Designation'],
  3678.                         'department' => $TwigData['department'],
  3679.                         'earningAspects' => HumanResourceConstant::$earningAspectsForPayrollPolicy,
  3680.                         'leaveTypes' => HumanResourceConstant::$LeaveTypeForPayrollPolicy,
  3681.                         'leaveTypesArray' => HumanResourceConstant::$LeaveTypeArrayForPayrollPolicy,
  3682.                         'deductionAspects' => HumanResourceConstant::$deductionAspects,
  3683.                         'HasUpdateMode' => false
  3684.                     )
  3685.                 );
  3686.             } else {
  3687.                 $Response HumanResource::StorePayrollPolicyData($em$id$CompanyId$request);
  3688.                 if ($Response['HasErr']) {
  3689.                     $this->addFlash('error'$Response['msg']);
  3690.                     return $this->redirectToRoute('payroll_policy_settings');
  3691.                 }
  3692.                 return $this->redirectToRoute('payroll_policy_settings');
  3693. //        return new JsonResponse(array("success" => true, 'msg' => 'Dont forget to redirect!'));
  3694.             }
  3695.         }
  3696.     }
  3697.     public function AttendanceReportAction(Request $request$apiKey 'impose')
  3698.     {
  3699.         $em $this->getDoctrine()->getManager();
  3700.         $attendanceSource HumanResourceConstant::$attendanceSources;
  3701.         $routeName $request->attributes->get('_route');
  3702.         if ($routeName == 'app_get_attendendance_data') {
  3703.             $ReportData HumanResource::GenerateAttendanceReport($em$request$request->get('considerCurrTsIfNoOut'1));
  3704.             $newReports = [];
  3705.             foreach ($ReportData['Reports'] as $gg) {
  3706.                 foreach ($gg as $d) {
  3707.                     $newReports[] = $d;
  3708. //                if(!isset($newReports[$d['id']]))
  3709. //                    $newReports[$d['id']]=array();
  3710. //                    $newReports[$d['id']][]=$d;
  3711.                 }
  3712.             }
  3713.             return new JsonResponse (array(
  3714.                 'attendanceSource' => $attendanceSource,
  3715. //                'Reports' => $ReportData['Reports'],
  3716.                 'Reports' => $newReports,
  3717.                 'from_date' => $ReportData['from_date'],
  3718.                 'to_date' => $ReportData['to_date'],
  3719.                 'report_for' => $ReportData['generated_for'],
  3720.                 'attendance' => $ReportData['attendance'],
  3721.             ));
  3722.         } else {
  3723.             $EmployeeIds $em->getRepository(EmployeeDetails::class)->findAll();
  3724.             $Departments $em->getRepository(SysDepartment::class)->findAll();
  3725.             if ($request->isMethod('GET')) {
  3726.                 return $this->render('ApplicationBundle:pages/human_resource/report:attendance_report.html.twig', array(
  3727.                     'page_title' => 'Attendance Report',
  3728.                     'employes' => $EmployeeIds,
  3729.                     'departments' => $Departments,
  3730.                     'isMethodGet' => true,
  3731.                     'from_date' => '',
  3732.                     'to_date' => '',
  3733.                     'report_for' => '',
  3734.                     'attendance' => [],
  3735.                     'Reports' => [],
  3736.                     'qry' => ''
  3737.                 ));
  3738.             }
  3739.             $ReportData HumanResource::GenerateAttendanceReport($em$request$request->request->get('considerCurrTsIfNoOut'0));
  3740.             if ($request->request->get('returnJson'0) == 1) {
  3741.                 return new JsonResponse($ReportData);
  3742.             }
  3743.             $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') : []));
  3744.             return $this->render('ApplicationBundle:pages/human_resource/report:attendance_report.html.twig', array(
  3745.                 'page_title' => 'Attendance Report',
  3746.                 'isMethodGet' => false,
  3747.                 'departments' => $Departments,
  3748.                 'employes' => $EmployeeIds,
  3749.                 'attendanceSource' => $attendanceSource,
  3750.                 'Reports' => $ReportData['Reports'],
  3751.                 'from_date' => $ReportData['from_date'],
  3752.                 'to_date' => $ReportData['to_date'],
  3753.                 'report_for' => $ReportData['generated_for'],
  3754.                 'attendance' => $ReportData['attendance'],
  3755.                 'qry' => $Qry
  3756.             ));
  3757.         }
  3758.     }
  3759.     public function PrintAttendanceReportAction(Request $request)
  3760.     {
  3761.         $em $this->getDoctrine()->getManager();
  3762.         $company_data Company::getCompanyData($em1);
  3763.         $ReportData HumanResource::GenerateAttendanceReport($em$request);
  3764.         return $this->render(
  3765.             'ApplicationBundle:pages/human_resource/print:print_attendance_report.html.twig',
  3766.             array(
  3767.                 'page_title' => 'Print Attendance Report',
  3768.                 'export' => 'pdf,print',
  3769.                 'company_name' => $company_data->getName(),
  3770.                 'company_data' => $company_data,
  3771.                 'company_address' => $company_data->getAddress(),
  3772.                 'company_image' => $company_data->getImage(),
  3773.                 'Reports' => $ReportData['Reports'],
  3774.                 'from_date' => $ReportData['from_date'],
  3775.                 'to_date' => $ReportData['to_date'],
  3776.                 'report_for' => $ReportData['generated_for'],
  3777.                 'attendance' => $ReportData['attendance'],
  3778.                 'red' => 0
  3779.             )
  3780.         );
  3781.     }
  3782.     public function DisburseSalaryAction(Request $request)
  3783.     {
  3784.         $em $this->getDoctrine()->getManager();
  3785.         $EmployeeIds $em->getRepository(EmployeeDetails::class)->findBy(
  3786.             array(
  3787.                 'emp_status' => 1
  3788.             )
  3789.         );
  3790.         $startDate $request->get('salary_start_date''');
  3791.         $endDate $request->get('salary_till_date''');
  3792.         $filterType $request->get('filterType'1);
  3793.         $filterBranchIds $request->get('branchIds', []);
  3794.         $filterBankIds $request->get('bankIds', []);
  3795.         $filterDepartmentIds $request->get('departmentIds', []);
  3796.         $filterEmployeeIds $request->get('employeeIds', []);
  3797.         $Departments $em->getRepository(SysDepartment::class)->findAll();
  3798.         $attendance $em->getRepository(EmployeeAttendanceLog::class)->findAll();
  3799.         $banks $em->getRepository(BankList::class)->findAll();
  3800.         $branches $em->getRepository(Branch::class)->findAll();
  3801.         if ($request->isMethod('GET')) {
  3802.             return $this->render('ApplicationBundle:pages/human_resource/report:disburse_salary.html.twig', array(
  3803.                 'page_title' => 'Disburse Salary',
  3804.                 'EmployeeIds' => $EmployeeIds,
  3805.                 'departments' => $Departments,
  3806.                 'attendance' => $attendance,
  3807.                 'branches' => $branches,
  3808.                 'banks' => $banks,
  3809.                 'SalaryReports' => [],
  3810.                 'from_date' => '',
  3811.                 'to_date' => '',
  3812.                 'Qry' => '',
  3813.                 'isMethodGet' => true,
  3814.                 'filterType' => $filterType,
  3815.                 'startDate' => $startDate,
  3816.                 'endDate' => $endDate,
  3817.                 'filterBranchIds' => $filterBranchIds,
  3818.                 'filterBankIds' => $filterBankIds,
  3819.                 'filterDepartmentIds' => $filterDepartmentIds,
  3820.                 'filterEmployeeIds' => $filterEmployeeIds,
  3821.             ));
  3822.         }
  3823.         $SalaryReports HumanResource::BasicDeduction($em$request);
  3824. //        $SalaryReportsNew = HumanResource::calculateSalary($em,
  3825. //            array(
  3826. //                'startDate' => $request->get('salary_start_date', ''),
  3827. //                'endDate' => $request->get('salary_end_date', ''),
  3828. //                'timeZone' => $request->get('time_zone', '+0600'),
  3829. //                'employeeIds' => $request->get('employeeIds', []),
  3830. //                'departmentIds' => $request->get('department', []),
  3831. //                'allFlag' => $request->get('show_all', 0),
  3832. //
  3833. //            )
  3834. //        );
  3835.         $Qry "salary_till_date=" $endDate '&' "departmentIds=" implode(','$filterDepartmentIds) . '&' "employeeIds=" implode(','$filterEmployeeIds) .
  3836.             '&' "salary_start_date=" $startDate .
  3837.             '&' "filterType=" $filterType .
  3838.             '&' "branchIds=" implode(','$filterBranchIds) .
  3839.             '&' "bankIds=" implode(','$filterBankIds);
  3840. //        if ($request->get('returnJson', 0) == 1) {
  3841.         if ($request->get('returnJson'0) == 1) {
  3842.             return new JsonResponse(array(
  3843.                 'SalaryReports' => $SalaryReports,
  3844.             ));
  3845.         } else {
  3846.             return $this->render('ApplicationBundle:pages/human_resource/report:disburse_salary.html.twig', array(
  3847.                 'page_title' => 'Disburse Salary',
  3848.                 'EmployeeIds' => $EmployeeIds,
  3849.                 'departments' => $Departments,
  3850.                 'branches' => $branches,
  3851.                 'banks' => $banks,
  3852.                 'SalaryReports' => $SalaryReports,
  3853.                 'for_month' => $SalaryReports[0]['for_month'],
  3854.                 'from_date' => $SalaryReports[0]['from_date'],
  3855.                 'to_date' => $SalaryReports[0]['to_date'],
  3856.                 'Qry' => $Qry,
  3857.                 'isMethodGet' => false,
  3858.                 'startDate' => $startDate,
  3859.                 'endDate' => $endDate,
  3860.                 'filterType' => $filterType,
  3861.                 'filterBranchIds' => $filterBranchIds,
  3862.                 'filterBankIds' => $filterBankIds,
  3863.                 'filterDepartmentIds' => $filterDepartmentIds,
  3864.                 'filterEmployeeIds' => $filterEmployeeIds,
  3865.             ));
  3866.         }
  3867.     }
  3868.     public function PrintDisburseSalaryAction(Request $Req)
  3869.     {
  3870.         $em $this->getDoctrine()->getManager();
  3871.         $company_data Company::getCompanyData($em1);
  3872.         $SalaryReports HumanResource::BasicDeduction($em$Req);
  3873.         return $this->render(
  3874.             'ApplicationBundle:pages/human_resource/print:print_disburse_salary.html.twig',
  3875.             array(
  3876.                 'page_title' => 'Print Disburse Salary',
  3877.                 'export' => 'pdf,print',
  3878.                 'company_name' => $company_data->getName(),
  3879.                 'company_data' => $company_data,
  3880.                 'company_address' => $company_data->getAddress(),
  3881.                 'company_image' => $company_data->getImage(),
  3882.                 'SalaryReports' => $SalaryReports,
  3883.                 'for_month' => $SalaryReports[0]['for_month'],
  3884.                 'from_date' => $SalaryReports[0]['from_date'],
  3885.                 'to_date' => $SalaryReports[0]['to_date'],
  3886.                 'red' => 0
  3887.             )
  3888.         );
  3889.     }
  3890.     public function SalaryReportAction(Request $request)
  3891.     {
  3892.         $em $this->getDoctrine()->getManager();
  3893.         $startDate $request->get('salary_start_date''');
  3894.         $endDate $request->get('salary_till_date''');
  3895.         $segregationType $request->get('segregationType'1);
  3896.         $filterBranchIds $request->get('branchIds', []);
  3897.         $filterBankIds $request->get('bankIds', []);
  3898.         $approvalFilterTypes $request->get('approvalFilterTypes', []);
  3899.         $filterDepartmentIds $request->get('departmentIds', []);
  3900.         $filterEmployeeIds $request->get('employeeIds', []);
  3901.         $Departments $em->getRepository(SysDepartment::class)->findAll();
  3902.         $attendance $em->getRepository(EmployeeAttendanceLog::class)->findAll();
  3903.         $banks $em->getRepository(BankList::class)->findAll();
  3904.         $branches $em->getRepository(Branch::class)->findAll();
  3905.         $SalaryReports HumanResource::GenerateSalaryReport($em$request);
  3906. //        dump($SalaryReports);
  3907.         $Qry "salary_till_date=" $endDate '&' "departmentIds=" implode(','$filterDepartmentIds) . '&' "employeeIds=" implode(','$filterEmployeeIds) .
  3908.             '&' "salary_start_date=" $startDate .
  3909.             '&' "segregationType=" $segregationType .
  3910.             '&' "branchIds=" implode(','$filterBranchIds) .
  3911.             '&' "bankIds=" implode(','$filterBankIds);
  3912. //        if ($request->get('returnJson', 0) == 1) {
  3913.         if ($request->get('returnJson'0) == 1) {
  3914.             return new JsonResponse(array(
  3915.                 'SalaryReports' => $SalaryReports,
  3916.             ));
  3917.         } else {
  3918.             return $this->render('ApplicationBundle:pages/human_resource/report:salary_report.html.twig', array(
  3919.                 'page_title' => 'Salary Report',
  3920.                 'departments' => $Departments,
  3921.                 'branches' => $branches,
  3922.                 'banks' => $banks,
  3923.                 'approvalFilterTypes' => $approvalFilterTypes,
  3924.                 'salaryInfo' => $SalaryReports,
  3925.                 'SalaryReports' => $SalaryReports,
  3926.                 'for_month' => '',
  3927.                 'from_date' => $startDate,
  3928.                 'to_date' => $endDate,
  3929.                 'Qry' => $Qry,
  3930.                 'isMethodGet' => false,
  3931.                 'startDate' => $startDate,
  3932.                 'endDate' => $endDate,
  3933.                 'segregationType' => $segregationType,
  3934.                 'filterBranchIds' => $filterBranchIds,
  3935.                 'filterBankIds' => $filterBankIds,
  3936.                 'filterDepartmentIds' => $filterDepartmentIds,
  3937.                 'filterEmployeeIds' => $filterEmployeeIds,
  3938.             ));
  3939.         }
  3940.     }
  3941.     public function createJobRecruitmentAction(Request $request$id 0)
  3942.     {
  3943.         $data = [];
  3944.         $em_goc $this->getDoctrine()->getManager('company_group');
  3945.         $skillDetails $em_goc->getRepository(EntitySkill::class)->findAll();
  3946.         $em $this->getDoctrine()->getManager();
  3947.         $companyId $this->getLoggedUserCompanyId($request);
  3948.         if ($request->isMethod('POST')) {
  3949.             $em $this->getDoctrine()->getManager();
  3950.             $entity_id array_flip(GeneralConstant::$Entity_list)['JobRecruitment']; //change
  3951.             $dochash $request->request->get('docHash'); //change
  3952.             $loginId $request->getSession()->get(UserConstants::USER_LOGIN_ID);
  3953.             $approveRole $request->request->get('approvalRole');
  3954.             $approveHash $request->request->get('approvalHash');
  3955.             if (!DocValidation::isInsertable($em$entity_id$dochash,
  3956.                 $loginId$approveRole$approveHash$id)
  3957.             ) {
  3958.                 $this->addFlash(
  3959.                     'error',
  3960.                     'Sorry Could not insert Data.'
  3961.                 );
  3962.             } else {
  3963.                 $data $request->request;
  3964.                 $docId HumanResource::createJobRecruitment($em$loginId$id$data$companyId);
  3965.                 //now add Approval info
  3966.                 $approveRole $request->request->get('approvalRole');
  3967.                 $options = array(
  3968.                     'notification_enabled' => $this->container->getParameter('notification_enabled'),
  3969.                     'notification_server' => $this->container->getParameter('notification_server'),
  3970.                     'appId' => $request->getSession()->get(UserConstants::USER_APP_ID),
  3971.                     'url' => $this->generateUrl(
  3972.                         GeneralConstant::$Entity_list_details[array_flip(GeneralConstant::$Entity_list)['JobRecruitment']]
  3973.                         ['entity_view_route_path_name']
  3974.                     )
  3975.                 );
  3976.                 System::setApprovalInfo($this->getDoctrine()->getManager(), $options,
  3977.                     array_flip(GeneralConstant::$Entity_list)['JobRecruitment'],
  3978.                     $docId,
  3979.                     $request->getSession()->get(UserConstants::USER_LOGIN_ID)    //journal voucher
  3980.                 );
  3981.                 System::createEditSignatureHash($this->getDoctrine()->getManager(), array_flip(GeneralConstant::$Entity_list)['JobRecruitment'],
  3982.                     $docId,
  3983.                     $loginId,
  3984.                     $approveRole,
  3985.                     $request->request->get('approvalHash'));
  3986.                 $this->addFlash(
  3987.                     'success',
  3988.                     'New Recruitment Document Added.'
  3989.                 );
  3990.                 $url $this->generateUrl(
  3991.                     'view_job_recruitment'
  3992.                 );
  3993.                 return $this->redirect($url "/" $docId);
  3994.             }
  3995.         }
  3996.         if ($id == 0) {
  3997.         } else {
  3998.             $extDoc $em->getRepository('ApplicationBundle:JobRecruitment')->findOneBy(
  3999.                 array(
  4000.                     'jobRecruitmentId' => $id///material
  4001.                 )
  4002.             );
  4003.             //now if its not editable, redirect to view
  4004.             if ($extDoc) {
  4005.                 if ($extDoc->getEditFlag() != 1) {
  4006.                     $url $this->generateUrl(
  4007.                         'view_job_recruitment'
  4008.                     );
  4009.                     return $this->redirect($url "/" $id);
  4010.                 }
  4011.             }
  4012.         }
  4013.         $jobType HumanResourceConstant::$employeeType;
  4014.         //$skillDetails = $em->getRepository(Skill::class)->findAll();
  4015.         $educationDetails $em->getRepository('ApplicationBundle:EducationQualification')->findAll();
  4016.         $employeeIds $em->getRepository('ApplicationBundle:Employee')->findAll();
  4017.         $location HumanResourceConstant::$location;
  4018.         $salaryPer HumanResourceConstant::$salaryPer;
  4019.         $workExperience HumanResourceConstant::$workExperience;
  4020.         $jobOpeningStatus HumanResourceConstant::$jobOpeningStatus;
  4021.         $compatibility HumanResourceConstant::$compatibility;
  4022.         return $this->render('ApplicationBundle:pages/human_resource/input_forms:create_new_job_post.html.twig', [
  4023.             'page_title' => 'Create New Job Post',
  4024.             'jobType' => $jobType,
  4025.             'skillDetails' => $skillDetails,
  4026.             'educationDetails' => $educationDetails,
  4027.             'employeeIds' => $employeeIds,
  4028.             'location' => $location,
  4029.             'salaryPer' => $salaryPer,
  4030.             'workExperience' => $workExperience,
  4031.             'jobOpeningStatus' => $jobOpeningStatus,
  4032.             'compatibility' => $compatibility
  4033.         ]);
  4034.     }
  4035.     public function viewApplicantInfoAction(Request $request$id)
  4036.     {
  4037.         $em $this->getDoctrine()->getManager('company_group');
  4038.         //$session = $request->getSession();
  4039.         $consultantDetails $em->getRepository(EntityApplicantDetails::class)->find($id);
  4040.         $skillDetails $em->getRepository('CompanyGroupBundle:EntitySkill')->findAll();
  4041.         //$companyId = $this->getLoggedUserCompanyId($request);
  4042.         $gender HumanResourceConstant::$sex;
  4043.         $blood HumanResourceConstant::$BloodGroup;
  4044.         //$userId = $session->get(UserConstants::USER_ID);
  4045.         return $this->render('ApplicationBundle:pages/human_resource/views:view_applicant_info.html.twig', [
  4046.             'page_title' => 'Applicant Information',
  4047.             'gender' => $gender,
  4048.             'blood' => $blood,
  4049.             'consultantDetails' => $consultantDetails,
  4050.             'education' => json_decode($consultantDetails->getEducationData(), true),
  4051.             'workExperience' => json_decode($consultantDetails->getWorkExperienceData(), true),
  4052.             'certificate' => json_decode($consultantDetails->getCertificateData(), true),
  4053.             'courses' => json_decode($consultantDetails->getCoursesData(), true),
  4054.             'languages' => json_decode($consultantDetails->getLanguagesData(), true),
  4055.             'skillDetails' => $skillDetails
  4056.         ]);
  4057.     }
  4058.     public function ListJobRecruitmentAction()
  4059.     {
  4060.         $em $this->getDoctrine()->getManager();
  4061.         $jobRecruitmentList = [];
  4062.         $jobRecruitments $em->getRepository('ApplicationBundle:JobRecruitment')->findAll();
  4063.         foreach ($jobRecruitments as $jobRecruitment) {
  4064.             $jobData = array(
  4065.                 'jobRecruitmentId' => $jobRecruitment->getJobRecruitmentId(),
  4066.                 'title' => $jobRecruitment->getTitle(),
  4067.                 'date' => $jobRecruitment->getDate(),
  4068.                 'jobOpeningStatus' => $jobRecruitment->getJobOpeningStatus(),
  4069.                 'applicationOpeningDate' => $jobRecruitment->getApplicationOpeningDate(),
  4070.                 'applicationClosingDate' => $jobRecruitment->getApplicationClosingDate(),
  4071.             );
  4072.             $jobRecruitmentList[] = $jobData;
  4073.         }
  4074.         return $this->render('ApplicationBundle:pages/human_resource/list:job_recruitment_list.html.twig', [
  4075.             'page_title' => 'Job RecruitmentAction List',
  4076.             'jobRecruitments' => $jobRecruitmentList
  4077.         ]);
  4078.     }
  4079.     public function ViewJobRecruitmentAction(Request $request$id 0)
  4080.     {
  4081.         $em_goc $this->getDoctrine()->getManager('company_group');
  4082.         $skillDetails $em_goc->getRepository('CompanyGroupBundle:EntitySkill')->findAll();
  4083.         $em $this->getDoctrine()->getManager();
  4084.         $companyId $this->getLoggedUserCompanyId($request);
  4085.         $company_data Company::getCompanyData($em$companyId);
  4086. //        return new JsonResponse($encryptedDataArray);
  4087.         $location HumanResourceConstant::$location;
  4088.         $salaryPer HumanResourceConstant::$salaryPer;
  4089.         $workExperience HumanResourceConstant::$workExperience;
  4090.         $jobOpeningStatus HumanResourceConstant::$jobOpeningStatus;
  4091.         $compatibility HumanResourceConstant::$compatibility;
  4092.         $jobType HumanResourceConstant::$employeeType;
  4093.         $educationDetail $em->getRepository(EducationQualification::class)->findAll();
  4094.         $jobRecruitments $em->getRepository('ApplicationBundle:JobRecruitment')->find($id);
  4095.         $em_goc $this->getDoctrine()->getManager('company_group');
  4096.         $applicantApplicationList $em_goc->getRepository("CompanyGroupBundle:EntityApplicantApplicationList")->findBy(
  4097.             array(
  4098.                 'jobPostId' => $id,
  4099.                 'CompanyId' => $companyId,
  4100.                 'appId' => $company_data->getAppId()
  4101.             )
  4102.         );
  4103.         $applicantIdList = [];
  4104.         foreach ($applicantApplicationList as $dt) {
  4105.             $applicantIdList[] = $dt->getApplicantId();
  4106.         }
  4107.         $applicantList ApplicantM::getApplicantList($em_goc$applicantIdList);
  4108.         $Approval_data = [
  4109.             'exists' => 0,
  4110.             'approvalId' => 0,
  4111.             'roleType' => 0,
  4112.             'required' => 0,
  4113.             'acted' => 0,
  4114.             'entity' => array_flip(GeneralConstant::$Entity_list)['JobRecruitment'],
  4115.             'entityId' => $id,
  4116.         ];
  4117.         if (in_array($request->getSession()->get(UserConstants::USER_TYPE), [125]))
  4118.             $Approval_data System::checkIfApprovalExists(
  4119.                 $em,
  4120.                 array_flip(GeneralConstant::$Entity_list)['JobRecruitment'],
  4121.                 $id,
  4122.                 $request->getSession()->get(UserConstants::USER_LOGIN_ID)
  4123.             );
  4124.         return $this->render('ApplicationBundle:pages/human_resource/views:view_job_recruitment.html.twig', [
  4125.             'page_title' => 'View Job RecruitmentAction',
  4126.             'jobRecruitments' => $jobRecruitments,
  4127.             'applicantApplicationList' => $applicantApplicationList,
  4128.             'applicantList' => $applicantList,
  4129. //            'encryptedData' => $encryptedData,
  4130.             'skills' => json_decode($jobRecruitments->getskills()),
  4131.             'skillDetails' => $skillDetails,
  4132.             'education' => json_decode($jobRecruitments->getEducations()),
  4133.             'educationDetails' => $educationDetail,
  4134.             'location' => $location,
  4135.             'salaryPer' => $salaryPer,
  4136.             'workExperience' => $workExperience,
  4137.             'jobType' => $jobType,
  4138.             'compatibility' => $compatibility,
  4139.             'approval_status' => $jobRecruitments->getApproved(),
  4140.             'jobOpeningStatus' => $jobOpeningStatus,
  4141.             'approval_data' => $Approval_data,
  4142.             'auto_created' => $jobRecruitments->getAutocreated(),
  4143.             'document_log' => $jobRecruitments->getAutocreated() == System::getDocumentLog(
  4144.                 $em,
  4145.                 array_flip(GeneralConstant::$Entity_list)['JobRecruitment'],
  4146.                 $id,
  4147.                 $jobRecruitments->getCreatedLoginId(),
  4148.                 $jobRecruitments->getEditedLoginId()
  4149.             ) : []
  4150.         ]);
  4151.     }
  4152.     public function ViewApplicantScheduleAction(Request $request$id 0)
  4153.     {
  4154.         $em $this->getDoctrine()->getManager();
  4155.         $companyId $this->getLoggedUserCompanyId($request);
  4156.         $company_data Company::getCompanyData($em$companyId);
  4157.         $em_goc $this->getDoctrine()->getManager('company_group');
  4158.         $applicantApplicationList $em_goc->getRepository("CompanyGroupBundle:EntityApplicantApplicationList")->findBy(
  4159.             array(
  4160.                 'jobPostId' => $id,
  4161.                 'CompanyId' => $companyId,
  4162.                 'appId' => $company_data->getAppId()
  4163.             )
  4164.         );
  4165.         $applicantIdList = [];
  4166.         foreach ($applicantApplicationList as $dt) {
  4167.             $applicantIdList[] = $dt->getApplicantId();
  4168.         }
  4169.         $applicantList ApplicantM::getApplicantList($em_goc$applicantIdList);
  4170.         return $this->render('ApplicationBundle:pages/human_resource/views:view_applicant_scheduled.html.twig', [
  4171.             'page_title' => 'View Applicant Scheduled',
  4172.             'applicantApplicationList' => $applicantApplicationList,
  4173.             'applicantList' => $applicantList,
  4174.         ]);
  4175.     }
  4176.     public function ViewApplicantReportAction(Request $request$id 0)
  4177.     {
  4178.         $em $this->getDoctrine()->getManager();
  4179.         $companyId $this->getLoggedUserCompanyId($request);
  4180.         $company_data Company::getCompanyData($em$companyId);
  4181.         $em_goc $this->getDoctrine()->getManager('company_group');
  4182.         $applicantApplicationList $em_goc->getRepository("CompanyGroupBundle:EntityApplicantApplicationList")->findBy(
  4183.             array(
  4184.                 'jobPostId' => $id,
  4185.                 'CompanyId' => $companyId,
  4186.                 'appId' => $company_data->getAppId()
  4187.             )
  4188.         );
  4189.         $applicantIdList = [];
  4190.         foreach ($applicantApplicationList as $dt) {
  4191.             $applicantIdList[] = $dt->getApplicantId();
  4192.         }
  4193.         $applicantList ApplicantM::getApplicantList($em_goc$applicantIdList);
  4194.         return $this->render('ApplicationBundle:pages/human_resource/views:view_applicant_report.html.twig', [
  4195.             'page_title' => 'View Applicant Report',
  4196.             'applicantApplicationList' => $applicantApplicationList,
  4197.             'applicantList' => $applicantList,
  4198.         ]);
  4199.     }
  4200.     public function createEmployeePerformanceEvaluationAction(Request $request$id 0)
  4201.     {
  4202.         $data = [];
  4203.         $em $this->getDoctrine()->getManager();
  4204.         $companyId $this->getLoggedUserCompanyId($request);
  4205.         if ($request->isMethod('POST')) {
  4206.             $em $this->getDoctrine()->getManager();
  4207.             $entity_id array_flip(GeneralConstant::$Entity_list)['EmployeePerformanceEvolution']; //change
  4208.             $dochash $request->request->get('docHash'); //change
  4209.             $loginId $request->getSession()->get(UserConstants::USER_LOGIN_ID);
  4210.             $approveRole $request->request->get('approvalRole');
  4211.             $approveHash $request->request->get('approvalHash');
  4212.             if (!DocValidation::isInsertable($em$entity_id$dochash,
  4213.                 $loginId$approveRole$approveHash$id)
  4214.             ) {
  4215.                 $this->addFlash(
  4216.                     'error',
  4217.                     'Sorry Could not insert Data.'
  4218.                 );
  4219.             } else {
  4220.                 $data $request->request;
  4221.                 $docId HumanResource::createEmployeePerformanceEvaluation($em$loginId$id$data$companyId);
  4222.                 //now add Approval info
  4223.                 $approveRole $request->request->get('approvalRole');
  4224.                 $options = array(
  4225.                     'notification_enabled' => $this->container->getParameter('notification_enabled'),
  4226.                     'notification_server' => $this->container->getParameter('notification_server'),
  4227.                     'appId' => $request->getSession()->get(UserConstants::USER_APP_ID),
  4228.                     'url' => $this->generateUrl(
  4229.                         GeneralConstant::$Entity_list_details[array_flip(GeneralConstant::$Entity_list)['EmployeePerformanceEvolution']]
  4230.                         ['entity_view_route_path_name']
  4231.                     )
  4232.                 );
  4233.                 System::setApprovalInfo($this->getDoctrine()->getManager(), $options,
  4234.                     array_flip(GeneralConstant::$Entity_list)['JobRecruitment'],
  4235.                     $docId,
  4236.                     $request->getSession()->get(UserConstants::USER_LOGIN_ID)    //journal voucher
  4237.                 );
  4238.                 System::createEditSignatureHash($this->getDoctrine()->getManager(), array_flip(GeneralConstant::$Entity_list)['EmployeePerformanceEvolution'],
  4239.                     $docId,
  4240.                     $loginId,
  4241.                     $approveRole,
  4242.                     $request->request->get('approvalHash'));
  4243.                 $this->addFlash(
  4244.                     'success',
  4245.                     'New Recruitment Document Added.'
  4246.                 );
  4247.                 $url $this->generateUrl(
  4248.                     'view_employee_performance_evolution'
  4249.                 );
  4250.                 return $this->redirect($url "/" $docId);
  4251.             }
  4252.         }
  4253.         $skill $em->getRepository(Skill::class)->findAll();
  4254.         $educationDetail $em->getRepository(EducationQualification::class)->findAll();
  4255.         $employeeIds $em->getRepository(EmployeeDetails::class)->findAll();
  4256.         $employeeType HumanResourceConstant::$employeeType;
  4257.         $Designation $em->getRepository(SysDepartmentPosition::class)->findAll();
  4258.         $branch $em->getRepository(Branch::class)->findAll();
  4259.         $departments $em->getRepository(SysDepartment::class)->findAll();
  4260.         $department = [];
  4261.         foreach ($departments as $entry) {
  4262.             $department[$entry->getDepartmentId()] = array(
  4263.                 'id' => $entry->getDepartmentId(),
  4264.                 'name' => $entry->getDepartmentName(),
  4265.             );
  4266.         }
  4267.         return $this->render('ApplicationBundle:pages/human_resource/input_forms:employee_performance_evolution.html.twig',
  4268.             array(
  4269.                 'page_title' => 'Create Employee Performance Evaluation',
  4270.                 'employeeIds' => $employeeIds,
  4271.                 'employeeType' => $employeeType,
  4272.                 'Designation' => $Designation,
  4273.                 'branch' => $branch,
  4274.                 'department' => $department,
  4275.                 'skill' => $skill,
  4276.                 'educationDetail' => $educationDetail
  4277.             )
  4278.         );
  4279.     }
  4280.     public function ViewIndividualReviewAction()
  4281.     {
  4282.         return $this->render('ApplicationBundle:pages/human_resource/views:individual_review.html.twig',
  4283.             array(
  4284.                 'page_title' => 'Individual Performance View',
  4285.             )
  4286.         );
  4287.     }
  4288.     public function EmployeeListBySkillPerformanceAction()
  4289.     {
  4290.         $em $this->getDoctrine()->getManager();
  4291.         $employee $em->getRepository('ApplicationBundle:EmployeeDetails')->findAll();
  4292.         $skill $em->getRepository('ApplicationBundle:Skill')->findAll();
  4293.         return $this->render('ApplicationBundle:pages/human_resource/list:employee_performance_evolution_list.html.twig',
  4294.             array(
  4295.                 'page_title' => 'Employee Skill & Performance',
  4296.                 'employee' => $employee,
  4297.                 //'employeeSkill' => json_decode($employee->getSkill(),true),
  4298.                 'skill' => $skill,
  4299.             )
  4300.         );
  4301.     }
  4302.     public function setWorkPlaceAction(Request $req)
  4303.     {
  4304.         $em $this->getDoctrine()->getManager();
  4305.         $companyId $this->getLoggedUserCompanyId($req);
  4306.         $docHash '';
  4307.         if ($req->request->has('XHRreq')) {
  4308.             $docHash HumanResource::HandelXHRreqForEmpWorkplace($em$req);
  4309.             return new JsonResponse([$docHash]);
  4310.         }
  4311.         if ($req->isMethod('GET')) {
  4312.             $TwigData HumanResource::TwigDataForEmployeeWorkplace($em);
  4313.             return $this->render(
  4314.                 'ApplicationBundle:pages/human_resource/input_forms:update_workplace.html.twig',
  4315.                 [
  4316.                     'page_title' => 'Set Workplace',
  4317.                     'employeeIds' => $TwigData['employeeIds']
  4318.                 ]
  4319.             );
  4320.         }
  4321.         if ($req->isMethod('POST')) {
  4322.             $approveHash $req->request->get('approvalHash');
  4323.             $loginId $req->getSession()->get(UserConstants::USER_LOGIN_ID);
  4324.             $isSignatureOk DocValidation::isSignatureOk($em$loginId$approveHash);
  4325.             if ($isSignatureOk) {
  4326.                 $isSuccess HumanResource::CreateOrUpdateForEmpWorkplace($em$req$companyIdfalse$docHash);
  4327.                 if ($isSuccess) {
  4328.                     $this->addFlash(
  4329.                         'success',
  4330.                         'Workplace set!'
  4331.                     );
  4332.                     return $this->redirectToRoute('set_workplace');
  4333.                 }
  4334.             } else {
  4335.                 $this->addFlash(
  4336.                     'error',
  4337.                     'Invalid Approval Hash!'
  4338.                 );
  4339.                 return $this->redirectToRoute('set_workplace');
  4340.             }
  4341.         }
  4342.     }
  4343.     public function setWorkPlaceForAppAction(Request $req)
  4344.     {
  4345.         $em $this->getDoctrine()->getManager();
  4346.         $companyId $this->getLoggedUserCompanyId($req);
  4347.         $docHash HumanResource::HandelXHRreqForEmpWorkplace($em$req);
  4348.         if ($req->isMethod('GET')) {
  4349.             $TwigData HumanResource::TwigDataForEmployeeWorkplace($em);
  4350.             return $this->render(
  4351.                 'ApplicationBundle:pages/human_resource/input_forms:update_workplace.html.twig',
  4352.                 [
  4353.                     'page_title' => 'Set Workplace',
  4354.                     'employeeIds' => $TwigData['employeeIds']
  4355.                 ]
  4356.             );
  4357.         }
  4358.         if ($req->isMethod('POST')) {
  4359.             $approveHash $req->request->get('approvalHash');
  4360.             $loginId $req->getSession()->get(UserConstants::USER_LOGIN_ID);
  4361.             $isSignatureOk DocValidation::isSignatureOk($em$loginId$approveHash);
  4362.             if ($isSignatureOk) {
  4363.                 $isSuccess HumanResource::CreateOrUpdateForEmpWorkplace($em$req$companyIdfalse$docHash);
  4364.                 if ($isSuccess) {
  4365.                     $this->addFlash(
  4366.                         'success',
  4367.                         'Workplace set!'
  4368.                     );
  4369. //                    return $this->redirectToRoute('set_workplace');
  4370.                     return new JsonResponse(array(
  4371.                         "success" => true
  4372.                     ));
  4373.                 }
  4374.             } else {
  4375.                 $this->addFlash(
  4376.                     'error',
  4377.                     'Invalid Approval Hash!'
  4378.                 );
  4379. //                return $this->redirectToRoute('set_workplace');
  4380.             }
  4381.         }
  4382.     }
  4383.     public function ViewMeetingAction(Request $req$action 0$id 0)
  4384.     {
  4385.         $em $this->getDoctrine()->getManager();
  4386.         $companyId $this->getLoggedUserCompanyId($req);
  4387.         if ($req->request->has('XHRreq')) {
  4388.             return new JsonResponse([HumanResource::HandelXHRreqForMeetingScheduling($em$req)]);
  4389.         }
  4390.         if ($action === 'view') {
  4391.             $response HumanResource::TwigDataForScheduledMeetingView($em$req$id);
  4392.             return $this->render(
  4393.                 'ApplicationBundle:pages/human_resource/views:scheduled_meeting_view.html.twig',
  4394.                 [
  4395.                     'page_title' => 'View Scheduled Meeting',
  4396.                     'duration' => $response['duration'],
  4397.                     'appId' => $response['appId'],
  4398.                     'publicView' => 0,
  4399.                     'meeting_data' => $response['meeting_data'],
  4400.                     'agenda_list' => $response['agenda_list'],
  4401.                     'id' => $req->query->get('view_meeting'),
  4402.                     'approval_data' => $response['approval_data'],
  4403.                     'document_log' => $response['document_log'],
  4404.                     'approval_status' => $response['approval_status'],
  4405.                     'created_by' => $response['created_by'],
  4406.                     'updated_at' => $response['updated_at'],
  4407.                     'auto_created' => 0,
  4408.                 ]
  4409.             );
  4410.         }
  4411.         if ($action === 'print') {
  4412.             $response HumanResource::TwigDataForScheduledMeetingView($em$req$id);
  4413. //      $id = $req->query->get('print_meeting');
  4414.             $em $this->getDoctrine()->getManager();
  4415.             $company_data Company::getCompanyData($em1);
  4416.             $Authorizations System::getSignatureListForDocumentPrint($emarray_flip(GeneralConstant::$Entity_list)['ScheduledMeeting'], $id);
  4417.             return $this->render(
  4418.                 'ApplicationBundle:pages/human_resource/print:scheduled_meeting_print.html.twig',
  4419.                 array(
  4420.                     'page_title' => 'View Scheduled Meeting',
  4421.                     'duration' => $response['duration'],
  4422.                     'meeting_data' => $response['meeting_data'],
  4423.                     'agenda_list' => $response['agenda_list'],
  4424.                     'export' => 'pdf,print',
  4425.                     'company_name' => $company_data->getName(),
  4426.                     'company_data' => $company_data,
  4427.                     'company_address' => $company_data->getAddress(),
  4428.                     'company_image' => $company_data->getImage(),
  4429.                     'Authorizations' => $Authorizations,
  4430.                     'red' => 0
  4431.                 )
  4432.             );
  4433.         }
  4434.     }
  4435.     public function UpdateMeetingMinutesAction(Request $req$action 0$id 0)
  4436.     {
  4437.         $em $this->getDoctrine()->getManager();
  4438.         $companyId $this->getLoggedUserCompanyId($req);
  4439.         $scheduleId $req->request->get('scheduleId');
  4440.         $minuteText $req->request->get('minuteText');
  4441.         $agendaKey $req->request->get('key');
  4442.         $scheduledMeeting $em->getRepository(ScheduledMeeting::class)
  4443.             ->find($scheduleId);
  4444.         $agendaList json_decode($scheduledMeeting->getAgendaList(), true);
  4445.         foreach ($agendaList as $key => $item) {
  4446.             if ($key == $agendaKey)
  4447.                 $agendaList[$key]['minutes'] = $minuteText;
  4448.         }
  4449.         $scheduledMeeting->setAgendaList(json_encode($agendaList));
  4450.         $em->flush();
  4451.         return new JsonResponse(array(
  4452.             'success' => true
  4453.         ));
  4454.     }
  4455.     public function deleteLastAttendanceAction(Request $request)
  4456.     {
  4457.         $em $this->getDoctrine()->getManager();
  4458.         $lastAttendance $em->getRepository('ApplicationBundle:EmployeeAttendance')
  4459.             ->createQueryBuilder('ea')
  4460.             ->orderBy('ea.id''DESC')
  4461.             ->setMaxResults(1)
  4462.             ->getQuery()
  4463.             ->getOneOrNullResult();
  4464.         $lastAttendanceLog $em->getRepository('ApplicationBundle:EmployeeAttendanceLog')
  4465.             ->createQueryBuilder('eal')
  4466.             ->orderBy('eal.id''DESC')
  4467.             ->setMaxResults(1)
  4468.             ->getQuery()
  4469.             ->getOneOrNullResult();
  4470.         $deletedCount 0;
  4471.         if ($lastAttendance) {
  4472.             $em->remove($lastAttendance);
  4473.             $deletedCount++;
  4474.         }
  4475.         if ($lastAttendanceLog) {
  4476.             $em->remove($lastAttendanceLog);
  4477.             $deletedCount++;
  4478.         }
  4479.         $em->flush();
  4480.         return new JsonResponse(
  4481.             [
  4482.                 'success' => true,
  4483.                 'message' => "Deleted `$deletedCount` rows from attendance tables."
  4484.             ]
  4485.         );
  4486.     }
  4487.     public function SendMeetingUpdatesAction(Request $req$action 0$id 0)
  4488.     {
  4489.         $em $this->getDoctrine()->getManager();
  4490.         $companyId $this->getLoggedUserCompanyId($req);
  4491.         $session $req->getSession();
  4492.         $companyData Company::getCompanyData($em$companyId);
  4493.         $scheduleId $req->request->get('scheduleId');
  4494.         $minuteText $req->request->get('minuteText');
  4495.         $agendaKey $req->request->get('key');
  4496.         $scheduledMeeting $em->getRepository(ScheduledMeeting::class)
  4497.             ->find($scheduleId);
  4498.         $sendEmailInvitationTo json_decode($scheduledMeeting->getAllParticipantsNameEmail(), true);
  4499.         if ($sendEmailInvitationTo == null)
  4500.             $sendEmailInvitationTo = [];
  4501.         $agendaList json_decode($scheduledMeeting->getAgendaList(), true);
  4502.         if ($agendaList == null)
  4503.             $agendaList = [];
  4504.         $EmployeeList HumanResource::GetEmployeeList($em, []);
  4505.         $meetingType MeetingSchedulingConstant::$meetingType[$scheduledMeeting->getMeetingType()];
  4506.         foreach ($sendEmailInvitationTo as $key => $email) {
  4507.             $name ucWords(str_replace("_"" "$key));
  4508.             $bodyHtml '';
  4509.             $bodyTemplate 'ApplicationBundle:email/meeting_scheduling:scheduled_meeting_update.html.twig';
  4510.             $bodyData = array(
  4511.                 'name' => $name,
  4512.                 'gocId' => $session->get(UserConstants::USER_GOC_ID),
  4513.                 'appId' => $session->get(UserConstants::USER_APP_ID),
  4514.                 'email' => $email,
  4515.                 'meetingData' => $scheduledMeeting,
  4516.                 'meeting_type' => $meetingType,
  4517.                 'agenda_list' => $agendaList,
  4518.                 'companyData' => $companyData,
  4519.                 'employeeList' => $EmployeeList,
  4520.             );
  4521.             $attachments = [];
  4522.             $new_mail $this->get('mail_module');
  4523.             $new_mail->sendMyMail(array(
  4524.                 'senderHash' => '_MEETING_',
  4525.                 'forwardToMailAddress' => $email,
  4526.                 'subject' => "Meeting Updates Arranged By - " $companyData->getName() . " on " $scheduledMeeting->getTitle() . ". ",
  4527.                 'fileName' => '',
  4528.                 'attachments' => $attachments,
  4529.                 'toAddress' => $email,
  4530.                 'mailTemplate' => $bodyTemplate,
  4531.                 'templateData' => $bodyData,
  4532.                 'embedCompanyImage' => 1,
  4533.                 'companyId' => $companyId,
  4534.                 'companyImagePath' => $companyData->getImage()
  4535.             ));
  4536.         }
  4537.         return new JsonResponse(array(
  4538.             'success' => true
  4539.         ));
  4540.     }
  4541.     public function meetingSchedulingAction(Request $req$action 0)
  4542.     {
  4543.         $em $this->getDoctrine()->getManager();
  4544.         $companyId $this->getLoggedUserCompanyId($req);
  4545.         $session $req->getSession();
  4546.         if ($req->request->has('XHRreq')) {
  4547.             return new JsonResponse([HumanResource::HandelXHRreqForMeetingScheduling($em$req)]);
  4548.         }
  4549.         if ($action === 'list') {
  4550.             $response HumanResource::TwigDataForScheduledMeetingList($em, [0null]);
  4551.             return $this->render(
  4552.                 'ApplicationBundle:pages/human_resource/list:scheduled_meeting_list.html.twig',
  4553.                 [
  4554.                     'page_title' => 'Scheduled Meeting List',
  4555.                     'list' => $response
  4556.                 ]
  4557.             );
  4558.         }
  4559.         if ($req->isMethod('GET')) {
  4560.             $response HumanResource::twigDataForMeetingScheduling($em);
  4561.             return $this->render(
  4562.                 'ApplicationBundle:pages/human_resource/input_forms:meeting_scheduling.html.twig',
  4563.                 [
  4564.                     'page_title' => 'Schedule a Meeting',
  4565.                     'employeeIds' => $response['employeeIds'],
  4566.                     'branches' => $response['branches'],
  4567.                     'asset' => $response['asset'],
  4568.                     'rooms' => $response['rooms'],
  4569.                     'sales_orders' => $response['salesOrders'],
  4570.                     'purchase_orders' => $response['purchaseOrders'],
  4571.                     'meeting_types' => $response['meetingType'],
  4572.                 ]
  4573.             );
  4574.         }
  4575.         if ($req->isMethod('POST')) {
  4576.             $approveHash $req->request->get('approvalHash');
  4577.             $approveRole $req->request->get('approvalRole');
  4578.             $loginId $req->getSession()->get(UserConstants::USER_LOGIN_ID);
  4579.             $isSignatureOk DocValidation::isSignatureOk($em$loginId$approveHash);
  4580.             $companyData Company::getCompanyData($em$companyId);
  4581.             if ($isSignatureOk) {
  4582.                 $isSuccess HumanResource::createOrUpdateDataForMeetingScheduling($em$req);
  4583.                 if ($isSuccess) {
  4584.                     $options = array(
  4585.                         'notification_enabled' => $this->container->getParameter('notification_enabled'),
  4586.                         'notification_server' => $this->container->getParameter('notification_server'),
  4587.                         'appId' => $req->getSession()->get(UserConstants::USER_APP_ID),
  4588.                         'url' => $this->generateUrl(
  4589.                             GeneralConstant::$Entity_list_details[array_flip(GeneralConstant::$Entity_list)['ScheduledMeeting']]['entity_view_route_path_name']
  4590.                         )
  4591.                     );
  4592.                     $meetingId $isSuccess[1];
  4593.                     System::setApprovalInfo(
  4594.                         $this->getDoctrine()->getManager(),
  4595.                         $options,
  4596.                         array_flip(GeneralConstant::$Entity_list)['ScheduledMeeting'],
  4597.                         $meetingId,
  4598.                         $req->getSession()->get(UserConstants::USER_LOGIN_ID),
  4599.                         0//normal meeting
  4600.                         0,
  4601.                         $this->get('mail_module')
  4602.                     );
  4603.                     System::createEditSignatureHash(
  4604.                         $this->getDoctrine()->getManager(),
  4605.                         array_flip(GeneralConstant::$Entity_list)['ScheduledMeeting'],
  4606.                         $meetingId,
  4607.                         $loginId,
  4608.                         $approveRole,
  4609.                         $req->request->get('approvalHash')
  4610.                     );
  4611.                     $url $this->generateUrl(
  4612.                         'view_scheduled_meeting'
  4613.                     );
  4614.                     return $this->redirect($url "/" $meetingId);
  4615.                 } else {
  4616.                     return new JsonResponse(array(
  4617.                         'success' => false
  4618.                     ));
  4619.                 }
  4620.             } else {
  4621.                 $this->addFlash(
  4622.                     'error',
  4623.                     'Invalid Approval Hash!'
  4624.                 );
  4625.                 return $this->redirectToRoute('meeting_scheduling');
  4626.             }
  4627.         }
  4628.         return $this->redirectToRoute('meeting_scheduling');
  4629.     }
  4630.     public function MeetingSchedulingForAppAction(Request $request): JsonResponse
  4631.     {
  4632.         $em $this->getDoctrine()->getManager();
  4633.         $session $request->getSession();
  4634.         $mailer $this->get('mail_module');
  4635.         $helper = new HumanResourceHelper($em$mailer);
  4636.         try {
  4637.             $data $request->request->all();
  4638.             $files $request->files->all();
  4639.             $companyId $this->getLoggedUserCompanyId($request);
  4640.             $meeting $helper->prepareMeeting($data$session);
  4641.             $agendaList = [];
  4642.             if (!empty($data['agendaList']) && is_array($data['agendaList'])) {
  4643.                 foreach ($data['agendaList'] as $index => $agendaData) {
  4644.                     $agenda = [
  4645.                         'title' => $agendaData['title'] ?? null,
  4646.                         'desc' => $agendaData['desc'] ?? null,
  4647.                         'notes' => $agendaData['notes'] ?? null,
  4648.                         'taggedDocuments' => $agendaData['taggedDocuments'] ?? [],
  4649.                         'otherDocuments' => [],
  4650.                     ];
  4651.                     if (!empty($files['agendaList'][$index]['otherDocuments'])) {
  4652.                         foreach ($files['agendaList'][$index]['otherDocuments'] as $uploadedFile) {
  4653.                             $uploadedFilePath $this->uploadMeetingFile($uploadedFile$request);
  4654.                             if ($uploadedFilePath) {
  4655.                                 $agenda['otherDocuments'][] = [
  4656.                                     'fileName' => basename($uploadedFilePath),
  4657.                                     'path' => $uploadedFilePath,
  4658.                                     'type' => $uploadedFile->getClientOriginalExtension(),
  4659.                                 ];
  4660.                             }
  4661.                         }
  4662.                     }
  4663.                     $agendaList[] = $agenda;
  4664.                 }
  4665.             }
  4666.             $meeting->setAgendaList(json_encode($agendaList));
  4667.             [$internalInfo$otherInfo$internalIds] = $helper->resolveParticipants(
  4668.                 $data['guests'] ?? [],
  4669.                 $session->get('userEmployeeId')
  4670.             );
  4671.             // Save **full participant objects** to DB
  4672.             $meeting->setInternalParticipantIds(!empty($internalInfo) ? json_encode($internalInfo) : null);
  4673.             $meeting->setOtherParticipantInfo(!empty($otherInfo) ? json_encode($otherInfo) : null);
  4674.             $meeting->setParticipantInfo(json_encode([
  4675.                 'internal' => $internalInfo,
  4676.                 'other' => $otherInfo,
  4677.             ]));
  4678.             // Persist the meeting
  4679.             $em->persist($meeting);
  4680.             $em->flush();
  4681.             // Send invitations
  4682.             $helper->sendInvitations($meeting$internalIds$otherInfo$companyId);
  4683.             return new JsonResponse([
  4684.                 'success' => true,
  4685.                 'message' => 'Meeting scheduled successfully',
  4686.                 'meetingId' => $meeting->getScheduleId(),
  4687.                 'documentHas' => $meeting->getDocumentHash(),
  4688.             ]);
  4689.         } catch (\Exception $e) {
  4690.             return new JsonResponse(['success' => false'error' => $e->getMessage()], 500);
  4691.         }
  4692.     }
  4693.     public function updateMeetingForAppAction(Request $requestint $meetingId): JsonResponse
  4694.     {
  4695.         $em $this->getDoctrine()->getManager();
  4696.         $session $request->getSession();
  4697.         $mailer $this->get('mail_module');
  4698.         $helper = new HumanResourceHelper($em$mailer);
  4699.         try {
  4700.             $data $request->request->all();
  4701.             $files $request->files->all();
  4702.             $meeting $em->getRepository(ScheduledMeeting::class)->find($meetingId);
  4703.             if (!$meeting) {
  4704.                 return new JsonResponse(['success' => false'error' => 'Meeting not found'], 404);
  4705.             }
  4706.             $meeting->setTitle($data['title'] ?? $meeting->getTitle());
  4707.             $meeting->setSpecialType($data['specialType'] ?? $meeting->getSpecialType());
  4708.             $meeting->setStartAt(!empty($data['startAt']) ? new \DateTime($data['startAt']) : $meeting->getStartAt());
  4709.             $meeting->setEndAt(!empty($data['endAt']) ? new \DateTime($data['endAt']) : $meeting->getEndAt());
  4710.             $meeting->setMeetingType($data['meetingType'] ?? $meeting->getMeetingType());
  4711.             $meeting->setLocation($data['location'] ?? $meeting->getLocation());
  4712.             $meeting->setRoomId($data['roomId'] ?? $meeting->getRoomId());
  4713.             $meeting->setDesc($data['desc'] ?? $meeting->getDesc());
  4714.             $meeting->setLastModifiedDate(new \DateTime());
  4715.             if (isset($data['agendaList']) && is_array($data['agendaList'])) {
  4716.                 $agendaList = [];
  4717.                 foreach ($data['agendaList'] as $index => $agendaData) {
  4718.                     $agenda = [
  4719.                         'title' => $agendaData['title'] ?? null,
  4720.                         'desc' => $agendaData['desc'] ?? null,
  4721.                         'notes' => $agendaData['notes'] ?? null,
  4722.                         'taggedDocuments' => $agendaData['taggedDocuments'] ?? [],
  4723.                         'otherDocuments' => [],
  4724.                     ];
  4725.                     if (!empty($files['agendaList'][$index]['otherDocuments'])) {
  4726.                         foreach ($files['agendaList'][$index]['otherDocuments'] as $uploadedFile) {
  4727.                             $uploadedFilePath $this->uploadMeetingFile($uploadedFile$request);
  4728.                             if ($uploadedFilePath) {
  4729.                                 $agenda['otherDocuments'][] = [
  4730.                                     'fileName' => basename($uploadedFilePath),
  4731.                                     'path' => $uploadedFilePath,
  4732.                                     'type' => $uploadedFile->getClientOriginalExtension(),
  4733.                                 ];
  4734.                             }
  4735.                         }
  4736.                     }
  4737.                     if (!empty($agendaData['otherDocumentsExisting'])) {
  4738.                         $agenda['otherDocuments'] = array_merge(
  4739.                             $agenda['otherDocuments'],
  4740.                             $agendaData['otherDocumentsExisting']
  4741.                         );
  4742.                     }
  4743.                     $agendaList[] = $agenda;
  4744.                 }
  4745.                 $meeting->setAgendaList(json_encode($agendaList));
  4746.             }
  4747.             if (isset($data['guests'])) {
  4748.                 [$internalIds$otherInfo] = $helper->resolveParticipants($data['guests'], $session->get('userEmployeeId'));
  4749.                 $meeting->setInternalParticipantIds(!empty($internalIds) ? json_encode($internalIds) : null);
  4750.                 $meeting->setOtherParticipantInfo(!empty($otherInfo) ? json_encode($otherInfo) : null);
  4751.             }
  4752.             $em->persist($meeting);
  4753.             $em->flush();
  4754.             if (isset($internalIds) || isset($otherInfo)) {
  4755.                 $helper->sendInvitations($meeting$internalIds ?? [], $otherInfo ?? [], $meeting->getCompanyId());
  4756.             }
  4757.             return new JsonResponse([
  4758.                 'success' => true,
  4759.                 'message' => 'Meeting updated successfully',
  4760.                 'meetingId' => $meeting->getScheduleId(),
  4761.                 'facilitator' => ['id' => $meeting->getFacilitatorId(), 'name' => $meeting->getFacilitatorName()],
  4762.                 'companyId' => $meeting->getCompanyId(),
  4763.                 'branchId' => $meeting->getBranchId(),
  4764.                 'internalParticipants' => json_decode($meeting->getInternalParticipantIds(), true) ?? [],
  4765.                 'otherParticipants' => json_decode($meeting->getOtherParticipantInfo(), true) ?? [],
  4766.                 'agendas' => json_decode($meeting->getAgendaList(), true) ?? [],
  4767.             ]);
  4768.         } catch (\Exception $e) {
  4769.             return new JsonResponse(['success' => false'error' => $e->getMessage()], 500);
  4770.         }
  4771.     }
  4772.     public function GetDocumentsForMeetingScheduleAppAction(Request $request): JsonResponse
  4773.     {
  4774.         $em $this->getDoctrine()->getManager();
  4775.         $hrHelper = new HumanResourceHelper($em);
  4776.         try {
  4777.             $documents $hrHelper->getAllDocumentsFromApproval($request);
  4778.             return ResponseStructure::success($documents'Documents fetched successfully');
  4779.         } catch (\Exception $e) {
  4780.             return ResponseStructure::error($e->getMessage());
  4781.         }
  4782.     }
  4783.     public function getMeetingsByDateAction(Request $request): JsonResponse
  4784.     {
  4785.         $em $this->getDoctrine()->getManager();
  4786.         $dateParam $request->query->get('date');
  4787.         $monthParam $request->query->get('month');
  4788.         $dayParam $request->query->get('day');
  4789.         $yearParam $request->query->get('year');
  4790.         $start $end null;
  4791.         try {
  4792.             if ($dateParam) {
  4793.                 if (strpos($dateParam',') !== false) {
  4794.                     [$startStr$endStr] = explode(','$dateParam);
  4795.                     $start = new \DateTime($startStr " 00:00:00");
  4796.                     $end = new \DateTime($endStr " 23:59:59");
  4797.                 } else {
  4798.                     $parts explode('-'$dateParam);
  4799.                     if (count($parts) === 3) {
  4800.                         $start = new \DateTime($dateParam " 00:00:00");
  4801.                         $end = new \DateTime($dateParam " 23:59:59");
  4802.                     } elseif (count($parts) === 2) {
  4803.                         $start = new \DateTime($dateParam "-01 00:00:00");
  4804.                         $end = (clone $start)->modify('last day of this month')->setTime(235959);
  4805.                     } else {
  4806.                         throw new \Exception("Invalid date format");
  4807.                     }
  4808.                 }
  4809.             } elseif ($monthParam) {
  4810.                 $year $yearParam ?: date('Y');
  4811.                 $monthDate = new \DateTime("first day of $monthParam $year");
  4812.                 $start = (clone $monthDate)->setTime(000);
  4813.                 $end = (clone $monthDate)->modify('last day of this month')->setTime(235959);
  4814.             } elseif ($dayParam) {
  4815.                 $year $yearParam ?: date('Y');
  4816.                 $startOfYear = new \DateTime("$year-01-01 00:00:00");
  4817.                 $endOfYear = new \DateTime("$year-12-31 23:59:59");
  4818.                 $meetings $em->getRepository(\ApplicationBundle\Entity\ScheduledMeeting::class)
  4819.                     ->createQueryBuilder('m')
  4820.                     ->where('m.startAt BETWEEN :start AND :end')
  4821.                     ->setParameter('start'$startOfYear)
  4822.                     ->setParameter('end'$endOfYear)
  4823.                     ->getQuery()
  4824.                     ->getResult();
  4825.                 $meetingType MeetingSchedulingConstant::$meetingType;
  4826.                 $data = [];
  4827.                 foreach ($meetings as $meeting) {
  4828.                     if (strtolower($meeting->getStartAt()->format('l')) === strtolower($dayParam)) {
  4829.                         $data[] = [
  4830.                             'id' => $meeting->getScheduleId(),
  4831.                             'title' => $meeting->getTitle(),
  4832.                             'desc' => $meeting->getDesc(),
  4833.                             'startAt' => $meeting->getStartAt()->format('Y-m-d H:i:s'),
  4834.                             'endAt' => $meeting->getEndAt() ? $meeting->getEndAt()->format('Y-m-d H:i:s') : null,
  4835.                             'roomId' => $meeting->getRoomId(),
  4836.                             'meetingType' => $meetingType[$meeting->getMeetingType()] ?? null,
  4837.                             'location' => $meeting->getLocation(),
  4838.                             'participant' => json_decode($meeting->getParticipantInfo()),
  4839.                             'status' => $meeting->getStatus(),
  4840.                             'approved' => (bool)$meeting->getApproved(),
  4841.                         ];
  4842.                     }
  4843.                 }
  4844.                 return new JsonResponse([
  4845.                     'success' => true,
  4846.                     'filter' => [
  4847.                         'day' => $dayParam,
  4848.                         'year' => $year
  4849.                     ],
  4850.                     'meetings' => $data
  4851.                 ]);
  4852.             } else {
  4853.                 return new JsonResponse([
  4854.                     'success' => false,
  4855.                     'error' => 'Please provide month, day, or date query parameter.'
  4856.                 ], 400);
  4857.             }
  4858.         } catch (\Exception $e) {
  4859.             return new JsonResponse([
  4860.                 'success' => false,
  4861.                 'error' => 'Invalid date format or input. ' $e->getMessage()
  4862.             ], 400);
  4863.         }
  4864.         $meetings $em->getRepository(\ApplicationBundle\Entity\ScheduledMeeting::class)
  4865.             ->createQueryBuilder('m')
  4866.             ->where('m.startAt BETWEEN :start AND :end')
  4867.             ->setParameter('start'$start)
  4868.             ->setParameter('end'$end)
  4869.             ->getQuery()
  4870.             ->getResult();
  4871.         $meetingType MeetingSchedulingConstant::$meetingType;
  4872.         $data = [];
  4873.         foreach ($meetings as $meeting) {
  4874.             $data[] = [
  4875.                 'id' => $meeting->getScheduleId(),
  4876.                 'title' => $meeting->getTitle(),
  4877.                 'desc' => $meeting->getDesc(),
  4878.                 'startAt' => $meeting->getStartAt() ? $meeting->getStartAt()->format('Y-m-d H:i:s') : null,
  4879.                 'endAt' => $meeting->getEndAt() ? $meeting->getEndAt()->format('Y-m-d H:i:s') : null,
  4880.                 'roomId' => $meeting->getRoomId(),
  4881.                 'meetingType' => $meetingType[$meeting->getMeetingType()] ?? null,
  4882.                 'location' => $meeting->getLocation(),
  4883.                 'participant' => json_decode($meeting->getParticipantInfo()),
  4884.                 'status' => $meeting->getStatus(),
  4885.                 'approved' => (bool)$meeting->getApproved(),
  4886.             ];
  4887.         }
  4888.         return new JsonResponse([
  4889.             'success' => true,
  4890.             'range' => [
  4891.                 'start' => $start->format('Y-m-d H:i:s'),
  4892.                 'end' => $end->format('Y-m-d H:i:s')
  4893.             ],
  4894.             'meetings' => $data
  4895.         ]);
  4896.     }
  4897.     public function getMeetingByYearlyAction(Request $request): JsonResponse
  4898.     {
  4899.         $em $this->getDoctrine()->getManager();
  4900.         $yearParam $request->query->get('year');
  4901.         try {
  4902.             $data HumanResourceHelper::GetMeetingByYearlyAction($em$yearParam);
  4903.             return new JsonResponse($data200);
  4904.         } catch (\Exception $e) {
  4905.             return new JsonResponse([
  4906.                 'success' => false,
  4907.                 'error' => $e->getMessage()
  4908.             ], 400);
  4909.         }
  4910.     }
  4911.     public function getMeetingByIdAction(Request $requestint $id): JsonResponse
  4912.     {
  4913.         $em $this->getDoctrine()->getManager();
  4914.         $meeting $em->getRepository(\ApplicationBundle\Entity\ScheduledMeeting::class)->find($id);
  4915.         if (!$meeting) {
  4916.             return new JsonResponse([
  4917.                 'success' => false,
  4918.                 'error' => 'Meeting not found'
  4919.             ], 404);
  4920.         }
  4921.         return new JsonResponse([
  4922.             'success' => true,
  4923.             'meeting' => [
  4924.                 'id' => $meeting->getScheduleId(),
  4925.                 'docHash' => $meeting->getDocumentHash(),
  4926.                 'title' => $meeting->getTitle(),
  4927.                 'desc' => $meeting->getDesc(),
  4928.                 'specialType' => $meeting->getSpecialType(),
  4929.                 'startAt' => $meeting->getStartAt() ? $meeting->getStartAt()->format('Y-m-d H:i:s') : null,
  4930.                 'endAt' => $meeting->getEndAt() ? $meeting->getEndAt()->format('Y-m-d H:i:s') : null,
  4931.                 'meetingType' => $meeting->getMeetingType(),
  4932.                 'location' => $meeting->getLocation(),
  4933.                 'roomId' => $meeting->getRoomId(),
  4934.                 'facilitator' => [
  4935.                     'id' => $meeting->getFacilitatorId(),
  4936.                     'name' => $meeting->getFacilitatorName()
  4937.                 ],
  4938.                 'companyId' => $meeting->getCompanyId(),
  4939.                 'branchId' => $meeting->getBranchId(),
  4940.                 'agendaList' => $meeting->getAgendaList() ? json_decode($meeting->getAgendaList(), true) : [],
  4941.                 'internalParticipants' => $meeting->getInternalParticipantIds() ? json_decode($meeting->getInternalParticipantIds(), true) : [],
  4942.                 'otherParticipants' => $meeting->getOtherParticipantInfo() ? json_decode($meeting->getOtherParticipantInfo(), true) : [],
  4943.                 'createdAt' => $meeting->getCreatedAt()->format('Y-m-d H:i:s'),
  4944.             ]
  4945.         ]);
  4946.     }
  4947.     public function updateMeetingAction(Request $requestint $id): JsonResponse
  4948.     {
  4949.         $em $this->getDoctrine()->getManager();
  4950.         $meeting $em->getRepository(\ApplicationBundle\Entity\ScheduledMeeting::class)->find($id);
  4951.         if (!$meeting) {
  4952.             return new JsonResponse(['success' => false'error' => 'Meeting not found'], 404);
  4953.         }
  4954.         $data json_decode($request->getContent(), true);
  4955.         if (!$data) {
  4956.             $data $request->request->all();
  4957.         }
  4958.         if (!$data) {
  4959.             return new JsonResponse(['success' => false'error' => 'Invalid data'], 400);
  4960.         }
  4961.         if (isset($data['title'])) $meeting->setTitle($data['title']);
  4962.         if (isset($data['desc'])) $meeting->setDesc($data['desc']);
  4963.         if (isset($data['startAt'])) $meeting->setStartAt(new \DateTime($data['startAt']));
  4964.         if (isset($data['endAt'])) $meeting->setEndAt(new \DateTime($data['endAt']));
  4965.         if (isset($data['location'])) $meeting->setLocation($data['location']);
  4966.         if (isset($data['meetingType'])) $meeting->setMeetingType($data['meetingType']);
  4967.         if (isset($data['roomId'])) $meeting->setRoomId($data['roomId']);
  4968.         if (isset($data['agendaList'])) {
  4969.             $agendaList is_array($data['agendaList']) ? $data['agendaList'] : json_decode($data['agendaList'], true);
  4970.             $meeting->setAgendaList(json_encode($agendaList));
  4971.         }
  4972.         $meeting->setLastModifiedDate(new \DateTime());
  4973.         $em->flush();
  4974.         return new JsonResponse([
  4975.             'success' => true,
  4976.             'message' => 'Meeting updated successfully',
  4977.             'meetingId' => $meeting->getScheduleId()
  4978.         ]);
  4979.     }
  4980.     public function deleteMeetingAction(Request $requestint $id): JsonResponse
  4981.     {
  4982.         $em $this->getDoctrine()->getManager();
  4983.         $meeting $em->getRepository(\ApplicationBundle\Entity\ScheduledMeeting::class)->find($id);
  4984.         if (!$meeting) {
  4985.             return new JsonResponse(['success' => false'error' => 'Meeting not found'], 404);
  4986.         }
  4987.         $em->remove($meeting);
  4988.         $em->flush();
  4989.         return new JsonResponse([
  4990.             'success' => true,
  4991.             'message' => 'Meeting deleted successfully',
  4992.             'deletedId' => $id
  4993.         ]);
  4994.     }
  4995.     public function searchParticipantByEmailAction(Request $request): JsonResponse
  4996.     {
  4997.         $em $this->getDoctrine()->getManager();
  4998.         $email trim($request->query->get('email'));
  4999.         if (empty($email)) {
  5000.             return new JsonResponse([
  5001.                 'success' => false,
  5002.                 'error' => 'Email is required'
  5003.             ], 400);
  5004.         }
  5005.         try {
  5006.             $companyId $this->getLoggedUserCompanyId($request);
  5007.             $client $em->getRepository(\ApplicationBundle\Entity\AccClients::class)
  5008.                 ->findOneBy(['email' => $email]);
  5009.             if ($client) {
  5010.                 return new JsonResponse([
  5011.                     'success' => true,
  5012.                     'type' => 'client',
  5013.                     'data' => [
  5014.                         'client_id' => $client->getClientId(),
  5015.                         'company_id' => $client->getCompanyId(),
  5016.                         'client_name' => $client->getClientName(),
  5017.                         'email' => $client->getEmail(),
  5018.                     ]
  5019.                 ]);
  5020.             }
  5021.             $employee $em->getRepository(\ApplicationBundle\Entity\Employee::class)
  5022.                 ->findOneBy(['email' => $email]);
  5023.             if ($employee) {
  5024.                 return new JsonResponse([
  5025.                     'success' => true,
  5026.                     'type' => 'employee',
  5027.                     'data' => [
  5028.                         'name' => $employee->getName(),
  5029.                         'email' => $employee->getEmail(),
  5030.                         'user_id' => $employee->getUserId(),
  5031.                         'address_contact' => $employee->getAddressContact(),
  5032.                     ]
  5033.                 ]);
  5034.             }
  5035.             return new JsonResponse([
  5036.                 'success' => false,
  5037.                 'error' => 'No client or employee found for this email'
  5038.             ], 404);
  5039.         } catch (\Exception $e) {
  5040.             return new JsonResponse([
  5041.                 'success' => false,
  5042.                 'error' => $e->getMessage()
  5043.             ], 500);
  5044.         }
  5045.     }
  5046.     public function GetRoomInformationForMeetingAction(Request $request): JsonResponse
  5047.     {
  5048.         $em $this->getDoctrine()->getManager();
  5049.         $onlyAvailable $request->query->getBoolean('onlyAvailable'false);
  5050.         $rooms HumanResourceHelper::getRooms($em$onlyAvailable);
  5051.         return new JsonResponse([
  5052.             'status' => 'success',
  5053.             'data' => $rooms
  5054.         ]);
  5055.     }
  5056.     public function MeetingTypeAction(Request $request)
  5057.     {
  5058.         return new JsonResponse([
  5059.             'success' => true,
  5060.             'data' => MeetingSchedulingConstant::$meetingType
  5061.         ]);
  5062.     }
  5063.     public function GetPriorityListAction()
  5064.     {
  5065.         $priority HumanResourceHelper::priorityList();
  5066.         return new JsonResponse([
  5067.             'success' => true,
  5068.             'data' => $priority
  5069.         ]);
  5070.     }
  5071.     public function CreateTrainingScheduleAction(Request $req$action 0)
  5072.     {
  5073.         $em $this->getDoctrine()->getManager();
  5074.         $companyId $this->getLoggedUserCompanyId($req);
  5075.         $session $req->getSession();
  5076.         if ($req->request->has('XHRreq')) {
  5077.             return new JsonResponse([HumanResource::HandelXHRreqForMeetingScheduling($em$req)]);
  5078.         }
  5079.         if ($action === 'list') {
  5080.             $response HumanResource::TwigDataForScheduledMeetingList($em, [1]);
  5081.             return $this->render(
  5082.                 'ApplicationBundle:pages/human_resource/list:scheduled_meeting_list.html.twig',
  5083.                 [
  5084.                     'page_title' => 'Training Schedule List',
  5085.                     'list' => $response
  5086.                 ]
  5087.             );
  5088.         }
  5089.         if ($req->isMethod('GET')) {
  5090.         }
  5091.         if ($req->isMethod('POST')) {
  5092.             $approveHash $req->request->get('approvalHash');
  5093.             $approveRole $req->request->get('approvalRole');
  5094.             $loginId $req->getSession()->get(UserConstants::USER_LOGIN_ID);
  5095.             $isSignatureOk DocValidation::isSignatureOk($em$loginId$approveHash);
  5096.             $companyData Company::getCompanyData($em$companyId);
  5097.             if ($isSignatureOk) {
  5098.                 $isSuccess HumanResource::createOrUpdateDataForMeetingScheduling($em$req);
  5099.                 if ($isSuccess) {
  5100.                     $options = array(
  5101.                         'notification_enabled' => $this->container->getParameter('notification_enabled'),
  5102.                         'notification_server' => $this->container->getParameter('notification_server'),
  5103.                         'appId' => $req->getSession()->get(UserConstants::USER_APP_ID),
  5104.                         'url' => $this->generateUrl(
  5105.                             GeneralConstant::$Entity_list_details[array_flip(GeneralConstant::$Entity_list)['ScheduledMeeting']]['entity_view_route_path_name']
  5106.                         )
  5107.                     );
  5108.                     $meetingId $isSuccess[1];
  5109.                     System::setApprovalInfo(
  5110.                         $this->getDoctrine()->getManager(),
  5111.                         $options,
  5112.                         array_flip(GeneralConstant::$Entity_list)['ScheduledMeeting'],
  5113.                         $meetingId,
  5114.                         $req->getSession()->get(UserConstants::USER_LOGIN_ID),
  5115.                         '',
  5116.                         0,
  5117.                         $this->get('mail_module')
  5118.                     );
  5119.                     System::createEditSignatureHash(
  5120.                         $this->getDoctrine()->getManager(),
  5121.                         array_flip(GeneralConstant::$Entity_list)['ScheduledMeeting'],
  5122.                         $meetingId,
  5123.                         $loginId,
  5124.                         $approveRole,
  5125.                         $req->request->get('approvalHash')
  5126.                     );
  5127.                     $url $this->generateUrl(
  5128.                         'view_scheduled_meeting'
  5129.                     );
  5130.                     return $this->redirect($url "/" $meetingId);
  5131.                 } else {
  5132.                     return new JsonResponse(array(
  5133.                         'success' => false
  5134.                     ));
  5135.                 }
  5136.             } else {
  5137.                 $this->addFlash(
  5138.                     'error',
  5139.                     'Invalid Approval Hash!'
  5140.                 );
  5141.                 return $this->redirectToRoute('create_training_schedule');
  5142.             }
  5143.         }
  5144.         $response HumanResource::twigDataForTrainingScheduling($em);
  5145.         return $this->render(
  5146.             'ApplicationBundle:pages/human_resource/input_forms:create_training_schedule.html.twig',
  5147.             [
  5148.                 'page_title' => 'Schedule a Training',
  5149.                 'employeeIds' => $response['employeeIds'],
  5150.                 'branches' => $response['branches'],
  5151.                 'asset' => $response['asset'],
  5152.                 'rooms' => $response['rooms'],
  5153.                 'courseList' => $response['courseList'],
  5154.                 'sales_orders' => $response['salesOrders'],
  5155.                 'purchase_orders' => $response['purchaseOrders'],
  5156.                 'meeting_types' => $response['meetingType'],
  5157.                 'skillList' => $response['skillList'],
  5158.             ]
  5159.         );
  5160.     }
  5161.     public function ScheduledTrainingListAction(Request $req$action 0)
  5162.     {
  5163.         $em $this->getDoctrine()->getManager();
  5164.         $companyId $this->getLoggedUserCompanyId($req);
  5165.         $session $req->getSession();
  5166.         $response HumanResource::TwigDataForScheduledMeetingList($em, [1]);
  5167.         return $this->render(
  5168.             'ApplicationBundle:pages/human_resource/list:scheduled_training_list.html.twig',
  5169.             [
  5170.                 'page_title' => 'Scheduled Trainings ',
  5171.                 'list' => $response
  5172.             ]
  5173.         );
  5174.     }
  5175.     public function ScheduledInterviewListAction(Request $req$action 0)
  5176.     {
  5177.         $em $this->getDoctrine()->getManager();
  5178.         $companyId $this->getLoggedUserCompanyId($req);
  5179.         $session $req->getSession();
  5180.         $response HumanResource::TwigDataForScheduledMeetingList($em, [2]);
  5181.         return $this->render(
  5182.             'ApplicationBundle:pages/human_resource/list:scheduled_interview_list.html.twig',
  5183.             [
  5184.                 'page_title' => 'Scheduled Interviews ',
  5185.                 'list' => $response
  5186.             ]
  5187.         );
  5188.     }
  5189.     public function GetFilteredQuestionsAction(Request $request$search '')
  5190.     {
  5191.         $em $this->getDoctrine()->getManager();
  5192.         $companyId $this->getLoggedUserCompanyId($request);
  5193.         if ($search == '' || $search == '_EMPTY_')
  5194.             $Query "SELECT  * FROM questionnaire WHERE 1 limit 10;";
  5195.         else
  5196.             $Query "SELECT  * FROM questionnaire WHERE question_text like '%$search%'  limit 10;";
  5197.         $stmt $em->getConnection()->prepare($Query);
  5198.         $stmt->execute();
  5199.         $queryResult $stmt->fetchAll();
  5200.         $parent_head_ids = [];
  5201.         $queryResultIndexed = [];
  5202.         foreach ($queryResult as $dt) {
  5203.             $queryResultIndexed[$dt['question_id']] = $dt;
  5204.         }
  5205.         return new JsonResponse(array(
  5206.             'data' => $queryResult,
  5207.             'queryResultIndexed' => $queryResultIndexed,
  5208.         ));
  5209.     }
  5210.     public function CreateTrainingCourseAction(Request $request$id 0)
  5211.     {
  5212.         $em $this->getDoctrine()->getManager();
  5213.         $companyId $this->getLoggedUserCompanyId($request);
  5214.         $skills $em->getRepository('ApplicationBundle:Skill')->findAll();
  5215.         $courses $em->getRepository('ApplicationBundle:TrainingCourse')->findAll();
  5216.         if ($request->isMethod('POST')) {
  5217.             $loginId $request->getSession()->get(UserConstants::USER_LOGIN_ID);
  5218.             $skill = new TrainingCourse;
  5219.             $skill->setTitle($request->request->get('name'));
  5220.             $skill->setCourseHash($request->request->get('coursehash'));
  5221.             $skill->setTrainingMaterialText($request->request->get('overview'));
  5222.             $skill->setTaggedSkillHashes(json_encode($request->request->get('skill')));
  5223.             $skill->setCompanyId($companyId);
  5224.             //$skill->setEditFlag(1); //editable usually
  5225.             $skill->setCreatedLoginId($request->getSession()->get(UserConstants::USER_LOGIN_ID));
  5226.             //$skill->setApproved(GeneralConstant::APPROVAL_STATUS_PENDING);
  5227.             //$skill->setAutocreated(0);
  5228.             $em->persist($skill);
  5229.             $em->flush();
  5230.         }
  5231.         return $this->render(
  5232.             'ApplicationBundle:pages/human_resource/input_forms:create_training_course.html.twig',
  5233.             [
  5234.                 'page_title' => 'Create Training Course',
  5235.                 'skills' => $skills,
  5236.                 'courses' => $courses
  5237.             ]
  5238.         );
  5239.     }
  5240.     public function CreateEmployeeExpenseAllowanceSettingsAction(Request $request$id 0)
  5241.     {
  5242.         $em $this->getDoctrine()->getManager();
  5243.         $companyId $this->getLoggedUserCompanyId($request);
  5244.         $extDocData = [];
  5245.         $extDetailsData = [];
  5246.         if ($request->isMethod('POST')) {
  5247.             //            Generic::debugMessage($_POST);
  5248.             $em $this->getDoctrine()->getManager();
  5249.             $entity_id array_flip(GeneralConstant::$Entity_list)['EmployeeExpenseAllowanceSettings']; //change
  5250.             $dochash $request->request->get('docHash'); //change
  5251.             $loginId $request->getSession()->get(UserConstants::USER_LOGIN_ID);
  5252.             $approveRole $request->request->get('approvalRole');
  5253.             $approveHash $request->request->get('approvalHash');
  5254.             if (!DocValidation::isInsertable(
  5255.                 $em,
  5256.                 $entity_id,
  5257.                 $dochash,
  5258.                 $loginId,
  5259.                 $approveRole,
  5260.                 $approveHash,
  5261.                 $id
  5262.             )
  5263.             ) {
  5264.                 $this->addFlash(
  5265.                     'error',
  5266.                     'Sorry Could not insert Data.'
  5267.                 );
  5268.             } else {
  5269.                 $funcname 'EmployeeExpenseAllowanceSettings';
  5270.                 DeleteDocument::$funcname($em$id0);
  5271.                 $docId HumanResource::CreateSalarySegregationPolicy($em$request$companyId0);
  5272.                 //now add Approval info
  5273.                 $loginId $request->getSession()->get(UserConstants::USER_LOGIN_ID);
  5274.                 $approveRole $request->request->get('approvalRole');
  5275.                 $options = array(
  5276.                     'notification_enabled' => $this->container->getParameter('notification_enabled'),
  5277.                     'notification_server' => $this->container->getParameter('notification_server'),
  5278.                     'appId' => $request->getSession()->get(UserConstants::USER_APP_ID),
  5279.                     'url' => $this->generateUrl(
  5280.                         GeneralConstant::$Entity_list_details[array_flip(GeneralConstant::$Entity_list)['EmployeeExpenseAllowanceSettings']]['entity_view_route_path_name']
  5281.                     )
  5282.                 );
  5283.                 System::setApprovalInfo(
  5284.                     $this->getDoctrine()->getManager(),
  5285.                     $options,
  5286.                     array_flip(GeneralConstant::$Entity_list)['EmployeeExpenseAllowanceSettings'],
  5287.                     $docId,
  5288.                     $request->getSession()->get(UserConstants::USER_LOGIN_ID)
  5289.                 );
  5290.                 System::createEditSignatureHash(
  5291.                     $this->getDoctrine()->getManager(),
  5292.                     array_flip(GeneralConstant::$Entity_list)['EmployeeExpenseAllowanceSettings'],
  5293.                     $docId,
  5294.                     $loginId,
  5295.                     $approveRole,
  5296.                     $request->request->get('approvalHash')
  5297.                 );
  5298.                 $doc_here $this->getDoctrine()
  5299.                     ->getRepository('ApplicationBundle:EmployeeExpenseAllowanceSettings')
  5300.                     ->findOneBy(
  5301.                         array(
  5302.                             'id' => $docId
  5303.                         )
  5304.                     );
  5305.                 //notify
  5306.                 $this->addFlash(
  5307.                     'success',
  5308.                     'Settings Successfully Updated.'
  5309.                 );
  5310.                 $url $this->generateUrl(
  5311.                     GeneralConstant::$Entity_list_details[array_flip(GeneralConstant::$Entity_list)['EmployeeExpenseAllowanceSettings']]['entity_view_route_path_name']
  5312.                 );
  5313.                 System::AddNewNotification(
  5314.                     $this->container->getParameter('notification_enabled'),
  5315.                     $this->container->getParameter('notification_server'),
  5316.                     $request->getSession()->get(UserConstants::USER_APP_ID),
  5317.                     $request->getSession()->get(UserConstants::USER_COMPANY_ID),
  5318.                     "Salary Segregation Policy : " $doc_here->getDocumentHash() . " Has Been Created And is Under Processing",
  5319.                     'pos',
  5320.                     System::getPositionIdsByDepartment($emGeneralConstant::HRM_DEPARTMENT),
  5321.                     'success',
  5322.                     //                    $url . "/" . $TransID,
  5323.                     $url "/" $docId,
  5324.                     "Journal"
  5325.                 );
  5326.                 return $this->redirect($url "/" $docId);
  5327.             }
  5328.         }
  5329.         //for edits
  5330.         if ($id == 0) {
  5331.         } else {
  5332.             $extDocData $em->getRepository('ApplicationBundle:EmployeeExpenseAllowanceSettings')->findOneBy(
  5333.                 array(
  5334.                     'id' => $id///material
  5335.                 )
  5336.             );
  5337.             //now if its not editable, redirect to view
  5338.             if ($extDocData) {
  5339.                 if ($extDocData->getEditFlag() != 1) {
  5340. //          $url = $this->generateUrl(
  5341. ////              'view_salary_segregation_policy'
  5342. //              'salary_segregation_policy'
  5343. //          );
  5344. //          return $this->redirect($url . "/" . $id);
  5345.                 } else {
  5346. //          $extVoucherDetailsData = Accounts::GetVoucherDataForEdit($em, $voucherId);
  5347. //          $extDetailsData = $em->getRepository('ApplicationBundle:SalarySegregationPolicy')->findOneBy(
  5348. //              array(
  5349. //                  'transactionId' => $id, ///material
  5350. //
  5351. //              )
  5352. //          );
  5353.                 }
  5354.             } else {
  5355.             }
  5356.         }
  5357.         $employeeIds $em->getRepository("ApplicationBundle:Employee")->findAll();
  5358.         $employeeType HumanResourceConstant::$employeeType;
  5359.         $employeeExpenseAllowanceTypes HumanResourceConstant::$employeeExpenseAllowanceTypes;
  5360.         $Designation $em->getRepository("ApplicationBundle:SysDepartmentPosition")->findAll();
  5361.         $branch $em->getRepository("ApplicationBundle:Branch")->findAll();
  5362.         $departments $em->getRepository("ApplicationBundle:SysDepartment")->findAll();
  5363.         $department = [];
  5364.         foreach ($departments as $entry) {
  5365.             $department[$entry->getDepartmentId()] = array(
  5366.                 'id' => $entry->getDepartmentId(),
  5367.                 'name' => $entry->getDepartmentName(),
  5368.             );
  5369.         }
  5370.         return $this->render(
  5371.             'ApplicationBundle:pages/human_resource/input_forms:create_employee_expense_allowance_settings.html.twig',
  5372.             [
  5373.                 'page_title' => 'Employee Expense Allowance Settings',
  5374.                 'employeeIds' => $employeeIds,
  5375.                 'extId' => $id,
  5376.                 'extDocData' => $extDocData,
  5377.                 'employeeType' => $employeeType,
  5378.                 'employeeExpenseAllowanceTypes' => $employeeExpenseAllowanceTypes,
  5379.                 'Designation' => $Designation,
  5380.                 'branch' => $branch,
  5381.                 'department' => $department,
  5382.             ]
  5383.         );
  5384.     }
  5385.     public function EmployeeExpenseAllowanceSettingsListAction(Request $request)
  5386.     {
  5387.         $em $this->getDoctrine()->getManager();
  5388.         $allowed_ids = [];
  5389.         $companyId $this->getLoggedUserCompanyId($request);
  5390.         $listData HumanResource::GetDataForEmployeeExpenseAllowanceSettingsListAction($em$request->isMethod('POST') ? 'POST' 'GET'$request->request$companyId);
  5391.         if ($request->isMethod('POST')) {
  5392.             if ($request->query->has('dataTableQry')) {
  5393.                 return new JsonResponse(
  5394.                     $listData
  5395.                 );
  5396.             }
  5397.         }
  5398.         return $this->render('ApplicationBundle:pages/human_resource/list:employee_expense_allowance_settings_list.html.twig',
  5399. //         return $this->render('ApplicationBundle:pages/dashboard:test_pix_invent.html.twig',
  5400.             array(
  5401.                 'page_title' => 'Expense Allowance Settings List',
  5402. //            'data' => SalesOrderM::GetClientList($em, [], $companyId),
  5403. //            'client_types' => Client::GetClientType($em, $companyId),
  5404. //            'region_list' => Client::RegionList($em, $companyId),
  5405. //            'geographical_region_list' => Client::GeographicalRegionList($em, $companyId)
  5406.             )
  5407.         );
  5408.     }
  5409.     public function salarySegAction(Request $request$id 0)
  5410.     {
  5411.         $em $this->getDoctrine()->getManager();
  5412.         $companyId $this->getLoggedUserCompanyId($request);
  5413.         $extDocData = [];
  5414.         $extDetailsData = [];
  5415.         if ($request->isMethod('POST')) {
  5416.             //            Generic::debugMessage($_POST);
  5417.             $em $this->getDoctrine()->getManager();
  5418.             $entity_id array_flip(GeneralConstant::$Entity_list)['SalarySegregationPolicy']; //change
  5419.             $dochash $request->request->get('docHash'); //change
  5420.             $loginId $request->getSession()->get(UserConstants::USER_LOGIN_ID);
  5421.             $approveRole $request->request->get('approvalRole');
  5422.             $approveHash $request->request->get('approvalHash');
  5423.             if (!DocValidation::isInsertable(
  5424.                 $em,
  5425.                 $entity_id,
  5426.                 $dochash,
  5427.                 $loginId,
  5428.                 $approveRole,
  5429.                 $approveHash,
  5430.                 $id
  5431.             )
  5432.             ) {
  5433.                 $this->addFlash(
  5434.                     'error',
  5435.                     'Sorry Couldnot insert Data.'
  5436.                 );
  5437.             } else {
  5438.                 $funcname 'SalarySegregationPolicy';
  5439.                 DeleteDocument::$funcname($em$id0);
  5440.                 $docId HumanResource::CreateSalarySegregationPolicy($em$request$companyId0);
  5441.                 //now add Approval info
  5442.                 $loginId $request->getSession()->get(UserConstants::USER_LOGIN_ID);
  5443.                 $approveRole $request->request->get('approvalRole');
  5444.                 $options = array(
  5445.                     'notification_enabled' => $this->container->getParameter('notification_enabled'),
  5446.                     'notification_server' => $this->container->getParameter('notification_server'),
  5447.                     'appId' => $request->getSession()->get(UserConstants::USER_APP_ID),
  5448.                     'url' => $this->generateUrl(
  5449.                         GeneralConstant::$Entity_list_details[array_flip(GeneralConstant::$Entity_list)['SalarySegregationPolicy']]['entity_view_route_path_name']
  5450.                     )
  5451.                 );
  5452.                 System::setApprovalInfo(
  5453.                     $this->getDoctrine()->getManager(),
  5454.                     $options,
  5455.                     array_flip(GeneralConstant::$Entity_list)['SalarySegregationPolicy'],
  5456.                     $docId,
  5457.                     $request->getSession()->get(UserConstants::USER_LOGIN_ID),
  5458.                     3    //journal voucher
  5459.                 );
  5460.                 System::createEditSignatureHash(
  5461.                     $this->getDoctrine()->getManager(),
  5462.                     array_flip(GeneralConstant::$Entity_list)['SalarySegregationPolicy'],
  5463.                     $docId,
  5464.                     $loginId,
  5465.                     $approveRole,
  5466.                     $request->request->get('approvalHash')
  5467.                 );
  5468.                 $doc_here $this->getDoctrine()
  5469.                     ->getRepository('ApplicationBundle:SalarySegregationPolicy')
  5470.                     ->findOneBy(
  5471.                         array(
  5472.                             'id' => $docId
  5473.                         )
  5474.                     );
  5475.                 //notify
  5476.                 $this->addFlash(
  5477.                     'success',
  5478.                     'Policy Successfully Updated.'
  5479.                 );
  5480.                 $url $this->generateUrl(
  5481.                     'salary_segregation_policy'
  5482.                 );
  5483.                 System::AddNewNotification(
  5484.                     $this->container->getParameter('notification_enabled'),
  5485.                     $this->container->getParameter('notification_server'),
  5486.                     $request->getSession()->get(UserConstants::USER_APP_ID),
  5487.                     $request->getSession()->get(UserConstants::USER_COMPANY_ID),
  5488.                     "Salary Segregation Policy : " $doc_here->getDocumentHash() . " Has Been Created And is Under Processing",
  5489.                     'pos',
  5490.                     System::getPositionIdsByDepartment($emGeneralConstant::HRM_DEPARTMENT),
  5491.                     'success',
  5492.                     //                    $url . "/" . $TransID,
  5493.                     $url "/" $docId,
  5494.                     "Journal"
  5495.                 );
  5496.                 return $this->redirect($url "/" $docId);
  5497.             }
  5498.         }
  5499.         //for edits
  5500.         if ($id == 0) {
  5501.         } else {
  5502.             $extDocData $em->getRepository('ApplicationBundle:SalarySegregationPolicy')->findOneBy(
  5503.                 array(
  5504.                     'id' => $id///material
  5505.                 )
  5506.             );
  5507.             //now if its not editable, redirect to view
  5508.             if ($extDocData) {
  5509.                 if ($extDocData->getEditFlag() != 1) {
  5510. //          $url = $this->generateUrl(
  5511. ////              'view_salary_segregation_policy'
  5512. //              'salary_segregation_policy'
  5513. //          );
  5514. //          return $this->redirect($url . "/" . $id);
  5515.                 } else {
  5516. //          $extVoucherDetailsData = Accounts::GetVoucherDataForEdit($em, $voucherId);
  5517. //          $extDetailsData = $em->getRepository('ApplicationBundle:SalarySegregationPolicy')->findOneBy(
  5518. //              array(
  5519. //                  'transactionId' => $id, ///material
  5520. //
  5521. //              )
  5522. //          );
  5523.                 }
  5524.             } else {
  5525.             }
  5526.         }
  5527.         $employeeIds $em->getRepository(EmployeeDetails::class)->findAll();
  5528.         $employeeType HumanResourceConstant::$employeeType;
  5529.         $Designation $em->getRepository(SysDepartmentPosition::class)->findAll();
  5530.         $branch $em->getRepository(Branch::class)->findAll();
  5531.         $departments $em->getRepository(SysDepartment::class)->findAll();
  5532.         $department = [];
  5533.         foreach ($departments as $entry) {
  5534.             $department[$entry->getDepartmentId()] = array(
  5535.                 'id' => $entry->getDepartmentId(),
  5536.                 'name' => $entry->getDepartmentName(),
  5537.             );
  5538.         }
  5539.         return $this->render(
  5540.             'ApplicationBundle:pages/human_resource/input_forms:salary_segregation_policy.html.twig',
  5541.             [
  5542.                 'page_title' => 'Salary Segregation Policy',
  5543.                 'employeeIds' => $employeeIds,
  5544.                 'extId' => $id,
  5545.                 'extDocData' => $extDocData,
  5546.                 'employeeType' => $employeeType,
  5547.                 'Designation' => $Designation,
  5548.                 'branch' => $branch,
  5549.                 'department' => $department,
  5550.             ]
  5551.         );
  5552.     }
  5553.     public function GetSalarySegregationDataForEmployeeEntryAction(Request $request)
  5554.     {
  5555.         $em $this->getDoctrine()->getManager();
  5556.         $companyId $this->getLoggedUserCompanyId($request);
  5557.         if ($request->request->has('salSagDataReq')) {
  5558.             $ajaxData HumanResource::handelXhrForSalSeg($em$request);
  5559.             return new JsonResponse($ajaxData);
  5560.         }
  5561.         return new JsonResponse(array('success' => false));
  5562.     }
  5563.     public function WorkHourPolicyAction(Request $req$id 0)
  5564.     {
  5565.         $em $this->getDoctrine()->getManager();
  5566.         $companyId $this->getLoggedUserCompanyId($req);
  5567.         $extData = [];
  5568.         if ($id != 0) {
  5569.             $extData $em->getRepository('ApplicationBundle:WorkHourPolicy')
  5570.                 ->findOneBy(
  5571.                     array(
  5572.                         'id' => $id
  5573.                     )
  5574.                 );
  5575.         }
  5576.         if ($req->isMethod('POST')) {
  5577.             $storeDataRes HumanResource::checkSignature($em$req);
  5578.             if ($storeDataRes['hasErr']) {
  5579.                 $msg $storeDataRes['msg'];
  5580.                 $this->addFlash(
  5581.                     'error',
  5582.                     $msg
  5583.                 );
  5584.                 return $this->redirectToRoute('work_hour_policy');
  5585.             } else {
  5586.                 HumanResource::storeDataForWhPolicy($em$req$companyId);
  5587.                 $this->addFlash(
  5588.                     'success',
  5589.                     'Policy Successfully Created!'
  5590.                 );
  5591.                 return $this->redirectToRoute('work_hour_policy');
  5592.             }
  5593.         }
  5594.         $twigData HumanResource::twigDataForWorkHourPolicy($em);
  5595.         $timeZonesArray = array();
  5596.         return $this->render(
  5597.             'ApplicationBundle:pages/human_resource/input_forms:work_hour_policy.html.twig',
  5598.             [
  5599.                 'page_title' => 'Work Hour Policy',
  5600.                 'extId' => $id,
  5601.                 'extData' => $extData,
  5602.                 'employeeIds' => $twigData['employeeIds'],
  5603.                 'employeeType' => $twigData['employeeType'],
  5604.                 'Designation' => $twigData['Designation'],
  5605.                 'branch' => $twigData['branch'],
  5606.                 'department' => $twigData['department'],
  5607.             ]
  5608.         );
  5609.     }
  5610.     public function WorkHourPolicyListAction(Request $request)
  5611.     {
  5612.         $em $this->getDoctrine()->getManager();
  5613.         $allowed_ids = [];
  5614.         $companyId $this->getLoggedUserCompanyId($request);
  5615.         $listData HumanResource::GetDataForWorkHourPolicyListAction($em$request->isMethod('POST') ? 'POST' 'GET'$request->request$companyId);
  5616.         if ($request->isMethod('POST')) {
  5617.             if ($request->query->has('dataTableQry')) {
  5618.                 return new JsonResponse(
  5619.                     $listData
  5620.                 );
  5621.             }
  5622.         }
  5623.         return $this->render('ApplicationBundle:pages/human_resource/list:work_hour_policy_list.html.twig',
  5624. //         return $this->render('ApplicationBundle:pages/dashboard:test_pix_invent.html.twig',
  5625.             array(
  5626.                 'page_title' => 'Work Hour Policy List',
  5627. //            'data' => SalesOrderM::GetClientList($em, [], $companyId),
  5628. //            'client_types' => Client::GetClientType($em, $companyId),
  5629. //            'region_list' => Client::RegionList($em, $companyId),
  5630. //            'geographical_region_list' => Client::GeographicalRegionList($em, $companyId)
  5631.             )
  5632.         );
  5633.     }
  5634.     public function WorkPlacePolicyListAction(Request $request)
  5635.     {
  5636.         $em $this->getDoctrine()->getManager();
  5637.         $workplacePolicyDetails $em->getRepository('ApplicationBundle:EmployeeWorkplace')->findAll();
  5638. //        $employee = $em->getRepository('ApplicationBundle:Employee')->findAll();
  5639.         return $this->render('ApplicationBundle:pages/human_resource/list:work_place_policy_list.html.twig', array(
  5640.             'page_title' => 'Work Place Policy List',
  5641.             'workplacePolicyDetails' => $workplacePolicyDetails,
  5642. //            'employee'=>$employee
  5643.         ));
  5644.     }
  5645.     public function workPlacePolicyAction(Request $data$id)
  5646.     {
  5647.         $em $this->getDoctrine()->getManager();
  5648.         $workPlacePolicy $em->getRepository('ApplicationBundle:EmployeeWorkplace')->find($id);
  5649.         $employee $em->getRepository(Employee::class)->findAll();
  5650.         $Approval_data System::checkIfApprovalExists(
  5651.             $em,
  5652.             array_flip(GeneralConstant::$Entity_list)['EmployeeWorkplace'],
  5653.             $id,
  5654.             $data->getSession()->get(UserConstants::USER_LOGIN_ID)
  5655.         );
  5656.         $ApprovalStatus GeneralConstant::$approvalStatus;
  5657.         return $this->render('ApplicationBundle:pages/human_resource/views:viewWorkPlacePolicy.html.twig', array(
  5658.             'page_title' => 'Work Place Policy  View',
  5659.             'workPlacePolicy' => $workPlacePolicy,
  5660.             'employee' => $employee,
  5661.             'approval_data' => $Approval_data,
  5662.             'approval_status' => $workPlacePolicy->getApproved(),
  5663.             'id' => $id,
  5664.         ));
  5665.     }
  5666.     public function SalarySegregationPolicyListAction(Request $request)
  5667.     {
  5668.         $em $this->getDoctrine()->getManager();
  5669.         $allowed_ids = [];
  5670.         $companyId $this->getLoggedUserCompanyId($request);
  5671.         $listData HumanResource::GetDataForSalarySegregationPolicyListAction($em$request->isMethod('POST') ? 'POST' 'GET'$request->request$companyId);
  5672.         if ($request->isMethod('POST')) {
  5673.             if ($request->query->has('dataTableQry')) {
  5674.                 return new JsonResponse(
  5675.                     $listData
  5676.                 );
  5677.             }
  5678.         }
  5679.         return $this->render('ApplicationBundle:pages/human_resource/list:salary_segregation_policy_list.html.twig',
  5680. //         return $this->render('ApplicationBundle:pages/dashboard:test_pix_invent.html.twig',
  5681.             array(
  5682.                 'page_title' => 'Salary Segregation Policy List',
  5683. //            'data' => SalesOrderM::GetClientList($em, [], $companyId),
  5684. //            'client_types' => Client::GetClientType($em, $companyId),
  5685. //            'region_list' => Client::RegionList($em, $companyId),
  5686. //            'geographical_region_list' => Client::GeographicalRegionList($em, $companyId)
  5687.             )
  5688.         );
  5689.     }
  5690.     public function HolidayCalendarListAction(Request $request)
  5691.     {
  5692.         $q $this->getDoctrine()
  5693.             ->getRepository('ApplicationBundle:HolidayCalendar')
  5694.             ->findBy(
  5695.                 array(
  5696. //                'status' => GeneralConstant::ACTIVE,
  5697.                     'CompanyId' => $this->getLoggedUserCompanyId($request)
  5698. //                    'approved' =>  GeneralConstant::APPROVED,
  5699.                 )
  5700.             );
  5701.         $stage_list = array(
  5702.             => 'Pending',
  5703.             => 'Pending',
  5704.             => 'Complete',
  5705.             => 'Partial',
  5706.         );
  5707.         $data = [];
  5708.         foreach ($q as $entry) {
  5709.             $data[] = array(
  5710. //          'doc_date' => $entry->getSalesReplacementDate(),
  5711.                 'id' => $entry->getHolidayCalendarId(),
  5712.                 'title' => $entry->getHoliDayTitle(),
  5713.                 'approval_status' => GeneralConstant::$approvalStatus[$entry->getApproved()],
  5714. //          'stage' => $stage_list[$entry->getStage()]
  5715.             );
  5716.         }
  5717.         return $this->render('ApplicationBundle:pages/human_resource/list:holiday_calendar_list.html.twig',
  5718.             array(
  5719.                 'page_title' => 'Holiday Calendar List',
  5720.                 'data' => $data
  5721.             )
  5722.         );
  5723.     }
  5724.     public function PayrollPolicyListAction(Request $request)
  5725.     {
  5726.         $em $this->getDoctrine()->getManager();
  5727.         $allowed_ids = [];
  5728.         $companyId $this->getLoggedUserCompanyId($request);
  5729.         $listData HumanResource::GetDataForPayrollPolicyListAction($em$request->isMethod('POST') ? 'POST' 'GET'$request->request$companyId);
  5730.         if ($request->isMethod('POST')) {
  5731.             if ($request->query->has('dataTableQry')) {
  5732.                 return new JsonResponse(
  5733.                     $listData
  5734.                 );
  5735.             }
  5736.         }
  5737.         return $this->render('ApplicationBundle:pages/human_resource/list:payroll_policy_list.html.twig',
  5738. //         return $this->render('ApplicationBundle:pages/dashboard:test_pix_invent.html.twig',
  5739.             array(
  5740.                 'page_title' => 'Payroll Policy List',
  5741. //            'data' => SalesOrderM::GetClientList($em, [], $companyId),
  5742. //            'client_types' => Client::GetClientType($em, $companyId),
  5743. //            'region_list' => Client::RegionList($em, $companyId),
  5744. //            'geographical_region_list' => Client::GeographicalRegionList($em, $companyId)
  5745.             )
  5746.         );
  5747.     }
  5748.     public function payslipAction(Request $req$action 0$id 0)
  5749.     {
  5750.         $em $this->getDoctrine()->getManager();
  5751.         $attendanceSource HumanResourceConstant::$attendanceSources;
  5752.         if ($action === 'list') {
  5753.             $response HumanResource::twigDataForPayslipList($em);
  5754.             $approval_status GeneralConstant::$approvalAction;
  5755.             return $this->render(
  5756.                 'ApplicationBundle:pages/human_resource/list:payslip_list.html.twig',
  5757.                 [
  5758.                     'page_title' => 'Payslip List',
  5759.                     'reports' => $response,
  5760.                     'approval_status' => $approval_status
  5761.                 ]
  5762.             );
  5763.         }
  5764.         if ($action === 'view') {
  5765.             $response HumanResource::twigDataForPayslipViewAndPrint($em$req$id);
  5766.             return $this->render(
  5767.                 'ApplicationBundle:pages/human_resource/views:payslip_view.html.twig',
  5768.                 [
  5769.                     'page_title' => 'View Payslip',
  5770.                     'approval_data' => $response['approval_data'],
  5771.                     'payslip' => $response['payslip'],
  5772.                     'bankAccount' => $response['bankAccount'],
  5773.                     'tin' => $response['tin'],
  5774.                     'employeeCode' => $response['employeeCode'],
  5775.                     'earningValues' => $response['earningValues'],
  5776.                     'facilityValues' => $response['facilityValues'],
  5777.                     'deductionValues' => $response['deductionValues'],
  5778.                     'document_log' => $response['document_log'],
  5779.                     'approval_status' => $response['approval_status'],
  5780.                     'created_by' => $response['created_by'],
  5781.                     'updated_at' => $response['updated_at'],
  5782.                     'employeeId' => $response['employeeId'],
  5783.                     'totalAttendance' => $response['totalPresent'],
  5784.                     'leaveList' => HumanResourceConstant::$LeaveType,
  5785.                     'AttReportData' => $response['AttReportData'],
  5786. //                    'attendanceLog' => $response['attendanceLog'],
  5787.                     'attendanceSource' => $attendanceSource,
  5788.                     'auto_created' => 0,
  5789.                 ]
  5790.             );
  5791.         }
  5792.         if ($action === 'print') {
  5793.             $em $this->getDoctrine()->getManager();
  5794.             $company_data Company::getCompanyData($em1);
  5795.             $Authorizations System::getSignatureListForDocumentPrint($emarray_flip(GeneralConstant::$Entity_list)['Payslip'], $id);
  5796.             $response HumanResource::twigDataForPayslipViewAndPrint($em$req$id);
  5797.             return $this->render(
  5798.                 'ApplicationBundle:pages/human_resource/print:payslip_print.html.twig',
  5799.                 array(
  5800.                     'page_title' => 'Print Payslip',
  5801.                     'export' => 'pdf,print',
  5802.                     'payslip' => $response['payslip'],
  5803.                     'bankAccount' => $response['bankAccount'],
  5804.                     'tin' => $response['tin'],
  5805.                     'employeeCode' => $response['employeeCode'],
  5806.                     'earningValues' => $response['earningValues'],
  5807.                     'facilityValues' => $response['facilityValues'],
  5808.                     'deductionValues' => $response['deductionValues'],
  5809.                     'company_name' => $company_data->getName(),
  5810.                     'company_data' => $company_data,
  5811.                     'company_address' => $company_data->getAddress(),
  5812.                     'company_image' => $company_data->getImage(),
  5813.                     'Authorizations' => $Authorizations,
  5814.                     'totalAttendance' => $response['totalPresent'],
  5815.                     'leaveList' => HumanResourceConstant::$LeaveType,
  5816.                     'AttReportData' => $response['AttReportData'],
  5817.                     'attendanceSource' => $attendanceSource,
  5818.                     'red' => 0
  5819.                 )
  5820.             );
  5821.         }
  5822.         if ($req->isMethod('POST')) {
  5823.             $sigRes HumanResource::checkSignature($em$req);
  5824.             if ($sigRes['hasErr']) {
  5825.                 $msg $sigRes['msg'];
  5826.                 return new JsonResponse(['success' => false'msg' => $msg]);
  5827.             }
  5828.             HumanResource::storeDataForPayslip($em$req);
  5829.             return new JsonResponse(['success' => true]);
  5830.         }
  5831.     }
  5832.     public function applicantInfoAction(Request $request$id)
  5833.     {
  5834.         $em $this->getDoctrine()->getManager('company_group');
  5835.         $session $request->getSession();
  5836.         $consultantDetails $em->getRepository(EntityApplicantDetails::class)->find($session->get(UserConstants::USER_ID));
  5837.         $skillDetails $em->getRepository(EntitySkill::class)->findAll();
  5838.         $companyId $this->getLoggedUserCompanyId($request);
  5839.         $gender HumanResourceConstant::$sex;
  5840.         $blood HumanResourceConstant::$BloodGroup;
  5841.         $userId $session->get(UserConstants::USER_ID);
  5842.         $encData $request->query->has('ref') ? $request->query->get('ref') : '';
  5843.         $education = array(
  5844.             'instituteName' => $request->get('instituteName'),
  5845.             'courseOfStudy' => $request->get('courseOfStudy'),
  5846.             'courseStartDate' => $request->get('courseStartDate'),
  5847.             'courseEndDate' => $request->get('courseEndDate'),
  5848.             'result' => $request->get('result'),
  5849.             'grade' => $request->get('grade'),
  5850.             'degree' => $request->get('degree'),
  5851.         );
  5852.         $workExperience = array(
  5853.             'title' => $request->get('title'),
  5854.             'companyName' => $request->get('companyName'),
  5855.             'jobStartDate' => $request->get('jobStartDate'),
  5856.             'jobEndDate' => $request->get('jobEndDate'),
  5857.             'description' => $request->get('description'),
  5858.         );
  5859.         $certificate = array(
  5860.             'certificatename' => $request->get('certificatename'),
  5861.             'issuedDate' => $request->get('issuedDate'),
  5862.         );
  5863.         $courses = array(
  5864.             'courseName' => $request->get('courseName'),
  5865.             'date' => $request->get('date'),
  5866.             'duration' => $request->get('duration')
  5867.         );
  5868.         $languages = array(
  5869.             'languageName' => $request->get('languageName'),
  5870.             'writtenSkill' => $request->get('writtenSkill'),
  5871.             'verbalSkill' => $request->get('verbalSkill'),
  5872.         );
  5873.         if ($request->isMethod('POST')) {
  5874.             if ($consultantDetails)
  5875.                 $consultant $consultantDetails;
  5876.             else
  5877.                 $consultant = new EntityApplicantDetails();
  5878.             $consultant->setApplicationText($request->request->get('applicationText'));
  5879.             $consultant->setFirstname($request->request->get('firstname'));
  5880.             $consultant->setLastname($request->request->get('lastname'));
  5881.             $consultant->setIsImgLegal($request->request->get('is_img_legal'));
  5882.             $consultant->setNid($request->request->get('nid'));
  5883.             $consultant->setDob(new \DateTime($request->get('dob')));
  5884.             $consultant->setSex($request->request->get('sex'));
  5885.             $consultant->setFather($request->request->get('father'));
  5886.             $consultant->setMother($request->request->get('mother'));
  5887.             $consultant->setBlood($request->request->get('blood'));
  5888.             $consultant->setPhone($request->request->get('phone'));
  5889.             $consultant->setCountry($request->request->get('country'));
  5890.             $consultant->setPostalCode($request->request->get('postalCode'));
  5891.             $consultant->setCurrAddr($request->request->get('curr_addr'));
  5892.             $consultant->setSkill(json_encode($request->request->get('skill')));
  5893.             $consultant->setEmergencyContactNumber($request->request->get('emm_contact'));
  5894.             $consultant->setCurrentEmployment($request->request->get('currentEmployment'));
  5895.             $consultant->setTin($request->request->get('tin'));
  5896.             $consultant->setEducationData(json_encode($education));
  5897.             $consultant->setWorkExperienceData(json_encode($workExperience));
  5898.             $consultant->setCertificateData(json_encode($certificate));
  5899.             $consultant->setCoursesData(json_encode($courses));
  5900.             $consultant->setLanguagesData(json_encode($languages));
  5901.             $consultant->setWorkExperienceYear($request->request->get('workExperienceYear'));
  5902.             //$consultant->setApplyForConsultant(1);
  5903.             $em->persist($consultant);
  5904.             $em->flush();
  5905.             $path "";
  5906.             $defaultProductImage '';
  5907.             $uploadedFile null;
  5908.             $upl_dir $this->container->getParameter('kernel.root_dir') . '/../web/uploads/applicantCv/';
  5909.             $uploadedFile $request->files->get('docUpload');
  5910.             if ($uploadedFile != null) {
  5911.                 $fileName 'cv' $consultantDetails->getApplicantId() . '.' $uploadedFile->guessExtension();
  5912.                 $path $fileName;
  5913. //            $upl_dir = $this->container->getParameter('kernel.root_dir') . '/../web/uploads/Products/';
  5914.                 if (!file_exists($upl_dir)) {
  5915.                     mkdir($upl_dir0777true);
  5916.                 }
  5917.                 $uploadedFile->move($upl_dir$path);
  5918.                 $defaultProductImage 'uploads/applicantCv/' $path;
  5919.                 $consultant->setDocImage($defaultProductImage);
  5920.                 $em->flush();
  5921.             }
  5922.             $this->addFlash(
  5923.                 'success',
  5924.                 'Data Updated.'
  5925.             );
  5926.             if ($encData != '') {
  5927.                 $url $this->generateUrl(
  5928.                     'applicant_job_recruitment_view'
  5929.                 );
  5930.                 return $this->redirect($url '?auto_apply=1&encData=' $encData);
  5931.             }
  5932.             $url $this->generateUrl(
  5933.                 'job_recruitment_list_applicant'
  5934.             );
  5935.             return $this->redirect($url);
  5936.         }
  5937.         return $this->render('ApplicationBundle:pages/human_resource/input_forms:applicant_info.html.twig', array(
  5938.             'page_title' => 'My Information ',
  5939.             'gender' => $gender,
  5940.             'blood' => $blood,
  5941.             'consultantDetails' => $consultantDetails,
  5942.             'education' => json_decode($consultantDetails->getEducationData(), true),
  5943.             'workExperience' => json_decode($consultantDetails->getWorkExperienceData(), true),
  5944.             'certificate' => json_decode($consultantDetails->getCertificateData(), true),
  5945.             'courses' => json_decode($consultantDetails->getCoursesData(), true),
  5946.             'languages' => json_decode($consultantDetails->getLanguagesData(), true),
  5947.             'skill' => json_decode($consultantDetails->getSkill(), true),
  5948.             'skillDetails' => $skillDetails
  5949.         ));
  5950. //        $em = $this->getDoctrine()->getManager('company_group');
  5951. //        $applicantRepo = $em->getRepository(EntityApplicantDetails::class);
  5952. //        $skillDetails = $em->getRepository(EntitySkill::class)->findAll();
  5953. //
  5954. //
  5955. //        if ($req->isMethod('POST')) {
  5956. //            $applicant = $applicantRepo->find($id);
  5957. //
  5958. //            if ($req->files->get('img')) {
  5959. //                $ImgName = HumanResource::StoreFiles($req->files->get('img'), 'Applicant');
  5960. //                $applicant->setImage($ImgName);
  5961. //            }
  5962. //
  5963. //            $applicant->setFirstname($req->request->get('firstname'));
  5964. //            $applicant->setLastname($req->request->get('lastname'));
  5965. //            $applicant->setIsImgLegal($req->request->get('is_img_legal'));
  5966. //            $applicant->setNid($req->request->get('nid'));
  5967. //            $applicant->setDob(HumanResource::StringToDate($req->request->get('dob')));
  5968. //            $applicant->setSex($req->request->get('sex'));
  5969. //            $applicant->setFather($req->request->get('father'));
  5970. //            $applicant->setMother($req->request->get('mother'));
  5971. //            $applicant->setSpouse($req->request->get('spouse'));
  5972. //            $applicant->setChild1($req->request->get('child_1'));
  5973. //            $applicant->setChild2($req->request->get('child_2'));
  5974. //            $applicant->setBlood($req->request->get('blood'));
  5975. //            $applicant->setPhone($req->request->get('phone'));
  5976. //            $applicant->setOAuthEmail($req->request->get('oauth_email'));
  5977. //            $applicant->setCurrAddr($req->request->get('curr_addr'));
  5978. //            $applicant->setPermAddr($req->request->get('perm_addr'));
  5979. //            $applicant->setEmmContact($req->request->get('emm_contact'));
  5980. //
  5981. //            $applicant->setInst1($req->request->get('inst1'));
  5982. //            $applicant->setYr1($req->request->get('yr1'));
  5983. //            $applicant->setDur1($req->request->get('dur1'));
  5984. //            $applicant->setInst2($req->request->get('inst2'));
  5985. //            $applicant->setYr2($req->request->get('yr2'));
  5986. //            $applicant->setDur2($req->request->get('dur2'));
  5987. //            $applicant->setInst3($req->request->get('inst3'));
  5988. //            $applicant->setYr3($req->request->get('yr3'));
  5989. //            $applicant->setDur3($req->request->get('dur3'));
  5990. //            $applicant->setEinst1($req->request->get('einst1'));
  5991. //            $applicant->setEyr1($req->request->get('eyr1'));
  5992. //            $applicant->setEdeg1($req->request->get('edeg1'));
  5993. //            $applicant->setEinst2($req->request->get('einst2'));
  5994. //            $applicant->setEyr2($req->request->get('eyr2'));
  5995. //            $applicant->setEdeg2($req->request->get('edeg2'));
  5996. //            $applicant->setEinst3($req->request->get('einst3'));
  5997. //            $applicant->setEyr3($req->request->get('eyr3'));
  5998. //            $applicant->setEdeg3($req->request->get('edeg3'));
  5999. //
  6000. //            $em->persist($applicant);
  6001. //            $em->flush();
  6002. //
  6003. //            return $this->render(
  6004. //                'ApplicationBundle:pages/human_resource/input_forms:applicant_info.html.twig',
  6005. //                [
  6006. //                    'page_title' => 'Applicant Info',
  6007. //                    'applicant_info' => $applicant,
  6008. //                    'blood' => HumanResourceConstant::$BloodGroup,
  6009. //                    'gender' => HumanResourceConstant::$sex,
  6010. //                    'skillDetails' => $skillDetails,
  6011. //                    'HasUpdateMode' => true,
  6012. //                ]
  6013. //            );
  6014. //        }
  6015. //
  6016. //        if ($id) {
  6017. //            $applicant = $applicantRepo->find($id);
  6018. //
  6019. //            return $this->render(
  6020. //                'ApplicationBundle:pages/human_resource/input_forms:applicant_info.html.twig',
  6021. //                [
  6022. //                    'page_title' => 'Applicant Info',
  6023. //                    'applicant_info' => $applicant,
  6024. //                    'blood' => HumanResourceConstant::$BloodGroup,
  6025. //                    'gender' => HumanResourceConstant::$sex,
  6026. //                    'skillDetails' => $skillDetails,
  6027. //                    'HasUpdateMode' => false,
  6028. //                ]
  6029. //            );
  6030. //        }
  6031. //
  6032. //        $google_client = new Google_Client();
  6033. //        $google_client->setClientId('916737688016-l2qfmb9p37cumudkaqpu8s7ndngq9una.apps.googleusercontent.com');
  6034. //        $google_client->setClientSecret('BEWpEBRvv3-hSoB4cGBrVB3z');
  6035. //        $google_client->setRedirectUri('http://localhost/applicant_info');
  6036. //        $google_client->addScope('email');
  6037. //        $google_client->addScope('profile');
  6038.     }
  6039.     public function applicantDashboardAction()
  6040.     {
  6041.         return new JsonResponse(['this is applicant dashboard']);
  6042.     }
  6043.     public function resignApplicationAction(Request $req$id)
  6044.     {
  6045.         $em $this->getDoctrine()->getManager();
  6046.         if ($req->request->has('xhrReq')) {
  6047.             $response HumanResource::HandelXhrForResignApplication($em$req);
  6048.             return new JsonResponse($response);
  6049.         }
  6050.         if ($req->isMethod('GET')) {
  6051.             $applicant $em->getRepository(EmployeeDetails::class)->findBy(['emp_status' => 1]);
  6052.             $resignReason HumanResourceConstant::$resignReason;
  6053.             return $this->render(
  6054.                 'ApplicationBundle:pages/human_resource/input_forms:resign_application.html.twig',
  6055.                 [
  6056.                     'page_title' => 'Resign Application',
  6057.                     'employeeIds' => $applicant,
  6058.                     'resignReasons' => $resignReason,
  6059.                     'HasUpdateMode' => false,
  6060.                 ]
  6061.             );
  6062.         }
  6063.         if ($req->isMethod('POST')) {
  6064.             $approveHash $req->request->get('approvalHash');
  6065.             $loginId $req->getSession()->get(UserConstants::USER_LOGIN_ID);
  6066.             $isSignatureOk DocValidation::isSignatureOk($em$loginId$approveHash);
  6067.             if ($isSignatureOk) {
  6068.                 $response HumanResource::storeResignApplicationData($em$req);
  6069.                 if ($response) {
  6070.                     return $this->redirectToRoute(
  6071.                         'view_resign_application',
  6072.                         array('id' => $response->getResignApplicationId()),
  6073.                         Response::HTTP_MOVED_PERMANENTLY
  6074.                     );
  6075.                 }
  6076.             } else {
  6077.                 $this->addFlash(
  6078.                     'error',
  6079.                     'Invalid Approval Hash!'
  6080.                 );
  6081.                 return $this->redirectToRoute('resign_application');
  6082.             }
  6083.         }
  6084.     }
  6085.     public function viewResignApplicationAction(Request $req$id 0)
  6086.     {
  6087.         $em $this->getDoctrine()->getManager();
  6088.         $response HumanResource::twigDataForResignApplicationView($em$req$id);
  6089.         return $this->render(
  6090.             'ApplicationBundle:pages/human_resource/views:resign_application_view.html.twig',
  6091.             [
  6092.                 'page_title' => 'View Resign Application',
  6093.                 'approval_data' => $response['approval_data'],
  6094.                 'application' => $response['application'],
  6095.                 'applicant' => $response['applicant'],
  6096.                 'document_log' => $response['document_log'],
  6097.                 'approval_status' => $response['approval_status'],
  6098.                 'created_by' => $response['created_by'],
  6099.                 'updated_at' => $response['updated_at'],
  6100.                 'auto_created' => 0,
  6101.             ]
  6102.         );
  6103.     }
  6104.     public function printResignApplicationAction(Request $req$id)
  6105.     {
  6106.         if ($id) {
  6107.             $em $this->getDoctrine()->getManager();
  6108.             $company_data Company::getCompanyData($em1);
  6109.             $authorizations System::getSignatureListForDocumentPrint($emarray_flip(GeneralConstant::$Entity_list)['ResignApplication'], $id);
  6110.             $response HumanResource::twigDataForResignApplicationView($em$req$id);
  6111.             return $this->render(
  6112.                 'ApplicationBundle:pages/human_resource/print:resign_application_print.html.twig',
  6113.                 array(
  6114.                     'page_title' => 'Print Resign Application',
  6115.                     'export' => 'pdf,print',
  6116.                     'company_name' => $company_data->getName(),
  6117.                     'company_data' => $company_data,
  6118.                     'company_address' => $company_data->getAddress(),
  6119.                     'company_image' => $company_data->getImage(),
  6120.                     'application' => $response['application'],
  6121.                     'applicant' => $response['applicant'],
  6122.                     'Authorizations' => $authorizations,
  6123.                     'red' => 0
  6124.                 )
  6125.             );
  6126.         }
  6127.         return new JsonResponse(array(
  6128.             'success' => false,
  6129.             'msg' => 'Wrong URL format! Please try with application ID'
  6130.         ));
  6131.     }
  6132.     public function listResignApplicationAction(Request $req)
  6133.     {
  6134.         $em $this->getDoctrine()->getManager();
  6135.         $response HumanResource::getResignApplicationList($em$req);
  6136.         return $this->render("ApplicationBundle:pages/human_resource/list:resign_application_list.html.twig", array(
  6137.             'page_title' => 'Resign Application List',
  6138.             'applications' => $response,
  6139.         ));
  6140.     }
  6141.     public function viewNocApprovalAction(Request $req$id)
  6142.     {
  6143.         $em $this->getDoctrine()->getManager();
  6144.         $response HumanResource::twigDataForNocView($em$req$id);
  6145.         return $this->render(
  6146.             'ApplicationBundle:pages/human_resource/views:noc_view.html.twig',
  6147.             [
  6148.                 'page_title' => 'View NOC',
  6149.                 'approval_data' => $response['approval_data'],
  6150.                 'noc_application' => $response['noc_application'],
  6151.                 'resign_application' => $response['resign_application'],
  6152.                 'applicant' => $response['applicant'],
  6153.                 'document_log' => $response['document_log'],
  6154.                 'approval_status' => $response['approval_status'],
  6155.                 'created_by' => $response['created_by'],
  6156.                 'updated_at' => $response['updated_at'],
  6157.                 'auto_created' => 0,
  6158.             ]
  6159.         );
  6160.     }
  6161.     public function printNocApprovalAction(Request $req$id)
  6162.     {
  6163.         $em $this->getDoctrine()->getManager();
  6164.         $company_data Company::getCompanyData($em1);
  6165.         $Authorizations System::getSignatureListForDocumentPrint($emarray_flip(GeneralConstant::$Entity_list)['NocApproval'], $id);
  6166.         $response HumanResource::twigDataForNocView($em$req$id);
  6167.         return $this->render(
  6168.             'ApplicationBundle:pages/human_resource/print:noc_print.html.twig',
  6169.             [
  6170.                 'page_title' => 'Print NOC',
  6171.                 'noc_application' => $response['noc_application'],
  6172.                 'resign_application' => $response['resign_application'],
  6173.                 'applicant' => $response['applicant'],
  6174.                 'export' => 'pdf,print',
  6175.                 'company_name' => $company_data->getName(),
  6176.                 'company_data' => $company_data,
  6177.                 'company_address' => $company_data->getAddress(),
  6178.                 'company_image' => $company_data->getImage(),
  6179.                 'Authorizations' => $Authorizations,
  6180.                 'red' => 0
  6181.             ]
  6182.         );
  6183.     }
  6184.     public function createHolidayAction(Request $request$id)
  6185.     {
  6186.         $em $this->getDoctrine()->getManager();
  6187.         $companyId $this->getLoggedUserCompanyId($request);
  6188.         if ($request->isMethod('POST')) {
  6189.             $entity_id array_flip(GeneralConstant::$Entity_list)['HolidayCalendar']; //change
  6190.             $dochash $request->request->get('doc_hash'); //change
  6191.             $loginId $request->getSession()->get(UserConstants::USER_LOGIN_ID);
  6192.             $approveRole $request->request->get('approvalRole');
  6193.             $approveHash $request->request->get('approvalHash');
  6194.             if (!DocValidation::isInsertable(
  6195.                 $em,
  6196.                 $entity_id,
  6197.                 $dochash,
  6198.                 $loginId,
  6199.                 $approveRole,
  6200.                 $approveHash,
  6201.                 $id
  6202.             )
  6203.             ) {
  6204.                 $this->addFlash(
  6205.                     'error',
  6206.                     'Sorry Couldnot insert Data.'
  6207.                 );
  6208.             } else {
  6209.                 $funcname 'HolidayCalendar';
  6210.                 $doc_id $id;
  6211.                 DeleteDocument::$funcname($em$doc_id0);
  6212.                 if ($id != 0)
  6213.                     $HolidayCalender $em->getRepository(HolidayCalendar::class)->find($id);
  6214.                 else
  6215.                     $HolidayCalender = new HolidayCalendar;
  6216.                 $HolidayCalender->setDocumentHash($request->request->get('doc_hash'));
  6217.                 $HolidayCalender->setHoliDayTitle($request->request->get('holidayCalendarTitle'));
  6218.                 $HolidayCalender->setEmployeeIds(json_encode($request->request->get('employee')));
  6219.                 $HolidayCalender->setEmployeeTypeIds(json_encode($request->request->get('emp_status')));
  6220.                 $HolidayCalender->setDesignationIds(json_encode($request->request->get('desg', [])));
  6221.                 $HolidayCalender->setDepartmentIds(json_encode($request->request->get('dept', [])));
  6222.                 $HolidayCalender->setBranchIds(json_encode($request->request->get('branch', [])));
  6223.                 $HolidayCalender->setLevelSelectionStr($request->get('levelSelectionStr'''));
  6224.                 $HolidayCalender->setLevels(json_encode(HumanResource::getLevelsFromLevelSelectionStr($request->get('levelSelectionStr'''))));
  6225.                 $HolidayCalender->setCompanyId($companyId);
  6226.                 $HolidayCalender->setTypeHash('HD');
  6227.                 $HolidayCalender->setEditFlag(1); //editable usually
  6228.                 $HolidayCalender->setPrefixHash($request->request->get('prefix'));
  6229.                 $HolidayCalender->setAssocHash($request->request->get('assoc'));
  6230.                 $HolidayCalender->setNumberHash($request->request->get('number_hash'));
  6231.                 $HolidayCalender->setCreatedLoginId($request->getSession()->get(UserConstants::USER_LOGIN_ID));
  6232.                 $HolidayCalender->setApproved(GeneralConstant::APPROVAL_STATUS_PENDING);
  6233.                 $HolidayCalender->setAutocreated(0);
  6234. //
  6235. //        $arr = [
  6236. //            'date' =>$request->request->get('start_date'),
  6237. //            'title' => $request->request->get('title'),
  6238. //        ];
  6239. //
  6240. //        $HolidayCalender->setData(json_encode($arr));
  6241.                 $em->persist($HolidayCalender);
  6242.                 $em->flush();
  6243.                 $indHolidays = [];
  6244.                 if ($request->request->has('start_date'))
  6245.                     $indHolidays $request->request->get('start_date');
  6246.                 foreach ($indHolidays as $ind => $dateRangeStr) {
  6247.                     $currRow $request->request->get('row')[$ind];//string
  6248.                     $holidayTitle $request->request->get('title')[$ind];//string
  6249.                     $currStartDate $request->request->get('start_date')[$ind];//string
  6250.                     $currEndDate $request->request->get('end_date')[$ind];//string
  6251.                     $HolidayDate = new HolidayCalendarDates();
  6252.                     $HolidayDate->setHolidayCalendarId($HolidayCalender->getHolidayCalendarId());
  6253.                     $HolidayDate->setDateRange($currStartDate '-' $currEndDate);//string
  6254.                     $HolidayDate->setStartDate(new \DateTime($currStartDate));//date
  6255.                     $HolidayDate->setEndDate(new \DateTime($currEndDate ' 23:59:59'));//date
  6256.                     $HolidayDate->setHolidayTitle($holidayTitle);
  6257. //          $HolidayDate->setIsVariableEachYearFlag($request->request->get('is_variable_each_year',null));
  6258.                     $HolidayDate->setIsVariableEachYearFlag($request->request->get('is_variable_each_year_' $currRownull));
  6259.                     $HolidayDate->setAllDayFlag($request->request->get('all_day_flag_' $currRow1));
  6260.                     $em->persist($HolidayDate);
  6261.                     $em->flush();
  6262.                 }
  6263.                 $options = [];
  6264.                 $entity array_flip(GeneralConstant::$Entity_list)['HolidayCalendar'];
  6265.                 $loginId $request->getSession()->get(UserConstants::USER_LOGIN_ID);
  6266.                 $approveRole $request->request->get('approvalRole');
  6267.                 System::setApprovalInfo(
  6268.                     $em,
  6269.                     $options,
  6270.                     $entity,
  6271.                     $HolidayCalender->getHolidayCalendarId(),
  6272.                     $request->getSession()->get(UserConstants::USER_LOGIN_ID)
  6273.                 );
  6274.                 System::createEditSignatureHash(
  6275.                     $em,
  6276.                     $entity,
  6277.                     $HolidayCalender->getHolidayCalendarId(),
  6278.                     $loginId,
  6279.                     $approveRole,
  6280.                     $request->request->get('approvalHash')
  6281.                 );
  6282.                 $url $this->generateUrl(
  6283.                     'view_holiday_calendar'
  6284.                 );
  6285.                 return $this->redirect($url "/" $HolidayCalender->getHolidayCalendarId());
  6286.             }
  6287.         }
  6288.         $em $this->getDoctrine()->getManager();
  6289.         $branches $em->getRepository(Branch::class)->findAll();
  6290.         $employee $em->getRepository(Employee::class)->findAll();
  6291.         $departments $em->getRepository(SysDepartment::class)->findAll();
  6292.         $departmentPositions $em->getRepository(SysDepartmentPosition::class)->findAll();
  6293.         $EmploymentStatus HumanResourceConstant::$employeeType;
  6294.         $em $this->getDoctrine()->getManager();
  6295.         $extDocData = [];
  6296.         if ($id != 0)
  6297.             $extDocData $em->getRepository(HolidayCalendar::class)->find($id);
  6298.         return $this->render(
  6299.             'ApplicationBundle:pages/human_resource/input_forms:create_holiday.html.twig',
  6300.             [
  6301.                 'page_title' => 'Create Holiday',
  6302.                 'branches' => $branches,
  6303.                 'id' => $id,
  6304.                 'extDocData' => $extDocData,
  6305.                 'departments' => $departments,
  6306.                 'departmentPositions' => $departmentPositions,
  6307.                 'employeeStatus' => $EmploymentStatus,
  6308.                 'employeeIds' => $employee,
  6309.                 'holidayCalendarList' => $em->getRepository('ApplicationBundle:HolidayCalendar')
  6310.                     ->findBy(array())
  6311.             ]
  6312.         );
  6313.     }
  6314.     public function HolidayViewAction(Request $request$id)
  6315.     {
  6316.         $em $this->getDoctrine()->getManager();
  6317.         $HolidaysCalendar $em->getRepository(HolidayCalendar::class)->find($id);
  6318.         $holidayCalendarDetails $em->getRepository('ApplicationBundle:HolidayCalendarDates')
  6319.             ->findBy(array(
  6320.                 'holidayCalendarId' => $id
  6321.             ));
  6322.         $Approval_data System::checkIfApprovalExists(
  6323.             $em,
  6324.             array_flip(GeneralConstant::$Entity_list)['HolidayCalendar'],
  6325.             $id,
  6326.             $request->getSession()->get(UserConstants::USER_LOGIN_ID)
  6327.         );
  6328.         return $this->render('ApplicationBundle:pages/human_resource/views:holidays_view.html.twig', array(
  6329.             'page_title' => 'View Holiday',
  6330.             'holidays' => $HolidaysCalendar,
  6331.             'holidayCalendarDetails' => $holidayCalendarDetails,
  6332.             'approval_status' => $HolidaysCalendar->getApproved(),
  6333.             'approval_data' => $Approval_data,
  6334.             'auto_created' => $HolidaysCalendar->getAutocreated(),
  6335.             'document_log' => $HolidaysCalendar->getAutocreated() == System::getDocumentLog(
  6336.                 $this->getDoctrine()->getManager(),
  6337.                 array_flip(GeneralConstant::$Entity_list)['HolidayCalendar'],
  6338.                 $id,
  6339.                 $HolidaysCalendar->getCreatedLoginId(),
  6340.                 $HolidaysCalendar->getEditedLoginId()
  6341.             ) : []
  6342.         ));
  6343.     }
  6344.     public function GetHolidayDetailsAction(Request $request$id)
  6345.     {
  6346.         $em $this->getDoctrine()->getManager();
  6347.         $holidayCalendar $em->getRepository('ApplicationBundle:HolidayCalendar')
  6348.             ->findOneBy(array(
  6349.                 'holidayCalendarId' => $id
  6350.             ));
  6351.         $holidayCalendarDetails $em->getRepository('ApplicationBundle:HolidayCalendarDates')
  6352.             ->findBy(array(
  6353.                 'holidayCalendarId' => $id
  6354.             ));
  6355.         $holidayList = [];
  6356.         foreach ($holidayCalendarDetails as $det) {
  6357.             $dateDet = array(
  6358.                 'title' => $det->getHolidayTitle(),
  6359.                 'startDate' => $det->getStartDate()->format('Y-m-d'),
  6360.                 'endDate' => $det->getEndDate()->format('Y-m-d'),
  6361.             );
  6362.             $holidayList[] = $dateDet;
  6363.         }
  6364.         return new JsonResponse(
  6365.             array(
  6366.                 'success' => true,
  6367.                 'holidayList' => $holidayList
  6368.             )
  6369.         );
  6370.     }
  6371.     public function GetHolidayListByEmployeeIdAction(Request $request$id)
  6372.     {
  6373.         $em $this->getDoctrine()->getManager();
  6374.         $options = [];
  6375.         $options['employeeId'] = $id;
  6376.         HumanResource::getFilteredHolidaysSingle($em$options);
  6377.         $holidayCalendar $em->getRepository('ApplicationBundle:HolidayCalendar')
  6378.             ->findOneBy(array(
  6379.                 'holidayCalendarId' => $id
  6380.             ));
  6381.         $holidayCalendarDetails $em->getRepository('ApplicationBundle:HolidayCalendarDates')
  6382.             ->findBy(array(
  6383.                 'holidayCalendarId' => $id
  6384.             ));
  6385.         $holidayList = [];
  6386.         foreach ($holidayCalendarDetails as $det) {
  6387.             $dateDet = array(
  6388.                 'title' => $det->getHolidayTitle(),
  6389.                 'startDate' => $det->getStartDate()->format('Y-m-d'),
  6390.                 'endDate' => $det->getEndDate()->format('Y-m-d'),
  6391.             );
  6392.             $holidayList[] = $dateDet;
  6393.         }
  6394.         return new JsonResponse(
  6395.             array(
  6396.                 'success' => true,
  6397.                 'holidayList' => $holidayList
  6398.             )
  6399.         );
  6400.     }
  6401.     public function createQuestionAction(Request $request)
  6402.     {
  6403.         $em $this->getDoctrine()->getManager();
  6404.         $em_goc $this->getDoctrine()->getManager('company_group');
  6405.         $companyId $this->getLoggedUserCompanyId($request);
  6406.         if ($request->isMethod('POST')) {
  6407.             $loginId $request->getSession()->get(UserConstants::USER_LOGIN_ID);
  6408.             $question = new Questionnaire();
  6409.             $question->setQuestionTitle($request->request->get('questionTitle'''));
  6410.             $question->setQuestionText($request->request->get('questionText'''));
  6411.             $question->setIsForPlanningItem($request->request->has('forPlanningItem') ? 0);
  6412.             $question->setIsForInterview($request->request->has('forInterview') ? 0);
  6413.             $question->setIsForMock($request->request->has('forMock') ? 0);
  6414.             $question->setIsForTraining($request->request->has('forTraining') ? 0);
  6415.             $question->setTaggedSkillHashes($request->request->get('skillHash'));
  6416.             $question->setCorrectAnswers(json_encode($request->request->get('correctAns')));
  6417.             $question->setCompanyId($companyId);
  6418.             $optionData = [];
  6419.             foreach ($request->request->get('optionText') as $key => $val) {
  6420.                 $option = array(
  6421.                     'index' => $request->request->get('optionIndex')[$key],
  6422.                     'text' => $val,
  6423.                 );
  6424.                 $optionData[] = $option;
  6425.             }
  6426.             $question->setOptions(json_encode($optionData));
  6427.             $question->setQuestionValueWeight(1);
  6428.             $question->setQuestionText($request->request->get('questionText'));
  6429.             $question->setUniqueHash('_NONE_');
  6430.             $question->setType($request->request->get('type'0));
  6431.             //$skill->setEditFlag(1); //editable usually
  6432.             $question->setCreatedLoginId($request->getSession()->get(UserConstants::USER_LOGIN_ID));
  6433.             //$skill->setApproved(GeneralConstant::APPROVAL_STATUS_PENDING);
  6434.             //$skill->setAutocreated(0);
  6435.             $em->persist($question);
  6436.             $em->flush();
  6437.             $questionId $question->getQuestionId();
  6438.             $file_path_list = [];
  6439.             if ($questionId != 0)
  6440.                 if (!empty($request->files)) {
  6441.                     MiscActions::RemoveFilesForEntityDoc($em_goc'Question'$questionId);
  6442.                     $storePath 'uploads/Questionnaire/';
  6443.                     $path "";
  6444.                     $file_path "";
  6445.                     $session $request->getSession();
  6446. //                    MiscActions::RemoveExpiredFiles($em_goc);
  6447.                     foreach ($request->files as $uploadedFileGG) {
  6448.                         //            if($uploadedFile->getImage())
  6449.                         //                var_dump($uploadedFile->getFile());
  6450.                         //                var_dump($uploadedFile);
  6451.                         $tempD $uploadedFileGG;
  6452.                         if (!is_array($uploadedFileGG)) {
  6453.                             $uploadedFileGG = array();
  6454.                             $uploadedFileGG[] = $tempD;
  6455.                         }
  6456.                         foreach ($uploadedFileGG as $uploadedFile) {
  6457.                             if ($uploadedFile != null) {
  6458.                                 $extension $uploadedFile->guessExtension();
  6459.                                 $size $uploadedFile->getSize();
  6460.                                 $fileName 'QUES_' $questionId '_' . (md5(uniqid())) . '.' $uploadedFile->guessExtension();
  6461.                                 $path $fileName;
  6462.                                 $upl_dir $this->container->getParameter('kernel.root_dir') . '/../web/' $storePath;
  6463.                                 if (!file_exists($upl_dir)) {
  6464.                                     mkdir($upl_dir0777true);
  6465.                                 }
  6466.                                 if (file_exists($upl_dir '' $path)) {
  6467.                                     chmod($upl_dir '' $path0755);
  6468.                                     unlink($upl_dir '' $path);
  6469.                                 }
  6470.                                 $file $uploadedFile->move($upl_dir$path);
  6471.                                 $expireNever 1;
  6472.                                 $expireTs 0;
  6473.                                 $EntityFile = new EntityFile();
  6474.                                 $EntityFile->setPath($this->container->getParameter('kernel.root_dir') . '/../web/' $storePath $path);
  6475.                                 $EntityFile->setMarker('_GEN_');
  6476.                                 $EntityFile->setExtension($extension);
  6477.                                 $EntityFile->setExpireTs($expireTs);
  6478.                                 $EntityFile->setSize($size);
  6479.                                 $EntityFile->setRelativePath($storePath $path);
  6480.                                 $EntityFile->setEntityName('Questionnaire');
  6481.                                 $EntityFile->setEntityBundle('ApplicationBundle');
  6482.                                 $EntityFile->setEntityId($questionId);
  6483.                                 $EntityFile->setEntityIdField('questionId');
  6484.                                 $EntityFile->setModifyFieldSetter('setFiles');
  6485.                                 $EntityFile->setDocIdForApplicant(0);
  6486.                                 $EntityFile->setUserId($session->get(UserConstants::USER_ID0));
  6487.                                 $EntityFile->setAppId($session->get(UserConstants::USER_APP_ID0));
  6488.                                 $EntityFile->setEmployeeId($session->get(UserConstants::USER_EMPLOYEE_ID0));
  6489.                                 $EntityFile->setUserType($session->get(UserConstants::USER_TYPE0));
  6490.                                 $em_goc->persist($EntityFile);
  6491.                                 $em_goc->flush();
  6492.                                 $EntityFileId $EntityFile->getId();
  6493.                             }
  6494.                             if ($path != "")
  6495.                                 $file_path_list[] = ($storePath $path);
  6496.                         }
  6497.                     }
  6498.                     $g_path $this->container->getParameter('kernel.root_dir') . '/../web/' $storePath $path;
  6499.                     $question->setFiles(implode(','$file_path_list));
  6500.                     $em->flush();
  6501.                 }
  6502.             if ($request->request->has('returnJson') || $request->query->has('returnJson')) {
  6503.                 if ($question)
  6504.                     return new JsonResponse(
  6505.                         array(
  6506.                             'id' => $questionId,
  6507.                             'value' => $questionId,
  6508.                             'question_id' => $questionId,
  6509.                             'text' => $question->getQuestionText(),
  6510.                             'question_text' => $question->getQuestionText(),
  6511.                             'question_title' => $question->getQuestionTitle(),
  6512.                             'files' => explode(','$question->getFiles()),
  6513.                             'options' => json_decode($question->getFiles(), true),
  6514.                             'answer_text' => '',
  6515.                             'success' => true
  6516.                         )
  6517.                     );
  6518.                 else
  6519.                     return new JsonResponse(
  6520.                         array(
  6521.                             'success' => false
  6522.                         )
  6523.                     );
  6524.             }
  6525.         }
  6526.         $skillDetails $em->getRepository(Skill::class)->findAll();
  6527.         $skillListObj = [];
  6528.         $skillListArray = [];
  6529.         foreach ($skillDetails as $skillDetail) {
  6530.             $dt = array(
  6531.                 'id' => $skillDetail->getSkillId(),
  6532.                 'name' => $skillDetail->getName(),
  6533.                 'hash' => $skillDetail->getUniqueHash(),
  6534.             );
  6535.             $skillListArray[] = $dt;
  6536.         }
  6537.         return $this->render('ApplicationBundle:pages/human_resource/input_forms:createQuestion.html.twig', array(
  6538.             'page_title' => 'Create Question',
  6539.             'skiillDetails' => $skillDetails,
  6540.             'skillListArray' => $skillListArray,
  6541.         ));
  6542.     }
  6543.     public function createSkillAction(Request $request)
  6544.     {
  6545.         $em $this->getDoctrine()->getManager();
  6546.         $companyId $this->getLoggedUserCompanyId($request);
  6547.         if ($request->isMethod('POST')) {
  6548.             $loginId $request->getSession()->get(UserConstants::USER_LOGIN_ID);
  6549.             $skill = new Skill;
  6550.             $skill->setName($request->request->get('skillName'));
  6551.             $skill->setParentId($request->request->get('parentName'));
  6552.             $skill->setUniqueHash($request->request->get('uniqueHash'));
  6553.             $skill->setCompanyId($companyId);
  6554.             //$skill->setEditFlag(1); //editable usually
  6555.             $skill->setCreatedLoginId($request->getSession()->get(UserConstants::USER_LOGIN_ID));
  6556.             //$skill->setApproved(GeneralConstant::APPROVAL_STATUS_PENDING);
  6557.             //$skill->setAutocreated(0);
  6558.             $em->persist($skill);
  6559.             $em->flush();
  6560.         }
  6561.         $skillDetails $em->getRepository(Skill::class)->findAll();
  6562.         return $this->render('ApplicationBundle:pages/human_resource/input_forms:createSkill.html.twig', array(
  6563.             'page_title' => 'Create Skill',
  6564.             'skiillDetails' => $skillDetails,
  6565.         ));
  6566.     }
  6567.     public function createEducationQualificationAction(Request $request)
  6568.     {
  6569.         $em $this->getDoctrine()->getManager();
  6570.         $companyId $this->getLoggedUserCompanyId($request);
  6571.         if ($request->isMethod('POST')) {
  6572.             $loginId $request->getSession()->get(UserConstants::USER_LOGIN_ID);
  6573.             $new = new EducationQualification;
  6574.             $new->setName($request->request->get('educationName'));
  6575.             $new->setParentId($request->request->get('parentName'));
  6576.             $new->setUniqueHash($request->request->get('uniqueHash'));
  6577.             $new->setCompanyId($companyId);
  6578.             //$skill->setEditFlag(1); //editable usually
  6579.             $new->setCreatedLoginId($request->getSession()->get(UserConstants::USER_LOGIN_ID));
  6580.             //$skill->setApproved(GeneralConstant::APPROVAL_STATUS_PENDING);
  6581.             //$skill->setAutocreated(0);
  6582.             $em->persist($new);
  6583.             $em->flush();
  6584.         }
  6585.         $educationDetails $em->getRepository(EducationQualification::class)->findAll();
  6586.         return $this->render('ApplicationBundle:pages/human_resource/input_forms:create_education.html.twig', array(
  6587.             'page_title' => 'Create Education',
  6588.             'educationDetails' => $educationDetails,
  6589.         ));
  6590.     }
  6591.     public function createEvaluationCategoryAction(Request $request$id 0)
  6592.     {
  6593.         $em $this->getDoctrine()->getManager();
  6594.         $companyId $this->getLoggedUserCompanyId($request);
  6595.         if ($request->isMethod('POST')) {
  6596.             $loginId $request->getSession()->get(UserConstants::USER_LOGIN_ID);
  6597.             $new = new EvaluationCategory;
  6598.             $new->setName($request->request->get('name'));
  6599.             $new->setBranch($request->request->get('branch'));
  6600.             $new->setSelectionType($request->request->get('selection_type'));
  6601.             $new->setEmployeeIds($request->request->get('selected_employeeIds'));
  6602.             $new->setEmployeeTypeIds($request->request->get('employee_types'));
  6603.             $new->setDesignationIds($request->request->get('designation'));
  6604.             $new->setDesignationIds($request->request->get('designation'));
  6605.             $new->setmark($request->request->get('mark'));
  6606.             $new->setSkills(json_encode($request->request->get('skill')));
  6607.             $new->setLevelSelectionStr($request->request->get('levelSelectionStr'));
  6608.             $new->setCompanyId($companyId);
  6609.             $new->setCreatedLoginId($request->getSession()->get(UserConstants::USER_LOGIN_ID));
  6610.             $em->persist($new);
  6611.             $em->flush();
  6612.         }
  6613.         $skill $em->getRepository(Skill::class)->findAll();
  6614.         $employeeIds $em->getRepository(EmployeeDetails::class)->findAll();
  6615.         $employeeType HumanResourceConstant::$employeeType;
  6616.         $Designation $em->getRepository(SysDepartmentPosition::class)->findAll();
  6617.         $branch $em->getRepository(Branch::class)->findAll();
  6618.         $departments $em->getRepository(SysDepartment::class)->findAll();
  6619.         $department = [];
  6620.         foreach ($departments as $entry) {
  6621.             $department[$entry->getDepartmentId()] = array(
  6622.                 'id' => $entry->getDepartmentId(),
  6623.                 'name' => $entry->getDepartmentName(),
  6624.             );
  6625.             return $this->render('ApplicationBundle:pages/human_resource/input_forms:create_evaluation_category.html.twig', array(
  6626.                 'page_title' => 'Create Evaluation Category',
  6627.                 'employeeIds' => $employeeIds,
  6628.                 'employeeType' => $employeeType,
  6629.                 'Designation' => $Designation,
  6630.                 'branch' => $branch,
  6631.                 'department' => $department,
  6632.                 'skill' => $skill,
  6633.             ));
  6634.         }
  6635.     }
  6636.     public function createWorkplaceHarassmentAction(Request $request$id 0)
  6637.     {
  6638.         $em $this->getDoctrine()->getManager();
  6639.         $employeeIds $em->getRepository(EmployeeDetails::class)->findAll();
  6640.         //$employeeType = HumanResourceConstant::$employeeType;
  6641.         $Designation $em->getRepository(SysDepartmentPosition::class)->findAll();
  6642.         $branches $em->getRepository(Branch::class)->findAll();
  6643.         $departments $em->getRepository(SysDepartment::class)->findAll();
  6644.         $harassmentType HumanResourceConstant::$harrasmentType;
  6645.         $department = [];
  6646.         foreach ($departments as $entry) {
  6647.             $department[$entry->getDepartmentId()] = array(
  6648.                 'id' => $entry->getDepartmentId(),
  6649.                 'name' => $entry->getDepartmentName(),
  6650.             );
  6651.         }
  6652.         return $this->render('ApplicationBundle:pages/human_resource/input_forms:create_workplace_harrasment.html.twig', array(
  6653.             'page_title' => 'Create Workplace Harrasment',
  6654.             'employeeIds' => $employeeIds,
  6655.             'branches' => $branches,
  6656.             'harassmentType' => $harassmentType,
  6657.             'departments' => $department,
  6658.             'designationIds' => $Designation
  6659.         ));
  6660.     }
  6661.     public function ViewHarasssmentComplainAction()
  6662.     {
  6663.         return $this->render('ApplicationBundle:pages/human_resource/views:view_harassment_compalin.html.twig', array(
  6664.             'page_title' => 'View Harassment Complain',
  6665.         ));
  6666.     }
  6667.     public function createWorkplaceViolenceAction(Request $request$id 0)
  6668.     {
  6669.         $em $this->getDoctrine()->getManager();
  6670.         $employeeIds $em->getRepository(EmployeeDetails::class)->findAll();
  6671.         //$employeeType = HumanResourceConstant::$employeeType;
  6672.         $Designation $em->getRepository(SysDepartmentPosition::class)->findAll();
  6673.         $branches $em->getRepository(Branch::class)->findAll();
  6674.         $departments $em->getRepository(SysDepartment::class)->findAll();
  6675.         $harassmentType HumanResourceConstant::$harrasmentType;
  6676.         $department = [];
  6677.         foreach ($departments as $entry) {
  6678.             $department[$entry->getDepartmentId()] = array(
  6679.                 'id' => $entry->getDepartmentId(),
  6680.                 'name' => $entry->getDepartmentName(),
  6681.             );
  6682.         }
  6683.         return $this->render('ApplicationBundle:pages/human_resource/input_forms:register_workplace_complaint.html.twig', array(
  6684.             'page_title' => 'Register Complaint',
  6685.             'employeeIds' => $employeeIds,
  6686.             'branches' => $branches,
  6687.             'harassmentType' => $harassmentType,
  6688.             'departments' => $department,
  6689.             'designationIds' => $Designation
  6690.         ));
  6691.     }
  6692.     public function createBonusPolicyAction(Request $request$id 0)
  6693.     {
  6694.         $em $this->getDoctrine()->getManager();
  6695.         $companyId $this->getLoggedUserCompanyId($request);
  6696.         $extDocData = [];
  6697.         $extDetailsData = [];
  6698.         if ($request->isMethod('POST')) {
  6699.             //            Generic::debugMessage($_POST);
  6700.             $em $this->getDoctrine()->getManager();
  6701.             $entity_id array_flip(GeneralConstant::$Entity_list)['BonusPolicy']; //change
  6702.             $dochash $request->request->get('docHash'); //change
  6703.             $loginId $request->getSession()->get(UserConstants::USER_LOGIN_ID);
  6704.             $approveRole $request->request->get('approvalRole');
  6705.             $approveHash $request->request->get('approvalHash');
  6706.             if (!DocValidation::isInsertable(
  6707.                 $em,
  6708.                 $entity_id,
  6709.                 $dochash,
  6710.                 $loginId,
  6711.                 $approveRole,
  6712.                 $approveHash,
  6713.                 $id
  6714.             )
  6715.             ) {
  6716.                 $this->addFlash(
  6717.                     'error',
  6718.                     'Sorry Couldnot insert Data.'
  6719.                 );
  6720.             } else {
  6721.                 $funcname 'BonusPolicy';
  6722.                 DeleteDocument::$funcname($em$id0);
  6723.                 $loginId $request->getSession()->get(UserConstants::USER_LOGIN_ID);
  6724.                 $docId HumanResource::createBonusPolicy($em$request$companyId$loginId0);
  6725.                 //now add Approval info
  6726.                 $approveRole $request->request->get('approvalRole');
  6727.                 $options = array(
  6728.                     'notification_enabled' => $this->container->getParameter('notification_enabled'),
  6729.                     'notification_server' => $this->container->getParameter('notification_server'),
  6730.                     'appId' => $request->getSession()->get(UserConstants::USER_APP_ID),
  6731.                     'url' => $this->generateUrl(
  6732.                         GeneralConstant::$Entity_list_details[array_flip(GeneralConstant::$Entity_list)['BonusPolicy']]['entity_view_route_path_name']
  6733.                     )
  6734.                 );
  6735.                 System::setApprovalInfo(
  6736.                     $this->getDoctrine()->getManager(),
  6737.                     $options,
  6738.                     array_flip(GeneralConstant::$Entity_list)['BonusPolicy'],
  6739.                     $docId,
  6740.                     $request->getSession()->get(UserConstants::USER_LOGIN_ID)
  6741.                 );
  6742.                 System::createEditSignatureHash(
  6743.                     $this->getDoctrine()->getManager(),
  6744.                     array_flip(GeneralConstant::$Entity_list)['BonusPolicy'],
  6745.                     $docId,
  6746.                     $loginId,
  6747.                     $approveRole,
  6748.                     $request->request->get('approvalHash')
  6749.                 );
  6750.                 $doc_here $this->getDoctrine()
  6751.                     ->getRepository('ApplicationBundle:BonusPolicy')
  6752.                     ->findOneBy(
  6753.                         array(
  6754.                             'id' => $docId
  6755.                         )
  6756.                     );
  6757.                 //notify
  6758.                 $this->addFlash(
  6759.                     'success',
  6760.                     'Policy Successfully Updated.'
  6761.                 );
  6762.                 $url $this->generateUrl(
  6763.                     'view_bonus_policy'
  6764.                 );
  6765. //                System::AddNewNotification(
  6766. //                    $this->container->getParameter('notification_enabled'),
  6767. //                    $this->container->getParameter('notification_server'),
  6768. //                    $request->getSession()->get(UserConstants::USER_APP_ID),
  6769. //                    $request->getSession()->get(UserConstants::USER_COMPANY_ID),
  6770. //                    "Salary Segregation Policy : " . $doc_here->getDocumentHash() . " Has Been Created And is Under Processing",
  6771. //                    'pos',
  6772. //                    System::getPositionIdsByDepartment($em, GeneralConstant::HRM_DEPARTMENT),
  6773. //                    'success',
  6774. //                    //                    $url . "/" . $TransID,
  6775. //                    $url . "/" . $docId,
  6776. //                    "Journal"
  6777. //
  6778. //                );
  6779.                 return $this->redirect($url "/" $docId);
  6780.             }
  6781.         }
  6782.         //for edits
  6783.         if ($id == 0) {
  6784.         } else {
  6785.             $extDocData $em->getRepository('ApplicationBundle:BonusPolicy')->findOneBy(
  6786.                 array(
  6787.                     'id' => $id///material
  6788.                 )
  6789.             );
  6790.             //now if its not editable, redirect to view
  6791.             if ($extDocData) {
  6792.                 if ($extDocData->getEditFlag() != 1) {
  6793. //          $url = $this->generateUrl(
  6794. ////              'view_salary_segregation_policy'
  6795. //              'salary_segregation_policy'
  6796. //          );
  6797. //          return $this->redirect($url . "/" . $id);
  6798.                 } else {
  6799. //          $extVoucherDetailsData = Accounts::GetVoucherDataForEdit($em, $voucherId);
  6800. //          $extDetailsData = $em->getRepository('ApplicationBundle:SalarySegregationPolicy')->findOneBy(
  6801. //              array(
  6802. //                  'transactionId' => $id, ///material
  6803. //
  6804. //              )
  6805. //          );
  6806.                 }
  6807.             } else {
  6808.             }
  6809.         }
  6810.         $employeeIds $em->getRepository(EmployeeDetails::class)->findAll();
  6811.         $employeeType HumanResourceConstant::$employeeType;
  6812.         $Designation $em->getRepository(SysDepartmentPosition::class)->findAll();
  6813.         $branch $em->getRepository(Branch::class)->findAll();
  6814.         $departments $em->getRepository(SysDepartment::class)->findAll();
  6815.         $department = [];
  6816.         foreach ($departments as $entry) {
  6817.             $department[$entry->getDepartmentId()] = array(
  6818.                 'id' => $entry->getDepartmentId(),
  6819.                 'name' => $entry->getDepartmentName(),
  6820.             );
  6821.         }
  6822.         return $this->render('ApplicationBundle:pages/human_resource/input_forms:create_bonus_policy.html.twig', array(
  6823.             'page_title' => 'Create Bonus Policy',
  6824.             'employeeIds' => $employeeIds,
  6825.             'employeeType' => $employeeType,
  6826.             'Designation' => $Designation,
  6827.             'branch' => $branch,
  6828.             'department' => $department,
  6829.         ));
  6830.     }
  6831.     public function BonusPolicyListAction()
  6832.     {
  6833.         $em $this->getDoctrine()->getManager();
  6834.         $bonusPolicy $em->getRepository(BonusPolicy::class)->findAll();
  6835.         return $this->render('ApplicationBundle:pages/human_resource/list:bonus_policy_list.html.twig', array(
  6836.             'page_title' => 'Increment Policy List',
  6837.             'bonusPolicy' => $bonusPolicy
  6838.         ));
  6839.     }
  6840.     public function createIncrementPolicyAction(Request $request$id 0)
  6841.     {
  6842.         $em $this->getDoctrine()->getManager();
  6843.         $companyId $this->getLoggedUserCompanyId($request);
  6844.         $extDocData = [];
  6845.         $extDetailsData = [];
  6846.         if ($request->isMethod('POST')) {
  6847.             //            Generic::debugMessage($_POST);
  6848.             $em $this->getDoctrine()->getManager();
  6849.             $entity_id array_flip(GeneralConstant::$Entity_list)['IncrementPolicy']; //change
  6850.             $dochash $request->request->get('docHash'); //change
  6851.             $loginId $request->getSession()->get(UserConstants::USER_LOGIN_ID);
  6852.             $approveRole $request->request->get('approvalRole');
  6853.             $approveHash $request->request->get('approvalHash');
  6854.             if (!DocValidation::isInsertable(
  6855.                 $em,
  6856.                 $entity_id,
  6857.                 $dochash,
  6858.                 $loginId,
  6859.                 $approveRole,
  6860.                 $approveHash,
  6861.                 $id
  6862.             )
  6863.             ) {
  6864.                 $this->addFlash(
  6865.                     'error',
  6866.                     'Sorry Couldnot insert Data.'
  6867.                 );
  6868.             } else {
  6869.                 $funcname 'IncrementPolicy';
  6870.                 DeleteDocument::$funcname($em$id0);
  6871.                 $docId HumanResource::createIncrementPolicy($em$request$companyId0);
  6872.                 //now add Approval info
  6873.                 $loginId $request->getSession()->get(UserConstants::USER_LOGIN_ID);
  6874.                 $approveRole $request->request->get('approvalRole');
  6875.                 $options = array(
  6876.                     'notification_enabled' => $this->container->getParameter('notification_enabled'),
  6877.                     'notification_server' => $this->container->getParameter('notification_server'),
  6878.                     'appId' => $request->getSession()->get(UserConstants::USER_APP_ID),
  6879.                     'url' => $this->generateUrl(
  6880.                         GeneralConstant::$Entity_list_details[array_flip(GeneralConstant::$Entity_list)['IncrementPolicy']]
  6881.                         ['entity_view_route_path_name']
  6882.                     )
  6883.                 );
  6884.                 System::setApprovalInfo(
  6885.                     $this->getDoctrine()->getManager(),
  6886.                     $options,
  6887.                     array_flip(GeneralConstant::$Entity_list)['IncrementPolicy'],
  6888.                     $docId,
  6889.                     $request->getSession()->get(UserConstants::USER_LOGIN_ID),
  6890.                     3    //journal voucher
  6891.                 );
  6892.                 System::createEditSignatureHash(
  6893.                     $this->getDoctrine()->getManager(),
  6894.                     array_flip(GeneralConstant::$Entity_list)['IncrementPolicy'],
  6895.                     $docId,
  6896.                     $loginId,
  6897.                     $approveRole,
  6898.                     $request->request->get('approvalHash')
  6899.                 );
  6900.                 $doc_here $this->getDoctrine()
  6901.                     ->getRepository('ApplicationBundle:IncrementPolicy')
  6902.                     ->findOneBy(
  6903.                         array(
  6904.                             'id' => $docId
  6905.                         )
  6906.                     );
  6907.                 //notify
  6908.                 $this->addFlash(
  6909.                     'success',
  6910.                     'Policy Successfully Updated.'
  6911.                 );
  6912.                 $url $this->generateUrl(
  6913.                     'view_increment_policy'
  6914.                 );
  6915.                 return $this->redirect($url "/" $docId);
  6916.             }
  6917.         }
  6918.         //for edits
  6919.         if ($id == 0) {
  6920.         } else {
  6921.             $extDocData $em->getRepository('ApplicationBundle:IncrementPolicy')->findOneBy(
  6922.                 array(
  6923.                     'id' => $id///material
  6924.                 )
  6925.             );
  6926.             //now if its not editable, redirect to view
  6927.             if ($extDocData) {
  6928.                 if ($extDocData->getEditFlag() != 1) {
  6929. //          $url = $this->generateUrl(
  6930. ////              'view_salary_segregation_policy'
  6931. //              'salary_segregation_policy'
  6932. //          );
  6933. //          return $this->redirect($url . "/" . $id);
  6934.                 } else {
  6935. //          $extVoucherDetailsData = Accounts::GetVoucherDataForEdit($em, $voucherId);
  6936. //          $extDetailsData = $em->getRepository('ApplicationBundle:SalarySegregationPolicy')->findOneBy(
  6937. //              array(
  6938. //                  'transactionId' => $id, ///material
  6939. //
  6940. //              )
  6941. //          );
  6942.                 }
  6943.             } else {
  6944.             }
  6945.         }
  6946.         //$em = $this->getDoctrine()->getManager();
  6947.         $employeeIds $em->getRepository(EmployeeDetails::class)->findAll();
  6948.         $employeeType HumanResourceConstant::$employeeType;
  6949.         $Designation $em->getRepository(SysDepartmentPosition::class)->findAll();
  6950.         $branch $em->getRepository(Branch::class)->findAll();
  6951.         $departments $em->getRepository(SysDepartment::class)->findAll();
  6952.         $department = [];
  6953.         foreach ($departments as $entry) {
  6954.             $department[$entry->getDepartmentId()] = array(
  6955.                 'id' => $entry->getDepartmentId(),
  6956.                 'name' => $entry->getDepartmentName(),
  6957.             );
  6958.         }
  6959.         return $this->render('ApplicationBundle:pages/human_resource/input_forms:create_increment_policy.html.twig', array(
  6960.             'page_title' => 'Create Increment Policy',
  6961.             'employeeIds' => $employeeIds,
  6962.             'employeeType' => $employeeType,
  6963.             'Designation' => $Designation,
  6964.             'branch' => $branch,
  6965.             'department' => $department,
  6966.         ));
  6967.     }
  6968.     public function IncrementPolicyListAction()
  6969.     {
  6970.         $em $this->getDoctrine()->getManager();
  6971.         $incrementPolicy $em->getRepository(IncrementPolicy::class)->findAll();
  6972.         return $this->render('ApplicationBundle:pages/human_resource/list:increment_policy_list.html.twig', array(
  6973.             'page_title' => 'Increment Policy List',
  6974.             'incrementPolicy' => $incrementPolicy
  6975.         ));
  6976.     }
  6977.     public function ViewIncrementPolicyAction(Request $request$id)
  6978.     {
  6979.         $em $this->getDoctrine()->getManager();
  6980.         $incrementPolicy $em->getRepository(IncrementPolicy::class)->find($id);
  6981.         $Approval_data System::checkIfApprovalExists(
  6982.             $em,
  6983.             array_flip(GeneralConstant::$Entity_list)['IncrementPolicy'],
  6984.             $id,
  6985.             $request->getSession()->get(UserConstants::USER_LOGIN_ID)
  6986.         );
  6987.         return $this->render('ApplicationBundle:pages/human_resource/views:view_increment_policy.html.twig', array(
  6988.             'page_title' => 'Increment Policy List',
  6989.             'incrementPolicy' => $incrementPolicy,
  6990.             'approval_status' => $incrementPolicy->getApproved(),
  6991.             'approval_data' => $Approval_data,
  6992.             'auto_created' => $incrementPolicy->getAutocreated(),
  6993.             'id' => $id,
  6994.             'document_log' => $incrementPolicy->getAutocreated() == System::getDocumentLog(
  6995.                 $this->getDoctrine()->getManager(),
  6996.                 array_flip(GeneralConstant::$Entity_list)['FundRequisition'],
  6997.                 $id,
  6998.                 $incrementPolicy->getCreatedLoginId(),
  6999.                 $incrementPolicy->getEditedLoginId()
  7000.             ) : []
  7001.         ));
  7002.     }
  7003.     public function createConsultancyTopicAction(Request $request$id 0)
  7004.     {
  7005.         $em $this->getDoctrine()->getManager();
  7006.         $companyId $this->getLoggedUserCompanyId($request);
  7007.         if ($request->isMethod('POST')) {
  7008.             $loginId $request->getSession()->get(UserConstants::USER_LOGIN_ID);
  7009.             $new = new ConsultancyTopic();
  7010.             $new->setTopicName($request->request->get('topicName'));
  7011.             $new->setParentTopicName($request->request->get('parentTopicName'));
  7012.             $new->setUniqueHash($request->request->get('uniqueHash'));
  7013.             $new->setCompanyId($companyId);
  7014.             $new->setTopicSlug($request->request->get('topicSlug'));
  7015.             $new->setTitle($request->request->get('title'));
  7016.             $new->setSubTitle($request->request->get('subTitle'));
  7017.             $new->setSummary($request->request->get('content'));
  7018.             $new->setVideo($request->request->get('video'));
  7019.             $new->setAuthor($request->request->get('author'));
  7020.             $new->setAuthorSummary($request->request->get('authorSummary'));
  7021.             $new->setCreatedLoginId($request->getSession()->get(UserConstants::USER_LOGIN_ID));
  7022. //            $arr = [
  7023. //                'requirement' => $request->request->get('requirement'),
  7024. //
  7025. //            ];
  7026. //            $new->setRequirementData(json_encode($arr));
  7027.             $em->persist($new);
  7028.             $em->flush();
  7029.         }
  7030. //            $data = [];
  7031. //            $em = $this->getDoctrine()->getManager();
  7032. //            $companyId = $this->getLoggedUserCompanyId($request);
  7033. //            if ($request->isMethod('POST')) {
  7034. //                $em = $this->getDoctrine()->getManager();
  7035. //                $entity_id = array_flip(GeneralConstant::$Entity_list)['ConsultancyTopic'];
  7036. //                //$dochash = $request->request->get('docHash');//change
  7037. //                $approveRole = $request->request->get('approvalRole');
  7038. //                $approveHash = $request->request->get('approvalHash');
  7039. //                $loginId = $request->getSession()->get(UserConstants::USER_LOGIN_ID);
  7040. //                if (!DocValidation::isInsertable($em, $entity_id,
  7041. //                    $loginId, $approveRole, $approveHash, $id)
  7042. //                ) {
  7043. //                    $this->addFlash(
  7044. //                        'error',
  7045. //                        'Sorry Could not insert Data.'
  7046. //                    );
  7047. //                }  else {
  7048. //                    $data = $request->request;
  7049. //                    $docId = HumanResource::createConsultancyTopic($em, $loginId, $id, $data, $companyId);
  7050. ////                    now add Approval info
  7051. //
  7052. //                    $approveRole = $request->request->get('approvalRole');
  7053. //                    $options = array(
  7054. //                        'notification_enabled' => $this->container->getParameter('notification_enabled'),
  7055. //                        'notification_server' => $this->container->getParameter('notification_server'),
  7056. //                        'appId' => $request->getSession()->get(UserConstants::USER_APP_ID),
  7057. ////                        'url' => $this->generateUrl(
  7058. ////                            GeneralConstant::$Entity_list_details[array_flip(GeneralConstant::$Entity_list)['EmployeePerformanceEvolution']]
  7059. ////                            ['entity_view_route_path_name']
  7060. ////                        )
  7061. //                    );
  7062. //                    System::setApprovalInfo($this->getDoctrine()->getManager(), $options,
  7063. //                        array_flip(GeneralConstant::$Entity_list)['ConsultancyTopic'],
  7064. //                        $docId,
  7065. //                        $request->getSession()->get(UserConstants::USER_LOGIN_ID)    //journal voucher
  7066. //                    );
  7067. //                    System::createEditSignatureHash($this->getDoctrine()->getManager(), array_flip(GeneralConstant::$Entity_list)['ConsultancyTopic'],
  7068. //                        $docId,
  7069. //                        $loginId,
  7070. //                        $request->request->get('approvalHash'));
  7071. //                    $this->addFlash(
  7072. //                        'success',
  7073. //                        'New Consultancy Topic Added.'
  7074. //                    );
  7075. ////                    $url = $this->generateUrl(
  7076. ////                        'create_consultancy_topic'
  7077. ////                    );
  7078. //                    //return $this->redirect($url);
  7079. //
  7080. //                }
  7081. //            }
  7082.         $consultancyDetails $em->getRepository('ApplicationBundle:ConsultancyTopic')->findAll();
  7083.         return $this->render('ApplicationBundle:pages/human_resource/input_forms:create_consultancy.html.twig', array(
  7084.             'page_title' => 'Consultancy Topic',
  7085.             'consultancyDetails' => $consultancyDetails,
  7086. //                'requirement' => json_decode($consultancyDetails->getRequirementData())
  7087.         ));
  7088.     }
  7089.     public function createTopicAction(Request $request$id 0)
  7090.     {
  7091.         $em $this->getDoctrine()->getManager('company_group');
  7092.         $companyId $this->getLoggedUserCompanyId($request);
  7093.         $documentQRY $em->getRepository('CompanyGroupBundle:EntityCreateDocument')->findAll();
  7094.         $topicList $em->getRepository('CompanyGroupBundle:EntityCreateTopic')->findAll();
  7095.         $topic = [];
  7096.         $sessionName BuddybeeConstant::$sessionName;
  7097.         $document = [];
  7098.         foreach ($documentQRY as $d) {
  7099.             $document[$d->getId()] = array(
  7100.                 'id' => $d->getId(),
  7101.                 'documentName' => $d->getDocumentName(),
  7102.                 'text' => $d->getDocumentName(),
  7103.             );
  7104.         }
  7105.         $topicId $id;
  7106.         if ($topicId != 0)
  7107.             $topic $em->getRepository('CompanyGroupBundle:EntityCreateTopic')->findOneBy(
  7108.                 array(
  7109.                     'id' => $topicId
  7110.                 )
  7111.             );
  7112.         if ($request->isMethod('POST')) {
  7113.             if ($request->request->has('topicId'))
  7114.                 $topicId $request->request->get('topicId');
  7115. //            $loginId = $request->getSession()->get(UserConstants::USER_LOGIN_ID);
  7116.             if ($topicId != 0)
  7117.                 $new $em->getRepository('CompanyGroupBundle:EntityCreateTopic')->findOneBy(
  7118.                     array(
  7119.                         'id' => $topicId
  7120.                     )
  7121.                 );
  7122.             else
  7123.                 $new = new EntityCreateTopic();
  7124.             $new->setTopicName($request->request->get('topicName'));
  7125.             $new->setParentTopicId($request->request->get('parentTopic'));
  7126.             if ($request->request->get('countryId') != '')
  7127.                 $new->setCountryId($request->request->get('countryId'));
  7128.             else if ($request->request->get('parentTopic') != '') {
  7129.                 $parentTopic $em->getRepository('CompanyGroupBundle:EntityCreateTopic')->findOneBy(
  7130.                     array(
  7131.                         'id' => $request->request->get('parentTopic')
  7132.                     )
  7133.                 );
  7134.                 if ($parentTopic)
  7135.                     $new->setCountryId($parentTopic->getCountryId());
  7136.             }
  7137.             $new->setTimeSlotMultipliers($request->request->get('timeSlotMultipliers'));
  7138.             $new->setOnlyBookableByAdmin($request->request->get('onlyBookableByAdmin'0));
  7139.             $new->setMeetingType($request->request->get('meetingType'0));
  7140.             $new->setConsultantCanUpload($request->request->get('consultantCanUpload'0));
  7141.             $new->setTopicMarker($request->request->get('topicMarker'));
  7142.             $new->setCoinMultiplierValue($request->request->get('coinMultiplierValue'1));
  7143.             $new->setMinLifetimeCoinsBalance($request->request->get('minLifetimeCoinsBalance'0));
  7144.             $new->setMapEmbedIframe($request->request->get('mapEmbedIframe'''));
  7145.             $new->setTopicSummary($request->request->get('topicSummary'));
  7146.             $new->setAddress($request->request->get('address'));
  7147.             $new->setLocationString($request->request->get('locationString'));
  7148.             $new->setLocationLat($request->request->get('locationLat'));
  7149.             $new->setLocationLong($request->request->get('locationLong'));
  7150.             $new->setUniversityRanking($request->request->get('universityRanking'));
  7151.             $new->setIsParent($request->request->get('isParent'));
  7152.             $new->setIsEvent($request->request->get('isEvent'));
  7153.             $new->setConsultancyEnabled($request->request->get('consultancyEnabled'0));
  7154.             $new->setEventExpired($request->request->get('eventExpired'0));
  7155.             $new->setEventDesc($request->request->get('eventDesc'0));
  7156.             $eventStartDate = new \DateTime($request->request->get('eventStartDate'));
  7157.             $eventEndDate = new \DateTime($request->request->get('eventStartDate'));
  7158.             $new->setEventStartDate($eventStartDate);
  7159.             $new->setEventStartDateTs($eventStartDate->format('U'));
  7160.             $new->setEventEndDate($eventEndDate);
  7161.             $new->setEventStartDateTs($eventEndDate->format('U'));
  7162.             $new->setCreatedLoginId($request->getSession()->get(UserConstants::USER_LOGIN_ID));
  7163.             $checkListStringArray = [];
  7164.             if ($request->request->has('checkList'))
  7165.                 foreach ($request->request->get('checkList') as $value) {
  7166.                     $checkListStringArray [] = explode(","$value);
  7167.                 }
  7168.             $docData = [];
  7169.             foreach ($request->request->get('document', []) as $key => $value)
  7170.                 $docData[] = [
  7171.                     'document' => $request->request->get('document')[$key],
  7172.                     'expDays' => $request->request->get('expDays')[$key],
  7173.                     'stage' => $request->request->get('stage')[$key],
  7174.                     'generalProcessingDays' => $request->request->get('generalProcessingDays')[$key],
  7175.                     'emergencyProcessingDays' => $request->request->get('emergencyProcessingDays')[$key],
  7176.                     'thresholdDaysOffset' => $request->request->get('thresholdDaysOffset')[$key],
  7177.                     'checklist' => explode(","$request->request->get('checkList')[$key])
  7178.                 ];
  7179.             $coursePlanData = [];
  7180.             foreach ($request->request->get('coursePlanSessionNo', []) as $key => $value)
  7181.                 if ($request->request->get('coursePlanSessionNo')[$key] != '' and $request->request->get('coursePlanSessionNo')[$key] != null) {
  7182.                     if (!isset($coursePlanData[$request->request->get('coursePlanSessionNo')[$key]]))
  7183.                         $coursePlanData[$request->request->get('coursePlanSessionNo')[$key]] = [];
  7184.                     $coursePlanData[$request->request->get('coursePlanSessionNo')[$key]][] = [
  7185.                         'sessionNo' => $request->request->get('coursePlanSessionNo')[$key],
  7186.                         'subject' => $request->request->get('coursePlanSubject')[$key],
  7187.                         'details' => $request->request->get('coursePlanDetails')[$key],
  7188.                         'optimumMin' => $request->request->get('coursePlanOptimumMin')[$key],
  7189.                     ];
  7190.                 }
  7191.             $routineData = [];
  7192.             foreach ($request->request->get('routine_sequence', []) as $key => $value) {
  7193.                 $routineData[] = [
  7194.                     'sequence' => $request->request->get('routine_sequence')[$key],
  7195.                     'topicId' => $request->request->get('routine_topic_id')[$key],
  7196.                     'topicName' => $request->request->get('routine_topic_name')[$key],
  7197.                     'meetingType' => $request->request->get('routine_topic_meeting_type')[$key],
  7198.                     'duration' => $request->request->get('routine_duration')[$key],
  7199.                     'offset' => $request->request->get('routine_offset')[$key],
  7200.                     'coins' => $request->request->get('routine_coins')[$key],
  7201.                     'nextSequenceStart' => $request->request->has('routine_next_sequence_start_' $value) ? 0,
  7202.                     'modifiable' => $request->request->has('routine_modifiable_' $value) ? 0,
  7203.                 ];
  7204.             }
  7205.             $sessionData = [];
  7206.             foreach ($request->request->get('sessionId', []) as $key => $value)
  7207.                 $sessionData[] = [
  7208.                     'sessionId' => $request->request->get('sessionId')[$key],
  7209.                     'sessionYear' => $request->request->get('year')[$key],
  7210.                     'threshold' => $request->request->get('threshold')[$key],
  7211.                     'sessionStart' => $request->request->get('sessionStart')[$key],
  7212.                     'applicationStartDate' => $request->request->get('applicationStartDate')[$key],
  7213.                 ];
  7214.             $coursesData = [];
  7215.             foreach ($request->request->get('courseName', []) as $key => $value)
  7216.                 $coursesData[] = [
  7217.                     'courseName' => $request->request->get('courseName')[$key],
  7218.                 ];
  7219.             $departmentData = [];
  7220.             foreach ($request->request->get('departmentName', []) as $key => $value)
  7221.                 $departmentData[] = [
  7222.                     'departmentName' => $request->request->get('departmentName')[$key],
  7223.                 ];
  7224.             $benefitsData = [];
  7225.             foreach ($request->request->get('benefit', []) as $key => $value)
  7226.                 $benefitsData[] = [
  7227.                     'benefit' => $request->request->get('benefit')[$key],
  7228.                 ];
  7229.             $new->setRoutineData(json_encode($routineData));
  7230.             $new->setDocumentData(json_encode($docData));
  7231.             $new->setCoursePlanData(json_encode($coursePlanData));
  7232.             $new->setSessionData(json_encode($sessionData));
  7233.             $new->setCourses(json_encode($coursesData));
  7234.             $new->setDepartments(json_encode($departmentData));
  7235.             $new->setBenefits(json_encode($benefitsData));
  7236.             $otherDataObj = [];
  7237.             foreach (BuddybeeConstant::$otherDataByHash as $ohash => $otherDataGroup)
  7238.                 foreach ($otherDataGroup as $otherData) {
  7239.                     $fieldExists $request->request->has($ohash '_' $otherData['field']);
  7240.                     if ($fieldExists) {
  7241.                         $fieldValue $request->request->get($ohash '_' $otherData['field'], '');
  7242.                         $otherDataObj[$ohash '_' $otherData['field']] = $fieldValue;
  7243.                     }
  7244.                 }
  7245.             $new->setOtherData(json_encode($otherDataObj));
  7246.             $new->setBenefits(json_encode($benefitsData));
  7247.             $em->persist($new);
  7248.             $em->flush();
  7249.             $path "";
  7250.             $defaultProductImage '';
  7251.             $uploadedFile null;
  7252.             $upl_dir $this->container->getParameter('kernel.root_dir') . '/../web/uploads/topicImage/';
  7253.             $uploadedFile $request->files->get('topicSummaryImage');
  7254.             if ($uploadedFile != null) {
  7255.                 $fileName 'TSI' $new->getId() . '.' $uploadedFile->guessExtension();
  7256.                 $path $fileName;
  7257. //            $upl_dir = $this->container->getParameter('kernel.root_dir') . '/../web/uploads/Products/';
  7258.                 if (!file_exists($upl_dir)) {
  7259.                     mkdir($upl_dir0777true);
  7260.                 }
  7261.                 $uploadedFile->move($upl_dir$path);
  7262.                 $defaultProductImage 'uploads/topicImage/' $path;
  7263.                 $new->setTopicSummaryImage($defaultProductImage);
  7264.                 $em->flush();
  7265.             }
  7266.             $path "";
  7267.             $defaultProductImage '';
  7268.             $uploadedFile null;
  7269.             $upl_dir $this->container->getParameter('kernel.root_dir') . '/../web/uploads/topicImage/';
  7270.             $uploadedFile $request->files->get('topicImage');
  7271.             if ($uploadedFile != null) {
  7272.                 $fileName 'TI' $new->getId() . '.' $uploadedFile->guessExtension();
  7273.                 $path $fileName;
  7274. //            $upl_dir = $this->container->getParameter('kernel.root_dir') . '/../web/uploads/Products/';
  7275.                 if (!file_exists($upl_dir)) {
  7276.                     mkdir($upl_dir0777true);
  7277.                 }
  7278.                 $uploadedFile->move($upl_dir$path);
  7279.                 $defaultProductImage 'uploads/topicImage/' $path;
  7280.                 $new->setTopicImage($defaultProductImage);
  7281.                 $em->flush();
  7282.             }
  7283.             $this->addFlash(
  7284.                 'success',
  7285.                 'Topic Added.'
  7286.             );
  7287.         }
  7288.         return $this->render('ApplicationBundle:pages/human_resource/input_forms:create_topic.html.twig', array(
  7289.             'page_title' => 'Create Topic',
  7290.             'defaultCoursePlan' => BuddybeeConstant::$defaultCoursePlan,
  7291.             'coursePlanSessionTitle' => BuddybeeConstant::$coursePlanSessionTitle,
  7292.             'coursePlanSessionTitleShort' => BuddybeeConstant::$coursePlanSessionTitleShort,
  7293.             'document' => $document,
  7294.             'topic' => $topic,
  7295.             'otherDataByHash' => BuddybeeConstant::$otherDataByHash,
  7296.             'topicId' => $topicId,
  7297.             'topicList' => $topicList,
  7298.             'topicMarker' => BuddybeeConstant::$topicMarkup,
  7299.             'sessionName' => $sessionName,
  7300.         ));
  7301.     }
  7302.     public function ConsultancyRequirementSettingsAction(Request $request$id 0)
  7303.     {
  7304.         $em $this->getDoctrine()->getManager('company_group');
  7305.         $entityList $em->getRepository('CompanyGroupBundle:EntityCountryConsultantRequirements')->findAll();
  7306.         $documentQRY $em->getRepository('CompanyGroupBundle:EntityCreateDocument')->findAll();
  7307.         $entity = [];
  7308.         $sessionName BuddybeeConstant::$sessionName;
  7309.         $document = [];
  7310.         foreach ($documentQRY as $d) {
  7311.             $document[$d->getId()] = array(
  7312.                 'id' => $d->getId(),
  7313.                 'documentName' => $d->getDocumentName(),
  7314.                 'text' => $d->getDocumentName(),
  7315.             );
  7316.         }
  7317.         $countryId $id;
  7318.         if ($countryId != 0)
  7319.             $entity $em->getRepository('CompanyGroupBundle:EntityCountryConsultantRequirements')->findOneBy(
  7320.                 array(
  7321.                     'countryId' => $countryId
  7322.                 )
  7323.             );
  7324.         if ($request->isMethod('POST')) {
  7325.             if ($request->request->has('countryId'))
  7326.                 $countryId $request->request->get('countryId');
  7327. //            $loginId = $request->getSession()->get(UserConstants::USER_LOGIN_ID);
  7328.             if ($countryId != 0) {
  7329.                 $new $em->getRepository('CompanyGroupBundle:EntityCountryConsultantRequirements')->findOneBy(
  7330.                     array(
  7331.                         'countryId' => $countryId
  7332.                     )
  7333.                 );
  7334.                 if (!$new)
  7335.                     $new = new EntityCountryConsultantRequirements();
  7336.             } else
  7337.                 $new = new EntityCountryConsultantRequirements();
  7338.             $new->setCountryId($request->request->get('countryId'));
  7339.             $new->setContractLetterHtml($request->request->get('contractLetterHtml'));
  7340.             $new->setRequiredFields($request->request->get('requiredFields'));
  7341.             $new->setAllowedWorkingHoursPerDay($request->request->get('allowedWorkingHoursPerDay'));
  7342.             $new->setAllowedWorkingHoursPerMonth($request->request->get('allowedWorkingHoursPerMonth'));
  7343.             $new->setAllowedWorkingHoursPerWeek($request->request->get('allowedWorkingHoursPerWeek'));
  7344.             $new->setAllowedWorkingHoursPerYear($request->request->get('allowedWorkingHoursPerYear'));
  7345.             $new->setAllowedEarningPerDay($request->request->get('allowedEarningPerDay'));
  7346.             $new->setAllowedEarningPerMonth($request->request->get('allowedEarningPerMonth'));
  7347.             $new->setAllowedEarningPerWeek($request->request->get('allowedEarningPerWeek'));
  7348.             $new->setAllowedEarningPerYear($request->request->get('allowedEarningPerYear'));
  7349.             $new->setRevenuePercentagePerSession($request->request->get('revenuePercentagePerSession'));
  7350.             $docData = [];
  7351.             foreach ($request->request->get('document', []) as $key => $value)
  7352.                 $docData[] = [
  7353.                     'document' => $request->request->get('document')[$key],
  7354.                     'expDays' => $request->request->get('expDays')[$key],
  7355.                     'stage' => $request->request->get('stage')[$key],
  7356.                     'generalProcessingDays' => $request->request->get('generalProcessingDays')[$key],
  7357.                     'emergencyProcessingDays' => $request->request->get('emergencyProcessingDays')[$key],
  7358.                     'thresholdDaysOffset' => $request->request->get('thresholdDaysOffset')[$key],
  7359.                     'checklist' => explode(","$request->request->get('checkList')[$key])
  7360.                 ];
  7361.             $new->setDocumentList(json_encode($docData));
  7362.             $em->persist($new);
  7363.             $em->flush();
  7364.             $this->addFlash(
  7365.                 'success',
  7366.                 'Restriction Updated.'
  7367.             );
  7368.         }
  7369.         return $this->render('@Buddybee/pages/create_consultancy_requirements.html.twig', array(
  7370.             'page_title' => 'Create Requirements',
  7371.             'defaultCoursePlan' => BuddybeeConstant::$defaultCoursePlan,
  7372.             'coursePlanSessionTitle' => BuddybeeConstant::$coursePlanSessionTitle,
  7373.             'coursePlanSessionTitleShort' => BuddybeeConstant::$coursePlanSessionTitleShort,
  7374.             'document' => $document,
  7375.             'entity' => $entity,
  7376.             'otherDataByHash' => BuddybeeConstant::$otherDataByHash,
  7377.             'countryId' => $countryId,
  7378.             'entityList' => $entityList,
  7379.             'topicMarker' => BuddybeeConstant::$topicMarkup,
  7380.             'sessionName' => $sessionName,
  7381.         ));
  7382.     }
  7383.     public function PromoCodeSettingsAction(Request $request$id 0)
  7384.     {
  7385.         $em $this->getDoctrine()->getManager('company_group');
  7386.         $entityList $em->getRepository('CompanyGroupBundle:PromoCode')->findAll();
  7387.         $applicantList $em->getRepository('CompanyGroupBundle:EntityApplicantDetails')->findAll();
  7388.         $promoCodeId $id;
  7389.         $entity = [];
  7390.         if ($promoCodeId != 0)
  7391.             $entity $em->getRepository('CompanyGroupBundle:PromoCode')->findOneBy(
  7392.                 array(
  7393.                     'id' => $promoCodeId
  7394.                 )
  7395.             );
  7396.         if ($request->isMethod('POST')) {
  7397.             if ($request->request->has('promoCodeId'))
  7398.                 $promoCodeId $request->request->get('promoCodeId');
  7399. //            $loginId = $request->getSession()->get(UserConstants::USER_LOGIN_ID);
  7400.             if ($promoCodeId != 0) {
  7401.                 $new $em->getRepository('CompanyGroupBundle:PromoCode')->findOneBy(
  7402.                     array(
  7403.                         'id' => $promoCodeId
  7404.                     )
  7405.                 );
  7406.                 if (!$new)
  7407.                     $new = new PromoCode();
  7408.             } else
  7409.                 $new = new PromoCode();
  7410. //            $new->setCountryId($request->request->get('countryId'));
  7411.             $new->setCode($request->request->get('code'''));
  7412.             $new->setPromoType($request->request->get('promoType'1));
  7413.             $new->setPromoCodeType($request->request->get('promoCodeType'1));
  7414.             $new->setPromoValue($request->request->get('promoValue'0));
  7415.             $new->setPerpetual($request->request->get('perpetual'0));
  7416.             $new->setMaxDiscountAmount($request->request->get('maxDiscountAmount', -1));
  7417.             $new->setMaxCoinAddition($request->request->get('maxCoinAddition', -1));
  7418.             $new->setMinAmountForApplication($request->request->get('minAmountForApplication'0));
  7419.             $new->setMinCoinForApplication($request->request->get('minCoinForApplication'0));
  7420.             $new->setNextApplicationEachCoinCount($request->request->get('nextApplicationEachCoinCount', -1));
  7421.             $new->setMaxUseCount($request->request->get('maxUseCount', -1));
  7422.             $new->setMaxUseCountPerUser($request->request->get('maxUseCountPerUser', -1));
  7423.             $new->setUseCountBalance($request->request->get('useCountBalance', -1));
  7424.             $new->setReferralApplicantId($request->request->get('referralApplicantId'0));
  7425.             $new->setMaxReferralCommissionCount($request->request->get('maxReferralCommissionCount'0));
  7426.             $new->setReferralCommissionCountBalance($request->request->get('referralCommissionCountBalance'0));
  7427.             $new->setReferralCommissionType($request->request->get('referralCommissionType'1));
  7428.             $new->setReferralAmount($request->request->get('referralAmount'0));
  7429.             $startsAt = new \DateTime($request->request->get('startsAt'''));
  7430.             $expiresAt = new \DateTime($request->request->get('expiresAt'''));
  7431.             $new->setStartsAtTs($startsAt->format('U'));
  7432.             $new->setExpiresAtTs($expiresAt->format('U'));
  7433. //
  7434. //        startsAtTs:
  7435. //            type: integer
  7436. //            nullable: true
  7437. //        expiresAtTs:
  7438. //            type: integer
  7439. //            nullable: true
  7440.             $em->persist($new);
  7441.             $em->flush();
  7442.             $this->addFlash(
  7443.                 'success',
  7444.                 'Promo Code Updated.'
  7445.             );
  7446.         }
  7447.         return $this->render('@Buddybee/pages/buddybee_promo_code_settings.html.twig', array(
  7448.             'page_title' => 'Promo Codes',
  7449.             'entity' => $entity,
  7450.             'promoCodeId' => $promoCodeId,
  7451.             'entityList' => $entityList,
  7452.             'applicantList' => $applicantList,
  7453.         ));
  7454.     }
  7455.     public function createDocumentAction(Request $request$id 0)
  7456.     {
  7457.         $em $this->getDoctrine()->getManager('company_group');
  7458.         $companyId $this->getLoggedUserCompanyId($request);
  7459.         $document $em->getRepository('CompanyGroupBundle:EntityCreateDocument')->findAll();
  7460.         $thisDoc = [];
  7461.         if ($id != 0)
  7462.             $thisDoc $em->getRepository('CompanyGroupBundle:EntityCreateDocument')->findOneBy(
  7463.                 array(
  7464.                     'Id' => $id
  7465.                 )
  7466.             );
  7467.         if ($request->isMethod('POST')) {
  7468.             if ($id != 0)
  7469.                 $new $thisDoc;
  7470.             else
  7471.                 $new = new EntityCreateDocument();
  7472.             $new->setDocumentName($request->request->get('docName'));
  7473.             $new->setExpiryDays($request->request->get('expDays'));
  7474.             $new->setProcessingDays($request->request->get('processingDays'));
  7475.             $new->setEmergencyProcessingDays($request->request->get('emergencyProcessingDays'));
  7476.             $new->setDocVideo($request->request->get('docVideoLink'));
  7477.             $new->setRequiredDocument(json_encode($request->request->get('requiredDoc')));
  7478.             $new->setCreatedLoginId($request->getSession()->get(UserConstants::USER_LOGIN_ID));
  7479.             $arr = [
  7480.                 'checkListName' => $request->request->get('checkListName'),
  7481.             ];
  7482.             $new->setCheckList(json_encode($arr));
  7483.             $em->persist($new);
  7484.             $em->flush();
  7485.         }
  7486.         $this->addFlash(
  7487.             'Document Added',
  7488.             'Topic Added.'
  7489.         );
  7490.         return $this->render('ApplicationBundle:pages/human_resource/input_forms:create_document.html.twig', array(
  7491.             'page_title' => 'Create Document',
  7492.             'document' => $document,
  7493.             'thisDoc' => $thisDoc
  7494.         ));
  7495.     }
  7496.     public function getIndividualDocumentAction(Request $request$id)
  7497.     {
  7498.         $em $this->getDoctrine()->getManager('company_group');
  7499.         if ($id == 0) {
  7500.             if ($request->request->has('documentId'))
  7501.                 $id $request->request->get('documentId');
  7502.         }
  7503.         $document $em->getRepository('CompanyGroupBundle:EntityCreateDocument')->find($id);
  7504.         return new JsonResponse(
  7505.             array(
  7506.                 'success' => true,
  7507.                 'rowId' => $request->request->get('rowId'),
  7508.                 'expiryDays' => $document->getExpiryDays(),
  7509.                 'processingDays' => $document->getProcessingDays(),
  7510.                 'emergencyProcessing' => $document->getEmergencyProcessingDays(),
  7511.                 'checklist' => json_decode($document->getCheckList()),
  7512.             )
  7513.         );
  7514.     }
  7515.     public function createBlogAction(Request $request$id)
  7516.     {
  7517.         if (!$id) {
  7518.             if ($request->isMethod('POST')) {
  7519.                 $em $this->getDoctrine()->getManager('company_group');
  7520.                 $loginId $request->getSession()->get(UserConstants::USER_LOGIN_ID);
  7521.                 $new = new EntityCreateBlog();
  7522.                 $new->setTopicId($request->request->get('topicId'));
  7523.                 $new->setTitle($request->request->get('title'));
  7524.                 $new->setSubtitle($request->request->get('subTitle'));
  7525.                 $new->setContent($request->request->get('content'));
  7526.                 $new->setVideoLink($request->request->get('videoLink'));
  7527.                 $new->setAuthorName($request->request->get('authorName'));
  7528.                 $new->setAuthorSummary($request->request->get('authorSummary'));
  7529.                 $new->setIsPrimaryBlog($request->request->get('checkPrimaryBlog'));
  7530.                 $em->persist($new);
  7531.                 $em->flush();
  7532.                 //$fileName = 'cv' . $consultantDetails->getApplicantId() . '.' . $uploadedFile->guessExtension();
  7533.                 $path "";
  7534.                 $defaultProductImage '';
  7535.                 $uploadedFile null;
  7536.                 $upl_dir $this->container->getParameter('kernel.root_dir') . '/../web/uploads/authorImage/';
  7537.                 $uploadedFile $request->files->get('authorImage');
  7538.                 if ($uploadedFile != null) {
  7539.                     $fileName 'authorImage' $new->getId() . '.' $uploadedFile->guessExtension();
  7540.                     $path $fileName;
  7541. //            $upl_dir = $this->container->getParameter('kernel.root_dir') . '/../web/uploads/Products/';
  7542.                     if (!file_exists($upl_dir)) {
  7543.                         mkdir($upl_dir0777true);
  7544.                     }
  7545.                     $uploadedFile->move($upl_dir$path);
  7546.                     $defaultProductImage 'uploads/authorImage/' $path;
  7547.                     $new->setAuthorImage($defaultProductImage);
  7548.                     $em->flush();
  7549.                 }
  7550.                 $path "";
  7551.                 $defaultProductImage '';
  7552.                 $uploadedFile null;
  7553.                 $upl_dir $this->container->getParameter('kernel.root_dir') . '/../web/uploads/mainImage/';
  7554.                 $uploadedFile $request->files->get('main_img');
  7555.                 if ($uploadedFile != null) {
  7556.                     $fileName 'mainImage' $new->getId() . '.' $uploadedFile->guessExtension();
  7557.                     $path $fileName;
  7558. //            $upl_dir = $this->container->getParameter('kernel.root_dir') . '/../web/uploads/Products/';
  7559.                     if (!file_exists($upl_dir)) {
  7560.                         mkdir($upl_dir0777true);
  7561.                     }
  7562.                     $uploadedFile->move($upl_dir$path);
  7563.                     $defaultProductImage 'uploads/mainImage/' $path;
  7564.                     $new->setMainImage($defaultProductImage);
  7565.                     $em->flush();
  7566.                 }
  7567.                 $topicDetails $em->getRepository('CompanyGroupBundle:EntityCreateTopic')->findOneBy(
  7568.                     array(
  7569.                         'id' => $request->request->get('topicId')
  7570.                     )
  7571.                 );
  7572.                 if ($new->getIsPrimaryBlog() == 1) {
  7573.                     if ($topicDetails)
  7574.                         $topic $topicDetails;
  7575.                     else
  7576.                         $topic = new EntityCreateTopic();
  7577.                     $topic->setPrimaryBlogId($new->getId());
  7578.                     $em->flush();
  7579.                 }
  7580.                 $this->addFlash(
  7581.                     'success',
  7582.                     'Blog Added.'
  7583.                 );
  7584.             } else {
  7585.                 $em $this->getDoctrine()->getManager('company_group');
  7586.                 $topic $em->getRepository('CompanyGroupBundle:EntityCreateTopic')->findAll();
  7587.                 $applicant $em->getRepository('CompanyGroupBundle:EntityApplicantDetails')->findAll();
  7588.                 $blogs $em->getRepository('CompanyGroupBundle:EntityCreateBlog')->findAll();
  7589.                 $topicIds = [];
  7590.                 foreach ($blogs as $blog) {
  7591.                     $topicIds [] = $blog->getTopicId();
  7592.                 }
  7593. //                $topic = $em->getRepository('CompanyGroupBundle:EntityCreateTopic')->findBy(
  7594. //                    array(
  7595. //                        'id' => $topicIds
  7596. //                    )
  7597. //                );
  7598.                 return $this->render('ApplicationBundle:pages/human_resource/input_forms:create_blog.html.twig', array(
  7599.                     'page_title' => 'Create Blog',
  7600.                     'topic' => $topic,
  7601.                     'applicant' => $applicant,
  7602.                     'blog' => $blogs,
  7603.                     'id' => $id,
  7604.                 ));
  7605.             }
  7606.         } else {
  7607.             if ($request->isMethod('GET')) {
  7608.                 $em $this->getDoctrine()->getManager('company_group');
  7609.                 $topic $em->getRepository('CompanyGroupBundle:EntityCreateTopic')->findAll();
  7610.                 $applicant $em->getRepository('CompanyGroupBundle:EntityApplicantDetails')->findAll();
  7611.                 $blogs $em->getRepository('CompanyGroupBundle:EntityCreateBlog')->find($id);
  7612.                 return $this->render('ApplicationBundle:pages/human_resource/input_forms:create_blog.html.twig', array(
  7613.                     'page_title' => 'Create Blog',
  7614.                     'topic' => $topic,
  7615.                     'applicant' => $applicant,
  7616.                     'blog' => $blogs,
  7617.                     'id' => $id,
  7618.                 ));
  7619.             } else {
  7620.                 $em $this->getDoctrine()->getManager('company_group');
  7621.                 $new = new EntityCreateBlog();
  7622.                 $new->setTopicId($request->request->get('topicId'));
  7623.                 $new->setTitle($request->request->get('title'));
  7624.                 $new->setSubtitle($request->request->get('subTitle'));
  7625.                 $new->setContent($request->request->get('content'));
  7626.                 $new->setVideoLink($request->request->get('videoLink'));
  7627.                 $new->setAuthorName($request->request->get('authorName'));
  7628.                 $new->setAuthorSummary($request->request->get('authorSummary'));
  7629.                 //$em->persist($new);
  7630.                 $em->flush();
  7631.                 $path "";
  7632.                 $defaultProductImage '';
  7633.                 $uploadedFile null;
  7634.                 $upl_dir $this->container->getParameter('kernel.root_dir') . '/../web/uploads/authorImage/';
  7635.                 $uploadedFile $request->files->get('authorImage');
  7636.                 if ($uploadedFile != null) {
  7637.                     $fileName 'authorImage' '.' $uploadedFile->guessExtension();
  7638.                     $path $fileName;
  7639. //            $upl_dir = $this->container->getParameter('kernel.root_dir') . '/../web/uploads/Products/';
  7640.                     if (!file_exists($upl_dir)) {
  7641.                         mkdir($upl_dir0777true);
  7642.                     }
  7643.                     $uploadedFile->move($upl_dir$path);
  7644.                     $defaultProductImage 'uploads/authorImage/' $path;
  7645.                     $new->setAuthorImage($defaultProductImage);
  7646.                     $em->flush();
  7647.                 }
  7648.                 $this->addFlash(
  7649.                     'success',
  7650.                     'Blog Updated.'
  7651.                 );
  7652.             }
  7653.         }
  7654.         return new JsonResponse(
  7655.             array(
  7656.                 'success' => true,
  7657.             )
  7658.         );
  7659. //        if ($request->isMethod('POST')) {
  7660. //            $loginId = $request->getSession()->get(UserConstants::USER_LOGIN_ID);
  7661. //
  7662. //            $new = new EntityCreateBlog();
  7663. //
  7664. //            $new->setTopicId($request->request->get('topicId'));
  7665. //            $new->setTitle($request->request->get('title'));
  7666. //            $new->setSubtitle($request->request->get('subTitle'));
  7667. //            $new->setContent($request->request->get('content'));
  7668. //            $new->setVideoLink($request->request->get('videoLink'));
  7669. //            $new->setAuthorName($request->request->get('authorName'));
  7670. //            $new->setAuthorSummary($request->request->get('authorSummary'));
  7671. //
  7672. //            $em->persist($new);
  7673. //            $em->flush();
  7674. //
  7675. //
  7676. //            $path = "";
  7677. //            $defaultProductImage = '';
  7678. //            $uploadedFile = null;
  7679. //            $upl_dir = $this->container->getParameter('kernel.root_dir') . '/../web/uploads/authorImage/';
  7680. //            $uploadedFile=  $request->files->get('authorImage');
  7681. //
  7682. //            if ($uploadedFile != null) {
  7683. //
  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_dir, 0777, true);
  7689. //                }
  7690. //                $uploadedFile->move($upl_dir, $path);
  7691. //                $defaultProductImage = 'uploads/authorImage/' . $path;
  7692. //                $new->setAuthorImage($defaultProductImage);
  7693. //                $em->flush();
  7694. //
  7695. //            }
  7696. //            $this->addFlash(
  7697. //                'success',
  7698. //                'Blog Added.'
  7699. //            );
  7700. //        }
  7701. //        return $this->render('ApplicationBundle:pages/human_resource/input_forms:create_blog.html.twig', array(
  7702. //            'page_title' => 'Create Blog',
  7703. //            'topic'=> $topic,
  7704. //            'applicant' => $applicant,
  7705. //            'blog' => $blogs
  7706. //        ));
  7707.     }
  7708.     public function applicantConsultancyAction()
  7709.     {
  7710.         return $this->render('ApplicationBundle:pages/human_resource/input_forms:consultancy.html.twig', array(
  7711.             'page_title' => 'Consultancy',
  7712.         ));
  7713.     }
  7714.     public function viewConsultantDetailsAction(Request $request$id 0)
  7715.     {
  7716.         $gocEnabled 1;
  7717.         $currAppId 4;
  7718.         $honeybeeAppId 1;
  7719.         $buddybeeAppId 4;
  7720.         $em_goc $this->getDoctrine()->getManager('company_group');
  7721.         $em $this->getDoctrine()->getManager();
  7722.         $option = [];
  7723.         $option['appId'] = $currAppId//honeybee
  7724.         $option['departmentId'] = 18//consultancy
  7725.         $option['designationId'] = 50;
  7726. //        $dataToConnect = System::changeDoctrineManagerByAppId(
  7727. //            $this->getDoctrine()->getManager('company_group'),
  7728. //            $gocEnabled,
  7729. //            $currAppId
  7730. //        );
  7731. //        if (!empty($dataToConnect)) {
  7732. //            $connector = $this->container->get('application_connector');
  7733. //            $connector->resetConnection(
  7734. //                'default',
  7735. //                $dataToConnect['dbName'],
  7736. //                $dataToConnect['dbUser'],
  7737. //                $dataToConnect['dbPass'],
  7738. //                $dataToConnect['dbHost'],
  7739. //                $reset = true
  7740. //            );
  7741. //            $em = $this->getDoctrine()->getManager();
  7742. //        } else {
  7743. //            $currAppId = $honeybeeAppId;
  7744. //            $dataToConnectAgain = System::changeDoctrineManagerByAppId(
  7745. //                $this->getDoctrine()->getManager('company_group'),
  7746. //                $gocEnabled,
  7747. //                $currAppId
  7748. //            );
  7749. //            if (!empty($dataToConnectAgain)) {
  7750. //                $connector = $this->container->get('application_connector');
  7751. //                $connector->resetConnection(
  7752. //                    'default',
  7753. //                    $dataToConnect['dbName'],
  7754. //                    $dataToConnect['dbUser'],
  7755. //                    $dataToConnect['dbPass'],
  7756. //                    $dataToConnect['dbHost'],
  7757. //                    $reset = true
  7758. //                );
  7759. //                $em = $this->getDoctrine()->getManager();
  7760. //            }
  7761. //
  7762. //        }
  7763.         $consultantDetails $em_goc->getRepository(EntityApplicantDetails::class)->find($id);
  7764.         $skill $em_goc->getRepository(EntitySkill::class)->findAll();
  7765.         $gender HumanResourceConstant::$sex;
  7766.         $blood HumanResourceConstant::$BloodGroup;
  7767.         $consultantLevel HumanResourceConstant::$consultantLevel;
  7768.         $companyId $this->getLoggedUserCompanyId($request);
  7769.         $designation $em->getRepository("ApplicationBundle:SysDepartmentPosition")->findAll();
  7770.         $departments $em->getRepository("ApplicationBundle:SysDepartment")->findAll();
  7771.         $companyData Company::getCompanyData($em$companyId);
  7772.         $currDate = new \DateTime();
  7773.         if ($request->isMethod('POST')) {
  7774.             //for consultant only
  7775.             $convertToConsultant HumanResource::convertToConsultant($em_goc$em$id$option$request->request);
  7776.             if ($request->request->get('confirmStatus'0) == 1) {
  7777.                 $bodyTemplate 'ApplicationBundle:email/templates:consultantApprovalEmail.html.twig';
  7778.                 $contractLetterHtml '';
  7779.                 $bodyData = array(
  7780.                     'name' => $consultantDetails->getFirstname() . ' ' $consultantDetails->getLastname(),
  7781.                     'companyData' => $companyData,
  7782.                     'contractLetterHtml' => $contractLetterHtml,
  7783.                     'commentText' => $request->request->get('commentText'),
  7784.                 );
  7785.                 $new_mail $this->get('mail_module');
  7786.                 $new_mail->sendMyMail(array(
  7787.                     'senderHash' => '_CUSTOM_',
  7788.                     'encryptionMethod' => 'ssl',
  7789.                     'userName' => 'management@buddybee.eu',
  7790.                     'fromAddress' => 'management@buddybee.eu',
  7791.                     'password' => 'Eco@0112',
  7792.                     'smtpServer' => 'smtp.hostinger.com',
  7793.                     'smtpPort' => '465',
  7794.                     'forwardToMailAddress' => $consultantDetails->getEmail(),
  7795.                     'subject' => 'Consultant Contract Letter Of ' $consultantDetails->getFirstName(),
  7796.                     'fileName' => '',
  7797.                     //'attachments' => $attachments,
  7798.                     'toAddress' => $consultantDetails->getEmail(),
  7799.                     'mailTemplate' => $bodyTemplate,
  7800.                     'templateData' => $bodyData,
  7801.                     'embedCompanyImage' => 1,
  7802.                     'companyId' => $companyId,
  7803.                     'companyImagePath' => ""
  7804.                 ));
  7805.             }
  7806.             if ($request->request->get('confirmStatus'0) == 0) {
  7807.                 $bodyTemplate 'ApplicationBundle:email/templates:consultantRejectionEmail.html.twig';
  7808.                 $contractLetterHtml '';
  7809.                 $bodyData = array(
  7810.                     'name' => $consultantDetails->getFirstname() . ' ' $consultantDetails->getLastname(),
  7811.                     'companyData' => $companyData,
  7812.                     'contractLetterHtml' => $contractLetterHtml,
  7813.                     'commentText' => $request->request->get('commentText'),
  7814.                 );
  7815.                 $new_mail $this->get('mail_module');
  7816.                 $new_mail->sendMyMail(array(
  7817.                     'senderHash' => '_CUSTOM_',
  7818.                     'encryptionMethod' => 'ssl',
  7819.                     'userName' => 'management@buddybee.eu',
  7820.                     'fromAddress' => 'management@buddybee.eu',
  7821.                     'password' => 'Eco@0112',
  7822.                     'smtpServer' => 'smtp.hostinger.com',
  7823.                     'smtpPort' => '465',
  7824.                     'forwardToMailAddress' => $consultantDetails->getEmail(),
  7825.                     'subject' => 'Rejection Letter Of ' $consultantDetails->getFirstName(),
  7826.                     'fileName' => '',
  7827.                     //'attachments' => $attachments,
  7828.                     'toAddress' => $consultantDetails->getEmail(),
  7829.                     'mailTemplate' => $bodyTemplate,
  7830.                     'templateData' => $bodyData,
  7831.                     'embedCompanyImage' => 1,
  7832.                     'companyId' => $companyId,
  7833.                     'companyImagePath' => ""
  7834.                 ));
  7835.             }
  7836.         }
  7837.         $docList MiscActions::GetDocumentDataForBuddybeeConsultantApply($em_goc,
  7838.             $id,
  7839.             $consultantDetails->getCurrentCountryId()
  7840.         );
  7841.         return $this->render('ApplicationBundle:pages/human_resource/views:viewConsultantDetails.html.twig', array(
  7842.             'page_title' => 'Consultant Details',
  7843.             'applicantId' => $id,
  7844.             'consultantDetails' => $consultantDetails,
  7845.             'education' => json_decode($consultantDetails->getEducationData(), true),
  7846.             'workExperience' => json_decode($consultantDetails->getWorkExperienceData(), true),
  7847.             'certificate' => json_decode($consultantDetails->getCertificateData(), true),
  7848.             'gender' => $gender,
  7849.             'blood' => $blood,
  7850.             'skill' => $skill,
  7851.             'docList' => $docList,
  7852.             'countryId' => $consultantDetails->getCurrentCountryId(),
  7853.             'consultantLevel' => $consultantLevel,
  7854.             'designation' => $designation,
  7855.             'department' => $departments
  7856.         ));
  7857.     }
  7858.     public function ApplicableEmployeSettingsAction()
  7859.     {
  7860.         $em $this->getDoctrine()->getManager();
  7861.         $employeeIds $em->getRepository(Employee::class)->findAll();
  7862.         return $this->render('ApplicationBundle:pages/human_resource/input_forms:applicable_employee_settings.html.twig', array(
  7863.             'page_title' => 'Applicable Employee Settings',
  7864.             'employeeIds' => $employeeIds
  7865.         ));
  7866.     }
  7867.     public function GetApplicableSettingsForSingleEmployeeAction($id)
  7868.     {
  7869.         $em $this->getDoctrine()->getManager();
  7870.         $bankLists $em->getRepository(WorkHourPolicy::class)->findAll();
  7871.         if (json_decode($bankLists->getEmployeeIds()) == $id) {
  7872.             return new JsonResponse(
  7873.                 array(
  7874.                     'success' => true,
  7875.                     'msg' => 'employee found'
  7876.                 )
  7877.             );
  7878.         } else {
  7879.             return new JsonResponse(
  7880.                 array(
  7881.                     'success' => true,
  7882.                     'msg' => 'employee not found'
  7883.                 )
  7884.             );
  7885.         }
  7886.     }
  7887. //    public function  getEmployeeDataAction(){
  7888. //        $em = $this->getDoctrine()->getManager();
  7889. //        $emplyeeDetails =  $em->getRepository('ApplicationBundle:EmployeeDeatils')->findAll();
  7890. //        $days = HumanResourceConstant::$days;
  7891. //        $holidays = ;
  7892. //        $workHourPolicies = ;
  7893. //
  7894. //    }
  7895.     public function meetingSchedulingForTabAction()
  7896.     {
  7897.         $em $this->getDoctrine()->getManager();
  7898.         $date date('Y-m-d');
  7899.         $month date('m');
  7900.         $year date('Y');
  7901.         $monthName date("F"mktime(000$month));
  7902.         $totalDayOfMonth cal_days_in_month(CAL_GREGORIAN$month$year);
  7903.         $fromdt date('Y-m-01 'strtotime("First Day Of  $monthName $year"));
  7904. //        echo "Start Date : $fromdt" . "<br>";
  7905.         $todt date('Y-m-d 'strtotime("Last Day of $monthName $year"));
  7906. //        echo "End Date : $todt" . "<br>";
  7907.         $num_friday '';
  7908.         for ($i 0$i < ((strtotime($todt) - strtotime($fromdt)) / 86400); $i++) {
  7909.             if (date('l'strtotime($fromdt) + ($i 86400)) == 'Friday') {
  7910.                 $num_friday++;
  7911.             }
  7912.         }
  7913.         $num_saturday '';
  7914.         for ($i 0$i < ((strtotime($todt) - strtotime($fromdt)) / 86400); $i++) {
  7915.             if (date('l'strtotime($fromdt) + ($i 86400)) == 'Saturday') {
  7916.                 $num_saturday++;
  7917.             }
  7918.         }
  7919.         $totalWeekends $num_saturday $num_friday;
  7920.         $totalCompanyWorkingDay $totalDayOfMonth $totalWeekends;
  7921. //        $attendanceData=$em->getRepository('ApplicationBundle:EmployeeAttendanceLog')->findOneBy(
  7922. //            array(
  7923. //                'employeeId' => 3
  7924. //            )
  7925. //        );
  7926.         $DateRange = [];
  7927.         $holidayDates $em->getRepository('ApplicationBundle:HolidayCalendarDates')->findAll();
  7928.         foreach ($holidayDates as $holiday) {
  7929.             $holidaayData = array(
  7930.                 'startDate' => $holiday->getStartDate(),
  7931.                 'endDate' => $holiday->getEndDate(),
  7932.             );
  7933.             $DateRange $holidaayData;
  7934.         }
  7935.         $employeeDataDetail = [];
  7936.         $employeeDetail $em->getRepository('ApplicationBundle:EmployeeDetails')->findOneBy(
  7937.             array(
  7938.                 'id' => 3
  7939.             )
  7940.         );
  7941. //        foreach($employeeDetail as $employee){
  7942.         $employeeData = array(
  7943.             'firstName' => $employeeDetail->getFirstname(),
  7944.             'basic' => $employeeDetail->getEar1(),
  7945.             'dearness' => $employeeDetail->getEar2(),
  7946.             'houseRent' => $employeeDetail->getEar3(),
  7947.             'medical' => $employeeDetail->getEar4(),
  7948.             'leaveTravel' => $employeeDetail->getEar5(),
  7949.             'childEducation' => $employeeDetail->getEar6(),
  7950.             'totalEarning' => $employeeDetail->getEart(),
  7951.         );
  7952.         $employeeDataDetail $employeeData;
  7953. //        }
  7954.         $attendanceData $em->getRepository(EmployeeAttendanceLog::class);
  7955. //        $employeeId = $attendanceData->getEmployeeId();
  7956. //        $countId = count($employeeId);
  7957.         $totalPresent $attendanceData->createQueryBuilder('a')
  7958.             // Filter by some parameter if you want
  7959.             ->where('a.employeeId = 3')
  7960.             ->andWhere('a.isPresent = 1')
  7961.             ->select('a.isPresent')
  7962.             ->getQuery()
  7963.             ->getResult();
  7964. //        $countAt = 0;
  7965.         $count count($totalPresent);
  7966. //        $count = $countAt+$count;
  7967.         //get holiday
  7968.         $holidayStartDate $DateRange['startDate']->format('Y-m-d');
  7969.         $holidayEndDate $DateRange['endDate']->format('Y-m-d');
  7970.         $dates HumanResource::getBetweenDates($holidayStartDate$holidayEndDate);
  7971.         $dateCount count($dates);
  7972.         $totalOffDay $totalWeekends $dateCount;
  7973.         $totalCompanyWorkingDay $totalDayOfMonth $totalOffDay;
  7974.         $totalAbsent $totalCompanyWorkingDay $count;
  7975. //        foreach($dates as $compDate ){
  7976. //
  7977. //
  7978. //
  7979. //            if($date == $compDate){
  7980. //                echo $date;
  7981. //                echo $compDate;
  7982. //                echo "holiday" ;
  7983. //
  7984. //            }
  7985. //            else{
  7986. //                echo "no holiday" ;
  7987. //            }
  7988. //        }
  7989.         $twigData HumanResource::twigDataForWorkHourPolicy($em);
  7990.         return $this->render('ApplicationBundle:pages/human_resource/list:meeting_schedule_list_for_tab.html.twig', array(
  7991.             'page_title' => 'Meeting Schedule List',
  7992.             'date' => $date,
  7993.             'totalWeekends' => $totalWeekends,
  7994.             'totalCompanyWorkingDay' => $totalCompanyWorkingDay,
  7995. //            'attendanceData' => $attendanceData,
  7996. //            'employeeId' => $employeeId,
  7997.             'count' => $count,
  7998.             'totalAbsent' => $totalAbsent,
  7999.             'employeeDataDetail' => $employeeDataDetail,
  8000.             'holiday' => $DateRange,
  8001.             'holidayStartDate' => $holidayStartDate,
  8002.             'holidayEndDate' => $holidayEndDate,
  8003.             'holidayCount' => $dateCount,
  8004.             'totalOffDay' => $totalOffDay,
  8005.             'employeeIds' => $twigData['employeeIds'],
  8006.         ));
  8007.     }
  8008.     public function getEmployeeDataForDisburseAction($id)
  8009.     {
  8010.         $em $this->getDoctrine()->getManager();
  8011.         $employeeDetail $em->getRepository('ApplicationBundle:EmployeeDetails')->find($id);
  8012.         return new JsonResponse(
  8013.             array(
  8014.                 'success' => true,
  8015.                 'firstName' => $employeeDetail->getFirstName(),
  8016.             )
  8017.         );
  8018.     }
  8019.     public function BulkAttendanceAction(Request $request)
  8020.     {
  8021.         $em $this->getDoctrine()->getManager();
  8022.         $companyId $this->getLoggedUserCompanyId($request);
  8023.         if ($request->isMethod('POST')) {
  8024.             $attendance = [];
  8025.             foreach ($request->request->get('date') as $key => $val) {
  8026.                 $loginId $request->getSession()->get(UserConstants::USER_LOGIN_ID);
  8027.                 $bulkAttendance null;
  8028.                 if ($request->request->get('attId')[$key] != 0)
  8029.                     $bulkAttendance $em->getRepository('ApplicationBundle:EmployeeAttendance')->findOneBy(array(
  8030.                         'id' => $request->request->get('attId')[$key],
  8031.                     ));
  8032.                 if (!$bulkAttendance)
  8033.                     $bulkAttendance = new EmployeeAttendance;
  8034.                 $theDate = new \DateTime($request->request->get('date')[$key]);
  8035.                 $bulkAttendance->setEmployeeId($request->request->get('employeeId'));
  8036.                 $bulkAttendance->setDate($theDate);
  8037.                 $bulkAttendance->setEntry(
  8038.                     ($request->request->get('startTimeTs')[$key] == '' ||
  8039.                         $request->request->get('startTimeTs')[$key] == 'NaN' ||
  8040.                         $request->request->get('startTimeTs')[$key] == 0) ? null :
  8041.                         new \DateTime('@' $request->request->get('startTimeTs')[$key])
  8042.                 );
  8043.                 $bulkAttendance->setLastOut(($request->request->get('endTimeTs')[$key] == '' ||
  8044.                     $request->request->get('endTimeTs')[$key] == 'NaN' ||
  8045.                     $request->request->get('endTimeTs')[$key] == 0) ? null :
  8046.                     new \DateTime('@' $request->request->get('endTimeTs')[$key]));
  8047.                 $bulkAttendance->setData(json_encode(
  8048.                     array(
  8049.                         "in" => json_decode($request->request->get('entryDataIn')[$key], true),
  8050.                         "out" => json_decode($request->request->get('entryDataOut')[$key], true)
  8051.                     )
  8052.                 ));
  8053. //                $bulkAttendance->setLastStartTime(new \DateTime($request->request->get('startDate')));
  8054. //                $bulkAttendance->setIsPresent(1);
  8055.                 $bulkAttendance->setLastStartTimeTs($request->request->get('startTimeTs')[$key]);
  8056.                 $bulkAttendance->setLastEndTimeTs($request->request->get('endTimeTs')[$key]);
  8057. //                $bulkAttendance->setTotalWorkHour($request->request->get('totalWorkHour')[$key]);
  8058.                 $em->persist($bulkAttendance);
  8059.                 $em->flush();
  8060.                 $bulkAttendanceLog $em->getRepository('ApplicationBundle:EmployeeAttendanceLog')->findOneBy(array(
  8061.                     'attendance_id' => $bulkAttendance->getId(),
  8062.                 ));
  8063.                 if (!$bulkAttendanceLog)
  8064.                     $bulkAttendanceLog = new EmployeeAttendanceLog;
  8065.                 $bulkAttendanceLog->setAttendanceId($bulkAttendance->getId());
  8066.                 $bulkAttendanceLog->setEmployeeId($request->request->get('employeeId'));
  8067.                 $bulkAttendanceLog->setLastStartTime(
  8068.                     ($request->request->get('startTimeTs')[$key] == '' ||
  8069.                         $request->request->get('startTimeTs')[$key] == 'NaN' ||
  8070.                         $request->request->get('startTimeTs')[$key] == 0) ? null :
  8071.                         new \DateTime('@' $request->request->get('startTimeTs')[$key])
  8072.                 );
  8073.                 $bulkAttendanceLog->setLastEndTime(($request->request->get('endTimeTs')[$key] == '' ||
  8074.                     $request->request->get('endTimeTs')[$key] == 'NaN' ||
  8075.                     $request->request->get('endTimeTs')[$key] == 0) ? null :
  8076.                     new \DateTime('@' $request->request->get('endTimeTs')[$key]));
  8077. //                $bulkAttendance->setLastStartTime(new \DateTime($request->request->get('startDate')));
  8078.                 $bulkAttendanceLog->setIsPresent(1);
  8079.                 $bulkAttendanceLog->setLastStartTimeTs($request->request->get('startTimeTs')[$key]);
  8080.                 $bulkAttendanceLog->setLastEndTimeTs($request->request->get('endTimeTs')[$key]);
  8081.                 $bulkAttendanceLog->setTotalWorkHour($request->request->get('totalWorkHour')[$key]);
  8082. //                $bulkAttendanceLog->setPositionArray(json_encode($request->request->get('locations')[$key]));
  8083.                 $em->persist($bulkAttendanceLog);
  8084.                 $em->flush();
  8085.             }
  8086.         }
  8087.         $startDate $request->query->get('start_date''');
  8088.         $endDate $request->query->get('end_date''');
  8089.         $employeeId $request->query->get('employee_id'0);
  8090.         $existingData = [];
  8091.         $startDateTs 0;
  8092.         $endDateTs 0;
  8093.         $returnData = array(
  8094.             'page_title' => 'Bulk Attendance',
  8095.             'existingData' => $existingData,
  8096.             'startDateTs' => $startDateTs,
  8097.             'endDateTs' => $endDateTs,
  8098.         );
  8099.         if ($request->query->has('returnJson')) {
  8100.             if ($startDate != '' && $endDate != '' && $employeeId != 0) {
  8101.                 $startDateDt = new \DateTime($startDate);
  8102.                 $endDateDt = new \DateTime($endDate);
  8103.                 $startDateTs $startDateDt->format('U');
  8104.                 $endDateTs $endDateDt->format('U');
  8105.                 $attendanceQuery $em->getRepository('ApplicationBundle:EmployeeAttendance')
  8106.                     ->createQueryBuilder('p')
  8107.                     ->where("p.employeeId = " $employeeId)
  8108. //                ->andWhere("p.date => '" . ($startDateDt->format('Y-m-d'))."'")
  8109.                     ->andWhere("p.date <= :last")
  8110.                     ->andWhere("p.date >= :start")
  8111.                     ->setParameter('start'$startDateDt)
  8112.                     ->setParameter('last'$endDateDt);
  8113.                 $attendanceResults $attendanceQuery->getQuery()->getResult();
  8114.                 foreach ($attendanceResults as $att) {
  8115.                     $entryDateTime null;
  8116.                     $outDateTime null;
  8117.                     if ($att->getEntry()) $entryDateTime = new \DateTime($att->getDate()->format('Y-m-d') . ' ' $att->getEntry()->format('H:i:00 +0000'));
  8118.                     if ($att->getLastOut()) $outDateTime = new \DateTime($att->getDate()->format('Y-m-d') . ' ' $att->getLastOut()->format('H:i:00 +0000'));
  8119.                     $attData = array(
  8120.                         'id' => $att->getId(),
  8121.                         'date_str' => $att->getDate()->format('Y-m-d'),
  8122.                         'date_str_full' => $att->getDate()->format('Y-m-d H:i:s'),
  8123.                         'in_time_full' => $entryDateTime $entryDateTime->format(DATE_RFC2822) : '',
  8124.                         'date_ts' => $att->getDate()->format('U'),
  8125.                         'in_time' => $entryDateTime $entryDateTime->format('H:i:s') : '',
  8126.                         'in_time_ts' => $entryDateTime $entryDateTime->format('U') : 0,
  8127.                         'last_out_time' => $outDateTime $outDateTime->format('H:i:s') : '',
  8128.                         'last_out_time_ts' => $outDateTime $outDateTime->format('U') : '',
  8129.                     );
  8130.                     $locations = [];
  8131.                     $locList = [];
  8132.                     $logHere $em->getRepository('ApplicationBundle:EmployeeAttendanceLog')->findOneBy(array(
  8133.                         'attendance_id' => $att->getId(),
  8134.                     ));
  8135.                     if ($logHere)
  8136.                         $locList json_decode($logHere->getPositionArray(), true);
  8137.                     if ($locList == null)
  8138.                         $locList = [];
  8139.                     $entry_data json_decode($att->getData(), true);
  8140.                     if ($entry_data == null$entry_data = [];
  8141.                     $lastLat 0;
  8142.                     $lastLng 0;
  8143.                     foreach ($locList as $lg) {
  8144.                         $dist 0;
  8145.                         if (isset($lg['lat'])) {
  8146.                             if ($lastLat == 0) {
  8147.                                 $lastLat $lg['lat'];
  8148.                                 $lastLng $lg['lng'];
  8149.                             }
  8150.                             $theta $lastLng $lg['lng'];
  8151.                             $dist sin(deg2rad($lastLat)) * sin(deg2rad($lg['lat'])) + cos(deg2rad($lastLat)) * cos(deg2rad($lg['lat'])) * cos(deg2rad($theta));
  8152.                             $dist acos($dist);
  8153.                             $dist rad2deg($dist);
  8154.                             $miles $dist 60 1.1515;
  8155.                             $dist $miles 1609.344;
  8156.                             if (abs($dist) > 1000) {
  8157.                                 $locations[] = array(
  8158.                                     'ts' => $lg['ts'],
  8159.                                     'lat' => $lg['lat'],
  8160.                                     'lng' => $lg['lng'],
  8161.                                 );
  8162.                                 $lastLat $lg['lat'];
  8163.                                 $lastLng $lg['lng'];
  8164.                             }
  8165.                         }
  8166.                     }
  8167.                     $attData['locations'] = $locations;
  8168.                     $attData['entryData'] = $entry_data;
  8169.                     $existingData[$att->getDate()->format('U')] = $attData;
  8170.                 }
  8171.             }
  8172.             $returnData = array(
  8173.                 'page_title' => 'Bulk Attendance',
  8174.                 'existingData' => $existingData,
  8175.                 'startDateTs' => $startDateTs,
  8176.                 'endDateTs' => $endDateTs,
  8177.             );
  8178.             return new JsonResponse($returnData);
  8179.         } else
  8180.             return $this->render('ApplicationBundle:pages/human_resource/attendance:bulk_attendance.html.twig'$returnData);
  8181.     }
  8182.     public function CreateAttendanceAmendmentAction(Request $request$id 0)
  8183.     {
  8184.         $em $this->getDoctrine()->getManager();
  8185.         $companyId $this->getLoggedUserCompanyId($request);
  8186.         $extDocData = [];
  8187.         if ($request->isMethod('POST')) {
  8188.             $em $this->getDoctrine()->getManager();
  8189.             $entity_id array_flip(GeneralConstant::$Entity_list)['AttendanceAmendment']; //change
  8190.             $dochash $request->request->get('docHash'); //change
  8191.             $loginId $request->getSession()->get(UserConstants::USER_LOGIN_ID);
  8192.             $approveRole $request->request->get('approvalRole');
  8193.             $approveHash $request->request->get('approvalHash');
  8194.             if ($dochash == '') {
  8195.                 $numberHash MiscActions::GetNumberHash($em'ATAM'$request->request->get('prefix_hash'$request->request->get('employeeId'0)), $request->request->get('assoc_hash'0), ''1);
  8196.                 $dochash 'ATAM' '/' $request->request->get('prefix_hash'$request->request->get('employeeId'0)) . '/' $request->request->get('assoc_hash'0) . '/' $numberHash;
  8197.             } else
  8198.                 $numberHash $request->request->get('number_hash');
  8199.             if (!DocValidation::isInsertable($em$entity_id$dochash,
  8200.                 $loginId$approveRole$approveHash$id)
  8201.             ) {
  8202.                 if ($request->request->has('returnJson')) {
  8203.                     return new JsonResponse(array(
  8204.                         'success' => false,
  8205.                         'documentHash' => 0,
  8206.                         'documentId' => 0,
  8207.                     ));
  8208.                 } else
  8209.                     $this->addFlash(
  8210.                         'error',
  8211.                         'Sorry Could not insert Data.'
  8212.                     );
  8213.             } else {
  8214.                 $funcname 'AttendanceAmendment';
  8215.                 $doc_id $id;
  8216.                 DeleteDocument::$funcname($em$doc_id0);
  8217.                 $attendanceAmendment = new AttendanceAmendment();
  8218.                 $attendanceAmendment->setDocumentHash($dochash);
  8219.                 $attendanceAmendment->setAttendanceAmendmentDate(new \DateTime($request->request->get('docDate''')));
  8220.                 $attendanceAmendment->setStartDate(new \DateTime($request->request->get('startDate''')));
  8221.                 $attendanceAmendment->setEndDate(new \DateTime($request->request->get('endDate''')));
  8222.                 $attendanceAmendment->setTypeHash('ATAM');
  8223.                 $attendanceAmendment->setPrefixHash($request->request->get('prefix_hash'0));
  8224.                 $attendanceAmendment->setAssocHash($request->request->get('assoc_hash'0));
  8225.                 $attendanceAmendment->setNumberHash($numberHash);
  8226.                 $attendanceAmendment->setCreatedLoginId($request->getSession()->get(UserConstants::USER_LOGIN_ID));
  8227.                 $attendanceAmendment->setApproved(array_flip(GeneralConstant::$approvalStatus)['pending']);
  8228.                 $attendanceAmendment->setAutoCreated($request->request->get('fullApprove'0));
  8229.                 $attendanceAmendment->setEmployeeId($request->request->get('forcedEmployeeId'$request->request->get('employeeId'0)));
  8230. //                $attendanceAmendment->setAutocreated(0);
  8231.                 if ($request->request->has('dataArrayJson')) {
  8232.                     $attendanceAmendment->setData($request->request->get('dataArrayJson''[]'));
  8233.                 } else {
  8234.                     $arr = [
  8235.                     ];
  8236.                     //dump($arr);
  8237.                     foreach ($request->request->get('date', []) as $key => $val) {
  8238.                         if ($request->request->get('isChanged')[$key] == 1) {
  8239.                             $dt = array(
  8240.                                 'enabled' => 1,
  8241.                                 'attId' => $request->request->get('attId')[$key],
  8242.                                 'note' => $request->request->get('note')[$key],
  8243.                                 'startTimeTs' => $request->request->get('startTimeTs')[$key],
  8244.                                 'endTimeTs' => $request->request->get('endTimeTs')[$key],
  8245.                                 'totalWorkHour' => $request->request->get('totalWorkHour')[$key],
  8246.                                 'entryDataIn' => json_decode($request->request->get('entryDataIn')[$key], true),
  8247.                                 'entryDataOut' => json_decode($request->request->get('entryDataOut')[$key], true),
  8248.                             );
  8249.                             $arr[$val] = $dt;
  8250.                         }
  8251.                     }
  8252.                     $attendanceAmendment->setData(json_encode($arr));
  8253.                 }
  8254.                 $em->persist($attendanceAmendment);
  8255.                 $em->flush();
  8256.                 $ID $attendanceAmendment->getAttendanceAmendmentId();
  8257.                 //now add Approval info
  8258.                 $loginId $request->getSession()->get(UserConstants::USER_LOGIN_ID);
  8259.                 $approveRole 1;  //created
  8260.                 $options = array(
  8261.                     'notification_enabled' => $this->container->getParameter('notification_enabled'),
  8262.                     'notification_server' => $this->container->getParameter('notification_server'),
  8263.                     'appId' => $request->getSession()->get(UserConstants::USER_APP_ID),
  8264.                     'url' => $this->generateUrl(
  8265.                         GeneralConstant::$Entity_list_details[array_flip(GeneralConstant::$Entity_list)['AttendanceAmendment']]
  8266.                         ['entity_view_route_path_name']
  8267.                     )
  8268.                 );
  8269.                 System::setApprovalInfo($this->getDoctrine()->getManager(), $options,
  8270.                     array_flip(GeneralConstant::$Entity_list)['AttendanceAmendment'],
  8271.                     $ID,
  8272.                     $request->getSession()->get(UserConstants::USER_LOGIN_ID)    //journal voucher
  8273.                 );
  8274.                 if ($request->request->get('fullApprove'0) == 1) {
  8275.                     DeleteDocument::AttendanceAmendment($em$ID);
  8276.                 } else {
  8277.                     System::createEditSignatureHash($this->getDoctrine()->getManager(), array_flip(GeneralConstant::$Entity_list)['AttendanceAmendment'], $ID,
  8278.                         $loginId,
  8279.                         $approveRole,
  8280.                         $request->request->get('approvalHash'));
  8281.                     $url $this->generateUrl(
  8282.                         'view_attendance_amendment'
  8283.                     );
  8284.                     if ($request->request->has('returnJson')) {
  8285.                         return new JsonResponse(array(
  8286.                             'success' => true,
  8287.                             'documentHash' => $dochash,
  8288.                             'documentId' => $ID,
  8289.                             'viewUrl' => $url "/" $ID,
  8290.                         ));
  8291.                     } else {
  8292.                         $this->addFlash(
  8293.                             'success',
  8294.                             'Attendance Amendment Note Added.'
  8295.                         );
  8296.                         return $this->redirect($url "/" $ID);
  8297.                     }
  8298.                 }
  8299.             }
  8300.         }
  8301.         if ($id == 0) {
  8302.         } else {
  8303.             $extDoc $em->getRepository('ApplicationBundle:AttendanceAmendment')->findOneBy(
  8304.                 array(
  8305.                     'salesOrderId' => $id///material
  8306.                 )
  8307.             );
  8308.             //now if its not editable, redirect to view
  8309.             if ($extDoc) {
  8310.                 if ($extDoc->getEditFlag() != 1) {
  8311.                     $url $this->generateUrl(
  8312.                         'view_attendance_amendment'
  8313.                     );
  8314.                     return $this->redirect($url "/" $id);
  8315.                 } else {
  8316.                     $extDocData $extDoc;
  8317.                 }
  8318.             } else {
  8319.             }
  8320.         }
  8321.         $startDate $request->query->get('start_date''');
  8322.         $endDate $request->query->get('end_date''');
  8323.         $employeeId $request->query->get('employee_id'0);
  8324.         $existingData = [];
  8325.         $startDateTs 0;
  8326.         $endDateTs 0;
  8327.         $returnData = array(
  8328.             'page_title' => 'Attendance Amendment',
  8329.             'existingData' => $existingData,
  8330.             'startDateTs' => $startDateTs,
  8331.             'extDocData' => $extDocData,
  8332.             'endDateTs' => $endDateTs,
  8333.         );
  8334.         if ($request->query->has('returnJson')) {
  8335.             if ($startDate != '' && $endDate != '' && $employeeId != 0) {
  8336.                 $startDateDt = new \DateTime($startDate);
  8337.                 $endDateDt = new \DateTime($endDate);
  8338.                 $startDateTs $startDateDt->format('U');
  8339.                 $endDateTs $endDateDt->format('U');
  8340.                 $attendanceQuery $em->getRepository('ApplicationBundle:EmployeeAttendance')
  8341.                     ->createQueryBuilder('p')
  8342.                     ->where("p.employeeId = " $employeeId)
  8343. //                ->andWhere("p.date => '" . ($startDateDt->format('Y-m-d'))."'")
  8344.                     ->andWhere("p.date <= :last")
  8345.                     ->andWhere("p.date >= :start")
  8346.                     ->setParameter('start'$startDateDt)
  8347.                     ->setParameter('last'$endDateDt);
  8348.                 $attendanceResults $attendanceQuery->getQuery()->getResult();
  8349.                 foreach ($attendanceResults as $att) {
  8350.                     $entryDateTime null;
  8351.                     $outDateTime null;
  8352.                     if ($att->getEntry()) $entryDateTime = new \DateTime($att->getDate()->format('Y-m-d') . ' ' $att->getEntry()->format('H:i:00 +0000'));
  8353.                     if ($att->getLastOut()) $outDateTime = new \DateTime($att->getDate()->format('Y-m-d') . ' ' $att->getLastOut()->format('H:i:00 +0000'));
  8354.                     $attData = array(
  8355.                         'id' => $att->getId(),
  8356.                         'date_str' => $att->getDate()->format('Y-m-d'),
  8357.                         'date_str_full' => $att->getDate()->format('Y-m-d H:i:s'),
  8358.                         'in_time_full' => $entryDateTime $entryDateTime->format(DATE_RFC2822) : '',
  8359.                         'date_ts' => $att->getDate()->format('U'),
  8360.                         'in_time' => $entryDateTime $entryDateTime->format('H:i:s') : '',
  8361.                         'in_time_ts' => $entryDateTime $entryDateTime->format('U') : 0,
  8362.                         'last_out_time' => $outDateTime $outDateTime->format('H:i:s') : '',
  8363.                         'last_out_time_ts' => $outDateTime $outDateTime->format('U') : '',
  8364.                     );
  8365.                     $locations = [];
  8366.                     $locList = [];
  8367.                     $logHere $em->getRepository('ApplicationBundle:EmployeeAttendanceLog')->findOneBy(array(
  8368.                         'attendance_id' => $att->getId(),
  8369.                     ));
  8370.                     if ($logHere)
  8371.                         $locList json_decode($logHere->getPositionArray(), true);
  8372.                     if ($locList == null)
  8373.                         $locList = [];
  8374.                     $entry_data json_decode($att->getData(), true);
  8375.                     if ($entry_data == null$entry_data = [];
  8376.                     $lastLat 0;
  8377.                     $lastLng 0;
  8378.                     foreach ($locList as $lg) {
  8379.                         $dist 0;
  8380.                         if (isset($lg['lat'])) {
  8381.                             if ($lastLat == 0) {
  8382.                                 $lastLat $lg['lat'];
  8383.                                 $lastLng $lg['lng'];
  8384.                             }
  8385.                             $theta $lastLng $lg['lng'];
  8386.                             $dist sin(deg2rad($lastLat)) * sin(deg2rad($lg['lat'])) + cos(deg2rad($lastLat)) * cos(deg2rad($lg['lat'])) * cos(deg2rad($theta));
  8387.                             $dist acos($dist);
  8388.                             $dist rad2deg($dist);
  8389.                             $miles $dist 60 1.1515;
  8390.                             $dist $miles 1609.344;
  8391.                             if (abs($dist) > 1000) {
  8392.                                 $locations[] = array(
  8393.                                     'ts' => $lg['ts'],
  8394.                                     'lat' => $lg['lat'],
  8395.                                     'lng' => $lg['lng'],
  8396.                                 );
  8397.                                 $lastLat $lg['lat'];
  8398.                                 $lastLng $lg['lng'];
  8399.                             }
  8400.                         }
  8401.                     }
  8402.                     $attData['locations'] = $locations;
  8403.                     $attData['entryData'] = $entry_data;
  8404.                     $existingData[$att->getDate()->format('U')] = $attData;
  8405.                 }
  8406.             }
  8407.             $returnData = array(
  8408.                 'page_title' => 'Attendance Amendment',
  8409.                 'existingData' => $existingData,
  8410.                 'startDateTs' => $startDateTs,
  8411.                 'extDocData' => $extDocData,
  8412.                 'endDateTs' => $endDateTs,
  8413.             );
  8414.             return new JsonResponse($returnData);
  8415.         } else
  8416.             return $this->render('ApplicationBundle:pages/human_resource/attendance:create_attendance_amendment.html.twig'$returnData);
  8417.     }
  8418.     public function AttendanceAmendmentListAction(Request $request)
  8419.     {
  8420.         $data = [];
  8421.         return $this->render('ApplicationBundle:pages/human_resource/list:attendance_amendment_list.html.twig',
  8422.             array(
  8423.                 'page_title' => 'Attendance Amendment List',
  8424.                 'data' => $data
  8425.             )
  8426.         );
  8427.     }
  8428.     public function ViewAttendanceAmendmentAction(Request $request$id)
  8429.     {
  8430.         $em $this->getDoctrine()->getManager();
  8431.         $dt HumanResource::GetAttendanceAmendmentDetails($em$id);
  8432.         return $this->render('ApplicationBundle:pages/human_resource/views:view_attendance_amendment.html.twig',
  8433.             array(
  8434.                 'page_title' => 'Attendance Amendment',
  8435.                 'data' => $dt,
  8436.                 'approval_data' => System::checkIfApprovalExists($emarray_flip(GeneralConstant::$Entity_list)['AttendanceAmendment'],
  8437.                     $id$request->getSession()->get(UserConstants::USER_LOGIN_ID)),
  8438.                 'document_log' => System::getDocumentLog($this->getDoctrine()->getManager(),
  8439.                     array_flip(GeneralConstant::$Entity_list)['AttendanceAmendment'],
  8440.                     $id,
  8441.                     $dt['created_by'],
  8442.                     $dt['edited_by'])
  8443.             )
  8444.         );
  8445.     }
  8446.     public function PrintAttendanceAmendmentAction(Request $request$id)
  8447.     {
  8448.         $em $this->getDoctrine()->getManager();
  8449.         $dt HumanResource::GetAttendanceAmendmentDetails($em$id);
  8450.         $company_data Company::getCompanyData($em1);
  8451.         $document_mark = array(
  8452.             'original' => '/images/Original-Stamp-PNG-Picture.png',
  8453.             'copy' => ''
  8454.         );
  8455.         if ($request->query->has('pdf') && $this->get('knp_snappy.pdf')) {
  8456.             $html $this->renderView('@Inventory/pages/print/print_stock_received_note.html.twig',
  8457.                 array(
  8458.                     //full array here
  8459.                     'pdf' => true,
  8460.                     'page_title' => 'Stock Received Note',
  8461.                     'export' => 'pdf,print',
  8462.                     'data' => $dt,
  8463.                     'approval_data' => System::checkIfApprovalExists($emarray_flip(GeneralConstant::$Entity_list)['AttendanceAmendment'],
  8464.                         $id$request->getSession()->get(UserConstants::USER_LOGIN_ID)),
  8465.                     'document_log' => System::getDocumentLog($this->getDoctrine()->getManager(),
  8466.                         array_flip(GeneralConstant::$Entity_list)['AttendanceAmendment'],
  8467.                         $id,
  8468.                         $dt['created_by'],
  8469.                         $dt['edited_by']),
  8470.                     'document_mark_image' => $document_mark['original'],
  8471.                     'company_name' => $company_data->getName(),
  8472.                     'company_data' => $company_data,
  8473.                     'company_address' => $company_data->getAddress(),
  8474.                     'company_image' => $company_data->getImage(),
  8475.                     'invoice_footer' => $company_data->getInvoiceFooter(),
  8476.                     'red' => 0
  8477.                 )
  8478.             );
  8479.             $pdf_response $this->get('knp_snappy.pdf')->getOutputFromHtml($html, array(
  8480. //                'orientation' => 'landscape',
  8481. //                'enable-javascript' => true,
  8482. //                'javascript-delay' => 1000,0
  8483.                 'no-stop-slow-scripts' => false,
  8484.                 'no-background' => false,
  8485.                 'lowquality' => false,
  8486.                 'encoding' => 'utf-8',
  8487. //            'images' => true,
  8488. //            'cookie' => array(),
  8489.                 'dpi' => 300,
  8490.                 'image-dpi' => 300,
  8491. //                'enable-external-links' => true,
  8492. //                'enable-internal-links' => true
  8493.             ));
  8494.             return new Response(
  8495.                 $pdf_response,
  8496.                 200,
  8497.                 array(
  8498.                     'Content-Type' => 'application/pdf',
  8499.                     'Content-Disposition' => 'attachment; filename="stock_received_note_' $id '.pdf"'
  8500.                 )
  8501.             );
  8502.         }
  8503.         return $this->render('ApplicationBundle:pages/human_resource/views:view_attendance_amendment.html.twig',
  8504.             array(
  8505.                 'page_title' => 'Attendance Amendment',
  8506.                 'data' => $dt,
  8507.                 'approval_data' => System::checkIfApprovalExists($emarray_flip(GeneralConstant::$Entity_list)['AttendanceAmendment'],
  8508.                     $id$request->getSession()->get(UserConstants::USER_LOGIN_ID)),
  8509.                 'document_log' => System::getDocumentLog($this->getDoctrine()->getManager(),
  8510.                     array_flip(GeneralConstant::$Entity_list)['AttendanceAmendment'],
  8511.                     $id,
  8512.                     $dt['created_by'],
  8513.                     $dt['edited_by'])
  8514.             )
  8515.         );
  8516.     }
  8517.     public function createRoomAction(Request $request)
  8518.     {
  8519.         $em $this->getDoctrine()->getManager();
  8520.         $companyId $this->getLoggedUserCompanyId($request);
  8521.         if ($request->isMethod('POST')) {
  8522.             $loginId $request->getSession()->get(UserConstants::USER_LOGIN_ID);
  8523.             $room = new Room;
  8524.             $room->setRoomNo($request->request->get('RoomNo'));
  8525.             //$room->setRoomName($request->request->get('RoomName'));
  8526.             $room->setBuilding($request->request->get('buildingName'));
  8527.             $room->setFloor($request->request->get('floor'));
  8528.             $room->setCapacity($request->request->get('capacity'));
  8529.             $room->setCreatedLoginId($request->getSession()->get(UserConstants::USER_LOGIN_ID));
  8530.             $em->persist($room);
  8531.             $em->flush();
  8532.         }
  8533.         return $this->render('ApplicationBundle:pages/human_resource/input_forms:create_room.html.twig', array(
  8534.             'page_title' => 'Add Room',
  8535.         ));
  8536.     }
  8537.     public function ExpenseTypeAction()
  8538.     {
  8539.         $expenseType HumanResourceConstant::$employeeExpenseAllowanceTypes;
  8540.         $expenseTypeArray = [];
  8541.         foreach ($expenseType as $k => $dt) {
  8542.             $dt['id'] = $k;
  8543.             $newSegs = [];
  8544.             foreach ($dt['segregations'] as $l => $s) {
  8545.                 $newOptions = [];
  8546.                 foreach ($s['options'] as $l2 => $s2) {
  8547.                     $s3 = array(
  8548.                         'value' => $l2,
  8549.                         'text' => $s2,
  8550.                     );
  8551.                     $newOptions[] = $s3;
  8552.                 }
  8553.                 $s['options'] = $newOptions;
  8554.                 if (is_string($s['defaultVal'])) $s['defaultVal'] = [$s['defaultVal']];
  8555.                 $newSegs[] = $s;
  8556.             }
  8557.             $dt['segregations'] = $newSegs;
  8558.             $expenseTypeArray[] = $dt;
  8559.         }
  8560.         return new JsonResponse(
  8561.             array(
  8562.                 'success' => true,
  8563.                 'expenseType' => $expenseType,
  8564.                 'expenseTypeArray' => $expenseTypeArray,
  8565.             )
  8566.         );
  8567.     }
  8568.     public function DemoDataTableAction()
  8569.     {
  8570.         return $this->render('ApplicationBundle:pages/human_resource/list:demo_data_table.html.twig', array(
  8571.             'page_title' => 'Add Room',
  8572.         ));
  8573.     }
  8574.     public function workEnrtyAction(Request $request)
  8575.     {
  8576. //        $em = $this->getDoctrine()->getManager();
  8577. //        $companyId = $this->getLoggedUserCompanyId($request);
  8578. //        if ($request->isMethod('POST')) {
  8579. //            $loginId = $request->getSession()->get(UserConstants::USER_LOGIN_ID);
  8580. //            $labour = new Labour();
  8581. //            $labour->setLabourName($request->request->get('labourName'));
  8582. //            $labour->setNidNumber($request->request->get('nidNumber'));
  8583. //            $em->persist($labour);
  8584. //            $em->flush();
  8585. //            $this->addFlash(
  8586. //                'success',
  8587. //                'Labour Added'
  8588. //            );
  8589. //        }
  8590.         return $this->render('ApplicationBundle:pages/human_resource/input_forms:work_entry.html.twig', array(
  8591.             'page_title' => 'Work Entry',
  8592.         ));
  8593.     }
  8594.     public function ViewContractLetterAction(Request $request$id)
  8595.     {
  8596.         $em $this->getDoctrine()->getManager();
  8597.         $employeeDetail $em->getRepository('ApplicationBundle:EmployeeDetails')->find($id);
  8598. //        $employeeData = [];
  8599. //        foreach ($employeeDetails as $employeeDetail) {
  8600. //            $data = array(
  8601. //                'firstName' => $employeeDetail->getNid(),
  8602. //
  8603. //
  8604. //
  8605. //            );
  8606. //
  8607. //
  8608. //            $employeeData[] = $data;
  8609. //        }
  8610.         return $this->render('ApplicationBundle:pages/human_resource/views:viewContractLetter.html.twig', array(
  8611.             'page_title' => 'Contract Letter',
  8612.             'employeeDetail' => $employeeDetail
  8613.         ));
  8614.     }
  8615.     public function getAttendanceReportForEmployeeAction(Request $request)
  8616.     {
  8617.         $em $this->getDoctrine()->getManager();
  8618.         $session $request->getSession();
  8619.         $fromDateRow = (new \DateTime($request->get('start_date''')));
  8620. //        $fromDate = $fromDateRow->format("M d, Y");
  8621.         $toDateRow = (new \DateTime($request->get('end_date'$fromDateRow) . ' 23:59:59'));
  8622. //        $toDate = $toDateRow->format("M d, Y");
  8623. //        $startDate = "2025-02-13";
  8624. //        $endDate = "2025-02-16";
  8625.         $userId $session->get(UserConstants::USER_ID);
  8626.         $attendanceDetails $em->getRepository('ApplicationBundle:EmployeeAttendance')->createQueryBuilder('A')
  8627. //            ->select('A.createdAt','A.data')
  8628.             ->where('A.sysId = :userId')
  8629.             ->andWhere('A.createdAt >=  :startDate')
  8630.             ->andWhere('A.createdAt <=  :endDate')
  8631.             ->setParameter('userId'$userId)
  8632.             ->setParameter('startDate'$fromDateRow)
  8633.             ->setParameter('endDate'$toDateRow)
  8634.             ->getQuery()
  8635.             ->getResult();
  8636.         $attendance = [];
  8637.         $dt = [];
  8638.         foreach ($attendanceDetails as $data) {
  8639.             $in_out_data json_decode($data->getData(), true);
  8640.             $new_in_data = [];
  8641.             $elapsed_data = [];
  8642.             $new_out_data = [];
  8643.             if ($in_out_data == null$in_out_data = [];
  8644.             if (isset($in_out_data['in'])) {
  8645.                 foreach ($in_out_data['in'] as $ind => $g) {
  8646.                     if (!isset($elapsed_data[$ind])) {
  8647.                         $elapsed_data[$ind] = 0;
  8648.                     }
  8649.                     $the_time = new \DateTime($data->getDate()->format('Y-m-d ') . $g ' +0000');
  8650.                     $new_in_data[] = $the_time->format('U');
  8651.                 }
  8652.             }
  8653.             if (isset($in_out_data['out'])) {
  8654.                 foreach ($in_out_data['out'] as $ind => $g) {
  8655.                     if (!isset($elapsed_data[$ind])) {
  8656.                         $elapsed_data[$ind] = 0;
  8657.                     }
  8658.                     $the_time = new \DateTime($data->getDate()->format('Y-m-d ') . $g ' +0000');
  8659.                     $new_out_data[] = $the_time->format('U');
  8660.                     if (isset($new_in_data[$ind])) {
  8661.                         $elapsed_data[$ind] = $new_out_data[$ind] - $new_in_data[$ind];
  8662.                     }
  8663.                 }
  8664.             }
  8665.             $list = array(
  8666.                 'date' => $data->getDate()->format('F d Y'),
  8667.                 'attendanceData' => [
  8668.                     'in' => $new_in_data,
  8669.                     'out' => $new_out_data,
  8670.                     'elapsedSec' => $elapsed_data,
  8671.                 ]
  8672.             );
  8673.             $dt[] = $list;
  8674.         }
  8675.         $count count($attendance);
  8676. //        for ($i=0;$i < $count; $i++){
  8677. //            $dt[] = $attendance[$i]['date'];
  8678. //            $dt[] = ($attendance[$i]['attendanceData']);
  8679. //        }
  8680. ////        $decodeData = json_decode($dt, true);
  8681. //
  8682. //        $work_hours = [];
  8683. //
  8684. //        foreach ($dt as $index => $entry) {
  8685. //            $in_times = $entry['in'];
  8686. //            $out_times = $entry['out'];
  8687. //
  8688. //
  8689. //            $count = min(count($in_times), count($out_times));
  8690. //
  8691. //            for ($i = 0; $i < $count; $i++) {
  8692. //                $time_in = new DateTime($in_times[$i]);
  8693. //                $time_out = new DateTime($out_times[$i]);
  8694. //
  8695. //
  8696. //                $interval = $time_in->diff($time_out);
  8697. //                $total_hours = $interval->format('%h');
  8698. //                $total_minutes = $interval->format('%i');
  8699. //
  8700. //
  8701. //                $work_hours[] = [
  8702. ////                    "set" => $index + 1,
  8703. //                    "in" => $in_times[$i],
  8704. //                    "out" => $out_times[$i],
  8705. //                    "worked" => "$total_hours hours, $total_minutes minutes"
  8706. //                ];
  8707. //            }
  8708. //        }
  8709. //
  8710. ////        foreach ($work_hours as $work) {
  8711. ////           return new  JsonResponse(
  8712. ////               array(
  8713. ////                   'in'=>$work['in'],
  8714. ////                   'out' => $work['out'],
  8715. ////                   'hour' => $work['worked']
  8716. ////               )
  8717. ////           ) ;
  8718. //////            echo "Set {$work['set']} - IN: {$work['in']} - OUT: {$work['out']} => Worked: {$work['worked']}\n";
  8719. ////        }
  8720.         return new JsonResponse($dt);
  8721.     }
  8722.     public function getTotalWorkHourAction(Request $request)
  8723.     {
  8724.         $em $this->getDoctrine()->getManager();
  8725.         $currentDate = new \DateTime(date('y-m-d'));
  8726.         $session $request->getSession();
  8727.         $token $session->get(UserConstants::USER_TOKEN);
  8728.         $employeeId $session->get(UserConstants::USER_EMPLOYEE_ID);
  8729.         $planningItemId $session->get(UserConstants::USER_CURRENT_PLANNING_ITEM_ID);
  8730.         $attendanceData $em->getRepository('ApplicationBundle:EmployeeAttendance');
  8731.         $currentStatus HumanResource::getCurrentStatusFromDb($attendanceData$employeeId$currentDate);
  8732.         $providedToken $request->headers->get('auth-token');
  8733.         if (empty($providedToken) || $providedToken !== $token) {
  8734.             return new JsonResponse([
  8735.                 'status' => 'error',
  8736.                 'message' => 'Token not match or missing',
  8737.             ], 401);
  8738.         }
  8739.         $planningItemDetails $em->getRepository(PlanningItem::class)->createQueryBuilder('p')
  8740.             ->select('p.itemAlias')
  8741.             ->where('p.id = :planningItemId')
  8742.             ->setParameter('planningItemId'$planningItemId)
  8743.             ->getQuery()
  8744.             ->getResult();
  8745.         // Check if "data" key exists and contains "in" times
  8746.         if (empty($currentStatus["data"]["in"])) {
  8747.             return new JsonResponse([
  8748. //                'message' => 'No attendance data available',
  8749.                 'currentStatus' => $currentStatus,
  8750.                 'totalWorkingTime' => '00:00:00'
  8751.             ]);
  8752.         }
  8753.         $totalSeconds 0;
  8754.         for ($i 0$i count($currentStatus["data"]["in"]); $i++) {
  8755.             $inTime $currentStatus["data"]["in"][$i];
  8756.             // Check if "out" time exists for this "in" time
  8757.             if (!isset($currentStatus["data"]["out"][$i])) {
  8758.                 continue; // Skip this entry if there is no out time
  8759.             }
  8760.             $outTime $currentStatus["data"]["out"][$i];
  8761.             // Calculate the difference
  8762.             $totalSeconds += ($outTime $inTime);
  8763.         }
  8764.         // If no valid time pairs were found, return 00:00:00
  8765. //        if ($totalSeconds == 0) {
  8766. //            return new JsonResponse([
  8767. //                'message' => 'No complete in-out records found',
  8768. //                'totalWorkingTime' => '00:00:00'
  8769. //            ]);
  8770. //        }
  8771.         // Convert total seconds to hours, minutes, and seconds
  8772.         $hours floor($totalSeconds 3600);
  8773.         $minutes floor(($totalSeconds 3600) / 60);
  8774.         $seconds $totalSeconds 60;
  8775.         $totalWorkingTime sprintf("%02d:%02d:%02d"$hours$minutes$seconds);
  8776.         return new JsonResponse([
  8777.             'taskName' => isset($planningItemDetails[0]) ? $planningItemDetails[0]['itemAlias'] : '',
  8778.             'currentStatus' => $currentStatus,
  8779.             'totalWorkingTime' => $totalWorkingTime,
  8780.         ]);
  8781.     }
  8782. //    public function getEmployeeDataAction(Request $request)
  8783. //    {
  8784. //        $em = $this->getDoctrine()->getManager();
  8785. //        $session = $request->getSession();
  8786. //        $employeeId = $session->get(UserConstants::USER_EMPLOYEE_ID);
  8787. //
  8788. //
  8789. //        $employeeDetails = $em->getRepository('ApplicationBundle:EmployeeDetails')->createQueryBuilder('E')
  8790. //            ->select('E.firstname', 'E.lastname', 'E.nid', 'E.tin','E.image', 'P.positionName')
  8791. //            ->addSelect('A.current_balance')
  8792. //            ->leftJoin('ApplicationBundle:SysDepartmentPosition', 'P', 'WITH', 'E.desg = P.positionId')
  8793. //            ->leftJoin('ApplicationBundle:Employee', 'EMP', 'WITH', 'EMP.employeeId = E.id')
  8794. //            ->leftJoin('ApplicationBundle:AccAccountsHead', 'A', 'WITH', 'EMP.accountsHeadId = A.accountsHeadId')
  8795. //            ->where('E.id = :employeeId')
  8796. //            ->setParameter('employeeId', $employeeId)
  8797. //            ->getQuery()
  8798. //            ->getResult();
  8799. //
  8800. //        return new JsonResponse($employeeDetails[0]);
  8801. //    }
  8802. //    public function getEmployeeDataAction(Request $request)
  8803. //    {
  8804. //        $em = $this->getDoctrine()->getManager();
  8805. //        $session = $request->getSession();
  8806. //        $employeeId = $session->get(UserConstants::USER_EMPLOYEE_ID);
  8807. //        $image = $session->get(UserConstants::USER_IMAGE);
  8808. //        $absoluteUrl = $this->generateUrl('dashboard', [], UrlGenerator::ABSOLUTE_URL);
  8809. //
  8810. //        $employeeDetails = $em->getRepository('ApplicationBundle:EmployeeDetails')->createQueryBuilder('E')
  8811. //            ->select('E.firstname', 'E.lastname', 'E.nid', 'E.tin', 'E.image', 'P.positionName')
  8812. //            ->addSelect('A.current_balance')
  8813. //            ->leftJoin('ApplicationBundle:SysDepartmentPosition', 'P', 'WITH', 'E.desg = P.positionId')
  8814. //            ->leftJoin('ApplicationBundle:Employee', 'EMP', 'WITH', 'EMP.employeeId = E.id')
  8815. //            ->leftJoin('ApplicationBundle:AccAccountsHead', 'A', 'WITH', 'EMP.accountsHeadId = A.accountsHeadId')
  8816. //            ->where('E.id = :employeeId')
  8817. //            ->setParameter('employeeId', $employeeId)
  8818. //            ->getQuery()
  8819. //            ->getResult();
  8820. //
  8821. //        // If image is null or empty, assign empty string
  8822. //        if (empty($employeeDetails['image'])) {
  8823. //            $employeeDetails['image'] =  $image;
  8824. //        }
  8825. //
  8826. //        return new JsonResponse($employeeDetails);
  8827. //    }
  8828.     public function getEmployeeDataAction(Request $request)
  8829.     {
  8830.         $em $this->getDoctrine()->getManager();
  8831.         $session $request->getSession();
  8832.         $employeeId $session->get(UserConstants::USER_EMPLOYEE_ID);
  8833.         $image $session->get(UserConstants::USER_IMAGE);
  8834.         $absoluteUrl $this->generateUrl('dashboard', [], UrlGenerator::ABSOLUTE_URL);
  8835.         $userImage $session->get(UserConstants::USER_IMAGE);
  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.             ->getOneOrNullResult(\Doctrine\ORM\Query::HYDRATE_ARRAY); // Only one employee expected
  8846.         if (!$employeeDetails) {
  8847.             return new JsonResponse(['error' => 'Employee not found'], 404);
  8848.         }
  8849.         // If image is missing, fallback to session image
  8850.         if (empty($employeeDetails['image'])) {
  8851.             $employeeDetails['image'] = $image;
  8852.         }
  8853.         // If image is still available, prefix it with absolute URL
  8854.         if (!empty($employeeDetails['image'])) {
  8855.             $employeeDetails['image_url'] = $absoluteUrl '' $userImage;
  8856.         } else {
  8857.             $employeeDetails['image_url'] = ''// no image
  8858.         }
  8859.         return new JsonResponse($employeeDetails);
  8860.     }
  8861.     public function updateEmployeeDataForAppAction(Request $request)
  8862.     {
  8863.         $em $this->getDoctrine()->getManager();
  8864.         $session $request->getSession();
  8865.         $employeeId $session->get(UserConstants::USER_EMPLOYEE_ID);
  8866.         $employeeDetails $em->getRepository('ApplicationBundle:EmployeeDetails')->find($employeeId);
  8867.         if ($request->isMethod('POST')) {
  8868.             $firstname $request->request->get('firstname');
  8869.             $lastname $request->request->get('lastname');
  8870.             $nid $request->request->get('nid');
  8871.             $tin $request->request->get('tin');
  8872.             if ($firstname !== null) {
  8873.                 $employeeDetails->setFirstName($firstname);
  8874.             }
  8875.             if ($lastname !== null) {
  8876.                 $employeeDetails->setLastName($lastname);
  8877.             }
  8878.             if ($nid !== null) {
  8879.                 $employeeDetails->setNid($nid);
  8880.             }
  8881.             if ($tin !== null) {
  8882.                 $employeeDetails->setTin($tin);
  8883.             }
  8884.             $em->flush();
  8885.             return new JsonResponse(['success' => true]);
  8886.         }
  8887.         return new JsonResponse(['success' => false'message' => 'Invalid request method']);
  8888.     }
  8889. //    public function updateEmployeeDataForAppAction(Request $request){
  8890. //        $em = $this->getDoctrine()->getManager();
  8891. //        $session = $request->getSession();
  8892. //        $employeeId = $session->get(UserConstants::USER_EMPLOYEE_ID);
  8893. //        $employeeDetails = $em->getRepository('ApplicationBundle:EmployeeDetails')->find($employeeId);
  8894. //
  8895. //        if ($request->isMethod('POST')) {
  8896. //            $employeeDetails->setFirstName(($request->request->get('firstname',$employeeDetails->getFirstName())));
  8897. //            $employeeDetails->setLastName($request->request->get('lastname',$employeeDetails->getLastName()));
  8898. //            $employeeDetails->setNid($request->request->get('nid'),$employeeDetails->getNid());
  8899. //            $employeeDetails->setTin($request->request->get('tin'),$employeeDetails->getTin());
  8900. //
  8901. //            $em->flush(); //
  8902. //
  8903. //            return new JsonResponse(['success' => true]);
  8904. //        }
  8905. //
  8906. //
  8907. //    }
  8908.     public function leaveApplicationListForAppAction(Request $request)
  8909.     {
  8910.         $em $this->getDoctrine()->getManager();
  8911.         $session $request->getSession();
  8912.         $employeeId $session->get(UserConstants::USER_EMPLOYEE_ID);
  8913.         $leaveType HumanResourceConstant::$LeaveType;
  8914.         $approvalStatus GeneralConstant::$approvalAction;
  8915.         $leaveCategory HumanResourceConstant::$leavCategory;
  8916.         // Get page and limit from request (default: page=1, limit=10)
  8917.         $page max((int)$request->query->get('page'1), 1);
  8918.         $limit max((int)$request->query->get('limit'10), 1);
  8919.         $offset = ($page 1) * $limit;
  8920.         // Get total count
  8921.         $total $em->getRepository('ApplicationBundle:EmployeeLeaveApplication')
  8922.             ->createQueryBuilder('L')
  8923.             ->select('COUNT(L.employeeLeaveApplicationId)')
  8924.             ->where('L.employeeId = :employeeId')
  8925.             ->setParameter('employeeId'$employeeId)
  8926.             ->getQuery()
  8927.             ->getSingleScalarResult();
  8928.         // Get paginated results
  8929.         $leaveRecords $em->getRepository('ApplicationBundle:EmployeeLeaveApplication')
  8930.             ->createQueryBuilder('L')
  8931.             ->select(
  8932.                 'L.documentHash',
  8933.                 'L.employeeLeaveApplicationId',
  8934.                 'L.leaveStartDate',
  8935.                 'L.leaveEndDate',
  8936.                 'L.leaveTypeId',
  8937.                 'L.leaveCategory',
  8938.                 'L.approved',
  8939.                 'L.createdAt',
  8940.                 'L.alternateDate',
  8941.                 'L.leaveComment',
  8942.                 'L.createdAt',
  8943.                 'L.approved_by'
  8944.             )
  8945.             ->where('L.employeeId = :employeeId')
  8946.             ->setParameter('employeeId'$employeeId)
  8947.             ->setFirstResult($offset)
  8948.             ->setMaxResults($limit)
  8949.             ->getQuery()
  8950.             ->getResult();
  8951.         // Format the results
  8952.         $formattedData = [];
  8953.         foreach ($leaveRecords as $leave) {
  8954.             $formattedData[] = [
  8955.                 'documentHash' => $leave['documentHash'],
  8956.                 'employeeLeaveApplicationId' => $leave['employeeLeaveApplicationId'],
  8957.                 'leaveStartDate' => $leave['leaveStartDate'] ? $leave['leaveStartDate']->getTimestamp() : 0,
  8958.                 'leaveEndDate' => $leave['leaveEndDate'] ? $leave['leaveEndDate']->getTimestamp() : 0,
  8959.                 'leaveType' => $leaveType[$leave['leaveTypeId']] ?? 'Unknown',
  8960.                 'leaveCategory' => $leaveCategory[$leave['leaveCategory']] ?? 'Unknown',
  8961.                 'approved' => $approvalStatus[$leave['approved']] ?? 'Unknown',
  8962.                 'createdAt' => $leave['createdAt'] ? $leave['createdAt']->getTimestamp() : 0,
  8963.                 'alternateDate' => $leave['alternateDate'] ? $leave['alternateDate']->getTimestamp() : 0,
  8964.                 'note' => $leave['leaveComment'] ? $leave['leaveComment'] : '',
  8965.                 'appliedOn' => $leave['createdAt'] ? $leave['createdAt']->getTimestamp() : 0,
  8966.                 'approvedBy' => $leave['approved_by'] ? $leave['approved_by'] : 'automatically approved',
  8967.             ];
  8968.         }
  8969.         // Final response with pagination meta
  8970.         return new JsonResponse([
  8971.             'CurrentPage' => $page,
  8972.             'limit' => $limit,
  8973.             'total' => (int)$total,
  8974.             'data' => $formattedData,
  8975.         ]);
  8976.     }
  8977.     public function PublicProfilePageAction(Request $request)
  8978.     {
  8979.         return new JsonResponse(['success' => true]);
  8980.     }
  8981.     public function leaveSettingsAction(Request $request)
  8982.     {
  8983.         $em $this->getDoctrine()->getManager();
  8984.         if ($request->isMethod('POST')) {
  8985.             $ids $request->request->get('id', []);
  8986.             $leaveTitles $request->request->get('leaveTitle', []);
  8987.             $carryForwardTypes $request->request->get('carryForwardType', []);
  8988.             $carryForwardQtys $request->request->get('number', []);
  8989.             $totalLeaves $request->request->get('totalLeave', []);
  8990.             $resetFreqTypes $request->request->get('resetFrequencyType', []);
  8991.             $resetFreqQtys $request->request->get('resetFrequencyQty', []);
  8992.             $additionConditions $request->request->get('additionCondition', []);
  8993.             $additionDurations $request->request->get('additionConditionDuration', []);
  8994.             for ($i 0$i count($leaveTitles); $i++) {
  8995.                 if (
  8996.                     isset(
  8997.                         $carryForwardTypes[$i],
  8998.                         $carryForwardQtys[$i],
  8999.                         $totalLeaves[$i],
  9000.                         $resetFreqTypes[$i],
  9001.                         $resetFreqQtys[$i],
  9002.                         $additionConditions[$i],
  9003.                         $additionDurations[$i]
  9004.                     )
  9005.                 ) {
  9006.                     $id $ids[$i] ?? null;
  9007.                     $leaveSetting null;
  9008.                     if ($id) {
  9009.                         $leaveSetting $em->getRepository('ApplicationBundle:LeaveSettings')->find($id);
  9010.                     }
  9011.                     if (!$leaveSetting) {
  9012.                         $leaveSetting = new LeaveSettings();
  9013.                     }
  9014.                     $leaveSetting->setLeaveTitle($leaveTitles[$i]);
  9015.                     $leaveSetting->setCarryForwardType((int)$carryForwardTypes[$i]);
  9016.                     $leaveSetting->setCarryForwardQty((int)$carryForwardQtys[$i]);
  9017.                     $leaveSetting->setTotalLeave((int)$totalLeaves[$i]);
  9018.                     $leaveSetting->setResetFrequencyType((int)$resetFreqTypes[$i]);
  9019.                     $leaveSetting->setResetFrequencyQty((int)$resetFreqQtys[$i]);
  9020.                     $leaveSetting->setAdditionCondition((int)$additionConditions[$i]);
  9021.                     $leaveSetting->setAdditionConditionDuration((int)$additionDurations[$i]);
  9022.                     $em->persist($leaveSetting);
  9023.                 }
  9024.             }
  9025.             $em->flush();
  9026.             $this->addFlash('success''Leave settings saved successfully!');
  9027.             return $this->redirectToRoute('leave_settings_list');
  9028.         }
  9029.         $defaultLeaveType HumanResourceConstant::$defaultLeaveType;
  9030.         $savedLeaveSettings $em->getRepository('ApplicationBundle:LeaveSettings')->findAll();
  9031.         $useDefaultLeave count($savedLeaveSettings) === 0;
  9032.         $leaveSettings array_map(function ($setting) {
  9033.             return [
  9034.                 'id' => $setting->getId(),
  9035.                 'leaveTitle' => $setting->getLeaveTitle(),
  9036.                 'carryForwardType' => $setting->getCarryForwardType(),
  9037.                 'carryForwardQty' => $setting->getCarryForwardQty(),
  9038.                 'totalLeave' => $setting->getTotalLeave(),
  9039.                 'resetFrequencyType' => $setting->getResetFrequencyType(),
  9040.                 'resetFrequencyQty' => $setting->getResetFrequencyQty(),
  9041.                 'additionCondition' => $setting->getAdditionCondition(),
  9042.                 'additionConditionDuration' => $setting->getAdditionConditionDuration(),
  9043.             ];
  9044.         }, $savedLeaveSettings);
  9045.         return $this->render('ApplicationBundle:pages/human_resource/input_forms:leave_settings.html.twig', [
  9046.             'page_title' => 'Leave Settings',
  9047.             'defaultLeaveType' => $defaultLeaveType,
  9048.             'leaveSettings' => $leaveSettings,
  9049.             'useDefaultLeave' => $useDefaultLeave,
  9050.         ]);
  9051.     }
  9052.     public function leavePolicyListAction()
  9053.     {
  9054.         return $this->render("ApplicationBundle:pages/human_resource/list:leaveApplicationSettingsList.html.twig", array(
  9055.             'page_title' => 'Leave PolicyList',
  9056.         ));
  9057.     }
  9058. }